Loading packages/admin-web-angular/src/app/pages/+carriers/+carrier/carrier.component.ts +1 −1 Original line number Diff line number Diff line Loading @@ -19,7 +19,7 @@ import { CarrierOrdersComponent } from './carrier-orders/carrier-orders.componen styleUrls: ['./carrier.component.scss'], }) export class CarrierComponent implements OnInit, OnDestroy { @ViewChild('carrierOrders', { static: true }) @ViewChild('carrierOrders', { static: false }) public carrierOrders: CarrierOrdersComponent; private ngDestroy$ = new Subject(); Loading packages/admin-web-angular/src/assets/i18n/he.json +1 −1 Original line number Diff line number Diff line Loading @@ -17,7 +17,7 @@ "ADD_PRODUCTS": "Add products", "REMOVE_PRODUCTS": "Remove Products", "CANCEL_ORDER": "Cancel Order", "THE_ORDER_IS_CANCELED": "The order is cancel", "THE_ORDER_IS_CANCELED": "The order is canceled", "THE_ORDER_IS_GIVEN_TO_CARRIER": "The order is given to carrier.", "THE_ORDER_IS_DELIVERED": "The order is delivered.", "ADD_PRODUCTS_MODAL": "Add Products", Loading packages/admin-web-angular/src/assets/i18n/ru.json +1 −1 Original line number Diff line number Diff line Loading @@ -17,7 +17,7 @@ "ADD_PRODUCTS": "Добавить товары", "REMOVE_PRODUCTS": "Удалить товары", "CANCEL_ORDER": "Отменить заказ", "THE_ORDER_IS_CANCELED": "Ордер отменен", "THE_ORDER_IS_CANCELED": "Заказ отменен", "THE_ORDER_IS_GIVEN_TO_CARRIER": "Заказ выдан перевозчику.", "THE_ORDER_IS_DELIVERED": "Заказ доставлен.", "ADD_PRODUCTS_MODAL": "Добавить товары", Loading packages/shop-mobile-ionic/src/app/pages/+products/+searchProducts/searchProducts.component.html +72 −32 Original line number Diff line number Diff line Loading @@ -6,55 +6,95 @@ placeholder="Product or a shop name" animated debounce="500" (ionChange)="loadProducts()" (ionChange)="loadFullData()" ></ion-searchbar> <!-- <ion-list class="merchants-list"> <ion-list-header class="p-0 mb-1"> </ion-list-header> <div class="merchants-container"> <h5 *ngIf="searchResultMerchants?.length === 0" class="not-found-text"> ne e namereno </h5> <ion-item *ngFor="let merchant of searchResultMerchants" (click)="selectMerchant(merchant)" class="m-2" lines="none" > <ion-avatar slot="start"> <img src="{{ merchant.logo }}" /> </ion-avatar> <ion-label> {{ merchant.name }} </ion-label> </ion-item> </div> </ion-list> --> <ion-list class="brand-dark"> <div class="products-container"> <h5 *ngIf="searchResultProducts?.length === 0" *ngIf=" searchResultProducts.length === 0 && searchResultMerchants.length === 0 " class="not-found-text p-3" > Empty List </h5> <ion-item *ngFor="let product of searchResultProducts" color="medium" *ngFor="let merchant of searchResultMerchants" lines="none" class="m-2" > <ion-avatar slot="start"> <img src="{{ product.warehouseLogo }}" /> <img [src]="merchant.logo" /> </ion-avatar> <ion-label >{{ product.warehouseProduct.product['title'][0].value }} </ion-label> <ion-label >price: {{ product.warehouseProduct.price }} </ion-label> <ion-label>{{ merchant.name }} </ion-label> </ion-item> <div class="center" *ngIf="searchResultMerchants.length"> <ion-button color="tertiary" size="small" (click)="loadMoreMerchants()" >View More</ion-button > </div> <ion-card *ngFor="let productInfo of searchResultProducts"> <ion-row class="product-container" (click)="goToDetailsPage(productInfo)" > <ion-col class="col-3 image-container"> <img [src]="getProductImage(productInfo)" /> </ion-col> <ion-col class="col-9" class="col-9 info-container"> <ion-row> <ion-col> <span class="product-title"> {{ localeTranslate( productInfo.warehouseProduct .product['title'] ) }} </span> </ion-col> <ion-col class="col-3 price"> <ion-badge color="primary" >{{ productInfo.warehouseProduct.price }} $</ion-badge > </ion-col> </ion-row> <ion-row> <span class="product-description"> {{ shortenDescription( localeTranslate( productInfo.warehouseProduct .product['description'] ) ) }} </span> </ion-row> </ion-col> </ion-row> </ion-card> <div class="center" *ngIf="searchResultProducts.length"> <ion-button color="tertiary" size="small" (click)="loadMoreProducts()" >View More</ion-button > </div> </div> </ion-list> </div> packages/shop-mobile-ionic/src/app/pages/+products/+searchProducts/searchProducts.component.ts +127 −67 Original line number Diff line number Diff line import { Component, OnInit } from '@angular/core'; import { Component, OnInit, Output, EventEmitter } from '@angular/core'; import { first } from 'rxjs/operators'; import Warehouse from '@modules/server.common/entities/Warehouse'; Loading @@ -6,15 +6,18 @@ import { ILocation } from '@modules/server.common/interfaces/IGeoLocation'; import GeoLocation from '@modules/server.common/entities/GeoLocation'; import RegistrationSystem from '@modules/server.common/enums/RegistrationSystem'; import ProductInfo from '@modules/server.common/entities/ProductInfo'; import DeliveryType from '@modules/server.common/enums/DeliveryType'; import { MerchantsService } from 'app/services/merchants/merchants.service'; import { Store } from 'app/services/store.service'; import { UserRouter } from '@modules/client.common.angular2/routers/user-router.service'; import { GeoLocationService } from 'app/services/geo-location'; import { Router } from '@angular/router'; import { ProductLocalesService } from '@modules/client.common.angular2/locale/product-locales.service'; import { ILocaleMember } from '@modules/server.common/interfaces/ILocale'; import { environment } from 'environments/environment'; import { GeoLocationProductsService } from 'app/services/geo-location/geo-location-products'; import { WarehouseProductsService } from 'app/services/merchants/warehouse-products'; @Component({ selector: 'search-products', Loading @@ -22,9 +25,13 @@ import { GeoLocationProductsService } from 'app/services/geo-location/geo-locati styleUrls: ['./searchProducts.style.scss'], }) export class SearchProductsComponent implements OnInit { searchInput: string; searchResultMerchants: Warehouse[]; searchResultProducts: ProductInfo[]; private static MAX_DESCRIPTION_LENGTH: number = 100; private loadingOrdersLimit: number = 6; private loadingMerchantsLimit: number = 5; searchInput: string = ''; searchResultMerchants: Warehouse[] = []; searchResultProducts: ProductInfo[] = []; getOrdersGeoObj: { loc: ILocation }; constructor( Loading @@ -33,81 +40,90 @@ export class SearchProductsComponent implements OnInit { private userRouter: UserRouter, private geoLocationService: GeoLocationService, private geoLocationProductsService: GeoLocationProductsService, private router: Router private router: Router, private readonly translateProductLocales: ProductLocalesService, private warehouseProductsService: WarehouseProductsService ) {} ngOnInit() { this.loadGeoLocationProducts(); this.loadFullData(); } async loadFullData() { await this.loadGeoLocationProducts(); this.loadMerchants(); this.loadProducts(); } async loadMerchants() { const location = this.getOrdersGeoObj.loc; const merchants = await this.merchantsService.getMerchantsBuyName( this.searchInput, { loc: location } ); this.searchResultMerchants = merchants.slice(0, 5); } async loadMoreMerchants() { const location = this.getOrdersGeoObj.loc; const merchants = await this.merchantsService.getMerchantsBuyName( this.searchInput, { loc: location } ); merchants .slice( this.searchResultMerchants.length, this.searchResultMerchants.length + this.loadingMerchantsLimit ) .map((merch) => this.searchResultMerchants.push(merch)); } async loadProducts() { const isDeliveryRequired = this.store.deliveryType === DeliveryType.Delivery; const isTakeaway = this.store.deliveryType === DeliveryType.Takeaway; await this.geoLocationProductsService .geoLocationProductsByPaging(this.getOrdersGeoObj, { .geoLocationProductsByPaging( this.getOrdersGeoObj, { limit: this.loadingOrdersLimit, skip: 0, limit: 100, }) }, { isDeliveryRequired, isTakeaway, }, this.searchInput ) .pipe(first()) .subscribe((products: ProductInfo[]) => { this.filterProducts(products); .subscribe((products) => { this.searchResultProducts = products; // products.map((pr) => this.searchResultProducts.push(pr)); }); } async loadMoreProducts() { const isDeliveryRequired = this.store.deliveryType === DeliveryType.Delivery; const isTakeaway = this.store.deliveryType === DeliveryType.Takeaway; filterProducts(products: ProductInfo[]) { if (products) { const filteredProducts = products.filter((product) => { const title = product.warehouseProduct.product['title']; const result = title.filter((t) => t.value .toLowerCase() .includes(this.searchInput.toLowerCase()) ); if (result.length === 0) { return false; } return result; await this.geoLocationProductsService .geoLocationProductsByPaging( this.getOrdersGeoObj, { limit: this.loadingOrdersLimit, skip: this.searchResultProducts.length, }, { isDeliveryRequired, isTakeaway, }, this.searchInput ) .pipe(first()) .subscribe((products) => { products.map((pr) => this.searchResultProducts.push(pr)); }); this.searchResultProducts = filteredProducts; // .filter(prod=>prod.warehouseProduct.isDeliveryRequired === !+this.store.deliveryType) // console.log(this.searchResultProducts) } } // async loadSearchMerchants() { // const location = await this.getLocation(); // this.searchResultMerchants = await this.merchantsService.getMerchantsBuyName( // this.searchInput, // { loc: location } // ); // } // private async getLocation() { // let location: ILocation; // const isProductionEnv = environment.production; // if (this.store.userId && isProductionEnv) { // const user = await this.userRouter // .get(this.store.userId) // .pipe(first()) // .toPromise(); // location = { // type: 'Point', // coordinates: user.geoLocation.loc.coordinates, // }; // } else { // const findGeoLocation = await this.geoLocationService.getCurrentGeoLocation(); // location = { // type: 'Point', // coordinates: findGeoLocation.loc.coordinates, // }; // } // return location; // } private async loadGeoLocationProducts() { let geoLocationForProducts: GeoLocation; const isProductionEnv = environment.production; Loading Loading @@ -138,4 +154,48 @@ export class SearchProductsComponent implements OnInit { }; } } localeTranslate(member: ILocaleMember[]): string { return this.translateProductLocales.getTranslate(member); } shortenDescription(desc: string) { return desc.length < SearchProductsComponent.MAX_DESCRIPTION_LENGTH ? desc : desc.substr( 0, SearchProductsComponent.MAX_DESCRIPTION_LENGTH - 3 ) + '...'; } getProductImage(product) { return this.localeTranslate(product.warehouseProduct.product['images']); } async goToDetailsPage(product: ProductInfo) { const prod = await this.warehouseProductsService.getWarehouseProduct( product.warehouseId, product.warehouseProduct.id ); if (prod) { this.router.navigate( [ `/products/product-details/${product.warehouseProduct.product['id']}`, ], { queryParams: { backUrl: '/products', warehouseId: product.warehouseId, }, } ); } else { const loadedProduct = this.searchResultProducts.find( (p) => p.warehouseProduct.id === product.warehouseProduct.id ); if (loadedProduct) { loadedProduct['soldOut'] = true; } } } } Loading
packages/admin-web-angular/src/app/pages/+carriers/+carrier/carrier.component.ts +1 −1 Original line number Diff line number Diff line Loading @@ -19,7 +19,7 @@ import { CarrierOrdersComponent } from './carrier-orders/carrier-orders.componen styleUrls: ['./carrier.component.scss'], }) export class CarrierComponent implements OnInit, OnDestroy { @ViewChild('carrierOrders', { static: true }) @ViewChild('carrierOrders', { static: false }) public carrierOrders: CarrierOrdersComponent; private ngDestroy$ = new Subject(); Loading
packages/admin-web-angular/src/assets/i18n/he.json +1 −1 Original line number Diff line number Diff line Loading @@ -17,7 +17,7 @@ "ADD_PRODUCTS": "Add products", "REMOVE_PRODUCTS": "Remove Products", "CANCEL_ORDER": "Cancel Order", "THE_ORDER_IS_CANCELED": "The order is cancel", "THE_ORDER_IS_CANCELED": "The order is canceled", "THE_ORDER_IS_GIVEN_TO_CARRIER": "The order is given to carrier.", "THE_ORDER_IS_DELIVERED": "The order is delivered.", "ADD_PRODUCTS_MODAL": "Add Products", Loading
packages/admin-web-angular/src/assets/i18n/ru.json +1 −1 Original line number Diff line number Diff line Loading @@ -17,7 +17,7 @@ "ADD_PRODUCTS": "Добавить товары", "REMOVE_PRODUCTS": "Удалить товары", "CANCEL_ORDER": "Отменить заказ", "THE_ORDER_IS_CANCELED": "Ордер отменен", "THE_ORDER_IS_CANCELED": "Заказ отменен", "THE_ORDER_IS_GIVEN_TO_CARRIER": "Заказ выдан перевозчику.", "THE_ORDER_IS_DELIVERED": "Заказ доставлен.", "ADD_PRODUCTS_MODAL": "Добавить товары", Loading
packages/shop-mobile-ionic/src/app/pages/+products/+searchProducts/searchProducts.component.html +72 −32 Original line number Diff line number Diff line Loading @@ -6,55 +6,95 @@ placeholder="Product or a shop name" animated debounce="500" (ionChange)="loadProducts()" (ionChange)="loadFullData()" ></ion-searchbar> <!-- <ion-list class="merchants-list"> <ion-list-header class="p-0 mb-1"> </ion-list-header> <div class="merchants-container"> <h5 *ngIf="searchResultMerchants?.length === 0" class="not-found-text"> ne e namereno </h5> <ion-item *ngFor="let merchant of searchResultMerchants" (click)="selectMerchant(merchant)" class="m-2" lines="none" > <ion-avatar slot="start"> <img src="{{ merchant.logo }}" /> </ion-avatar> <ion-label> {{ merchant.name }} </ion-label> </ion-item> </div> </ion-list> --> <ion-list class="brand-dark"> <div class="products-container"> <h5 *ngIf="searchResultProducts?.length === 0" *ngIf=" searchResultProducts.length === 0 && searchResultMerchants.length === 0 " class="not-found-text p-3" > Empty List </h5> <ion-item *ngFor="let product of searchResultProducts" color="medium" *ngFor="let merchant of searchResultMerchants" lines="none" class="m-2" > <ion-avatar slot="start"> <img src="{{ product.warehouseLogo }}" /> <img [src]="merchant.logo" /> </ion-avatar> <ion-label >{{ product.warehouseProduct.product['title'][0].value }} </ion-label> <ion-label >price: {{ product.warehouseProduct.price }} </ion-label> <ion-label>{{ merchant.name }} </ion-label> </ion-item> <div class="center" *ngIf="searchResultMerchants.length"> <ion-button color="tertiary" size="small" (click)="loadMoreMerchants()" >View More</ion-button > </div> <ion-card *ngFor="let productInfo of searchResultProducts"> <ion-row class="product-container" (click)="goToDetailsPage(productInfo)" > <ion-col class="col-3 image-container"> <img [src]="getProductImage(productInfo)" /> </ion-col> <ion-col class="col-9" class="col-9 info-container"> <ion-row> <ion-col> <span class="product-title"> {{ localeTranslate( productInfo.warehouseProduct .product['title'] ) }} </span> </ion-col> <ion-col class="col-3 price"> <ion-badge color="primary" >{{ productInfo.warehouseProduct.price }} $</ion-badge > </ion-col> </ion-row> <ion-row> <span class="product-description"> {{ shortenDescription( localeTranslate( productInfo.warehouseProduct .product['description'] ) ) }} </span> </ion-row> </ion-col> </ion-row> </ion-card> <div class="center" *ngIf="searchResultProducts.length"> <ion-button color="tertiary" size="small" (click)="loadMoreProducts()" >View More</ion-button > </div> </div> </ion-list> </div>
packages/shop-mobile-ionic/src/app/pages/+products/+searchProducts/searchProducts.component.ts +127 −67 Original line number Diff line number Diff line import { Component, OnInit } from '@angular/core'; import { Component, OnInit, Output, EventEmitter } from '@angular/core'; import { first } from 'rxjs/operators'; import Warehouse from '@modules/server.common/entities/Warehouse'; Loading @@ -6,15 +6,18 @@ import { ILocation } from '@modules/server.common/interfaces/IGeoLocation'; import GeoLocation from '@modules/server.common/entities/GeoLocation'; import RegistrationSystem from '@modules/server.common/enums/RegistrationSystem'; import ProductInfo from '@modules/server.common/entities/ProductInfo'; import DeliveryType from '@modules/server.common/enums/DeliveryType'; import { MerchantsService } from 'app/services/merchants/merchants.service'; import { Store } from 'app/services/store.service'; import { UserRouter } from '@modules/client.common.angular2/routers/user-router.service'; import { GeoLocationService } from 'app/services/geo-location'; import { Router } from '@angular/router'; import { ProductLocalesService } from '@modules/client.common.angular2/locale/product-locales.service'; import { ILocaleMember } from '@modules/server.common/interfaces/ILocale'; import { environment } from 'environments/environment'; import { GeoLocationProductsService } from 'app/services/geo-location/geo-location-products'; import { WarehouseProductsService } from 'app/services/merchants/warehouse-products'; @Component({ selector: 'search-products', Loading @@ -22,9 +25,13 @@ import { GeoLocationProductsService } from 'app/services/geo-location/geo-locati styleUrls: ['./searchProducts.style.scss'], }) export class SearchProductsComponent implements OnInit { searchInput: string; searchResultMerchants: Warehouse[]; searchResultProducts: ProductInfo[]; private static MAX_DESCRIPTION_LENGTH: number = 100; private loadingOrdersLimit: number = 6; private loadingMerchantsLimit: number = 5; searchInput: string = ''; searchResultMerchants: Warehouse[] = []; searchResultProducts: ProductInfo[] = []; getOrdersGeoObj: { loc: ILocation }; constructor( Loading @@ -33,81 +40,90 @@ export class SearchProductsComponent implements OnInit { private userRouter: UserRouter, private geoLocationService: GeoLocationService, private geoLocationProductsService: GeoLocationProductsService, private router: Router private router: Router, private readonly translateProductLocales: ProductLocalesService, private warehouseProductsService: WarehouseProductsService ) {} ngOnInit() { this.loadGeoLocationProducts(); this.loadFullData(); } async loadFullData() { await this.loadGeoLocationProducts(); this.loadMerchants(); this.loadProducts(); } async loadMerchants() { const location = this.getOrdersGeoObj.loc; const merchants = await this.merchantsService.getMerchantsBuyName( this.searchInput, { loc: location } ); this.searchResultMerchants = merchants.slice(0, 5); } async loadMoreMerchants() { const location = this.getOrdersGeoObj.loc; const merchants = await this.merchantsService.getMerchantsBuyName( this.searchInput, { loc: location } ); merchants .slice( this.searchResultMerchants.length, this.searchResultMerchants.length + this.loadingMerchantsLimit ) .map((merch) => this.searchResultMerchants.push(merch)); } async loadProducts() { const isDeliveryRequired = this.store.deliveryType === DeliveryType.Delivery; const isTakeaway = this.store.deliveryType === DeliveryType.Takeaway; await this.geoLocationProductsService .geoLocationProductsByPaging(this.getOrdersGeoObj, { .geoLocationProductsByPaging( this.getOrdersGeoObj, { limit: this.loadingOrdersLimit, skip: 0, limit: 100, }) }, { isDeliveryRequired, isTakeaway, }, this.searchInput ) .pipe(first()) .subscribe((products: ProductInfo[]) => { this.filterProducts(products); .subscribe((products) => { this.searchResultProducts = products; // products.map((pr) => this.searchResultProducts.push(pr)); }); } async loadMoreProducts() { const isDeliveryRequired = this.store.deliveryType === DeliveryType.Delivery; const isTakeaway = this.store.deliveryType === DeliveryType.Takeaway; filterProducts(products: ProductInfo[]) { if (products) { const filteredProducts = products.filter((product) => { const title = product.warehouseProduct.product['title']; const result = title.filter((t) => t.value .toLowerCase() .includes(this.searchInput.toLowerCase()) ); if (result.length === 0) { return false; } return result; await this.geoLocationProductsService .geoLocationProductsByPaging( this.getOrdersGeoObj, { limit: this.loadingOrdersLimit, skip: this.searchResultProducts.length, }, { isDeliveryRequired, isTakeaway, }, this.searchInput ) .pipe(first()) .subscribe((products) => { products.map((pr) => this.searchResultProducts.push(pr)); }); this.searchResultProducts = filteredProducts; // .filter(prod=>prod.warehouseProduct.isDeliveryRequired === !+this.store.deliveryType) // console.log(this.searchResultProducts) } } // async loadSearchMerchants() { // const location = await this.getLocation(); // this.searchResultMerchants = await this.merchantsService.getMerchantsBuyName( // this.searchInput, // { loc: location } // ); // } // private async getLocation() { // let location: ILocation; // const isProductionEnv = environment.production; // if (this.store.userId && isProductionEnv) { // const user = await this.userRouter // .get(this.store.userId) // .pipe(first()) // .toPromise(); // location = { // type: 'Point', // coordinates: user.geoLocation.loc.coordinates, // }; // } else { // const findGeoLocation = await this.geoLocationService.getCurrentGeoLocation(); // location = { // type: 'Point', // coordinates: findGeoLocation.loc.coordinates, // }; // } // return location; // } private async loadGeoLocationProducts() { let geoLocationForProducts: GeoLocation; const isProductionEnv = environment.production; Loading Loading @@ -138,4 +154,48 @@ export class SearchProductsComponent implements OnInit { }; } } localeTranslate(member: ILocaleMember[]): string { return this.translateProductLocales.getTranslate(member); } shortenDescription(desc: string) { return desc.length < SearchProductsComponent.MAX_DESCRIPTION_LENGTH ? desc : desc.substr( 0, SearchProductsComponent.MAX_DESCRIPTION_LENGTH - 3 ) + '...'; } getProductImage(product) { return this.localeTranslate(product.warehouseProduct.product['images']); } async goToDetailsPage(product: ProductInfo) { const prod = await this.warehouseProductsService.getWarehouseProduct( product.warehouseId, product.warehouseProduct.id ); if (prod) { this.router.navigate( [ `/products/product-details/${product.warehouseProduct.product['id']}`, ], { queryParams: { backUrl: '/products', warehouseId: product.warehouseId, }, } ); } else { const loadedProduct = this.searchResultProducts.find( (p) => p.warehouseProduct.id === product.warehouseProduct.id ); if (loadedProduct) { loadedProduct['soldOut'] = true; } } } }