re-factor / cleanup
This commit is contained in:
@@ -3,6 +3,7 @@ import initialize from "./initialize";
|
||||
import notifypoll from "./notifypoll";
|
||||
|
||||
export function processLogin(authResponse, loggedInWithKnownPassword) {
|
||||
// eslint-disable-next-line no-async-promise-executor
|
||||
return new Promise(async function(resolve, reject) {
|
||||
try {
|
||||
//check there is a response of some kind
|
||||
|
||||
@@ -16,7 +16,7 @@ export default {
|
||||
const availableRoles = this.getSelectionList("AuthorizationRoles");
|
||||
for (let i = 0; i < availableRoles.length; i++) {
|
||||
const role = availableRoles[i];
|
||||
if (!!(enumValue & role.id)) {
|
||||
if (enumValue & role.id) {
|
||||
ret.push(role.name);
|
||||
}
|
||||
}
|
||||
@@ -70,7 +70,7 @@ export default {
|
||||
//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)) {
|
||||
const that = this;
|
||||
// eslint-disable-next-line
|
||||
|
||||
const dat = await that.fetchEnumKey(k);
|
||||
//massage the data as necessary
|
||||
const e = { enumKey: k, items: {} };
|
||||
@@ -84,10 +84,10 @@ export default {
|
||||
}
|
||||
},
|
||||
async fetchEnumKey(enumKey) {
|
||||
// eslint-disable-next-line
|
||||
const res = await window.$gz.api.get("enum-list/list/" + enumKey);
|
||||
//We never expect there to be no data here
|
||||
if (!res.hasOwnProperty("data")) {
|
||||
//if (!Object.prototype.hasOwnProperty.call(res, "data")) {
|
||||
if (!Object.prototype.hasOwnProperty.call(res, "data")) {
|
||||
return Promise.reject(res);
|
||||
}
|
||||
return res.data;
|
||||
|
||||
@@ -32,6 +32,7 @@ async function dealWithError(msg, vm) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(errMsg);
|
||||
|
||||
// eslint-disable-next-line no-debugger
|
||||
debugger;
|
||||
}
|
||||
|
||||
@@ -142,7 +143,7 @@ function decodeError(e, vm) {
|
||||
|
||||
//Javascript Fetch API Response object?
|
||||
if (e instanceof Response) {
|
||||
return `http error: ${err.statusText} - ${err.status} Url: ${err.url}`;
|
||||
return `http error: ${e.statusText} - ${e.status} Url: ${e.url}`;
|
||||
}
|
||||
|
||||
//last resort
|
||||
|
||||
@@ -542,7 +542,7 @@ export default {
|
||||
r = await that.extractBodyEx(r);
|
||||
return r;
|
||||
} catch (error) {
|
||||
handleError("POSTATTACHMENT", error, route);
|
||||
handleError("POSTATTACHMENT", error, "uploadAttachmentRoute");
|
||||
}
|
||||
},
|
||||
//////////////////////////////////////////////
|
||||
@@ -616,7 +616,7 @@ export default {
|
||||
r = await that.extractBodyEx(r);
|
||||
return r;
|
||||
} catch (error) {
|
||||
handleError("uploadLogo", error, route);
|
||||
handleError("uploadLogo", error, "postLogoRoute");
|
||||
}
|
||||
},
|
||||
///////////////////////////////////
|
||||
@@ -633,7 +633,6 @@ export default {
|
||||
LanguageName: window.$gz.locale.getResolvedLanguage(),
|
||||
Hour12: window.$gz.locale.getHour12(),
|
||||
CurrencyName: window.$gz.locale.getCurrencyName(),
|
||||
LanguageName: window.$gz.locale.getResolvedLanguage(),
|
||||
DefaultLocale: window.$gz.locale.getResolvedLanguage().split("-", 1)[0], //kind of suspect, maybe it can be removed
|
||||
PDFDate: window.$gz.locale.utcDateToShortDateLocalized(nowUtc),
|
||||
PDFTime: window.$gz.locale.utcDateToShortTimeLocalized(nowUtc)
|
||||
@@ -646,7 +645,7 @@ export default {
|
||||
async fetchBizObjectName(ayaType, objectId) {
|
||||
const res = await this.get(`name/${ayaType}/${objectId}`);
|
||||
//We never expect there to be no data here
|
||||
if (!res.hasOwnProperty("data")) {
|
||||
if (!Object.prototype.hasOwnProperty.call(res, "data")) {
|
||||
return Promise.reject(res);
|
||||
} else {
|
||||
return res.data;
|
||||
|
||||
@@ -239,9 +239,10 @@ export default {
|
||||
vm: vm
|
||||
});
|
||||
*/
|
||||
let key = null;
|
||||
//Find the last report key and update it if present
|
||||
for (let i = 0; i < vm.appBar.menuItems.length; i++) {
|
||||
var key = vm.appBar.menuItems[i].key;
|
||||
key = vm.appBar.menuItems[i].key;
|
||||
if (key && key.includes(":report:")) {
|
||||
vm.appBar.menuItems[i].key = newItem.key;
|
||||
vm.appBar.menuItems[i].title = newItem.title;
|
||||
@@ -250,7 +251,7 @@ export default {
|
||||
}
|
||||
//No prior last report so slot it in under the report one
|
||||
for (let i = 0; i < vm.appBar.menuItems.length; i++) {
|
||||
var key = vm.appBar.menuItems[i].key;
|
||||
key = vm.appBar.menuItems[i].key;
|
||||
if (key && key.endsWith(":report")) {
|
||||
vm.appBar.menuItems.splice(i + 1, 0, newItem);
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ export default {
|
||||
|
||||
removeAllPropertiesFromObject: function(o) {
|
||||
for (let variableKey in o) {
|
||||
if (o.hasOwnProperty(variableKey)) {
|
||||
if (Object.prototype.hasOwnProperty.call(o, variableKey)) {
|
||||
delete o[variableKey];
|
||||
}
|
||||
}
|
||||
@@ -136,7 +136,7 @@ export default {
|
||||
if (
|
||||
!key.endsWith("Viz") &&
|
||||
!skipNames.some(x => x == key) &&
|
||||
source.hasOwnProperty(key)
|
||||
Object.prototype.hasOwnProperty.call(source, key)
|
||||
) {
|
||||
o[key] = source[key];
|
||||
}
|
||||
@@ -201,7 +201,7 @@ export default {
|
||||
// ROUNDING
|
||||
// //https://medium.com/swlh/how-to-round-to-a-certain-number-of-decimal-places-in-javascript-ed74c471c1b8
|
||||
roundAccurately: function(number, decimalPlaces) {
|
||||
if (!number || number == 0 || number == NaN) {
|
||||
if (!number || number == 0 || Number.isNaN(number)) {
|
||||
return number;
|
||||
}
|
||||
const wasNegative = number < 0;
|
||||
@@ -300,7 +300,7 @@ export default {
|
||||
|
||||
//A number already then parse and return
|
||||
if (this.isNumeric(string)) {
|
||||
if (string === NaN) {
|
||||
if (Number.isNaN(string)) {
|
||||
return 0;
|
||||
}
|
||||
return parseFloat(string);
|
||||
@@ -312,7 +312,7 @@ export default {
|
||||
}
|
||||
|
||||
const ret = parseFloat(string.replace(/[^\d.-]/g, ""));
|
||||
if (ret == NaN) {
|
||||
if (Number.isNaN(ret)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -324,7 +324,7 @@ export default {
|
||||
//
|
||||
isNegative: function(v) {
|
||||
//null or empty then zero
|
||||
if (!v || v == 0 || v == NaN) {
|
||||
if (!v || v == 0 || Number.isNaN(v)) {
|
||||
return false;
|
||||
}
|
||||
return parseFloat(v) < 0;
|
||||
@@ -943,25 +943,25 @@ export default {
|
||||
const ret = [];
|
||||
|
||||
//turn EXCLUDE selected gzDaysOfWeek into INCLUDE selected days for vCalendar
|
||||
if (!!!(dow & 64)) {
|
||||
if (!(dow & 64)) {
|
||||
ret.push(0);
|
||||
}
|
||||
if (!!!(dow & 1)) {
|
||||
if (!(dow & 1)) {
|
||||
ret.push(1);
|
||||
}
|
||||
if (!!!(dow & 2)) {
|
||||
if (!(dow & 2)) {
|
||||
ret.push(2);
|
||||
}
|
||||
if (!!!(dow & 4)) {
|
||||
if (!(dow & 4)) {
|
||||
ret.push(3);
|
||||
}
|
||||
if (!!!(dow & 8)) {
|
||||
if (!(dow & 8)) {
|
||||
ret.push(4);
|
||||
}
|
||||
if (!!!(dow & 16)) {
|
||||
if (!(dow & 16)) {
|
||||
ret.push(5);
|
||||
}
|
||||
if (!!!(dow & 32)) {
|
||||
if (!(dow & 32)) {
|
||||
ret.push(6);
|
||||
}
|
||||
return ret;
|
||||
|
||||
@@ -862,8 +862,7 @@ async function getUserOptions() {
|
||||
"logItem",
|
||||
"Initialize::() fetch useroptions -> error" + error
|
||||
);
|
||||
// throw new Error(error);
|
||||
throw new Error(window.$gz.errorHandler.errorToString(res));
|
||||
throw new Error(window.$gz.errorHandler.errorToString(error));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -871,6 +870,7 @@ async function getUserOptions() {
|
||||
// Initialize the app
|
||||
// on change of authentication status
|
||||
export default function initialize() {
|
||||
// eslint-disable-next-line no-async-promise-executor
|
||||
return new Promise(async function(resolve, reject) {
|
||||
if (!window.$gz.store.state.authenticated) {
|
||||
throw new Error("initialize: Error, called but user not authenticated!");
|
||||
|
||||
@@ -453,12 +453,7 @@ export default {
|
||||
///////////////////////////////////////////////
|
||||
// Get default start date time in api format
|
||||
// (this is used to centralize and for future)
|
||||
defaultStartDateTime(ofType) {
|
||||
//ofType in future could be for
|
||||
//different areas having different custom start / top times
|
||||
//so will set that in all callers for future purposes, but
|
||||
//for now, here going to ignore it and just default to now
|
||||
//and now plus one hour
|
||||
defaultStartDateTime() {
|
||||
return {
|
||||
start: window.$gz.DateTime.local()
|
||||
.toUTC()
|
||||
|
||||
@@ -10,7 +10,7 @@ export default {
|
||||
|
||||
if (editedTranslation) {
|
||||
//iterate the keys that are cached and set them from whatever is in editedTranslation for that key
|
||||
for (const [key, value] of Object.entries(
|
||||
for (const [key] of Object.entries(
|
||||
window.$gz.store.state.translationText
|
||||
)) {
|
||||
const display = editedTranslation.translationItems.find(
|
||||
@@ -55,6 +55,7 @@ export default {
|
||||
return window.$gz.store.state.translationText[key];
|
||||
},
|
||||
async cacheTranslations(keys, forceTranslationId) {
|
||||
// eslint-disable-next-line no-async-promise-executor
|
||||
return new Promise(async function fetchTranslationKeysFromServer(resolve) {
|
||||
//
|
||||
//step 1: build an array of keys that we don't have already
|
||||
|
||||
Reference in New Issue
Block a user