diff --git a/ayanova/devdocs/todo.txt b/ayanova/devdocs/todo.txt index f82b01f1..bf14c287 100644 --- a/ayanova/devdocs/todo.txt +++ b/ayanova/devdocs/todo.txt @@ -486,7 +486,7 @@ CASES TODO: ideally in some kind of order so it's easy to find them and remove any they don't want also it should have a sane limit of some kind so 10,000 units aren't added accidentally to a workorder Do at client so user can just not save if they fuck it up - 3560 - changing date and time updates quantity?? (customer request, see how it was in v7 and replicate if it was that, but I have doubts if this is a good idea) + 3709 - Project to have list all workorders button also this is the point to make sure that is working with all the other list all workorders previously added in stubbed form like Customer, Unit etc 3720 - prevent double booking a tech (some kind of warning) diff --git a/ayanova/src/components/work-order-item-labors.vue b/ayanova/src/components/work-order-item-labors.vue index db4a3f86..08759d61 100644 --- a/ayanova/src/components/work-order-item-labors.vue +++ b/ayanova/src/components/work-order-item-labors.vue @@ -476,8 +476,10 @@ export default { concurrency: 0, userId: null, //userViz: null, - serviceStartDate: window.$gz.locale.nowUTC8601String(), - serviceStopDate: window.$gz.locale.nowUTC8601String(), //TODO:sb now plus one hour to match v7 + serviceStartDate: null, + serviceStopDate: null, //Actually I think it's best to be null, user can select NOW from start or stop and have it automatically do it's thing + // serviceStartDate: window.$gz.locale.nowUTC8601String(), + // serviceStopDate: window.$gz.locale.nowUTC8601String(), //TODO:sb now plus one hour to match v7 serviceRateId: null, serviceDetails: null, serviceRateQuantity: 1, @@ -531,6 +533,86 @@ export default { this.activeItemIndex ].isDirty = true; window.$gz.form.fieldValueChanged(this.pvm, ref); + //------- SPECIAL HANDLING OF CHANGES ----------- + const isNew = + this.value.items[this.activeWoItemIndex].labors[this.activeItemIndex] + .id == 0; + + //Auto calculate dates / quantities / global defaults + const dStart = this.value.items[this.activeWoItemIndex].labors[ + this.activeItemIndex + ].serviceStartDate; + const dStop = this.value.items[this.activeWoItemIndex].labors[ + this.activeItemIndex + ].serviceStopDate; + if (ref.includes("serviceStartDate") && dStart != null) { + this.handleStartDateChange(isNew, dStart, dStop); + } + if (ref.includes("serviceStopDate") && dStop != null) { + this.handleStopDateChange(isNew, dStart, dStop); + } + //------------------------------------------------------ + } + }, + handleStartDateChange: function(isNew, dStart, dStop) { + const globalMinutes = + window.$gz.store.state.globalSettings.workLaborScheduleDefaultMinutes; + + if (isNew && dStop == null) { + if (globalMinutes != 0) { + //set stop date based on start date and global minutes + this.value.items[this.activeWoItemIndex].labors[ + this.activeItemIndex + ].serviceStopDate = window.$gz.locale.addMinutesToUTC8601String( + dStart, + globalMinutes + ); + + this.value.items[this.activeWoItemIndex].labors[ + this.activeItemIndex + ].serviceRateQuantity = globalMinutes; + } + } else { + //Existing record or both dates filled, just update quantity + if (dStop != null) { + this.value.items[this.activeWoItemIndex].labors[ + this.activeItemIndex + ].serviceRateQuantity = window.$gz.locale.diffHoursFromUTC8601String( + dStart, + dStop + ); + } + } + }, + handleStopDateChange: function(isNew, dStart, dStop) { + const globalMinutes = + window.$gz.store.state.globalSettings.workLaborScheduleDefaultMinutes; + + if (isNew && dStart == null) { + if (globalMinutes != 0) { + //set start date based on stop date and global minutes + this.value.items[this.activeWoItemIndex].labors[ + this.activeItemIndex + ].serviceStartDate = window.$gz.locale.addMinutesToUTC8601String( + dStop, + 0 - globalMinutes + ); + + this.value.items[this.activeWoItemIndex].labors[ + this.activeItemIndex + ].serviceRateQuantity = globalMinutes; + } + } else { + //Existing record or both dates filled, just update quantity + if (dStart != null) { + console.log("setting serviceRateQuantity"); + this.value.items[this.activeWoItemIndex].labors[ + this.activeItemIndex + ].serviceRateQuantity = window.$gz.locale.diffHoursFromUTC8601String( + dStart, + dStop + ); + } } }, itemRowClasses: function(item) { diff --git a/ayanova/src/components/work-order-item-scheduled-users.vue b/ayanova/src/components/work-order-item-scheduled-users.vue index 24b3fcc2..86bfa4a1 100644 --- a/ayanova/src/components/work-order-item-scheduled-users.vue +++ b/ayanova/src/components/work-order-item-scheduled-users.vue @@ -390,6 +390,7 @@ export default { this.activeItemIndex ].isDirty = true; window.$gz.form.fieldValueChanged(this.pvm, ref); + //------- SPECIAL HANDLING OF CHANGES ----------- const isNew = this.value.items[this.activeWoItemIndex].scheduledUsers[ this.activeItemIndex @@ -408,9 +409,7 @@ export default { if (ref.includes("stopDate") && dStop != null) { this.handleStopDateChange(isNew, dStart, dStop); } - if (ref.includes("estimatedQuantity")) { - this.handleEstimatedQuantityChange(isNew, dStart, dStop); - } + //------------------------------------------------------ } }, handleStartDateChange: function(isNew, dStart, dStop) { @@ -444,7 +443,6 @@ export default { } }, handleStopDateChange: function(isNew, dStart, dStop) { - // (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 const globalMinutes = window.$gz.store.state.globalSettings.workLaborScheduleDefaultMinutes; @@ -474,12 +472,6 @@ export default { } } }, - handleEstimatedQuantityChange: function(isNew, dStart, dStop) { - let val = this.value.items[this.activeWoItemIndex].scheduledUsers[ - this.activeItemIndex - ].estimatedQuantity; - console.log("Estimated Quantity is now", val); - }, itemRowClasses: function(item) { let ret = ""; const isDeleted =