From b8a6340afdf08d7694068038b01902ebbf81c274 Mon Sep 17 00:00:00 2001 From: Daniel Herrero Date: Wed, 13 Dec 2017 08:24:14 +0100 Subject: [PATCH] [R12 - T16] REST para mandatos --- client/client/src/mandate/mandate.html | 10 +++--- .../client/common/methods/mandate/filter.js | 28 ++++++++++++++++ services/client/common/models/company.json | 14 ++++++++ services/client/common/models/mandate.js | 3 ++ services/client/common/models/mandate.json | 32 +++++++++++++++++++ .../client/common/models/mandateType.json | 14 ++++++++ services/client/server/model-config.json | 9 ++++++ 7 files changed, 105 insertions(+), 5 deletions(-) create mode 100644 services/client/common/methods/mandate/filter.js create mode 100644 services/client/common/models/company.json create mode 100644 services/client/common/models/mandate.js create mode 100644 services/client/common/models/mandate.json create mode 100644 services/client/common/models/mandateType.json diff --git a/client/client/src/mandate/mandate.html b/client/client/src/mandate/mandate.html index 54b388267..c09824582 100644 --- a/client/client/src/mandate/mandate.html +++ b/client/client/src/mandate/mandate.html @@ -1,12 +1,12 @@ - + Mandate - - + + @@ -17,8 +17,8 @@ ng-repeat="mandate in index.model.instances track by mandate.id" > {{::mandate.id}} - {{::mandate.company}} - {{::mandate.type}} + {{::mandate.company.code}} + {{::mandate.mandateType.name}} {{::mandate.created | date:'dd/MM/yyyy HH:mm' }} {{::mandate.finished | date:'dd/MM/yyyy HH:mm' || '-'}} diff --git a/services/client/common/methods/mandate/filter.js b/services/client/common/methods/mandate/filter.js new file mode 100644 index 000000000..03482cd72 --- /dev/null +++ b/services/client/common/methods/mandate/filter.js @@ -0,0 +1,28 @@ +module.exports = Self => { + Self.installMethod('filter', filterParams); + + function filterParams(params) { + return { + where: { + clientFk: params.clientFk + }, + skip: (params.page - 1) * params.size, + limit: params.size, + order: params.order || 'created DESC', + include: [ + { + relation: "mandateType", + scope: { + fields: ["id", "name"] + } + }, + { + relation: "company", + scope: { + fields: ["id", "code"] + } + } + ] + }; + } +}; diff --git a/services/client/common/models/company.json b/services/client/common/models/company.json new file mode 100644 index 000000000..ae7b0c07f --- /dev/null +++ b/services/client/common/models/company.json @@ -0,0 +1,14 @@ +{ + "name": "company", + "base": "VnModel", + "properties": { + "id": { + "id": true, + "type": "Number", + "description": "Identifier" + }, + "code": { + "type": "String" + } + } + } \ No newline at end of file diff --git a/services/client/common/models/mandate.js b/services/client/common/models/mandate.js new file mode 100644 index 000000000..82fbd6bb4 --- /dev/null +++ b/services/client/common/models/mandate.js @@ -0,0 +1,3 @@ +module.exports = function(Self) { + require('../methods/mandate/filter.js')(Self); +}; diff --git a/services/client/common/models/mandate.json b/services/client/common/models/mandate.json new file mode 100644 index 000000000..1f8c6dd9b --- /dev/null +++ b/services/client/common/models/mandate.json @@ -0,0 +1,32 @@ +{ + "name": "mandate", + "base": "VnModel", + "properties": { + "id": { + "id": true, + "type": "Number", + "description": "Identifier" + }, + "code": { + "type": "String" + }, + "created": { + "type": "date" + }, + "finished": { + "type": "date" + } + }, + "relations": { + "company": { + "type": "belongsTo", + "model": "company", + "foreignKey": "companyFk" + }, + "mandateType": { + "type": "belongsTo", + "model": "mandateType", + "foreignKey": "mandateTypeFk" + } + } + } \ No newline at end of file diff --git a/services/client/common/models/mandateType.json b/services/client/common/models/mandateType.json new file mode 100644 index 000000000..3e6199303 --- /dev/null +++ b/services/client/common/models/mandateType.json @@ -0,0 +1,14 @@ +{ + "name": "mandateType", + "base": "VnModel", + "properties": { + "id": { + "id": true, + "type": "Number", + "description": "Identifier" + }, + "name": { + "type": "String" + } + } + } \ No newline at end of file diff --git a/services/client/server/model-config.json b/services/client/server/model-config.json index c95fb15c7..90ccfeb59 100644 --- a/services/client/server/model-config.json +++ b/services/client/server/model-config.json @@ -65,5 +65,14 @@ }, "greugeType": { "dataSource": "vn" + }, + "mandate": { + "dataSource": "vn" + }, + "mandateType": { + "dataSource": "vn" + }, + "company": { + "dataSource": "vn" } }