Merge branch 'dev' of https://git.verdnatura.es/salix into dev
This commit is contained in:
commit
c2c4aa23cf
|
@ -8,7 +8,8 @@
|
|||
"url": "/order",
|
||||
"state": "order",
|
||||
"abstract": true,
|
||||
"component": "ui-view"
|
||||
"component": "ui-view",
|
||||
"acl": ["developer"]
|
||||
},
|
||||
{
|
||||
"url": "/index?q",
|
||||
|
|
|
@ -9,15 +9,17 @@
|
|||
show-field="name"
|
||||
value-field="id"
|
||||
field="$ctrl.clientFk"
|
||||
initial-data="$ctrl.clientFk"
|
||||
on-change="$ctrl.onChange()">
|
||||
initial-data="$ctrl.clientFk">
|
||||
</vn-autocomplete>
|
||||
<vn-autocomplete vn-one
|
||||
url="{{$ctrl.getAddresses()}}"
|
||||
data="$ctrl.addresses"
|
||||
label="Address"
|
||||
show-field="nickname"
|
||||
value-field="id"
|
||||
field="$ctrl.ticket.addressFk">
|
||||
<tpl-item>{{::nickname}}
|
||||
<span ng-show="city || province">- {{::city}} ({{::province.name}})</span>
|
||||
</tpl-item>
|
||||
</vn-autocomplete>
|
||||
<vn-autocomplete vn-one
|
||||
url="/api/AgencyModes"
|
||||
|
|
|
@ -9,9 +9,27 @@ class Controller {
|
|||
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) {
|
||||
this.ticket.clientFk = value;
|
||||
this.ticket.addressFk = null;
|
||||
|
||||
this.onChange(value);
|
||||
}
|
||||
|
||||
get clientFk() {
|
||||
|
@ -19,13 +37,24 @@ class Controller {
|
|||
return this.ticket.clientFk;
|
||||
}
|
||||
|
||||
$onInit() {
|
||||
this.data.registerChild(this);
|
||||
}
|
||||
onChange(value) {
|
||||
let filter = {
|
||||
include: [
|
||||
{
|
||||
relation: 'province',
|
||||
scope: {
|
||||
fields: ['name']
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
filter = encodeURIComponent(JSON.stringify(filter));
|
||||
|
||||
getAddresses() {
|
||||
if (this.ticket && this.ticket.addressFk)
|
||||
return `/api/Clients/${this.ticket.clientFk}/addresses`;
|
||||
let query = `/api/Clients/${value}/addresses?filter=${filter}`;
|
||||
this.$http.get(query).then(res => {
|
||||
if (res.data)
|
||||
this.addresses = res.data;
|
||||
});
|
||||
}
|
||||
|
||||
async onStepChange(state) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import './index.js';
|
||||
|
||||
describe('ticket', () => {
|
||||
fdescribe('ticket', () => {
|
||||
describe('Component vnTicketDataStepOne', () => {
|
||||
let $componentController;
|
||||
let $state;
|
||||
|
@ -19,6 +19,25 @@ describe('ticket', () => {
|
|||
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()', () => {
|
||||
it('should check if all form fields are valid', () => {
|
||||
controller.ticket = {
|
||||
|
@ -31,8 +50,7 @@ describe('ticket', () => {
|
|||
landed: new Date()
|
||||
};
|
||||
|
||||
let result = controller.isFormInvalid();
|
||||
expect(result).toBeFalsy();
|
||||
expect(controller.isFormInvalid()).toBeFalsy();
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -41,7 +59,7 @@ describe('ticket', () => {
|
|||
let landed = new Date();
|
||||
landed.setHours(0, 0, 0, 0);
|
||||
|
||||
controller.ticket = {
|
||||
controller._ticket = {
|
||||
id: 1,
|
||||
clientFk: 1,
|
||||
addressFk: 121,
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
UPDATE `salix`.`ACL` SET `accessType`='*' WHERE `id`='58';
|
||||
UPDATE `salix`.`ACL` SET `accessType`='*' WHERE `id`='60';
|
Loading…
Reference in New Issue