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

Merge pull request #1155 from ever-co/feat/#21-is-product-available

feat: implemented functionality about product availability
parents edff55a3 a30f762f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
{
	"name": "@ever-platform/admin-web-angular",
	"version": "0.3.1",
	"version": "0.3.7",
	"description": "Ever Admin",
	"license": "AGPL-3.0",
	"homepage": "https://ever.co",
+0 −1
Original line number Diff line number Diff line
@@ -272,7 +272,6 @@ export class WarehousesService {

		return res.data['getCountOfMerchants'];
	}

	protected _warehouseFactory(warehouse: IWarehouse) {
		return warehouse == null ? null : new Warehouse(warehouse);
	}
+2 −0
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@ import { ProductImageComponent } from './product-image/product-image.component';
import { CustomerEmailComponent } from './customer-email/customer-email.component';
import { CustomerPhoneComponent } from './customer-phone/customer-phone.component';
import { CheckboxComponent } from './customer-orders-table/checkbox/checkbox.component';
import { IsAvailableCheckBox } from './store-product-is-available-checkbox/is-available-checkbox.component';

const COMPONENTS = [
	PriceCountInputComponent,
@@ -28,6 +29,7 @@ const COMPONENTS = [
	ProductImageComponent,
	CustomerEmailComponent,
	CustomerPhoneComponent,
	IsAvailableCheckBox,
];

@NgModule({
+50 −0
Original line number Diff line number Diff line
import { Component, Input, OnInit } from '@angular/core';
import { ViewCell } from 'ng2-smart-table';
import { WarehouseProductsRouter } from '@modules/client.common.angular2/routers/warehouse-products-router.service';
@Component({
	template: `
		<div class="checkbox-container">
			<nb-checkbox
				[(ngModel)]="isChecked"
				(checkedChange)="clickHandler($event)"
			></nb-checkbox>
		</div>
	`,
	styles: [
		`
			.checkbox-container {
				display: flex;
				justify-content: center;
				align-items: center;
			}
			​ nb-checkbox {
				width: 1rem;
				height: 1rem;
			}
		`,
	],
})
export class IsAvailableCheckBox implements ViewCell, OnInit {
	@Input() rowData: any;
	@Input() value: string;
	isChecked: boolean;
	wareHouseId: string;
	productId: string;
	constructor(private warehouseProductRouter: WarehouseProductsRouter) {}
	ngOnInit() {
		this.isChecked = this.rowData.isProductAvailable;
		this.wareHouseId = this.rowData.storeId;
		this.productId = this.rowData.product.id;
		console.warn(this.rowData);
	}

	async clickHandler() {
		this.isChecked = !this.isChecked;
		this.rowData.isProductAvailable = this.isChecked;
		await this.warehouseProductRouter.changeProductAvailability(
			this.wareHouseId,
			this.productId,
			this.rowData.isProductAvailable
		);
	}
}
+12 −1
Original line number Diff line number Diff line
@@ -19,6 +19,8 @@ import { ProductLocalesService } from '@modules/client.common.angular2/locale/pr
import { ProductsCategoryService } from '@app/@core/data/productsCategory.service';
import Product from '@modules/server.common/entities/Product';
import { StoreProductImageComponent } from '@app/@shared/render-component/store-products-table/store-product-image/store-product-image.component';
import { CheckboxComponent } from '@app/@shared/render-component/customer-orders-table/checkbox/checkbox.component';
import { IsAvailableCheckBox } from '@app/@shared/render-component/store-product-is-available-checkbox/is-available-checkbox.component';

export interface WarehouseProductViewModel {
	id: string;
@@ -32,6 +34,7 @@ export interface WarehouseProductViewModel {
	storeId: string;
	product: Product;
	allCategories: any[];
	isProductAvailable: boolean;
}

@Component({
@@ -118,6 +121,7 @@ export class WarehouseProductsComponent implements OnInit, OnDestroy {
				storeId,
				product: product.product,
				allCategories: this.categoriesInfo,
				isProductAvailable: product.isProductAvailable,
			};
		});

@@ -149,6 +153,7 @@ export class WarehouseProductsComponent implements OnInit, OnDestroy {
			getTranslate('CATEGORY'),
			getTranslate('PRICE'),
			getTranslate('QUANTITY'),
			getTranslate('AVAILABILITY'),
			getTranslate('TYPE')
		)
			.pipe(takeUntil(this.ngDestroy$))
@@ -162,7 +167,8 @@ export class WarehouseProductsComponent implements OnInit, OnDestroy {
					category,
					price,
					quantity,
					type,
					availability,
					type
				]) => {
					this.settingsSmartTable = {
						mode: 'external',
@@ -218,6 +224,11 @@ export class WarehouseProductsComponent implements OnInit, OnDestroy {
								class: 'text-center',
								type: 'custom',
								renderComponent: StoreProductAmountComponent,
							},
							isAvailable: {
								title: availability,
								type: 'custom',
								renderComponent: IsAvailableCheckBox
              },
							type: {
								title: type,
Loading