This commit is contained in:
2019-06-11 00:06:18 +00:00
parent 8dfad9670e
commit ecd4865fb9
2 changed files with 75 additions and 6 deletions

View File

@@ -157,7 +157,9 @@
</template>
<script>
/* xeslint-disable */
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
/* Xeslint-disable */
////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////
//
@@ -395,6 +397,7 @@ export default {
return;
}
//enable / disable save button
var canSave = val.dirty && val.valid && !val.readOnly;
if (canSave) {
this.$gzevent.$emit("menu-enable-item", "inventory-widget-edit:save");
@@ -404,6 +407,20 @@ export default {
"inventory-widget-edit:save"
);
}
//enable / disable duplicate button
var canDuplicate = !val.dirty && val.valid && !val.readOnly;
if (canDuplicate) {
this.$gzevent.$emit(
"menu-enable-item",
"inventory-widget-edit:duplicate"
);
} else {
this.$gzevent.$emit(
"menu-disable-item",
"inventory-widget-edit:duplicate"
);
}
},
deep: true
}
@@ -411,6 +428,9 @@ export default {
computed: {
canSave: function() {
return this.formState.valid && this.formState.dirty;
},
canDuplicate: function() {
return this.formState.valid && !this.formState.dirty;
}
},
methods: {
@@ -548,11 +568,34 @@ export default {
});
},
duplicate() {
//only if not dirty
//check rights
//duplicate
//navigate to new record
throw "T$EST";
if (this.canDuplicate && this.$route.params.id != 0) {
this.formState.loading = true;
var vm = this;
var url = "Widget/duplicate/" + this.$route.params.id;
//clear any errors vm might be around from previous submit
this.$gzform.deleteAllErrorBoxErrors(this);
this.$gzapi
.duplicate(url)
.then(res => {
// debugger;
vm.formState.loading = false;
if (res.error != undefined) {
vm.formState.serverError = res.error;
vm.$gzform.setErrorBoxErrors(vm);
} else {
//Navigate to new record
bugbug: this is not navigating, only changing the url in the location bar??
vm.$router.push(
vm.$gzapi.replaceAfterLastSlash(vm.$route.fullPath, res.data.id)
);
}
})
.catch(function handleDuplicateError(error) {
vm.formState.loading = false;
vm.$gzHandleFormError(error, vm);
});
}
}
}
};