From 9df3d30c40d92fc9c4ca57f603f02e6535f842f6 Mon Sep 17 00:00:00 2001 From: Daniel Herrero Date: Tue, 28 Nov 2017 12:58:05 +0100 Subject: [PATCH] =?UTF-8?q?listado=20de=20cr=C3=A9dito=20de=20cliente?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/client/src/client.js | 1 + .../client/src/credit-list/credit-list.html | 29 ++++++++++++++ client/client/src/credit-list/credit-list.js | 38 +++++++++++++++++++ .../client/common/models/client-credit.js | 14 +++++++ .../client/common/models/client-credit.json | 2 +- services/client/server/model-config.json | 4 +- 6 files changed, 85 insertions(+), 3 deletions(-) create mode 100644 client/client/src/credit-list/credit-list.html create mode 100644 client/client/src/credit-list/credit-list.js create mode 100644 services/client/common/models/client-credit.js diff --git a/client/client/src/client.js b/client/client/src/client.js index 6dc0de725..4409dc034 100644 --- a/client/client/src/client.js +++ b/client/client/src/client.js @@ -14,3 +14,4 @@ import './address-edit/address-edit'; import './notes/notes'; import './note-create/note-create'; import './web-access/web-access'; +import './credit-list/credit-list'; diff --git a/client/client/src/credit-list/credit-list.html b/client/client/src/credit-list/credit-list.html new file mode 100644 index 000000000..c2ed95b00 --- /dev/null +++ b/client/client/src/credit-list/credit-list.html @@ -0,0 +1,29 @@ + + + + + + Credit + + + + + + + + + + {{::credit.amount | number:2}} + {{::credit.created}} + + + + + + + + + + \ No newline at end of file diff --git a/client/client/src/credit-list/credit-list.js b/client/client/src/credit-list/credit-list.js new file mode 100644 index 000000000..a0da14e4c --- /dev/null +++ b/client/client/src/credit-list/credit-list.js @@ -0,0 +1,38 @@ +import ngModule from '../module'; + +class ClientCreditList { + constructor($scope) { + this.$ = $scope; + } + onOrder(field, order) { + this.filter(`${field} ${order}`); + } + filter(order) { + this.$.index.filter = { + page: 1, + size: 10, + clientFk: this.client.id + }; + + if (order) { + this.$.index.filter.order = order; + } + + this.$.index.accept(); + } + + $onChanges() { + if (this.client && this.client.id) { + this.filter(); + } + } +} +ClientCreditList.$inject = ['$scope']; + +ngModule.component('vnClientCreditList', { + template: require('./credit-list.html'), + controller: ClientCreditList, + bindings: { + client: '<' + } +}); diff --git a/services/client/common/models/client-credit.js b/services/client/common/models/client-credit.js new file mode 100644 index 000000000..11a27e6af --- /dev/null +++ b/services/client/common/models/client-credit.js @@ -0,0 +1,14 @@ +module.exports = function(Self) { + Self.installMethod('filter', filterCredits); + + function filterCredits(params) { + return { + where: { + clientFk: params.clientFk + }, + skip: (params.page - 1) * params.size, + limit: params.size, + order: params.order || 'created DESC' + }; + } +}; diff --git a/services/client/common/models/client-credit.json b/services/client/common/models/client-credit.json index f6512bfc7..26a1733ad 100644 --- a/services/client/common/models/client-credit.json +++ b/services/client/common/models/client-credit.json @@ -1,5 +1,5 @@ { - "name": "ClientCredit", + "name": "clientCredit", "base": "VnModel", "validateUpsert": true, "properties": { diff --git a/services/client/server/model-config.json b/services/client/server/model-config.json index 3c9c2199d..710141a87 100644 --- a/services/client/server/model-config.json +++ b/services/client/server/model-config.json @@ -27,8 +27,8 @@ "Client": { "dataSource": "vn" }, - "ClientCredit": { - "dataSource": "salix" + "clientCredit": { + "dataSource": "vn" }, "ClientCreditLimit": { "dataSource": "salix"