This commit is contained in:
2019-12-06 20:48:51 +00:00
parent 674d839cd7
commit 0859846fbf
2 changed files with 73 additions and 79 deletions

View File

@@ -48,27 +48,30 @@
<v-card-subtitle>
{{ item.key }}
</v-card-subtitle>
<v-checkbox
v-model="item.visible"
:label="lt('FormFieldVisible')"
:ref="item.key"
:disabled="item.stockRequired"
@change="visibleChanged(item)"
></v-checkbox>
<v-checkbox
v-model="item.required"
:label="lt('FormFieldEntryRequired')"
:disabled="item.stockRequired"
@change="requiredChanged(item)"
></v-checkbox>
<v-select
v-if="item.custom"
v-model="item.type"
:items="pickLists.formFieldDataTypes"
item-text="name"
item-value="id"
:label="lt('FormfieldDataType')"
></v-select>
<v-card-text>
<v-checkbox
v-model="item.visible"
:label="lt('FormFieldVisible')"
:ref="item.key"
:disabled="item.stockRequired"
@change="visibleChanged(item)"
></v-checkbox>
<v-checkbox
v-model="item.required"
:label="lt('FormFieldEntryRequired')"
:disabled="item.stockRequired"
@change="requiredChanged(item)"
></v-checkbox>
<v-select
v-if="item.custom"
v-model="item.type"
:items="pickLists.formFieldDataTypes"
item-text="name"
item-value="id"
:label="lt('FormfieldDataType')"
@change="dataTypeChanged(item)"
></v-select>
</v-card-text>
</v-card>
</v-col>
</template>
@@ -82,6 +85,9 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
/* Xeslint-disable */
////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
//NOTE: This is a simple form with no need for business rules or validation so stripped out any extraneous code related to all that
//
const FORM_KEY = "customize";
const API_BASE_URL = "FormCustom/";
export default {
@@ -117,6 +123,8 @@ export default {
//NOTE: this would normally be in getDataFromAPI but this form doesn't really need that function so doing it here
//modify the menu as necessary
generateMenu(this, false); //default is never read only and passing in this vm
//init disable save button so it can be enabled only on edit to show dirty form
window.$gz.eventBus.$emit("menu-disable-item", FORM_KEY + ":save");
},
data() {
return {
@@ -135,61 +143,41 @@ export default {
},
formState: {
ready: false,
dirty: false,
valid: true,
readOnly: false,
loading: true,
errorBoxMessage: null,
appError: null,
serverError: {}
errorBoxMessage: null
},
rights: window.$gz.role.defaultRightsObject(),
tempTemplate: window.$gz.store.state.formCustomTemplate["widget"]
rights: window.$gz.role.getRights(window.$gz.type.FormCustom)
//,tempTemplate: window.$gz.store.state.formCustomTemplate["widget"]
};
},
//WATCHERS
watch: {
formState: {
handler: function(val) {
//,oldval is available here too if necessary
if (this.formState.loading) {
return;
}
// //WATCHERS
// watch: {
// formState: {
// handler: function(val) {
// //,oldval is available here too if necessary
// if (this.formState.loading) {
// return;
// }
//enable / disable save button
var canSave = val.dirty && val.valid && !val.readOnly;
if (canSave) {
window.$gz.eventBus.$emit("menu-enable-item", FORM_KEY + ":save");
} else {
window.$gz.eventBus.$emit("menu-disable-item", FORM_KEY + ":save");
}
//enable / disable duplicate button
var canDuplicate = !val.dirty && val.valid && !val.readOnly;
if (canDuplicate) {
window.$gz.eventBus.$emit(
"menu-enable-item",
FORM_KEY + ":duplicate"
);
} else {
window.$gz.eventBus.$emit(
"menu-disable-item",
FORM_KEY + ":duplicate"
);
}
},
deep: true
}
},
computed: {
canSave: function() {
return this.formState.valid && this.formState.dirty;
},
canDuplicate: function() {
return this.formState.valid && !this.formState.dirty;
}
},
components: {},
// //enable / disable save button
// var canSave = val.dirty && val.valid && !val.readOnly;
// if (canSave) {
// window.$gz.eventBus.$emit("menu-enable-item", FORM_KEY + ":save");
// } else {
// window.$gz.eventBus.$emit("menu-disable-item", FORM_KEY + ":save");
// }
// },
// deep: true
// }
// },
// computed: {
// canSave: function() {
// return this.formState.valid && this.formState.dirty;
// },
// canDuplicate: function() {
// return this.formState.valid && !this.formState.dirty;
// }
// },
// components: {},
methods: {
lt: function(ltkey) {
return window.$gz.locale.get(ltkey);
@@ -199,16 +187,26 @@ export default {
if (item.required && item.visible == false) {
item.required = false;
}
enableSaveButton();
},
requiredChanged: function(item) {
//Note: stock items can't be changed so no need to take that into account
if (item.required && item.visible == false) {
item.visible = true;
}
enableSaveButton();
},
dataTypeChanged: function(item) {
//nothing to scan here just set form dirty
enableSaveButton();
}
}
};
function enableSaveButton() {
window.$gz.eventBus.$emit("menu-enable-item", FORM_KEY + ":save");
}
//////////////////////
//
//