Skip to content

Commit

Permalink
Save+new action for attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
r3-gabriel committed May 19, 2023
1 parent d218917 commit d46c7de
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 6 deletions.
30 changes: 25 additions & 5 deletions www/comps/builder/builderAttribute.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,15 @@ let MyBuilderAttribute = {
<div class="top lower">
<div class="area">
<my-button image="save.png"
@trigger="set"
@trigger="set(false)"
:active="canSave"
:caption="isNew ? capGen.button.create : capGen.button.save"
/>
<my-button image="save_new.png"
@trigger="set(true)"
:active="canSave"
:caption="isNew ? capGen.button.createNew : capGen.button.saveNew"
/>
<my-button image="refresh.png"
@trigger="reset"
:active="hasChanges"
Expand Down Expand Up @@ -108,7 +113,7 @@ let MyBuilderAttribute = {
<td>{{ capApp.usedFor }}</td>
<td>
<div class="row centered gap">
<select v-model="usedFor" :disabled="readonly">
<select v-model="usedFor" :disabled="readonly" @change="changedUsedFor">
<optgroup :label="capGen.standard">
<option value="text" :disabled="!isNew && !isString">{{ capApp.option.text }}</option>
<option value="textarea" :disabled="!isNew && !isString">{{ capApp.option.textarea }}</option>
Expand Down Expand Up @@ -274,7 +279,7 @@ let MyBuilderAttribute = {
readonly: { type:Boolean, required:true },
relation: { type:Object, required:true }
},
emits:['close','next-language'],
emits:['close','next-language','new-record'],
data() {
return {
defaultsOption:'fixed',
Expand Down Expand Up @@ -454,6 +459,10 @@ let MyBuilderAttribute = {
isAttributeUuid,

// actions
changedUsedFor() {
if(!this.isRelationship && this.values.relationshipId !== null)
this.values.relationshipId = null;
},
handleHotkeys(e) {
if(e.ctrlKey && e.key === 's' && this.canSave) {
this.set();
Expand Down Expand Up @@ -487,7 +496,7 @@ let MyBuilderAttribute = {
}
};

this.valuesOrg = JSON.parse(JSON.stringify(this.values));
this.resetOrg();

// set defaults option
switch(this.values.def) {
Expand All @@ -496,6 +505,9 @@ let MyBuilderAttribute = {
case 'GEN_RANDOM_UUID()': this.defaultsOption = 'uuid'; break;
}
},
resetOrg() {
this.valuesOrg = JSON.parse(JSON.stringify(this.values));
},
updateDefaultsOption() {
switch(this.defaultsOption) {
case 'date': this.values.def = 'EXTRACT(EPOCH FROM CURRENT_DATE)'; break;
Expand Down Expand Up @@ -537,7 +549,7 @@ let MyBuilderAttribute = {
this.$root.genericError
);
},
set() {
set(saveAndNew) {
if(this.values.encrypted && !this.canEncrypt)
this.values.encrypted = false;

Expand All @@ -547,6 +559,14 @@ let MyBuilderAttribute = {
],true).then(
() => {
this.$root.schemaReload(this.module.id);

if(saveAndNew) {
this.$emit('new-record');
this.values.id = null;
this.values.name = '';
this.resetOrg();
return;
}
this.$emit('close');
},
this.$root.genericError
Expand Down
3 changes: 2 additions & 1 deletion www/comps/builder/builderRelation.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ let MyBuilderRelation = {
v-if="attributeIdEdit !== false"
@close="attributeIdEdit = false"
@nextLanguage="$emit('next-language')"
@new-record="attributeIdEdit = null"
:attributeId="attributeIdEdit"
:builderLanguage="builderLanguage"
:readonly="readonly"
Expand Down Expand Up @@ -555,7 +556,7 @@ let MyBuilderRelation = {
emits:['next-language'],
watch:{
relation:{
handler:function() { this.reset(); },
handler() { this.reset(); },
immediate:true
}
},
Expand Down
1 change: 1 addition & 0 deletions www/langs/REPLACE_BY_BUILD/de_de
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"copy":"Kopieren",
"copyClipboard":"In Zwischenablage kopieren",
"create":"Erstellen",
"createNew":"Erstellen+Neu",
"delete":"Löschen",
"deleteHint":"Datensatz dauerhaft löschen",
"deleteSelected":"Ausgewählte löschen",
Expand Down
1 change: 1 addition & 0 deletions www/langs/REPLACE_BY_BUILD/en_us
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"copy":"Copy",
"copyClipboard":"Copy to clipboard",
"create":"Create",
"createNew":"Create+New",
"delete":"Delete",
"deleteHint":"Permanently delete record",
"deleteSelected":"Delete selected",
Expand Down
1 change: 1 addition & 0 deletions www/langs/REPLACE_BY_BUILD/it_it
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"copy":"Copy",
"copyClipboard":"Copy to clipboard",
"create":"Crea",
"createNew":"Crea+Nuovo",
"delete":"Cancella",
"deleteHint":"Cancella il record definitivamente",
"deleteSelected":"Cancella selezionati",
Expand Down
1 change: 1 addition & 0 deletions www/langs/REPLACE_BY_BUILD/ro_ro
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"copy":"Copy",
"copyClipboard":"Copy to clipboard",
"create":"Crează",
"createNew":"Crează+Nou",
"delete":"Șterge",
"deleteHint":"Șterge definitiv înregistrarea selectată",
"deleteSelected":"Șterge selecția",
Expand Down

0 comments on commit d46c7de

Please sign in to comment.