gunsmith-common 2.3.3 → 2.3.4

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.
@@ -1,9 +1,9 @@
1
- import { DateTime } from 'luxon';
2
1
  import * as i0 from '@angular/core';
3
2
  import { Injectable, Inject, Pipe, Directive, Input, Component, EventEmitter, Output, NgModule } from '@angular/core';
4
3
  import * as i1 from '@angular/common/http';
5
- import { of, switchMap as switchMap$1, Subject } from 'rxjs';
4
+ import { of, switchMap as switchMap$1, lastValueFrom, forkJoin, Subject } from 'rxjs';
6
5
  import { switchMap } from 'rxjs/operators';
6
+ import { DateTime } from 'luxon';
7
7
  import * as i2 from '@angular/forms';
8
8
  import { NgControl, Validators, NG_VALUE_ACCESSOR, NG_VALIDATORS, FormsModule, ReactiveFormsModule } from '@angular/forms';
9
9
  import * as i3 from '@progress/kendo-angular-dropdowns';
@@ -507,6 +507,7 @@ class FirearmOptic {
507
507
  this.rearSights = [];
508
508
  this.keepDovetail = false;
509
509
  this.removeDovetail = false;
510
+ this.active = true;
510
511
  }
511
512
  }
512
513
 
@@ -520,34 +521,6 @@ class SlideAddon {
520
521
  }
521
522
  }
522
523
 
