scheduler-node-models 1.2.28 → 1.2.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -167,6 +167,11 @@ export declare class Employee implements IEmployee {
|
|
|
167
167
|
* @param start The date object used to mark the start of the assignment
|
|
168
168
|
*/
|
|
169
169
|
addAssignment(site: string, wkctr: string, start: Date): void;
|
|
170
|
+
/**
|
|
171
|
+
* The function will remove a particular assignment from the assignment list
|
|
172
|
+
* @param id The numeric identifier for the assignment to remove.
|
|
173
|
+
*/
|
|
174
|
+
removeAssignment(id: number): void;
|
|
170
175
|
/**
|
|
171
176
|
* This method is used to add a new variation to the employee. It will determine the
|
|
172
177
|
* new variation's identifier and add that along with site and start date to the new
|
|
@@ -176,10 +181,29 @@ export declare class Employee implements IEmployee {
|
|
|
176
181
|
*/
|
|
177
182
|
addVariation(site: string, start: Date): void;
|
|
178
183
|
/**
|
|
179
|
-
*
|
|
180
|
-
*
|
|
184
|
+
* This method will update the selected variation with an update a single
|
|
185
|
+
* field in the selected variation. If the variation isn't found, an error
|
|
186
|
+
* will be transmitted to the requestor.
|
|
187
|
+
* @param varID A numeric value for the variation to change.
|
|
188
|
+
* @param field A string value for the data member to change.
|
|
189
|
+
* @param value A string value representing the data member's new value.
|
|
190
|
+
* @param workday (Optional) a numeric value for the workday to update if the update
|
|
191
|
+
* field is in a variation workday.
|
|
181
192
|
*/
|
|
182
|
-
|
|
193
|
+
updateVariation(varID: number, field: string, value: string, workday?: number): void;
|
|
194
|
+
/**
|
|
195
|
+
* This method will be used to convert a date string in the format of 2006-01-02 to
|
|
196
|
+
* a Date object with that date.
|
|
197
|
+
* @param date A string value in the correct format
|
|
198
|
+
* @returns
|
|
199
|
+
*/
|
|
200
|
+
private getDateFromString;
|
|
201
|
+
/**
|
|
202
|
+
* This method will be used to remove a single variation from the employee's variation
|
|
203
|
+
* list. An error will be thrown if the variation is not found.
|
|
204
|
+
* @param varID A numeric value for the identifier of the variation to delete.
|
|
205
|
+
*/
|
|
206
|
+
removeVariation(varID: number): void;
|
|
183
207
|
/**
|
|
184
208
|
* This function will determine if a labor code (charge number and extension) is the
|
|
185
209
|
* employee's primary code for the date given.
|
|
@@ -565,6 +565,37 @@ class Employee {
|
|
|
565
565
|
}
|
|
566
566
|
this.assignments.push(newAsgmt);
|
|
567
567
|
}
|
|
568
|
+
/**
|
|
569
|
+
* The function will remove a particular assignment from the assignment list
|
|
570
|
+
* @param id The numeric identifier for the assignment to remove.
|
|
571
|
+
*/
|
|
572
|
+
removeAssignment(id) {
|
|
573
|
+
this.assignments.sort((a, b) => a.compareTo(b));
|
|
574
|
+
let pos = -1;
|
|
575
|
+
for (let a = 0; a < this.assignments.length && pos < 0; a++) {
|
|
576
|
+
if (this.assignments[a].id === id) {
|
|
577
|
+
pos = a;
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
if (pos === 0) {
|
|
581
|
+
const asgmt = this.assignments[pos];
|
|
582
|
+
const nextAsgmt = this.assignments[pos + 1];
|
|
583
|
+
nextAsgmt.startDate = new Date(asgmt.startDate);
|
|
584
|
+
this.assignments[pos + 1] = nextAsgmt;
|
|
585
|
+
this.assignments.splice(pos, 1);
|
|
586
|
+
}
|
|
587
|
+
else if (pos === this.assignments.length - 1) {
|
|
588
|
+
if (pos > 0) {
|
|
589
|
+
this.assignments[pos - 1].endDate = new Date(Date.UTC(9999, 11, 31));
|
|
590
|
+
this.assignments.pop();
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
else {
|
|
594
|
+
this.assignments[pos - 1].endDate
|
|
595
|
+
= new Date(this.assignments[pos + 1].startDate.getTime() - (24 * 3600000));
|
|
596
|
+
this.assignments.splice(pos, 1);
|
|
597
|
+
}
|
|
598
|
+
}
|
|
568
599
|
/**
|
|
569
600
|
* This method is used to add a new variation to the employee. It will determine the
|
|
570
601
|
* new variation's identifier and add that along with site and start date to the new
|
|
@@ -590,34 +621,97 @@ class Employee {
|
|
|
590
621
|
this.variations.sort((a, b) => a.compareTo(b));
|
|
591
622
|
}
|
|
592
623
|
/**
|
|
593
|
-
*
|
|
594
|
-
*
|
|
624
|
+
* This method will update the selected variation with an update a single
|
|
625
|
+
* field in the selected variation. If the variation isn't found, an error
|
|
626
|
+
* will be transmitted to the requestor.
|
|
627
|
+
* @param varID A numeric value for the variation to change.
|
|
628
|
+
* @param field A string value for the data member to change.
|
|
629
|
+
* @param value A string value representing the data member's new value.
|
|
630
|
+
* @param workday (Optional) a numeric value for the workday to update if the update
|
|
631
|
+
* field is in a variation workday.
|
|
595
632
|
*/
|
|
596
|
-
|
|
597
|
-
this.
|
|
598
|
-
let
|
|
599
|
-
|
|
600
|
-
if (
|
|
601
|
-
|
|
633
|
+
updateVariation(varID, field, value, workday) {
|
|
634
|
+
this.variations.sort((a, b) => a.compareTo(b));
|
|
635
|
+
let found = false;
|
|
636
|
+
this.variations.forEach((vari, v) => {
|
|
637
|
+
if (vari.id === varID) {
|
|
638
|
+
found = true;
|
|
639
|
+
switch (field.toLowerCase()) {
|
|
640
|
+
case "site":
|
|
641
|
+
vari.site = value;
|
|
642
|
+
break;
|
|
643
|
+
case "mids":
|
|
644
|
+
case "ismids":
|
|
645
|
+
vari.mids = Boolean(value);
|
|
646
|
+
break;
|
|
647
|
+
case "dates":
|
|
648
|
+
vari.schedule.showdates = Boolean(value);
|
|
649
|
+
break;
|
|
650
|
+
case "start":
|
|
651
|
+
case "startdate":
|
|
652
|
+
vari.startdate = this.getDateFromString(value);
|
|
653
|
+
break;
|
|
654
|
+
case "end":
|
|
655
|
+
case "enddate":
|
|
656
|
+
vari.enddate = this.getDateFromString(value);
|
|
657
|
+
break;
|
|
658
|
+
case "changeschedule":
|
|
659
|
+
vari.schedule.setScheduleDays(Number(value));
|
|
660
|
+
break;
|
|
661
|
+
case "workday-code":
|
|
662
|
+
case "workday-workcenter":
|
|
663
|
+
case "workday-hours":
|
|
664
|
+
case "workday-copy":
|
|
665
|
+
const wparts = field.split('-');
|
|
666
|
+
if (workday) {
|
|
667
|
+
vari.updateWorkday(workday, wparts[1], value);
|
|
668
|
+
}
|
|
669
|
+
break;
|
|
670
|
+
}
|
|
671
|
+
this.variations[v] = vari;
|
|
602
672
|
}
|
|
673
|
+
});
|
|
674
|
+
if (!found) {
|
|
675
|
+
throw new Error('Variation not found');
|
|
603
676
|
}
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
677
|
+
}
|
|
678
|
+
/**
|
|
679
|
+
* This method will be used to convert a date string in the format of 2006-01-02 to
|
|
680
|
+
* a Date object with that date.
|
|
681
|
+
* @param date A string value in the correct format
|
|
682
|
+
* @returns
|
|
683
|
+
*/
|
|
684
|
+
getDateFromString(date) {
|
|
685
|
+
const reDateFormat = new RegExp('^[0-9]{4}\-[0-9]{2}\-[0-9]{2}$');
|
|
686
|
+
if (reDateFormat.test(date)) {
|
|
687
|
+
const parts = date.split('-');
|
|
688
|
+
const year = parseInt(parts[0]);
|
|
689
|
+
const month = parseInt(parts[1]);
|
|
690
|
+
const day = parseInt(parts[2]);
|
|
691
|
+
const result = new Date(Date.UTC(year, month - 1, day));
|
|
692
|
+
return result;
|
|
610
693
|
}
|
|
611
|
-
else
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
694
|
+
else {
|
|
695
|
+
throw new Error('Date not in correct format (yyyy-mm-dd)');
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
/**
|
|
699
|
+
* This method will be used to remove a single variation from the employee's variation
|
|
700
|
+
* list. An error will be thrown if the variation is not found.
|
|
701
|
+
* @param varID A numeric value for the identifier of the variation to delete.
|
|
702
|
+
*/
|
|
703
|
+
removeVariation(varID) {
|
|
704
|
+
let found = -1;
|
|
705
|
+
this.variations.forEach((vari, v) => {
|
|
706
|
+
if (vari.id === varID) {
|
|
707
|
+
found = v;
|
|
615
708
|
}
|
|
709
|
+
});
|
|
710
|
+
if (found >= 0) {
|
|
711
|
+
this.variations.splice(found, 1);
|
|
616
712
|
}
|
|
617
713
|
else {
|
|
618
|
-
|
|
619
|
-
= new Date(this.assignments[pos + 1].startDate.getTime() - (24 * 3600000));
|
|
620
|
-
this.assignments.splice(pos, 1);
|
|
714
|
+
throw new Error('Variation not found');
|
|
621
715
|
}
|
|
622
716
|
}
|
|
623
717
|
/**
|