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

This commit is contained in:
Carlos Jimenez 2018-11-14 18:06:04 +01:00
commit 295486c7ad
5 changed files with 126 additions and 96 deletions

View File

@ -19,14 +19,13 @@ class Controller {
}, },
}, },
{ {
relation: 'tracking', relation: 'state',
scope: { scope: {
fields: ['stateFk'], fields: ['stateFk'],
include: { include: {
relation: 'state', relation: 'state',
fields: ['name'], fields: ['id', 'name'],
}, }
order: 'created DESC'
}, },
}, },
], ],
@ -55,5 +54,5 @@ Controller.$inject = ['$http', '$state'];
ngModule.component('vnTicketCard', { ngModule.component('vnTicketCard', {
template: require('./index.html'), template: require('./index.html'),
controller: Controller, controller: Controller
}); });

View File

@ -275,3 +275,11 @@
message="Continue anyway?" message="Continue anyway?"
on-response="$ctrl.onRemoveLinesClick(response)"> on-response="$ctrl.onRemoveLinesClick(response)">
</vn-confirm> </vn-confirm>
<vn-float-button
ng-show="$ctrl.isEditable"
ng-click="$ctrl.newOrderFromTicket()"
icon="add"
vn-tooltip="New item"
vn-bind="+"
fixed-bottom-right>
</vn-float-button>

View File

@ -68,7 +68,7 @@ class Controller {
get isEditable() { get isEditable() {
try { try {
return !this.ticket.tracking.state.alertLevel; return !this.ticket.state.state.alertLevel;
} catch (e) {} } catch (e) {}
return true; return true;
@ -324,6 +324,13 @@ class Controller {
this.$scope.model.refresh(); this.$scope.model.refresh();
}); });
} }
newOrderFromTicket() {
this.$http.post(`/api/Orders/newFromTicket`, {ticketFk: this.ticket.id}).then(res => {
this.$state.go('order.card.catalog', {id: res.data});
this.vnApp.showSuccess(this.$translate.instant('Order created'));
});
}
} }
Controller.$inject = ['$scope', '$state', '$http', 'vnApp', '$translate']; Controller.$inject = ['$scope', '$state', '$http', 'vnApp', '$translate'];

View File

@ -615,6 +615,17 @@ describe('Ticket Edit sale path', () => {
expect(result).toEqual(1); expect(result).toEqual(1);
}); });
it(`should click on the search result to access to the ticket Sale`, async () => {
const url = await nightmare
.waitForTextInElement(selectors.ticketsIndex.searchResult, 'address 21')
.waitToClick(selectors.ticketsIndex.searchResult)
.waitToClick(selectors.ticketSales.saleButton)
.waitForURL('/sale')
.url();
expect(url).toContain('/sale');
});
}); });
describe('when state is preparation and loged as salesPerson', () => { describe('when state is preparation and loged as salesPerson', () => {

View File

@ -81,7 +81,7 @@
"foreignKey": "ticketFk" "foreignKey": "ticketFk"
}, },
"tracking": { "tracking": {
"type": "hasOne", "type": "hasMany",
"model": "TicketTracking", "model": "TicketTracking",
"foreignKey": "ticketFk" "foreignKey": "ticketFk"
}, },
@ -94,6 +94,11 @@
"type": "hasOne", "type": "hasOne",
"model": "TicketState", "model": "TicketState",
"foreignKey": "ticketFk" "foreignKey": "ticketFk"
},
"state": {
"type": "hasOne",
"model": "TicketState",
"foreignKey": "ticketFk"
} }
} }
} }