523
- function adjustHoliday(finishDate, holidays) {
524
- while (holidays.map(h => new Date(h.holiday)).findIndex(h => DateTime.fromJSDate(h) === DateTime.fromJSDate(finishDate)) !== -1) {
525
- do {
526
- finishDate = DateTime.fromJSDate(finishDate).plus({ days: 1 }).toJSDate();
527
- } while (finishDate.getDay() === 0 || finishDate.getDay() === 6);
528
- }
529
- return finishDate;
530
- }
531
- function calculateFinishDate(receivedDate, workOrderType, configs, holidays) {
532
- if (!receivedDate) {
533
- return null;
534
- }
535
- let finishDate = DateTime.fromJSDate(receivedDate).startOf("day");
536
- if (workOrderType === WorkOrderType.Warranty) {
537
- finishDate = finishDate.plus({ weeks: configs.warrantyWeeks });
538
- }
539
- else if (workOrderType === WorkOrderType.Expedited) {
540
- finishDate = finishDate.plus({ weeks: configs.expeditedWeeks });
541
- }
542
- else if (workOrderType === WorkOrderType.NewInBox) {
543
- finishDate = finishDate.plus({ weeks: configs.newInBoxWeeks });
544
- }
545
- else {
546
- finishDate = finishDate.plus({ weeks: configs.standardWeeks });
547
- }
548
- return adjustHoliday(finishDate.toJSDate(), holidays);
549
- }
550
-
551
524
  class CustomerService {
552
525
  constructor(http, env) {
553
526
  this.http = http;
@@ -609,19 +582,23 @@ class BaseService {
609
582
  return this.http.get(this.getUrl(...params));
610
583
  }
611
584
  getAllWithParams(queryParams, ...params) {
612
- return this.http.get(this.getUrl(...params), { params: queryParams });
585
+ return this.http
586
+ .get(this.getUrl(...params), { params: queryParams });
613
587
  }
614
588
  get(...params) {
615
589
  return this.http.get(this.getUrl(...params));
616
590
  }
617
591
  create(item, ...params) {
618
- return this.http.post(this.getUrl(...params), item);
592
+ return this.http
593
+ .post(this.getUrl(...params), item);
619
594
  }
620
595
  update(item, ...params) {
621
- return this.http.put(this.getUrl(...params), item);
596
+ return this.http
597
+ .put(this.getUrl(...params), item);
622
598
  }
623
599
  delete(...params) {
624
- return this.http.delete(this.getUrl(...params));
600
+ return this.http
601
+ .delete(this.getUrl(...params));
625
602
  }
626
603
  }
627
604
  BaseService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: BaseService, deps: [{ token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
@@ -1322,46 +1299,6 @@ class CoatingService extends BaseService {
1322
1299
  this.env = env;
1323
1300
  this.urlSegments = [`${this.env.baseUrl}api/coatings`];
1324
1301
  }
1325
- // readCoatings(includeInactive = false): Observable<Coating[]> {
1326
- // const params = {
1327
- // includeInactive: includeInactive.toString(),
1328
- // };
1329
- // return this.http.get<Coating[]>(this.url, {
1330
- // params: params,
1331
- // });
1332
- // }
1333
- // readCoating(id: number): Observable<Coating> {
1334
- // return this.http.get<Coating>(`${this.url}/${id}`);
1335
- // }
1336
- // createCoating(coating: Coating): Observable<Coating> {
1337
- // return this.http.post<Coating>(this.url, coating);
1338
- // }
1339
- // updateCoating(id: number, coating: Coating): Observable<Coating> {
1340
- // return this.http.put<Coating>(`${this.url}/${id}`, coating);
1341
- // }
1342
- // deleteCoating(id: number): Observable<any> {
1343
- // return this.http.delete(`${this.url}/${id}`);
1344
- // }
1345
- // Coating Values
1346
- readCoatingValues(coatingId, includeInactive = false) {
1347
- return this.http.get(`${this.url}/${coatingId}/coating-values`, {
1348
- params: {
1349
- includeInactive: includeInactive.toString(),
1350
- },
1351
- });
1352
- }
1353
- readCoatingValue(coatingId, coatingValueId) {
1354
- return this.http.get(`${this.url}/${coatingId}/coating-values/${coatingValueId}`);
1355
- }
1356
- createCoatingValue(coatingId, coatingValue) {
1357
- return this.http.post(`${this.url}/${coatingId}/coating-values`, coatingValue);
1358
- }
1359
- updateCoatingValue(coatingId, coatingValueId, coatingValue) {
1360
- return this.http.put(`${this.url}/${coatingId}/coating-values/${coatingValueId}`, coatingValue);
1361
- }
1362
- deleteCoatingValue(coatingId, coatingValueId) {
1363
- return this.http.delete(`${this.url}/${coatingId}/coating-values/${coatingValueId}`);
1364
- }
1365
1302
  }
1366
1303
  CoatingService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: CoatingService, deps: [{ token: i1.HttpClient }, { token: "env" }], target: i0.ɵɵFactoryTarget.Injectable });
1367
1304
  CoatingService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: CoatingService, providedIn: "root" });
@@ -1956,6 +1893,68 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImpo
1956
1893
  args: ["env"]
1957
1894
  }] }]; } });
1958
1895
 
