diff --git a/client/client/src/billing-data/billing-data.html b/client/client/src/billing-data/billing-data.html index 0f2a3c1e8..c46c00e98 100644 --- a/client/client/src/billing-data/billing-data.html +++ b/client/client/src/billing-data/billing-data.html @@ -21,10 +21,6 @@ - diff --git a/client/client/src/billing-data/billing-data.js b/client/client/src/billing-data/billing-data.js index 0081113e6..6bbb3705c 100644 --- a/client/client/src/billing-data/billing-data.js +++ b/client/client/src/billing-data/billing-data.js @@ -17,9 +17,6 @@ export default class Controller { this.billData.payMethodFk = this.client.payMethodFk; this.billData.iban = this.client.iban; this.billData.dueDay = this.client.dueDay; - /* this.billData.discount = this.client.discount; - this.billData.credit = this.client.credit; - this.billData.creditInsurance = this.client.creditInsurance; */ } } submit() { diff --git a/client/client/src/credit-list/credit-list.js b/client/client/src/credit-list/credit-list.js index 8cf7a449f..c1d283e33 100644 --- a/client/client/src/credit-list/credit-list.js +++ b/client/client/src/credit-list/credit-list.js @@ -1,45 +1,9 @@ import ngModule from '../module'; +import FilterClientList from '../filterClientList'; -class ClientCreditList { - constructor($scope, $timeout) { - this.$ = $scope; - this.$timeout = $timeout; - - this.waitingMgCrud = 0; - } - onOrder(field, order) { - this.filter(`${field} ${order}`); - } - filter(order) { - if (this.$.index && this.client && this.client.id) { - this.waitingMgCrud = 0; - this.$.index.filter = { - page: 1, - size: 10, - clientFk: this.client.id - }; - - if (order) { - this.$.index.filter.order = order; - } - - this.$.index.accept(); - } else if (this.waitingMgCrud > 0) { - throw new Error('Magic Crud is not loaded'); - } else { - this.waitingMgCrud++; - this.$timeout(() => { - this.filter(order); - }, 250); - } - } -} -ClientCreditList.$inject = ['$scope', '$timeout']; +class ClientCreditList extends FilterClientList {} ngModule.component('vnClientCreditList', { template: require('./credit-list.html'), - controller: ClientCreditList, - bindings: { - client: '<' - } + controller: ClientCreditList }); diff --git a/client/client/src/filterClientList.js b/client/client/src/filterClientList.js new file mode 100644 index 000000000..908754b0f --- /dev/null +++ b/client/client/src/filterClientList.js @@ -0,0 +1,36 @@ +export default class FilterClientList { + constructor($scope, $timeout, $state) { + this.$ = $scope; + this.$timeout = $timeout; + + this.waitingMgCrud = 0; + this.clientFk = $state.params.id; + } + onOrder(field, order) { + this.filter(`${field} ${order}`); + } + filter(order) { + if (this.$.index && this.clientFk) { + this.waitingMgCrud = 0; + this.$.index.filter = { + page: 1, + size: 10, + clientFk: this.clientFk + }; + + if (order) { + this.$.index.filter.order = order; + } + + this.$.index.accept(); + } else if (this.waitingMgCrud > 3) { + throw new Error('Magic Crud is not loaded'); + } else { + this.waitingMgCrud++; + this.$timeout(() => { + this.filter(order); + }, 250); + } + } +} +FilterClientList.$inject = ['$scope', '$timeout', '$state']; diff --git a/client/client/src/greuge-list/greuge-list.js b/client/client/src/greuge-list/greuge-list.js index 0574a321c..a2e5bd33a 100644 --- a/client/client/src/greuge-list/greuge-list.js +++ b/client/client/src/greuge-list/greuge-list.js @@ -1,45 +1,9 @@ import ngModule from '../module'; +import FilterClientList from '../filterClientList'; -class ClientGreugeList { - constructor($scope, $timeout) { - this.$ = $scope; - this.$timeout = $timeout; - - this.waitingMgCrud = 0; - } - onOrder(field, order) { - this.filter(`${field} ${order}`); - } - filter(order) { - if (this.$.index && this.client && this.client.id) { - this.waitingMgCrud = 0; - this.$.index.filter = { - page: 1, - size: 10, - clientFk: this.client.id - }; - - if (order) { - this.$.index.filter.order = order; - } - - this.$.index.accept(); - } else if (this.waitingMgCrud > 3) { - throw new Error('Magic Crud is not loaded'); - } else { - this.waitingMgCrud++; - this.$timeout(() => { - this.filter(order); - }, 250); - } - } -} -ClientGreugeList.$inject = ['$scope', '$timeout']; +class ClientGreugeList extends FilterClientList {} ngModule.component('vnClientGreugeList', { template: require('./greuge-list.html'), - controller: ClientGreugeList, - bindings: { - client: '<' - } + controller: ClientGreugeList });