HUGE REFACTOR / CLEANUP
if there is a issue it's probably something in here that was changed
This commit is contained in:
@@ -69,32 +69,23 @@
|
||||
</v-overlay>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/* Xeslint-disable */
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//THIS FORM IS CREATE ONLY
|
||||
//no delete, no duplicate, no fetch, just create or leave
|
||||
//
|
||||
const FORM_KEY = "inv-part-adjustment";
|
||||
const API_BASE_URL = "part-inventory/";
|
||||
|
||||
export default {
|
||||
async created() {
|
||||
let vm = this;
|
||||
|
||||
const vm = this;
|
||||
try {
|
||||
await initForm(vm);
|
||||
|
||||
vm.obj.partId = window.$gz.util.stringToIntOrNull(
|
||||
vm.$route.params.partId
|
||||
);
|
||||
vm.obj.partWarehouseId = window.$gz.util.stringToIntOrNull(
|
||||
vm.$route.params.partWarehouseId
|
||||
);
|
||||
|
||||
vm.rights = window.$gz.role.getRights(window.$gz.type.PartInventory);
|
||||
vm.formState.readOnly = !vm.rights.change;
|
||||
window.$gz.eventBus.$on("menu-click", clickHandler);
|
||||
@@ -105,7 +96,6 @@ export default {
|
||||
dirty: false,
|
||||
valid: true
|
||||
});
|
||||
|
||||
generateMenu(vm);
|
||||
} catch (error) {
|
||||
window.$gz.errorHandler.handleFormError(error, vm);
|
||||
@@ -151,23 +141,19 @@ export default {
|
||||
ayaType: window.$gz.type.PartInventory
|
||||
};
|
||||
},
|
||||
//WATCHERS
|
||||
watch: {
|
||||
formState: {
|
||||
handler: function(val) {
|
||||
//,oldval is available here too if necessary
|
||||
if (this.formState.loading) {
|
||||
return;
|
||||
}
|
||||
|
||||
//enable / disable save button
|
||||
if (val.dirty && val.valid && !val.readOnly) {
|
||||
window.$gz.eventBus.$emit("menu-enable-item", FORM_KEY + ":save");
|
||||
} else {
|
||||
window.$gz.eventBus.$emit("menu-disable-item", FORM_KEY + ":save");
|
||||
}
|
||||
|
||||
//enable / disable duplicate / new button
|
||||
if (!val.dirty && val.valid && !val.readOnly) {
|
||||
window.$gz.eventBus.$emit(
|
||||
"menu-enable-item",
|
||||
@@ -208,7 +194,7 @@ export default {
|
||||
}
|
||||
},
|
||||
async submit() {
|
||||
let vm = this;
|
||||
const vm = this;
|
||||
if (vm.canSave == false) {
|
||||
return;
|
||||
}
|
||||
@@ -218,17 +204,12 @@ export default {
|
||||
vm: vm,
|
||||
loading: true
|
||||
});
|
||||
let url = API_BASE_URL; // + vm.$route.params.recordid;
|
||||
//clear any errors vm might be around from previous submit
|
||||
window.$gz.form.deleteAllErrorBoxErrors(vm);
|
||||
|
||||
let res = await window.$gz.api.post(url, vm.obj);
|
||||
|
||||
const res = await window.$gz.api.post(API_BASE_URL, vm.obj);
|
||||
if (res.error) {
|
||||
vm.formState.serverError = res.error;
|
||||
window.$gz.form.setErrorBoxErrors(vm);
|
||||
} else {
|
||||
//success, no need to be here anymore this is not an update form so navigate backwards since we don't know which list we came from
|
||||
window.$gz.form.setFormState({
|
||||
vm: vm,
|
||||
loading: false,
|
||||
@@ -246,7 +227,6 @@ export default {
|
||||
});
|
||||
}
|
||||
}
|
||||
//end methods
|
||||
}
|
||||
};
|
||||
|
||||
@@ -257,7 +237,7 @@ async function clickHandler(menuItem) {
|
||||
if (!menuItem) {
|
||||
return;
|
||||
}
|
||||
let m = window.$gz.menu.parseMenuItem(menuItem);
|
||||
const m = window.$gz.menu.parseMenuItem(menuItem);
|
||||
if (m.owner == FORM_KEY && !m.disabled) {
|
||||
switch (m.key) {
|
||||
case "save":
|
||||
@@ -277,7 +257,7 @@ async function clickHandler(menuItem) {
|
||||
//
|
||||
//
|
||||
function generateMenu(vm) {
|
||||
let menuOptions = {
|
||||
const menuOptions = {
|
||||
isMain: false,
|
||||
readOnly: vm.formState.readOnly,
|
||||
icon: "$ayiPeopleCarry",
|
||||
@@ -286,7 +266,6 @@ function generateMenu(vm) {
|
||||
formData: {
|
||||
ayaType: window.$gz.type.PartInventory,
|
||||
recordId: vm.$route.params.recordid,
|
||||
// formCustomTemplateKey: FORM_CUSTOM_TEMPLATE_KEY,
|
||||
recordName: vm.obj.name
|
||||
},
|
||||
menuItems: []
|
||||
@@ -301,9 +280,7 @@ function generateMenu(vm) {
|
||||
vm: vm
|
||||
});
|
||||
}
|
||||
|
||||
menuOptions.menuItems.push({ divider: true, inset: false });
|
||||
|
||||
window.$gz.eventBus.$emit("menu-change", menuOptions);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user