1896
+ class FinishDateHelperService {
1897
+ constructor(configService, holidayService) {
1898
+ this.configService = configService;
1899
+ this.holidayService = holidayService;
1900
+ this.holidays = [];
1901
+ }
1902
+ adjustHoliday(finishDate) {
1903
+ while (this.holidays
1904
+ .map((h) => new Date(h.holiday))
1905
+ .findIndex((h) => h === finishDate) !== -1) {
1906
+ do {
1907
+ finishDate = DateTime.fromJSDate(finishDate)
1908
+ .plus({ days: 1 })
1909
+ .toJSDate();
1910
+ } while (finishDate.getDay() === 0 || finishDate.getDay() === 6);
1911
+ }
1912
+ return finishDate;
1913
+ }
1914
+ calculateFinishDate(receivedDate, workOrderType) {
1915
+ let finishDate = DateTime.fromJSDate(receivedDate).startOf("day");
1916
+ if (workOrderType === WorkOrderType.Warranty) {
1917
+ finishDate = finishDate.plus({ weeks: this.configs.warrantyWeeks });
1918
+ }
1919
+ else if (workOrderType === WorkOrderType.Expedited) {
1920
+ finishDate = finishDate.plus({ weeks: this.configs.expeditedWeeks });
1921
+ }
1922
+ else if (workOrderType === WorkOrderType.NewInBox) {
1923
+ finishDate = finishDate.plus({ weeks: this.configs.newInBoxWeeks });
1924
+ }
1925
+ else {
1926
+ finishDate = finishDate.plus({ weeks: this.configs.standardWeeks });
1927
+ }
1928
+ return this.adjustHoliday(finishDate.toJSDate());
1929
+ }
1930
+ async calculate(receivedDate, workOrderType) {
1931
+ if (!receivedDate) {
1932
+ return null;
1933
+ }
1934
+ if (!this.configs) {
1935
+ return await lastValueFrom(forkJoin([
1936
+ this.configService.readConfigs(),
1937
+ this.holidayService.readHolidays(),
1938
+ ]).pipe(switchMap$1(([configs, holidays]) => {
1939
+ this.configs = configs;
1940
+ this.holidays = holidays;
1941
+ return of(this.calculateFinishDate(receivedDate, workOrderType));
1942
+ })));
1943
+ }
1944
+ return await new Promise((resolve) => {
1945
+ resolve(this.calculateFinishDate(receivedDate, workOrderType));
1946
+ });
1947
+ }
1948
+ }
1949
+ FinishDateHelperService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: FinishDateHelperService, deps: [{ token: ConfigurationService }, { token: WorkHolidayService }], target: i0.ɵɵFactoryTarget.Injectable });
1950
+ FinishDateHelperService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: FinishDateHelperService, providedIn: "root" });
1951
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: FinishDateHelperService, decorators: [{
1952
+ type: Injectable,
1953
+ args: [{
1954
+ providedIn: "root",
1955
+ }]
1956
+ }], ctorParameters: function () { return [{ type: ConfigurationService }, { type: WorkHolidayService }]; } });
1957
+
1959
1958
  class PhonePipe {
1960
1959
  transform(value, args) {
1961
1960
  if (value && value.length >= 10) {
@@ -2468,5 +2467,5 @@ var NotificationType;
2468
2467
  * Generated bundle index. Do not edit.
2469
2468
  */
2470
2469
 
2471
- export { BaseService, BundleItem, ChangeOrderPackageDetail, ChangeOrderStatus, Coating, CoatingService, CoatingValue, CoatingValueService, Configuration, ConfigurationService, Customer, CustomerService, Dealer, DealerContact, DealerCoupon, DealerService, DisableControlDirective, EnumPipe, FileNamePipe, FileUploadService, FilterOptions, Firearm, FirearmOptic, FirearmOpticService, FirearmService, FirearmSightService, FormErrorMessageComponent, FrameMaterial, FrameMaterialPipe, GunCaliber, GunPart, GunPartOption, GunPartService, InventoryItem, InventoryService, JFile, Material, MaterialService, MillingDetail, MillingItem, MillingType, MillingTypeService, ModalHeaderComponent, MountType, MountTypeService, NewLinePipe, NotificationBarComponent, NotificationModule, NotificationService, NotificationType, Optic, OpticService, OpticSight, OpticStatus, Package, PackageItem, PackageOptionalItem, PackageOptionalItemService, PackageSelectorComponent, PackageService, PackageTotal, PackageVariation, PackageVariationOption, PackageVariationService, PhonePipe, Product, ProductService, ProjectType, PurchaseOrder, PurchaseOrderRefinishItem, PurchaseOrderService, PurchaseOrderStatus, QuickbooksService, RearSightPosition, RefinishCode, RefinishCodeService, RefinishDetail, ReportMillingItem, ReportRefinishItem, SharedModule, ShieldRMSOptions, Sight, SightMaterialService, SightMaterialType, SightService, SightType, SightTypeEnum, SightTypeService, SlideAddon, SlideAddonService, State, StateService, StatusHistoryService, Total, TotalItem, TotalsService, UserService, Vendor, VendorContact, VendorService, WaitlistAction, WaitlistCustomerService, WaitlistGun, WaitlistGunPackageDetail, WaitlistHistory, WaitlistItem, WaitlistProjectService, WaitlistService, WaitlistStatus, WorkChangeOrder, WorkHoliday, WorkHolidayService, WorkOrder, WorkOrderAction, WorkOrderDiscount, WorkOrderDiscountService, WorkOrderHistory, WorkOrderInventoryItem, WorkOrderListItem, WorkOrderNonInventoryItem, WorkOrderNonInventoryItemService, WorkOrderPackageDetail, WorkOrderRefinishItem, WorkOrderService, WorkOrderShippingItem, WorkOrderShippingItemService, WorkOrderStatus, WorkOrderType, calculateFinishDate, coatingDescriptionValidator, coatingValueValidator, convertEnumToObjectArray, getCoatingValues, getCoatings, hasCoatingDescription, hasCoatingValues, refinishDetailsValidator, touchControls };
2470
+ export { BaseService, BundleItem, ChangeOrderPackageDetail, ChangeOrderStatus, Coating, CoatingService, CoatingValue, CoatingValueService, Configuration, ConfigurationService, Customer, CustomerService, Dealer, DealerContact, DealerCoupon, DealerService, DisableControlDirective, EnumPipe, FileNamePipe, FileUploadService, FilterOptions, FinishDateHelperService, Firearm, FirearmOptic, FirearmOpticService, FirearmService, FirearmSightService, FormErrorMessageComponent, FrameMaterial, FrameMaterialPipe, GunCaliber, GunPart, GunPartOption, GunPartService, InventoryItem, InventoryService, JFile, Material, MaterialService, MillingDetail, MillingItem, MillingType, MillingTypeService, ModalHeaderComponent, MountType, MountTypeService, NewLinePipe, NotificationBarComponent, NotificationModule, NotificationService, NotificationType, Optic, OpticService, OpticSight, OpticStatus, Package, PackageItem, PackageOptionalItem, PackageOptionalItemService, PackageSelectorComponent, PackageService, PackageTotal, PackageVariation, PackageVariationOption, PackageVariationService, PhonePipe, Product, ProductService, ProjectType, PurchaseOrder, PurchaseOrderRefinishItem, PurchaseOrderService, PurchaseOrderStatus, QuickbooksService, RearSightPosition, RefinishCode, RefinishCodeService, RefinishDetail, ReportMillingItem, ReportRefinishItem, SharedModule, ShieldRMSOptions, Sight, SightMaterialService, SightMaterialType, SightService, SightType, SightTypeEnum, SightTypeService, SlideAddon, SlideAddonService, State, StateService, StatusHistoryService, Total, TotalItem, TotalsService, UserService, Vendor, VendorContact, VendorService, WaitlistAction, WaitlistCustomerService, WaitlistGun, WaitlistGunPackageDetail, WaitlistHistory, WaitlistItem, WaitlistProjectService, WaitlistService, WaitlistStatus, WorkChangeOrder, WorkHoliday, WorkHolidayService, WorkOrder, WorkOrderAction, WorkOrderDiscount, WorkOrderDiscountService, WorkOrderHistory, WorkOrderInventoryItem, WorkOrderListItem, WorkOrderNonInventoryItem, WorkOrderNonInventoryItemService, WorkOrderPackageDetail, WorkOrderRefinishItem, WorkOrderService, WorkOrderShippingItem, WorkOrderShippingItemService, WorkOrderStatus, WorkOrderType, coatingDescriptionValidator, coatingValueValidator, convertEnumToObjectArray, getCoatingValues, getCoatings, hasCoatingDescription, hasCoatingValues, refinishDetailsValidator, touchControls };
2472
2471
  //# sourceMappingURL=gunsmith-common.mjs.map