From 1231f4c773834dd61df07e9d3bdfa06c68f3bbe0 Mon Sep 17 00:00:00 2001 From: andrey Date: Fri, 13 Jan 2017 16:33:21 +0300 Subject: [PATCH] Ft/fe 151/refactoring shops (#65) FE-151: refactoring shops --- .../analytic-selection.component.pug | 32 ++++----- src/app/backend/classes/category.class.ts | 3 - src/app/backend/classes/claim.class.ts | 3 - src/app/backend/classes/contract.class.ts | 2 + src/app/backend/classes/conversion.class.ts | 4 -- src/app/backend/classes/geodata.class.ts | 5 -- src/app/backend/classes/invoice.class.ts | 8 --- .../backend/classes/request-params.class.ts | 5 -- src/app/backend/classes/revenue.class.ts | 4 -- .../backend/classes/shop-creation.class.ts | 2 - src/app/backend/classes/shop-detail.class.ts | 3 - src/app/backend/classes/shop-item.class.ts | 2 - .../classes/shop-modification.class.ts | 2 - src/app/backend/services/contract.service.ts | 11 +++ .../claims/claims.component.pug | 23 ++++++ .../claims/claims.component.ts | 49 +++++++++++++ .../modification-detail.component.pug | 3 + .../modification-detail.component.ts | 14 ++++ .../shop-creation/shop-creation.component.pug | 12 ++++ .../shop-creation/shop-creation.component.ts | 25 +++++++ .../shop-modification.component.pug | 12 ++++ .../shop-modification.component.ts | 28 ++++++++ .../contracts/contracts.component.pug | 1 + .../contracts/contracts.component.ts | 11 +++ .../management.component.pug | 10 +++ .../management.component.ts | 6 ++ .../shops/shops.component.pug | 29 ++++++++ .../shops/shops.component.ts | 71 +++++++++++++++++++ .../management/management-routing.module.ts | 36 ++++++++++ src/app/management/management.module.ts | 34 +++++++++ .../components/sidebar/sidebar.component.pug | 4 ++ src/app/root/root.module.ts | 18 ++--- .../edit-shop/edit-shop.component.ts | 13 ++-- .../shop-management.component.pug | 2 +- 34 files changed, 413 insertions(+), 74 deletions(-) create mode 100644 src/app/management/components/management-container/claims/claims.component.pug create mode 100644 src/app/management/components/management-container/claims/claims.component.ts create mode 100644 src/app/management/components/management-container/claims/modification-detail/modification-detail.component.pug create mode 100644 src/app/management/components/management-container/claims/modification-detail/modification-detail.component.ts create mode 100644 src/app/management/components/management-container/claims/shop-creation/shop-creation.component.pug create mode 100644 src/app/management/components/management-container/claims/shop-creation/shop-creation.component.ts create mode 100644 src/app/management/components/management-container/claims/shop-modification/shop-modification.component.pug create mode 100644 src/app/management/components/management-container/claims/shop-modification/shop-modification.component.ts create mode 100644 src/app/management/components/management-container/contracts/contracts.component.pug create mode 100644 src/app/management/components/management-container/contracts/contracts.component.ts create mode 100644 src/app/management/components/management-container/management.component.pug create mode 100644 src/app/management/components/management-container/management.component.ts create mode 100644 src/app/management/components/management-container/shops/shops.component.pug create mode 100644 src/app/management/components/management-container/shops/shops.component.ts create mode 100644 src/app/management/management-routing.module.ts create mode 100644 src/app/management/management.module.ts diff --git a/src/app/analytics/components/analytic-selection/analytic-selection.component.pug b/src/app/analytics/components/analytic-selection/analytic-selection.component.pug index 9bcbc00..76c8072 100644 --- a/src/app/analytics/components/analytic-selection/analytic-selection.component.pug +++ b/src/app/analytics/components/analytic-selection/analytic-selection.component.pug @@ -1,17 +1,15 @@ -.row - .col-xs-12 - .x_panel.tile - .x_content - form.form-horizontal - .form-group - .col-xs-12.col-sm-1 - label.control-label Магазин - .col-xs-12.col-sm-6 - kof-select(*ngIf="selectItems.length", [(ngModel)]="selectedShopID", [items]="selectItems", (onChange)="navigateToShop()", [modelOptions]="{standalone: true}", name='shopId') - ul.nav.nav-tabs.bar_tabs(*ngIf="selectedShopID") - li.hand-cursor([routerLink]="['dashboard']", [routerLinkActive]="['active']") - a Статистика - li.hand-cursor([routerLink]="['finance']", [routerLinkActive]="['active']") - a Финансы - .tab-content - router-outlet +.x_panel.tile + .x_content + form.form-horizontal + .form-group + .col-xs-12.col-sm-1 + label.control-label Магазин + .col-xs-12.col-sm-6 + kof-select(*ngIf="selectItems.length", [(ngModel)]="selectedShopID", [items]="selectItems", (onChange)="navigateToShop()", [modelOptions]="{standalone: true}", name='shopId') + ul.nav.nav-tabs.bar_tabs(*ngIf="selectedShopID") + li.hand-cursor([routerLink]="['dashboard']", [routerLinkActive]="['active']") + a Статистика + li.hand-cursor([routerLink]="['finance']", [routerLinkActive]="['active']") + a Финансы + .tab-content + router-outlet diff --git a/src/app/backend/classes/category.class.ts b/src/app/backend/classes/category.class.ts index 49998ac..7f3736e 100644 --- a/src/app/backend/classes/category.class.ts +++ b/src/app/backend/classes/category.class.ts @@ -1,8 +1,5 @@ export class Category { - public categoryRef: number; - public description: string; - public name: string; } diff --git a/src/app/backend/classes/claim.class.ts b/src/app/backend/classes/claim.class.ts index cae37f3..e1e6143 100644 --- a/src/app/backend/classes/claim.class.ts +++ b/src/app/backend/classes/claim.class.ts @@ -1,9 +1,6 @@ export class Claim { - public id: number; - public changeset: any[]; - public status: { status: string; }; diff --git a/src/app/backend/classes/contract.class.ts b/src/app/backend/classes/contract.class.ts index 5aa0d11..194afa6 100644 --- a/src/app/backend/classes/contract.class.ts +++ b/src/app/backend/classes/contract.class.ts @@ -1,8 +1,10 @@ import { Contractor } from './contractor.class'; +import { PayoutAccount } from './payout-account.class'; export class Contract { public id: number; public contractor: Contractor; public concludedAt: string; public terminatedAt: string; + public payoutAccouts: PayoutAccount[]; } diff --git a/src/app/backend/classes/conversion.class.ts b/src/app/backend/classes/conversion.class.ts index dc05c9e..450f246 100644 --- a/src/app/backend/classes/conversion.class.ts +++ b/src/app/backend/classes/conversion.class.ts @@ -1,10 +1,6 @@ export class Conversion { - public conversion: number; - public offset: number; - public successfulCount: number; - public totalCount: number; } diff --git a/src/app/backend/classes/geodata.class.ts b/src/app/backend/classes/geodata.class.ts index 5c94763..e9679fa 100644 --- a/src/app/backend/classes/geodata.class.ts +++ b/src/app/backend/classes/geodata.class.ts @@ -1,12 +1,7 @@ export class GeoData { - public cityName: string; - public currency: string; - public offset: number; - public profit: number; - public revenue: number; } diff --git a/src/app/backend/classes/invoice.class.ts b/src/app/backend/classes/invoice.class.ts index ca53462..a6ca386 100644 --- a/src/app/backend/classes/invoice.class.ts +++ b/src/app/backend/classes/invoice.class.ts @@ -1,18 +1,10 @@ export class Invoice { - public id: number; - public shopID: number; - public amount: number; - public currency: string; - public description: string; - public dueDate: string; - public product: string; - public status: string; } diff --git a/src/app/backend/classes/request-params.class.ts b/src/app/backend/classes/request-params.class.ts index b8191ff..7026c2b 100644 --- a/src/app/backend/classes/request-params.class.ts +++ b/src/app/backend/classes/request-params.class.ts @@ -1,13 +1,8 @@ export class RequestParams { - public fromTime: string; - public toTime: string; - public splitUnit: string = 'minute'; - public splitSize: string = '1'; - public paymentMethod: string = 'bank_card'; constructor(fromTime: string, toTime: string, splitUnit?: string, splitSize?: string, paymentMethod?: string) { diff --git a/src/app/backend/classes/revenue.class.ts b/src/app/backend/classes/revenue.class.ts index 8270496..b2220c4 100644 --- a/src/app/backend/classes/revenue.class.ts +++ b/src/app/backend/classes/revenue.class.ts @@ -1,10 +1,6 @@ export class Revenue { - public currency: string; - public offset: number; - public profit: number; - public revenue: number; } diff --git a/src/app/backend/classes/shop-creation.class.ts b/src/app/backend/classes/shop-creation.class.ts index db848e7..a3d59b1 100644 --- a/src/app/backend/classes/shop-creation.class.ts +++ b/src/app/backend/classes/shop-creation.class.ts @@ -1,8 +1,6 @@ import { Shop } from './shop.class'; export class ShopCreation { - public modificationType: string; - public shop: Shop; } diff --git a/src/app/backend/classes/shop-detail.class.ts b/src/app/backend/classes/shop-detail.class.ts index f215f0a..62c33f7 100644 --- a/src/app/backend/classes/shop-detail.class.ts +++ b/src/app/backend/classes/shop-detail.class.ts @@ -1,8 +1,5 @@ export class ShopDetail { - public name: string; - public description: string; - public location: string; } diff --git a/src/app/backend/classes/shop-item.class.ts b/src/app/backend/classes/shop-item.class.ts index 0b3e476..089d5eb 100644 --- a/src/app/backend/classes/shop-item.class.ts +++ b/src/app/backend/classes/shop-item.class.ts @@ -1,7 +1,5 @@ export class ShopItem { - public value: string; - public label: string; constructor(value: string, label: string) { diff --git a/src/app/backend/classes/shop-modification.class.ts b/src/app/backend/classes/shop-modification.class.ts index e365b7c..fa2b063 100644 --- a/src/app/backend/classes/shop-modification.class.ts +++ b/src/app/backend/classes/shop-modification.class.ts @@ -1,7 +1,5 @@ export class ShopModification { - public modificationType: string; - public shopID: string; public details: { diff --git a/src/app/backend/services/contract.service.ts b/src/app/backend/services/contract.service.ts index e885a11..bb625b0 100644 --- a/src/app/backend/services/contract.service.ts +++ b/src/app/backend/services/contract.service.ts @@ -5,6 +5,7 @@ import 'rxjs/add/operator/toPromise'; import { ConfigService } from './config.service'; import { Contract } from '../classes/contract.class'; import { Contractor } from '../classes/contractor.class'; +import { PayoutAccount } from '../classes/payout-account.class'; @Injectable() export class ContractService { @@ -30,4 +31,14 @@ export class ContractService { .toPromise() .then(response => response.json()); } + + public createPayoutAccount(contractID: number, payoutAccount: PayoutAccount): Promise { + const params = { + currency: payoutAccount.currency, + tool: payoutAccount.tool + }; + return this.http.post(`${this.contractsUrl}/${contractID}/accounts`, params) + .toPromise() + .then(response => response.json()); + } } diff --git a/src/app/management/components/management-container/claims/claims.component.pug b/src/app/management/components/management-container/claims/claims.component.pug new file mode 100644 index 0000000..7068055 --- /dev/null +++ b/src/app/management/components/management-container/claims/claims.component.pug @@ -0,0 +1,23 @@ +.x_panel.tile(*ngIf="showClaimInfo") + .x_title + h4 Активная заявка + .x_content + .row(*ngFor="let set of changeset") + kof-shop-creation(*ngIf="set.modificationType == 'ShopCreation'", [changeset]="set") + kof-shop-modification(*ngIf="set.modificationType == 'ShopModificationUnit' && set.details.modificationType !== 'ShopAccountCreated'", [changeset]="set") + button.btn.btn-danger.pull-right(data-toggle="modal" data-target=".revoke-modal" data-backdrop="false") Отмена заявки + +.modal.fade.revoke-modal(tabindex="-1" role="dialog") + .modal-dialog.modal-sm + .modal-content + .modal-header + h5.modal-title Подтверждение отмены заявки + .modal-body Введите причину отмены + textarea.form-control(required, [(ngModel)]="revokeReason", #reason="ngModel") + .modal-footer + .btn-toolbar.pull-left + .btn-group.btn-group-sm + button.btn.btn-default(type="button", data-dismiss="modal") Назад + .btn-toolbar.pull-right + .btn-group.btn-group-sm + button.btn.btn-danger(*ngIf="reason.valid", type="button", data-dismiss="modal",(click)="revoke(reason)") Отменить заявку diff --git a/src/app/management/components/management-container/claims/claims.component.ts b/src/app/management/components/management-container/claims/claims.component.ts new file mode 100644 index 0000000..8b5d37c --- /dev/null +++ b/src/app/management/components/management-container/claims/claims.component.ts @@ -0,0 +1,49 @@ +import { Component, OnInit } from '@angular/core'; + +import { Claim } from 'koffing/backend/backend.module'; +import { ClaimService } from 'koffing/backend/backend.module'; + +@Component({ + selector: 'kof-claims', + templateUrl: 'claims.component.pug' +}) +export class ClaimsComponent implements OnInit { + + public claim: Claim; + public changeset: any[]; + public showClaimInfo: boolean = false; + public revokeReason: string; + + private currentClaimStatus: string; + + constructor(private claimService: ClaimService) { } + + public revoke(reasonControl: any) { + if (!reasonControl.valid) { + return; + } + + let revokeDetails = { + reason: this.revokeReason + }; + + this.claimService.revokeClaim(this.claim.id, revokeDetails).then(() => { + this.showClaimInfo = false; + }); + } + + public ngOnInit() { + this.currentClaimStatus = 'pending'; + + this.getClaim(); + } + + private getClaim() { + this.claimService.getClaim({status: this.currentClaimStatus}).then((aClaim: Claim) => { + this.claim = aClaim; + this.changeset = aClaim.changeset; + this.showClaimInfo = true; + } + ); + } +} diff --git a/src/app/management/components/management-container/claims/modification-detail/modification-detail.component.pug b/src/app/management/components/management-container/claims/modification-detail/modification-detail.component.pug new file mode 100644 index 0000000..2213d11 --- /dev/null +++ b/src/app/management/components/management-container/claims/modification-detail/modification-detail.component.pug @@ -0,0 +1,3 @@ +dl(*ngIf="value") + dt {{displayName}} + dd {{value}} \ No newline at end of file diff --git a/src/app/management/components/management-container/claims/modification-detail/modification-detail.component.ts b/src/app/management/components/management-container/claims/modification-detail/modification-detail.component.ts new file mode 100644 index 0000000..7184f08 --- /dev/null +++ b/src/app/management/components/management-container/claims/modification-detail/modification-detail.component.ts @@ -0,0 +1,14 @@ +import { Component, Input } from '@angular/core'; + +@Component({ + selector: 'kof-modification-detail', + templateUrl: 'modification-detail.component.pug' +}) +export class ModificationDetailComponent { + + @Input() + public displayName: string; + + @Input() + public value: string; +} diff --git a/src/app/management/components/management-container/claims/shop-creation/shop-creation.component.pug b/src/app/management/components/management-container/claims/shop-creation/shop-creation.component.pug new file mode 100644 index 0000000..924261f --- /dev/null +++ b/src/app/management/components/management-container/claims/shop-creation/shop-creation.component.pug @@ -0,0 +1,12 @@ +.panel.panel-default + .panel-heading((click)="show()") + a Создание магазина: {{shop.shopDetails.name}} + i.fa.pull-right.custom-chevron([ngClass]="{'fa-chevron-down': showPanel, 'fa-chevron-right': !showPanel}") + .panel-body(*ngIf="showPanel") + div(*ngIf="shop.shopDetails") + kof-modification-detail([displayName]="'Название магазина'", [value]="shop.shopDetails.name") + kof-modification-detail([displayName]="'Описание'", [value]="shop.shopDetails.description") + kof-modification-detail([displayName]="'Месторасположение'", [value]="shop.shopDetails.location") + div(*ngIf="shop.contractor") + kof-modification-detail([displayName]="'Наименование организации'", [value]="shop.contractor.registeredName") + kof-modification-detail([displayName]="'Тип юридического лица'", [value]="shop.contractor.legalEntity") diff --git a/src/app/management/components/management-container/claims/shop-creation/shop-creation.component.ts b/src/app/management/components/management-container/claims/shop-creation/shop-creation.component.ts new file mode 100644 index 0000000..98a08ad --- /dev/null +++ b/src/app/management/components/management-container/claims/shop-creation/shop-creation.component.ts @@ -0,0 +1,25 @@ +import { Component, Input, OnInit } from '@angular/core'; + +import { ShopCreation } from 'koffing/backend/backend.module'; + +@Component({ + selector: 'kof-shop-creation', + templateUrl: 'shop-creation.component.pug' +}) +export class ShopCreationComponent implements OnInit { + + @Input() + public changeset: ShopCreation; + + public showPanel: boolean = false; + + public shop: any; + + public ngOnInit() { + this.shop = this.changeset.shop; + } + + public show() { + this.showPanel = !this.showPanel; + } +} diff --git a/src/app/management/components/management-container/claims/shop-modification/shop-modification.component.pug b/src/app/management/components/management-container/claims/shop-modification/shop-modification.component.pug new file mode 100644 index 0000000..9c9deb3 --- /dev/null +++ b/src/app/management/components/management-container/claims/shop-modification/shop-modification.component.pug @@ -0,0 +1,12 @@ +.panel.panel-default + .panel-heading((click)="show()") + a Изменение магазина + i.fa.pull-right.custom-chevron([ngClass]="{'fa-chevron-down': showPanel, 'fa-chevron-right': !showPanel}") + .panel-body(*ngIf="showPanel") + div(*ngIf="details.shopDetails") + kof-modification-detail([displayName]="'Название магазина'", [value]="details.shopDetails.name") + kof-modification-detail([displayName]="'Описание'", [value]="details.shopDetails.description") + kof-modification-detail([displayName]="'Месторасположение'", [value]="details.shopDetails.location") + div(*ngIf="details.contractor") + kof-modification-detail([displayName]="'Наименование организации'", [value]="details.contractor.registeredName") + kof-modification-detail([displayName]="'Тип юридического лица'", [value]="details.contractor.legalEntity") \ No newline at end of file diff --git a/src/app/management/components/management-container/claims/shop-modification/shop-modification.component.ts b/src/app/management/components/management-container/claims/shop-modification/shop-modification.component.ts new file mode 100644 index 0000000..95aabf3 --- /dev/null +++ b/src/app/management/components/management-container/claims/shop-modification/shop-modification.component.ts @@ -0,0 +1,28 @@ +import { Component, Input, OnInit } from '@angular/core'; + +import { ShopModification } from 'koffing/backend/backend.module'; + +@Component({ + selector: 'kof-shop-modification', + templateUrl: 'shop-modification.component.pug' +}) +export class ShopModificationComponent implements OnInit { + + @Input() + public changeset: ShopModification; + + public showPanel: boolean = false; + + public isModification: boolean = false; + + public details: any; + + public ngOnInit() { + this.details = this.changeset.details.details; + this.isModification = this.changeset.details.modificationType === 'ShopModification'; + } + + public show() { + this.showPanel = !this.showPanel; + } +} diff --git a/src/app/management/components/management-container/contracts/contracts.component.pug b/src/app/management/components/management-container/contracts/contracts.component.pug new file mode 100644 index 0000000..82c27c2 --- /dev/null +++ b/src/app/management/components/management-container/contracts/contracts.component.pug @@ -0,0 +1 @@ +div contracts diff --git a/src/app/management/components/management-container/contracts/contracts.component.ts b/src/app/management/components/management-container/contracts/contracts.component.ts new file mode 100644 index 0000000..82b38a6 --- /dev/null +++ b/src/app/management/components/management-container/contracts/contracts.component.ts @@ -0,0 +1,11 @@ +import { Component, OnInit } from '@angular/core'; + +@Component({ + templateUrl: 'contracts.component.pug' +}) +export class ContractsComponent implements OnInit { + + public ngOnInit() { + console.log('ContractsComponent'); + } +} diff --git a/src/app/management/components/management-container/management.component.pug b/src/app/management/components/management-container/management.component.pug new file mode 100644 index 0000000..5f134e1 --- /dev/null +++ b/src/app/management/components/management-container/management.component.pug @@ -0,0 +1,10 @@ +kof-claims +.x_panel.tile + .x_content + ul.nav.nav-tabs.bar_tabs + li.hand-cursor([routerLink]="['shops']", [routerLinkActive]="['active']") + a Магазины + li.hand-cursor([routerLink]="['contracts']", [routerLinkActive]="['active']") + a Контракты + .tab-content + router-outlet diff --git a/src/app/management/components/management-container/management.component.ts b/src/app/management/components/management-container/management.component.ts new file mode 100644 index 0000000..c7ec0e0 --- /dev/null +++ b/src/app/management/components/management-container/management.component.ts @@ -0,0 +1,6 @@ +import { Component } from '@angular/core'; + +@Component({ + templateUrl: 'management.component.pug' +}) +export class ManagementComponent {} diff --git a/src/app/management/components/management-container/shops/shops.component.pug b/src/app/management/components/management-container/shops/shops.component.pug new file mode 100644 index 0000000..be055e4 --- /dev/null +++ b/src/app/management/components/management-container/shops/shops.component.pug @@ -0,0 +1,29 @@ +.x_title + h4 Магазины +.x_content + kof-loading([isLoading]="isLoading") + table(*ngIf="shops.length").table.table-hover.table-striped + thead + tr + th ID магазина + th Название магазина + th.hidden-xs Описание + th.hidden-xs Месторасположение + th Категория + th + tbody + tr(*ngFor="let shop of shops",[ngClass]="{'success': shop.isSuspended, 'danger': shop.isBlocked}") + td {{shop.shopID}} + td {{shop.shopDetails.name}} + td.hidden-xs {{shop.shopDetails.description}} + td.hidden-xs {{shop.shopDetails.location}} + td {{getCategory(shop.categoryRef).name}} + td(*ngIf="shop.isSuspended && !shop.isBlocked") + button.btn.btn-success.btn-xs.pull-right((click)="activateShop(shop)") Активировать + td(*ngIf="!shop.isSuspended && !shop.isBlocked") + a.btn.btn-default.btn-xs.pull-right([routerLink]="['edit', shop.shopID]") Изменить данные + td(*ngIf="shop.isBlocked") + span.pull-right Заблокирован + span(*ngIf="!shops.length") Список магазинов пуст + a.btn.btn-primary.pull-right([routerLink]="['/management/contracts']") Добавить новый магазин + //a.btn.btn-primary.pull-right([routerLink]="['add']") Добавить новый магазин \ No newline at end of file diff --git a/src/app/management/components/management-container/shops/shops.component.ts b/src/app/management/components/management-container/shops/shops.component.ts new file mode 100644 index 0000000..2f96227 --- /dev/null +++ b/src/app/management/components/management-container/shops/shops.component.ts @@ -0,0 +1,71 @@ +import { Component, OnInit } from '@angular/core'; +import * as _ from 'lodash'; + +import { Category } from 'koffing/backend/backend.module'; +import { CategoryService } from 'koffing/backend/backend.module'; +import { Shop } from 'koffing/backend/backend.module'; +import { ShopService } from 'koffing/backend/backend.module'; + +@Component({ + templateUrl: 'shops.component.pug' +}) +export class ShopsComponent implements OnInit { + + public shops: Shop[] = []; + public categories: Category[] = []; + + private isLoading: boolean; + + constructor( + private shopService: ShopService, + private categoryService: CategoryService + ) {} + + public activateShop(shop: any) { + this.isLoading = true; + + this.shopService.activateShop(shop.shopID).then(() => { + this.loadShops().then(() => { + this.isLoading = false; + }); + }); + } + + public loadShops() { + return new Promise((resolve) => { + this.shopService.getShops().then(aShops => { + this.shops = aShops; + + resolve(); + }); + }); + } + + public loadCategories() { + return new Promise((resolve) => { + this.categoryService.getCategories().then(aCategories => { + this.categories = aCategories; + + resolve(); + }); + }); + } + + public getCategory(categoryRef: number): Category { + let result = new Category(); + if (this.categories.length > 0) { + result = _.find(this.categories, (category: Category) => category.categoryRef === categoryRef); + } + return result; + } + + public ngOnInit() { + this.isLoading = true; + Promise.all([ + this.loadShops(), + this.loadCategories() + ]).then(() => { + this.isLoading = false; + }); + } +} diff --git a/src/app/management/management-routing.module.ts b/src/app/management/management-routing.module.ts new file mode 100644 index 0000000..91bd315 --- /dev/null +++ b/src/app/management/management-routing.module.ts @@ -0,0 +1,36 @@ +import { NgModule } from '@angular/core'; +import { RouterModule } from '@angular/router'; + +import { ManagementComponent } from './components/management-container/management.component'; +import { ShopsComponent } from './components/management-container/shops/shops.component'; +import { ContractsComponent } from './components/management-container/contracts/contracts.component'; + +@NgModule({ + imports: [ + RouterModule.forChild([ + { + path: 'management', + component: ManagementComponent, + children: [ + { + path: '', + redirectTo: '/management/shops', + pathMatch: 'full' + }, + { + path: 'shops', + component: ShopsComponent + }, + { + path: 'contracts', + component: ContractsComponent + } + ] + } + ]) + ], + exports: [ + RouterModule + ] +}) +export class ManagementRoutingModule {} diff --git a/src/app/management/management.module.ts b/src/app/management/management.module.ts new file mode 100644 index 0000000..b4839b4 --- /dev/null +++ b/src/app/management/management.module.ts @@ -0,0 +1,34 @@ +import { NgModule } from '@angular/core'; +import { BrowserModule } from '@angular/platform-browser'; +import { FormsModule } from '@angular/forms'; + +import { ManagementRoutingModule } from './management-routing.module'; +import { CommonModule } from 'koffing/common/common.module'; +import { BackendModule } from 'koffing/backend/backend.module'; +import { ManagementComponent } from './components/management-container/management.component'; +import { ClaimsComponent } from './components/management-container/claims/claims.component'; +import { ModificationDetailComponent } from './components/management-container/claims/modification-detail/modification-detail.component'; +import { ShopModificationComponent } from './components/management-container/claims/shop-modification/shop-modification.component'; +import { ShopCreationComponent } from './components/management-container/claims/shop-creation/shop-creation.component'; +import { ShopsComponent } from './components/management-container/shops/shops.component'; +import { ContractsComponent } from './components/management-container/contracts/contracts.component'; + +@NgModule({ + imports: [ + ManagementRoutingModule, + BrowserModule, + FormsModule, + CommonModule, + BackendModule + ], + declarations: [ + ManagementComponent, + ClaimsComponent, + ShopCreationComponent, + ShopModificationComponent, + ModificationDetailComponent, + ShopsComponent, + ContractsComponent + ] +}) +export class ManagementModule {} diff --git a/src/app/root/components/sidebar/sidebar.component.pug b/src/app/root/components/sidebar/sidebar.component.pug index b3cc52a..c40098f 100644 --- a/src/app/root/components/sidebar/sidebar.component.pug +++ b/src/app/root/components/sidebar/sidebar.component.pug @@ -15,6 +15,10 @@ a(routerLink="/shops") i.fa.fa-shopping-cart | Мои магазины + li([routerLinkActive]="['active']") + a(routerLink="/management") + i.fa.fa-user + | Мои
данные li([routerLinkActive]="['active']") a(routerLink="/tokenization") i.fa.fa-key diff --git a/src/app/root/root.module.ts b/src/app/root/root.module.ts index 311aacf..f925f80 100644 --- a/src/app/root/root.module.ts +++ b/src/app/root/root.module.ts @@ -2,25 +2,27 @@ import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { GrowlModule } from 'primeng/primeng'; -import { SidebarComponent } from './components/sidebar/sidebar.component'; -import { TopPanelComponent } from './components/top-panel/top-panel.component'; import { RootRoutingModule } from './root-routing.module'; -import { ContainerComponent } from './components/container/container.component'; +import { BroadcasterModule } from '../broadcaster/broadcaster.module'; import { TokenizationModule } from '../tokenization/tokenization.module'; import { AnalyticsModule } from '../analytics/analytics.module'; import { ShopsModule } from '../shops/shops.module'; -import { BroadcasterModule } from '../broadcaster/broadcaster.module'; +import { ManagementModule } from '../management/management.module'; +import { SidebarComponent } from './components/sidebar/sidebar.component'; +import { TopPanelComponent } from './components/top-panel/top-panel.component'; +import { ContainerComponent } from './components/container/container.component'; import { HttpErrorHandleComponent } from './components/http-error-handle/http-error-handle.component'; @NgModule({ imports: [ + BrowserModule, + GrowlModule, RootRoutingModule, + BroadcasterModule, + TokenizationModule, AnalyticsModule, ShopsModule, - TokenizationModule, - BrowserModule, - BroadcasterModule, - GrowlModule + ManagementModule ], declarations: [ ContainerComponent, diff --git a/src/app/shops/components/shop-management/edit-shop/edit-shop.component.ts b/src/app/shops/components/shop-management/edit-shop/edit-shop.component.ts index f4de881..6240a1b 100644 --- a/src/app/shops/components/shop-management/edit-shop/edit-shop.component.ts +++ b/src/app/shops/components/shop-management/edit-shop/edit-shop.component.ts @@ -6,6 +6,7 @@ import { CategoryService } from 'koffing/backend/backend.module'; import { ShopService } from 'koffing/backend/backend.module'; import { SelectItem } from 'koffing/common/common.module'; import { ShopArgs } from 'koffing/shops/shops.module'; +import { Shop } from 'koffing/backend/classes/shop.class'; @Component({ selector: 'kof-edit-shop', @@ -14,7 +15,7 @@ import { ShopArgs } from 'koffing/shops/shops.module'; export class EditShopComponent implements OnInit { public categories: SelectItem[] = []; - public currentShopId: string; + public currentShopId: number = Number(this.route.snapshot.params['shopID']); public args: ShopArgs = { shopDetails: {}, contractor: {}, @@ -31,10 +32,10 @@ export class EditShopComponent implements OnInit { public loadShops() { return new Promise((resolve) => { this.shopService.getShops().then((shops: any) => { - const found: any = _.find(shops, (shop: any) => shop.shopID === this.currentShopId); - this.args.shopDetails = found.shopDetails ? found.shopDetails : {}; - this.args.contractor = found.contractor ? found.contractor : {}; - this.args.categoryRef = found.categoryRef; + const currentShop: Shop = _.find(shops, (shop: any) => shop.shopID === this.currentShopId); + this.args.shopDetails = currentShop.shopDetails ? currentShop.shopDetails : {}; + // this.args.contractor = currentShop.contractor ? currentShop.contractor : {}; + this.args.categoryRef = currentShop.categoryRef; resolve(); }); @@ -72,8 +73,6 @@ export class EditShopComponent implements OnInit { } public ngOnInit() { - this.currentShopId = this.route.snapshot.params['shopID']; - this.isLoading = true; Promise.all([ this.loadShops(), diff --git a/src/app/shops/components/shop-management/shop-management.component.pug b/src/app/shops/components/shop-management/shop-management.component.pug index a31bc0d..ac8010d 100644 --- a/src/app/shops/components/shop-management/shop-management.component.pug +++ b/src/app/shops/components/shop-management/shop-management.component.pug @@ -27,4 +27,4 @@ kof-claims td(*ngIf="shop.isBlocked") span.pull-right Заблокирован span(*ngIf="!shops.length") Список магазинов пуст - a.btn.btn-primary.pull-right(routerLink="/shops/add") Добавить новый магазин \ No newline at end of file + a.btn.btn-primary.pull-right([routerLink]="['add']") Добавить новый магазин \ No newline at end of file