Unverified Commit d07f08b4 authored by Ruslan Konviser's avatar Ruslan Konviser Committed by GitHub
Browse files

Merge pull request #1272 from ever-co/fix/#1244/#1242-inactive-store-show-orders-products

fix: when inactive show store orders and products
parents fd31e874 bbb8b736
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -173,7 +173,7 @@ export class WarehouseComponent implements OnDestroy, AfterViewInit, OnChanges {

	private _loadWarehouses() {
		this.warehouseRouter
			.getAllActive()
			.getAll()
			.pipe(takeUntil(this.ngDestroy$))
			.subscribe((w: Warehouse[]) => {
				this.warehouses = w;
+1 −1
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@
	"name": "@ever-platform/common-angular",
	"description": "Ever Platform Shared Angular Core",
	"license": "AGPL-3.0",
	"version": "0.3.5",
	"version": "0.3.6",
	"homepage": "https://ever.co",
	"repository": {
		"type": "git",
+12 −0
Original line number Diff line number Diff line
@@ -38,6 +38,18 @@ export class WarehouseRouter implements IWarehouseRouter {
			);
	}

	getAll(fullProducts: boolean = false): Observable<Warehouse[]> {
		return this.router
			.runAndObserve<IWarehouse[]>('getAllStores', fullProducts)
			.pipe(
				map((warehouses) =>
					_.map(warehouses, (warehouse) =>
						this._warehouseFactory(warehouse)
					)
				)
			);
	}

	async login(
		username: string,
		password: string
+1 −1
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@
	"name": "@ever-platform/core",
	"description": "Ever Platform Headless Framework",
	"license": "AGPL-3.0",
	"version": "0.3.16",
	"version": "0.3.17",
	"homepage": "https://ever.co",
	"repository": {
		"type": "git",
+48 −0
Original line number Diff line number Diff line
@@ -120,6 +120,42 @@ export class WarehousesService extends DBService<Warehouse>
		);
	}

	/**
	 * Get all merchants
	 *
	 * @param {boolean} [fullProducts=false]
	 * @returns {Observable<Warehouse[]>}
	 * @memberof WarehousesService
	 */
	@observableListener()
	getAllStores(fullProducts: boolean = false): Observable<Warehouse[]> {
		const callId = uuid();

		this.log.info(
			{ callId, fullProducts },
			'.getAllStores(fullProducts) called'
		);

		return of(null).pipe(
			concat(this.existence),
			exhaustMap(() => this._getAllStores(fullProducts)),
			tap({
				next: (warehouses) => {
					this.log.info(
						{ callId, fullProducts, warehouses },
						'.getAllStores(fullProducts) emitted next value'
					);
				},
				error: (err) => {
					this.log.error(
						{ callId, fullProducts, err },
						'.getAllStores(fullProducts) thrown error!'
					);
				},
			})
		);
	}

	/**
	 * Create new Merchant
	 *
@@ -314,4 +350,16 @@ export class WarehousesService extends DBService<Warehouse>
			(warehouse) => new Warehouse(warehouse)
		);
	}

	private async _getAllStores(fullProducts = false): Promise<Warehouse[]> {
		return _.map(
			(await this.Model.find({
				isDeleted: { $eq: false },
			})
				.populate(fullProducts ? 'products.product' : '')
				.lean()
				.exec()) as IWarehouse[],
			(warehouse) => new Warehouse(warehouse)
		);
	}
}