From ed1160bd60015be9fc0ac4652b7af5fc0e1e73a7 Mon Sep 17 00:00:00 2001 From: Gabriel Herbert Date: Tue, 27 Jun 2023 19:02:05 +0200 Subject: [PATCH] Warning against 1:n joins in form editor --- www/comps/builder/builderForm.css | 24 ++++++++++++++++++++++++ www/comps/builder/builderForm.js | 25 ++++++++++++++++++++++++- www/langs/REPLACE_BY_BUILD/de_de | 2 ++ www/langs/REPLACE_BY_BUILD/en_us | 2 ++ www/langs/REPLACE_BY_BUILD/it_it | 2 ++ www/langs/REPLACE_BY_BUILD/ro_ro | 2 ++ 6 files changed, 56 insertions(+), 1 deletion(-) diff --git a/www/comps/builder/builderForm.css b/www/comps/builder/builderForm.css index aa130625..69f2430a 100644 --- a/www/comps/builder/builderForm.css +++ b/www/comps/builder/builderForm.css @@ -44,6 +44,30 @@ text-decoration-thickness:4px; } +.builder-form .sidebar .warning{ + margin:6px; + display:flex; + flex-flow:row nowrap; + align-items:center; + gap:6px; + cursor:pointer; +} +.builder-form .sidebar .warning>img{ + width:24px; + margin:2px; + filter:var(--image-filter-error); +} +.builder-form .sidebar .warning>span{ + color:var(--color-error); +} +.builder-form .sidebar .warning:hover>img{ + width:28px; + margin:0px; +} +.builder-form .sidebar .warning:hover>span{ + text-decoration:underline; +} + /* form builder main area */ .builder-form-main{ flex:2 1 auto; diff --git a/www/comps/builder/builderForm.js b/www/comps/builder/builderForm.js index 37406c3e..4e66433f 100644 --- a/www/comps/builder/builderForm.js +++ b/www/comps/builder/builderForm.js @@ -222,6 +222,14 @@ let MyBuilderForm = { :relationId="relationId" /> + +
+ + {{ capApp.warning.joinN1Hint }} +
+

{{ capApp.fields }}

@@ -677,6 +685,19 @@ let MyBuilderForm = { return atr.relationId; }, + hasAny1nJoin:(s) => { + for(let j of s.joins) { + if(j.index === 0) + continue; + + let joinAtr = s.attributeIdMap[j.attributeId]; + + // join via 1:n attribute (outside-in join) + if(s.isAttributeRelationshipN1(joinAtr.content) && joinAtr.relationId === j.relationId) + return true; + } + return false; + }, // simple columnShow: (s) => s.columnIdShow === null ? false : s.columnIdMap[s.columnIdShow], @@ -741,9 +762,11 @@ let MyBuilderForm = { this.fieldMoveList = evt.fieldList; this.fieldMoveIndex = evt.fieldIndex; }, - showMessage(msg) { + showMessage(msg,top,image) { this.$store.commit('dialog',{ + captionTop:top, captionBody:msg, + image:image, buttons:[{ caption:this.capGen.button.close, cancel:true, diff --git a/www/langs/REPLACE_BY_BUILD/de_de b/www/langs/REPLACE_BY_BUILD/de_de index c95ec598..40fbdb1a 100644 --- a/www/langs/REPLACE_BY_BUILD/de_de +++ b/www/langs/REPLACE_BY_BUILD/de_de @@ -824,6 +824,8 @@ "warning":{ "calendarNoDateFromTo":"Kein Attribut ausgewählt für \"Datum von\" oder \"Datum zu\". Beide sind notwendig, damit ein Kalenderfeld arbeiten kann.", "columnNoSubQueryAttribute":"Keine Relation & Attribut ausgewählt für eine Sub-Query-Spalte.", + "joinN1":"Relationen zu verbinden dient der gleichzeitigen Bearbeitung mehrerer, assoziierter Datensätze. Ein Formular kann aber immer nur einen Datensatz je Relation verarbeiten.

Wenn eine 1:n-Beziehung zur Verbindung genutzt wird, können mehrere Datensätze für eine Relation existieren. Falls dies geschieht, zeigt das Formular einen Fehler.

1:n-Beziehungen zu verwenden ist valide, solange der Formularinhalt so gefiltert wird, dass jede Relation maximal 1 Datensatz haben kann.", + "joinN1Hint":"Warnung! 1:n-Verbindung im Formularinhalt erkannt", "queryColumnsNotSet":"Keine angezeigten Spalten. Eine Spalte hinzufügen, um Daten anzuzeigen.", "queryRelationNotSet":"Keine Relation ausgewählt. Feld hat keinen Zugriff auf Daten." }, diff --git a/www/langs/REPLACE_BY_BUILD/en_us b/www/langs/REPLACE_BY_BUILD/en_us index ce498b2e..1771352c 100644 --- a/www/langs/REPLACE_BY_BUILD/en_us +++ b/www/langs/REPLACE_BY_BUILD/en_us @@ -824,6 +824,8 @@ "warning":{ "calendarNoDateFromTo":"No attribute selected for 'date from' or 'date to'. Both are required for a calendar field to work.", "columnNoSubQueryAttribute":"No relation & attribute chosen for a sub query column.", + "joinN1":"Joining relations on a form serves to update multiple, connected records at the same time. However, a form can only handle a single record per relation.

Using a 1:n relationship for a join can lead to multiple records being available on a single relation. If this happens, the form will show an error.

Using 1:n relationships for joins is valid, if the form content is being filtered so that each relation can never have more than 1 record.", + "joinN1Hint":"Warning! 1:n join detected in form content", "queryColumnsNotSet":"No displayed columns. Add any column to show data.", "queryRelationNotSet":"No relation selected. Field has no access to data." }, diff --git a/www/langs/REPLACE_BY_BUILD/it_it b/www/langs/REPLACE_BY_BUILD/it_it index 343b870d..91eacfa1 100644 --- a/www/langs/REPLACE_BY_BUILD/it_it +++ b/www/langs/REPLACE_BY_BUILD/it_it @@ -824,6 +824,8 @@ "warning":{ "calendarNoDateFromTo":"No attribute selected for 'date from' or 'date to'. Both are required for a calendar field to work.", "columnNoSubQueryAttribute":"No relation & attribute chosen for a sub query column.", + "joinN1":"Joining relations on a form serves to update multiple, connected records at the same time. However, a form can only handle a single record per relation.

Using a 1:n relationship for a join can lead to multiple records being available on a single relation. If this happens, the form will show an error.

Using 1:n relationships for joins is valid, if the form content is being filtered so that each relation can never have more than 1 record.", + "joinN1Hint":"Warning! 1:n join detected in form content", "queryColumnsNotSet":"No displayed columns. Add any column to show data.", "queryRelationNotSet":"No relation selected. Field has no access to data." }, diff --git a/www/langs/REPLACE_BY_BUILD/ro_ro b/www/langs/REPLACE_BY_BUILD/ro_ro index 6436cddf..e95b566e 100644 --- a/www/langs/REPLACE_BY_BUILD/ro_ro +++ b/www/langs/REPLACE_BY_BUILD/ro_ro @@ -824,6 +824,8 @@ "warning":{ "calendarNoDateFromTo":"No attribute selected for 'date from' or 'date to'. Both are required for a calendar field to work.", "columnNoSubQueryAttribute":"No relation & attribute chosen for a sub query column.", + "joinN1":"Joining relations on a form serves to update multiple, connected records at the same time. However, a form can only handle a single record per relation.

Using a 1:n relationship for a join can lead to multiple records being available on a single relation. If this happens, the form will show an error.

Using 1:n relationships for joins is valid, if the form content is being filtered so that each relation can never have more than 1 record.", + "joinN1Hint":"Warning! 1:n join detected in form content", "queryColumnsNotSet":"No displayed columns. Add any column to show data.", "queryRelationNotSet":"No relation selected. Field has no access to data." },