@aggdirect/coolmap 2.6.8 → 2.7.0

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.
Files changed (109) hide show
  1. package/esm2022/aggdirect-coolmap.mjs +5 -0
  2. package/esm2022/lib/component/add-route/add-route.component.mjs +348 -0
  3. package/esm2022/lib/component/job-code/job-code.component.mjs +192 -0
  4. package/esm2022/lib/component/map/map.component.mjs +39 -0
  5. package/esm2022/lib/component/nav/layout/add-route-nav/add-route-nav.component.mjs +152 -0
  6. package/esm2022/lib/component/nav/layout/job-code-nav/job-code-nav.component.mjs +147 -0
  7. package/esm2022/lib/component/nav/nav.component.mjs +54 -0
  8. package/esm2022/lib/component/route-jobcode-list/job-code-list-card/job-code-list-card.component.mjs +77 -0
  9. package/esm2022/lib/component/route-jobcode-list/route-jobcode-list.component.mjs +321 -0
  10. package/esm2022/lib/component/route-jobcode-list/sms-card-details-overview/sms-card-details-overview.component.mjs +19 -0
  11. package/esm2022/lib/component/route-jobcode-list/view-route-list-card/view-route-list-card.component.mjs +37 -0
  12. package/esm2022/lib/component/shared/dialog/dialog.component.mjs +31 -0
  13. package/esm2022/lib/component/shared/estimation-display/estimation-display.component.mjs +18 -0
  14. package/esm2022/lib/component/shared/job-route-list/job-route-list.component.mjs +79 -0
  15. package/esm2022/lib/component/shared/jobcode-overview/jobcode-overview.component.mjs +24 -0
  16. package/esm2022/lib/component/shared/jobcode-status/jobcode-status.component.mjs +15 -0
  17. package/esm2022/lib/component/shared/route-info-card/route-info-card.component.mjs +57 -0
  18. package/esm2022/lib/coolmap.module.mjs +186 -0
  19. package/esm2022/public-api.mjs +19 -0
  20. package/fesm2022/aggdirect-coolmap.mjs +1672 -0
  21. package/fesm2022/aggdirect-coolmap.mjs.map +1 -0
  22. package/index.d.ts +5 -0
  23. package/lib/component/add-route/add-route.component.d.ts +61 -0
  24. package/lib/component/job-code/job-code.component.d.ts +42 -0
  25. package/lib/component/map/map.component.d.ts +15 -0
  26. package/lib/component/nav/layout/add-route-nav/add-route-nav.component.d.ts +49 -0
  27. package/lib/component/nav/layout/job-code-nav/job-code-nav.component.d.ts +42 -0
  28. package/lib/component/nav/nav.component.d.ts +31 -0
  29. package/lib/component/route-jobcode-list/job-code-list-card/job-code-list-card.component.d.ts +20 -0
  30. package/lib/component/route-jobcode-list/route-jobcode-list.component.d.ts +42 -0
  31. package/lib/component/route-jobcode-list/sms-card-details-overview/sms-card-details-overview.component.d.ts +9 -0
  32. package/lib/component/route-jobcode-list/view-route-list-card/view-route-list-card.component.d.ts +12 -0
  33. package/lib/component/shared/dialog/dialog.component.d.ts +13 -0
  34. package/lib/component/shared/estimation-display/estimation-display.component.d.ts +8 -0
  35. package/lib/component/shared/job-route-list/job-route-list.component.d.ts +26 -0
  36. package/lib/component/shared/jobcode-overview/jobcode-overview.component.d.ts +10 -0
  37. package/lib/component/shared/jobcode-status/jobcode-status.component.d.ts +7 -0
  38. package/lib/component/shared/route-info-card/route-info-card.component.d.ts +29 -0
  39. package/lib/coolmap.module.d.ts +44 -0
  40. package/package.json +22 -5
  41. package/{src/public-api.ts → public-api.d.ts} +0 -8
  42. package/karma.conf.js +0 -44
  43. package/ng-package.json +0 -7
  44. package/src/assets/mixin.scss +0 -28
  45. package/src/assets/palette.scss +0 -24
  46. package/src/assets/variable.scss +0 -15
  47. package/src/lib/component/add-route/add-route.component.html +0 -136
  48. package/src/lib/component/add-route/add-route.component.scss +0 -236
  49. package/src/lib/component/add-route/add-route.component.spec.ts +0 -23
  50. package/src/lib/component/add-route/add-route.component.ts +0 -295
  51. package/src/lib/component/job-code/job-code.component.html +0 -79
  52. package/src/lib/component/job-code/job-code.component.scss +0 -396
  53. package/src/lib/component/job-code/job-code.component.ts +0 -157
  54. package/src/lib/component/map/map.component.css +0 -0
  55. package/src/lib/component/map/map.component.html +0 -4
  56. package/src/lib/component/map/map.component.spec.ts +0 -23
  57. package/src/lib/component/map/map.component.ts +0 -34
  58. package/src/lib/component/nav/layout/add-route-nav/add-route-nav.component.html +0 -46
  59. package/src/lib/component/nav/layout/add-route-nav/add-route-nav.component.scss +0 -18
  60. package/src/lib/component/nav/layout/add-route-nav/add-route-nav.component.spec.ts +0 -23
  61. package/src/lib/component/nav/layout/add-route-nav/add-route-nav.component.ts +0 -131
  62. package/src/lib/component/nav/layout/job-code-nav/job-code-nav.component.html +0 -48
  63. package/src/lib/component/nav/layout/job-code-nav/job-code-nav.component.scss +0 -24
  64. package/src/lib/component/nav/layout/job-code-nav/job-code-nav.component.ts +0 -154
  65. package/src/lib/component/nav/nav.component.html +0 -19
  66. package/src/lib/component/nav/nav.component.scss +0 -67
  67. package/src/lib/component/nav/nav.component.ts +0 -38
  68. package/src/lib/component/route-jobcode-list/job-code-list-card/job-code-list-card.component.html +0 -56
  69. package/src/lib/component/route-jobcode-list/job-code-list-card/job-code-list-card.component.scss +0 -168
  70. package/src/lib/component/route-jobcode-list/job-code-list-card/job-code-list-card.component.spec.ts +0 -23
  71. package/src/lib/component/route-jobcode-list/job-code-list-card/job-code-list-card.component.ts +0 -43
  72. package/src/lib/component/route-jobcode-list/route-jobcode-list.component.html +0 -66
  73. package/src/lib/component/route-jobcode-list/route-jobcode-list.component.scss +0 -232
  74. package/src/lib/component/route-jobcode-list/route-jobcode-list.component.ts +0 -234
  75. package/src/lib/component/route-jobcode-list/sms-card-details-overview/sms-card-details-overview.component.html +0 -7
  76. package/src/lib/component/route-jobcode-list/sms-card-details-overview/sms-card-details-overview.component.scss +0 -10
  77. package/src/lib/component/route-jobcode-list/sms-card-details-overview/sms-card-details-overview.component.spec.ts +0 -23
  78. package/src/lib/component/route-jobcode-list/sms-card-details-overview/sms-card-details-overview.component.ts +0 -15
  79. package/src/lib/component/route-jobcode-list/view-route-list-card/view-route-list-card.component.html +0 -28
  80. package/src/lib/component/route-jobcode-list/view-route-list-card/view-route-list-card.component.scss +0 -172
  81. package/src/lib/component/route-jobcode-list/view-route-list-card/view-route-list-card.component.spec.ts +0 -23
  82. package/src/lib/component/route-jobcode-list/view-route-list-card/view-route-list-card.component.ts +0 -20
  83. package/src/lib/component/shared/dialog/dialog.component.html +0 -7
  84. package/src/lib/component/shared/dialog/dialog.component.scss +0 -30
  85. package/src/lib/component/shared/dialog/dialog.component.ts +0 -18
  86. package/src/lib/component/shared/estimation-display/estimation-display.component.html +0 -7
  87. package/src/lib/component/shared/estimation-display/estimation-display.component.scss +0 -7
  88. package/src/lib/component/shared/estimation-display/estimation-display.component.ts +0 -13
  89. package/src/lib/component/shared/job-route-list/job-route-list.component.html +0 -30
  90. package/src/lib/component/shared/job-route-list/job-route-list.component.scss +0 -15
  91. package/src/lib/component/shared/job-route-list/job-route-list.component.spec.ts +0 -23
  92. package/src/lib/component/shared/job-route-list/job-route-list.component.ts +0 -54
  93. package/src/lib/component/shared/jobcode-overview/jobcode-overview.component.html +0 -11
  94. package/src/lib/component/shared/jobcode-overview/jobcode-overview.component.scss +0 -13
  95. package/src/lib/component/shared/jobcode-overview/jobcode-overview.component.spec.ts +0 -23
  96. package/src/lib/component/shared/jobcode-overview/jobcode-overview.component.ts +0 -19
  97. package/src/lib/component/shared/jobcode-status/jobcode-status.component.html +0 -5
  98. package/src/lib/component/shared/jobcode-status/jobcode-status.component.scss +0 -40
  99. package/src/lib/component/shared/jobcode-status/jobcode-status.component.spec.ts +0 -23
  100. package/src/lib/component/shared/jobcode-status/jobcode-status.component.ts +0 -11
  101. package/src/lib/component/shared/route-info-card/route-info-card.component.html +0 -11
  102. package/src/lib/component/shared/route-info-card/route-info-card.component.scss +0 -50
  103. package/src/lib/component/shared/route-info-card/route-info-card.component.spec.ts +0 -23
  104. package/src/lib/component/shared/route-info-card/route-info-card.component.ts +0 -69
  105. package/src/lib/coolmap.module.ts +0 -117
  106. package/src/test.ts +0 -27
  107. package/tsconfig.lib.json +0 -15
  108. package/tsconfig.lib.prod.json +0 -10
  109. package/tsconfig.spec.json +0 -17
