credit list terminado
This commit is contained in:
parent
d816853b6c
commit
261d9408ee
|
@ -12,7 +12,7 @@
|
|||
|
||||
<vn-horizontal>
|
||||
<vn-textfield vn-one label="Credit" field="$ctrl.client.credit" type="number" vn-focus></vn-textfield>
|
||||
|
||||
<vn-one></vn-one>
|
||||
</vn-horizontal>
|
||||
|
||||
</vn-vertical>
|
||||
|
|
|
@ -11,19 +11,18 @@
|
|||
<vn-grid-header on-order="$ctrl.onOrder(field, order)">
|
||||
<vn-column-header vn-one pad-medium-h field="amount" text="Credit"></vn-column-header>
|
||||
<vn-column-header vn-two pad-medium-h field="created" text="Since" default-order="ASC"></vn-column-header>
|
||||
<vn-six></vn-six>
|
||||
<vn-column-header vn-two pad-medium-h field="employee.name" text="Employee" order-locked></vn-column-header>
|
||||
</vn-grid-header>
|
||||
<vn-one class="list list-content">
|
||||
<vn-horizontal vn-one class="list list-element text-center" ng-repeat="credit in index.model.instances track by credit.id">
|
||||
<vn-one pad-medium-h>{{::credit.amount | number:2}} €</vn-one>
|
||||
<vn-two pad-medium-h>{{::credit.created | date:'dd/MM/yyyy HH:mm' }}</vn-two>
|
||||
<vn-six></vn-six>
|
||||
<vn-two pad-medium-h>{{::credit.employee.name}}</vn-two>
|
||||
</vn-horizontal>
|
||||
</vn-one>
|
||||
<vn-one class="text-center" ng-if="index.model.count === 0" translate>No results</vn-one>
|
||||
<vn-horizontal vn-one class="list list-footer"></vn-horizontal>
|
||||
<vn-one>
|
||||
<vn-paging index="index" total="index.model.count"></vn-paging>
|
||||
</vn-one>
|
||||
<vn-paging vn-one index="index" total="index.model.count"></vn-paging>
|
||||
</vn-vertical>
|
||||
</vn-card>
|
||||
</vn-vertical>
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
{
|
||||
"Since" : "Desde"
|
||||
"Since" : "Desde",
|
||||
"Employee" : "Empleado",
|
||||
"No results": "Sin resultados"
|
||||
}
|
|
@ -2,7 +2,6 @@ vn-grid-header {
|
|||
border-bottom: 3px solid #9D9D9D;
|
||||
font-weight: bold;
|
||||
.orderly{
|
||||
cursor: pointer;
|
||||
text-align: center;
|
||||
white-space: nowrap;
|
||||
justify-content: center;
|
||||
|
|
|
@ -1,14 +1,31 @@
|
|||
module.exports = function(Self) {
|
||||
Self.installMethod('filter', filterCredits);
|
||||
Self.installMethod('filter', filterParams, filterResults);
|
||||
|
||||
function filterCredits(params) {
|
||||
function filterParams(params) {
|
||||
return {
|
||||
where: {
|
||||
clientFk: params.clientFk
|
||||
},
|
||||
skip: (params.page - 1) * params.size,
|
||||
limit: params.size,
|
||||
order: params.order || 'created DESC'
|
||||
order: params.order || 'created DESC',
|
||||
include: {
|
||||
relation: "employee",
|
||||
scope: {
|
||||
fields: ["id", "name", "surname"]
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function filterResults(instances) {
|
||||
let result = JSON.parse(JSON.stringify(instances));
|
||||
if (result && result.instances && result.instances.length) {
|
||||
result.instances.forEach((element, i) => {
|
||||
result.instances[i].employee.name = `${element.employee.name} ${element.employee.surname}`;
|
||||
delete result.instances[i].employee.surname;
|
||||
});
|
||||
}
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -130,7 +130,7 @@ module.exports = function(Self) {
|
|||
};
|
||||
};
|
||||
|
||||
Self.installMethod = function(methodName, filterCb) {
|
||||
Self.installMethod = function(methodName, filterCb, filterResult) {
|
||||
this.remoteMethod(methodName, {
|
||||
description: 'List items using a filter',
|
||||
accessType: 'READ',
|
||||
|
@ -161,8 +161,12 @@ module.exports = function(Self) {
|
|||
var response = {};
|
||||
|
||||
function returnValues() {
|
||||
if (response.instances !== undefined && response.count !== undefined)
|
||||
cb(null, response);
|
||||
if (response.instances !== undefined && response.count !== undefined) {
|
||||
if (filterResult)
|
||||
cb(null, filterResult(response));
|
||||
else
|
||||
cb(null, response);
|
||||
}
|
||||
}
|
||||
|
||||
function error() {
|
||||
|
|
Loading…
Reference in New Issue