This commit is contained in:
2019-12-11 19:43:20 +00:00
parent 2cf2b03599
commit 79a84eba42
12 changed files with 107 additions and 21 deletions

View File

@@ -99,6 +99,25 @@ export default {
hash |= 0; // Convert to 32bit integer
}
return hash;
},
///////////////////////////////
// CONVERT STRING TO BOOLEAN
// https://stackoverflow.com/a/1414175/8939
//
stringToBoolean: function(string) {
switch (string.toLowerCase().trim()) {
case "true":
case "yes":
case "1":
return true;
case "false":
case "no":
case "0":
case null:
return false;
default:
return Boolean(string);
}
}
//new functions above here

View File

@@ -173,11 +173,61 @@ export default {
//get the data out of the JSON string value
var cData = JSON.parse(this.value);
//POtentially, down the road might need to co-erce the value to the right type, this is where that would happen
//get the type it *should* be
//coerce it to that type and return it
//Custom field types can be changed by the user and cause old entered data to be invalid for that field type
//Here we need to take action if the data is of an incompatible type for the control field type and attempt to coerce or simply nullify if not co-ercable the data
// - CURRENT TEXT fields could handle any data so they don't need to be changed
// - CURRENT BOOL fields can only handle empty or true false so they would need to be set null
// - CURRENT TIME, DATE, DATETIME are pretty specific but all use a datetime string so any value not datetime like should be nulled
// - CURRENT NUMBER, CURRENCY are also pretty specific but easy to identify if not fully numeric and then sb nulled or attempt to convert then null if not
return cData[dataKey];
//Get the field data type
//https://lodash.com/docs#find
var ctrlType = window.$gz._.find(
this.$store.state.formCustomTemplate[this.formKey],
["dataKey", dataKey]
).type;
//console.log("Field with datakey " + dataKey + " is of type " + ctrlType);
//First get current value for the data that came from the server
var ret = cData[dataKey];
//Only process if value is non-null since all control types can handle null
if (ret != null) {
//check types that matter
switch (ctrlType) {
//DateLike?
case "date":
case "time":
case "datetime":
//can it be parsed into a date using the same library as the components use?
if (!window.$gz.dayjs(ret).isValid()) {
ret = null;
}
break;
case "bool":
//if it's not already a boolean
if (!window.$gz._.isBoolean(ret)) {
//it's not a bool and it's not null, it came from some other data type,
//perhaps though, it's a truty string so check for that before giving up and nulling
if (window.$gz._.isString(ret)) {
ret = window.$gz.util.stringToBoolean(ret);
break;
}
//The number 1?
if (ret === 1) {
ret = true;
break;
}
//The number 0?
if (ret === 0) {
ret = false;
break;
}
}
break;
}
}
//{"c1":"2019-01-27T09:26:06.1673391Z","c2":"Esse sunt re in.","c3":48824971,"c4":false,"c5":0.120971084628706}
return ret;
},
SetValueForField: function(dataKey, newValue) {
//Get the current data out of the json string value
@@ -192,9 +242,6 @@ export default {
cData[dataKey] = null;
} else {
//then set item in the cData
//POtentially, down the road might need to co-erce the value to the right type, this is where that would happen
cData[dataKey] = newValue.toString();
}

View File

@@ -205,6 +205,7 @@ export default {
isMain: false,
icon: "fa-info-circle",
title: window.$gz.locale.get("HelpAboutAyaNova"),
helpUrl: "user-form-about",
menuItems: [
{
title: window.$gz.locale.get("Copy"),

View File

@@ -13,7 +13,8 @@ export default {
window.$gz.eventBus.$emit("menu-change", {
isMain: true,
icon: "fa-home",
title: window.$gz.locale.get("Home")
title: window.$gz.locale.get("Home"),
helpUrl: "user-form-home"
});
}
};

View File

@@ -13,7 +13,8 @@ export default {
window.$gz.eventBus.$emit("menu-change", {
isMain: true,
icon: "fa-file-invoice-dollar",
title: window.$gz.locale.get("Accounting")
title: window.$gz.locale.get("Accounting"),
helpUrl: "user-form-accounting"
});
}
};

View File

@@ -13,7 +13,8 @@ export default {
window.$gz.eventBus.$emit("menu-change", {
isMain: true,
icon: "fa-user-tie",
title: window.$gz.locale.get("Administration")
title: window.$gz.locale.get("Administration"),
helpUrl: "user-form-administration"
});
}
};

View File

@@ -13,7 +13,8 @@ export default {
window.$gz.eventBus.$emit("menu-change", {
isMain: true,
icon: "fa-shipping-fast",
title: window.$gz.locale.get("Dispatch")
title: window.$gz.locale.get("Dispatch"),
helpUrl: "user-form-dispatch"
});
}
};

View File

@@ -61,7 +61,8 @@ export default {
window.$gz.eventBus.$emit("menu-change", {
isMain: true,
icon: "fa-dolly",
title: window.$gz.locale.get("Inventory")
title: window.$gz.locale.get("Inventory"),
helpUrl: "user-form-inventory"
});
},
components: {

View File

@@ -26,6 +26,8 @@ export default {
isMain: false,
icon: "fa-info-circle",
title: window.$gz.locale.get("Log"),
helpUrl: "user-form-log",
menuItems: [
// {
// title: window.$gz.locale.get("Log"),

View File

@@ -13,7 +13,8 @@ export default {
window.$gz.eventBus.$emit("menu-change", {
isMain: true,
icon: "fa-cogs",
title: window.$gz.locale.get("Operations")
title: window.$gz.locale.get("Operations"),
helpUrl: "user-form-operations"
});
}
};

View File

@@ -13,7 +13,8 @@ export default {
window.$gz.eventBus.$emit("menu-change", {
isMain: true,
icon: "fa-toolbox",
title: window.$gz.locale.get("Service")
title: window.$gz.locale.get("Service"),
helpUrl: "user-form-service"
});
}
};