@@ -1,136 +0,0 @@
1
- <div class="addroutebox">
2
- <div class="routedetailbox" *ngIf="enablePopUp">
3
- <div class="closebtnroutedetail">
4
- <mat-icon (click)="prevantPopupClose = false; enablePopUp = false;">clear</mat-icon>
5
- </div>
6
- <lib-route-info-card [propData]="{className: 'routeCard', repository: config['repository']}" [popupData]="popupDetails"></lib-route-info-card>
7
- <div class="createTxt">
8
- <small>
9
- Created by {{popupDetails['created_by_name']}} on {{popupDetails['created_at']}}
10
- </small>
11
- <button class="editbtn" (click)="editEvent()">Edit</button>
12
- </div>
13
- </div>
14
- <div class="add_add_route_box" cdkDrag [style.visibility]="!enableForm ? 'hidden' : 'visible'">
15
- <div class="topheadingprt">
16
- <h2> {{routeId? 'EDIT' : 'ADD'}} ROUTE </h2>
17
- <div class="buttonprt">
18
- <button *ngIf="routeId" class="delbtn" (click)="openDialog()">Delete</button>
19
- <button mat-raised-button type="submit" class="closebtn" (click)="changeNav.next('Addroute')">Close</button>
20
- </div>
21
- </div>
22
- <form [formGroup]="addRouteForm">
23
- <div class="route_form_area">
24
- <div class="col-6">
25
- <mat-form-field>
26
- <mat-label>Route Name</mat-label>
27
- <input matInput formControlName="route_name" autocomplete="nope" (mousedown)="$event.stopPropagation()">
28
- <mat-error *ngIf="addRouteForm.controls['route_name'].hasError('required')">
29
- Route Name is required
30
- </mat-error>
31
- </mat-form-field>
32
- </div>
33
- <div class="col-6">
34
- <mat-form-field>
35
- <mat-label>Customer_name</mat-label>
36
- <input type="text" placeholder="Customer Name" matInput formControlName="customer_name" [matAutocomplete]="auto" (mousedown)="$event.stopPropagation()">
37
- <mat-autocomplete autoActiveFirstOption #auto="matAutocomplete">
38
- <mat-option *ngFor="let customer of customersList$ | async" [value]="customer['customer_name']">
39
- {{customer['customer_name']}}
40
- </mat-option>
41
- </mat-autocomplete>
42
- <mat-error *ngIf="addRouteForm.controls['customer_name'].hasError('required')">
43
- Customer name is required.
44
- </mat-error>
45
- </mat-form-field>
46
- </div>
47
- <div class="col-6">
48
- <mat-form-field>
49
- <mat-label>Pickup</mat-label>
50
- <input type="text" placeholder="Search..." matInput #filterPickup [matAutocomplete]="pickupAutocomplete"
51
- formControlName="pickup_location" (mousedown)="$event.stopPropagation()">
52
-
53
- <mat-autocomplete #pickupAutocomplete="matAutocomplete">
54
- <mat-option (click)="selectedLongLat('pickup', option)" *ngFor="let option of pickupOptions"
55
- [value]="option?.place_name">
56
- {{option?.place_name}}
57
- </mat-option>
58
- </mat-autocomplete>
59
- </mat-form-field>
60
- <mat-error *ngIf="addRouteForm.controls['pickup_lat_lng'].touched && addRouteForm.controls['pickup_lat_lng'].hasError('required')">
61
- Please select pickup location from the list.
62
- </mat-error>
63
- </div>
64
- <div class="col-6">
65
- <mat-form-field>
66
- <mat-label>Delivery</mat-label>
67
- <input type="text" placeholder="Search..." matInput #filterDelivery [matAutocomplete]="deliveryAutocomplete"
68
- formControlName="delivery_location" (mousedown)="$event.stopPropagation()">
69
- <mat-autocomplete #deliveryAutocomplete="matAutocomplete">
70
- <mat-option (click)="selectedLongLat('delivery', option)" *ngFor="let option of deliveryOptions"
71
- [value]="option?.place_name">
72
- {{option?.place_name}}
73
- </mat-option>
74
- </mat-autocomplete>
75
- </mat-form-field>
76
- <mat-error *ngIf="addRouteForm.controls['delivery_lat_lng'].touched && addRouteForm.controls['delivery_lat_lng'].hasError('required')">
77
- Please select delivery location from the list.
78
- </mat-error>
79
- </div>
80
- <div class="col-6">
81
- <mat-form-field>
82
- <mat-label>Notes</mat-label>
83
- <textarea style="height: 18px; resize: none;" matInput name="" id="" cols="30" rows="10" formControlName="note" autocomplete="nope" (mousedown)="$event.stopPropagation()"></textarea>
84
- <mat-error *ngIf="addRouteForm.controls['note'].hasError('maxlength')">
85
- Notes should be within 2048 characters.
86
- </mat-error>
87
- </mat-form-field>
88
- </div>
89
-
90
- <div class="col-6 d-flex">
91
- <div class="inputbox m-0">
92
- <mat-form-field>
93
- <mat-label>Unit type</mat-label>
94
- <mat-select formControlName="unit_id" (selectionChange)="checkAndFetchRouteInformation()" (mousedown)="$event.stopPropagation()">
95
- <mat-option *ngFor="let unit of unitsList" [value]="unit?.id"> {{unit?.type}} </mat-option>
96
- </mat-select>
97
- <mat-error *ngIf="addRouteForm.controls['unit_id'].hasError('required')">
98
- Unit is required
99
- </mat-error>
100
- </mat-form-field>
101
- </div>
102
-
103
- <div class="inputbox m-0">
104
- <mat-form-field>
105
- <mat-label>Material</mat-label>
106
- <mat-select formControlName="materials_id" (mousedown)="$event.stopPropagation()">
107
- <mat-option *ngFor="let material of materialsList" [value]="config.repository === 'coolmap' ? material?.material_id : material?.sub_material_id"> {{config.repository === 'coolmap' ? material?.material : material?.label}}
108
- </mat-option>
109
- </mat-select>
110
- <mat-error *ngIf="addRouteForm.controls['materials_id'].hasError('required')">
111
- Material is required
112
- </mat-error>
113
- </mat-form-field>
114
- </div>
115
- </div>
116
- <div class="col-6">
117
- <app-estimation-display *ngIf="addRouteForm?.value?.pickup_lat_lng && addRouteForm?.value?.delivery_lat_lng" [value]="addRouteForm['value']"></app-estimation-display>
118
- </div>
119
- <div class="col-6" *ngIf="addRouteForm['value']['trucker_pay_estimate'] && addRouteForm['value']['customer_price_estimate']">
120
- <span *ngIf="config['repository'] !== 'customer'" class="estimate" (mousedown)="$event.stopPropagation()">
121
- Trucker Pay Estimate - <b>{{'$'+ addRouteForm['value']['trucker_pay_estimate']}}</b>
122
- </span>
123
- <span class="estimate" (mousedown)="$event.stopPropagation()">
124
- Customer Price Estimate - <b>{{'$'+ addRouteForm['value']['customer_price_estimate']}}</b>
125
- </span>
126
- </div>
127
- <button mat-raised-button type="submit" (click)="saveRoute()" *ngIf="preventSave"
128
- [disabled]="addRouteForm.invalid && preventSave || preventInitialSave">{{routeId? 'Update' : 'Save'}}
129
- </button>
130
- <div class="loader">
131
- <mat-spinner *ngIf="!preventSave"></mat-spinner>
132
- </div>
133
- </div>
134
- </form>
135
- </div>
136
- </div>
@@ -1,236 +0,0 @@
1
- @import "../../../assets/variable.scss";
2
- .addroutebox{
3
- width: calc(100% - 340px);
4
- position: absolute;
5
- left: 320px;
6
- bottom: 10px;
7
- display: flex;
8
- justify-content: space-between;
9
- align-items: flex-start;
10
-
11
- .routedetailbox{
12
- max-width: 300px;
13
- padding: 10px;
14
- background-color: #fff;
15
- border-radius: 20px;
16
- margin-right: 20px;
17
- @media (min-width:1600px) {
18
- max-width: 280px;
19
- }
20
- }
21
- .editbtn{
22
- background: #326ad3;
23
- padding: 10px 25px 10px 25px;
24
- color: white;
25
- font-size: 0.8125rem;
26
- border-radius: 30px;
27
- float: right;
28
- }
29
- }
30
- .add_add_route_box {
31
- background: $white;
32
- padding: 10px 20px;
33
- border-radius: 20px;
34
- box-shadow: 2px 4px 4px 2px rgb(0 0 0 / 14%);
35
- height: 370px;
36
- width: 100%;
37
- position: relative;
38
- cursor: move;
39
-
40
- .route_form_area {
41
- display: flex;
42
- flex-wrap: wrap;
43
- justify-content: space-between;
44
- .col-6 {
45
- width: 48%;
46
- margin-top: 10px;
47
- justify-content: space-between;
48
- .inputbox {
49
- width: 47%;
50
- }
51
- span {
52
- font-size: 0.875rem;
53
- }
54
- }
55
- button {
56
- background: $blue;
57
- padding: 0px 18px;
58
- color: $white;
59
- font-size: 0.8125rem;
60
- border-radius: 30px;
61
- position: absolute;
62
- right: 18px;
63
- top: 20px;
64
- height: 35px;
65
- }
66
- }
67
- }
68
- .closebtn{
69
- background: $black;
70
- color: $white;
71
- border-radius: 30px;
72
- padding: 0px 18px;
73
- margin-left: 10px;
74
- height: 35px;
75
- }
76
- .delbtn{
77
- background:red;
78
- color: $white;
79
- border-radius: 30px;
80
- padding: 10px 18px 10px 18px;
81
- }
82
- .add_route_listingpart {
83
- .listing_toggle {
84
- background: $white;
85
- border-radius: 15px;
86
- padding: 8px 10px;
87
- position: absolute;
88
- right: 10px;
89
- top: 30px;
90
- cursor: pointer;
91
- }
92
- }
93
- .listing_box {
94
- background: #282828;
95
- height: 100vh;
96
- position: fixed;
97
- right: 0;
98
- top: 0;
99
- z-index: 1111;
100
- box-shadow: -3px 0px 5px 0px rgba(255, 255, 255, 0.08);
101
- transition: 0.5s;
102
- -webkit-transition: 0.5s;
103
- transition: 0.5s;
104
- -webkit-transition: 0.5s;
105
- -moz-transition: 0.5s;
106
- width: 0;
107
- border-radius: 40px 0px 0px 40px;
108
- opacity: 0;
109
- .closebtn {
110
- display: none;
111
- }
112
- }
113
- .show {
114
- .listing_box {
115
- width: 250px;
116
- max-width: 250px;
117
- -webkit-box-flex: 0;
118
- flex: 0 0 250px;
119
- transition: 0.5s;
120
- -webkit-transition: 0.5s;
121
- transition: 0.5s;
122
- -webkit-transition: 0.5s;
123
- -moz-transition: 0.5s;
124
- padding: 40px 0px 40px 20px;
125
- opacity: 1;
126
- @media (min-width:1600px) {
127
- width: 320px;
128
- max-width: 320px;
129
- -webkit-box-flex: 0;
130
- flex: 0 0 320px;
131
- }
132
- h2 {
133
- color: $white;
134
- white-space: nowrap;
135
- }
136
- ul {
137
- padding: 0 20px 0 0;
138
- li {
139
- background: #4a4a4a;
140
- padding: 15px;
141
- border-radius: 15px;
142
- display: flex;
143
- margin-bottom: 15px;
144
- .companayIcon {
145
- width: 40px;
146
- height: 40px;
147
- border-radius: 10px;
148
- background: $white;
149
- margin-right: 10px;
150
- display: flex;
151
- justify-content: center;
152
- align-items: center;
153
- }
154
- .company_cont {
155
- width: calc(100% - 50px);
156
- h3 {
157
- color: $white;
158
- font-size: 15px;
159
- font-weight: normal;
160
- margin: 0;
161
- text-overflow: ellipsis;
162
- max-width: 129px;
163
- -webkit-box-orient: vertical;
164
- white-space: nowrap;
165
- overflow: hidden;
166
- @media (min-width:1600px) {
167
- max-width: 170px;
168
- }
169
- }
170
- p {
171
- color: #bcbcbc;
172
- font-size: 12px;
173
- margin: 5px 0;
174
- overflow: hidden;
175
- text-overflow: ellipsis;
176
- display: -webkit-box;
177
- -webkit-line-clamp: 2;
178
- -webkit-box-orient: vertical;
179
- line-height: 16px;
180
- }
181
- }
182
- }
183
- }
184
- }
185
- .closebtn {
186
- position: absolute;
187
- left: -33px;
188
- top: 50px;
189
- background: #282828;
190
- color: $white;
191
- padding: 8px;
192
- border-top-left-radius: 15px;
193
- border-bottom-left-radius: 15px;
194
- cursor: pointer;
195
- box-shadow: -4px 2px 5px 0px rgba(255, 255, 255, 0.08);
196
- display: block;
197
- }
198
- }
199
- .loader{
200
- position: absolute;
201
- width: 95%;
202
- height: 100%;
203
- display: flex;
204
- justify-content: center;
205
- align-items: center;
206
- pointer-events: none;
207
- }
208
- .buttonprt{
209
- margin-right: 83px;
210
- }
211
-
212
- .closebtnroutedetail{
213
- box-shadow: 0px 0px 5px 0px rgba(0,0,0,0.11);
214
- border-radius: 100%;
215
- width: 30px;
216
- height: 30px;
217
- display: flex;
218
- justify-content: center;
219
- align-items: center;
220
- cursor: pointer;
221
- background: #fff;
222
- position: absolute;
223
- top: -11px;
224
- left: -11px;
225
- }
226
- .routenotes{
227
- max-height: 170px;
228
- overflow: auto;
229
- }
230
- .estimate{
231
- margin-right: 20px;
232
- font-size: 0.7rem;
233
- @media (min-width:1600px) {
234
- font-size: 0.95rem;
235
- }
236
- }
@@ -1,23 +0,0 @@
1
- import { ComponentFixture, TestBed } from '@angular/core/testing';
2
-
3
- import { AddRouteComponent } from './add-route.component';
4
-
5
- describe('AddRouteComponent', () => {
6
- let component: AddRouteComponent;
7
- let fixture: ComponentFixture<AddRouteComponent>;
8
-
9
- beforeEach(async () => {
10
- await TestBed.configureTestingModule({
11
- declarations: [ AddRouteComponent ]
12
- })
13
- .compileComponents();
14
-
15
- fixture = TestBed.createComponent(AddRouteComponent);
16
- component = fixture.componentInstance;
17
- fixture.detectChanges();
18
- });
19
-
20
- it('should create', () => {
21
- expect(component).toBeTruthy();
22
- });
23
- });
@@ -1,295 +0,0 @@
1
- import { Component, ElementRef, OnInit, ViewChild, Output, EventEmitter, SimpleChanges, OnChanges, Input, OnDestroy, Inject } from '@angular/core';
2
- import { FormControl, FormGroup, Validators } from '@angular/forms';
3
- import { debounceTime, distinctUntilChanged, fromEvent, map, Observable, 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, Route, UtilsService } from '@aggdirect/coolmap-services';
7
-
8
-
9
-
10
- @Component({
11
- selector: 'app-add-route',
12
- templateUrl: './add-route.component.html',
13
- styleUrls: ['./add-route.component.scss']
14
- })
15
- export class AddRouteComponent implements OnInit, OnChanges, OnDestroy {
16
- @ViewChild('filterPickup') public filterPickup!: ElementRef;
17
- @ViewChild('filterDelivery') public filterDelivery!: ElementRef;
18
- @Output() public changeNav = new EventEmitter<string>();
19
- @Output() public updateRouteList = new EventEmitter<boolean>();
20
- pickupOptions: any = [];
21
- deliveryOptions: any = [];
22
- requestParmsForRouteDetails = { pickup_lat_lng: '', delivery_lat_lng: '' }
23
- customersList: any = [];
24
- unitsList: any = [];
25
- materialsList: any = [];
26
- addRouteForm!: FormGroup;
27
- @Input() public routeData!: Route;
28
- @Input() public customerRepoDetails!: CustomerRepoDetailsModel;
29
- routeId: string | null | undefined;
30
- preventSave: boolean = false;
31
- preventInitialSave: boolean = false;
32
- customersList$!: Observable<any>;
33
- routeDetails!: { pickup_location: string | null | undefined; delivery_location: string | null | undefined; } | null;
34
- public destroyer$ = new Subject<boolean>();
35
- popupDetails: Route;
36
- enablePopUp: boolean = false;
37
- prevantPopupClose = false;
38
- enableForm: boolean = false;
39
-
40
- constructor(public coolMapService: CoolmapService, public utils: UtilsService, public dialog: MatDialog,
41
- @Inject('memberData') public config: CoolmapConfigModel) {
42
- if (this.config.repository === 'customer') {
43
- this.utils.fetchMaterialsListForCustomer().then((res)=>{
44
- this.materialsList = res;
45
- });
46
- } else {
47
- this.utils.fetchMaterialsList().then((res)=>{
48
- this.materialsList = res;
49
- });
50
- }
51
-
52
- this.utils.fetchUnitsList().then((res)=>{
53
- this.unitsList = res;
54
- });
55
- this.formInit();
56
- this.utils.getrouteDetailsUtility.subscribe(res => {
57
- if (res) {
58
- if (res['event'] !== 'click' && !this.prevantPopupClose) { this.enablePopUp = res['event'] }
59
- else if (this.enablePopUp && !this.prevantPopupClose) { this.prevantPopupClose = true; }
60
- if (res['event'] !== 'click' && !res['event'] && this.prevantPopupClose) {
61
- this.popupDetails = this.utils.getdictValue('route-detailsv2');
62
- } else { this.popupDetails = res['route'] }
63
- if (this.enablePopUp) this.popupDetails['created_at'] = this.utils.getDateFormat(new Date(this.popupDetails['created_at']), '/');
64
- }
65
- });
66
- }
67
- filterCustomerList() {
68
- this.customersList$ = this.addRouteForm.controls['customer_name'].valueChanges.pipe(
69
- startWith(''),
70
- map(value => this._filter(value || '')),
71
- );
72
- }
73
- public _filter(value: string): string[] {
74
- const filterValue = value.toLowerCase();
75
- return this.customersList.filter((option: any) => option['customer_name'].toLowerCase().includes(filterValue));
76
- }
77
- ngOnChanges(changes: SimpleChanges): void {
78
- if (changes['routeData'] && !changes['routeData']['currentValue']) this.inIt(null);
79
- }
80
- openDialog(): void {
81
- const dialogRef = this.dialog.open(DialogComponent, {
82
- data: { body: 'Are you sure you want to delete this route?' },
83
- });
84
- dialogRef.afterClosed().subscribe(res => { if (res) { this.deleteRoute() } });
85
- }
86
- editEvent() {
87
- this.prevantPopupClose = false;
88
- this.enableForm = true; this.enablePopUp = false;
89
- this.popupDetails['prevent'] = false;
90
- this.utils.removeMapEntity.next(this.popupDetails);
91
- this.inIt(this.popupDetails);
92
- }
93
- inIt(changes: Route) {
94
- if (changes) {
95
- if (!changes['prevent']) {
96
- this.preventSave = false;
97
- this.formControlValue();
98
- this.patchFormValue(changes).then(() => {
99
- this.checkAndFetchRouteInformation(true)
100
- });
101
- }
102
- }
103
- if (!changes) {
104
- this.enableForm = true; this.preventSave = true;
105
- this.patchFormValue().then(() => {
106
- this.checkAndFetchRouteInformation()
107
- });
108
- }
109
- }
110
- ngOnInit(): void {
111
- this.formControlValue();
112
- if (this.config.repository === 'customer') {
113
- this.addRouteForm.patchValue({
114
- customer_id: this.customerRepoDetails.customer.id,
115
- customer_name: this.customerRepoDetails.customer.name,
116
- })
117
- } else {
118
- this.utils.fetchCustomersList().then((res)=>{
119
- this.customersList = res; this.filterCustomerList(); this.addRouteForm.controls['customer_name'].enable();
120
- });
121
- }
122
- }
123
-
124
- ngAfterViewInit() {
125
- fromEvent(this.filterPickup.nativeElement, 'keyup').pipe(
126
- distinctUntilChanged(), debounceTime(150)).pipe(takeUntil(this.destroyer$)).subscribe(() => {
127
- this.utils.fetchAutoCompleteLocations(this.filterPickup.nativeElement.value).pipe(takeUntil(this.destroyer$)).subscribe((res: any) => {
128
- this.pickupOptions = res.features;
129
- });
130
- });
131
-
132
- fromEvent(this.filterDelivery.nativeElement, 'keyup').pipe(
133
- distinctUntilChanged(), debounceTime(150)).pipe(takeUntil(this.destroyer$)).subscribe(() => {
134
- this.utils.fetchAutoCompleteLocations(this.filterDelivery.nativeElement.value).pipe(takeUntil(this.destroyer$)).subscribe((res: any) => {
135
- this.deliveryOptions = res.features;
136
- });
137
- });
138
- }
139
-
140
- formControlValue() {
141
- this.addRouteForm.controls['pickup_location']?.valueChanges.pipe(takeUntil(this.destroyer$)).subscribe((res: any) => {
142
- if (this.addRouteForm.value.pickup_location && res !== this.addRouteForm.value.pickup_location) {
143
- this.addRouteForm.patchValue({ pickup_lat_lng: '' });
144
- this.addRouteForm.controls['pickup_lat_lng'].markAsTouched();
145
- }
146
- });
147
-
148
- this.addRouteForm.controls['delivery_location']?.valueChanges.pipe(takeUntil(this.destroyer$)).subscribe((res: any) => {
149
- if (this.addRouteForm.value.delivery_location && res !== this.addRouteForm.value.delivery_location) {
150
- this.addRouteForm.patchValue({ delivery_lat_lng: '' });
151
- this.addRouteForm.controls['delivery_lat_lng'].markAsTouched();
152
- }
153
- });
154
- }
155
-
156
- formInit() {
157
- this.addRouteForm = new FormGroup({
158
- route_name: new FormControl('', [Validators.required]),
159
- customer_name: new FormControl({ value: '', disabled: true }, [Validators.required]),
160
- customer_id: new FormControl(''),
161
- materials_id: new FormControl('', [Validators.required]),
162
- unit_id: new FormControl('', [Validators.required]),
163
- path: new FormControl('', [Validators.required]),
164
- pickup_location: new FormControl('', [Validators.required]),
165
- pickup_lat_lng: new FormControl('', [Validators.required]),
166
- delivery_location: new FormControl('', [Validators.required]),
167
- delivery_lat_lng: new FormControl('', [Validators.required]),
168
- estimated_distance: new FormControl('', [Validators.required]),
169
- estimated_time: new FormControl('', [Validators.required]),
170
- note: new FormControl('', [Validators.maxLength(2048)]),
171
- trucker_pay_estimate: new FormControl(null),
172
- customer_price_estimate: new FormControl(null),
173
- });
174
- }
175
-
176
- async patchFormValue(data?: Route) {
177
- this.addRouteForm.reset();
178
- this.addRouteForm.patchValue(data!);
179
- if (this.config.repository === 'customer') {
180
- this.addRouteForm.patchValue({
181
- customer_id: this.customerRepoDetails.customer.id,
182
- customer_name: this.customerRepoDetails.customer.name,
183
- })
184
- }
185
- this.routeId = data?.route_id;
186
- this.routeDetails = data ? { pickup_location: data.pickup_location, delivery_location: data.delivery_location } : null;
187
- this.addRouteForm.valueChanges.pipe(takeUntil(this.destroyer$)).subscribe(res => {
188
- if (res) { if (this.preventInitialSave) this.preventInitialSave = false }
189
- });
190
- this.filterCustomerList();
191
- await true;
192
- }
193
-
194
- selectedLongLat(type: string, event: any) {
195
- if (type === 'pickup') {
196
- this.addRouteForm.patchValue({
197
- pickup_lat_lng: (event.geometry.coordinates[1] + ',' + event.geometry.coordinates[0]).toString()
198
- });
199
- this.coolMapService.clearBoundWithCordinates();
200
- } else if (type === 'delivery') {
201
- this.addRouteForm.patchValue({
202
- delivery_lat_lng: (event.geometry.coordinates[1] + ',' + event.geometry.coordinates[0]).toString()
203
- })
204
- }
205
- this.checkAndFetchRouteInformation();
206
- }
207
-
208
- checkAndFetchRouteInformation(isinitial?: boolean) {
209
- if (this.addRouteForm.value?.delivery_lat_lng?.length > 0 && this.addRouteForm.value?.pickup_lat_lng?.length > 0 && this.addRouteForm.value.unit_id) {
210
- let unit = this.unitsList.find((x: any) => x.id === this.addRouteForm.value.unit_id);
211
- const param = {
212
- delivery_lat_lng: this.addRouteForm.value.delivery_lat_lng,
213
- pickup_lat_lng: this.addRouteForm.value.pickup_lat_lng,
214
- unit: unit?.type
215
- };
216
- this.utils.postdata('calculate/routes/estimation', param).pipe(takeUntil(this.destroyer$)).subscribe((res: any) => {
217
- if (res && res['path']) {
218
- this.addRouteForm.patchValue({
219
- estimated_distance: res['dist'],
220
- estimated_time: res['time'],
221
- path: res['path'],
222
- trucker_pay_estimate: res['trucker_haul_cost'],
223
- customer_price_estimate: (+(+res['trucker_haul_cost'] / 0.80).toFixed(2))
224
- });
225
- let path = res['path'].split(';');
226
- path = path.map((ele: string | any) => { return ele = this.formateLatLong(ele) });
227
- res['path'] = path;
228
- const element: any = {
229
- type: 'FeatureCollection',
230
- features: [{ type: 'Feature', properties: {}, geometry: { type: 'LineString', coordinates: res['path'] } }]
231
- }
232
- this.coolMapService.removeRouteAndMarker(1).then(() => {
233
- const unit = this.unitsList.find((x: any) => x.id === this.addRouteForm.value.unit_id);
234
- const materialDetails = this.materialsList.find((x: any) => x.sub_material_id === this.addRouteForm.value.materials_id);
235
- this.coolMapService.loadMapProperty(element, 1, unit?.type,
236
- {
237
- pickup_location: this.addRouteForm.get('pickup_location')?.value,
238
- delivery_location: this.addRouteForm.get('delivery_location')?.value,
239
- route_name: this.addRouteForm.get('route_name')?.value,
240
- materialLabel: materialDetails?.label,
241
- unit: unit?.type
242
- }).then((res) => { this.preventSave = true });
243
- });
244
- } else {
245
- this.coolMapService.removeRouteAndMarker(1);
246
- this.utils.openSnackBar(res['status'], 'error');
247
- }
248
- if (this.routeId && isinitial) this.preventInitialSave = true;
249
- });
250
- } else { this.coolMapService.removeRouteAndMarker(1) }
251
- }
252
-
253
- formateLatLong(latlong: string) { return latlong ? latlong.split(',').map(x => +x).reverse() : null }
254
- saveRoute() {
255
- if (this.addRouteForm.valid) {
256
- this.preventSave = false;
257
- const data = this.addRouteForm.getRawValue();
258
- const url = this.routeId ? this.utils.postdata('update/routes', data) : this.utils.postdata('add/routes', data)
259
- if (this.routeId) data['id'] = this.routeId;
260
- url.pipe(takeUntil(this.destroyer$)).subscribe((res: any) => {
261
- if (res.success) {
262
- this.updateRouteList.emit(true);
263
- this.utils.openSnackBar(res.message, 'success');
264
- this.preventInitialSave = true;
265
- this.preventSave = true;
266
- if (!this.routeId) this.changeNav.next('Addroute');
267
- } else {
268
- this.utils.openSnackBar(res.message, 'error');
269
- this.preventSave = true;
270
- }
271
- }, (err) => { if (err) { this.preventSave = true; } });
272
- } else {
273
- this.addRouteForm.markAllAsTouched();
274
- }
275
- }
276
- deleteRoute() {
277
- this.preventSave = false;
278
- this.utils.postdata('delete/routes', { uuid: this.routeId }).subscribe(res => {
279
- if (res['data']['success']) {
280
- this.utils.openSnackBar(res['data']['message'], 'success');
281
- this.updateRouteList.emit(true);
282
- this.changeNav.next('Addroute');
283
- this.preventInitialSave = true;
284
- this.preventSave = true;
285
- } else {
286
- this.utils.openSnackBar('Somthing went wrong', 'error');
287
- this.preventSave = true;
288
- }
289
- }, (err) => { this.preventSave = true })
290
- }
291
- ngOnDestroy(): void {
292
- this.destroyer$.next(true);
293
- this.destroyer$.unsubscribe();
294
- }
295
- }