@aggdirect/coolmap 2.9.7 → 2.9.8
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/karma.conf.js +44 -0
- package/ng-package.json +7 -0
- package/package.json +4 -21
- package/src/assets/mixin.scss +28 -0
- package/src/assets/palette.scss +24 -0
- package/src/assets/variable.scss +15 -0
- package/src/lib/component/add-route/add-route.component.html +172 -0
- package/src/lib/component/add-route/add-route.component.scss +243 -0
- package/src/lib/component/add-route/add-route.component.spec.ts +23 -0
- package/src/lib/component/add-route/add-route.component.ts +394 -0
- package/src/lib/component/job-code/job-code.component.html +79 -0
- package/src/lib/component/job-code/job-code.component.scss +396 -0
- package/src/lib/component/job-code/job-code.component.ts +146 -0
- package/src/lib/component/map/map.component.css +0 -0
- package/src/lib/component/map/map.component.html +4 -0
- package/src/lib/component/map/map.component.spec.ts +23 -0
- package/src/lib/component/map/map.component.ts +34 -0
- package/src/lib/component/nav/layout/add-route-nav/add-route-nav.component.html +46 -0
- package/src/lib/component/nav/layout/add-route-nav/add-route-nav.component.scss +18 -0
- package/src/lib/component/nav/layout/add-route-nav/add-route-nav.component.spec.ts +23 -0
- package/src/lib/component/nav/layout/add-route-nav/add-route-nav.component.ts +130 -0
- package/src/lib/component/nav/layout/job-code-nav/job-code-nav.component.html +48 -0
- package/src/lib/component/nav/layout/job-code-nav/job-code-nav.component.scss +24 -0
- package/src/lib/component/nav/layout/job-code-nav/job-code-nav.component.ts +143 -0
- package/src/lib/component/nav/nav.component.html +19 -0
- package/src/lib/component/nav/nav.component.scss +67 -0
- package/src/lib/component/nav/nav.component.ts +38 -0
- package/src/lib/component/route-jobcode-list/job-code-list-card/job-code-list-card.component.html +56 -0
- package/src/lib/component/route-jobcode-list/job-code-list-card/job-code-list-card.component.scss +168 -0
- package/src/lib/component/route-jobcode-list/job-code-list-card/job-code-list-card.component.spec.ts +23 -0
- package/src/lib/component/route-jobcode-list/job-code-list-card/job-code-list-card.component.ts +43 -0
- package/src/lib/component/route-jobcode-list/route-jobcode-list.component.html +73 -0
- package/src/lib/component/route-jobcode-list/route-jobcode-list.component.scss +227 -0
- package/src/lib/component/route-jobcode-list/route-jobcode-list.component.ts +233 -0
- package/src/lib/component/route-jobcode-list/sms-card-details-overview/sms-card-details-overview.component.html +7 -0
- package/src/lib/component/route-jobcode-list/sms-card-details-overview/sms-card-details-overview.component.scss +10 -0
- package/src/lib/component/route-jobcode-list/sms-card-details-overview/sms-card-details-overview.component.spec.ts +23 -0
- package/src/lib/component/route-jobcode-list/sms-card-details-overview/sms-card-details-overview.component.ts +15 -0
- package/src/lib/component/route-jobcode-list/view-route-list-card/view-route-list-card.component.html +28 -0
- package/src/lib/component/route-jobcode-list/view-route-list-card/view-route-list-card.component.scss +172 -0
- package/src/lib/component/route-jobcode-list/view-route-list-card/view-route-list-card.component.spec.ts +23 -0
- package/src/lib/component/route-jobcode-list/view-route-list-card/view-route-list-card.component.ts +20 -0
- package/src/lib/component/shared/dialog/dialog.component.html +7 -0
- package/src/lib/component/shared/dialog/dialog.component.scss +30 -0
- package/src/lib/component/shared/dialog/dialog.component.ts +18 -0
- package/src/lib/component/shared/estimation-display/estimation-display.component.html +7 -0
- package/src/lib/component/shared/estimation-display/estimation-display.component.scss +7 -0
- package/src/lib/component/shared/estimation-display/estimation-display.component.ts +13 -0
- package/src/lib/component/shared/job-route-list/job-route-list.component.html +46 -0
- package/src/lib/component/shared/job-route-list/job-route-list.component.scss +15 -0
- package/src/lib/component/shared/job-route-list/job-route-list.component.spec.ts +23 -0
- package/src/lib/component/shared/job-route-list/job-route-list.component.ts +54 -0
- package/src/lib/component/shared/jobcode-overview/jobcode-overview.component.html +11 -0
- package/src/lib/component/shared/jobcode-overview/jobcode-overview.component.scss +13 -0
- package/src/lib/component/shared/jobcode-overview/jobcode-overview.component.spec.ts +23 -0
- package/src/lib/component/shared/jobcode-overview/jobcode-overview.component.ts +19 -0
- package/src/lib/component/shared/jobcode-status/jobcode-status.component.html +5 -0
- package/src/lib/component/shared/jobcode-status/jobcode-status.component.scss +40 -0
- package/src/lib/component/shared/jobcode-status/jobcode-status.component.spec.ts +23 -0
- package/src/lib/component/shared/jobcode-status/jobcode-status.component.ts +11 -0
- package/src/lib/component/shared/route-info-card/route-info-card.component.html +19 -0
- package/src/lib/component/shared/route-info-card/route-info-card.component.scss +50 -0
- package/src/lib/component/shared/route-info-card/route-info-card.component.spec.ts +23 -0
- package/src/lib/component/shared/route-info-card/route-info-card.component.ts +74 -0
- package/src/lib/component/shared/searchoptiongroup/searchoptiongroup.component.css +3 -0
- package/src/lib/component/shared/searchoptiongroup/searchoptiongroup.component.html +6 -0
- package/src/lib/component/shared/searchoptiongroup/searchoptiongroup.component.spec.ts +23 -0
- package/src/lib/component/shared/searchoptiongroup/searchoptiongroup.component.ts +21 -0
- package/src/lib/coolmap.module.ts +120 -0
- package/{public-api.d.ts → src/public-api.ts} +8 -0
- package/src/test.ts +27 -0
- package/tsconfig.lib.json +15 -0
- package/tsconfig.lib.prod.json +10 -0
- package/tsconfig.spec.json +17 -0
- package/esm2022/aggdirect-coolmap.mjs +0 -5
- package/esm2022/lib/component/add-route/add-route.component.mjs +0 -433
- package/esm2022/lib/component/job-code/job-code.component.mjs +0 -181
- package/esm2022/lib/component/map/map.component.mjs +0 -39
- package/esm2022/lib/component/nav/layout/add-route-nav/add-route-nav.component.mjs +0 -151
- package/esm2022/lib/component/nav/layout/job-code-nav/job-code-nav.component.mjs +0 -150
- package/esm2022/lib/component/nav/nav.component.mjs +0 -54
- package/esm2022/lib/component/route-jobcode-list/job-code-list-card/job-code-list-card.component.mjs +0 -77
- package/esm2022/lib/component/route-jobcode-list/route-jobcode-list.component.mjs +0 -319
- package/esm2022/lib/component/route-jobcode-list/sms-card-details-overview/sms-card-details-overview.component.mjs +0 -19
- package/esm2022/lib/component/route-jobcode-list/view-route-list-card/view-route-list-card.component.mjs +0 -37
- package/esm2022/lib/component/shared/dialog/dialog.component.mjs +0 -31
- package/esm2022/lib/component/shared/estimation-display/estimation-display.component.mjs +0 -18
- package/esm2022/lib/component/shared/job-route-list/job-route-list.component.mjs +0 -79
- package/esm2022/lib/component/shared/jobcode-overview/jobcode-overview.component.mjs +0 -24
- package/esm2022/lib/component/shared/jobcode-status/jobcode-status.component.mjs +0 -15
- package/esm2022/lib/component/shared/route-info-card/route-info-card.component.mjs +0 -62
- package/esm2022/lib/component/shared/searchoptiongroup/searchoptiongroup.component.mjs +0 -25
- package/esm2022/lib/coolmap.module.mjs +0 -193
- package/esm2022/public-api.mjs +0 -19
- package/fesm2022/aggdirect-coolmap.mjs +0 -1778
- package/fesm2022/aggdirect-coolmap.mjs.map +0 -1
- package/index.d.ts +0 -5
- package/lib/component/add-route/add-route.component.d.ts +0 -73
- package/lib/component/job-code/job-code.component.d.ts +0 -41
- package/lib/component/map/map.component.d.ts +0 -15
- package/lib/component/nav/layout/add-route-nav/add-route-nav.component.d.ts +0 -49
- package/lib/component/nav/layout/job-code-nav/job-code-nav.component.d.ts +0 -42
- package/lib/component/nav/nav.component.d.ts +0 -31
- package/lib/component/route-jobcode-list/job-code-list-card/job-code-list-card.component.d.ts +0 -20
- package/lib/component/route-jobcode-list/route-jobcode-list.component.d.ts +0 -42
- package/lib/component/route-jobcode-list/sms-card-details-overview/sms-card-details-overview.component.d.ts +0 -9
- package/lib/component/route-jobcode-list/view-route-list-card/view-route-list-card.component.d.ts +0 -12
- package/lib/component/shared/dialog/dialog.component.d.ts +0 -13
- package/lib/component/shared/estimation-display/estimation-display.component.d.ts +0 -8
- package/lib/component/shared/job-route-list/job-route-list.component.d.ts +0 -26
- package/lib/component/shared/jobcode-overview/jobcode-overview.component.d.ts +0 -10
- package/lib/component/shared/jobcode-status/jobcode-status.component.d.ts +0 -7
- package/lib/component/shared/route-info-card/route-info-card.component.d.ts +0 -32
- package/lib/component/shared/searchoptiongroup/searchoptiongroup.component.d.ts +0 -14
- package/lib/coolmap.module.d.ts +0 -46
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
import { Component, ElementRef, OnInit, ViewChild, Output, EventEmitter, SimpleChanges, OnChanges, Input, OnDestroy, Inject, inject, ChangeDetectorRef } from '@angular/core';
|
|
2
|
+
import { FormControl, FormGroup, Validators } from '@angular/forms';
|
|
3
|
+
import { debounceTime, distinctUntilChanged, filter, fromEvent, map, Observable, pairwise, startWith, Subject, takeUntil } from 'rxjs';
|
|
4
|
+
import { MatDialog } from '@angular/material/dialog';
|
|
5
|
+
import { DialogComponent } from '../shared/dialog/dialog.component';
|
|
6
|
+
import { CoolmapConfigModel, CoolmapService, CustomerRepoDetailsModel, LocationAll, Route, UtilsService } from '@aggdirect/coolmap-services';
|
|
7
|
+
|
|
8
|
+
@Component({
|
|
9
|
+
selector: 'app-add-route',
|
|
10
|
+
templateUrl: './add-route.component.html',
|
|
11
|
+
styleUrls: ['./add-route.component.scss']
|
|
12
|
+
})
|
|
13
|
+
export class AddRouteComponent implements OnInit, OnChanges, OnDestroy {
|
|
14
|
+
@ViewChild('filterPickup') public filterPickup!: ElementRef;
|
|
15
|
+
@ViewChild('filterDelivery') public filterDelivery!: ElementRef;
|
|
16
|
+
@ViewChild('pickup_system_location') public pickup_system_location!: ElementRef;
|
|
17
|
+
@ViewChild('delivery_system_location') public delivery_system_location!: ElementRef;
|
|
18
|
+
@Output() public changeNav = new EventEmitter<string>();
|
|
19
|
+
@Output() public updateRouteList = new EventEmitter<boolean>();
|
|
20
|
+
pickupOptions: Observable<string[] | LocationAll[]>;
|
|
21
|
+
deliveryOptions: Observable<string[] | LocationAll[]>;
|
|
22
|
+
requestParmsForRouteDetails = { pickup_lat_lng: '', delivery_lat_lng: '' }
|
|
23
|
+
customersList: any = [];
|
|
24
|
+
unitsList: any = [];
|
|
25
|
+
addRouteForm!: FormGroup;
|
|
26
|
+
@Input() public routeData!: Route;
|
|
27
|
+
@Input() public customerRepoDetails!: CustomerRepoDetailsModel;
|
|
28
|
+
routeId: string | null | undefined;
|
|
29
|
+
preventSave: boolean = false;
|
|
30
|
+
preventInitialSave: boolean = false;
|
|
31
|
+
customersList$!: Observable<any>;
|
|
32
|
+
routeDetails!: { pickup_location: string | null | undefined; delivery_location: string | null | undefined; } | null;
|
|
33
|
+
public destroyer$ = new Subject<boolean>();
|
|
34
|
+
popupDetails: Route;
|
|
35
|
+
enablePopUp: boolean = false;
|
|
36
|
+
prevantPopupClose = false;
|
|
37
|
+
enableForm: boolean = false;
|
|
38
|
+
public locationList: LocationAll[];
|
|
39
|
+
public cdr = inject(ChangeDetectorRef)
|
|
40
|
+
get isSystemPickup() {
|
|
41
|
+
return this.addRouteForm.get('pickUpSearchOption')?.value === 'system';
|
|
42
|
+
}
|
|
43
|
+
get isSystemDelivery() {
|
|
44
|
+
return this.addRouteForm.get('deliverySearchOtption')?.value === 'system';
|
|
45
|
+
}
|
|
46
|
+
constructor(
|
|
47
|
+
public coolMapService: CoolmapService,
|
|
48
|
+
public utils: UtilsService,
|
|
49
|
+
public dialog: MatDialog,
|
|
50
|
+
@Inject('memberData') public config: CoolmapConfigModel) {
|
|
51
|
+
this.utils.fetchUnitsList().then((res)=>{
|
|
52
|
+
this.unitsList = res;
|
|
53
|
+
});
|
|
54
|
+
this.formInit();
|
|
55
|
+
this.utils.getrouteDetailsUtility.subscribe(res => {
|
|
56
|
+
if (res) {
|
|
57
|
+
if (res['event'] !== 'click' && !this.prevantPopupClose) { this.enablePopUp = res['event'] }
|
|
58
|
+
else if (this.enablePopUp && !this.prevantPopupClose) { this.prevantPopupClose = true; }
|
|
59
|
+
if (res['event'] !== 'click' && !res['event'] && this.prevantPopupClose) {
|
|
60
|
+
this.popupDetails = this.utils.getdictValue('route-detailsv2');
|
|
61
|
+
} else { this.popupDetails = res['route'] }
|
|
62
|
+
if (this.enablePopUp) this.popupDetails['created_at'] = this.utils.getDateFormat(new Date(this.popupDetails['created_at']), '/');
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
filterCustomerList() {
|
|
67
|
+
this.customersList$ = this.addRouteForm.controls['customer_name'].valueChanges.pipe(
|
|
68
|
+
startWith(''),
|
|
69
|
+
map(value => this._filter((value || ''), this.customersList, 'customer_name')),
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
public _filter(value: string, list, prop: string): string[] {
|
|
74
|
+
const filterValue = value.toLowerCase();
|
|
75
|
+
return list.filter((option: any) => option[prop].toLowerCase().includes(filterValue));
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
ngOnChanges(changes: SimpleChanges): void {
|
|
79
|
+
if (changes['routeData'] && !changes['routeData']['currentValue']) this.inIt(null);
|
|
80
|
+
}
|
|
81
|
+
openDialog(): void {
|
|
82
|
+
const dialogRef = this.dialog.open(DialogComponent, {
|
|
83
|
+
data: { body: 'Are you sure you want to delete this route?' },
|
|
84
|
+
});
|
|
85
|
+
dialogRef.afterClosed().subscribe(res => { if (res) { this.deleteRoute() } });
|
|
86
|
+
}
|
|
87
|
+
editEvent() {
|
|
88
|
+
this.prevantPopupClose = false;
|
|
89
|
+
this.enableForm = true; this.enablePopUp = false;
|
|
90
|
+
this.popupDetails['prevent'] = false;
|
|
91
|
+
this.utils.removeMapEntity.next(this.popupDetails);
|
|
92
|
+
this.inIt(this.popupDetails);
|
|
93
|
+
}
|
|
94
|
+
inIt(changes: Route) {
|
|
95
|
+
if (changes) {
|
|
96
|
+
if (!changes['prevent']) {
|
|
97
|
+
this.preventSave = false;
|
|
98
|
+
this.formControlValue();
|
|
99
|
+
this.patchFormValue(changes).then(() => {
|
|
100
|
+
this.checkAndFetchRouteInformation(true)
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
if (!changes) {
|
|
105
|
+
this.enableForm = true; this.preventSave = true;
|
|
106
|
+
this.patchFormValue().then(() => {
|
|
107
|
+
this.checkAndFetchRouteInformation()
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
ngOnInit(): void {
|
|
112
|
+
this.formControlValue();
|
|
113
|
+
if (this.config.repository === 'customer') {
|
|
114
|
+
this.addRouteForm.patchValue({
|
|
115
|
+
customer_id: this.customerRepoDetails.customer.id,
|
|
116
|
+
customer_name: this.customerRepoDetails.customer.name,
|
|
117
|
+
})
|
|
118
|
+
} else {
|
|
119
|
+
this.utils.fetchCustomersList().then((res) => {
|
|
120
|
+
this.customersList = res;
|
|
121
|
+
this.filterCustomerList();
|
|
122
|
+
this.addRouteForm.controls['customer_name'].enable();
|
|
123
|
+
});
|
|
124
|
+
if (this.config.repository === 'coolmap') {
|
|
125
|
+
this.utils.fetchLocationlist().then((res: LocationAll[]) => {
|
|
126
|
+
this.locationList = res;
|
|
127
|
+
this.pickupOptions = this.createAddressFilter(
|
|
128
|
+
'pickup_location',
|
|
129
|
+
this.locationList,
|
|
130
|
+
'formatted_address'
|
|
131
|
+
);
|
|
132
|
+
this.deliveryOptions = this.createAddressFilter(
|
|
133
|
+
'delivery_location',
|
|
134
|
+
this.locationList,
|
|
135
|
+
'formatted_address'
|
|
136
|
+
);
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
formPickUpFilter() {
|
|
142
|
+
fromEvent(this.filterPickup.nativeElement, 'keyup')
|
|
143
|
+
.pipe(
|
|
144
|
+
distinctUntilChanged(),
|
|
145
|
+
debounceTime(150),
|
|
146
|
+
takeUntil(this.destroyer$))
|
|
147
|
+
.subscribe(() => {
|
|
148
|
+
this.utils
|
|
149
|
+
.autocomplete(this.filterPickup)
|
|
150
|
+
.then((res) => {
|
|
151
|
+
if (res) {
|
|
152
|
+
this.patchAddressValue(res, 'pickup');
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
formDeliveryFilter() {
|
|
159
|
+
fromEvent(this.filterDelivery.nativeElement, 'keyup')
|
|
160
|
+
.pipe(distinctUntilChanged(), debounceTime(150))
|
|
161
|
+
.pipe(takeUntil(this.destroyer$))
|
|
162
|
+
.subscribe(() => {
|
|
163
|
+
this.utils.autocomplete(this.filterDelivery).then((res) => {
|
|
164
|
+
if (res) {
|
|
165
|
+
this.patchAddressValue(res, 'delivery');
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
createAddressFilter(control, list, prop) {
|
|
172
|
+
return this.addRouteForm.get(control).valueChanges.pipe(
|
|
173
|
+
startWith(''),
|
|
174
|
+
map(value => value === '' ? list : this._filter((value || ''), this.locationList, prop)),
|
|
175
|
+
)
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
ngAfterViewInit() {
|
|
179
|
+
this.formPickUpFilter();
|
|
180
|
+
this.formDeliveryFilter();
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
patchAddressValue(data: any, type: string) {
|
|
184
|
+
setTimeout(() => {
|
|
185
|
+
this.addRouteForm.patchValue({
|
|
186
|
+
[type + '_location']: data['formatted_address'],
|
|
187
|
+
[type + '_lat_lng']: `${data['lat']},${data['lng']}`
|
|
188
|
+
});
|
|
189
|
+
this.addRouteForm.updateValueAndValidity();
|
|
190
|
+
if(type === 'pickup') this.coolMapService.clearBoundWithCordinates();
|
|
191
|
+
this.checkAndFetchRouteInformation();
|
|
192
|
+
}, 100);
|
|
193
|
+
}
|
|
194
|
+
updateDeliveryField() {
|
|
195
|
+
this.addRouteForm.patchValue({
|
|
196
|
+
delivery_location: null,
|
|
197
|
+
delivery_lat_lng: null
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
updatePickUpField() {
|
|
201
|
+
this.addRouteForm.patchValue({
|
|
202
|
+
pickup_location: null,
|
|
203
|
+
pickup_lat_lng: null
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
formControlValue() {
|
|
207
|
+
this.addRouteForm.get('pickup_location')?.valueChanges.pipe(takeUntil(this.destroyer$)).subscribe((res: any) => {
|
|
208
|
+
const rawFormvalue = this.addRouteForm.getRawValue();
|
|
209
|
+
if ((rawFormvalue.pickup_location && res) !== rawFormvalue.pickup_location) {
|
|
210
|
+
this.addRouteForm.patchValue({ pickup_lat_lng: '' });
|
|
211
|
+
this.addRouteForm.controls['pickup_lat_lng'].markAsTouched();
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
this.addRouteForm.get('delivery_location')?.valueChanges.pipe(takeUntil(this.destroyer$)).subscribe((res: any) => {
|
|
216
|
+
const rawFormvalue = this.addRouteForm.getRawValue();
|
|
217
|
+
if ((rawFormvalue.delivery_location && res) !== rawFormvalue.delivery_location) {
|
|
218
|
+
this.addRouteForm.patchValue({ delivery_lat_lng: '' });
|
|
219
|
+
this.addRouteForm.controls['delivery_lat_lng'].markAsTouched();
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
formInit() {
|
|
225
|
+
this.addRouteForm = new FormGroup({
|
|
226
|
+
route_name: new FormControl('', [Validators.required]),
|
|
227
|
+
customer_name: new FormControl({ value: '', disabled: true }, [Validators.required]),
|
|
228
|
+
customer_id: new FormControl(''),
|
|
229
|
+
unit_id: new FormControl('', [Validators.required]),
|
|
230
|
+
path: new FormControl('', [Validators.required]),
|
|
231
|
+
pickup_location: new FormControl('', [Validators.required]),
|
|
232
|
+
pickup_lat_lng: new FormControl('', [Validators.required]),
|
|
233
|
+
delivery_location: new FormControl('', [Validators.required]),
|
|
234
|
+
delivery_lat_lng: new FormControl('', [Validators.required]),
|
|
235
|
+
estimated_distance: new FormControl('', [Validators.required]),
|
|
236
|
+
estimated_time: new FormControl('', [Validators.required]),
|
|
237
|
+
note: new FormControl('', [Validators.maxLength(2048)]),
|
|
238
|
+
trucker_pay_estimate: new FormControl(null),
|
|
239
|
+
customer_price_estimate: new FormControl(null),
|
|
240
|
+
pickUpSearchOption: new FormControl(''),
|
|
241
|
+
deliverySearchOtption: new FormControl(''),
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
async patchFormValue(data?: Route) {
|
|
246
|
+
this.addRouteForm.reset();
|
|
247
|
+
const isCustomerRepo = this.config.repository === 'customer';
|
|
248
|
+
this.addRouteForm.patchValue(data!);
|
|
249
|
+
if (isCustomerRepo) {
|
|
250
|
+
this.addRouteForm.patchValue({
|
|
251
|
+
customer_id: this.customerRepoDetails.customer.id,
|
|
252
|
+
customer_name: this.customerRepoDetails.customer.name,
|
|
253
|
+
})
|
|
254
|
+
} else {
|
|
255
|
+
this.addRouteForm.patchValue({
|
|
256
|
+
pickUpSearchOption: (!data || data.is_system_pickup) ? 'system' : 'google',
|
|
257
|
+
deliverySearchOtption: (!data || data.is_system_delivery) ? 'system' : 'google',
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
this.routeId = data?.route_id;
|
|
261
|
+
this.routeDetails = data
|
|
262
|
+
? {
|
|
263
|
+
pickup_location: data.pickup_location,
|
|
264
|
+
delivery_location: data.delivery_location,
|
|
265
|
+
}
|
|
266
|
+
: null;
|
|
267
|
+
this.addRouteForm.valueChanges
|
|
268
|
+
.pipe(
|
|
269
|
+
takeUntil(this.destroyer$),
|
|
270
|
+
pairwise(),
|
|
271
|
+
filter(([prev, curr]) => {
|
|
272
|
+
return (prev.pickUpSearchOption === curr.pickUpSearchOption) &&
|
|
273
|
+
prev.deliverySearchOtption === curr.deliverySearchOtption
|
|
274
|
+
})
|
|
275
|
+
).subscribe(() => {
|
|
276
|
+
if (this.preventInitialSave) {
|
|
277
|
+
this.preventInitialSave = false;
|
|
278
|
+
}
|
|
279
|
+
});
|
|
280
|
+
this.filterCustomerList();
|
|
281
|
+
await true;
|
|
282
|
+
}
|
|
283
|
+
patchLocation(data, key) {
|
|
284
|
+
const location = this.locationList.find((location) => (this.getFormatedAddress(location)?.trim() === data![key].trim()));
|
|
285
|
+
if(location) {
|
|
286
|
+
this.addRouteForm.patchValue({
|
|
287
|
+
[key]: `${location.name} | ${data[key]}` ,
|
|
288
|
+
})
|
|
289
|
+
} else {
|
|
290
|
+
this.addRouteForm.patchValue({
|
|
291
|
+
[key]: data[key],
|
|
292
|
+
})
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
getFormatedAddress(object) {
|
|
296
|
+
return `${object.street} ${object.city}, ${object.state} ${object.zip}`
|
|
297
|
+
}
|
|
298
|
+
checkAndFetchRouteInformation(isinitial?: boolean) {
|
|
299
|
+
if (this.addRouteForm.value?.delivery_lat_lng?.length > 0 && this.addRouteForm.value?.pickup_lat_lng?.length > 0 && this.addRouteForm.value.unit_id) {
|
|
300
|
+
let unit = this.unitsList.find((x: any) => x.id === this.addRouteForm.value.unit_id);
|
|
301
|
+
const param = {
|
|
302
|
+
delivery_lat_lng: this.addRouteForm.value.delivery_lat_lng,
|
|
303
|
+
pickup_lat_lng: this.addRouteForm.value.pickup_lat_lng,
|
|
304
|
+
unit: unit?.type
|
|
305
|
+
};
|
|
306
|
+
this.utils.postdata('calculate/routes/estimation', param).pipe(takeUntil(this.destroyer$)).subscribe((res: any) => {
|
|
307
|
+
if (res && res['path']) {
|
|
308
|
+
this.addRouteForm.patchValue({
|
|
309
|
+
estimated_distance: res['dist'],
|
|
310
|
+
estimated_time: res['time'],
|
|
311
|
+
path: res['path'],
|
|
312
|
+
trucker_pay_estimate: res['trucker_haul_cost'],
|
|
313
|
+
customer_price_estimate: res['customer_price_estimate']
|
|
314
|
+
});
|
|
315
|
+
let path = res['path'].split(';');
|
|
316
|
+
path = path.map((ele: string | any) => { return ele = this.formateLatLong(ele) });
|
|
317
|
+
res['path'] = path;
|
|
318
|
+
const element: any = {
|
|
319
|
+
type: 'FeatureCollection',
|
|
320
|
+
features: [{ type: 'Feature', properties: {}, geometry: { type: 'LineString', coordinates: res['path'] } }]
|
|
321
|
+
}
|
|
322
|
+
this.coolMapService.removeRouteAndMarker(1).then(() => {
|
|
323
|
+
const unit = this.unitsList.find((x: any) => x.id === this.addRouteForm.value.unit_id);
|
|
324
|
+
const rawFormvalue = this.addRouteForm.getRawValue();
|
|
325
|
+
this.coolMapService.loadMapProperty(element, 1, unit?.type,
|
|
326
|
+
{
|
|
327
|
+
pickup_location: rawFormvalue.pickup_location,
|
|
328
|
+
delivery_location: rawFormvalue.delivery_location,
|
|
329
|
+
route_name: rawFormvalue.route_name,
|
|
330
|
+
unit: unit?.type
|
|
331
|
+
}).then((res) => { this.preventSave = true });
|
|
332
|
+
});
|
|
333
|
+
} else {
|
|
334
|
+
this.coolMapService.removeRouteAndMarker(1);
|
|
335
|
+
this.preventSave = true
|
|
336
|
+
this.utils.openSnackBar((res['status']
|
|
337
|
+
? res['status'] :
|
|
338
|
+
'Somthing went wrong, Please try different address.'),
|
|
339
|
+
'error');
|
|
340
|
+
}
|
|
341
|
+
if (this.routeId && isinitial) this.preventInitialSave = true;
|
|
342
|
+
});
|
|
343
|
+
} else { this.coolMapService.removeRouteAndMarker(1) }
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
formateLatLong(latlong: string) { return latlong ? latlong.split(',').map(x => +x).reverse() : null }
|
|
347
|
+
saveRoute() {
|
|
348
|
+
if (this.addRouteForm.valid) {
|
|
349
|
+
this.preventSave = false;
|
|
350
|
+
const data = this.addRouteForm.getRawValue();
|
|
351
|
+
if(this.config.repository === 'coolmap') {
|
|
352
|
+
data.is_system_delivery = data.deliverySearchOtption === 'system' ? 1 : 0;
|
|
353
|
+
data.is_system_pickup = data.pickUpSearchOption === 'system' ? 1 : 0;
|
|
354
|
+
}
|
|
355
|
+
delete data.pickUpSearchOption;
|
|
356
|
+
delete data.deliverySearchOtption;
|
|
357
|
+
const url = this.routeId ? this.utils.postdata('update/routes', data) : this.utils.postdata('add/routes', data)
|
|
358
|
+
if (this.routeId) data['id'] = this.routeId;
|
|
359
|
+
url.pipe(takeUntil(this.destroyer$)).subscribe((res: any) => {
|
|
360
|
+
if (res.success) {
|
|
361
|
+
this.updateRouteList.emit(true);
|
|
362
|
+
this.utils.openSnackBar(res.message, 'success');
|
|
363
|
+
this.preventInitialSave = true;
|
|
364
|
+
this.preventSave = true;
|
|
365
|
+
if (!this.routeId) this.changeNav.next('Addroute');
|
|
366
|
+
} else {
|
|
367
|
+
this.utils.openSnackBar(res.message, 'error');
|
|
368
|
+
this.preventSave = true;
|
|
369
|
+
}
|
|
370
|
+
}, (err) => { if (err) { this.preventSave = true; } });
|
|
371
|
+
} else {
|
|
372
|
+
this.addRouteForm.markAllAsTouched();
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
deleteRoute() {
|
|
376
|
+
this.preventSave = false;
|
|
377
|
+
this.utils.postdata('delete/routes', { uuid: this.routeId }).subscribe(res => {
|
|
378
|
+
if (res['data']['success']) {
|
|
379
|
+
this.utils.openSnackBar(res['data']['message'], 'success');
|
|
380
|
+
this.updateRouteList.emit(true);
|
|
381
|
+
this.changeNav.next('Addroute');
|
|
382
|
+
this.preventInitialSave = true;
|
|
383
|
+
this.preventSave = true;
|
|
384
|
+
} else {
|
|
385
|
+
this.utils.openSnackBar('Somthing went wrong', 'error');
|
|
386
|
+
this.preventSave = true;
|
|
387
|
+
}
|
|
388
|
+
}, (err) => { this.preventSave = true })
|
|
389
|
+
}
|
|
390
|
+
ngOnDestroy(): void {
|
|
391
|
+
this.destroyer$.next(true);
|
|
392
|
+
this.destroyer$.unsubscribe();
|
|
393
|
+
}
|
|
394
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
<div class="jobcode_detailprt" (click)="isOverlapRouteSection = false" *ngIf="jobdetail" [ngClass]="{'overlap': !isOverlapRouteSection}" cdkDrag>
|
|
2
|
+
<span class="close"><mat-icon (click)="clearJob()">clear</mat-icon></span>
|
|
3
|
+
<div class="job_details_area">
|
|
4
|
+
<div class="detailnameprt">
|
|
5
|
+
<app-jobcode-status [jobValue]="jobdetail"></app-jobcode-status>
|
|
6
|
+
</div>
|
|
7
|
+
<app-jobcode-overview [jobValue]="jobdetail"></app-jobcode-overview>
|
|
8
|
+
</div>
|
|
9
|
+
</div>
|
|
10
|
+
|
|
11
|
+
<div class="route_listprt" (click)="isOverlapRouteSection = true" [ngClass]="{ 'show': isVisible, 'overlap': isOverlapRouteSection}">
|
|
12
|
+
<div class="listing_toggle" (click)="toggleSidemenu()">
|
|
13
|
+
<img src="assets/images/route.svg" alt="" />
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
<div class="listing_box">
|
|
17
|
+
<div class="closebtn" (click)="toggleSidemenu()">
|
|
18
|
+
<mat-icon>clear</mat-icon>
|
|
19
|
+
</div>
|
|
20
|
+
|
|
21
|
+
<div class="btnprt">
|
|
22
|
+
<h2> List of Routes </h2>
|
|
23
|
+
<button (click)="masterToggle()">{{routes && routes.length > 0 && routes.length === selectedRoute.selected.length ? 'Uncheck' : 'Check'}} All</button>
|
|
24
|
+
</div>
|
|
25
|
+
|
|
26
|
+
<app-job-route-list [routes]="routes" [masterRoutes]="masterRoutes" [selectedRoute]="selectedRoute" (changeRoutes)="routes = $event" (changeSelectedRoute)="selectedRoute = $event"></app-job-route-list>
|
|
27
|
+
<cdk-virtual-scroll-viewport itemSize="50" class="routeList-viewport">
|
|
28
|
+
<ul *ngIf="routes['length'] > 0">
|
|
29
|
+
<li *ngFor="let list of routes">
|
|
30
|
+
<div class="iconprt">
|
|
31
|
+
<span>
|
|
32
|
+
<input type="checkbox" [checked]="selectedRoute.isSelected(list)"
|
|
33
|
+
(change)="$event ? selectRoute(list) : null" /><label> </label>
|
|
34
|
+
<div class="border"></div>
|
|
35
|
+
</span>
|
|
36
|
+
<div class="statusunit" [ngClass]="list['unit']">{{list['unit']}}</div>
|
|
37
|
+
<div class="infoicon">
|
|
38
|
+
<img (mouseenter)="togglerouteDetails(true, list)" (mouseout)="togglerouteDetails(false, list, true)"
|
|
39
|
+
(click)="togglerouteDetails('click', list)" src="assets/images/info_icon.png" [alt]="" />
|
|
40
|
+
</div>
|
|
41
|
+
<div class="infoicon" *ngIf="config.repository === 'customer'">
|
|
42
|
+
<img src="assets/images/share_icon.png" (click)="openShareRouteModal(list)" [alt]="" />
|
|
43
|
+
</div>
|
|
44
|
+
</div>
|
|
45
|
+
<div class="pickprtbox">
|
|
46
|
+
<h2> {{list['route_name']}} </h2>
|
|
47
|
+
<h3><ng-container *ngIf="config?.repository === 'coolmap'">{{list['customer_name']}} </ng-container></h3>
|
|
48
|
+
<div class="pickdropprt">
|
|
49
|
+
<div class="pickprt">
|
|
50
|
+
<b>
|
|
51
|
+
<h4>{{list['pickup_location']?.split('|')[1] ? list['pickup_location'].split('|')[1] : list['pickup_location']}}</h4>
|
|
52
|
+
</b>
|
|
53
|
+
</div>
|
|
54
|
+
<div class="dropprt">
|
|
55
|
+
<b>
|
|
56
|
+
<h4>{{list['delivery_location']?.split('|')[1] ? list['delivery_location'].split('|')[1] : list['delivery_location']}}</h4>
|
|
57
|
+
</b>
|
|
58
|
+
</div>
|
|
59
|
+
</div>
|
|
60
|
+
</div>
|
|
61
|
+
</li>
|
|
62
|
+
</ul>
|
|
63
|
+
<p style="color: #fff;" *ngIf="routes.length === 0">No Route found</p>
|
|
64
|
+
</cdk-virtual-scroll-viewport>
|
|
65
|
+
|
|
66
|
+
</div>
|
|
67
|
+
|
|
68
|
+
<div class="route_detail" *ngIf="detailsCardEnable">
|
|
69
|
+
<div class="closebtnroutedetail" (click)="detailsCardEnable = false; preventMouseout = false">
|
|
70
|
+
<mat-icon>clear</mat-icon>
|
|
71
|
+
</div>
|
|
72
|
+
<lib-route-info-card [propData]="{className: 'listRoutecard', repository: config['repository']}" [popupData]="routeCardDetail"></lib-route-info-card>
|
|
73
|
+
<div class="createTxt">
|
|
74
|
+
<small>
|
|
75
|
+
Created by {{routeCardDetail?.created_by_name}} on {{routeCardDetail?.created_at}}
|
|
76
|
+
</small>
|
|
77
|
+
</div>
|
|
78
|
+
</div>
|
|
79
|
+
</div>
|