Merge branch 'dev' of https://git.verdnatura.es/salix into dev

This commit is contained in:
gerard 2018-07-11 09:56:11 +02:00
commit c2c4aa23cf
5 changed files with 66 additions and 14 deletions

View File

@ -8,7 +8,8 @@
"url": "/order", "url": "/order",
"state": "order", "state": "order",
"abstract": true, "abstract": true,
"component": "ui-view" "component": "ui-view",
"acl": ["developer"]
}, },
{ {
"url": "/index?q", "url": "/index?q",

View File

@ -9,15 +9,17 @@
show-field="name" show-field="name"
value-field="id" value-field="id"
field="$ctrl.clientFk" field="$ctrl.clientFk"
initial-data="$ctrl.clientFk" initial-data="$ctrl.clientFk">
on-change="$ctrl.onChange()">
</vn-autocomplete> </vn-autocomplete>
<vn-autocomplete vn-one <vn-autocomplete vn-one
url="{{$ctrl.getAddresses()}}" data="$ctrl.addresses"
label="Address" label="Address"
show-field="nickname" show-field="nickname"
value-field="id" value-field="id"
field="$ctrl.ticket.addressFk"> field="$ctrl.ticket.addressFk">
<tpl-item>{{::nickname}}
<span ng-show="city || province">- {{::city}} ({{::province.name}})</span>
</tpl-item>
</vn-autocomplete> </vn-autocomplete>
<vn-autocomplete vn-one <vn-autocomplete vn-one
url="/api/AgencyModes" url="/api/AgencyModes"

View File

@ -9,9 +9,27 @@ class Controller {
this.vnApp = vnApp; this.vnApp = vnApp;
} }
$onInit() {
this.data.registerChild(this);
}
set ticket(value) {
this._ticket = value;
if (!value || !value.id) return;
this.onChange(value.clientFk);
}
get ticket() {
return this._ticket;
}
set clientFk(value) { set clientFk(value) {
this.ticket.clientFk = value; this.ticket.clientFk = value;
this.ticket.addressFk = null; this.ticket.addressFk = null;
this.onChange(value);
} }
get clientFk() { get clientFk() {
@ -19,13 +37,24 @@ class Controller {
return this.ticket.clientFk; return this.ticket.clientFk;
} }
$onInit() { onChange(value) {
this.data.registerChild(this); let filter = {
include: [
{
relation: 'province',
scope: {
fields: ['name']
} }
}
]
};
filter = encodeURIComponent(JSON.stringify(filter));
getAddresses() { let query = `/api/Clients/${value}/addresses?filter=${filter}`;
if (this.ticket && this.ticket.addressFk) this.$http.get(query).then(res => {
return `/api/Clients/${this.ticket.clientFk}/addresses`; if (res.data)
this.addresses = res.data;
});
} }
async onStepChange(state) { async onStepChange(state) {

View File

@ -1,6 +1,6 @@
import './index.js'; import './index.js';
describe('ticket', () => { fdescribe('ticket', () => {
describe('Component vnTicketDataStepOne', () => { describe('Component vnTicketDataStepOne', () => {
let $componentController; let $componentController;
let $state; let $state;
@ -19,6 +19,25 @@ describe('ticket', () => {
controller = $componentController('vnTicketDataStepOne', {$state: $state}); controller = $componentController('vnTicketDataStepOne', {$state: $state});
})); }));
describe('ticket() setter', () => {
it('should set ticket property and call onChange() method ', () => {
spyOn(controller, 'onChange');
controller.ticket = {id: 1, clientFk: 101};
expect(controller.onChange).toHaveBeenCalledWith(101);
});
});
describe('clientFk() setter', () => {
it('should set clientFk property and call onChange() method ', () => {
spyOn(controller, 'onChange');
controller.ticket = {id: 1, clientFk: 101};
controller.clientFk = 102;
expect(controller.onChange).toHaveBeenCalledWith(102);
});
});
describe('isFormInvalid()', () => { describe('isFormInvalid()', () => {
it('should check if all form fields are valid', () => { it('should check if all form fields are valid', () => {
controller.ticket = { controller.ticket = {
@ -31,8 +50,7 @@ describe('ticket', () => {
landed: new Date() landed: new Date()
}; };
let result = controller.isFormInvalid(); expect(controller.isFormInvalid()).toBeFalsy();
expect(result).toBeFalsy();
}); });
}); });
@ -41,7 +59,7 @@ describe('ticket', () => {
let landed = new Date(); let landed = new Date();
landed.setHours(0, 0, 0, 0); landed.setHours(0, 0, 0, 0);
controller.ticket = { controller._ticket = {
id: 1, id: 1,
clientFk: 1, clientFk: 1,
addressFk: 121, addressFk: 121,

View File

@ -0,0 +1,2 @@
UPDATE `salix`.`ACL` SET `accessType`='*' WHERE `id`='58';
UPDATE `salix`.`ACL` SET `accessType`='*' WHERE `id`='60';