From b5af95c56e5085af14a7355869331380f440fd5a Mon Sep 17 00:00:00 2001 From: Ildar Galeev Date: Fri, 23 Sep 2016 23:15:31 +0300 Subject: [PATCH 01/13] FE-38: Added analytics component, party mock --- app/bootstrap.js | 26 ++++++++------- .../analytics/analytics.component.js | 28 ++++++++++++++++ app/components/analytics/analytics.module.js | 1 + .../analytics/analytics.template.pug | 32 +++++++++++++++++++ .../shop-select/select2.directive.js | 10 ++++++ .../shop-select/shop-select.component.js | 11 +++++++ .../statistic/statistic.component.js | 8 +++++ .../analytics/statistic/statistic.module.js | 1 + .../statistic/statistic.template.pug | 1 + app/components/app/app-config.js | 7 +++- app/components/app/app.component.js | 4 ++- app/components/app/app.module.js | 1 + app/components/finance/finance.component.js | 4 +-- app/components/sidebar/sidebar.pug | 4 +++ app/components/top-panel/top-panel.js | 11 ++++--- app/components/top-panel/top-panel.pug | 2 +- app/shared/resources/parties.js | 3 ++ app/shared/resources/resources.module.js | 2 +- capi-mock/capi.js | 15 +++++---- capi-mock/me.js | 30 +++++++++++++++++ 20 files changed, 173 insertions(+), 28 deletions(-) create mode 100644 app/components/analytics/analytics.component.js create mode 100644 app/components/analytics/analytics.module.js create mode 100644 app/components/analytics/analytics.template.pug create mode 100644 app/components/analytics/shop-select/select2.directive.js create mode 100644 app/components/analytics/shop-select/shop-select.component.js create mode 100644 app/components/analytics/statistic/statistic.component.js create mode 100644 app/components/analytics/statistic/statistic.module.js create mode 100644 app/components/analytics/statistic/statistic.template.pug create mode 100644 app/shared/resources/parties.js create mode 100644 capi-mock/me.js diff --git a/app/bootstrap.js b/app/bootstrap.js index 475d1f6..7619b58 100644 --- a/app/bootstrap.js +++ b/app/bootstrap.js @@ -1,15 +1,17 @@ angular.element(document).ready(function () { - var keycloakAuth = new Keycloak('keycloak.json'); + // var keycloakAuth = new Keycloak('keycloak.json'); - keycloakAuth.init({onLoad: 'login-required'}).success(function () { - app.factory('Auth', function () { - return { - profileName: keycloakAuth.tokenParsed.name, - logout: keycloakAuth.logout, - token: keycloakAuth.token, - updateToken: keycloakAuth.updateToken - }; - }); - angular.bootstrap(document, ['app']); - }); + // keycloakAuth.init({onLoad: 'login-required'}).success(function () { + // app.factory('Auth', function () { + // return { + // profileName: keycloakAuth.tokenParsed.name, + // logout: keycloakAuth.logout, + // token: keycloakAuth.token, + // updateToken: keycloakAuth.updateToken + // }; + // }); + // angular.bootstrap(document, ['app']); + // }); + + angular.bootstrap(document, ['app']); }); diff --git a/app/components/analytics/analytics.component.js b/app/components/analytics/analytics.component.js new file mode 100644 index 0000000..d958584 --- /dev/null +++ b/app/components/analytics/analytics.component.js @@ -0,0 +1,28 @@ +dashboard.component('analytics', { + templateUrl: 'components/analytics/analytics.template.html', + $routeConfig: [ + {path: '/:shopId/statistic', name: 'Statistic', component: 'statistic'} + ], + bindings: { + $router: '<' + }, + controller: function (Parties) { + this.$routerOnActivate = () => { + Parties.get(party => { + this.party = party; + this.shopsDetails = _.map(this.party.shops, shop => ({ + name: shop.shopDetails.name, + key: shop.shopID + })); + }); + }; + + this.onShopSelect = () => { + console.log(this.selectedShopId); + }; + + this.showStatistic = () => { + this.$router.navigate(['Statistic', {shopId: this.selectedShopId}]); + } + } +}); diff --git a/app/components/analytics/analytics.module.js b/app/components/analytics/analytics.module.js new file mode 100644 index 0000000..fbf9176 --- /dev/null +++ b/app/components/analytics/analytics.module.js @@ -0,0 +1 @@ +const analytics = angular.module('analytics', ['statistic']); diff --git a/app/components/analytics/analytics.template.pug b/app/components/analytics/analytics.template.pug new file mode 100644 index 0000000..f7c8ce3 --- /dev/null +++ b/app/components/analytics/analytics.template.pug @@ -0,0 +1,32 @@ +.row + .col-md-12 + .x_panel.tile + .x_title + h4 Аналитика + .x_content + .row + .col-md-5 + form.form-horizontal + .form-group + label.control-label.col-md-2 Магазин: + .col-md-8 + shop-select(options="$ctrl.shopsDetails" selected="$ctrl.selectedShopId" on-select="$ctrl.onShopSelect()") + .col-md-3 + button.btn.btn-default(ng-click="$ctrl.showStatistic()") Показать статистику + +ng-outlet +//.row + //.col-md-12 + // .x_panel.tile + // .x_content + //div(role="tabpanel" data-example-id="togglable-tabs") + // ul#myTab.nav.nav-tabs.bar_tabs(role="tablist") + // li.active(role="presentation") + // a#statistic-tab(href="#tab_content_statistic" role="tab" data-toggle="tab" aria-expanded="true") Статистика + // li(role="presentation") + // a#finance-tab(href="#tab_content_finance" role="tab" data-toggle="tab" aria-expanded="false") Финансы + // div#myTabContent.tab-content + // div#tab_content_statistic.tab-pane.fade.active.in(role="tabpanel" aria-labelledby="finance-tab") + // p Хуй + // div#tab_content_finance.tab-pane.fade.in(role="tabpanel" aria-labelledby="profile-tab") + // p Хуй2 \ No newline at end of file diff --git a/app/components/analytics/shop-select/select2.directive.js b/app/components/analytics/shop-select/select2.directive.js new file mode 100644 index 0000000..21f3a66 --- /dev/null +++ b/app/components/analytics/shop-select/select2.directive.js @@ -0,0 +1,10 @@ +customSelect.directive('select2', function () { + return { + restrict: 'A', + link: function (scope, element) { + element.select2({ + placeholder: '' + }); + } + } +}); diff --git a/app/components/analytics/shop-select/shop-select.component.js b/app/components/analytics/shop-select/shop-select.component.js new file mode 100644 index 0000000..490b55f --- /dev/null +++ b/app/components/analytics/shop-select/shop-select.component.js @@ -0,0 +1,11 @@ +analytics.component('shopSelect', { + template: ``, + bindings: { + options: '=', + selected: '=', + onSelect: '&' + } +}); \ No newline at end of file diff --git a/app/components/analytics/statistic/statistic.component.js b/app/components/analytics/statistic/statistic.component.js new file mode 100644 index 0000000..c459c72 --- /dev/null +++ b/app/components/analytics/statistic/statistic.component.js @@ -0,0 +1,8 @@ +statistic.component('statistic', { + templateUrl: 'components/analytics/statistic/statistic.template.html', + controller: function () { + this.$routerOnActivate = (next) => { + console.log(next); + } + } +}); diff --git a/app/components/analytics/statistic/statistic.module.js b/app/components/analytics/statistic/statistic.module.js new file mode 100644 index 0000000..8e5d684 --- /dev/null +++ b/app/components/analytics/statistic/statistic.module.js @@ -0,0 +1 @@ +const statistic = angular.module('statistic', []); diff --git a/app/components/analytics/statistic/statistic.template.pug b/app/components/analytics/statistic/statistic.template.pug new file mode 100644 index 0000000..fab18d5 --- /dev/null +++ b/app/components/analytics/statistic/statistic.template.pug @@ -0,0 +1 @@ +div Test \ No newline at end of file diff --git a/app/components/app/app-config.js b/app/components/app/app-config.js index 4f94ca9..90e8b76 100644 --- a/app/components/app/app-config.js +++ b/app/components/app/app-config.js @@ -1,4 +1,9 @@ +// app.constant('appConfig', { +// capiUrl: 'http://macroserver1.msk1.rbkmoney.net:8080/v1/', +// shopID: 'THRIFT-SHOP' +// }); + app.constant('appConfig', { - capiUrl: 'http://macroserver1.msk1.rbkmoney.net:8080/v1/', + capiUrl: 'http://localhost:9000/v1/', shopID: 'THRIFT-SHOP' }); diff --git a/app/components/app/app.component.js b/app/components/app/app.component.js index 00936ce..5fecfbd 100644 --- a/app/components/app/app.component.js +++ b/app/components/app/app.component.js @@ -1,7 +1,9 @@ app.component('app', { templateUrl: 'components/app/app.html', $routeConfig: [ - {path: '/dashboard', name: 'Dashboard', component: 'dashboard', useAsDefault: true}, + {path: '/analytics', name: 'Analytics', component: 'analytics', useAsDefault: true}, + {path: '/analytics/...', component: 'analytics'}, + {path: '/dashboard', name: 'Dashboard', component: 'dashboard'}, {path: '/finance', name: 'Finance', component: 'finance'} ] }); diff --git a/app/components/app/app.module.js b/app/components/app/app.module.js index 410c48d..6106a33 100644 --- a/app/components/app/app.module.js +++ b/app/components/app/app.module.js @@ -1,5 +1,6 @@ const app = angular.module('app', [ 'ngComponentRouter', + 'analytics', 'dashboard', 'finance', 'sidebar', diff --git a/app/components/finance/finance.component.js b/app/components/finance/finance.component.js index 3ff0269..bf1fc51 100644 --- a/app/components/finance/finance.component.js +++ b/app/components/finance/finance.component.js @@ -10,10 +10,10 @@ finance.component('finance', { this.isLoading = false; this.isSearched = false; - this.search = offset => { + this.search = (offset = 0) => { this.isLoading = true; this.isSearched = true; - this.searchParams.offset = offset ? offset : 0; + this.searchParams.offset = offset; if (_.isEmpty(this.searchParams.invoiceID)) { this.searchParams.invoiceID = null; } diff --git a/app/components/sidebar/sidebar.pug b/app/components/sidebar/sidebar.pug index 99deb99..acd8a72 100644 --- a/app/components/sidebar/sidebar.pug +++ b/app/components/sidebar/sidebar.pug @@ -15,3 +15,7 @@ a(ng-link="[\'Finance\']") i.fa.fa-bar-chart-o | Финансы + li(ng-class="{active: $ctrl.isActive('/analytics')}") + a(ng-link="['\Analytics\']") + i.fa.fa-bar-chart-o + | Аналитика diff --git a/app/components/top-panel/top-panel.js b/app/components/top-panel/top-panel.js index 158c74b..32f7fbc 100644 --- a/app/components/top-panel/top-panel.js +++ b/app/components/top-panel/top-panel.js @@ -2,9 +2,12 @@ const topPanel = angular.module('topPanel', []); topPanel.component('topPanel', { templateUrl: 'components/top-panel/top-panel.html', - controller: function (Auth) { - this.profileName = Auth.profileName; - this.logout = Auth.logout; - this.token = Auth.token; + controller: function () { + // this.profileName = Auth.profileName; + // this.logout = Auth.logout; + // this.token = Auth.token; + this.profileName = 'test name'; + this.logout = () => {}; + this.token = 'test token'; } }); diff --git a/app/components/top-panel/top-panel.pug b/app/components/top-panel/top-panel.pug index d3e6fa6..6a70b1f 100644 --- a/app/components/top-panel/top-panel.pug +++ b/app/components/top-panel/top-panel.pug @@ -6,7 +6,7 @@ a.user-profile.dropdown-toggle(data-toggle="dropdown", aria-expanded="false") img(src="img.png" alt="") | {{$ctrl.profileName}}  - span.fa.fa-angle-down() + span.fa.fa-angle-down ul.dropdown-menu.dropdown-usermenu.pull-right li(data-toggle="modal" data-target=".bs-example-modal-lg") a(href="") diff --git a/app/shared/resources/parties.js b/app/shared/resources/parties.js new file mode 100644 index 0000000..e5f0fb3 --- /dev/null +++ b/app/shared/resources/parties.js @@ -0,0 +1,3 @@ +resources.factory('Parties', function ($resource, appConfig) { + return $resource(appConfig.capiUrl + 'processing/me'); +}); diff --git a/app/shared/resources/resources.module.js b/app/shared/resources/resources.module.js index 1ef7184..9b4dc8e 100644 --- a/app/shared/resources/resources.module.js +++ b/app/shared/resources/resources.module.js @@ -1,6 +1,6 @@ const resources = angular.module('resources', ['ngResource']); resources.config(function ($httpProvider) { - $httpProvider.interceptors.push('authInterceptor'); + // $httpProvider.interceptors.push('authInterceptor'); $httpProvider.interceptors.push('dateInterceptor'); }); diff --git a/capi-mock/capi.js b/capi-mock/capi.js index e51d978..be967b3 100644 --- a/capi-mock/capi.js +++ b/capi-mock/capi.js @@ -9,6 +9,7 @@ const revenue = require('./revenue'); const conversion = require('./conversion'); const geo = require('./geo'); const rate = require('./rate'); +const me = require('./me'); app.use((req, res, next) => { res.header('Access-Control-Allow-Origin', '*'); @@ -16,16 +17,18 @@ app.use((req, res, next) => { next(); }); -router.route('/invoices').get((req, res) => setTimeout(() => res.json(invoices), 300)); +router.route('/processing/me').get((req, res) => res.json(me)); -router.route('/payments/stats/revenue').get((req, res) => setTimeout(() => res.json(revenue), 0)); +router.route('/analytics/shops/THRIFT-SHOP/invoices').get((req, res) => setTimeout(() => res.json(invoices), 300)); -router.route('/payments/stats/conversion').get((req, res) => setTimeout(() => res.json(conversion), 0)); +router.route('/analytics/shops/THRIFT-SHOP/payments/stats/revenue').get((req, res) => setTimeout(() => res.json(revenue), 0)); -router.route('/payments/stats/geo').get((req, res) => setTimeout(() => res.json(geo), 0)); +router.route('/analytics/shops/THRIFT-SHOP/payments/stats/conversion').get((req, res) => setTimeout(() => res.json(conversion), 0)); -router.route('/customers/stats/rate').get((req, res) => setTimeout(() => res.json(rate), 0)); +router.route('/analytics/shops/THRIFT-SHOP/payments/stats/geo').get((req, res) => setTimeout(() => res.json(geo), 0)); -app.use('/v1/analytics/shops/THRIFT-SHOP', router); +router.route('/analytics/shops/THRIFT-SHOP/customers/stats/rate').get((req, res) => setTimeout(() => res.json(rate), 0)); + +app.use('/v1', router); app.listen(9000); diff --git a/capi-mock/me.js b/capi-mock/me.js new file mode 100644 index 0000000..6568020 --- /dev/null +++ b/capi-mock/me.js @@ -0,0 +1,30 @@ +var shop = { + shopID: 'THRIFT-SHOP', + isBlocked: false, + isSuspended: false, + categoryRef: 1, + shopDetails: { + name: 'Лееееех, да ответь же ты', + description: 'Магазин пропавшего Лехи', + location: 'Стена' + }, + contractor: { + registeredName: 'Леха Свотин', + legalEntity: 'Хер знает что за поле' + }, + contract: { + number: '2341', + systemContractorRef: '34564', + concludedAt: 'Наверно дата и время', + validSince: 'Какая то дата и время', + validUntil: 'Какая то дата и время', + terminatedAt: 'Наверно дата и время' + } +}; + +module.exports = { + partyID: '1', + isBlocked: false, + isSuspended: false, + shops: [shop] +}; From 6c9d16a574fc34753d36b2ec7f11b2473b062068 Mon Sep 17 00:00:00 2001 From: Ildar Galeev Date: Sat, 24 Sep 2016 16:53:54 +0300 Subject: [PATCH 02/13] FE-38: Moved dashboard, finance components to analytics component --- .../analytics/analytics.component.js | 12 ++++++--- app/components/analytics/analytics.module.js | 2 +- .../analytics/analytics.template.pug | 27 ++++++++----------- .../chart-data-conversion.service.js | 0 .../dashboard/conversion/conversion.js | 0 .../dashboard/dashboard.component.js | 6 ++++- .../dashboard/dashboard.module.js | 0 .../dashboard/dashboard.template.pug} | 0 .../dashboard/geolocation/geolocation.js | 0 .../dashboard/info-panel/info-panel.js | 2 +- .../info-panel/info-panel.template.pug} | 0 .../dashboard/revenue/revenue.js | 0 .../finance/finance.component.js | 2 +- .../{ => analytics}/finance/finance.module.js | 0 .../{ => analytics}/finance/finance.pug | 2 +- .../finance/paginate/paginate.component.js | 2 +- .../finance/paginate/paginate.module.js | 0 .../finance/paginate/paginate.pug | 0 .../finance/paginate/paginate.service.js | 0 .../finance/payment-statuses.js | 0 .../custom-select/custom-select.component.js | 0 .../custom-select/custom-select.module.js | 0 .../custom-select/select2.directive.js | 0 .../datepicker/datepicker.component.js | 0 .../datepicker/datepicker.module.js | 0 .../datepicker/daterangepicker.directive.js | 0 .../finance/search-form/search-form.js | 2 +- .../finance/search-form/search-form.pug | 8 +++--- .../search-result/search-result.component.js | 2 +- .../search-result/search-result.module.js | 0 .../finance/search-result/search-result.pug | 0 .../finance/search-result/status.filter.js | 0 .../statistic/statistic.component.js | 8 ------ .../analytics/statistic/statistic.module.js | 1 - .../statistic/statistic.template.pug | 1 - app/components/app/app.component.js | 4 +-- app/components/app/app.module.js | 2 +- app/components/sidebar/sidebar.pug | 8 ------ 38 files changed, 37 insertions(+), 54 deletions(-) rename app/components/{ => analytics}/dashboard/chart-data-conversion.service.js (100%) rename app/components/{ => analytics}/dashboard/conversion/conversion.js (100%) rename app/components/{ => analytics}/dashboard/dashboard.component.js (91%) rename app/components/{ => analytics}/dashboard/dashboard.module.js (100%) rename app/components/{dashboard/dashboard.pug => analytics/dashboard/dashboard.template.pug} (100%) rename app/components/{ => analytics}/dashboard/geolocation/geolocation.js (100%) rename app/components/{ => analytics}/dashboard/info-panel/info-panel.js (91%) rename app/components/{dashboard/info-panel/info-panel.pug => analytics/dashboard/info-panel/info-panel.template.pug} (100%) rename app/components/{ => analytics}/dashboard/revenue/revenue.js (100%) rename app/components/{ => analytics}/finance/finance.component.js (93%) rename app/components/{ => analytics}/finance/finance.module.js (100%) rename app/components/{ => analytics}/finance/finance.pug (90%) rename app/components/{ => analytics}/finance/paginate/paginate.component.js (90%) rename app/components/{ => analytics}/finance/paginate/paginate.module.js (100%) rename app/components/{ => analytics}/finance/paginate/paginate.pug (100%) rename app/components/{ => analytics}/finance/paginate/paginate.service.js (100%) rename app/components/{ => analytics}/finance/payment-statuses.js (100%) rename app/components/{ => analytics}/finance/search-form/custom-select/custom-select.component.js (100%) rename app/components/{ => analytics}/finance/search-form/custom-select/custom-select.module.js (100%) rename app/components/{ => analytics}/finance/search-form/custom-select/select2.directive.js (100%) rename app/components/{ => analytics}/finance/search-form/datepicker/datepicker.component.js (100%) rename app/components/{ => analytics}/finance/search-form/datepicker/datepicker.module.js (100%) rename app/components/{ => analytics}/finance/search-form/datepicker/daterangepicker.directive.js (100%) rename app/components/{ => analytics}/finance/search-form/search-form.js (71%) rename app/components/{ => analytics}/finance/search-form/search-form.pug (74%) rename app/components/{ => analytics}/finance/search-result/search-result.component.js (54%) rename app/components/{ => analytics}/finance/search-result/search-result.module.js (100%) rename app/components/{ => analytics}/finance/search-result/search-result.pug (100%) rename app/components/{ => analytics}/finance/search-result/status.filter.js (100%) delete mode 100644 app/components/analytics/statistic/statistic.component.js delete mode 100644 app/components/analytics/statistic/statistic.module.js delete mode 100644 app/components/analytics/statistic/statistic.template.pug diff --git a/app/components/analytics/analytics.component.js b/app/components/analytics/analytics.component.js index d958584..7ca3f1f 100644 --- a/app/components/analytics/analytics.component.js +++ b/app/components/analytics/analytics.component.js @@ -1,13 +1,15 @@ dashboard.component('analytics', { templateUrl: 'components/analytics/analytics.template.html', $routeConfig: [ - {path: '/:shopId/statistic', name: 'Statistic', component: 'statistic'} + {path: '/:shopId/statistic', name: 'Dashboard', component: 'dashboard'}, + {path: '/:shopId/finance', name: 'Finance', component: 'finance'} ], bindings: { $router: '<' }, controller: function (Parties) { - this.$routerOnActivate = () => { + this.$routerOnActivate = route => { + console.log(route); Parties.get(party => { this.party = party; this.shopsDetails = _.map(this.party.shops, shop => ({ @@ -22,7 +24,9 @@ dashboard.component('analytics', { }; this.showStatistic = () => { - this.$router.navigate(['Statistic', {shopId: this.selectedShopId}]); - } + this.$router.navigate(['Dashboard', {shopId: this.selectedShopId}]); + }; + + this.isRouteActive = route => this.$router.isRouteActive(this.$router.generate(route)); } }); diff --git a/app/components/analytics/analytics.module.js b/app/components/analytics/analytics.module.js index fbf9176..1a2e462 100644 --- a/app/components/analytics/analytics.module.js +++ b/app/components/analytics/analytics.module.js @@ -1 +1 @@ -const analytics = angular.module('analytics', ['statistic']); +const analytics = angular.module('analytics', ['dashboard']); diff --git a/app/components/analytics/analytics.template.pug b/app/components/analytics/analytics.template.pug index f7c8ce3..8a89cba 100644 --- a/app/components/analytics/analytics.template.pug +++ b/app/components/analytics/analytics.template.pug @@ -14,19 +14,14 @@ .col-md-3 button.btn.btn-default(ng-click="$ctrl.showStatistic()") Показать статистику -ng-outlet -//.row - //.col-md-12 - // .x_panel.tile - // .x_content - //div(role="tabpanel" data-example-id="togglable-tabs") - // ul#myTab.nav.nav-tabs.bar_tabs(role="tablist") - // li.active(role="presentation") - // a#statistic-tab(href="#tab_content_statistic" role="tab" data-toggle="tab" aria-expanded="true") Статистика - // li(role="presentation") - // a#finance-tab(href="#tab_content_finance" role="tab" data-toggle="tab" aria-expanded="false") Финансы - // div#myTabContent.tab-content - // div#tab_content_statistic.tab-pane.fade.active.in(role="tabpanel" aria-labelledby="finance-tab") - // p Хуй - // div#tab_content_finance.tab-pane.fade.in(role="tabpanel" aria-labelledby="profile-tab") - // p Хуй2 \ No newline at end of file +.row(ng-show="$ctrl.selectedShopId") + .col-md-12 + .x_panel.tile + .x_content + ul.nav.nav-tabs.bar_tabs + li(ng-class="{active: $ctrl.isRouteActive(['\Dashboard\', {shopId: $ctrl.selectedShopId}])}") + a(ng-link="['\Dashboard\', {shopId: $ctrl.selectedShopId}]") Статистика + li(ng-class="{active: $ctrl.isRouteActive(['\Finance\', {shopId: $ctrl.selectedShopId}])}") + a(ng-link="['\Finance\', {shopId: $ctrl.selectedShopId}]") Финансы + .tab-content + ng-outlet diff --git a/app/components/dashboard/chart-data-conversion.service.js b/app/components/analytics/dashboard/chart-data-conversion.service.js similarity index 100% rename from app/components/dashboard/chart-data-conversion.service.js rename to app/components/analytics/dashboard/chart-data-conversion.service.js diff --git a/app/components/dashboard/conversion/conversion.js b/app/components/analytics/dashboard/conversion/conversion.js similarity index 100% rename from app/components/dashboard/conversion/conversion.js rename to app/components/analytics/dashboard/conversion/conversion.js diff --git a/app/components/dashboard/dashboard.component.js b/app/components/analytics/dashboard/dashboard.component.js similarity index 91% rename from app/components/dashboard/dashboard.component.js rename to app/components/analytics/dashboard/dashboard.component.js index 8f8894f..aea2d7a 100644 --- a/app/components/dashboard/dashboard.component.js +++ b/app/components/analytics/dashboard/dashboard.component.js @@ -1,6 +1,10 @@ dashboard.component('dashboard', { - templateUrl: 'components/dashboard/dashboard.html', + templateUrl: 'components/analytics/dashboard/dashboard.template.html', controller: function (Payments, ChartDataConversion, Customers) { + this.$routerOnActivate = route => { + console.log(route); + }; + this.toTime = moment().format(); // this.fromTime = moment(this.toTime) diff --git a/app/components/dashboard/dashboard.module.js b/app/components/analytics/dashboard/dashboard.module.js similarity index 100% rename from app/components/dashboard/dashboard.module.js rename to app/components/analytics/dashboard/dashboard.module.js diff --git a/app/components/dashboard/dashboard.pug b/app/components/analytics/dashboard/dashboard.template.pug similarity index 100% rename from app/components/dashboard/dashboard.pug rename to app/components/analytics/dashboard/dashboard.template.pug diff --git a/app/components/dashboard/geolocation/geolocation.js b/app/components/analytics/dashboard/geolocation/geolocation.js similarity index 100% rename from app/components/dashboard/geolocation/geolocation.js rename to app/components/analytics/dashboard/geolocation/geolocation.js diff --git a/app/components/dashboard/info-panel/info-panel.js b/app/components/analytics/dashboard/info-panel/info-panel.js similarity index 91% rename from app/components/dashboard/info-panel/info-panel.js rename to app/components/analytics/dashboard/info-panel/info-panel.js index 9180487..1568b60 100644 --- a/app/components/dashboard/info-panel/info-panel.js +++ b/app/components/analytics/dashboard/info-panel/info-panel.js @@ -1,7 +1,7 @@ const infoPanel = angular.module('infoPanel', ['currency']); infoPanel.component('infoPanel', { - templateUrl: 'components/dashboard/info-panel/info-panel.html', + templateUrl: 'components/analytics/dashboard/info-panel/info-panel.template.html', bindings: { uniqueCount: '<', successfulCount: '<', diff --git a/app/components/dashboard/info-panel/info-panel.pug b/app/components/analytics/dashboard/info-panel/info-panel.template.pug similarity index 100% rename from app/components/dashboard/info-panel/info-panel.pug rename to app/components/analytics/dashboard/info-panel/info-panel.template.pug diff --git a/app/components/dashboard/revenue/revenue.js b/app/components/analytics/dashboard/revenue/revenue.js similarity index 100% rename from app/components/dashboard/revenue/revenue.js rename to app/components/analytics/dashboard/revenue/revenue.js diff --git a/app/components/finance/finance.component.js b/app/components/analytics/finance/finance.component.js similarity index 93% rename from app/components/finance/finance.component.js rename to app/components/analytics/finance/finance.component.js index bf1fc51..8624a40 100644 --- a/app/components/finance/finance.component.js +++ b/app/components/analytics/finance/finance.component.js @@ -1,5 +1,5 @@ finance.component('finance', { - templateUrl: 'components/finance/finance.html', + templateUrl: 'components/analytics/finance/finance.html', controller: function (Invoices) { this.searchParams = { fromTime: moment().hours(0).minutes(0).seconds(0).format(), diff --git a/app/components/finance/finance.module.js b/app/components/analytics/finance/finance.module.js similarity index 100% rename from app/components/finance/finance.module.js rename to app/components/analytics/finance/finance.module.js diff --git a/app/components/finance/finance.pug b/app/components/analytics/finance/finance.pug similarity index 90% rename from app/components/finance/finance.pug rename to app/components/analytics/finance/finance.pug index 0f1781d..f2aa688 100644 --- a/app/components/finance/finance.pug +++ b/app/components/analytics/finance/finance.pug @@ -2,7 +2,7 @@ .col-md-12.col-sm-12.col-xs-12 .x_panel.tile .x_title - h3 Поиск + h4 Поиск .x_content search-form(search-params="$ctrl.searchParams" on-search="$ctrl.search()") .row diff --git a/app/components/finance/paginate/paginate.component.js b/app/components/analytics/finance/paginate/paginate.component.js similarity index 90% rename from app/components/finance/paginate/paginate.component.js rename to app/components/analytics/finance/paginate/paginate.component.js index 042f0ad..50b2f29 100644 --- a/app/components/finance/paginate/paginate.component.js +++ b/app/components/analytics/finance/paginate/paginate.component.js @@ -1,5 +1,5 @@ paginate.component('paginate', { - templateUrl: 'components/finance/paginate/paginate.html', + templateUrl: 'components/analytics/finance/paginate/paginate.html', bindings: { limit: '<', size: '<', diff --git a/app/components/finance/paginate/paginate.module.js b/app/components/analytics/finance/paginate/paginate.module.js similarity index 100% rename from app/components/finance/paginate/paginate.module.js rename to app/components/analytics/finance/paginate/paginate.module.js diff --git a/app/components/finance/paginate/paginate.pug b/app/components/analytics/finance/paginate/paginate.pug similarity index 100% rename from app/components/finance/paginate/paginate.pug rename to app/components/analytics/finance/paginate/paginate.pug diff --git a/app/components/finance/paginate/paginate.service.js b/app/components/analytics/finance/paginate/paginate.service.js similarity index 100% rename from app/components/finance/paginate/paginate.service.js rename to app/components/analytics/finance/paginate/paginate.service.js diff --git a/app/components/finance/payment-statuses.js b/app/components/analytics/finance/payment-statuses.js similarity index 100% rename from app/components/finance/payment-statuses.js rename to app/components/analytics/finance/payment-statuses.js diff --git a/app/components/finance/search-form/custom-select/custom-select.component.js b/app/components/analytics/finance/search-form/custom-select/custom-select.component.js similarity index 100% rename from app/components/finance/search-form/custom-select/custom-select.component.js rename to app/components/analytics/finance/search-form/custom-select/custom-select.component.js diff --git a/app/components/finance/search-form/custom-select/custom-select.module.js b/app/components/analytics/finance/search-form/custom-select/custom-select.module.js similarity index 100% rename from app/components/finance/search-form/custom-select/custom-select.module.js rename to app/components/analytics/finance/search-form/custom-select/custom-select.module.js diff --git a/app/components/finance/search-form/custom-select/select2.directive.js b/app/components/analytics/finance/search-form/custom-select/select2.directive.js similarity index 100% rename from app/components/finance/search-form/custom-select/select2.directive.js rename to app/components/analytics/finance/search-form/custom-select/select2.directive.js diff --git a/app/components/finance/search-form/datepicker/datepicker.component.js b/app/components/analytics/finance/search-form/datepicker/datepicker.component.js similarity index 100% rename from app/components/finance/search-form/datepicker/datepicker.component.js rename to app/components/analytics/finance/search-form/datepicker/datepicker.component.js diff --git a/app/components/finance/search-form/datepicker/datepicker.module.js b/app/components/analytics/finance/search-form/datepicker/datepicker.module.js similarity index 100% rename from app/components/finance/search-form/datepicker/datepicker.module.js rename to app/components/analytics/finance/search-form/datepicker/datepicker.module.js diff --git a/app/components/finance/search-form/datepicker/daterangepicker.directive.js b/app/components/analytics/finance/search-form/datepicker/daterangepicker.directive.js similarity index 100% rename from app/components/finance/search-form/datepicker/daterangepicker.directive.js rename to app/components/analytics/finance/search-form/datepicker/daterangepicker.directive.js diff --git a/app/components/finance/search-form/search-form.js b/app/components/analytics/finance/search-form/search-form.js similarity index 71% rename from app/components/finance/search-form/search-form.js rename to app/components/analytics/finance/search-form/search-form.js index 183f3d0..1e26117 100644 --- a/app/components/finance/search-form/search-form.js +++ b/app/components/analytics/finance/search-form/search-form.js @@ -1,7 +1,7 @@ const searchForm = angular.module('searchForm', ['datepicker', 'customSelect']); searchForm.component('searchForm', { - templateUrl: 'components/finance/search-form/search-form.html', + templateUrl: 'components/analytics/finance/search-form/search-form.html', bindings: { searchParams: '=', onSearch: '&' diff --git a/app/components/finance/search-form/search-form.pug b/app/components/analytics/finance/search-form/search-form.pug similarity index 74% rename from app/components/finance/search-form/search-form.pug rename to app/components/analytics/finance/search-form/search-form.pug index 24eba68..c8dab79 100644 --- a/app/components/finance/search-form/search-form.pug +++ b/app/components/analytics/finance/search-form/search-form.pug @@ -10,10 +10,10 @@ form.form-horizontal.form-label-left .col-md-6 datepicker(date="$ctrl.searchParams.toTime") .col-md-6 - //.form-group - // label.control-label.col-md-4 Статус платежа: - // .col-md-6 - // custom-select(options="$ctrl.statuses" selected="$ctrl.searchParams.status") + .form-group + label.control-label.col-md-4 Статус платежа: + .col-md-6 + custom-select(options="$ctrl.statuses" selected="$ctrl.searchParams.status") .form-group label.control-label.col-md-4 Номер: .col-md-6 diff --git a/app/components/finance/search-result/search-result.component.js b/app/components/analytics/finance/search-result/search-result.component.js similarity index 54% rename from app/components/finance/search-result/search-result.component.js rename to app/components/analytics/finance/search-result/search-result.component.js index 05b9b7e..96eb31d 100644 --- a/app/components/finance/search-result/search-result.component.js +++ b/app/components/analytics/finance/search-result/search-result.component.js @@ -1,5 +1,5 @@ searchResult.component('searchResult', { - templateUrl: 'components/finance/search-result/search-result.html', + templateUrl: 'components/analytics/finance/search-result/search-result.html', bindings: { searchedInvoices: '<' } diff --git a/app/components/finance/search-result/search-result.module.js b/app/components/analytics/finance/search-result/search-result.module.js similarity index 100% rename from app/components/finance/search-result/search-result.module.js rename to app/components/analytics/finance/search-result/search-result.module.js diff --git a/app/components/finance/search-result/search-result.pug b/app/components/analytics/finance/search-result/search-result.pug similarity index 100% rename from app/components/finance/search-result/search-result.pug rename to app/components/analytics/finance/search-result/search-result.pug diff --git a/app/components/finance/search-result/status.filter.js b/app/components/analytics/finance/search-result/status.filter.js similarity index 100% rename from app/components/finance/search-result/status.filter.js rename to app/components/analytics/finance/search-result/status.filter.js diff --git a/app/components/analytics/statistic/statistic.component.js b/app/components/analytics/statistic/statistic.component.js deleted file mode 100644 index c459c72..0000000 --- a/app/components/analytics/statistic/statistic.component.js +++ /dev/null @@ -1,8 +0,0 @@ -statistic.component('statistic', { - templateUrl: 'components/analytics/statistic/statistic.template.html', - controller: function () { - this.$routerOnActivate = (next) => { - console.log(next); - } - } -}); diff --git a/app/components/analytics/statistic/statistic.module.js b/app/components/analytics/statistic/statistic.module.js deleted file mode 100644 index 8e5d684..0000000 --- a/app/components/analytics/statistic/statistic.module.js +++ /dev/null @@ -1 +0,0 @@ -const statistic = angular.module('statistic', []); diff --git a/app/components/analytics/statistic/statistic.template.pug b/app/components/analytics/statistic/statistic.template.pug deleted file mode 100644 index fab18d5..0000000 --- a/app/components/analytics/statistic/statistic.template.pug +++ /dev/null @@ -1 +0,0 @@ -div Test \ No newline at end of file diff --git a/app/components/app/app.component.js b/app/components/app/app.component.js index 5fecfbd..3dca88e 100644 --- a/app/components/app/app.component.js +++ b/app/components/app/app.component.js @@ -2,9 +2,7 @@ app.component('app', { templateUrl: 'components/app/app.html', $routeConfig: [ {path: '/analytics', name: 'Analytics', component: 'analytics', useAsDefault: true}, - {path: '/analytics/...', component: 'analytics'}, - {path: '/dashboard', name: 'Dashboard', component: 'dashboard'}, - {path: '/finance', name: 'Finance', component: 'finance'} + {path: '/analytics/...', component: 'analytics'} ] }); diff --git a/app/components/app/app.module.js b/app/components/app/app.module.js index 6106a33..8257067 100644 --- a/app/components/app/app.module.js +++ b/app/components/app/app.module.js @@ -1,7 +1,7 @@ const app = angular.module('app', [ 'ngComponentRouter', 'analytics', - 'dashboard', + // 'dashboard', 'finance', 'sidebar', 'topPanel', diff --git a/app/components/sidebar/sidebar.pug b/app/components/sidebar/sidebar.pug index acd8a72..ac242ef 100644 --- a/app/components/sidebar/sidebar.pug +++ b/app/components/sidebar/sidebar.pug @@ -7,14 +7,6 @@ #sidebar-menu.main_menu_side.hidden-print.main_menu .menu_section ul.nav.side-menu - li(ng-class="{active: $ctrl.isActive('/dashboard')}") - a(ng-link="[\'Dashboard\']") - i.fa.fa-home - | Обзор - li(ng-class="{active: $ctrl.isActive('/finance')}") - a(ng-link="[\'Finance\']") - i.fa.fa-bar-chart-o - | Финансы li(ng-class="{active: $ctrl.isActive('/analytics')}") a(ng-link="['\Analytics\']") i.fa.fa-bar-chart-o From 6762b5d3fe853fcebec1ac3d0cd317a3684b2a43 Mon Sep 17 00:00:00 2001 From: Ildar Galeev Date: Sat, 24 Sep 2016 19:14:38 +0300 Subject: [PATCH 03/13] FE-38: Added dynamic route support to sidebar. Removed on select event from shop selector --- .../analytics/analytics.component.js | 20 +++++++++++-------- .../analytics/analytics.template.pug | 2 +- .../dashboard/dashboard.component.js | 4 ---- .../shop-select/select2.directive.js | 2 +- .../shop-select/shop-select.component.js | 9 ++++++--- app/components/sidebar/sidebar.js | 14 ++++++++++++- 6 files changed, 33 insertions(+), 18 deletions(-) diff --git a/app/components/analytics/analytics.component.js b/app/components/analytics/analytics.component.js index 7ca3f1f..30fec9f 100644 --- a/app/components/analytics/analytics.component.js +++ b/app/components/analytics/analytics.component.js @@ -7,21 +7,25 @@ dashboard.component('analytics', { bindings: { $router: '<' }, - controller: function (Parties) { - this.$routerOnActivate = route => { - console.log(route); + controller: function (Parties, $location) { + this.$routerOnActivate = () => { + const path = $location.path(); + this.selectedShopId = findParam(path, 'analytics'); Parties.get(party => { - this.party = party; - this.shopsDetails = _.map(this.party.shops, shop => ({ + this.shopsDetails = _.map(party.shops, shop => ({ name: shop.shopDetails.name, key: shop.shopID })); }); }; - this.onShopSelect = () => { - console.log(this.selectedShopId); - }; + function findParam(path, marker) { + const res = _.chain(path) + .split('/') + .reduce((a, c) => ((c === marker || a === marker) ? c : a), '') + .value(); + return res !== marker ? res : null; + } this.showStatistic = () => { this.$router.navigate(['Dashboard', {shopId: this.selectedShopId}]); diff --git a/app/components/analytics/analytics.template.pug b/app/components/analytics/analytics.template.pug index 8a89cba..42f2897 100644 --- a/app/components/analytics/analytics.template.pug +++ b/app/components/analytics/analytics.template.pug @@ -10,7 +10,7 @@ .form-group label.control-label.col-md-2 Магазин: .col-md-8 - shop-select(options="$ctrl.shopsDetails" selected="$ctrl.selectedShopId" on-select="$ctrl.onShopSelect()") + shop-select(options="$ctrl.shopsDetails" selected="$ctrl.selectedShopId") .col-md-3 button.btn.btn-default(ng-click="$ctrl.showStatistic()") Показать статистику diff --git a/app/components/analytics/dashboard/dashboard.component.js b/app/components/analytics/dashboard/dashboard.component.js index aea2d7a..b00cbd7 100644 --- a/app/components/analytics/dashboard/dashboard.component.js +++ b/app/components/analytics/dashboard/dashboard.component.js @@ -1,10 +1,6 @@ dashboard.component('dashboard', { templateUrl: 'components/analytics/dashboard/dashboard.template.html', controller: function (Payments, ChartDataConversion, Customers) { - this.$routerOnActivate = route => { - console.log(route); - }; - this.toTime = moment().format(); // this.fromTime = moment(this.toTime) diff --git a/app/components/analytics/shop-select/select2.directive.js b/app/components/analytics/shop-select/select2.directive.js index 21f3a66..777f997 100644 --- a/app/components/analytics/shop-select/select2.directive.js +++ b/app/components/analytics/shop-select/select2.directive.js @@ -1,4 +1,4 @@ -customSelect.directive('select2', function () { +analytics.directive('select2', function () { return { restrict: 'A', link: function (scope, element) { diff --git a/app/components/analytics/shop-select/shop-select.component.js b/app/components/analytics/shop-select/shop-select.component.js index 490b55f..d076f96 100644 --- a/app/components/analytics/shop-select/shop-select.component.js +++ b/app/components/analytics/shop-select/shop-select.component.js @@ -1,11 +1,14 @@ analytics.component('shopSelect', { - template: ` `, bindings: { options: '=', - selected: '=', - onSelect: '&' + selected: '=' + }, + controller: function () { + } + }); \ No newline at end of file diff --git a/app/components/sidebar/sidebar.js b/app/components/sidebar/sidebar.js index fa06874..271accf 100644 --- a/app/components/sidebar/sidebar.js +++ b/app/components/sidebar/sidebar.js @@ -3,6 +3,18 @@ const sidebar = angular.module('sidebar', []); sidebar.component('sidebar', { templateUrl: 'components/sidebar/sidebar.html', controller: function ($location) { - this.isActive = location => location === $location.path(); + this.$routerOnActivate = () => { + const path = $location.path(); + console.log(path); + }; + + this.isActive = location => { + const cleaned = _.replace(location, '/', ''); + const result = _.chain($location.path()) + .split('/') + .find(item => item === cleaned) + .value(); + return result && result.length > 0; + }; } }); From 939d04f15049379d77a9ad918fcc1a4487c68ac7 Mon Sep 17 00:00:00 2001 From: Ildar Galeev Date: Sun, 25 Sep 2016 18:42:55 +0300 Subject: [PATCH 04/13] FE-38: Added date range customization on dashboard --- .../analytics/analytics.component.js | 2 +- .../analytics/analytics.template.pug | 8 +- .../dashboard/dashboard.component.js | 91 +++++++++---------- .../dashboard/dashboard.template.pug | 20 +++- .../analytics/finance/finance.component.js | 33 ++++--- .../datepicker/datepicker.component.js | 3 +- .../shop-select/select2.directive.js | 10 -- .../shop-select/shop-select.component.js | 14 --- app/components/top-panel/top-panel.pug | 3 +- app/shared/resources/customers.js | 28 +++--- app/shared/resources/invoices.js | 61 +++++++++---- app/shared/resources/payments.js | 82 +++++++++-------- capi-mock/me.js | 46 +++++++--- 13 files changed, 220 insertions(+), 181 deletions(-) delete mode 100644 app/components/analytics/shop-select/select2.directive.js delete mode 100644 app/components/analytics/shop-select/shop-select.component.js diff --git a/app/components/analytics/analytics.component.js b/app/components/analytics/analytics.component.js index 30fec9f..40697e5 100644 --- a/app/components/analytics/analytics.component.js +++ b/app/components/analytics/analytics.component.js @@ -27,7 +27,7 @@ dashboard.component('analytics', { return res !== marker ? res : null; } - this.showStatistic = () => { + this.onSelect = () => { this.$router.navigate(['Dashboard', {shopId: this.selectedShopId}]); }; diff --git a/app/components/analytics/analytics.template.pug b/app/components/analytics/analytics.template.pug index 42f2897..3624bd9 100644 --- a/app/components/analytics/analytics.template.pug +++ b/app/components/analytics/analytics.template.pug @@ -5,14 +5,14 @@ h4 Аналитика .x_content .row - .col-md-5 + .col-md-6 form.form-horizontal .form-group label.control-label.col-md-2 Магазин: .col-md-8 - shop-select(options="$ctrl.shopsDetails" selected="$ctrl.selectedShopId") - .col-md-3 - button.btn.btn-default(ng-click="$ctrl.showStatistic()") Показать статистику + select.select2_multiple.form-control.custom_select( + select2 ng-options="detail.key as detail.name for detail in $ctrl.shopsDetails" + ng-model="$ctrl.selectedShopId" ng-change="$ctrl.onSelect()") .row(ng-show="$ctrl.selectedShopId") .col-md-12 diff --git a/app/components/analytics/dashboard/dashboard.component.js b/app/components/analytics/dashboard/dashboard.component.js index b00cbd7..b705cae 100644 --- a/app/components/analytics/dashboard/dashboard.component.js +++ b/app/components/analytics/dashboard/dashboard.component.js @@ -1,58 +1,57 @@ dashboard.component('dashboard', { templateUrl: 'components/analytics/dashboard/dashboard.template.html', controller: function (Payments, ChartDataConversion, Customers) { + // this.fromTime = moment(this.toTime).subtract(1, 'M').hours(0).minutes(0).seconds(0).milliseconds(0).format(); this.toTime = moment().format(); + this.fromTime = moment().hours(0).minutes(0).seconds(0).format(); - // this.fromTime = moment(this.toTime) - // .subtract(1, 'M') - // .hours(0) - // .minutes(0) - // .seconds(0) - // .milliseconds(0) - // .format(); + this.$routerOnActivate = route => { + this.shopID = route.params.shopId; + this.show(); + }; - this.fromTime = moment() - .hours(0) - .minutes(0) - .seconds(0) - .format(); + this.show = () => { + this.chartFromTime = this.fromTime; - Payments.conversion({ - fromTime: this.fromTime, - toTime: this.toTime, - splitUnit: 'minute', - splitSize: 1 - }, conversionStat => { - this.conversionChartData = ChartDataConversion.toConversionChartData(conversionStat); - const paymentCountInfo = ChartDataConversion.toPaymentCountInfo(conversionStat); - this.successfulCount = paymentCountInfo.successfulCount; - this.unfinishedCount = paymentCountInfo.unfinishedCount; - }); + const customers = new Customers(this.shopID); + customers.rate({ + fromTime: this.fromTime, + toTime: this.toTime + }, rateStat => { + this.uniqueCount = rateStat[0] ? rateStat[0].uniqueCount : 0; + }); - Payments.revenue({ - fromTime: this.fromTime, - toTime: this.toTime, - splitUnit: 'minute', - splitSize: 1 - }, revenueStat => { - this.revenueChartData = ChartDataConversion.toRevenueChartData(revenueStat); - this.profit = ChartDataConversion.toTotalProfit(revenueStat); - }); + const payments = new Payments(this.shopID); + payments.conversion({ + fromTime: this.fromTime, + toTime: this.toTime, + splitUnit: 'minute', + splitSize: 1 + }, conversionStat => { + this.conversionChartData = ChartDataConversion.toConversionChartData(conversionStat); + const paymentCountInfo = ChartDataConversion.toPaymentCountInfo(conversionStat); + this.successfulCount = paymentCountInfo.successfulCount; + this.unfinishedCount = paymentCountInfo.unfinishedCount; + }); - Payments.geo({ - fromTime: this.fromTime, - toTime: this.toTime, - splitUnit: 'day', - splitSize: 1 - }, geoStat => { - this.geoChartData = ChartDataConversion.toGeoChartData(geoStat); - }); + payments.revenue({ + fromTime: this.fromTime, + toTime: this.toTime, + splitUnit: 'minute', + splitSize: 1 + }, revenueStat => { + this.revenueChartData = ChartDataConversion.toRevenueChartData(revenueStat); + this.profit = ChartDataConversion.toTotalProfit(revenueStat); + }); - Customers.rate({ - fromTime: this.fromTime, - toTime: this.toTime - }, rateStat => { - this.uniqueCount = rateStat[0] ? rateStat[0].uniqueCount : 0; - }); + payments.geo({ + fromTime: this.fromTime, + toTime: this.toTime, + splitUnit: 'day', + splitSize: 1 + }, geoStat => { + this.geoChartData = ChartDataConversion.toGeoChartData(geoStat); + }); + }; } }); diff --git a/app/components/analytics/dashboard/dashboard.template.pug b/app/components/analytics/dashboard/dashboard.template.pug index f226631..1bf094e 100644 --- a/app/components/analytics/dashboard/dashboard.template.pug +++ b/app/components/analytics/dashboard/dashboard.template.pug @@ -1,21 +1,31 @@ +.row + .col-md-12 + form.form-inline.pull-right + .form-group + label.control-label Статистика с + datepicker(date="$ctrl.fromTime") + .form-group + label.control-label по + datepicker(date="$ctrl.toTime") + button.btn.btn-default(style="margin-bottom: 0; margin-right: 0" ng-click="$ctrl.show()") Показать .row info-panel(unique-count="$ctrl.uniqueCount" successful-count="$ctrl.successfulCount" unfinished-count="$ctrl.unfinishedCount" profit="$ctrl.profit") .row - .col-md-12.col-sm-12.col-xs-12 + .col-md-12 .x_panel.tile .x_title h4 Оборот .x_content - revenue(from-time="$ctrl.fromTime" chart-data="$ctrl.revenueChartData") + revenue(from-time="$ctrl.chartFromTime" chart-data="$ctrl.revenueChartData") .row - .col-md-6.col-sm-6.col-xs-12 + .col-md-6 .x_panel.tile .x_title h4 Конверсия оплат .x_content - conversion(from-time="$ctrl.fromTime" chart-data="$ctrl.conversionChartData") - .col-md-6.col-sm-6.col-xs-12 + conversion(from-time="$ctrl.chartFromTime" chart-data="$ctrl.conversionChartData") + .col-md-6 .x_panel.tile .x_title h4 Геолокация diff --git a/app/components/analytics/finance/finance.component.js b/app/components/analytics/finance/finance.component.js index 8624a40..14a127f 100644 --- a/app/components/analytics/finance/finance.component.js +++ b/app/components/analytics/finance/finance.component.js @@ -10,20 +10,25 @@ finance.component('finance', { this.isLoading = false; this.isSearched = false; - this.search = (offset = 0) => { - this.isLoading = true; - this.isSearched = true; - this.searchParams.offset = offset; - if (_.isEmpty(this.searchParams.invoiceID)) { - this.searchParams.invoiceID = null; - } - Invoices.search(this.searchParams, result => { - this.searchedInvoices = result.invoices; - this.totalCount = result.totalCount; - this.isLoading = false; - }); - }; + this.$routerOnActivate = route => { + const shopID = route.params.shopId; - this.search(); + this.search = (offset = 0) => { + this.isLoading = true; + this.isSearched = true; + this.searchParams.offset = offset; + if (_.isEmpty(this.searchParams.invoiceID)) { + this.searchParams.invoiceID = null; + } + const invoices = new Invoices(shopID); + invoices.search(this.searchParams, result => { + this.searchedInvoices = result.invoices; + this.totalCount = result.totalCount; + this.isLoading = false; + }); + }; + + this.search(); + }; } }); diff --git a/app/components/analytics/finance/search-form/datepicker/datepicker.component.js b/app/components/analytics/finance/search-form/datepicker/datepicker.component.js index 7bfd8da..95468ca 100644 --- a/app/components/analytics/finance/search-form/datepicker/datepicker.component.js +++ b/app/components/analytics/finance/search-form/datepicker/datepicker.component.js @@ -1,6 +1,5 @@ datepicker.component('datepicker', { - template: ` - `, + template: ``, bindings: { date: '=' } diff --git a/app/components/analytics/shop-select/select2.directive.js b/app/components/analytics/shop-select/select2.directive.js deleted file mode 100644 index 777f997..0000000 --- a/app/components/analytics/shop-select/select2.directive.js +++ /dev/null @@ -1,10 +0,0 @@ -analytics.directive('select2', function () { - return { - restrict: 'A', - link: function (scope, element) { - element.select2({ - placeholder: '' - }); - } - } -}); diff --git a/app/components/analytics/shop-select/shop-select.component.js b/app/components/analytics/shop-select/shop-select.component.js deleted file mode 100644 index d076f96..0000000 --- a/app/components/analytics/shop-select/shop-select.component.js +++ /dev/null @@ -1,14 +0,0 @@ -analytics.component('shopSelect', { - template: ``, - bindings: { - options: '=', - selected: '=' - }, - controller: function () { - - } - -}); \ No newline at end of file diff --git a/app/components/top-panel/top-panel.pug b/app/components/top-panel/top-panel.pug index 6a70b1f..22b0103 100644 --- a/app/components/top-panel/top-panel.pug +++ b/app/components/top-panel/top-panel.pug @@ -4,8 +4,7 @@ ul.nav.navbar-nav.navbar-right li a.user-profile.dropdown-toggle(data-toggle="dropdown", aria-expanded="false") - img(src="img.png" alt="") - | {{$ctrl.profileName}}  + span {{$ctrl.profileName}}  span.fa.fa-angle-down ul.dropdown-menu.dropdown-usermenu.pull-right li(data-toggle="modal" data-target=".bs-example-modal-lg") diff --git a/app/shared/resources/customers.js b/app/shared/resources/customers.js index 44e8fea..a9d5c18 100644 --- a/app/shared/resources/customers.js +++ b/app/shared/resources/customers.js @@ -1,16 +1,18 @@ resources.factory('Customers', function ($resource, appConfig) { - return $resource(appConfig.capiUrl + 'analytics/shops/:shopID/customers/stats/:statsType', { - shopID: appConfig.shopID - }, { - /** - * @typedef {Object} Parameters - * @property {dateTime} fromTime - * @property {dateTime} toTime - */ + return function (shopID) { + return $resource(appConfig.capiUrl + 'analytics/shops/:shopID/customers/stats/:statsType', { + shopID: shopID + }, { + /** + * @typedef {Object} Parameters + * @property {dateTime} fromTime + * @property {dateTime} toTime + */ - /** - * @returns {PaymentRateStat} - */ - rate: {method: 'GET', isArray: true, params: {statsType: 'rate'}} - }); + /** + * @returns {PaymentRateStat} + */ + rate: {method: 'GET', isArray: true, params: {statsType: 'rate'}} + }); + } }); \ No newline at end of file diff --git a/app/shared/resources/invoices.js b/app/shared/resources/invoices.js index 5744dce..9b0db6e 100644 --- a/app/shared/resources/invoices.js +++ b/app/shared/resources/invoices.js @@ -1,20 +1,43 @@ -resources.factory('Invoices', function ($resource, appConfig) { - return $resource(appConfig.capiUrl + 'analytics/shops/:shopID/invoices', { - shopID: appConfig.shopID - }, { - /** - * @typedef {Object} Parameters - * @property {int} limit - * @property {int} offset - * @property {dateTime} fromTime - * @property {dateTime} toTime - * @property {string} status - * @property {string} invoiceID - */ +// resources.factory('Invoices', function ($resource, appConfig) { +// return $resource(appConfig.capiUrl + 'analytics/shops/:shopID/invoices', { +// shopID: appConfig.shopID +// }, { +// /** +// * @typedef {Object} Parameters +// * @property {int} limit +// * @property {int} offset +// * @property {dateTime} fromTime +// * @property {dateTime} toTime +// * @property {string} status +// * @property {string} invoiceID +// */ +// +// /** +// * @returns {Invoices} +// */ +// search: {method: 'GET'} +// }); +// }); - /** - * @returns {Invoices} - */ - search: {method: 'GET'} - }); -}); \ No newline at end of file +resources.factory('Invoices', function ($resource, appConfig) { + return function (shopID) { + return $resource(appConfig.capiUrl + 'analytics/shops/:shopID/invoices', { + shopID: shopID + }, { + /** + * @typedef {Object} Parameters + * @property {int} limit + * @property {int} offset + * @property {dateTime} fromTime + * @property {dateTime} toTime + * @property {string} status + * @property {string} invoiceID + */ + + /** + * @returns {Invoices} + */ + search: {method: 'GET'} + }); + } +}); diff --git a/app/shared/resources/payments.js b/app/shared/resources/payments.js index 9a5d797..3fa2e4a 100644 --- a/app/shared/resources/payments.js +++ b/app/shared/resources/payments.js @@ -1,47 +1,49 @@ resources.factory('Payments', function ($resource, appConfig) { - return $resource(appConfig.capiUrl + 'analytics/shops/:shopID/payments/stats/:statsType', { - shopID: appConfig.shopID - }, { - /** - * @typedef {Object} Parameters - * @property {string} invoiceID - * @property {dateTime} fromTime - * @property {dateTime} toTime - * @property {string} splitUnit - * @property {int} splitSize - */ + return function (shopID) { + return $resource(appConfig.capiUrl + 'analytics/shops/:shopID/payments/stats/:statsType', { + shopID: shopID + }, { + /** + * @typedef {Object} Parameters + * @property {string} invoiceID + * @property {dateTime} fromTime + * @property {dateTime} toTime + * @property {string} splitUnit + * @property {int} splitSize + */ - /** - * @returns {Array.} - */ - revenue: {method: 'GET', isArray: true, params: {statsType: 'revenue'}}, + /** + * @returns {Array.} + */ + revenue: {method: 'GET', isArray: true, params: {statsType: 'revenue'}}, - /** - * @typedef {Object} Parameters - * @property {string} invoiceID - * @property {dateTime} fromTime - * @property {dateTime} toTime - * @property {string} splitUnit - * @property {int} splitSize - */ + /** + * @typedef {Object} Parameters + * @property {string} invoiceID + * @property {dateTime} fromTime + * @property {dateTime} toTime + * @property {string} splitUnit + * @property {int} splitSize + */ - /** - * @returns {Array.} - */ - conversion: {method: 'GET', isArray: true, params: {statsType: 'conversion'}}, + /** + * @returns {Array.} + */ + conversion: {method: 'GET', isArray: true, params: {statsType: 'conversion'}}, - /** - * @typedef {Object} Parameters - * @property {string} invoiceID - * @property {dateTime} fromTime - * @property {dateTime} toTime - * @property {string} splitUnit - * @property {int} splitSize - */ + /** + * @typedef {Object} Parameters + * @property {string} invoiceID + * @property {dateTime} fromTime + * @property {dateTime} toTime + * @property {string} splitUnit + * @property {int} splitSize + */ - /** - * @returns {Array.} - */ - geo: {method: 'GET', isArray: true, params: {statsType: 'geo'}}, - }); + /** + * @returns {Array.} + */ + geo: {method: 'GET', isArray: true, params: {statsType: 'geo'}}, + }); + } }); diff --git a/capi-mock/me.js b/capi-mock/me.js index 6568020..82a2915 100644 --- a/capi-mock/me.js +++ b/capi-mock/me.js @@ -1,24 +1,48 @@ -var shop = { +var shop1 = { shopID: 'THRIFT-SHOP', isBlocked: false, isSuspended: false, categoryRef: 1, shopDetails: { - name: 'Лееееех, да ответь же ты', - description: 'Магазин пропавшего Лехи', - location: 'Стена' + name: 'Shop 1', + description: 'shop 1 description', + location: 'Moscow' }, contractor: { - registeredName: 'Леха Свотин', - legalEntity: 'Хер знает что за поле' + registeredName: 'Registered name', + legalEntity: 'legalEntity' }, contract: { number: '2341', systemContractorRef: '34564', - concludedAt: 'Наверно дата и время', - validSince: 'Какая то дата и время', - validUntil: 'Какая то дата и время', - terminatedAt: 'Наверно дата и время' + concludedAt: 'concludedAt', + validSince: 'validSince', + validUntil: 'validUntil', + terminatedAt: 'terminatedAt' + } +}; + +var shop2 = { + shopID: 'THRIFT-SHOP2', + isBlocked: false, + isSuspended: false, + categoryRef: 1, + shopDetails: { + name: 'Shop 2', + description: 'shop 2 description', + location: 'Moscow' + }, + contractor: { + registeredName: 'Registered name', + legalEntity: 'legalEntity' + }, + contract: { + number: '4532', + systemContractorRef: '33422', + concludedAt: 'concludedAt', + validSince: 'validSince', + validUntil: 'validUntil', + terminatedAt: 'terminatedAt' } }; @@ -26,5 +50,5 @@ module.exports = { partyID: '1', isBlocked: false, isSuspended: false, - shops: [shop] + shops: [shop1, shop2] }; From 344d6feed3b1a50a5ae75aee12c5fcdbf79d0a82 Mon Sep 17 00:00:00 2001 From: Ildar Galeev Date: Mon, 26 Sep 2016 14:41:14 +0300 Subject: [PATCH 05/13] FE-38: Returned keycloak integration --- app/bootstrap.js | 26 ++++++++++++------------ app/components/top-panel/top-panel.js | 11 ++++------ app/keycloak.json | 2 +- app/shared/resources/resources.module.js | 2 +- 4 files changed, 19 insertions(+), 22 deletions(-) diff --git a/app/bootstrap.js b/app/bootstrap.js index 7619b58..a9caaf4 100644 --- a/app/bootstrap.js +++ b/app/bootstrap.js @@ -1,17 +1,17 @@ angular.element(document).ready(function () { - // var keycloakAuth = new Keycloak('keycloak.json'); + var keycloakAuth = new Keycloak('keycloak.json'); - // keycloakAuth.init({onLoad: 'login-required'}).success(function () { - // app.factory('Auth', function () { - // return { - // profileName: keycloakAuth.tokenParsed.name, - // logout: keycloakAuth.logout, - // token: keycloakAuth.token, - // updateToken: keycloakAuth.updateToken - // }; - // }); - // angular.bootstrap(document, ['app']); - // }); + keycloakAuth.init({onLoad: 'login-required'}).success(function () { + app.factory('Auth', function () { + return { + profileName: keycloakAuth.tokenParsed.name, + logout: keycloakAuth.logout, + token: keycloakAuth.token, + updateToken: keycloakAuth.updateToken + }; + }); + angular.bootstrap(document, ['app']); + }); - angular.bootstrap(document, ['app']); + // angular.bootstrap(document, ['app']); }); diff --git a/app/components/top-panel/top-panel.js b/app/components/top-panel/top-panel.js index 32f7fbc..158c74b 100644 --- a/app/components/top-panel/top-panel.js +++ b/app/components/top-panel/top-panel.js @@ -2,12 +2,9 @@ const topPanel = angular.module('topPanel', []); topPanel.component('topPanel', { templateUrl: 'components/top-panel/top-panel.html', - controller: function () { - // this.profileName = Auth.profileName; - // this.logout = Auth.logout; - // this.token = Auth.token; - this.profileName = 'test name'; - this.logout = () => {}; - this.token = 'test token'; + controller: function (Auth) { + this.profileName = Auth.profileName; + this.logout = Auth.logout; + this.token = Auth.token; } }); diff --git a/app/keycloak.json b/app/keycloak.json index 4106d55..d70b920 100644 --- a/app/keycloak.json +++ b/app/keycloak.json @@ -1,7 +1,7 @@ { "realm" : "external", "realm-public-key" : "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2KZPnAJs0SS6/w39mDTrWYRjM86IFteU/dPGpGQdOPwNe85Ep2leVN3/FBKVUMHsFTtFkVsg/VcCEfYBj22B0mZ8zV2hQUCNq1NV2b2LnYYrDmThmFOOTnpbBhEOMS8Wrzj3Yk7mcDtKlMzoBNIQ/Z54ffymkyiKX8XOw45K9Cx1Bp/SVjOnJlm0Qu/+zE40/XVpzgjbaqSc9+8B3tur2E03EVemOa6EFhu7ocKsbSR7/fG1nYOGKjACS1Z+VYQTMcRqxZlLw7kv3fxUaMDcK5p/16YWpWggflVy5w26IIJeDcsXG+X3LV6f6dyo9ZfOEvGqQZmPCohaSOgi+IRwAQIDAQAB", - "auth-server-url" : "http://macroserver1.msk1.rbkmoney.net:81/auth/", + "auth-server-url" : "http://localhost:31245/auth/", "ssl-required" : "external", "resource" : "koffing", "public-client" : true diff --git a/app/shared/resources/resources.module.js b/app/shared/resources/resources.module.js index 9b4dc8e..1ef7184 100644 --- a/app/shared/resources/resources.module.js +++ b/app/shared/resources/resources.module.js @@ -1,6 +1,6 @@ const resources = angular.module('resources', ['ngResource']); resources.config(function ($httpProvider) { - // $httpProvider.interceptors.push('authInterceptor'); + $httpProvider.interceptors.push('authInterceptor'); $httpProvider.interceptors.push('dateInterceptor'); }); From 6b24fa9090c43d9a9b9d76409d0d921b67c49546 Mon Sep 17 00:00:00 2001 From: Ildar Galeev Date: Mon, 26 Sep 2016 17:33:32 +0300 Subject: [PATCH 06/13] FE-38: Added create shop functionality --- .../analytics/analytics.template.pug | 2 +- .../finance/search-form/search-form.pug | 8 ++-- app/components/app/app.component.js | 2 + app/components/app/app.module.js | 2 +- .../shops/add/add-shop.component.js | 23 ++++++++++ .../shops/add/add-shop.template.pug | 45 +++++++++++++++++++ app/components/shops/shops.component.js | 5 +++ app/components/shops/shops.module.js | 1 + app/components/shops/shops.template.pug | 7 +++ app/components/sidebar/sidebar.js | 9 +--- app/components/sidebar/sidebar.pug | 8 ++++ app/index.pug | 2 +- app/shared/resources/shops.js | 3 ++ capi-mock/capi.js | 2 + 14 files changed, 104 insertions(+), 15 deletions(-) create mode 100644 app/components/shops/add/add-shop.component.js create mode 100644 app/components/shops/add/add-shop.template.pug create mode 100644 app/components/shops/shops.component.js create mode 100644 app/components/shops/shops.module.js create mode 100644 app/components/shops/shops.template.pug create mode 100644 app/shared/resources/shops.js diff --git a/app/components/analytics/analytics.template.pug b/app/components/analytics/analytics.template.pug index 3624bd9..c95705d 100644 --- a/app/components/analytics/analytics.template.pug +++ b/app/components/analytics/analytics.template.pug @@ -8,7 +8,7 @@ .col-md-6 form.form-horizontal .form-group - label.control-label.col-md-2 Магазин: + label.control-label.col-md-2 Магазин .col-md-8 select.select2_multiple.form-control.custom_select( select2 ng-options="detail.key as detail.name for detail in $ctrl.shopsDetails" diff --git a/app/components/analytics/finance/search-form/search-form.pug b/app/components/analytics/finance/search-form/search-form.pug index c8dab79..fd5593f 100644 --- a/app/components/analytics/finance/search-form/search-form.pug +++ b/app/components/analytics/finance/search-form/search-form.pug @@ -2,20 +2,20 @@ form.form-horizontal.form-label-left .row .col-md-6 .form-group - label.control-label.col-md-4 Дата с: + label.control-label.col-md-4 Дата с .col-md-6 datepicker(date="$ctrl.searchParams.fromTime") .form-group - label.control-label.col-md-4 Дата по: + label.control-label.col-md-4 Дата по .col-md-6 datepicker(date="$ctrl.searchParams.toTime") .col-md-6 .form-group - label.control-label.col-md-4 Статус платежа: + label.control-label.col-md-4 Статус платежа .col-md-6 custom-select(options="$ctrl.statuses" selected="$ctrl.searchParams.status") .form-group - label.control-label.col-md-4 Номер: + label.control-label.col-md-4 Номер .col-md-6 input.form-control(type="text" ng-model="$ctrl.searchParams.invoiceID") .form-group diff --git a/app/components/app/app.component.js b/app/components/app/app.component.js index 3dca88e..1e00782 100644 --- a/app/components/app/app.component.js +++ b/app/components/app/app.component.js @@ -1,6 +1,8 @@ app.component('app', { templateUrl: 'components/app/app.html', $routeConfig: [ + {path: '/shops', name: 'Shops', component: 'shops'}, + {path: '/shops/add', name: 'AddShop', component: 'addShop'}, {path: '/analytics', name: 'Analytics', component: 'analytics', useAsDefault: true}, {path: '/analytics/...', component: 'analytics'} ] diff --git a/app/components/app/app.module.js b/app/components/app/app.module.js index 8257067..b5329aa 100644 --- a/app/components/app/app.module.js +++ b/app/components/app/app.module.js @@ -1,7 +1,7 @@ const app = angular.module('app', [ 'ngComponentRouter', + 'shops', 'analytics', - // 'dashboard', 'finance', 'sidebar', 'topPanel', diff --git a/app/components/shops/add/add-shop.component.js b/app/components/shops/add/add-shop.component.js new file mode 100644 index 0000000..8499da4 --- /dev/null +++ b/app/components/shops/add/add-shop.component.js @@ -0,0 +1,23 @@ +shops.component('addShop', { + templateUrl: 'components/shops/add/add-shop.template.html', + bindings: { + $router: '<' + }, + controller: function (Shops) { + this.args = {}; + this.isLoading = false; + + this.create = (form) => { + if (form.$valid) { + this.isLoading = true; + Shops.save(this.args, () => { + this.args = {}; + this.isLoading = false; + this.$router.navigate(['Shops']); + }); + } + }; + + this.hasError = field => field.$dirty && field.$invalid; + } +}); diff --git a/app/components/shops/add/add-shop.template.pug b/app/components/shops/add/add-shop.template.pug new file mode 100644 index 0000000..b3923fe --- /dev/null +++ b/app/components/shops/add/add-shop.template.pug @@ -0,0 +1,45 @@ +.row + .col-md-12 + .x_panel.tile + .x_title + h4 Добавление нового магазина + .x_content + loading(is-loading="$ctrl.isLoading") + form.form-horizontal.form-label-left.css-form(novalidate name="form") + .row + .col-md-12 + .form-group(ng-class="{'has-error': $ctrl.hasError(form.shopDetails)}") + label.control-label.col-md-3 Название магазина * + .col-md-6 + input.form-control(type="text" ng-model="$ctrl.args.shopDetails.name" name="shopDetails" required) + .form-group + label.control-label.col-md-3 Описание магазина + .col-md-6 + input.form-control(type="text" ng-model="$ctrl.args.shopDetails.description") + .form-group + label.control-label.col-md-3 Месторасположение + .col-md-6 + input.form-control(type="text" ng-model="$ctrl.args.shopDetails.location") + + .form-group(ng-class="{'has-error': $ctrl.hasError(form.contractor)}") + label.control-label.col-md-3 registeredName * + .col-md-6 + input.form-control(type="text" ng-model="$ctrl.args.contractor.registeredName" name="contractor" required) + .form-group + label.control-label.col-md-3 legalEntity + .col-md-6 + input.form-control(type="text" ng-model="$ctrl.args.contractor.legalEntity") + + .form-group(ng-class="{'has-error': $ctrl.hasError(form.category)}") + label.control-label.col-md-3 name * + .col-md-6 + input.form-control(type="text" ng-model="$ctrl.args.category.name" name="category" required) + .form-group + label.control-label.col-md-3 description + .col-md-6 + input.form-control(type="text" ng-model="$ctrl.args.category.description") + .ln_solid + .form-group + .col-md-6.col-md-offset-3 + button.btn.btn-primary(type="submit" ng-click="$ctrl.create(form)" ng-disabled="form.$invalid") Создать заявку + a.btn.btn-default.pull-right(type="reset" ng-link="['\Shops\']") Отмена diff --git a/app/components/shops/shops.component.js b/app/components/shops/shops.component.js new file mode 100644 index 0000000..e5952cd --- /dev/null +++ b/app/components/shops/shops.component.js @@ -0,0 +1,5 @@ +shops.component('shops', { + templateUrl: 'components/shops/shops.template.html', + controller: function () { + } +}); diff --git a/app/components/shops/shops.module.js b/app/components/shops/shops.module.js new file mode 100644 index 0000000..6d7ed92 --- /dev/null +++ b/app/components/shops/shops.module.js @@ -0,0 +1 @@ +const shops = angular.module('shops', []); diff --git a/app/components/shops/shops.template.pug b/app/components/shops/shops.template.pug new file mode 100644 index 0000000..bc4b873 --- /dev/null +++ b/app/components/shops/shops.template.pug @@ -0,0 +1,7 @@ +.row + .col-md-12 + .x_panel.tile + .x_title + h4 Магазины + .x_content + a.btn.btn-primary(ng-link="['\AddShop\']") Добавить новый магазин \ No newline at end of file diff --git a/app/components/sidebar/sidebar.js b/app/components/sidebar/sidebar.js index 271accf..0163f2b 100644 --- a/app/components/sidebar/sidebar.js +++ b/app/components/sidebar/sidebar.js @@ -8,13 +8,6 @@ sidebar.component('sidebar', { console.log(path); }; - this.isActive = location => { - const cleaned = _.replace(location, '/', ''); - const result = _.chain($location.path()) - .split('/') - .find(item => item === cleaned) - .value(); - return result && result.length > 0; - }; + this.isActive = location => _.includes($location.path(), location); } }); diff --git a/app/components/sidebar/sidebar.pug b/app/components/sidebar/sidebar.pug index ac242ef..df808bf 100644 --- a/app/components/sidebar/sidebar.pug +++ b/app/components/sidebar/sidebar.pug @@ -7,6 +7,14 @@ #sidebar-menu.main_menu_side.hidden-print.main_menu .menu_section ul.nav.side-menu + li(ng-class="{active: $ctrl.isActive('/shops')}") + a(ng-link="['\Shops\']") + i.fa.fa-shopping-cart + | Мои магазины + span.fa.fa-chevron-down + ul.nav.child_menu(style="display: block") + li(ng-class="{active: $ctrl.isActive('/shops/add')}") + a(ng-link="['\AddShop\']") Создать магазин li(ng-class="{active: $ctrl.isActive('/analytics')}") a(ng-link="['\Analytics\']") i.fa.fa-bar-chart-o diff --git a/app/index.pug b/app/index.pug index e7d22bd..04cce43 100644 --- a/app/index.pug +++ b/app/index.pug @@ -9,5 +9,5 @@ html(lang="en") body.nav-md app script(src="vendor.min.js") - script(src="https://use.fontawesome.com/a5c70f40dd.js") + //script(src="https://use.fontawesome.com/a5c70f40dd.js") script(src="source.js") diff --git a/app/shared/resources/shops.js b/app/shared/resources/shops.js new file mode 100644 index 0000000..eb552d4 --- /dev/null +++ b/app/shared/resources/shops.js @@ -0,0 +1,3 @@ +resources.factory('Shops', function ($resource, appConfig) { + return $resource(appConfig.capiUrl + 'processing/shops/:shopID'); +}); diff --git a/capi-mock/capi.js b/capi-mock/capi.js index be967b3..f1fffac 100644 --- a/capi-mock/capi.js +++ b/capi-mock/capi.js @@ -19,6 +19,8 @@ app.use((req, res, next) => { router.route('/processing/me').get((req, res) => res.json(me)); +router.route('/processing/shops').post((req, res) => setTimeout(() => res.json("1"), 600)); + router.route('/analytics/shops/THRIFT-SHOP/invoices').get((req, res) => setTimeout(() => res.json(invoices), 300)); router.route('/analytics/shops/THRIFT-SHOP/payments/stats/revenue').get((req, res) => setTimeout(() => res.json(revenue), 0)); From 7f2bd1bf06833377f8f35e5c80113cdb1094e88a Mon Sep 17 00:00:00 2001 From: Ildar Galeev Date: Tue, 27 Sep 2016 18:23:21 +0300 Subject: [PATCH 07/13] FE-38: Added edit shop functionality --- .../analytics/analytics.component.js | 9 +++- app/components/app/app.component.js | 3 +- .../shops/add/add-shop.component.js | 23 ---------- .../shops/claim-form/claim-form.component.js | 46 +++++++++++++++++++ .../claim-form.template.pug} | 11 +++-- app/components/shops/shops.component.js | 7 ++- app/components/shops/shops.template.pug | 18 ++++++++ app/components/sidebar/sidebar.pug | 16 +++---- app/index.pug | 2 +- capi-mock/capi.js | 2 + 10 files changed, 96 insertions(+), 41 deletions(-) delete mode 100644 app/components/shops/add/add-shop.component.js create mode 100644 app/components/shops/claim-form/claim-form.component.js rename app/components/shops/{add/add-shop.template.pug => claim-form/claim-form.template.pug} (87%) diff --git a/app/components/analytics/analytics.component.js b/app/components/analytics/analytics.component.js index 40697e5..467671b 100644 --- a/app/components/analytics/analytics.component.js +++ b/app/components/analytics/analytics.component.js @@ -9,13 +9,13 @@ dashboard.component('analytics', { }, controller: function (Parties, $location) { this.$routerOnActivate = () => { - const path = $location.path(); - this.selectedShopId = findParam(path, 'analytics'); Parties.get(party => { this.shopsDetails = _.map(party.shops, shop => ({ name: shop.shopDetails.name, key: shop.shopID })); + this.selectedShopId = resolveShopId(party.shops); + this.onSelect(); }); }; @@ -27,6 +27,11 @@ dashboard.component('analytics', { return res !== marker ? res : null; } + function resolveShopId(shops) { + const path = $location.path(); + return shops.length > 0 ? shops[0].shopID : findParam(path, 'analytics'); + } + this.onSelect = () => { this.$router.navigate(['Dashboard', {shopId: this.selectedShopId}]); }; diff --git a/app/components/app/app.component.js b/app/components/app/app.component.js index 1e00782..4e65e17 100644 --- a/app/components/app/app.component.js +++ b/app/components/app/app.component.js @@ -2,7 +2,8 @@ app.component('app', { templateUrl: 'components/app/app.html', $routeConfig: [ {path: '/shops', name: 'Shops', component: 'shops'}, - {path: '/shops/add', name: 'AddShop', component: 'addShop'}, + {path: '/shops/add', name: 'AddShop', component: 'claimForm'}, + {path: '/shops/edit/:shopId', name: 'EditShop', component: 'claimForm'}, {path: '/analytics', name: 'Analytics', component: 'analytics', useAsDefault: true}, {path: '/analytics/...', component: 'analytics'} ] diff --git a/app/components/shops/add/add-shop.component.js b/app/components/shops/add/add-shop.component.js deleted file mode 100644 index 8499da4..0000000 --- a/app/components/shops/add/add-shop.component.js +++ /dev/null @@ -1,23 +0,0 @@ -shops.component('addShop', { - templateUrl: 'components/shops/add/add-shop.template.html', - bindings: { - $router: '<' - }, - controller: function (Shops) { - this.args = {}; - this.isLoading = false; - - this.create = (form) => { - if (form.$valid) { - this.isLoading = true; - Shops.save(this.args, () => { - this.args = {}; - this.isLoading = false; - this.$router.navigate(['Shops']); - }); - } - }; - - this.hasError = field => field.$dirty && field.$invalid; - } -}); diff --git a/app/components/shops/claim-form/claim-form.component.js b/app/components/shops/claim-form/claim-form.component.js new file mode 100644 index 0000000..e2e0159 --- /dev/null +++ b/app/components/shops/claim-form/claim-form.component.js @@ -0,0 +1,46 @@ +shops.component('claimForm', { + templateUrl: 'components/shops/claim-form/claim-form.template.html', + bindings: { + $router: '<' + }, + controller: function (Shops, Parties) { + this.args = {}; + this.isLoading = false; + + this.$routerOnActivate = route => { + this.mode = route.params.shopId ? 'edit' : 'add'; + if (this.mode === 'edit') { + this.shopID = route.params.shopId; + Parties.get(party => { + const shop = _.find(party.shops, shop => shop.shopID === this.shopID); + this.args.shopDetails = shop.shopDetails; + this.args.contractor = shop.contractor; + }); + } + }; + + const back = () => { + this.args = {}; + this.isLoading = false; + this.$router.navigate(['Shops']); + }; + + this.createClaim = form => { + if (form.$valid) { + this.isLoading = true; + if (this.mode === 'add') { + Shops.save(this.args, () => { + back(); + }); + } else if (this.mode === 'edit') { + const shops = new Shops(this.args); + shops.$save({shopID: this.shopID}, () => { + back(); + }); + } + } + }; + + this.hasError = field => field.$dirty && field.$invalid; + } +}); diff --git a/app/components/shops/add/add-shop.template.pug b/app/components/shops/claim-form/claim-form.template.pug similarity index 87% rename from app/components/shops/add/add-shop.template.pug rename to app/components/shops/claim-form/claim-form.template.pug index b3923fe..f4f64ac 100644 --- a/app/components/shops/add/add-shop.template.pug +++ b/app/components/shops/claim-form/claim-form.template.pug @@ -2,7 +2,8 @@ .col-md-12 .x_panel.tile .x_title - h4 Добавление нового магазина + h4(ng-if="$ctrl.mode === 'edit'") Изменение данных магазина + h4(ng-if="$ctrl.mode === 'add'") Добавление нового магазина .x_content loading(is-loading="$ctrl.isLoading") form.form-horizontal.form-label-left.css-form(novalidate name="form") @@ -30,10 +31,10 @@ .col-md-6 input.form-control(type="text" ng-model="$ctrl.args.contractor.legalEntity") - .form-group(ng-class="{'has-error': $ctrl.hasError(form.category)}") - label.control-label.col-md-3 name * + .form-group + label.control-label.col-md-3 name .col-md-6 - input.form-control(type="text" ng-model="$ctrl.args.category.name" name="category" required) + input.form-control(type="text" ng-model="$ctrl.args.category.name") .form-group label.control-label.col-md-3 description .col-md-6 @@ -41,5 +42,5 @@ .ln_solid .form-group .col-md-6.col-md-offset-3 - button.btn.btn-primary(type="submit" ng-click="$ctrl.create(form)" ng-disabled="form.$invalid") Создать заявку + button.btn.btn-primary(type="submit" ng-click="$ctrl.createClaim(form)" ng-disabled="form.$invalid") Создать заявку a.btn.btn-default.pull-right(type="reset" ng-link="['\Shops\']") Отмена diff --git a/app/components/shops/shops.component.js b/app/components/shops/shops.component.js index e5952cd..d5cb745 100644 --- a/app/components/shops/shops.component.js +++ b/app/components/shops/shops.component.js @@ -1,5 +1,10 @@ shops.component('shops', { templateUrl: 'components/shops/shops.template.html', - controller: function () { + controller: function (Parties) { + this.$routerOnActivate = () => { + Parties.get(party => { + this.shops = party.shops; + }); + } } }); diff --git a/app/components/shops/shops.template.pug b/app/components/shops/shops.template.pug index bc4b873..81704a7 100644 --- a/app/components/shops/shops.template.pug +++ b/app/components/shops/shops.template.pug @@ -4,4 +4,22 @@ .x_title h4 Магазины .x_content + .row + .col-md-12 + table.table.table-hover.table-striped + thead + tr + th Название магазина + th Описание + th Месторасположение + th registeredName + th + tbody + tr(ng-repeat="shop in $ctrl.shops") + td {{shop.shopDetails.name}} + td {{shop.shopDetails.description}} + td {{shop.shopDetails.location}} + td {{shop.contractor.registeredName}} + td + a.btn.btn-default.btn-xs(ng-link="['\EditShop\', {shopId: shop.shopID}]") Изменить данные a.btn.btn-primary(ng-link="['\AddShop\']") Добавить новый магазин \ No newline at end of file diff --git a/app/components/sidebar/sidebar.pug b/app/components/sidebar/sidebar.pug index df808bf..f6d2ef5 100644 --- a/app/components/sidebar/sidebar.pug +++ b/app/components/sidebar/sidebar.pug @@ -7,15 +7,15 @@ #sidebar-menu.main_menu_side.hidden-print.main_menu .menu_section ul.nav.side-menu - li(ng-class="{active: $ctrl.isActive('/shops')}") - a(ng-link="['\Shops\']") - i.fa.fa-shopping-cart - | Мои магазины - span.fa.fa-chevron-down - ul.nav.child_menu(style="display: block") - li(ng-class="{active: $ctrl.isActive('/shops/add')}") - a(ng-link="['\AddShop\']") Создать магазин li(ng-class="{active: $ctrl.isActive('/analytics')}") a(ng-link="['\Analytics\']") i.fa.fa-bar-chart-o | Аналитика + li(ng-class="{active: $ctrl.isActive('/shops')}") + a(ng-link="['\Shops\']") + i.fa.fa-shopping-cart + | Мои магазины + //span.fa.fa-chevron-down + //ul.nav.child_menu(style="display: block") + // li(ng-class="{active: $ctrl.isActive('/shops/add')}") + // a(ng-link="['\AddShop\']") Создать магазин diff --git a/app/index.pug b/app/index.pug index 04cce43..e7d22bd 100644 --- a/app/index.pug +++ b/app/index.pug @@ -9,5 +9,5 @@ html(lang="en") body.nav-md app script(src="vendor.min.js") - //script(src="https://use.fontawesome.com/a5c70f40dd.js") + script(src="https://use.fontawesome.com/a5c70f40dd.js") script(src="source.js") diff --git a/capi-mock/capi.js b/capi-mock/capi.js index f1fffac..690af7b 100644 --- a/capi-mock/capi.js +++ b/capi-mock/capi.js @@ -21,6 +21,8 @@ router.route('/processing/me').get((req, res) => res.json(me)); router.route('/processing/shops').post((req, res) => setTimeout(() => res.json("1"), 600)); +router.route('/processing/shops/THRIFT-SHOP').post((req, res) => setTimeout(() => res.json("2"), 600)); + router.route('/analytics/shops/THRIFT-SHOP/invoices').get((req, res) => setTimeout(() => res.json(invoices), 300)); router.route('/analytics/shops/THRIFT-SHOP/payments/stats/revenue').get((req, res) => setTimeout(() => res.json(revenue), 0)); From b15ecfcc2c0471fbc2ed5972471071447faa8199 Mon Sep 17 00:00:00 2001 From: Ildar Galeev Date: Tue, 27 Sep 2016 21:14:23 +0300 Subject: [PATCH 08/13] FE-38: Added claims mock and resources --- app/components/app/app-config.js | 3 +- .../shops/claim-form/claim-form.component.js | 2 + app/components/shops/claims/claim-statuses.js | 5 +++ .../shops/claims/claims.component.js | 14 +++++++ .../shops/claims/claims.template.pug | 9 +++++ app/components/shops/shops.component.js | 3 ++ app/components/shops/shops.template.pug | 40 +++++++++++-------- app/shared/resources/claims.js | 7 ++++ capi-mock/capi.js | 7 +++- capi-mock/claims.js | 13 ++++++ 10 files changed, 84 insertions(+), 19 deletions(-) create mode 100644 app/components/shops/claims/claim-statuses.js create mode 100644 app/components/shops/claims/claims.component.js create mode 100644 app/components/shops/claims/claims.template.pug create mode 100644 app/shared/resources/claims.js create mode 100644 capi-mock/claims.js diff --git a/app/components/app/app-config.js b/app/components/app/app-config.js index 90e8b76..57835f1 100644 --- a/app/components/app/app-config.js +++ b/app/components/app/app-config.js @@ -4,6 +4,5 @@ // }); app.constant('appConfig', { - capiUrl: 'http://localhost:9000/v1/', - shopID: 'THRIFT-SHOP' + capiUrl: 'http://localhost:9000/v1/' }); diff --git a/app/components/shops/claim-form/claim-form.component.js b/app/components/shops/claim-form/claim-form.component.js index e2e0159..a33bd15 100644 --- a/app/components/shops/claim-form/claim-form.component.js +++ b/app/components/shops/claim-form/claim-form.component.js @@ -10,8 +10,10 @@ shops.component('claimForm', { this.$routerOnActivate = route => { this.mode = route.params.shopId ? 'edit' : 'add'; if (this.mode === 'edit') { + this.isLoading = true; this.shopID = route.params.shopId; Parties.get(party => { + this.isLoading = false; const shop = _.find(party.shops, shop => shop.shopID === this.shopID); this.args.shopDetails = shop.shopDetails; this.args.contractor = shop.contractor; diff --git a/app/components/shops/claims/claim-statuses.js b/app/components/shops/claims/claim-statuses.js new file mode 100644 index 0000000..ab45ae1 --- /dev/null +++ b/app/components/shops/claims/claim-statuses.js @@ -0,0 +1,5 @@ +shops.constant('CLAIM_STATUSES', { + pending: 'pending', + approved: 'approved', + denied: 'denied' +}); diff --git a/app/components/shops/claims/claims.component.js b/app/components/shops/claims/claims.component.js new file mode 100644 index 0000000..76bc55f --- /dev/null +++ b/app/components/shops/claims/claims.component.js @@ -0,0 +1,14 @@ +shops.component('claims', { + templateUrl: 'components/shops/claims/claims.template.html', + controller: function (Claims) { + Claims.get({claimStatus: 'pending'}, claim => { + this.claimID = claim.id; + this.status = claim.status; + }); + + this.revoke = () => { + const claims = new Claims(); + claims.$revoke({claimID: this.claimID}); + }; + } +}); diff --git a/app/components/shops/claims/claims.template.pug b/app/components/shops/claims/claims.template.pug new file mode 100644 index 0000000..7156745 --- /dev/null +++ b/app/components/shops/claims/claims.template.pug @@ -0,0 +1,9 @@ +.accordion#accordion(role="tablist" aria-multiselectable="true") + .panel + a.panel-heading.collapsed#headingOne(role="tab" data-toggle="collapse" data-parent="#accordion" href="#collapseOne" aria-expanded="false" aria-controls="collapseOne") + .panel-title {{$ctrl.status.status}} + .panel-collapse.collapse.in#collapseOne(role="tabpanel" aria-labelledby="headingOne") + .panel-body + .row + .col-md-12 + button.btn.btn-danger(ng-click="$ctrl.revoke()") Отменить заявку diff --git a/app/components/shops/shops.component.js b/app/components/shops/shops.component.js index d5cb745..d4cbad9 100644 --- a/app/components/shops/shops.component.js +++ b/app/components/shops/shops.component.js @@ -1,8 +1,11 @@ shops.component('shops', { templateUrl: 'components/shops/shops.template.html', controller: function (Parties) { + this.isLoading = true; + this.$routerOnActivate = () => { Parties.get(party => { + this.isLoading = false; this.shops = party.shops; }); } diff --git a/app/components/shops/shops.template.pug b/app/components/shops/shops.template.pug index 81704a7..4b90a83 100644 --- a/app/components/shops/shops.template.pug +++ b/app/components/shops/shops.template.pug @@ -1,3 +1,10 @@ +.row + .col-md-12 + .x_panel.tile + .x_title + h4 Заявки + .x_content + claims .row .col-md-12 .x_panel.tile @@ -6,20 +13,21 @@ .x_content .row .col-md-12 - table.table.table-hover.table-striped - thead - tr - th Название магазина - th Описание - th Месторасположение - th registeredName - th - tbody - tr(ng-repeat="shop in $ctrl.shops") - td {{shop.shopDetails.name}} - td {{shop.shopDetails.description}} - td {{shop.shopDetails.location}} - td {{shop.contractor.registeredName}} - td - a.btn.btn-default.btn-xs(ng-link="['\EditShop\', {shopId: shop.shopID}]") Изменить данные + loading(is-loading="$ctrl.isLoading") + table.table.table-hover.table-striped + thead + tr + th Название магазина + th Описание + th Месторасположение + th registeredName + th + tbody + tr(ng-repeat="shop in $ctrl.shops") + td {{shop.shopDetails.name}} + td {{shop.shopDetails.description}} + td {{shop.shopDetails.location}} + td {{shop.contractor.registeredName}} + td + a.btn.btn-default.btn-xs(ng-link="['\EditShop\', {shopId: shop.shopID}]") Изменить данные a.btn.btn-primary(ng-link="['\AddShop\']") Добавить новый магазин \ No newline at end of file diff --git a/app/shared/resources/claims.js b/app/shared/resources/claims.js new file mode 100644 index 0000000..8e64c4b --- /dev/null +++ b/app/shared/resources/claims.js @@ -0,0 +1,7 @@ +resources.factory('Claims', function ($resource, appConfig) { + return $resource(`${appConfig.capiUrl}processing/claims/:claimID/:action`, { + claimID: '@claimID' + }, { + revoke: {method: 'POST', params: {action: 'revoke'}} + }); +}); diff --git a/capi-mock/capi.js b/capi-mock/capi.js index 690af7b..04f0e2b 100644 --- a/capi-mock/capi.js +++ b/capi-mock/capi.js @@ -10,6 +10,7 @@ const conversion = require('./conversion'); const geo = require('./geo'); const rate = require('./rate'); const me = require('./me'); +const claims = require('./claims'); app.use((req, res, next) => { res.header('Access-Control-Allow-Origin', '*'); @@ -17,12 +18,16 @@ app.use((req, res, next) => { next(); }); -router.route('/processing/me').get((req, res) => res.json(me)); +router.route('/processing/me').get((req, res) => setTimeout(() => res.json(me), 600)); router.route('/processing/shops').post((req, res) => setTimeout(() => res.json("1"), 600)); router.route('/processing/shops/THRIFT-SHOP').post((req, res) => setTimeout(() => res.json("2"), 600)); +router.route('/processing/claims').get((req, res) => setTimeout(() => res.json(claims), 0)); + +router.route('/processing/claims/1/revoke').post((req, res) => setTimeout(() => res.json(), 0)); + router.route('/analytics/shops/THRIFT-SHOP/invoices').get((req, res) => setTimeout(() => res.json(invoices), 300)); router.route('/analytics/shops/THRIFT-SHOP/payments/stats/revenue').get((req, res) => setTimeout(() => res.json(revenue), 0)); diff --git a/capi-mock/claims.js b/capi-mock/claims.js new file mode 100644 index 0000000..e7fe67a --- /dev/null +++ b/capi-mock/claims.js @@ -0,0 +1,13 @@ +var claimStatus = { + status: 'pending' +}; + +var partyModification = { + modificationType: '' +}; + +module.exports = { + id: '1', + status: claimStatus, + changeset: [partyModification] +}; From 801ec58030a5a5b89325024a3fc15f2613adbf96 Mon Sep 17 00:00:00 2001 From: Ildar Galeev Date: Wed, 28 Sep 2016 19:32:54 +0300 Subject: [PATCH 09/13] FE-38: Added claims revoke functionality --- app/assets/styles.less | 4 ++ .../shops/claim-form/claim-form.component.js | 10 ++-- .../shops/claim-form/claim-form.template.pug | 13 +---- .../shops/claims/claims.component.js | 9 +++- .../shops/claims/claims.template.pug | 30 +++++++---- .../modification-detail.component.js | 11 ++++ .../shop-creation/shop-creation.component.js | 12 +++++ .../shop-creation/shop-creation.template.pug | 12 +++++ .../shop-modification.component.js | 13 +++++ .../shop-modification.template.pug | 12 +++++ app/components/shops/shops.template.pug | 12 ++--- app/components/sidebar/sidebar.pug | 4 -- capi-mock/capi.js | 2 + capi-mock/claims.js | 29 +++++++++-- capi-mock/me.js | 50 +------------------ capi-mock/shops.js | 45 +++++++++++++++++ 16 files changed, 175 insertions(+), 93 deletions(-) create mode 100644 app/components/shops/claims/modification-detail/modification-detail.component.js create mode 100644 app/components/shops/claims/shop-creation/shop-creation.component.js create mode 100644 app/components/shops/claims/shop-creation/shop-creation.template.pug create mode 100644 app/components/shops/claims/shop-modification/shop-modification.component.js create mode 100644 app/components/shops/claims/shop-modification/shop-modification.template.pug create mode 100644 capi-mock/shops.js diff --git a/app/assets/styles.less b/app/assets/styles.less index 6d051af..25229c7 100644 --- a/app/assets/styles.less +++ b/app/assets/styles.less @@ -47,3 +47,7 @@ width: 100% !important; font-size: 40px !important; } + +.custom-chevron { + margin-top: 3px; +} diff --git a/app/components/shops/claim-form/claim-form.component.js b/app/components/shops/claim-form/claim-form.component.js index a33bd15..0b0059a 100644 --- a/app/components/shops/claim-form/claim-form.component.js +++ b/app/components/shops/claim-form/claim-form.component.js @@ -30,15 +30,11 @@ shops.component('claimForm', { this.createClaim = form => { if (form.$valid) { this.isLoading = true; + const shops = new Shops(this.args); if (this.mode === 'add') { - Shops.save(this.args, () => { - back(); - }); + shops.$save(() => back()); } else if (this.mode === 'edit') { - const shops = new Shops(this.args); - shops.$save({shopID: this.shopID}, () => { - back(); - }); + shops.$save({shopID: this.shopID}, () => back()); } } }; diff --git a/app/components/shops/claim-form/claim-form.template.pug b/app/components/shops/claim-form/claim-form.template.pug index f4f64ac..99c3c64 100644 --- a/app/components/shops/claim-form/claim-form.template.pug +++ b/app/components/shops/claim-form/claim-form.template.pug @@ -23,22 +23,13 @@ input.form-control(type="text" ng-model="$ctrl.args.shopDetails.location") .form-group(ng-class="{'has-error': $ctrl.hasError(form.contractor)}") - label.control-label.col-md-3 registeredName * + label.control-label.col-md-3 Наименование организации * .col-md-6 input.form-control(type="text" ng-model="$ctrl.args.contractor.registeredName" name="contractor" required) .form-group - label.control-label.col-md-3 legalEntity + label.control-label.col-md-3 Тип юридического лица .col-md-6 input.form-control(type="text" ng-model="$ctrl.args.contractor.legalEntity") - - .form-group - label.control-label.col-md-3 name - .col-md-6 - input.form-control(type="text" ng-model="$ctrl.args.category.name") - .form-group - label.control-label.col-md-3 description - .col-md-6 - input.form-control(type="text" ng-model="$ctrl.args.category.description") .ln_solid .form-group .col-md-6.col-md-offset-3 diff --git a/app/components/shops/claims/claims.component.js b/app/components/shops/claims/claims.component.js index 76bc55f..8992f06 100644 --- a/app/components/shops/claims/claims.component.js +++ b/app/components/shops/claims/claims.component.js @@ -1,14 +1,19 @@ shops.component('claims', { templateUrl: 'components/shops/claims/claims.template.html', controller: function (Claims) { + this.showClaimInfo = false; + Claims.get({claimStatus: 'pending'}, claim => { this.claimID = claim.id; - this.status = claim.status; + this.showClaimInfo = true; + this.changeset = claim.changeset; }); this.revoke = () => { const claims = new Claims(); - claims.$revoke({claimID: this.claimID}); + claims.$revoke({claimID: this.claimID}, () => { + this.showClaimInfo = false; + }); }; } }); diff --git a/app/components/shops/claims/claims.template.pug b/app/components/shops/claims/claims.template.pug index 7156745..4899d29 100644 --- a/app/components/shops/claims/claims.template.pug +++ b/app/components/shops/claims/claims.template.pug @@ -1,9 +1,21 @@ -.accordion#accordion(role="tablist" aria-multiselectable="true") - .panel - a.panel-heading.collapsed#headingOne(role="tab" data-toggle="collapse" data-parent="#accordion" href="#collapseOne" aria-expanded="false" aria-controls="collapseOne") - .panel-title {{$ctrl.status.status}} - .panel-collapse.collapse.in#collapseOne(role="tabpanel" aria-labelledby="headingOne") - .panel-body - .row - .col-md-12 - button.btn.btn-danger(ng-click="$ctrl.revoke()") Отменить заявку +.x_panel.tile(ng-if="$ctrl.showClaimInfo") + .x_title + h4 Активная заявка + .x_content + .row(ng-repeat="set in $ctrl.changeset") + shop-creation(ng-if="set.modificationType == 'ShopCreation'" changeset="set") + shop-modification(ng-if="set.modificationType == 'ShopModificationUnit'" 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 + h4.modal-title Подтверждение + .modal-body Отменить заявку? + .modal-footer + .btn-toolbar.pull-right + .btn-group.btn-group-sm + button.btn.btn-default(type="button" data-dismiss="modal") Назад + .btn-group.btn-group-sm + button.btn.btn-danger(type="button" data-dismiss="modal" ng-click="$ctrl.revoke()") Отменить заявку \ No newline at end of file diff --git a/app/components/shops/claims/modification-detail/modification-detail.component.js b/app/components/shops/claims/modification-detail/modification-detail.component.js new file mode 100644 index 0000000..25de8a7 --- /dev/null +++ b/app/components/shops/claims/modification-detail/modification-detail.component.js @@ -0,0 +1,11 @@ +shops.component('modificationDetail', { + template: ` +
+
{{$ctrl.displayName}}
+
{{$ctrl.value}}
+
`, + bindings: { + displayName: '<', + value: '<' + } +}); diff --git a/app/components/shops/claims/shop-creation/shop-creation.component.js b/app/components/shops/claims/shop-creation/shop-creation.component.js new file mode 100644 index 0000000..723fcc7 --- /dev/null +++ b/app/components/shops/claims/shop-creation/shop-creation.component.js @@ -0,0 +1,12 @@ +shops.component('shopCreation', { + templateUrl: 'components/shops/claims/shop-creation/shop-creation.template.html', + bindings: { + changeset: '<' + }, + controller: function () { + this.showPanel = false; + + this.show = () => this.showPanel = !this.showPanel; + this.shop = this.changeset.shop; + } +}); diff --git a/app/components/shops/claims/shop-creation/shop-creation.template.pug b/app/components/shops/claims/shop-creation/shop-creation.template.pug new file mode 100644 index 0000000..06ecfea --- /dev/null +++ b/app/components/shops/claims/shop-creation/shop-creation.template.pug @@ -0,0 +1,12 @@ +.panel.panel-default + .panel-heading(ng-click="$ctrl.show()") + a(href="#") Создание магазина: {{$ctrl.shop.shopDetails.name}} + i.fa.pull-right.custom-chevron(ng-class="{'fa-chevron-down': $ctrl.showPanel, 'fa-chevron-right': !$ctrl.showPanel}") + .panel-body(ng-show="$ctrl.showPanel") + div(ng-show="$ctrl.shop.shopDetails") + modification-detail(display-name="'Название магазина'" value="$ctrl.shop.shopDetails.name") + modification-detail(display-name="'Описание'" value="$ctrl.shop.shopDetails.description") + modification-detail(display-name="'Месторасположение'" value="$ctrl.shop.shopDetails.location") + div(ng-show="$ctrl.shop.contractor") + modification-detail(display-name="'Наименование организации'" value="$ctrl.shop.contractor.registeredName") + modification-detail(display-name="'Тип юридического лица'" value="$ctrl.shop.contractor.legalEntity") diff --git a/app/components/shops/claims/shop-modification/shop-modification.component.js b/app/components/shops/claims/shop-modification/shop-modification.component.js new file mode 100644 index 0000000..538ff8a --- /dev/null +++ b/app/components/shops/claims/shop-modification/shop-modification.component.js @@ -0,0 +1,13 @@ +shops.component('shopModification', { + templateUrl: 'components/shops/claims/shop-modification/shop-modification.template.html', + bindings: { + changeset: '<' + }, + controller: function () { + this.showPanel = false; + this.isModification = this.changeset.details.modificationType === 'ShopModification'; + this.details = this.changeset.details.details; + + this.show = () => this.showPanel = !this.showPanel; + } +}); diff --git a/app/components/shops/claims/shop-modification/shop-modification.template.pug b/app/components/shops/claims/shop-modification/shop-modification.template.pug new file mode 100644 index 0000000..7a93d55 --- /dev/null +++ b/app/components/shops/claims/shop-modification/shop-modification.template.pug @@ -0,0 +1,12 @@ +.panel.panel-default + .panel-heading(ng-click="$ctrl.show()") + a(href="#") Изменение магазина + i.fa.pull-right.custom-chevron(ng-class="{'fa-chevron-down': $ctrl.showPanel, 'fa-chevron-right': !$ctrl.showPanel}") + .panel-body(ng-show="$ctrl.showPanel") + div(ng-show="$ctrl.details.shopDetails") + modification-detail(display-name="'Название магазина'" value="$ctrl.details.shopDetails.name") + modification-detail(display-name="'Описание'" value="$ctrl.details.shopDetails.description") + modification-detail(display-name="'Месторасположение'" value="$ctrl.details.shopDetails.location") + div(ng-show="$ctrl.details.contractor") + modification-detail(display-name="'Наименование организации'" value="$ctrl.details.contractor.registeredName") + modification-detail(display-name="'Тип юридического лица'" value="$ctrl.details.contractor.legalEntity") diff --git a/app/components/shops/shops.template.pug b/app/components/shops/shops.template.pug index 4b90a83..f6db038 100644 --- a/app/components/shops/shops.template.pug +++ b/app/components/shops/shops.template.pug @@ -1,10 +1,6 @@ .row .col-md-12 - .x_panel.tile - .x_title - h4 Заявки - .x_content - claims + claims .row .col-md-12 .x_panel.tile @@ -20,14 +16,12 @@ th Название магазина th Описание th Месторасположение - th registeredName th tbody tr(ng-repeat="shop in $ctrl.shops") td {{shop.shopDetails.name}} td {{shop.shopDetails.description}} td {{shop.shopDetails.location}} - td {{shop.contractor.registeredName}} td - a.btn.btn-default.btn-xs(ng-link="['\EditShop\', {shopId: shop.shopID}]") Изменить данные - a.btn.btn-primary(ng-link="['\AddShop\']") Добавить новый магазин \ No newline at end of file + a.btn.btn-default.btn-xs.pull-right(ng-link="['\EditShop\', {shopId: shop.shopID}]") Изменить данные + a.btn.btn-primary.pull-right(ng-link="['\AddShop\']") Добавить новый магазин \ No newline at end of file diff --git a/app/components/sidebar/sidebar.pug b/app/components/sidebar/sidebar.pug index f6d2ef5..b5c3cd6 100644 --- a/app/components/sidebar/sidebar.pug +++ b/app/components/sidebar/sidebar.pug @@ -15,7 +15,3 @@ a(ng-link="['\Shops\']") i.fa.fa-shopping-cart | Мои магазины - //span.fa.fa-chevron-down - //ul.nav.child_menu(style="display: block") - // li(ng-class="{active: $ctrl.isActive('/shops/add')}") - // a(ng-link="['\AddShop\']") Создать магазин diff --git a/capi-mock/capi.js b/capi-mock/capi.js index 04f0e2b..e18f949 100644 --- a/capi-mock/capi.js +++ b/capi-mock/capi.js @@ -26,6 +26,8 @@ router.route('/processing/shops/THRIFT-SHOP').post((req, res) => setTimeout(() = router.route('/processing/claims').get((req, res) => setTimeout(() => res.json(claims), 0)); +// router.route('/processing/claims').get((req, res) => res.status(404).send('Not found')); + router.route('/processing/claims/1/revoke').post((req, res) => setTimeout(() => res.json(), 0)); router.route('/analytics/shops/THRIFT-SHOP/invoices').get((req, res) => setTimeout(() => res.json(invoices), 300)); diff --git a/capi-mock/claims.js b/capi-mock/claims.js index e7fe67a..753f8d6 100644 --- a/capi-mock/claims.js +++ b/capi-mock/claims.js @@ -1,13 +1,36 @@ +const shops = require('./shops'); + var claimStatus = { status: 'pending' }; -var partyModification = { - modificationType: '' +var shopCreation = { + modificationType: 'ShopCreation', + shop: shops[0] +}; + +var shopModification = { + modificationType: 'ShopModificationUnit', + shopID: 'THRIFT-SHOP', + details: { + modificationType: 'ShopModification', + details: { + shopDetails : { + name: 'Test name', + description: 'Test description', + location: 'Moscow' + }, + contractor: { + registeredName: 'Registered test name', + legalEntity: 'Legal entity' + }, + categoryRef: '1' + } + } }; module.exports = { id: '1', status: claimStatus, - changeset: [partyModification] + changeset: [shopCreation, shopModification] }; diff --git a/capi-mock/me.js b/capi-mock/me.js index 82a2915..2b0976f 100644 --- a/capi-mock/me.js +++ b/capi-mock/me.js @@ -1,54 +1,8 @@ -var shop1 = { - shopID: 'THRIFT-SHOP', - isBlocked: false, - isSuspended: false, - categoryRef: 1, - shopDetails: { - name: 'Shop 1', - description: 'shop 1 description', - location: 'Moscow' - }, - contractor: { - registeredName: 'Registered name', - legalEntity: 'legalEntity' - }, - contract: { - number: '2341', - systemContractorRef: '34564', - concludedAt: 'concludedAt', - validSince: 'validSince', - validUntil: 'validUntil', - terminatedAt: 'terminatedAt' - } -}; - -var shop2 = { - shopID: 'THRIFT-SHOP2', - isBlocked: false, - isSuspended: false, - categoryRef: 1, - shopDetails: { - name: 'Shop 2', - description: 'shop 2 description', - location: 'Moscow' - }, - contractor: { - registeredName: 'Registered name', - legalEntity: 'legalEntity' - }, - contract: { - number: '4532', - systemContractorRef: '33422', - concludedAt: 'concludedAt', - validSince: 'validSince', - validUntil: 'validUntil', - terminatedAt: 'terminatedAt' - } -}; +const shops = require('./shops'); module.exports = { partyID: '1', isBlocked: false, isSuspended: false, - shops: [shop1, shop2] + shops: shops }; diff --git a/capi-mock/shops.js b/capi-mock/shops.js new file mode 100644 index 0000000..0d46adb --- /dev/null +++ b/capi-mock/shops.js @@ -0,0 +1,45 @@ +module.exports = [{ + shopID: 'THRIFT-SHOP', + isBlocked: false, + isSuspended: false, + categoryRef: 1, + shopDetails: { + name: 'Shop 1', + description: 'shop 1 description', + location: 'Moscow' + }, + contractor: { + registeredName: 'Registered name', + legalEntity: 'legalEntity' + }, + contract: { + number: '2341', + systemContractorRef: '34564', + concludedAt: 'concludedAt', + validSince: 'validSince', + validUntil: 'validUntil', + terminatedAt: 'terminatedAt' + } +}, { + shopID: 'THRIFT-SHOP2', + isBlocked: false, + isSuspended: false, + categoryRef: 1, + shopDetails: { + name: 'Shop 2', + description: 'shop 2 description', + location: 'Moscow' + }, + contractor: { + registeredName: 'Registered name', + legalEntity: 'legalEntity' + }, + contract: { + number: '4532', + systemContractorRef: '33422', + concludedAt: 'concludedAt', + validSince: 'validSince', + validUntil: 'validUntil', + terminatedAt: 'terminatedAt' + } +}]; From d39c9e09fbe47da0fd4a576a60abf53491eabc65 Mon Sep 17 00:00:00 2001 From: Ildar Galeev Date: Thu, 29 Sep 2016 14:20:51 +0300 Subject: [PATCH 10/13] FE-38: Add edit shop form --- app/components/app/app.component.js | 4 +- .../shops/add-shop/add-shop.component.js | 25 +++++++ .../shops/add-shop/add-shop.template.pug | 34 +++++++++ .../shops/claim-form/claim-form.component.js | 44 ------------ .../shops/claim-form/claim-form.template.pug | 37 ---------- .../shops/edit-shop/edit-shop.component.js | 72 +++++++++++++++++++ .../shops/edit-shop/edit-shop.template.pug | 35 +++++++++ 7 files changed, 168 insertions(+), 83 deletions(-) create mode 100644 app/components/shops/add-shop/add-shop.component.js create mode 100644 app/components/shops/add-shop/add-shop.template.pug delete mode 100644 app/components/shops/claim-form/claim-form.component.js delete mode 100644 app/components/shops/claim-form/claim-form.template.pug create mode 100644 app/components/shops/edit-shop/edit-shop.component.js create mode 100644 app/components/shops/edit-shop/edit-shop.template.pug diff --git a/app/components/app/app.component.js b/app/components/app/app.component.js index 4e65e17..364e61c 100644 --- a/app/components/app/app.component.js +++ b/app/components/app/app.component.js @@ -2,8 +2,8 @@ app.component('app', { templateUrl: 'components/app/app.html', $routeConfig: [ {path: '/shops', name: 'Shops', component: 'shops'}, - {path: '/shops/add', name: 'AddShop', component: 'claimForm'}, - {path: '/shops/edit/:shopId', name: 'EditShop', component: 'claimForm'}, + {path: '/shops/add', name: 'AddShop', component: 'addShop'}, + {path: '/shops/edit/:shopId', name: 'EditShop', component: 'editShop'}, {path: '/analytics', name: 'Analytics', component: 'analytics', useAsDefault: true}, {path: '/analytics/...', component: 'analytics'} ] diff --git a/app/components/shops/add-shop/add-shop.component.js b/app/components/shops/add-shop/add-shop.component.js new file mode 100644 index 0000000..14cb7ae --- /dev/null +++ b/app/components/shops/add-shop/add-shop.component.js @@ -0,0 +1,25 @@ +shops.component('addShop', { + templateUrl: 'components/shops/add-shop/add-shop.template.html', + bindings: { + $router: '<' + }, + controller: function (Shops) { + this.args = {}; + this.isLoading = false; + + const back = () => { + this.args = {}; + this.isLoading = false; + this.$router.navigate(['Shops']); + }; + + this.createClaim = form => { + if (form.$valid) { + this.isLoading = true; + Shops.save(this.args, () => back()); + } + }; + + this.hasError = field => field.$dirty && field.$invalid; + } +}); diff --git a/app/components/shops/add-shop/add-shop.template.pug b/app/components/shops/add-shop/add-shop.template.pug new file mode 100644 index 0000000..0f9334c --- /dev/null +++ b/app/components/shops/add-shop/add-shop.template.pug @@ -0,0 +1,34 @@ +.row + .col-md-12 + .x_panel.tile + .x_title + h4 Добавление нового магазина + .x_content + loading(is-loading="$ctrl.isLoading") + form.form-horizontal.form-label-left.css-form(novalidate name="form") + .form-group(ng-class="{'has-error': $ctrl.hasError(form.shopDetails)}") + label.control-label.col-md-3 Название магазина * + .col-md-6 + input.form-control(type="text" ng-model="$ctrl.args.shopDetails.name" name="shopDetails" required) + .form-group + label.control-label.col-md-3 Описание магазина + .col-md-6 + input.form-control(type="text" ng-model="$ctrl.args.shopDetails.description") + .form-group + label.control-label.col-md-3 Месторасположение + .col-md-6 + input.form-control(type="text" ng-model="$ctrl.args.shopDetails.location") + + .form-group(ng-class="{'has-error': $ctrl.hasError(form.contractor)}") + label.control-label.col-md-3 Наименование организации * + .col-md-6 + input.form-control(type="text" ng-model="$ctrl.args.contractor.registeredName" name="contractor" required) + .form-group + label.control-label.col-md-3 Тип юридического лица + .col-md-6 + input.form-control(type="text" ng-model="$ctrl.args.contractor.legalEntity") + .ln_solid + .form-group + .col-md-6.col-md-offset-3 + button.btn.btn-primary(type="submit" ng-click="$ctrl.createClaim(form)" ng-disabled="form.$invalid") Создать заявку + a.btn.btn-default.pull-right(type="reset" ng-link="['\Shops\']") Отмена diff --git a/app/components/shops/claim-form/claim-form.component.js b/app/components/shops/claim-form/claim-form.component.js deleted file mode 100644 index 0b0059a..0000000 --- a/app/components/shops/claim-form/claim-form.component.js +++ /dev/null @@ -1,44 +0,0 @@ -shops.component('claimForm', { - templateUrl: 'components/shops/claim-form/claim-form.template.html', - bindings: { - $router: '<' - }, - controller: function (Shops, Parties) { - this.args = {}; - this.isLoading = false; - - this.$routerOnActivate = route => { - this.mode = route.params.shopId ? 'edit' : 'add'; - if (this.mode === 'edit') { - this.isLoading = true; - this.shopID = route.params.shopId; - Parties.get(party => { - this.isLoading = false; - const shop = _.find(party.shops, shop => shop.shopID === this.shopID); - this.args.shopDetails = shop.shopDetails; - this.args.contractor = shop.contractor; - }); - } - }; - - const back = () => { - this.args = {}; - this.isLoading = false; - this.$router.navigate(['Shops']); - }; - - this.createClaim = form => { - if (form.$valid) { - this.isLoading = true; - const shops = new Shops(this.args); - if (this.mode === 'add') { - shops.$save(() => back()); - } else if (this.mode === 'edit') { - shops.$save({shopID: this.shopID}, () => back()); - } - } - }; - - this.hasError = field => field.$dirty && field.$invalid; - } -}); diff --git a/app/components/shops/claim-form/claim-form.template.pug b/app/components/shops/claim-form/claim-form.template.pug deleted file mode 100644 index 99c3c64..0000000 --- a/app/components/shops/claim-form/claim-form.template.pug +++ /dev/null @@ -1,37 +0,0 @@ -.row - .col-md-12 - .x_panel.tile - .x_title - h4(ng-if="$ctrl.mode === 'edit'") Изменение данных магазина - h4(ng-if="$ctrl.mode === 'add'") Добавление нового магазина - .x_content - loading(is-loading="$ctrl.isLoading") - form.form-horizontal.form-label-left.css-form(novalidate name="form") - .row - .col-md-12 - .form-group(ng-class="{'has-error': $ctrl.hasError(form.shopDetails)}") - label.control-label.col-md-3 Название магазина * - .col-md-6 - input.form-control(type="text" ng-model="$ctrl.args.shopDetails.name" name="shopDetails" required) - .form-group - label.control-label.col-md-3 Описание магазина - .col-md-6 - input.form-control(type="text" ng-model="$ctrl.args.shopDetails.description") - .form-group - label.control-label.col-md-3 Месторасположение - .col-md-6 - input.form-control(type="text" ng-model="$ctrl.args.shopDetails.location") - - .form-group(ng-class="{'has-error': $ctrl.hasError(form.contractor)}") - label.control-label.col-md-3 Наименование организации * - .col-md-6 - input.form-control(type="text" ng-model="$ctrl.args.contractor.registeredName" name="contractor" required) - .form-group - label.control-label.col-md-3 Тип юридического лица - .col-md-6 - input.form-control(type="text" ng-model="$ctrl.args.contractor.legalEntity") - .ln_solid - .form-group - .col-md-6.col-md-offset-3 - button.btn.btn-primary(type="submit" ng-click="$ctrl.createClaim(form)" ng-disabled="form.$invalid") Создать заявку - a.btn.btn-default.pull-right(type="reset" ng-link="['\Shops\']") Отмена diff --git a/app/components/shops/edit-shop/edit-shop.component.js b/app/components/shops/edit-shop/edit-shop.component.js new file mode 100644 index 0000000..9ab64cd --- /dev/null +++ b/app/components/shops/edit-shop/edit-shop.component.js @@ -0,0 +1,72 @@ +shops.component('editShop', { + templateUrl: 'components/shops/edit-shop/edit-shop.template.html', + bindings: { + $router: '<' + }, + controller: function (Shops, Parties) { + this.args = {}; + this.isLoading = false; + + this.$routerOnActivate = route => { + this.isLoading = true; + this.shopID = route.params.shopId; + Parties.get(party => { + this.isLoading = false; + const shop = _.find(party.shops, shop => shop.shopID === this.shopID); + this.shopDetails = shop.shopDetails; + this.contractor = shop.contractor; + }); + }; + + const back = () => { + this.args = {}; + this.isLoading = false; + this.$router.navigate(['Shops']); + }; + + this.createClaim = form => { + if (!form.$valid) { + return; + } + this.args = getArgs(form); + this.isLoading = true; + const shops = new Shops(this.args); + shops.$save({shopID: this.shopID}, () => back()); + }; + + function getArgs(form) { + const args = {}; + if (form.shopDetailsName.$dirty) { + if (!args.shopDetails) { + args.shopDetails = {}; + } + args.shopDetails.name = form.shopDetailsName.$modelValue; + } + if (form.shopDetailsDescription.$dirty) { + if (!args.shopDetails) { + args.shopDetails = {}; + } + args.shopDetails.description = form.shopDetailsDescription.$modelValue; + } + if (form.shopDetailsLocation.$dirty) { + if (!args.shopDetails) { + args.shopDetails = {}; + } + args.shopDetails.location = form.shopDetailsLocation.$modelValue; + } + if (form.contractorRegisteredName.$dirty) { + if (!args.contractor) { + args.contractor = {}; + } + args.contractor.registeredName = form.contractorRegisteredName.$modelValue; + } + if (form.contractorLegalEntity.$dirty) { + if (!args.contractor) { + args.contractor = {}; + } + args.contractor.legalEntity = form.contractorLegalEntity.$modelValue; + } + return args; + } + } +}); diff --git a/app/components/shops/edit-shop/edit-shop.template.pug b/app/components/shops/edit-shop/edit-shop.template.pug new file mode 100644 index 0000000..abf2e4f --- /dev/null +++ b/app/components/shops/edit-shop/edit-shop.template.pug @@ -0,0 +1,35 @@ +.row + .col-md-12 + .x_panel.tile + .x_title + h4 Изменение данных магазина + .x_content + loading(is-loading="$ctrl.isLoading") + form.form-horizontal.form-label-left.css-form(novalidate name="form") + + .form-group + label.control-label.col-md-3 Название магазина * + .col-md-6 + input.form-control(type="text" ng-model="$ctrl.shopDetails.name" name="shopDetailsName") + .form-group + label.control-label.col-md-3 Описание магазина + .col-md-6 + input.form-control(type="text" ng-model="$ctrl.shopDetails.description" name="shopDetailsDescription") + .form-group + label.control-label.col-md-3 Месторасположение + .col-md-6 + input.form-control(type="text" ng-model="$ctrl.shopDetails.location" name="shopDetailsLocation") + + .form-group + label.control-label.col-md-3 Наименование организации * + .col-md-6 + input.form-control(type="text" ng-model="$ctrl.contractor.registeredName" name="contractorRegisteredName") + .form-group + label.control-label.col-md-3 Тип юридического лица + .col-md-6 + input.form-control(type="text" ng-model="$ctrl.contractor.legalEntity" name="contractorLegalEntity") + .ln_solid + .form-group + .col-md-6.col-md-offset-3 + button.btn.btn-primary(type="submit" ng-click="$ctrl.createClaim(form)" ng-disabled="form.$pristine") Создать заявку + a.btn.btn-default.pull-right(type="reset" ng-link="['\Shops\']") Отмена From a543c29b01766a3f439525ee4a9e9caa8436ea2e Mon Sep 17 00:00:00 2001 From: Ildar Galeev Date: Thu, 29 Sep 2016 15:08:04 +0300 Subject: [PATCH 11/13] FE-38: Added activate shop functionality --- app/components/shops/shops.component.js | 16 ++++++-- app/components/shops/shops.template.pug | 52 ++++++++++++------------- app/shared/resources/shops.js | 6 ++- capi-mock/capi.js | 3 ++ capi-mock/shops.js | 24 +++++++++++- 5 files changed, 68 insertions(+), 33 deletions(-) diff --git a/app/components/shops/shops.component.js b/app/components/shops/shops.component.js index d4cbad9..6c3b04a 100644 --- a/app/components/shops/shops.component.js +++ b/app/components/shops/shops.component.js @@ -1,13 +1,21 @@ shops.component('shops', { templateUrl: 'components/shops/shops.template.html', - controller: function (Parties) { - this.isLoading = true; + controller: function (Parties, Shops) { - this.$routerOnActivate = () => { + const getParty = () => { + this.isLoading = true; Parties.get(party => { this.isLoading = false; this.shops = party.shops; }); - } + }; + + this.$routerOnActivate = () => getParty(); + + this.activate = shop => { + this.isLoading = true; + const shops = new Shops(); + shops.$activate({shopID: shop.shopID}, () => getParty()); + }; } }); diff --git a/app/components/shops/shops.template.pug b/app/components/shops/shops.template.pug index f6db038..f5f996d 100644 --- a/app/components/shops/shops.template.pug +++ b/app/components/shops/shops.template.pug @@ -1,27 +1,25 @@ -.row - .col-md-12 - claims -.row - .col-md-12 - .x_panel.tile - .x_title - h4 Магазины - .x_content - .row - .col-md-12 - loading(is-loading="$ctrl.isLoading") - table.table.table-hover.table-striped - thead - tr - th Название магазина - th Описание - th Месторасположение - th - tbody - tr(ng-repeat="shop in $ctrl.shops") - td {{shop.shopDetails.name}} - td {{shop.shopDetails.description}} - td {{shop.shopDetails.location}} - td - a.btn.btn-default.btn-xs.pull-right(ng-link="['\EditShop\', {shopId: shop.shopID}]") Изменить данные - a.btn.btn-primary.pull-right(ng-link="['\AddShop\']") Добавить новый магазин \ No newline at end of file +claims +.x_panel.tile + .x_title + h4 Магазины + .x_content + loading(is-loading="$ctrl.isLoading") + table.table.table-hover.table-striped + thead + tr + th Название магазина + th Описание + th Месторасположение + th + tbody + tr(ng-repeat="shop in $ctrl.shops" ng-class="{'success': shop.isSuspended, 'danger': shop.isBlocked}") + td {{shop.shopDetails.name}} + td {{shop.shopDetails.description}} + td {{shop.shopDetails.location}} + td(ng-if="shop.isSuspended && !shop.isBlocked") + button.btn.btn-success.btn-xs.pull-right(ng-click="$ctrl.activate(shop)") Активировать + td(ng-if="!shop.isSuspended && !shop.isBlocked") + a.btn.btn-default.btn-xs.pull-right(ng-link="['\EditShop\', {shopId: shop.shopID}]") Изменить данные + td(ng-if="shop.isBlocked") + span.pull-right Заблокирован + a.btn.btn-primary.pull-right(ng-link="['\AddShop\']") Добавить новый магазин \ No newline at end of file diff --git a/app/shared/resources/shops.js b/app/shared/resources/shops.js index eb552d4..12183fe 100644 --- a/app/shared/resources/shops.js +++ b/app/shared/resources/shops.js @@ -1,3 +1,7 @@ resources.factory('Shops', function ($resource, appConfig) { - return $resource(appConfig.capiUrl + 'processing/shops/:shopID'); + return $resource(appConfig.capiUrl + 'processing/shops/:shopID/:action', { + shopID: '@shopID' + }, { + activate: {method: 'PUT', params: {action: 'activate'}} + }); }); diff --git a/capi-mock/capi.js b/capi-mock/capi.js index e18f949..b33a556 100644 --- a/capi-mock/capi.js +++ b/capi-mock/capi.js @@ -13,6 +13,7 @@ const me = require('./me'); const claims = require('./claims'); app.use((req, res, next) => { + res.header('Access-Control-Allow-Methods', 'PUT'); res.header('Access-Control-Allow-Origin', '*'); res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept, Authorization, X-Request-ID'); next(); @@ -24,6 +25,8 @@ router.route('/processing/shops').post((req, res) => setTimeout(() => res.json(" router.route('/processing/shops/THRIFT-SHOP').post((req, res) => setTimeout(() => res.json("2"), 600)); +router.route('/processing/shops/THRIFT-SHOP2/activate').put((req, res) => setTimeout(() => res.json("1"), 600)); + router.route('/processing/claims').get((req, res) => setTimeout(() => res.json(claims), 0)); // router.route('/processing/claims').get((req, res) => res.status(404).send('Not found')); diff --git a/capi-mock/shops.js b/capi-mock/shops.js index 0d46adb..271ec5f 100644 --- a/capi-mock/shops.js +++ b/capi-mock/shops.js @@ -23,7 +23,7 @@ module.exports = [{ }, { shopID: 'THRIFT-SHOP2', isBlocked: false, - isSuspended: false, + isSuspended: true, categoryRef: 1, shopDetails: { name: 'Shop 2', @@ -42,4 +42,26 @@ module.exports = [{ validUntil: 'validUntil', terminatedAt: 'terminatedAt' } +}, { + shopID: 'THRIFT-SHOP3', + isBlocked: true, + isSuspended: true, + categoryRef: 1, + shopDetails: { + name: 'Shop 3', + description: 'shop 3 description', + location: 'Moscow' + }, + contractor: { + registeredName: 'Registered name', + legalEntity: 'legalEntity' + }, + contract: { + number: '2345', + systemContractorRef: '23435', + concludedAt: 'concludedAt', + validSince: 'validSince', + validUntil: 'validUntil', + terminatedAt: 'terminatedAt' + } }]; From e16962466c83dbd71b22082e3cb065c00fed024c Mon Sep 17 00:00:00 2001 From: Ildar Galeev Date: Thu, 29 Sep 2016 15:58:36 +0300 Subject: [PATCH 12/13] FE-38: Added categories support --- .../custom-select/custom-select.component.js | 5 +--- .../shops/add-shop/add-shop.component.js | 4 ++- .../shops/add-shop/add-shop.template.pug | 5 ++++ .../shops/edit-shop/edit-shop.component.js | 8 +++++- .../shops/edit-shop/edit-shop.template.pug | 10 +++++-- app/components/shops/shops.component.js | 6 ++++- app/components/shops/shops.template.pug | 2 ++ app/shared/resources/categories.js | 5 ++++ capi-mock/capi.js | 9 +++++-- capi-mock/categories.js | 27 +++++++++++++++++++ capi-mock/shops.js | 4 +-- 11 files changed, 72 insertions(+), 13 deletions(-) create mode 100644 app/shared/resources/categories.js create mode 100644 capi-mock/categories.js diff --git a/app/components/analytics/finance/search-form/custom-select/custom-select.component.js b/app/components/analytics/finance/search-form/custom-select/custom-select.component.js index fa50246..e5897e4 100644 --- a/app/components/analytics/finance/search-form/custom-select/custom-select.component.js +++ b/app/components/analytics/finance/search-form/custom-select/custom-select.component.js @@ -10,8 +10,5 @@ customSelect.component('customSelect', { this.options = _.map(PAYMENT_STATUSES, (name, key) => { return {name, key} }); - // jQuery(".select2_multiple").select2({ - // placeholder: '' - // }); } -}); \ No newline at end of file +}); diff --git a/app/components/shops/add-shop/add-shop.component.js b/app/components/shops/add-shop/add-shop.component.js index 14cb7ae..8b48a6c 100644 --- a/app/components/shops/add-shop/add-shop.component.js +++ b/app/components/shops/add-shop/add-shop.component.js @@ -3,10 +3,12 @@ shops.component('addShop', { bindings: { $router: '<' }, - controller: function (Shops) { + controller: function (Shops, Categories) { this.args = {}; this.isLoading = false; + this.categories = Categories.query(); + const back = () => { this.args = {}; this.isLoading = false; diff --git a/app/components/shops/add-shop/add-shop.template.pug b/app/components/shops/add-shop/add-shop.template.pug index 0f9334c..0b2785b 100644 --- a/app/components/shops/add-shop/add-shop.template.pug +++ b/app/components/shops/add-shop/add-shop.template.pug @@ -27,6 +27,11 @@ label.control-label.col-md-3 Тип юридического лица .col-md-6 input.form-control(type="text" ng-model="$ctrl.args.contractor.legalEntity") + .form-group + label.control-label.col-md-3 Категория * + .col-md-6 + select.select2_multiple.form-control.custom_select(select2 ng-model="$ctrl.args.categoryRef" required + ng-options="category.categoryRef as category.name for category in $ctrl.categories") .ln_solid .form-group .col-md-6.col-md-offset-3 diff --git a/app/components/shops/edit-shop/edit-shop.component.js b/app/components/shops/edit-shop/edit-shop.component.js index 9ab64cd..59e1dc6 100644 --- a/app/components/shops/edit-shop/edit-shop.component.js +++ b/app/components/shops/edit-shop/edit-shop.component.js @@ -3,10 +3,12 @@ shops.component('editShop', { bindings: { $router: '<' }, - controller: function (Shops, Parties) { + controller: function (Shops, Parties, Categories) { this.args = {}; this.isLoading = false; + this.categories = Categories.query(); + this.$routerOnActivate = route => { this.isLoading = true; this.shopID = route.params.shopId; @@ -15,6 +17,7 @@ shops.component('editShop', { const shop = _.find(party.shops, shop => shop.shopID === this.shopID); this.shopDetails = shop.shopDetails; this.contractor = shop.contractor; + this.categoryRef = shop.categoryRef; }); }; @@ -36,6 +39,9 @@ shops.component('editShop', { function getArgs(form) { const args = {}; + if (form.category.$dirty) { + args.categoryRef = form.category.$modelValue; + } if (form.shopDetailsName.$dirty) { if (!args.shopDetails) { args.shopDetails = {}; diff --git a/app/components/shops/edit-shop/edit-shop.template.pug b/app/components/shops/edit-shop/edit-shop.template.pug index abf2e4f..7e90da9 100644 --- a/app/components/shops/edit-shop/edit-shop.template.pug +++ b/app/components/shops/edit-shop/edit-shop.template.pug @@ -10,7 +10,7 @@ .form-group label.control-label.col-md-3 Название магазина * .col-md-6 - input.form-control(type="text" ng-model="$ctrl.shopDetails.name" name="shopDetailsName") + input.form-control(type="text" ng-model="$ctrl.shopDetails.name" name="shopDetailsName" required) .form-group label.control-label.col-md-3 Описание магазина .col-md-6 @@ -23,11 +23,17 @@ .form-group label.control-label.col-md-3 Наименование организации * .col-md-6 - input.form-control(type="text" ng-model="$ctrl.contractor.registeredName" name="contractorRegisteredName") + input.form-control(type="text" ng-model="$ctrl.contractor.registeredName" name="contractorRegisteredName" required) .form-group label.control-label.col-md-3 Тип юридического лица .col-md-6 input.form-control(type="text" ng-model="$ctrl.contractor.legalEntity" name="contractorLegalEntity") + + .form-group + label.control-label.col-md-3 Категория * + .col-md-6 + select.select2_multiple.form-control.custom_select(select2 ng-model="$ctrl.categoryRef" required name="category" + ng-options="category.categoryRef as category.name for category in $ctrl.categories") .ln_solid .form-group .col-md-6.col-md-offset-3 diff --git a/app/components/shops/shops.component.js b/app/components/shops/shops.component.js index 6c3b04a..34282dd 100644 --- a/app/components/shops/shops.component.js +++ b/app/components/shops/shops.component.js @@ -1,6 +1,10 @@ shops.component('shops', { templateUrl: 'components/shops/shops.template.html', - controller: function (Parties, Shops) { + controller: function (Parties, Shops, Categories) { + + this.categories = Categories.query(); + + this.getCategory = ref => _.find(this.categories, category => category.categoryRef === ref); const getParty = () => { this.isLoading = true; diff --git a/app/components/shops/shops.template.pug b/app/components/shops/shops.template.pug index f5f996d..32d6184 100644 --- a/app/components/shops/shops.template.pug +++ b/app/components/shops/shops.template.pug @@ -10,12 +10,14 @@ claims th Название магазина th Описание th Месторасположение + th Категория th tbody tr(ng-repeat="shop in $ctrl.shops" ng-class="{'success': shop.isSuspended, 'danger': shop.isBlocked}") td {{shop.shopDetails.name}} td {{shop.shopDetails.description}} td {{shop.shopDetails.location}} + td {{$ctrl.getCategory(shop.categoryRef).name}} td(ng-if="shop.isSuspended && !shop.isBlocked") button.btn.btn-success.btn-xs.pull-right(ng-click="$ctrl.activate(shop)") Активировать td(ng-if="!shop.isSuspended && !shop.isBlocked") diff --git a/app/shared/resources/categories.js b/app/shared/resources/categories.js new file mode 100644 index 0000000..72a6ef3 --- /dev/null +++ b/app/shared/resources/categories.js @@ -0,0 +1,5 @@ +resources.factory('Categories', function ($resource, appConfig) { + return $resource(`${appConfig.capiUrl}processing/categories/:categoryRef`, { + categoryRef: '@categoryRef' + }); +}); diff --git a/capi-mock/capi.js b/capi-mock/capi.js index b33a556..d8687f7 100644 --- a/capi-mock/capi.js +++ b/capi-mock/capi.js @@ -11,6 +11,7 @@ const geo = require('./geo'); const rate = require('./rate'); const me = require('./me'); const claims = require('./claims'); +const categories = require('./categories'); app.use((req, res, next) => { res.header('Access-Control-Allow-Methods', 'PUT'); @@ -27,11 +28,15 @@ router.route('/processing/shops/THRIFT-SHOP').post((req, res) => setTimeout(() = router.route('/processing/shops/THRIFT-SHOP2/activate').put((req, res) => setTimeout(() => res.json("1"), 600)); -router.route('/processing/claims').get((req, res) => setTimeout(() => res.json(claims), 0)); +router.route('/processing/claims').get((req, res) => setTimeout(() => res.json(claims), 600)); // router.route('/processing/claims').get((req, res) => res.status(404).send('Not found')); -router.route('/processing/claims/1/revoke').post((req, res) => setTimeout(() => res.json(), 0)); +router.route('/processing/claims/1/revoke').post((req, res) => setTimeout(() => res.json(), 600)); + +router.route('/processing/categories').get((req, res) => setTimeout(() => res.json(categories), 300)); + +router.route('/processing/categories/1').get((req, res) => setTimeout(() => res.json(categories[0]), 300)); router.route('/analytics/shops/THRIFT-SHOP/invoices').get((req, res) => setTimeout(() => res.json(invoices), 300)); diff --git a/capi-mock/categories.js b/capi-mock/categories.js new file mode 100644 index 0000000..c2a984b --- /dev/null +++ b/capi-mock/categories.js @@ -0,0 +1,27 @@ +module.exports = [ + { + name: 'Test category 1', + categoryRef: 1, + description: 'description' + }, + { + name: 'Test category 2', + categoryRef: 2, + description: 'description' + }, + { + name: 'Test category 3', + categoryRef: 3, + description: 'description' + }, + { + name: 'Test category 4', + categoryRef: 4, + description: 'description' + }, + { + name: 'Test category 5', + categoryRef: 5, + description: 'description' + } +]; diff --git a/capi-mock/shops.js b/capi-mock/shops.js index 271ec5f..91f7f76 100644 --- a/capi-mock/shops.js +++ b/capi-mock/shops.js @@ -24,7 +24,7 @@ module.exports = [{ shopID: 'THRIFT-SHOP2', isBlocked: false, isSuspended: true, - categoryRef: 1, + categoryRef: 2, shopDetails: { name: 'Shop 2', description: 'shop 2 description', @@ -46,7 +46,7 @@ module.exports = [{ shopID: 'THRIFT-SHOP3', isBlocked: true, isSuspended: true, - categoryRef: 1, + categoryRef: 3, shopDetails: { name: 'Shop 3', description: 'shop 3 description', From 9bffc45d1dd4912022f3b8cf5ab6e77daefd5ae1 Mon Sep 17 00:00:00 2001 From: Ildar Galeev Date: Thu, 29 Sep 2016 19:00:32 +0300 Subject: [PATCH 13/13] FE-38: Added account support --- app/assets/styles.less | 2 +- .../analytics/analytics.template.pug | 23 ++++-------- .../dashboard/dashboard.component.js | 37 +++++++++++++++---- .../dashboard/dashboard.template.pug | 4 +- .../dashboard/info-panel/info-panel.js | 7 +++- .../info-panel/info-panel.template.pug | 22 ++++++++--- app/shared/resources/accounts.js | 6 +++ app/shared/resources/invoices.js | 21 ----------- capi-mock/accounts.js | 11 ++++++ capi-mock/capi.js | 24 ++++++++---- capi-mock/shopAccounts.js | 6 +++ 11 files changed, 103 insertions(+), 60 deletions(-) create mode 100644 app/shared/resources/accounts.js create mode 100644 capi-mock/accounts.js create mode 100644 capi-mock/shopAccounts.js diff --git a/app/assets/styles.less b/app/assets/styles.less index 25229c7..5319ce3 100644 --- a/app/assets/styles.less +++ b/app/assets/styles.less @@ -1,5 +1,5 @@ .dashboard_stats_count { - font-size: 33px; + font-size: 27px; line-height: 40px; font-weight: 600; } diff --git a/app/components/analytics/analytics.template.pug b/app/components/analytics/analytics.template.pug index c95705d..09308f0 100644 --- a/app/components/analytics/analytics.template.pug +++ b/app/components/analytics/analytics.template.pug @@ -1,23 +1,14 @@ -.row - .col-md-12 - .x_panel.tile - .x_title - h4 Аналитика - .x_content - .row - .col-md-6 - form.form-horizontal - .form-group - label.control-label.col-md-2 Магазин - .col-md-8 - select.select2_multiple.form-control.custom_select( - select2 ng-options="detail.key as detail.name for detail in $ctrl.shopsDetails" - ng-model="$ctrl.selectedShopId" ng-change="$ctrl.onSelect()") - .row(ng-show="$ctrl.selectedShopId") .col-md-12 .x_panel.tile .x_content + form.form-horizontal + .form-group + label.control-label.col-md-1 Магазин + .col-md-5 + select.select2_multiple.form-control.custom_select( + select2 ng-options="detail.key as detail.name for detail in $ctrl.shopsDetails" + ng-model="$ctrl.selectedShopId" ng-change="$ctrl.onSelect()") ul.nav.nav-tabs.bar_tabs li(ng-class="{active: $ctrl.isRouteActive(['\Dashboard\', {shopId: $ctrl.selectedShopId}])}") a(ng-link="['\Dashboard\', {shopId: $ctrl.selectedShopId}]") Статистика diff --git a/app/components/analytics/dashboard/dashboard.component.js b/app/components/analytics/dashboard/dashboard.component.js index b705cae..1825ad8 100644 --- a/app/components/analytics/dashboard/dashboard.component.js +++ b/app/components/analytics/dashboard/dashboard.component.js @@ -1,16 +1,11 @@ dashboard.component('dashboard', { templateUrl: 'components/analytics/dashboard/dashboard.template.html', - controller: function (Payments, ChartDataConversion, Customers) { + controller: function (Payments, ChartDataConversion, Customers, Accounts) { // this.fromTime = moment(this.toTime).subtract(1, 'M').hours(0).minutes(0).seconds(0).milliseconds(0).format(); this.toTime = moment().format(); this.fromTime = moment().hours(0).minutes(0).seconds(0).format(); - this.$routerOnActivate = route => { - this.shopID = route.params.shopId; - this.show(); - }; - - this.show = () => { + this.loadData = () => { this.chartFromTime = this.fromTime; const customers = new Customers(this.shopID); @@ -52,6 +47,34 @@ dashboard.component('dashboard', { }, geoStat => { this.geoChartData = ChartDataConversion.toGeoChartData(geoStat); }); + + Accounts.query({shopID: this.shopID}, shopAccounts => { + if (shopAccounts.length > 1) { + console.warn('shop accounts size > 1'); + } + _.forEach(shopAccounts, item => { + const account = {}; + Accounts.get({ + shopID: this.shopID, + accountID: item.generalID + }, generalAccount => { + account.general = generalAccount; + }); + + Accounts.get({ + shopID: this.shopID, + accountID: item.guaranteeID + }, guaranteeAccount => { + account.guarantee = guaranteeAccount; + }); + this.account = account; + }); + }); + }; + + this.$routerOnActivate = route => { + this.shopID = route.params.shopId; + this.loadData(); }; } }); diff --git a/app/components/analytics/dashboard/dashboard.template.pug b/app/components/analytics/dashboard/dashboard.template.pug index 1bf094e..949904d 100644 --- a/app/components/analytics/dashboard/dashboard.template.pug +++ b/app/components/analytics/dashboard/dashboard.template.pug @@ -7,10 +7,10 @@ .form-group label.control-label по datepicker(date="$ctrl.toTime") - button.btn.btn-default(style="margin-bottom: 0; margin-right: 0" ng-click="$ctrl.show()") Показать + button.btn.btn-default(style="margin-bottom: 0; margin-right: 0" ng-click="$ctrl.loadData()") Показать .row info-panel(unique-count="$ctrl.uniqueCount" successful-count="$ctrl.successfulCount" - unfinished-count="$ctrl.unfinishedCount" profit="$ctrl.profit") + unfinished-count="$ctrl.unfinishedCount" profit="$ctrl.profit" account="$ctrl.account") .row .col-md-12 .x_panel.tile diff --git a/app/components/analytics/dashboard/info-panel/info-panel.js b/app/components/analytics/dashboard/info-panel/info-panel.js index 1568b60..e484c4d 100644 --- a/app/components/analytics/dashboard/info-panel/info-panel.js +++ b/app/components/analytics/dashboard/info-panel/info-panel.js @@ -6,13 +6,15 @@ infoPanel.component('infoPanel', { uniqueCount: '<', successfulCount: '<', unfinishedCount: '<', - profit: '<' + profit: '<', + account: '<' }, controller: function () { this.profitLoading = true; this.successfulCountLoading = true; this.unfinishedCountLoading = true; this.uniqueCountLoading = true; + this.accountsLoading = true; this.$onChanges = () => { if (_.isNumber(this.profit)) { this.profitLoading = false; @@ -26,6 +28,9 @@ infoPanel.component('infoPanel', { if(_.isNumber(this.uniqueCount)) { this.uniqueCountLoading = false; } + if (this.account) { + this.accountsLoading = false; + } }; } }); \ No newline at end of file diff --git a/app/components/analytics/dashboard/info-panel/info-panel.template.pug b/app/components/analytics/dashboard/info-panel/info-panel.template.pug index ba2433a..1961abf 100644 --- a/app/components/analytics/dashboard/info-panel/info-panel.template.pug +++ b/app/components/analytics/dashboard/info-panel/info-panel.template.pug @@ -1,22 +1,34 @@ .tile_count - .col-md-3.col-sm-4.col-xs-6.tile_stats_count + .col-md-2.tile_stats_count span.count_top Оборот .dashboard_stats_count loading(is-loading="$ctrl.profitLoading") div {{$ctrl.profit | roubleCurrency}} span.count_bottom Рублей - .col-md-3.col-sm-4.col-xs-6.tile_stats_count + .col-md-2.tile_stats_count + span.count_top Основной счет + .dashboard_stats_count + loading(is-loading="$ctrl.accountsLoading") + div {{$ctrl.account.general.availableAmount | roubleCurrency}} + span.count_bottom Рублей + .col-md-2.tile_stats_count + span.count_top Гарантийный счет + .dashboard_stats_count + loading(is-loading="$ctrl.accountsLoading") + div {{$ctrl.account.guarantee.availableAmount | roubleCurrency}} + span.count_bottom Рублей + .col-md-2.tile_stats_count span.count_top Успешных платежей .dashboard_stats_count loading(is-loading="$ctrl.successfulCountLoading") div {{$ctrl.successfulCount}} - .col-md-3.col-sm-4.col-xs-6.tile_stats_count + .col-md-2.tile_stats_count span.count_top Незавершенных платежей .dashboard_stats_count loading(is-loading="$ctrl.unfinishedCountLoading") div {{$ctrl.unfinishedCount}} - .col-md-3.col-sm-4.col-xs-6.tile_stats_count + .col-md-2.tile_stats_count span.count_top Уникальных плательщиков .dashboard_stats_count loading(is-loading="$ctrl.uniqueCountLoading") - div {{$ctrl.uniqueCount}} \ No newline at end of file + div {{$ctrl.uniqueCount}} diff --git a/app/shared/resources/accounts.js b/app/shared/resources/accounts.js new file mode 100644 index 0000000..7759da3 --- /dev/null +++ b/app/shared/resources/accounts.js @@ -0,0 +1,6 @@ +resources.factory('Accounts', function ($resource, appConfig) { + return $resource(`${appConfig.capiUrl}processing/shops/:shopID/accounts/:accountID`, { + shopID: '@shopID', + accountID: '@accountID' + }); +}); diff --git a/app/shared/resources/invoices.js b/app/shared/resources/invoices.js index 9b0db6e..7cbc70e 100644 --- a/app/shared/resources/invoices.js +++ b/app/shared/resources/invoices.js @@ -1,24 +1,3 @@ -// resources.factory('Invoices', function ($resource, appConfig) { -// return $resource(appConfig.capiUrl + 'analytics/shops/:shopID/invoices', { -// shopID: appConfig.shopID -// }, { -// /** -// * @typedef {Object} Parameters -// * @property {int} limit -// * @property {int} offset -// * @property {dateTime} fromTime -// * @property {dateTime} toTime -// * @property {string} status -// * @property {string} invoiceID -// */ -// -// /** -// * @returns {Invoices} -// */ -// search: {method: 'GET'} -// }); -// }); - resources.factory('Invoices', function ($resource, appConfig) { return function (shopID) { return $resource(appConfig.capiUrl + 'analytics/shops/:shopID/invoices', { diff --git a/capi-mock/accounts.js b/capi-mock/accounts.js new file mode 100644 index 0000000..9e1d316 --- /dev/null +++ b/capi-mock/accounts.js @@ -0,0 +1,11 @@ +module.exports = [{ + id: '1', + ownAmount: 1000000, + availableAmount: 1100000, + currency: 'rub' +}, { + id: '2', + ownAmount: 2000000, + availableAmount: 2100000, + currency: 'rub' +}]; diff --git a/capi-mock/capi.js b/capi-mock/capi.js index d8687f7..697505d 100644 --- a/capi-mock/capi.js +++ b/capi-mock/capi.js @@ -12,6 +12,8 @@ const rate = require('./rate'); const me = require('./me'); const claims = require('./claims'); const categories = require('./categories'); +const shopAccounts = require('./shopAccounts'); +const accounts = require('./accounts'); app.use((req, res, next) => { res.header('Access-Control-Allow-Methods', 'PUT'); @@ -28,15 +30,11 @@ router.route('/processing/shops/THRIFT-SHOP').post((req, res) => setTimeout(() = router.route('/processing/shops/THRIFT-SHOP2/activate').put((req, res) => setTimeout(() => res.json("1"), 600)); -router.route('/processing/claims').get((req, res) => setTimeout(() => res.json(claims), 600)); +router.route('/processing/shops/THRIFT-SHOP/accounts').get((req, res) => setTimeout(() => res.json(shopAccounts), 300)); -// router.route('/processing/claims').get((req, res) => res.status(404).send('Not found')); +router.route('/processing/shops/THRIFT-SHOP/accounts/1').get((req, res) => setTimeout(() => res.json(accounts[0]), 600)); -router.route('/processing/claims/1/revoke').post((req, res) => setTimeout(() => res.json(), 600)); - -router.route('/processing/categories').get((req, res) => setTimeout(() => res.json(categories), 300)); - -router.route('/processing/categories/1').get((req, res) => setTimeout(() => res.json(categories[0]), 300)); +router.route('/processing/shops/THRIFT-SHOP/accounts/2').get((req, res) => setTimeout(() => res.json(accounts[1]), 300)); router.route('/analytics/shops/THRIFT-SHOP/invoices').get((req, res) => setTimeout(() => res.json(invoices), 300)); @@ -48,6 +46,18 @@ router.route('/analytics/shops/THRIFT-SHOP/payments/stats/geo').get((req, res) = router.route('/analytics/shops/THRIFT-SHOP/customers/stats/rate').get((req, res) => setTimeout(() => res.json(rate), 0)); +router.route('/processing/claims').get((req, res) => setTimeout(() => res.json(claims), 600)); + +// router.route('/processing/claims').get((req, res) => res.status(404).send('Not found')); + +router.route('/processing/claims/1/revoke').post((req, res) => setTimeout(() => res.json(), 600)); + +router.route('/processing/categories').get((req, res) => setTimeout(() => res.json(categories), 300)); + +router.route('/processing/categories/1').get((req, res) => setTimeout(() => res.json(categories[0]), 300)); + +router.route('/processing/categories/1').get((req, res) => setTimeout(() => res.json(categories[0]), 300)); + app.use('/v1', router); app.listen(9000); diff --git a/capi-mock/shopAccounts.js b/capi-mock/shopAccounts.js new file mode 100644 index 0000000..0521284 --- /dev/null +++ b/capi-mock/shopAccounts.js @@ -0,0 +1,6 @@ +module.exports = [ + { + generalID: '1', + guaranteeID: '2' + } +];