Prevent double saving on entity creation
This commit is contained in:
parent
2a6d2fe693
commit
bd1286abba
|
|
@ -55,7 +55,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div slot="footer">
|
<div slot="footer">
|
||||||
<a class="button button--primary" data-cy="modal-save-button" v-on:click="save">Speichern</a>
|
<a class="button button--primary" data-cy="modal-save-button" :class="{'button--disabled': disableSave}" v-on:click="save">Speichern</a>
|
||||||
<a class="button" v-on:click="$emit('hide')">Abbrechen</a>
|
<a class="button" v-on:click="$emit('hide')">Abbrechen</a>
|
||||||
</div>
|
</div>
|
||||||
</modal>
|
</modal>
|
||||||
|
|
@ -85,6 +85,10 @@
|
||||||
'show-task-selection': {
|
'show-task-selection': {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false
|
default: false
|
||||||
|
},
|
||||||
|
'disable-save': {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -237,11 +241,13 @@
|
||||||
this.localContentBlock.contents.splice(index, 1, el);
|
this.localContentBlock.contents.splice(index, 1, el);
|
||||||
},
|
},
|
||||||
save() {
|
save() {
|
||||||
if (!this.localContentBlock.title) {
|
if (!this.disableSave) {
|
||||||
this.error = true;
|
if (!this.localContentBlock.title) {
|
||||||
return false;
|
this.error = true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
this.$emit('save', this.localContentBlock);
|
||||||
}
|
}
|
||||||
this.$emit('save', this.localContentBlock);
|
|
||||||
},
|
},
|
||||||
setContentBlockType(checked, localContentBlock) {
|
setContentBlockType(checked, localContentBlock) {
|
||||||
this.localContentBlock.isAssignment = checked;
|
this.localContentBlock.isAssignment = checked;
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
:show-task-selection="true"
|
:show-task-selection="true"
|
||||||
@save="saveContentBlock"
|
@save="saveContentBlock"
|
||||||
@hide="hideModal"
|
@hide="hideModal"
|
||||||
|
:disable-save="saving"
|
||||||
></contents-form>
|
></contents-form>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
@ -25,6 +26,7 @@
|
||||||
this.$store.dispatch('hideModal');
|
this.$store.dispatch('hideModal');
|
||||||
},
|
},
|
||||||
saveContentBlock(contentBlock) {
|
saveContentBlock(contentBlock) {
|
||||||
|
this.saving = true;
|
||||||
this.$apollo.mutate({
|
this.$apollo.mutate({
|
||||||
mutation: NEW_CONTENT_BLOCK_MUTATION,
|
mutation: NEW_CONTENT_BLOCK_MUTATION,
|
||||||
variables: {
|
variables: {
|
||||||
|
|
@ -45,6 +47,7 @@
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
|
this.saving = false;
|
||||||
this.hideModal();
|
this.hideModal();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -57,7 +60,8 @@
|
||||||
contents: [
|
contents: [
|
||||||
{}
|
{}
|
||||||
]
|
]
|
||||||
}
|
},
|
||||||
|
saving: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
:show-task-selection="false"
|
:show-task-selection="false"
|
||||||
@save="saveEntry"
|
@save="saveEntry"
|
||||||
block-type="RoomEntry"
|
block-type="RoomEntry"
|
||||||
|
:disable-save="saving"
|
||||||
@hide="hideModal"
|
@hide="hideModal"
|
||||||
></contents-form>
|
></contents-form>
|
||||||
</template>
|
</template>
|
||||||
|
|
@ -24,7 +25,8 @@
|
||||||
entry: {
|
entry: {
|
||||||
title: '',
|
title: '',
|
||||||
contents: []
|
contents: []
|
||||||
}
|
},
|
||||||
|
saving: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -36,6 +38,7 @@
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
saveEntry(entry) {
|
saveEntry(entry) {
|
||||||
|
this.saving = true;
|
||||||
this.$apollo.mutate({
|
this.$apollo.mutate({
|
||||||
mutation: NEW_ROOM_ENTRY_MUTATION,
|
mutation: NEW_ROOM_ENTRY_MUTATION,
|
||||||
variables: {
|
variables: {
|
||||||
|
|
@ -62,6 +65,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
|
this.saving = false;
|
||||||
this.hideModal();
|
this.hideModal();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue