This commit is contained in:
2019-04-30 23:26:39 +00:00
parent aba5dc721c
commit 9a51e8c4e8
4 changed files with 34 additions and 17 deletions

View File

@@ -497,6 +497,10 @@ export default {
if (newState.loading != undefined) {
newState.vm.formState.loading = newState.loading;
}
if (newState.readOnly != undefined) {
newState.vm.formState.readOnly = newState.readOnly;
}
});
}
};

View File

@@ -18,6 +18,7 @@
<v-flex xs12 sm6 lg4 xl3 px-2>
<v-text-field
v-model="obj.name"
:readonly="this.formState.readOnly"
clearable
@click:clear="onChange('name')"
:counter="255"
@@ -31,6 +32,7 @@
<v-flex xs12 sm6 lg4 xl3 px-2>
<v-text-field
v-model="obj.serial"
:readonly="this.formState.readOnly"
clearable
@click:clear="onChange('serial')"
:counter="10"
@@ -44,6 +46,7 @@
<v-flex xs12 sm6 lg4 xl3 px-2>
<v-text-field
v-model="obj.count"
:readonly="this.formState.readOnly"
clearable
@click:clear="onChange('count')"
:counter="10"
@@ -60,6 +63,7 @@
<v-flex xs12 sm6 lg4 xl3 px-2>
<v-text-field
v-model="obj.dollarAmount"
:readonly="this.formState.readOnly"
:prefix="this.$gzlocale.formats.currencySymbol"
:label="this.$gzlocale.get('WidgetDollarAmount')"
ref="dollarAmount"
@@ -75,6 +79,7 @@
<gz-date-time-picker
:label="this.$gzlocale.get('WidgetStartDate')"
v-model="obj.startDate"
:readonly="this.formState.readOnly"
ref="startDate"
:error-messages="this.$gzform.serverErrors(this,'startDate')"
@change="onChange('startDate')"
@@ -82,11 +87,12 @@
</v-flex>
<v-flex xs12 sm6 lg4 xl3 px-2>
<gz-date-time-picker
<gz-date-time-picker
:label="this.$gzlocale.get('WidgetEndDate')"
:rules="[this.$gzform.datePrecedence(this,'startDate','endDate')]"
:error-messages="this.$gzform.serverErrors(this,'endDate')"
v-model="obj.endDate"
:readonly="this.formState.readOnly"
ref="endDate"
@change="onChange('endDate')"
></gz-date-time-picker>
@@ -94,6 +100,7 @@
<v-flex xs12 sm6 lg4 xl3 px-2>
<v-checkbox
v-model="obj.active"
:readonly="this.formState.readOnly"
:label="this.$gzlocale.get('Active')"
ref="active"
:error-messages="this.$gzform.serverErrors(this,'active')"
@@ -104,6 +111,7 @@
<v-flex xs12 sm6 lg4 xl3 px-2>
<v-text-field
v-model="obj.roles"
:readonly="this.formState.readOnly"
:label="this.$gzlocale.get('WidgetRoles')"
ref="roles"
:rules="[this.$gzform.integerValid(this,'roles'),this.$gzform.required(this,'roles')]"
@@ -318,7 +326,7 @@ export default {
},
methods: {
onChange(ref) {
if (!this.formState.loading) {
if (!this.formState.loading && !this.formState.readOnly) {
this.$gzform.onChange(this, ref);
}
},
@@ -340,7 +348,8 @@ export default {
vm: vm,
dirty: false,
valid: true,
loading: false
loading: false,
readOnly: res.readOnly ? true : false
});
}
})
@@ -370,18 +379,22 @@ export default {
vm.formState.serverError = res.error;
vm.$gzform.setErrorBoxErrors(vm);
} else {
vm.$gzform.setFormState({
vm: vm,
dirty: false
});
//Logic for detecting if a post or put: if id then it was a post, if no id then it was a put
if (res.id) {
//Handle "post" of new record
vm.obj = res.data;
vm.$gzform.setFormState({
vm: vm,
dirty: false,
readOnly: res.readOnly ? true : false
});
} else {
//Handle "put" of an existing record
vm.obj.concurrencyToken = res.data.concurrencyToken;
vm.$gzform.setFormState({
vm: vm,
dirty: false
});
}
}
})