This commit is contained in:
@@ -52,12 +52,12 @@
|
|||||||
<v-row>
|
<v-row>
|
||||||
<v-col cols="12" sm="6" lg="4" xl="3">
|
<v-col cols="12" sm="6" lg="4" xl="3">
|
||||||
<v-text-field
|
<v-text-field
|
||||||
v-model="objName"
|
v-model="obj.name"
|
||||||
:readonly="this.formState.readOnly"
|
:readonly="this.formState.readOnly"
|
||||||
clearable
|
clearable
|
||||||
@click:clear="onChange('name')"
|
@click:clear="onChange('name')"
|
||||||
:counter="255"
|
:counter="255"
|
||||||
:label="lt('WidgetName')"
|
:label="lt('Name')"
|
||||||
:rules="[
|
:rules="[
|
||||||
form().max255(this, 'name'),
|
form().max255(this, 'name'),
|
||||||
form().required(this, 'name')
|
form().required(this, 'name')
|
||||||
@@ -69,15 +69,16 @@
|
|||||||
</v-col>
|
</v-col>
|
||||||
<v-col cols="12" sm="6" lg="4" xl="3">
|
<v-col cols="12" sm="6" lg="4" xl="3">
|
||||||
<v-checkbox
|
<v-checkbox
|
||||||
v-model="objPublic"
|
v-model="obj.public"
|
||||||
:readonly="this.formState.readOnly"
|
:readonly="this.formState.readOnly"
|
||||||
:label="lt('AnyUser')"
|
:label="lt('AnyUser')"
|
||||||
ref="public"
|
ref="public"
|
||||||
|
@change="onChange('public')"
|
||||||
></v-checkbox>
|
></v-checkbox>
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
</v-col>
|
</v-col>
|
||||||
<template v-for="(item, index) in obj">
|
<template v-for="(item, index) in obj.editView">
|
||||||
<v-col :key="item.key" cols="12" sm="6" lg="4" xl="3" px-2>
|
<v-col :key="item.key" cols="12" sm="6" lg="4" xl="3" px-2>
|
||||||
<v-card>
|
<v-card>
|
||||||
<v-card-title>
|
<v-card-title>
|
||||||
@@ -422,8 +423,8 @@
|
|||||||
</v-list-item>
|
</v-list-item>
|
||||||
</v-list>
|
</v-list>
|
||||||
</template>
|
</template>
|
||||||
<v-divider></v-divider>
|
<!-- <v-divider></v-divider>
|
||||||
{{ item }}
|
{{ item }} -->
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</v-card-text>
|
</v-card-text>
|
||||||
@@ -495,14 +496,16 @@ export default {
|
|||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
obj: [], //working copy driving UI
|
obj: { editView: [], name: "", public: true },
|
||||||
objName: "",
|
|
||||||
objPublic: true,
|
|
||||||
listViewId: undefined,
|
listViewId: undefined,
|
||||||
dataListKey: undefined,
|
dataListKey: undefined,
|
||||||
formKey: undefined,
|
formKey: undefined,
|
||||||
fieldDefinitions: [],
|
fieldDefinitions: [],
|
||||||
effectiveListView: undefined,
|
effectiveListView: undefined,
|
||||||
|
editedListView: undefined,
|
||||||
|
editedName: "",
|
||||||
|
editedPublic: true,
|
||||||
concurrencyToken: undefined,
|
concurrencyToken: undefined,
|
||||||
pickLists: {
|
pickLists: {
|
||||||
dateFilterOperators: [],
|
dateFilterOperators: [],
|
||||||
@@ -543,12 +546,10 @@ export default {
|
|||||||
return window.$gz.enums.getPickList(enumKey);
|
return window.$gz.enums.getPickList(enumKey);
|
||||||
},
|
},
|
||||||
includeChanged: function(item) {
|
includeChanged: function(item) {
|
||||||
//Note: stock items can't be changed so no need to take that into account
|
|
||||||
if (item.required && item.visible == false) {
|
if (item.required && item.visible == false) {
|
||||||
item.required = false;
|
item.required = false;
|
||||||
}
|
}
|
||||||
this.formState.dirty = true;
|
updateEditedListView(this);
|
||||||
enableSaveButton();
|
|
||||||
},
|
},
|
||||||
toggleSort: function(item) {
|
toggleSort: function(item) {
|
||||||
if (item.sort == null) {
|
if (item.sort == null) {
|
||||||
@@ -562,9 +563,10 @@ export default {
|
|||||||
if (item.sort) {
|
if (item.sort) {
|
||||||
item.include = true;
|
item.include = true;
|
||||||
}
|
}
|
||||||
|
updateEditedListView(this);
|
||||||
},
|
},
|
||||||
move: function(direction, index) {
|
move: function(direction, index) {
|
||||||
var totalItems = this.obj.length;
|
var totalItems = this.obj.editView.length;
|
||||||
var newIndex = 0;
|
var newIndex = 0;
|
||||||
//calculate new index
|
//calculate new index
|
||||||
switch (direction) {
|
switch (direction) {
|
||||||
@@ -589,7 +591,12 @@ export default {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.obj.splice(newIndex, 0, this.obj.splice(index, 1)[0]);
|
this.obj.editView.splice(
|
||||||
|
newIndex,
|
||||||
|
0,
|
||||||
|
this.obj.editView.splice(index, 1)[0]
|
||||||
|
);
|
||||||
|
updateEditedListView(this);
|
||||||
},
|
},
|
||||||
addFilterCondition(item) {
|
addFilterCondition(item) {
|
||||||
var filterItem = { op: null, value: null, display: null };
|
var filterItem = { op: null, value: null, display: null };
|
||||||
@@ -705,12 +712,14 @@ export default {
|
|||||||
//add only if not already in the collection (accidental double click)
|
//add only if not already in the collection (accidental double click)
|
||||||
if (!window.$gz._.find(item.filter.items, filterItem)) {
|
if (!window.$gz._.find(item.filter.items, filterItem)) {
|
||||||
item.filter.items.push(filterItem);
|
item.filter.items.push(filterItem);
|
||||||
|
updateEditedListView(this);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
removeFilterCondition(item, index) {
|
removeFilterCondition(item, index) {
|
||||||
item.filter.items.splice(index, 1);
|
item.filter.items.splice(index, 1);
|
||||||
|
updateEditedListView(this);
|
||||||
},
|
},
|
||||||
form() {
|
form() {
|
||||||
return window.$gz.form;
|
return window.$gz.form;
|
||||||
@@ -721,84 +730,78 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
submit() {
|
submit() {
|
||||||
var vm = this;
|
// var vm = this;
|
||||||
var url = API_BASE_URL + this.formCustomTemplateKey;
|
// var url = API_BASE_URL + this.formCustomTemplateKey;
|
||||||
|
// //clear any errors vm might be around from previous submit
|
||||||
//clear any errors vm might be around from previous submit
|
// window.$gz.form.deleteAllErrorBoxErrors(this);
|
||||||
window.$gz.form.deleteAllErrorBoxErrors(this);
|
// //Create template data object here....
|
||||||
|
// //Note that server expects to see a string array of json template, not actual json
|
||||||
//Create template data object here....
|
// var newObj = {
|
||||||
//Note that server expects to see a string array of json template, not actual json
|
// formKey: this.formCustomTemplateKey,
|
||||||
var newObj = {
|
// concurrencyToken: this.concurrencyToken,
|
||||||
formKey: this.formCustomTemplateKey,
|
// template: "[]"
|
||||||
concurrencyToken: this.concurrencyToken,
|
// };
|
||||||
template: "[]"
|
// //temporary array to hold template for later stringification
|
||||||
};
|
// var temp = [];
|
||||||
//temporary array to hold template for later stringification
|
// //Rules:
|
||||||
var temp = [];
|
// for (var i = 0; i < this.obj.length; i++) {
|
||||||
//Rules:
|
// var fldItem = this.obj[i];
|
||||||
for (var i = 0; i < this.obj.length; i++) {
|
// if (fldItem.custom == false) {
|
||||||
var fldItem = this.obj[i];
|
// //Process regular stock field
|
||||||
if (fldItem.custom == false) {
|
// //If it's *not* set to stockRequired (i.e. built in field with biz rules that can't be hidden or changed)
|
||||||
//Process regular stock field
|
// // and it's also set to hidden or required then it's template-worthy
|
||||||
//If it's *not* set to stockRequired (i.e. built in field with biz rules that can't be hidden or changed)
|
// if (
|
||||||
// and it's also set to hidden or required then it's template-worthy
|
// !fldItem.stockRequired &&
|
||||||
if (
|
// (fldItem.visible == false || fldItem.required == true)
|
||||||
!fldItem.stockRequired &&
|
// ) {
|
||||||
(fldItem.visible == false || fldItem.required == true)
|
// temp.push({
|
||||||
) {
|
// fld: fldItem.key,
|
||||||
temp.push({
|
// required: fldItem.required,
|
||||||
fld: fldItem.key,
|
// hide: !fldItem.visible
|
||||||
required: fldItem.required,
|
// });
|
||||||
hide: !fldItem.visible
|
// }
|
||||||
});
|
// } else {
|
||||||
}
|
// //Process custom field
|
||||||
} else {
|
// //If it's not visible then don't add it at all
|
||||||
//Process custom field
|
// if (fldItem.visible == true) {
|
||||||
//If it's not visible then don't add it at all
|
// temp.push({
|
||||||
if (fldItem.visible == true) {
|
// fld: fldItem.key,
|
||||||
temp.push({
|
// required: fldItem.required,
|
||||||
fld: fldItem.key,
|
// type: fldItem.type
|
||||||
required: fldItem.required,
|
// });
|
||||||
type: fldItem.type
|
// }
|
||||||
});
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// //now set the template as a json string
|
||||||
}
|
// newObj.template = JSON.stringify(temp);
|
||||||
|
// window.$gz.api
|
||||||
//now set the template as a json string
|
// .upsert(url, newObj)
|
||||||
newObj.template = JSON.stringify(temp);
|
// .then(res => {
|
||||||
|
// vm.formState.loading = false;
|
||||||
window.$gz.api
|
// if (res.error != undefined) {
|
||||||
.upsert(url, newObj)
|
// vm.formState.serverError = res.error;
|
||||||
.then(res => {
|
// window.$gz.form.setErrorBoxErrors(vm);
|
||||||
vm.formState.loading = false;
|
// } else {
|
||||||
if (res.error != undefined) {
|
// //Handle "put" of an existing record (UPDATE) (there is no POST of a new record for this particular object)
|
||||||
vm.formState.serverError = res.error;
|
// //Set store values for template and token
|
||||||
window.$gz.form.setErrorBoxErrors(vm);
|
// window.$gz.formCustomTemplate.set(
|
||||||
} else {
|
// vm.formCustomTemplateKey,
|
||||||
//Handle "put" of an existing record (UPDATE) (there is no POST of a new record for this particular object)
|
// res.data.concurrencyToken,
|
||||||
|
// newObj.template
|
||||||
//Set store values for template and token
|
// );
|
||||||
window.$gz.formCustomTemplate.set(
|
// //set our local concurrency token value
|
||||||
vm.formCustomTemplateKey,
|
// vm.concurrencyToken = res.data.concurrencyToken;
|
||||||
res.data.concurrencyToken,
|
// //form is now clean
|
||||||
newObj.template
|
// window.$gz.form.setFormState({
|
||||||
);
|
// vm: vm,
|
||||||
//set our local concurrency token value
|
// dirty: false
|
||||||
vm.concurrencyToken = res.data.concurrencyToken;
|
// });
|
||||||
|
// }
|
||||||
//form is now clean
|
// })
|
||||||
window.$gz.form.setFormState({
|
// .catch(function handleSubmitError(error) {
|
||||||
vm: vm,
|
// vm.formState.loading = false;
|
||||||
dirty: false
|
// window.$gz.errorHandler.handleFormError(error, vm);
|
||||||
});
|
// });
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch(function handleSubmitError(error) {
|
|
||||||
vm.formState.loading = false;
|
|
||||||
window.$gz.errorHandler.handleFormError(error, vm);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -1143,7 +1146,7 @@ function setEffectiveListView(vm) {
|
|||||||
- If listviewid is zero then that's starting with the default list view so need to fetch it and then init the form
|
- If listviewid is zero then that's starting with the default list view so need to fetch it and then init the form
|
||||||
- If listviewid is -1 then that's starting with an unsaved listview so get that from the saved form store
|
- If listviewid is -1 then that's starting with an unsaved listview so get that from the saved form store
|
||||||
- If listviewid is greater than 0 then it's a saved listview and there sb a cached version of it but ideally maybe fetch it from
|
- If listviewid is greater than 0 then it's a saved listview and there sb a cached version of it but ideally maybe fetch it from
|
||||||
objPublic, objName
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (vm.listViewId == null) {
|
if (vm.listViewId == null) {
|
||||||
@@ -1155,7 +1158,7 @@ objPublic, objName
|
|||||||
if (vm.listViewId == -1) {
|
if (vm.listViewId == -1) {
|
||||||
if (formSettings.saved.dataTable.editedListView != null) {
|
if (formSettings.saved.dataTable.editedListView != null) {
|
||||||
vm.effectiveListView = formSettings.saved.dataTable.editedListView;
|
vm.effectiveListView = formSettings.saved.dataTable.editedListView;
|
||||||
vm.objName = vm.lt("FilterUnsaved");
|
vm.obj.name = vm.lt("FilterUnsaved");
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
} else if (vm.listViewId == 0) {
|
} else if (vm.listViewId == 0) {
|
||||||
@@ -1168,7 +1171,7 @@ objPublic, objName
|
|||||||
throw res.error;
|
throw res.error;
|
||||||
} else {
|
} else {
|
||||||
vm.effectiveListView = JSON.parse(res.data);
|
vm.effectiveListView = JSON.parse(res.data);
|
||||||
vm.objName = vm.lt("FilterUnsaved");
|
vm.obj.name = vm.lt("FilterUnsaved");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@@ -1178,8 +1181,8 @@ objPublic, objName
|
|||||||
throw res.error;
|
throw res.error;
|
||||||
} else {
|
} else {
|
||||||
vm.effectiveListView = JSON.parse(res.data.listView);
|
vm.effectiveListView = JSON.parse(res.data.listView);
|
||||||
vm.objPublic = res.data.public;
|
vm.obj.public = res.data.public;
|
||||||
vm.objName = res.data.name;
|
vm.obj.name = res.data.name;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -1260,10 +1263,10 @@ function initDataObject(vm) {
|
|||||||
ret.push(o);
|
ret.push(o);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
vm.obj = ret;
|
vm.obj.editView = ret;
|
||||||
|
|
||||||
if (window.$gz.errorHandler.devMode) {
|
if (window.$gz.errorHandler.devMode) {
|
||||||
if (vm.obj.length != vm.fieldDefinitions.length - 1) {
|
if (vm.obj.editView.length != vm.fieldDefinitions.length - 1) {
|
||||||
throw "ay-data-list-view::initDataObject - working array length not equal to total field definition length";
|
throw "ay-data-list-view::initDataObject - working array length not equal to total field definition length";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1293,6 +1296,20 @@ function fetchEnums(vm) {
|
|||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Convert working object to actual listView
|
||||||
|
//
|
||||||
|
function updateEditedListView(vm) {
|
||||||
|
//turn the obj.editView settings into an actual listview
|
||||||
|
//compare it with the effectiveListView to see if there are any changes between the two
|
||||||
|
//set the form to dirty if there are changes and can save
|
||||||
|
//this.formState.dirty = true;
|
||||||
|
// enableSaveButton();
|
||||||
|
//this way user can build their way back to the same view and then no need to save if no changes
|
||||||
|
//build an array of all enums then execute method
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
public const string OpEquality = "=";
|
public const string OpEquality = "=";
|
||||||
public const string OpGreaterThan = ">";
|
public const string OpGreaterThan = ">";
|
||||||
|
|||||||
Reference in New Issue
Block a user