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

Merge pull request #1330 from ever-co/feature/remove-products-order

Feature/remove products order
parents 764a075f 88abfd1f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -313,6 +313,7 @@ export class WarehousesOrdersService
			products: newProducts,
		});

		// TODO investigate why bellow function throw error when adding new product
		await this._updateProductCount(order, warehouseId);

		return order;
+6 −1
Original line number Diff line number Diff line
@@ -44,10 +44,15 @@
<div class="hr"></div>

<div (click)="goToOrder()" class="order-body">
	<div class="product-container" *ngFor="let product of order.products">
	<div
		class="product-container"
		[ngClass]="product.price == 0 ? 'deleted-product' : ''"
		*ngFor="let product of order.products"
	>
		<e-cu-order-product
			[orderProduct]="product"
			[showDetailsButton]="showDetailsButton"
			(remove)="removeProduct(order._id, $event)"
		></e-cu-order-product>
	</div>
</div>
+23 −0
Original line number Diff line number Diff line
@@ -59,8 +59,25 @@
	width: 100%;
}

@keyframes product-fade-out {
	50% {
		opacity: 0.2;
		margin-right: calc(100% + 15px);
		margin-left: calc(-100% + 15px);
	}
	100% {
		margin-right: calc(100% + 15px);
		margin-left: calc(-100% + 15px);
		width: 0;
		height: 0;
		padding: 0;
	}
}

.order-body {
	padding: 15px;
	display: flex;
	flex-direction: column;

	.product-container {
		padding-bottom: 15px;
@@ -68,5 +85,11 @@
		&:last-of-type {
			padding-bottom: 0;
		}

		&.deleted-product {
			animation-name: product-fade-out;
			animation-duration: 1s;
			animation-fill-mode: both;
		}
	}
}
+23 −1
Original line number Diff line number Diff line
@@ -3,6 +3,8 @@ import {
	Component,
	Input,
	Inject,
	EventEmitter,
	Output,
} from '@angular/core';
import { Store } from '../../services/store.service';
import OrderStatus from '@modules/server.common/enums/OrderStatus';
@@ -20,6 +22,7 @@ import { DOCUMENT } from '@angular/common';
import DeliveryType from '@modules/server.common/enums/DeliveryType';
import { NavController } from '@ionic/angular';
import { environment } from 'environments/environment';
import { OrderRouter } from '@modules/client.common.angular2/routers/order-router.service';

@Component({
	selector: 'e-cu-order',
@@ -36,11 +39,16 @@ import { environment } from 'environments/environment';
	]*/
})
export class OrderComponent {
	deletedProductId: string;

	@Input()
	order: Order;
	@Input()
	showDetailsButton: boolean = false;

	@Output()
	orderChange = new EventEmitter<Order>();

	get id() {
		return this.order.id;
	}
@@ -120,7 +128,8 @@ export class OrderComponent {
	constructor(
		@Inject(DOCUMENT) public document: Document,
		private readonly store: Store,
		public navCtrl: NavController
		public navCtrl: NavController,
		private orderRouter: OrderRouter
	) {}

	goToOrder() {
@@ -135,6 +144,19 @@ export class OrderComponent {
		}
	}

	async removeProduct(orderId, orderProduct) {
		await this.orderRouter.removeProducts(orderId, [
			orderProduct.product._id,
		]);

		const productIndex = this.order.products.findIndex(
			(p) => p.id == orderProduct.id
		);
		this.order.products[productIndex].price = 0;
		this.deletedProductId = orderProduct._id;
		this.orderChange.emit(this.order);
	}

	private _millisToMinutes(ms) {
		const minutes = Math.floor(ms / 60000);
		const seconds = ((ms % 60000) / 1000).toFixed(0);
+13 −1
Original line number Diff line number Diff line
<div class="container">
	<div class="test">
	<div class="container-row">
		<section class="product-image">
			<ion-img [src]="image.url" [ngClass]="imageClass"></ion-img>
		</section>
@@ -35,4 +35,16 @@
	>
		${{ price }}
	</section>

	<section
		class="product-remove"
		[ngClass]="{
			ltr: document.documentElement.dir === 'rtl',
			rtl: document.documentElement.dir !== 'rtl',
			'product-remove-out': isRemove
		}"
		(click)="onRemove()"
	>
		<i class="fa fa-trash"></i>
	</section>
</div>
Loading