Merge branch 'dev' of ssh://git.verdnatura.es:/var/lib/git/salix into dev
This commit is contained in:
commit
5db994e263
|
@ -22,6 +22,7 @@
|
||||||
<vn-horizontal>
|
<vn-horizontal>
|
||||||
<vn-textfield vn-one label="Email" field="$ctrl.client.email"></vn-textfield>
|
<vn-textfield vn-one label="Email" field="$ctrl.client.email"></vn-textfield>
|
||||||
<vn-autocomplete vn-one
|
<vn-autocomplete vn-one
|
||||||
|
initial-value="$ctrl.client.salesPerson"
|
||||||
field="$ctrl.client.salesPersonFk"
|
field="$ctrl.client.salesPersonFk"
|
||||||
url="/client/api/Employees"
|
url="/client/api/Employees"
|
||||||
show-field="name"
|
show-field="name"
|
||||||
|
@ -29,6 +30,7 @@
|
||||||
label="Comercial">
|
label="Comercial">
|
||||||
</vn-autocomplete>
|
</vn-autocomplete>
|
||||||
<vn-autocomplete vn-one
|
<vn-autocomplete vn-one
|
||||||
|
initial-value="$ctrl.client.contactChannel"
|
||||||
field="$ctrl.client.contactChannelFk"
|
field="$ctrl.client.contactChannelFk"
|
||||||
url="/client/api/ContactChannels"
|
url="/client/api/ContactChannels"
|
||||||
show-field="name"
|
show-field="name"
|
||||||
|
|
|
@ -7,7 +7,7 @@ export const COMPONENT = {
|
||||||
controllerAs: 'card',
|
controllerAs: 'card',
|
||||||
controller: function($http, $stateParams) {
|
controller: function($http, $stateParams) {
|
||||||
this.client = null;
|
this.client = null;
|
||||||
$http.get(`/client/api/Clients/${$stateParams.id}?filter[include][account]`).then(
|
$http.get(`/client/api/Clients/${$stateParams.id}/card`).then(
|
||||||
json => this.client = json.data
|
json => this.client = json.data
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
<vn-horizontal>
|
<vn-horizontal>
|
||||||
<vn-textfield vn-one label="Código postal" field="fiscal.client.postcode"></vn-textfield>
|
<vn-textfield vn-one label="Código postal" field="fiscal.client.postcode"></vn-textfield>
|
||||||
<vn-autocomplete vn-one
|
<vn-autocomplete vn-one
|
||||||
|
initial-value="fiscal.client.province"
|
||||||
field="fiscal.client.provinceFk"
|
field="fiscal.client.provinceFk"
|
||||||
url="/client/api/Provinces"
|
url="/client/api/Provinces"
|
||||||
show-field="name"
|
show-field="name"
|
||||||
|
@ -27,6 +28,7 @@
|
||||||
label="Provincia">
|
label="Provincia">
|
||||||
</vn-autocomplete>
|
</vn-autocomplete>
|
||||||
<vn-autocomplete vn-one
|
<vn-autocomplete vn-one
|
||||||
|
initial-value="fiscal.client.country"
|
||||||
field="fiscal.client.countryFk"
|
field="fiscal.client.countryFk"
|
||||||
url="/client/api/Countries"
|
url="/client/api/Countries"
|
||||||
show-field="name"
|
show-field="name"
|
||||||
|
@ -42,6 +44,7 @@
|
||||||
<vn-horizontal>
|
<vn-horizontal>
|
||||||
<vn-textfield vn-two label="IBAN" field="fiscal.client.iban"></vn-textfield>
|
<vn-textfield vn-two label="IBAN" field="fiscal.client.iban"></vn-textfield>
|
||||||
<vn-autocomplete vn-two
|
<vn-autocomplete vn-two
|
||||||
|
initial-value="fiscal.client.payMethod"
|
||||||
field="fiscal.client.payMethodFk"
|
field="fiscal.client.payMethodFk"
|
||||||
url="/client/api/PayMethods"
|
url="/client/api/PayMethods"
|
||||||
show-field="name"
|
show-field="name"
|
||||||
|
|
|
@ -27,7 +27,6 @@ export default class Autocomplete extends Component {
|
||||||
this.vnPopover = vnPopover;
|
this.vnPopover = vnPopover;
|
||||||
|
|
||||||
componentHandler.upgradeElement($element[0].firstChild);
|
componentHandler.upgradeElement($element[0].firstChild);
|
||||||
this.requestItem();
|
|
||||||
}
|
}
|
||||||
set field(value) {
|
set field(value) {
|
||||||
this.locked = true;
|
this.locked = true;
|
||||||
|
@ -37,6 +36,14 @@ export default class Autocomplete extends Component {
|
||||||
get field() {
|
get field() {
|
||||||
return this.value;
|
return this.value;
|
||||||
}
|
}
|
||||||
|
set initialValue(value) {
|
||||||
|
if (value) {
|
||||||
|
if (!this.data)
|
||||||
|
this.data = [];
|
||||||
|
this.data.push(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
mdlUpdate() {
|
mdlUpdate() {
|
||||||
let mdlField = this.element.firstChild.MaterialTextfield;
|
let mdlField = this.element.firstChild.MaterialTextfield;
|
||||||
if (mdlField)
|
if (mdlField)
|
||||||
|
@ -191,10 +198,7 @@ export default class Autocomplete extends Component {
|
||||||
this.hasFocus = true;
|
this.hasFocus = true;
|
||||||
this.input.select();
|
this.input.select();
|
||||||
|
|
||||||
if (this.data)
|
this.loadData();
|
||||||
this.showPopover();
|
|
||||||
else
|
|
||||||
this.loadData();
|
|
||||||
}
|
}
|
||||||
onBlur() {
|
onBlur() {
|
||||||
this.hasFocus = false;
|
this.hasFocus = false;
|
||||||
|
@ -340,6 +344,7 @@ export default class Autocomplete extends Component {
|
||||||
this.item = item;
|
this.item = item;
|
||||||
this.mdlUpdate();
|
this.mdlUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Autocomplete.$inject = ['$element', '$scope', '$http', 'vnPopover'];
|
Autocomplete.$inject = ['$element', '$scope', '$http', 'vnPopover'];
|
||||||
|
|
||||||
|
@ -349,6 +354,7 @@ module.component('vnAutocomplete', {
|
||||||
url: '@',
|
url: '@',
|
||||||
showField: '@',
|
showField: '@',
|
||||||
valueField: '@',
|
valueField: '@',
|
||||||
|
initialValue: '<',
|
||||||
field: '=',
|
field: '=',
|
||||||
label: '@'
|
label: '@'
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
|
|
||||||
module.exports = function(Client) {
|
module.exports = function(Client) {
|
||||||
|
|
||||||
|
require("../scopes/client/card.js")(Client);
|
||||||
|
require("../scopes/client/activate.js")(Client);
|
||||||
|
require("../scopes/client/addresses.js")(Client);
|
||||||
|
|
||||||
// Validations
|
// Validations
|
||||||
|
|
||||||
Client.validatesUniquenessOf('name', {message: 'El nombre debe ser único'});
|
Client.validatesUniquenessOf('name', {message: 'El nombre debe ser único'});
|
||||||
Client.validatesUniquenessOf('fi', {message: 'El NIF/CIF debe ser único'});
|
Client.validatesUniquenessOf('fi', {message: 'El NIF/CIF debe ser único'});
|
||||||
Client.validatesPresenceOf('socialName', {message: 'Debe especificarse la razón social'});
|
Client.validatesPresenceOf('socialName', {message: 'Debe especificarse la razón social'});
|
||||||
|
@ -42,36 +45,6 @@ module.exports = function(Client) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Methods
|
|
||||||
|
|
||||||
Client.remoteMethod('activate', {
|
|
||||||
description: 'Activate or deactive client',
|
|
||||||
accepts: {
|
|
||||||
arg: 'id',
|
|
||||||
type: 'number',
|
|
||||||
required: true,
|
|
||||||
description: 'Model id',
|
|
||||||
http: {source: 'path'}
|
|
||||||
},
|
|
||||||
returns: {
|
|
||||||
arg: 'active',
|
|
||||||
type: 'boolean'
|
|
||||||
},
|
|
||||||
http: {
|
|
||||||
verb: 'put',
|
|
||||||
path: '/:id/activate'
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Client.activate = function(id, cb) {
|
|
||||||
console.log(id);
|
|
||||||
Client.findById(id, function(err, client) {
|
|
||||||
if(!err) {
|
|
||||||
Client.update({id: client.id}, {active: !client.active});
|
|
||||||
cb(null, !client.active);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// Basic filter
|
// Basic filter
|
||||||
|
|
||||||
|
@ -93,53 +66,4 @@ module.exports = function(Client) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Client addresses
|
|
||||||
|
|
||||||
Client.remoteMethod('addressesList', {
|
|
||||||
description: 'List items using a filter',
|
|
||||||
accessType: 'READ',
|
|
||||||
accepts: [
|
|
||||||
{
|
|
||||||
arg: 'id',
|
|
||||||
type: 'string',
|
|
||||||
required: true,
|
|
||||||
description: 'Model id',
|
|
||||||
http: {source: 'path'}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
arg: 'filter',
|
|
||||||
type: 'object',
|
|
||||||
required: true,
|
|
||||||
description: 'Filter defining where',
|
|
||||||
http: function(ctx) {
|
|
||||||
return ctx.req.query;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
returns: {
|
|
||||||
arg: 'data',
|
|
||||||
type: ['Address'],
|
|
||||||
root: true
|
|
||||||
},
|
|
||||||
http: {
|
|
||||||
path: `/:id/addressesList`,
|
|
||||||
verb: 'get'
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Client.addressesList = function(id, p, cb) {
|
|
||||||
let filter = {
|
|
||||||
where: {
|
|
||||||
clientFk: id,
|
|
||||||
},
|
|
||||||
skip: (p.page - 1) * p.size,
|
|
||||||
limit: p.size
|
|
||||||
};
|
|
||||||
|
|
||||||
Client.app.models.Address.find(filter, function(err, instances) {
|
|
||||||
if(!err) {
|
|
||||||
cb(null, instances);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
};
|
|
||||||
};
|
};
|
|
@ -149,12 +149,5 @@
|
||||||
"permission": "ALLOW"
|
"permission": "ALLOW"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"methods": {},
|
"methods": {}
|
||||||
"scopes": {
|
}
|
||||||
"test": {
|
|
||||||
"where": {
|
|
||||||
"name": "Verdnatura"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
module.exports = function(Client){
|
||||||
|
Client.remoteMethod('activate', {
|
||||||
|
description: 'Activate or deactive client',
|
||||||
|
accepts: {
|
||||||
|
arg: 'id',
|
||||||
|
type: 'number',
|
||||||
|
required: true,
|
||||||
|
description: 'Model id',
|
||||||
|
http: {source: 'path'}
|
||||||
|
},
|
||||||
|
returns: {
|
||||||
|
arg: 'active',
|
||||||
|
type: 'boolean'
|
||||||
|
},
|
||||||
|
http: {
|
||||||
|
verb: 'put',
|
||||||
|
path: '/:id/activate'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Client.activate = function(id, cb) {
|
||||||
|
Client.findById(id, function(err, client) {
|
||||||
|
if(!err) {
|
||||||
|
Client.update({id: client.id}, {active: !client.active});
|
||||||
|
cb(null, !client.active);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
};
|
|
@ -0,0 +1,49 @@
|
||||||
|
module.exports = function(Client){
|
||||||
|
Client.remoteMethod('addressesList', {
|
||||||
|
description: 'List items using a filter',
|
||||||
|
accessType: 'READ',
|
||||||
|
accepts: [
|
||||||
|
{
|
||||||
|
arg: 'id',
|
||||||
|
type: 'string',
|
||||||
|
required: true,
|
||||||
|
description: 'Model id',
|
||||||
|
http: {source: 'path'}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'filter',
|
||||||
|
type: 'object',
|
||||||
|
required: true,
|
||||||
|
description: 'Filter defining where',
|
||||||
|
http: function(ctx) {
|
||||||
|
return ctx.req.query;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
returns: {
|
||||||
|
arg: 'data',
|
||||||
|
type: ['Address'],
|
||||||
|
root: true
|
||||||
|
},
|
||||||
|
http: {
|
||||||
|
path: `/:id/addressesList`,
|
||||||
|
verb: 'get'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Client.addressesList = function(id, p, cb) {
|
||||||
|
let filter = {
|
||||||
|
where: {
|
||||||
|
clientFk: id,
|
||||||
|
},
|
||||||
|
skip: (p.page - 1) * p.size,
|
||||||
|
limit: p.size
|
||||||
|
};
|
||||||
|
|
||||||
|
Client.app.models.Address.find(filter, function(err, instances) {
|
||||||
|
if(!err) {
|
||||||
|
cb(null, instances);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
};
|
||||||
|
}
|
|
@ -0,0 +1,39 @@
|
||||||
|
module.exports = function(Client) {
|
||||||
|
// Validations
|
||||||
|
var card = require('./card.json');
|
||||||
|
|
||||||
|
Client.remoteMethod('card', {
|
||||||
|
description: 'Get client for card call',
|
||||||
|
accepts: {
|
||||||
|
arg: 'id',
|
||||||
|
type: 'number',
|
||||||
|
required: true,
|
||||||
|
description: 'Model id',
|
||||||
|
http: {source: 'path'}
|
||||||
|
},
|
||||||
|
returns: {
|
||||||
|
arg: 'data',
|
||||||
|
type: 'Client',
|
||||||
|
root: true
|
||||||
|
},
|
||||||
|
http: {
|
||||||
|
verb: 'get',
|
||||||
|
path: '/:id/card'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Client.card = function(id, cb) {
|
||||||
|
let filter = {
|
||||||
|
where: {
|
||||||
|
id: id
|
||||||
|
},
|
||||||
|
include: card
|
||||||
|
};
|
||||||
|
|
||||||
|
Client.find(filter, function(err, instances) {
|
||||||
|
if(!err) {
|
||||||
|
cb(null, instances[0]);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
};
|
||||||
|
};
|
|
@ -0,0 +1,43 @@
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"relation": "salesPerson",
|
||||||
|
"scope":{
|
||||||
|
"fields": {
|
||||||
|
"id": true, "name": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"relation": "contactChannel",
|
||||||
|
"scope":{
|
||||||
|
"fields": {
|
||||||
|
"id": true, "name": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"relation": "province",
|
||||||
|
"scope":{
|
||||||
|
"fields": {
|
||||||
|
"id": true, "name": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"relation": "country",
|
||||||
|
"scope":{
|
||||||
|
"fields": {
|
||||||
|
"id": true, "name": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"relation": "payMethod",
|
||||||
|
"scope":{
|
||||||
|
"fields": {
|
||||||
|
"id": true, "name": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
Loading…
Reference in New Issue