This commit is contained in:
@@ -67,7 +67,7 @@ TODO: FILTER AT CLIENT
|
|||||||
- DataTAble UI
|
- DataTAble UI
|
||||||
- Pick list of ListOptions for that list type at top also (no options) empty default choice
|
- Pick list of ListOptions for that list type at top also (no options) empty default choice
|
||||||
|
|
||||||
|
- MAKE LT() method in forms available to all vm users so don't have to keep defining it in every single form
|
||||||
|
|
||||||
|
|
||||||
- Make functional user settings form with all overrides so can test shit out
|
- Make functional user settings form with all overrides so can test shit out
|
||||||
|
|||||||
@@ -17,8 +17,9 @@ export default {
|
|||||||
DEPRECATED_REUSELATER_15: 15,
|
DEPRECATED_REUSELATER_15: 15,
|
||||||
DEPRECATED_REUSELATER_16: 16,
|
DEPRECATED_REUSELATER_16: 16,
|
||||||
FileAttachment: 17,
|
FileAttachment: 17,
|
||||||
DataFilter: 18,
|
DataListSortFilter: 18,
|
||||||
FormCustom: 19
|
FormCustom: 19,
|
||||||
|
DataListTemplate: 20
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -45,6 +45,10 @@ function dealWithError(msg, vm) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
vm.formState.appError = msg;
|
vm.formState.appError = msg;
|
||||||
|
|
||||||
|
//TODO: What is this doing exactly?
|
||||||
|
//it's related to server errors but I'm setting appError above
|
||||||
|
//why two error properties?
|
||||||
window.$gz.form.setErrorBoxErrors(vm);
|
window.$gz.form.setErrorBoxErrors(vm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -101,12 +105,14 @@ export default {
|
|||||||
// Localize, log and return error
|
// Localize, log and return error
|
||||||
//
|
//
|
||||||
handleFormError(err, vm) {
|
handleFormError(err, vm) {
|
||||||
//called inside forms when things go wrong
|
//called inside forms when things go unexpectedly wrong
|
||||||
//returns the localized message in case the form wants to display it as well
|
//returns the localized message in case the form wants to display it as well
|
||||||
if (err instanceof Error && err.message) {
|
if (err instanceof Error && err.message) {
|
||||||
dealWithError(err.message, vm);
|
dealWithError(err.message, vm);
|
||||||
} else {
|
} else {
|
||||||
dealWithError(err.toString(), vm);
|
//TODO: this is pretty bad
|
||||||
|
var msg = JSON.stringify(err);
|
||||||
|
dealWithError(msg, vm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -110,6 +110,12 @@ export default {
|
|||||||
return Promise.reject(new Error("[ErrorUserNotAuthorized]"));
|
return Promise.reject(new Error("[ErrorUserNotAuthorized]"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//404 not found is an expected status not worth logging allow to bubble up
|
||||||
|
//for client code to deal with
|
||||||
|
if (response.status == 404) {
|
||||||
|
return Promise.resolve(response);
|
||||||
|
}
|
||||||
|
|
||||||
if (response.status >= 200 && response.status < 300) {
|
if (response.status >= 200 && response.status < 300) {
|
||||||
return Promise.resolve(response);
|
return Promise.resolve(response);
|
||||||
} else {
|
} else {
|
||||||
@@ -289,6 +295,7 @@ export default {
|
|||||||
// console.log("gzapi::get->Calling resolve now for " + route);
|
// console.log("gzapi::get->Calling resolve now for " + route);
|
||||||
// resolve(response); // (**)
|
// resolve(response); // (**)
|
||||||
// }, 2000);
|
// }, 2000);
|
||||||
|
|
||||||
resolve(response);
|
resolve(response);
|
||||||
})
|
})
|
||||||
.catch(function handleGetError(error) {
|
.catch(function handleGetError(error) {
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ function getErrorBoxErrors(vm, errs) {
|
|||||||
//any application errors?
|
//any application errors?
|
||||||
if (vm.formState.appError) {
|
if (vm.formState.appError) {
|
||||||
hasErrors = true;
|
hasErrors = true;
|
||||||
ret = vm.formState.appError + "\r\n----------\r\n" + ret;
|
ret += vm.formState.appError + "\r\n----------\r\n" + ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hasErrors) {
|
if (!hasErrors) {
|
||||||
|
|||||||
@@ -40,6 +40,18 @@
|
|||||||
>
|
>
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
|
<v-row>
|
||||||
|
<v-col cols="12" sm="6" lg="4" xl="3">
|
||||||
|
<v-select
|
||||||
|
v-model="selectedDataListSortFilter"
|
||||||
|
:items="pickLists.availableDataListSortFilters"
|
||||||
|
item-text="name"
|
||||||
|
item-value="id"
|
||||||
|
:label="lt('GridFilterName')"
|
||||||
|
@change="filterSelected(item)"
|
||||||
|
></v-select>
|
||||||
|
</v-col>
|
||||||
|
</v-row>
|
||||||
</v-form>
|
</v-form>
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
@@ -52,22 +64,11 @@
|
|||||||
//
|
//
|
||||||
//NOTE: This is a simple form with no need for business rules or validation so stripped out any extraneous code related to all that
|
//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 = "sortfilter";
|
const FORM_KEY = "ay-sort-filter";
|
||||||
const API_BASE_URL = "DataListSortFilter/";
|
const API_BASE_URL = "DataListSortFilter/";
|
||||||
export default {
|
export default {
|
||||||
beforeRouteEnter(to, from, next) {
|
beforeRouteEnter(to, from, next) {
|
||||||
var ltKeysRequired = [
|
var ltKeysRequired = ["DataListSortFilter", "GridFilterName"];
|
||||||
"DataListSortFilter",
|
|
||||||
"FormFieldVisible",
|
|
||||||
"UiFieldDataType",
|
|
||||||
"UiFieldDataTypesCurrency",
|
|
||||||
"UiFieldDataTypesDateOnly",
|
|
||||||
"UiFieldDataTypesDateTime",
|
|
||||||
"UiFieldDataTypesNumber",
|
|
||||||
"UiFieldDataTypesText",
|
|
||||||
"UiFieldDataTypesTimeOnly",
|
|
||||||
"UiFieldDataTypesTrueFalse"
|
|
||||||
];
|
|
||||||
|
|
||||||
window.$gz.locale.fetch(ltKeysRequired).then(next);
|
window.$gz.locale.fetch(ltKeysRequired).then(next);
|
||||||
},
|
},
|
||||||
@@ -79,6 +80,8 @@ export default {
|
|||||||
vv.then(() => {
|
vv.then(() => {
|
||||||
vm.formState.ready = true;
|
vm.formState.ready = true;
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
|
debugger;
|
||||||
|
|
||||||
vm.formState.ready = true;
|
vm.formState.ready = true;
|
||||||
window.$gz.errorHandler.handleFormError(err);
|
window.$gz.errorHandler.handleFormError(err);
|
||||||
});
|
});
|
||||||
@@ -115,17 +118,9 @@ export default {
|
|||||||
dataListKey: this.$route.params.dataListKey,
|
dataListKey: this.$route.params.dataListKey,
|
||||||
concurrencyToken: undefined,
|
concurrencyToken: undefined,
|
||||||
formCustomTemplateKey: this.$route.params.formCustomTemplateKey,
|
formCustomTemplateKey: this.$route.params.formCustomTemplateKey,
|
||||||
|
selectedDataListSortFilter: {},
|
||||||
pickLists: {
|
pickLists: {
|
||||||
uiFieldDataTypes: [
|
availableDataListSortFilters: []
|
||||||
{ name: this.lt("UiFieldDataTypesDateTime"), id: "1" },
|
|
||||||
{ name: this.lt("UiFieldDataTypesDateOnly"), id: "2" },
|
|
||||||
{ name: this.lt("UiFieldDataTypesTimeOnly"), id: "3" },
|
|
||||||
{ name: this.lt("UiFieldDataTypesText"), id: "4" },
|
|
||||||
{ name: this.lt("UiFieldDataTypesTrueFalse"), id: "6" },
|
|
||||||
{ name: this.lt("UiFieldDataTypesInteger"), id: "5" },
|
|
||||||
{ name: this.lt("UiFieldDataTypesDecimal"), id: "7" },
|
|
||||||
{ name: this.lt("UiFieldDataTypesCurrency"), id: "8" }
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
formState: {
|
formState: {
|
||||||
ready: false,
|
ready: false,
|
||||||
@@ -137,7 +132,7 @@ export default {
|
|||||||
appError: null,
|
appError: null,
|
||||||
serverError: {}
|
serverError: {}
|
||||||
},
|
},
|
||||||
rights: window.$gz.role.getRights(window.$gz.type.FormCustom)
|
rights: window.$gz.role.getRights(window.$gz.type.DataListSortFilter)
|
||||||
//,tempTemplate: window.$gz.store.state.formCustomTemplate["widget"]
|
//,tempTemplate: window.$gz.store.state.formCustomTemplate["widget"]
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@@ -162,10 +157,11 @@ export default {
|
|||||||
this.formState.dirty = true;
|
this.formState.dirty = true;
|
||||||
enableSaveButton();
|
enableSaveButton();
|
||||||
},
|
},
|
||||||
dataTypeChanged: function(item) {
|
filterSelected: function(item) {
|
||||||
//nothing to scan here just set form dirty
|
alert("STUB:FILTER SELECTED");
|
||||||
this.formState.dirty = true;
|
// //nothing to scan here just set form dirty
|
||||||
enableSaveButton();
|
// this.formState.dirty = true;
|
||||||
|
// enableSaveButton();
|
||||||
},
|
},
|
||||||
submit() {
|
submit() {
|
||||||
var vm = this;
|
var vm = this;
|
||||||
@@ -307,19 +303,35 @@ function generateMenu(vm) {
|
|||||||
window.$gz.eventBus.$emit("menu-change", menuOptions);
|
window.$gz.eventBus.$emit("menu-change", menuOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
//
|
||||||
|
//
|
||||||
function initForm(vm) {
|
function initForm(vm) {
|
||||||
return ensureTemplateIsInStore(vm).then(() => {
|
return populatePickLists(vm).then(() => {
|
||||||
//Must use return here
|
//Must use return here
|
||||||
return initDataObject(vm);
|
return initDataObject(vm);
|
||||||
});
|
});
|
||||||
|
// .catch(function handlePopulatePickListError(error) {
|
||||||
|
// debugger;
|
||||||
|
// });
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////
|
////////////////////
|
||||||
//
|
//
|
||||||
function ensureTemplateIsInStore(vm) {
|
function populatePickLists(vm) {
|
||||||
return window.$gz.formCustomTemplate.get(
|
//http://localhost:7575/api/v8/DataListSortFilter/PickList?ListKey=TestWidgetDataList
|
||||||
vm.$route.params.formCustomTemplateKey
|
return window.$gz.api
|
||||||
);
|
.get("DataListSortFilter/PickList?ListKey=" + vm.dataListKey)
|
||||||
|
.then(res => {
|
||||||
|
if (res.error != undefined) {
|
||||||
|
window.$gz.errorHandler.handleFormError(res.error, vm);
|
||||||
|
} else {
|
||||||
|
vm.pickLists.availableDataListSortFilters = res.data;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// return window.$gz.formCustomTemplate.get(
|
||||||
|
// vm.$route.params.formCustomTemplateKey
|
||||||
|
// );
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////
|
////////////////////
|
||||||
@@ -327,53 +339,52 @@ function ensureTemplateIsInStore(vm) {
|
|||||||
function initDataObject(vm) {
|
function initDataObject(vm) {
|
||||||
//http://localhost:7575/api/v8/ObjectFields/ObjectFields/widget
|
//http://localhost:7575/api/v8/ObjectFields/ObjectFields/widget
|
||||||
|
|
||||||
var url =
|
var url = "FormFieldsDefinitions/" + vm.$route.params.formCustomTemplateKey;
|
||||||
"ObjectFields/ObjectFields/" + vm.$route.params.formCustomTemplateKey;
|
|
||||||
return window.$gz.api.get(url).then(res => {
|
return window.$gz.api.get(url).then(res => {
|
||||||
if (res.error) {
|
if (res.error != undefined) {
|
||||||
throw res.error;
|
window.$gz.errorHandler.handleFormError(res.error, vm);
|
||||||
}
|
} else {
|
||||||
|
//set vm.obj to the combined synthesized snapshot array of template and availble fields for working data for this form
|
||||||
|
// - {key, ltdisplay, hideable, custom, required, hide, type}
|
||||||
|
//Iterate ObjectFields
|
||||||
|
//create a new object based on the f.a.f. item and any existing template values for that item
|
||||||
|
|
||||||
//set vm.obj to the combined synthesized snapshot array of template and availble fields for working data for this form
|
for (var i = 0; i < res.data.length; i++) {
|
||||||
// - {key, ltdisplay, hideable, custom, required, hide, type}
|
//get the formAvailableField record into an object to save typing
|
||||||
//Iterate ObjectFields
|
var faf = res.data[i];
|
||||||
//create a new object based on the f.a.f. item and any existing template values for that item
|
//get the customTemplate record for this field if it exists
|
||||||
|
|
||||||
for (var i = 0; i < res.data.length; i++) {
|
var templateItem = window.$gz.formCustomTemplate.getFieldTemplateValue(
|
||||||
//get the formAvailableField record into an object to save typing
|
vm.formCustomTemplateKey,
|
||||||
var faf = res.data[i];
|
faf.fieldKey
|
||||||
//get the customTemplate record for this field if it exists
|
);
|
||||||
|
|
||||||
var templateItem = (templateItem = window.$gz.formCustomTemplate.getFieldTemplateValue(
|
//handle non-existent template item (expected)
|
||||||
vm.formCustomTemplateKey,
|
if (templateItem === undefined || templateItem === null) {
|
||||||
faf.key
|
templateItem = {
|
||||||
));
|
required: false,
|
||||||
|
hide: faf.isCustomField ? true : false, //hide if custom because it's not set to display if it's not present, all others are stock fields
|
||||||
|
type: "text"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
//handle non-existent template item (expected)
|
// var canHide=faf.hideable && templateItem.required!==true;
|
||||||
if (templateItem === undefined || templateItem === null) {
|
|
||||||
templateItem = {
|
var objItem = {
|
||||||
required: false,
|
key: faf.fieldKey,
|
||||||
hide: faf.custom ? true : false, //hide if custom because it's not set to display if it's not present, all others are stock fields
|
title: window.$gz.locale.get(faf.ltKey),
|
||||||
type: "text"
|
stockRequired: !faf.hideable,
|
||||||
|
custom: faf.isCustomField,
|
||||||
|
required: faf.hideable === false || templateItem.required === true,
|
||||||
|
visible: templateItem.hide !== true,
|
||||||
|
type: templateItem.type
|
||||||
};
|
};
|
||||||
|
|
||||||
|
vm.obj.push(objItem);
|
||||||
|
vm.concurrencyToken = window.$gz.formCustomTemplate.getTemplateConcurrencyToken(
|
||||||
|
vm.formCustomTemplateKey
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// var canHide=faf.hideable && templateItem.required!==true;
|
|
||||||
|
|
||||||
var objItem = {
|
|
||||||
key: faf.key,
|
|
||||||
title: window.$gz.locale.get(faf.key),
|
|
||||||
stockRequired: !faf.hideable,
|
|
||||||
custom: faf.custom,
|
|
||||||
required: faf.hideable === false || templateItem.required === true,
|
|
||||||
visible: templateItem.hide !== true,
|
|
||||||
type: templateItem.type
|
|
||||||
};
|
|
||||||
|
|
||||||
vm.obj.push(objItem);
|
|
||||||
vm.concurrencyToken = window.$gz.formCustomTemplate.getTemplateConcurrencyToken(
|
|
||||||
vm.formCustomTemplateKey
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user