Commit f1f4ddf9 authored by Alish's avatar Alish
Browse files

feat: added button for unselectOrder #1030

parent 56fc6b00
Loading
Loading
Loading
Loading
+10 −6
Original line number Diff line number Diff line
@@ -6,12 +6,11 @@
		<span class="right-text">{{ carrierUserDistance + 'km' }}</span>
	</div>
	<div class="buttons">
		<div class="button-bar" *ngIf="!workTaken">
			<button
				*ngIf="!selectedOrder?.isCancelled"
				class="button button-brand"
				(click)="takeWork()"
		<div
			class="button-bar"
			*ngIf="!workTaken && !selectedOrder?.isCancelled"
		>
			<button class="button button-brand" (click)="takeWork()">
				{{ 'DRIVE_TO_WAREHOUSE_VIEW.TAKE_WORK' | translate }}
			</button>

@@ -36,5 +35,10 @@
				{{ 'DRIVE_TO_WAREHOUSE_VIEW.CANCEL' | translate }}
			</button>
		</div>
		<div class="button-bar" *ngIf="selectedOrder?.isCancelled">
			<button class="button button-assertive" (click)="unselectOrder()">
				{{ 'OK' | translate }}
			</button>
		</div>
	</div>
</div>
+9 −13
Original line number Diff line number Diff line
@@ -124,10 +124,6 @@ export class DriveToWarehousePage {
			]);

			this.unselectOrder();

			this.router.navigateByUrl('/main/home', {
				skipLocationChange: false
			});
		}
	}

@@ -161,10 +157,6 @@ export class DriveToWarehousePage {
					[this.selectedOrder['id']]
				);
				this.unselectOrder();

				this.router.navigateByUrl('/main/home', {
					skipLocationChange: false
				});
			}
		}
	}
@@ -174,6 +166,15 @@ export class DriveToWarehousePage {
		this.unsubscribeAll();
	}

	unselectOrder() {
		this.store.selectedOrder = null;
		localStorage.removeItem('orderId');

		this.router.navigateByUrl('/main/home', {
			skipLocationChange: false
		});
	}

	private unsubscribeAll() {
		if (this.carrier$) {
			this.carrier$.unsubscribe();
@@ -183,11 +184,6 @@ export class DriveToWarehousePage {
		}
	}

	private unselectOrder() {
		this.store.selectedOrder = null;
		localStorage.removeItem('orderId');
	}

	private unselectDriveToWarehouseFrom() {
		localStorage.removeItem('driveToWarehouseFrom');
	}
+10 −1
Original line number Diff line number Diff line
@@ -118,7 +118,16 @@ export class HomePage {

				if (carrier.status === CarrierStatus.Online) {
					this.order$ = this.geoLocationOrdersService
						.getOrderForWork(dbGeoInput, carrier.skippedOrderIds)
						.getOrderForWork(
							dbGeoInput,
							carrier.skippedOrderIds,
							null,
							{
								byRegex: [
									{ key: 'isCancelled', value: 'false' }
								]
							}
						)

						.subscribe(async (order) => {
							if (order || this.store.orderId) {
+5 −2
Original line number Diff line number Diff line
@@ -12,7 +12,8 @@ export class GeoLocationOrdersService {
	getOrderForWork(
		geoLocation: IGeoLocation,
		skippedOrderIds: string[] = [],
		options: { sort: string } = { sort: 'asc' }
		options: { sort: string } = { sort: 'asc' },
		searchObj?: { byRegex: Array<{ key: string; value: string }> }
	) {
		return this.apollo
			.watchQuery<{ getOrderForWork: Order }>({
@@ -21,17 +22,19 @@ export class GeoLocationOrdersService {
						$geoLocation: GeoLocationFindInput!
						$skippedOrderIds: [String!]!
						$options: GeoLocationOrdersOptions
						$searchObj: SearchOrdersForWork
					) {
						getOrderForWork(
							geoLocation: $geoLocation
							skippedOrderIds: $skippedOrderIds
							options: $options
							searchObj: $searchObj
						) {
							id
						}
					}
				`,
				variables: { geoLocation, skippedOrderIds, options },
				variables: { geoLocation, skippedOrderIds, options, searchObj },
				pollInterval: 2000
			})
			.valueChanges.pipe(