From 44893b57e73fdae198edaeecdad7665622b1aa7c Mon Sep 17 00:00:00 2001 From: Gerard Date: Tue, 5 Feb 2019 16:41:36 +0100 Subject: [PATCH] #1012 claim.action --- e2e/helpers/selectors.js | 2 +- front/core/components/dialog/dialog.js | 3 - front/salix/styles/index.js | 1 + .../salix/styles/modal-form.scss | 4 +- modules/client/front/risk/create/index.html | 85 ++++++++++--------- modules/client/front/risk/create/index.js | 70 +++++++++------ modules/client/front/risk/create/style.scss | 3 + modules/client/front/risk/index/index.html | 19 +++-- modules/client/front/risk/index/index.js | 11 +++ modules/item/front/ticket-descriptor/index.js | 1 - 10 files changed, 116 insertions(+), 83 deletions(-) rename modules/item/front/ticket-descriptor/style.scss => front/salix/styles/modal-form.scss (90%) create mode 100644 modules/client/front/risk/create/style.scss diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index b3b937f48..bc0135e40 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -164,7 +164,7 @@ export default { newPaymentButton: `${components.vnFloatButton}`, newPaymentBankInut: `vn-client-risk-create vn-textfield[field="$ctrl.receipt.bankFk"] input`, newPaymentAmountInput: `vn-client-risk-create vn-textfield[field="$ctrl.receipt.amountPaid"] input`, - saveButton: `${components.vnSubmit}`, + saveButton: `vn-client-risk-create vn-button[label="Save"]`, firstRiskLineBalance: 'vn-client-risk-index vn-tbody > vn-tr:nth-child(1) > vn-td:nth-child(8)' }, diff --git a/front/core/components/dialog/dialog.js b/front/core/components/dialog/dialog.js index fb904f2f0..7ea588a27 100644 --- a/front/core/components/dialog/dialog.js +++ b/front/core/components/dialog/dialog.js @@ -47,9 +47,6 @@ export default class Dialog extends Component { if (this.onOpen) this.onOpen(); - - let firstFocusable = this.element.querySelector('input, textarea'); - if (firstFocusable) firstFocusable.focus(); } /** diff --git a/front/salix/styles/index.js b/front/salix/styles/index.js index 6149668b8..7f919436a 100644 --- a/front/salix/styles/index.js +++ b/front/salix/styles/index.js @@ -13,3 +13,4 @@ import './effects.scss'; import './order-product.scss'; import './summary.scss'; import './descriptor.scss'; +import './modal-form.scss'; diff --git a/modules/item/front/ticket-descriptor/style.scss b/front/salix/styles/modal-form.scss similarity index 90% rename from modules/item/front/ticket-descriptor/style.scss rename to front/salix/styles/modal-form.scss index 7c1a448d0..e353833e6 100644 --- a/modules/item/front/ticket-descriptor/style.scss +++ b/front/salix/styles/modal-form.scss @@ -1,7 +1,9 @@ @import 'colors'; +@import "./padding"; vn-dialog.modal-form { vn-horizontal.header{ + @extend .pad-small; background-color: $main-01; h5{ color: white; @@ -14,7 +16,7 @@ vn-dialog.modal-form { table { width: 100% } - &>div{ + & > div{ padding: 0!important; } vn-textfield { diff --git a/modules/client/front/risk/create/index.html b/modules/client/front/risk/create/index.html index 095d16986..950d54a52 100644 --- a/modules/client/front/risk/create/index.html +++ b/modules/client/front/risk/create/index.html @@ -1,44 +1,45 @@ - - - -
- - - - - - + + + + +
New payment
- - - - - +
+ + + + + + + + + + + + +
+ + + -
- - - - -
\ No newline at end of file + + \ No newline at end of file diff --git a/modules/client/front/risk/create/index.js b/modules/client/front/risk/create/index.js index a828d7264..11e701791 100644 --- a/modules/client/front/risk/create/index.js +++ b/modules/client/front/risk/create/index.js @@ -1,11 +1,13 @@ import ngModule from '../../module'; +import './style.scss'; class Controller { - constructor($scope, $state, $http, $stateParams) { + constructor($scope, $state, $http, vnApp, $translate) { this.$http = $http; this.$ = $scope; this.$state = $state; - this.$stateParams = $stateParams; + this.vnApp = vnApp; + this.$translate = $translate; this.receipt = { payed: new Date(), @@ -13,21 +15,26 @@ class Controller { companyFk: window.localStorage.defaultCompanyFk, bankFk: window.localStorage.defaultBankFk }; - - if (this.$stateParams.payed) - this.receipt.payed = this.$stateParams.payed; - - if (this.$stateParams.bankFk) - this.receipt.bankFk = this.$stateParams.bankFk; - - if (this.$stateParams.amountPaid) - this.receipt.amountPaid = this.$stateParams.amountPaid; - - if (this.$stateParams.companyFk) - this.receipt.companyFk = this.$stateParams.companyFk; } - $onInit() { + set payed(value) { + this.receipt.payed = value; + } + + set bankFk(value) { + this.receipt.bankFk = value; + } + + set amountPaid(value) { + this.receipt.amountPaid = value; + } + + set companyFk(value) { + this.receipt.companyFk = value; + this.getAmountPaid(); + } + + getAmountPaid() { let filter = { where: { clientFk: this.$state.params.id, @@ -41,25 +48,34 @@ class Controller { }); } - cancel() { - this.goToIndex(); + show() { + this.$.dialog.show(); } - goToIndex() { - this.$state.go('client.card.risk.index'); + hide() { + this.$.dialog.hide(); } - onSubmit() { - this.$.watcher.submit().then( - () => { - this.goToIndex(); - } - ); + save() { + let query = `/client/api/receipts`; + this.$http.post(query, this.receipt).then(() => { + this.vnApp.showSuccess(this.$translate.instant('Data saved!')); + this.hide(); + if (this.onResponse) + this.onResponse(); + }); } } -Controller.$inject = ['$scope', '$state', '$http', '$stateParams']; +Controller.$inject = ['$scope', '$state', '$http', 'vnApp', '$translate']; ngModule.component('vnClientRiskCreate', { template: require('./index.html'), - controller: Controller + controller: Controller, + bindings: { + payed: ' - - - - + fixed-bottom-right + ng-click="$ctrl.openCreateDialog()"> + + + + \ No newline at end of file diff --git a/modules/client/front/risk/index/index.js b/modules/client/front/risk/index/index.js index 14c1be3b7..6feea8b96 100644 --- a/modules/client/front/risk/index/index.js +++ b/modules/client/front/risk/index/index.js @@ -31,6 +31,9 @@ class Controller { setOrder(value) { this.params.params.companyFk = value; this.filter.where.companyFk = value; + } + + refresh() { this.$.model.refresh(); this.$.riskModel.refresh(); } @@ -55,6 +58,14 @@ class Controller { return this._risks; } + openCreateDialog() { + this.$.riskCreateDialog.companyFk = this.companyFk; + this.$.riskCreateDialog.onResponse = () => { + this.refresh(); + }; + this.$.riskCreateDialog.show(); + } + onDownload() { alert('Not implemented yet'); } diff --git a/modules/item/front/ticket-descriptor/index.js b/modules/item/front/ticket-descriptor/index.js index 948994701..53f13eb1a 100644 --- a/modules/item/front/ticket-descriptor/index.js +++ b/modules/item/front/ticket-descriptor/index.js @@ -1,5 +1,4 @@ import ngModule from '../module'; -import './style.scss'; class Controller { constructor($state, $scope, $http, vnApp, $translate) {