#156 client descriptor icons missing correct icons
This commit is contained in:
parent
c9ba1d00e4
commit
db88d00560
|
@ -25,4 +25,30 @@
|
|||
<span ng-if="!$ctrl.client.creditInsurance">-</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="footer">
|
||||
<vn-icon
|
||||
vn-tooltip="Client inactive"
|
||||
tooltip-position = "right"
|
||||
icon="person"
|
||||
ng-class="{bright: $ctrl.client.isActive == false}">
|
||||
</vn-icon>
|
||||
<vn-icon
|
||||
vn-tooltip="Client Frozen"
|
||||
tooltip-position = "right"
|
||||
icon="mail"
|
||||
ng-class="{bright: $ctrl.client.isFreezed == true}">
|
||||
</vn-icon>
|
||||
<vn-icon
|
||||
vn-tooltip="Web Account inactive"
|
||||
tooltip-position = "right"
|
||||
icon="phone"
|
||||
ng-class="{bright: $ctrl.client.account.active == false}">
|
||||
</vn-icon>
|
||||
<vn-icon
|
||||
vn-tooltip="Client has debt"
|
||||
tooltip-position = "right"
|
||||
icon="power"
|
||||
ng-class="{bright: $ctrl.clientDebt < 0}">
|
||||
</vn-icon>
|
||||
</div>
|
||||
</vn-card>
|
|
@ -1,8 +1,35 @@
|
|||
import ngModule from '../module';
|
||||
|
||||
class ClientDescriptor {
|
||||
constructor($http) {
|
||||
this.$http = $http;
|
||||
}
|
||||
_getClientDebt(clientFk) {
|
||||
this.$http.get(`/client/api/Clients/${clientFk}/getDebt`)
|
||||
.then(response => {
|
||||
this.clientDebt = response.data.debt;
|
||||
});
|
||||
}
|
||||
|
||||
_getClient(clientFk) {
|
||||
this.$http.get(`/client/api/Clients/${clientFk}/card`)
|
||||
.then(response => {
|
||||
Object.assign(this.client, response.data);
|
||||
});
|
||||
}
|
||||
|
||||
$onChanges(changes) {
|
||||
if (changes.client && this.client) {
|
||||
this._getClient(this.client.id);
|
||||
this._getClientDebt(this.client.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ngModule.component('vnClientDescriptor', {
|
||||
template: require('./descriptor.html'),
|
||||
bindings: {
|
||||
client: '<'
|
||||
}
|
||||
},
|
||||
controller: ClientDescriptor
|
||||
});
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
import './descriptor.js';
|
||||
|
||||
describe('Descriptor', () => {
|
||||
describe('Component vnClientDescriptor', () => {
|
||||
let $componentController;
|
||||
let $httpBackend;
|
||||
let controller;
|
||||
|
||||
beforeEach(() => {
|
||||
angular.mock.module('client');
|
||||
});
|
||||
|
||||
beforeEach(angular.mock.inject((_$componentController_, _$httpBackend_) => {
|
||||
$componentController = _$componentController_;
|
||||
$httpBackend = _$httpBackend_;
|
||||
controller = $componentController('vnClientDescriptor');
|
||||
}));
|
||||
|
||||
describe('_getClientDebt()', () => {
|
||||
it(`should call _getClientDebt() and define the client.debt value on the controller`, () => {
|
||||
controller.client = {};
|
||||
let response = {debt: 100};
|
||||
$httpBackend.whenGET(`/client/api/Clients/101/getDebt`).respond(response);
|
||||
$httpBackend.expectGET(`/client/api/Clients/101/getDebt`);
|
||||
controller._getClientDebt(101);
|
||||
$httpBackend.flush();
|
||||
|
||||
expect(controller.client.debt).toEqual(100);
|
||||
});
|
||||
});
|
||||
|
||||
describe('_getClient()', () => {
|
||||
it(`should call _getClient() and define the client value on the controller`, () => {
|
||||
controller.client = {};
|
||||
let response = {id: 101, name: 'Batman'};
|
||||
$httpBackend.whenGET(`/client/api/Clients/101/card`).respond(response);
|
||||
$httpBackend.expectGET(`/client/api/Clients/101/card`);
|
||||
controller._getClient(101);
|
||||
$httpBackend.flush();
|
||||
|
||||
expect(controller.client.name).toEqual('Batman');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
|
@ -138,7 +138,7 @@ vn-main-block {
|
|||
}
|
||||
|
||||
.vn-descriptor {
|
||||
& .header {
|
||||
.header {
|
||||
background: #ffa410;
|
||||
color: white;
|
||||
justify-content: space-between;
|
||||
|
@ -163,6 +163,19 @@ vn-main-block {
|
|||
}
|
||||
}
|
||||
}
|
||||
.footer {
|
||||
text-align: center;
|
||||
& > vn-icon {
|
||||
color: #666;
|
||||
opacity: .4;
|
||||
padding: 0 5% 0 5%;
|
||||
font-size: 1.5em;
|
||||
}
|
||||
& > vn-icon.bright {
|
||||
color: #ffa410;
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.vn-list {
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethod('getDebt', {
|
||||
description: 'Returns the boolean debt of a client',
|
||||
accessType: 'READ',
|
||||
accepts: [{
|
||||
arg: 'id',
|
||||
type: 'number',
|
||||
required: true,
|
||||
description: 'client id',
|
||||
http: {source: 'path'}
|
||||
}],
|
||||
returns: {
|
||||
type: 'number',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/:id/getDebt`,
|
||||
verb: 'GET'
|
||||
}
|
||||
});
|
||||
|
||||
Self.getDebt = async clientFk => {
|
||||
let query = `SELECT vn.clientGetDebt(?, CURDATE()) AS debt`;
|
||||
let response = await Self.rawSql(query, [clientFk]);
|
||||
return response[0];
|
||||
};
|
||||
};
|
|
@ -0,0 +1,16 @@
|
|||
const getDebt = require('../getDebt');
|
||||
|
||||
describe('client getDebt()', () => {
|
||||
it('should call the getDebt method', done => {
|
||||
let clientFk = 109;
|
||||
let self = jasmine.createSpyObj('self', ['remoteMethod', 'rawSql']);
|
||||
self.rawSql.and.returnValue(Promise.resolve([{debt: 100}]));
|
||||
getDebt(self);
|
||||
self.getDebt(clientFk)
|
||||
.then(result => {
|
||||
expect(result.debt).toEqual(100);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
@ -15,6 +15,7 @@ module.exports = function(Self) {
|
|||
require('../methods/client/isValidClient')(Self);
|
||||
require('../methods/client/activeSalesPerson')(Self);
|
||||
require('../methods/client/addressesPropagateRe')(Self);
|
||||
require('../methods/client/getDebt')(Self);
|
||||
|
||||
// Validations
|
||||
|
||||
|
|
|
@ -64,6 +64,10 @@
|
|||
"type": "boolean",
|
||||
"description": "The client has equalization tax"
|
||||
},
|
||||
"isFreezed": {
|
||||
"type": "boolean",
|
||||
"description": "The client frozen"
|
||||
},
|
||||
"hasToInvoiceByAddress": {
|
||||
"type": "boolean",
|
||||
"description": "The client has to be invoiced by address"
|
||||
|
|
Loading…
Reference in New Issue