Skip to content

Commit

Permalink
Warning against 1:n joins in form editor
Browse files Browse the repository at this point in the history
  • Loading branch information
r3-gabriel committed Jun 27, 2023
1 parent 926de7c commit ed1160b
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 1 deletion.
24 changes: 24 additions & 0 deletions www/comps/builder/builderForm.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
25 changes: 24 additions & 1 deletion www/comps/builder/builderForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,14 @@ let MyBuilderForm = {
:relationId="relationId"
/>
<!-- 1:n join warning -->
<div v-if="tabTarget === 'content' && hasAny1nJoin" class="warning"
@click="showMessage(capApp.warning.joinN1,capApp.warning.joinN1Hint,'link2.png')"
>
<img src="images/link2.png" />
<span>{{ capApp.warning.joinN1Hint }}</span>
</div>
<!-- template fields -->
<div class="templates-wrap" v-if="tabTarget === 'content'">
<h2>{{ capApp.fields }}</h2>
Expand Down Expand Up @@ -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],
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions www/langs/REPLACE_BY_BUILD/de_de
Original file line number Diff line number Diff line change
Expand Up @@ -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.<br /><br />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.<br /><br />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."
},
Expand Down
2 changes: 2 additions & 0 deletions www/langs/REPLACE_BY_BUILD/en_us
Original file line number Diff line number Diff line change
Expand Up @@ -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.<br /><br />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.<br /><br />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."
},
Expand Down
2 changes: 2 additions & 0 deletions www/langs/REPLACE_BY_BUILD/it_it
Original file line number Diff line number Diff line change
Expand Up @@ -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.<br /><br />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.<br /><br />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."
},
Expand Down
2 changes: 2 additions & 0 deletions www/langs/REPLACE_BY_BUILD/ro_ro
Original file line number Diff line number Diff line change
Expand Up @@ -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.<br /><br />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.<br /><br />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."
},
Expand Down

0 comments on commit ed1160b

Please sign in to comment.