This commit is contained in:
@@ -79,6 +79,8 @@ todo: Contract override by TAGS
|
|||||||
todo: form field customization add a "reset" feature to reset to default for when people fuck it up
|
todo: form field customization add a "reset" feature to reset to default for when people fuck it up
|
||||||
basically just show all fields and remove the required from fields
|
basically just show all fields and remove the required from fields
|
||||||
|
|
||||||
|
todo: add NOW button to date picker just like time picker that does the same thing
|
||||||
|
|
||||||
todo: Not in love with the "Error api2200" as the only error text in the box
|
todo: Not in love with the "Error api2200" as the only error text in the box
|
||||||
sometimes it has things you can't see in the form
|
sometimes it has things you can't see in the form
|
||||||
ideally I'd like to see it have a string of text as a duplicate showing the errors translated in a list
|
ideally I'd like to see it have a string of text as a duplicate showing the errors translated in a list
|
||||||
|
|||||||
@@ -179,6 +179,25 @@ export default {
|
|||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
///////////////////////////////
|
///////////////////////////////
|
||||||
|
// 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) {
|
||||||
|
return number;
|
||||||
|
}
|
||||||
|
let wasNegative = number < 0;
|
||||||
|
if (wasNegative) {
|
||||||
|
number = Match.abs(number); //make sure it's positive because rounding negative numbers is weird in JS
|
||||||
|
}
|
||||||
|
number = Number(
|
||||||
|
Math.round(number + "e" + decimalPlaces) + "e-" + decimalPlaces
|
||||||
|
);
|
||||||
|
if (wasNegative) {
|
||||||
|
number = 0 - number;
|
||||||
|
}
|
||||||
|
return number;
|
||||||
|
},
|
||||||
|
///////////////////////////////
|
||||||
// CLEAN TAG NAME
|
// CLEAN TAG NAME
|
||||||
// Clean up a tag with same rules as server
|
// Clean up a tag with same rules as server
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -243,11 +243,47 @@ export default {
|
|||||||
}
|
}
|
||||||
//instantiate a luxon date object from val which is assumed to be an iso string
|
//instantiate a luxon date object from val which is assumed to be an iso string
|
||||||
let dt = window.$gz.DateTime.fromISO(val);
|
let dt = window.$gz.DateTime.fromISO(val);
|
||||||
|
if (!dt.isValid) {
|
||||||
|
console.error("locale::addMinutes, input not valid:", {
|
||||||
|
val: val,
|
||||||
|
dt: dt
|
||||||
|
});
|
||||||
|
return val;
|
||||||
|
}
|
||||||
//add minutes
|
//add minutes
|
||||||
dt = dt.plus({ minutes: minutes });
|
dt = dt.plus({ minutes: minutes });
|
||||||
return dt.toUTC().toString();
|
return dt.toUTC().toString();
|
||||||
},
|
},
|
||||||
///////////////////////////////////////////////
|
///////////////////////////////////////////////
|
||||||
|
// parse UTC ISO 8601 strings, diff, return hours
|
||||||
|
//
|
||||||
|
diffHoursFromUTC8601String(start, stop) {
|
||||||
|
if (!start || start == "" || !stop == null || stop == "") {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
//instantiate a luxon date object from val which is assumed to be an iso string
|
||||||
|
const startDate = window.$gz.DateTime.fromISO(start);
|
||||||
|
if (!startDate.isValid) {
|
||||||
|
console.error("locale::diffHours, start not valid:", {
|
||||||
|
start: start,
|
||||||
|
startDate: startDate
|
||||||
|
});
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
const stopDate = window.$gz.DateTime.fromISO(stop);
|
||||||
|
if (!stopDate.isValid) {
|
||||||
|
console.error("locale::diffHours, start not valid:", {
|
||||||
|
stop: stop,
|
||||||
|
stopDate: stopDate
|
||||||
|
});
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return window.$gz.util.roundAccurately(
|
||||||
|
stopDate.diff(startDate, "hours").toObject().hours,
|
||||||
|
2
|
||||||
|
);
|
||||||
|
},
|
||||||
|
///////////////////////////////////////////////
|
||||||
// Local now timestamp converted to timeZoneName
|
// Local now timestamp converted to timeZoneName
|
||||||
// and output as ISO 8601
|
// and output as ISO 8601
|
||||||
// (used to inform server of local client time)
|
// (used to inform server of local client time)
|
||||||
|
|||||||
@@ -408,17 +408,33 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
handleStartDateChange: function(isNew) {
|
handleStartDateChange: function(isNew) {
|
||||||
const dt = this.value.items[this.activeWoItemIndex].scheduledUsers[
|
const dStart = this.value.items[this.activeWoItemIndex].scheduledUsers[
|
||||||
this.activeItemIndex
|
this.activeItemIndex
|
||||||
].startDate;
|
].startDate;
|
||||||
|
|
||||||
console.log("IsNew:", isNew);
|
if (isNew) {
|
||||||
const globalMinutes =
|
// (ONLY IF GLOBAL DEFAULT QTY) enter start date when stop date is null then it will add global default to start and set stop and qty
|
||||||
window.$gz.store.state.globalSettings.workLaborScheduleDefaultMinutes;
|
// (ONLY IF GLOBAL DEFAULT QTY) enter stop date when start date is null then it will back calc and set start and qty based on global default
|
||||||
if (globalMinutes == 0) {
|
// If no global default then it acts like existing and updates qty or stop date when qty changes (if there are dates to go on)
|
||||||
return;
|
|
||||||
|
const globalMinutes =
|
||||||
|
window.$gz.store.state.globalSettings.workLaborScheduleDefaultMinutes;
|
||||||
|
if (globalMinutes == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let d = window.$gz.locale.addMinutesToUTC8601String(dStart);
|
||||||
|
} else {
|
||||||
|
const dStop = this.value.items[this.activeWoItemIndex].scheduledUsers[
|
||||||
|
this.activeItemIndex
|
||||||
|
].stopDate;
|
||||||
|
// Existing
|
||||||
|
// update quantity when dates change or update stop date when quantity changes to match
|
||||||
|
// no consideration for global default, once it's made that shit doesn't apply
|
||||||
|
console.log(
|
||||||
|
"existing record - DIFF HOURS IS:",
|
||||||
|
window.$gz.locale.diffHoursFromUTC8601String(dStart, dStop)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
let d = window.$gz.locale.addMinutesToUTC8601String(dt);
|
|
||||||
},
|
},
|
||||||
handleStopDateChange: function(isNew) {
|
handleStopDateChange: function(isNew) {
|
||||||
let val = this.value.items[this.activeWoItemIndex].scheduledUsers[
|
let val = this.value.items[this.activeWoItemIndex].scheduledUsers[
|
||||||
|
|||||||
Reference in New Issue
Block a user