This commit is contained in:
@@ -44,21 +44,18 @@ export default {
|
||||
|
||||
//de-lodash
|
||||
// //turn it into an array suitable for selection lists
|
||||
// window.$gz._.forOwn(e, function(value, key) {
|
||||
// window.$gz. _.forOwn(e, function(value, key) {
|
||||
// ret.push({ id: Number(key), name: value });
|
||||
// });
|
||||
//return window.$gz. _.sortBy(ret, "name");
|
||||
|
||||
//turn it into an array suitable for selection lists
|
||||
for (const [key, value] of Object.entries(e)) {
|
||||
ret.push({ id: Number(key), name: value });
|
||||
}
|
||||
|
||||
//e is an object with keys of id values i.e. {1:"display1",2:"display 2"}
|
||||
//what needs to be returned is an array of objects like: [{id:1,name:"display1"},{id:2,name:"display2"}]
|
||||
|
||||
console.log("enum::getSelectionList, e is: ", e);
|
||||
console.log("ret is", ret);
|
||||
return window.$gz._.sortBy(ret, "name");
|
||||
//sort by name
|
||||
ret.sort(window.$gz.util.sortByKey("name"));
|
||||
return ret;
|
||||
},
|
||||
///////////////////////////////////
|
||||
//
|
||||
@@ -67,7 +64,7 @@ export default {
|
||||
// ACCEPTS an ARRAY or a single STRING KEY
|
||||
//
|
||||
async fetchEnumList(enumKey) {
|
||||
if (!window.$gz._.isArray(enumKey)) {
|
||||
if (!Array.isArray(enumKey)) {
|
||||
enumKey = [enumKey];
|
||||
}
|
||||
for (let i = 0; i < enumKey.length; i++) {
|
||||
@@ -75,7 +72,10 @@ export default {
|
||||
//if not then fetch it and store it
|
||||
let k = enumKey[i].toLowerCase();
|
||||
|
||||
if (!window.$gz._.has(window.$gz.store.state.enums, k)) {
|
||||
//de-lodash
|
||||
// if (!window.$gz. _.has(window.$gz.store.state.enums, k)) {
|
||||
//enums is an object this is checking if that object has a key with the name in k
|
||||
if (!window.$gz.util.has(window.$gz.store.state.enums, k)) {
|
||||
let that = this;
|
||||
// eslint-disable-next-line
|
||||
let dat = await that.fetchEnumKey(k);
|
||||
|
||||
@@ -48,7 +48,7 @@ function dealWithError(msg, vm) {
|
||||
//should be able to display in form...
|
||||
if (vm.$ay.dev) {
|
||||
//make sure formState.appError is defined on data
|
||||
if (!window.$gz._.has(vm, "formState.appError")) {
|
||||
if (!window.$gz.util.has(vm, "formState.appError")) {
|
||||
throw new Error(
|
||||
"DEV ERROR errorHandler::dealWithError -> formState.appError seems to be missing from form's vue data object"
|
||||
);
|
||||
|
||||
@@ -18,7 +18,9 @@ function addDataKeyNames(obj) {
|
||||
export default {
|
||||
// cache the form customization data if it's not already present
|
||||
async get(formKey) {
|
||||
if (!window.$gz._.has(window.$gz.store.state.formCustomTemplate, formKey)) {
|
||||
if (
|
||||
!window.$gz.util.has(window.$gz.store.state.formCustomTemplate, formKey)
|
||||
) {
|
||||
//fetch and populate the store
|
||||
let res = await window.$gz.api.get("form-custom/" + formKey);
|
||||
if (res.error) {
|
||||
@@ -56,11 +58,11 @@ export default {
|
||||
);
|
||||
}
|
||||
|
||||
//_https://lodash.com/docs#find
|
||||
//Note that not every field being requested will exist so it's valid to return undefined
|
||||
let templateItem = window.$gz._.find(template, ["fld", fieldKey]);
|
||||
|
||||
return templateItem;
|
||||
//template is an array of objects that contain a key called "fld"
|
||||
//de-lodash
|
||||
//let templateItem = window.$gz. _.find(template, ["fld", fieldKey]);
|
||||
return template.find(z => z.fld == fieldKey);
|
||||
},
|
||||
getTemplateConcurrencyToken(formKey) {
|
||||
let tok =
|
||||
|
||||
@@ -506,11 +506,13 @@ export default {
|
||||
//See if control formCustomTemplateFieldName is in server required fields collection
|
||||
//this is a collection of both custom field definitions and standard form fields that are required
|
||||
//since all names are unique can just filter out the one we need by name which will inherently ignore custom fields by default
|
||||
//_https://lodash.com/docs#find
|
||||
let templateItem = window.$gz._.find(template, [
|
||||
"fld",
|
||||
formCustomTemplateFieldName
|
||||
]);
|
||||
//de-lodash
|
||||
// let templateItem = window.$gz. _.find(template, [
|
||||
// "fld",
|
||||
// formCustomTemplateFieldName
|
||||
// ]);
|
||||
|
||||
let templateItem = template.find(z => z.fld == formCustomTemplateFieldName);
|
||||
|
||||
//templateItem.required
|
||||
if (templateItem === undefined || templateItem.required !== true) {
|
||||
@@ -590,21 +592,21 @@ export default {
|
||||
//CHECK PREREQUISITES IN DEV MODE TO ENSURE FORM ISN"T MISSING NEEDED DATA ATTRIBUTES ETC
|
||||
if (vm.$ay.dev) {
|
||||
//make sure formState.serverErrors is defined on data
|
||||
if (!window.$gz._.has(vm, "formState.serverError")) {
|
||||
if (!window.$gz.util.has(vm, "formState.serverError")) {
|
||||
throw new Error(
|
||||
"DEV ERROR gzform::formState.serverErrors -> formState.serverError seems to be missing from form's vue data object"
|
||||
);
|
||||
}
|
||||
|
||||
//make sure formState.appError is defined on data
|
||||
if (!window.$gz._.has(vm, "formState.appError")) {
|
||||
if (!window.$gz.util.has(vm, "formState.appError")) {
|
||||
throw new Error(
|
||||
"DEV ERROR gzform::formState.serverErrors -> formState.appError seems to be missing from form's vue data object"
|
||||
);
|
||||
}
|
||||
|
||||
//make sure formState.errorBoxMessage is defined on data
|
||||
if (!window.$gz._.has(vm, "formState.errorBoxMessage")) {
|
||||
if (!window.$gz.util.has(vm, "formState.errorBoxMessage")) {
|
||||
throw new Error(
|
||||
"DEV ERROR gzform::formState.serverErrors -> formState.errorBoxMessage seems to be missing from form's vue data object"
|
||||
);
|
||||
@@ -726,11 +728,13 @@ export default {
|
||||
//See if control templateFieldName is in server required fields collection
|
||||
//this is a collection of both custom field definitions and standard form fields that are required
|
||||
//since all names are unique can just filter out the one we need by name which will inherently ignore custom fields by default
|
||||
//_https://lodash.com/docs#find
|
||||
let templateItem = window.$gz._.find(template, [
|
||||
"fld",
|
||||
formCustomTemplateFieldName
|
||||
]);
|
||||
//de-lodash
|
||||
// let templateItem = window.$gz. _.find(template, [
|
||||
// "fld",
|
||||
// formCustomTemplateFieldName
|
||||
// ]);
|
||||
|
||||
let templateItem = template.find(z => z.fld == formCustomTemplateFieldName);
|
||||
|
||||
if (templateItem === undefined || templateItem.hide !== true) {
|
||||
return true;
|
||||
|
||||
@@ -383,6 +383,30 @@ export default {
|
||||
sleepAsync: function(milliseconds) {
|
||||
// eslint-disable-next-line
|
||||
return new Promise((resolve) => setTimeout(resolve, milliseconds));
|
||||
},
|
||||
///////////////////////////////////////////////
|
||||
// sortByKey lodash "sortBy" replacement
|
||||
// https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore#_sortby-and-_orderby
|
||||
//usage:
|
||||
// The native sort modifies the array in place. `_.orderBy` and `_.sortBy` do not, so we use `.concat()` to
|
||||
// copy the array, then sort.
|
||||
// fruits.concat().sort(sortBy("name"));
|
||||
// => [{name:"apple", amount: 4}, {name:"banana", amount: 2}, {name:"mango", amount: 1}, {name:"pineapple", amount: 2}]
|
||||
sortByKey: key => {
|
||||
return (a, b) => (a[key] > b[key] ? 1 : b[key] > a[key] ? -1 : 0);
|
||||
},
|
||||
///////////////////////////////////////////////
|
||||
// "has" lodash replacement
|
||||
// https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore#_has
|
||||
//
|
||||
has: function(obj, key) {
|
||||
var keyParts = key.split(".");
|
||||
return (
|
||||
!!obj &&
|
||||
(keyParts.length > 1
|
||||
? has(obj[key.split(".")[0]], keyParts.slice(1).join("."))
|
||||
: hasOwnProperty.call(obj, key))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,9 +17,14 @@ export default {
|
||||
cachekey
|
||||
) {
|
||||
//find match
|
||||
let display = window.$gz._.find(editedTranslation.translationItems, {
|
||||
key: cachekey
|
||||
}).display;
|
||||
//de-lodash
|
||||
// let display = window.$gz. _.find(editedTranslation.translationItems, {
|
||||
// key: cachekey
|
||||
// }).display;
|
||||
let display = editedTranslation.translationItems.find(
|
||||
z => z.key == cachekey
|
||||
).display;
|
||||
|
||||
window.$gz.store.commit("setTranslationText", {
|
||||
key: cachekey,
|
||||
value: display
|
||||
@@ -48,7 +53,7 @@ export default {
|
||||
if (key == "Wiki") {
|
||||
return "Wiki";
|
||||
}
|
||||
if (!window.$gz._.has(window.$gz.store.state.translationText, key)) {
|
||||
if (!window.$gz.util.has(window.$gz.store.state.translationText, key)) {
|
||||
return "??" + key;
|
||||
}
|
||||
return window.$gz.store.state.translationText[key];
|
||||
@@ -62,7 +67,7 @@ export default {
|
||||
let needIt = [];
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
if (
|
||||
!window.$gz._.has(window.$gz.store.state.translationText, keys[i])
|
||||
!window.$gz.util.has(window.$gz.store.state.translationText, keys[i])
|
||||
) {
|
||||
needIt.push(keys[i]);
|
||||
}
|
||||
|
||||
@@ -233,7 +233,9 @@ export default {
|
||||
return false;
|
||||
}
|
||||
//iterate template and see if it has any custom fields set to display
|
||||
return window.$gz._.find(template, "type") != undefined;
|
||||
//de-lodash
|
||||
//return window.$gz. _.find(template, "type") != undefined;
|
||||
return template.find(z => z.type != undefined);
|
||||
},
|
||||
GetValueForField: function(dataKey) {
|
||||
if (!this.value) {
|
||||
@@ -252,9 +254,13 @@ export default {
|
||||
|
||||
//Get the field data type
|
||||
//https://lodash.com/docs#find
|
||||
let ctrlType = window.$gz._.find(
|
||||
this.$store.state.formCustomTemplate[this.formKey],
|
||||
["dataKey", dataKey]
|
||||
// let ctrlType = window.$gz._.find(
|
||||
// this.$store.state.formCustomTemplate[this.formKey],
|
||||
// ["dataKey", dataKey]
|
||||
// ).type;
|
||||
|
||||
let ctrlType = this.$store.state.formCustomTemplate[this.formKey].find(
|
||||
z => z.dataKey == dataKey
|
||||
).type;
|
||||
|
||||
//First get current value for the data that came from the server
|
||||
@@ -327,7 +333,7 @@ export default {
|
||||
//Get the current data out of the json string value
|
||||
//
|
||||
let cData = JSON.parse(this.value);
|
||||
if (!window.$gz._.has(cData, dataKey)) {
|
||||
if (!window.$gz.util.has(cData, dataKey)) {
|
||||
cData[dataKey] = null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user