Loading packages/core/src/graphql/products/promotions/promotion.resolver.ts +18 −0 Original line number Diff line number Diff line Loading @@ -18,4 +18,22 @@ export class PromotionResolver { ) { return this._promotionService.createPromotion(createInput); } @Mutation() async removePromotion(_, { id }: { id: string }): Promise<void> { await this._promotionService.throwIfNotExists(id); return this._promotionService.remove(id); } @Mutation() async removePromotionsByIds(_, { ids }: { ids: string[] }): Promise<void> { const promotions = await this._promotionService.find({ _id: { $in: ids }, isDeleted: { $eq: false }, }); const promotionsIds = promotions.map((p) => p.id); return this._promotionService.removeMultipleByIds(promotionsIds); } } packages/core/src/graphql/products/promotions/promotion.types.graphql +2 −0 Original line number Diff line number Diff line Loading @@ -41,4 +41,6 @@ type Query { type Mutation { createPromotion(createInput: PromotionCreateInput): Promotion removePromotion(id: String!): Void removePromotionsByIds(ids: [String!]!): Remove } packages/core/src/services/products/PromotionService.ts +9 −0 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ import Promotion from '@modules/server.common/entities/Promotion'; import { createEverLogger } from '../../helpers/Log'; import Logger from 'bunyan'; import { IPromotionCreateObject } from '@ever-platform/common/src/interfaces/IPromotion'; import { first } from 'rxjs/operators'; @injectable() @routerName('promotion') Loading Loading @@ -40,4 +41,12 @@ export class PromotionService extends DBService<Promotion> implements IService { isDeleted: { $eq: false }, }); } async throwIfNotExists(promotionId: string) { const promotion = await this.get(promotionId).pipe(first()).toPromise(); if (!promotion || promotion.isDeleted) { throw Error(`Prmotion with id '${promotionId}' does not exist!`); } } } packages/merchant-tablet-ionic/src/components/components.module.ts +3 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import { CustomerDeliveriesPopupPageModule } from 'pages/+customers/customer-del import { CustomerAddrPopupPageModule } from 'pages/+customers/customer-addr-popup/customer-addr-popup.module'; import { FileUploaderModule } from './file-uploader/file-uploader.module'; import { OrderInfoComponent } from './common/order-info/order-info'; import { ImageTableComponent } from './table-components/image-table'; @NgModule({ declarations: [ Loading @@ -50,6 +51,7 @@ import { OrderInfoComponent } from './common/order-info/order-info'; CarrierInfoComponent, PhoneComponent, UserPhoneComponent, ImageTableComponent, ], imports: [ CommonModule, Loading Loading @@ -80,6 +82,7 @@ import { OrderInfoComponent } from './common/order-info/order-info'; AccountComponent, LocationComponent, PhoneComponent, ImageTableComponent, ], }) export class ComponentsModule {} packages/merchant-tablet-ionic/src/components/table-components/image-table.ts 0 → 100644 +16 −0 Original line number Diff line number Diff line import { Component } from '@angular/core'; import { ViewCell } from 'ng2-smart-table'; @Component({ selector: 'image-table', styles: ['img { width: 64px; height: 64px}'], template: ` <span class="image-component"> <img *ngIf="rowData?.image" [src]="rowData?.image" /> </span> `, }) export class ImageTableComponent implements ViewCell { value: string | number; rowData: any; } Loading
packages/core/src/graphql/products/promotions/promotion.resolver.ts +18 −0 Original line number Diff line number Diff line Loading @@ -18,4 +18,22 @@ export class PromotionResolver { ) { return this._promotionService.createPromotion(createInput); } @Mutation() async removePromotion(_, { id }: { id: string }): Promise<void> { await this._promotionService.throwIfNotExists(id); return this._promotionService.remove(id); } @Mutation() async removePromotionsByIds(_, { ids }: { ids: string[] }): Promise<void> { const promotions = await this._promotionService.find({ _id: { $in: ids }, isDeleted: { $eq: false }, }); const promotionsIds = promotions.map((p) => p.id); return this._promotionService.removeMultipleByIds(promotionsIds); } }
packages/core/src/graphql/products/promotions/promotion.types.graphql +2 −0 Original line number Diff line number Diff line Loading @@ -41,4 +41,6 @@ type Query { type Mutation { createPromotion(createInput: PromotionCreateInput): Promotion removePromotion(id: String!): Void removePromotionsByIds(ids: [String!]!): Remove }
packages/core/src/services/products/PromotionService.ts +9 −0 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ import Promotion from '@modules/server.common/entities/Promotion'; import { createEverLogger } from '../../helpers/Log'; import Logger from 'bunyan'; import { IPromotionCreateObject } from '@ever-platform/common/src/interfaces/IPromotion'; import { first } from 'rxjs/operators'; @injectable() @routerName('promotion') Loading Loading @@ -40,4 +41,12 @@ export class PromotionService extends DBService<Promotion> implements IService { isDeleted: { $eq: false }, }); } async throwIfNotExists(promotionId: string) { const promotion = await this.get(promotionId).pipe(first()).toPromise(); if (!promotion || promotion.isDeleted) { throw Error(`Prmotion with id '${promotionId}' does not exist!`); } } }
packages/merchant-tablet-ionic/src/components/components.module.ts +3 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import { CustomerDeliveriesPopupPageModule } from 'pages/+customers/customer-del import { CustomerAddrPopupPageModule } from 'pages/+customers/customer-addr-popup/customer-addr-popup.module'; import { FileUploaderModule } from './file-uploader/file-uploader.module'; import { OrderInfoComponent } from './common/order-info/order-info'; import { ImageTableComponent } from './table-components/image-table'; @NgModule({ declarations: [ Loading @@ -50,6 +51,7 @@ import { OrderInfoComponent } from './common/order-info/order-info'; CarrierInfoComponent, PhoneComponent, UserPhoneComponent, ImageTableComponent, ], imports: [ CommonModule, Loading Loading @@ -80,6 +82,7 @@ import { OrderInfoComponent } from './common/order-info/order-info'; AccountComponent, LocationComponent, PhoneComponent, ImageTableComponent, ], }) export class ComponentsModule {}
packages/merchant-tablet-ionic/src/components/table-components/image-table.ts 0 → 100644 +16 −0 Original line number Diff line number Diff line import { Component } from '@angular/core'; import { ViewCell } from 'ng2-smart-table'; @Component({ selector: 'image-table', styles: ['img { width: 64px; height: 64px}'], template: ` <span class="image-component"> <img *ngIf="rowData?.image" [src]="rowData?.image" /> </span> `, }) export class ImageTableComponent implements ViewCell { value: string | number; rowData: any; }