item & ticket crud-refactor #372

This commit is contained in:
Joan Sanchez 2018-07-17 08:44:31 +02:00
parent 7e1a2025a5
commit ef71f5c7cf
23 changed files with 516 additions and 290 deletions

View File

@ -83,9 +83,13 @@ vn-table {
text-align: left; text-align: left;
padding: 10px; padding: 10px;
&[number]{ &[number] {
text-align: right; text-align: right;
} }
&[center] {
text-align: center;
}
vn-icon.bright, i.bright { vn-icon.bright, i.bright {
color: #f7931e; color: #f7931e;

View File

@ -1,44 +1,59 @@
<mg-ajax path="/ticket/api/Expeditions/filter" options="vnIndexNonAuto"></mg-ajax> <vn-crud-model
vn-id="model"
url="/ticket/api/Expeditions"
filter="::$ctrl.filter"
link="{ticketFk: $ctrl.$stateParams.id}"
limit="20"
data="expeditions">
</vn-crud-model>
<vn-vertical> <vn-vertical>
<vn-card pad-large> <vn-card pad-large>
<vn-vertical> <vn-vertical>
<vn-title>Expedition</vn-title> <vn-title>Expedition</vn-title>
<vn-grid-header on-order="$ctrl.onOrder(field, order)"> <vn-table model="model">
<vn-column-header vn-one pad-medium-h text="Delete"></vn-column-header> <vn-thead>
<vn-column-header vn-one pad-medium-h field="itemFk" text="Item"></vn-column-header> <vn-tr>
<vn-column-header vn-one pad-medium-h field="name" text="Name" order-locked></vn-column-header> <vn-th></vn-th>
<vn-column-header vn-one pad-medium-h field="packageFk" text="Package type"></vn-column-header> <vn-th field="itemFk" number>Item</vn-th>
<vn-column-header vn-one pad-medium-h field="counter" text="Counter"></vn-column-header> <vn-th field="name">Name</vn-th>
<vn-column-header vn-one pad-medium-h field="checked" text="Checked"></vn-column-header> <vn-th field="isBox">Package type</vn-th>
<vn-column-header vn-one pad-medium-h field="worker" text="Worker"></vn-column-header> <vn-th field="counter" number>Counter</vn-th>
<vn-column-header vn-one pad-medium-h field="created" text="Created" default-order="DESC"></vn-column-header> <vn-th field="checked" number>Checked</vn-th>
</vn-grid-header> <vn-th field="worker">Worker</vn-th>
<vn-one class="list list-content"> <vn-th field="created" default-order="DESC">Created</vn-th>
<vn-horizontal </vn-tr>
vn-one class="list list-element text-center" </vn-thead>
pad-small-bottom <vn-tbody>
ng-repeat="expedition in index.model.instances track by expedition.id"> <vn-tr ng-repeat="expedition in expeditions">
<vn-one pad-medium-h style="color:#FFA410;"> <vn-td pad-medium-h style="color:#FFA410;">
<i <i
pointer pointer
class="material-icons" class="material-icons"
vn-tooltip="delete expedition" vn-tooltip="Delete expedition"
ng-click="$ctrl.deleteExpedition(expedition)">delete</i> ng-click="$ctrl.deleteExpedition(expedition)">delete</i>
</vn-one> </vn-td>
<vn-one pointer number <vn-td pointer number
ng-click="$ctrl.showDescriptor($event, expedition.item.id)">{{::expedition.itemFk}}</vn-one> ng-click="$ctrl.showDescriptor($event, expedition.item.id)">
<vn-one pad-medium-h>{{::expedition.item.name}}</vn-one> {{::expedition.itemFk}}
<vn-one pad-medium-h>{{::expedition.package.name}}</vn-one> </vn-td>
<vn-one pad-medium-h>{{::expedition.counter}}</vn-one> <vn-td>{{::expedition.item.name}}</vn-td>
<vn-one pad-medium-h>{{::expedition.checked}}</vn-one> <vn-td>{{::expedition.box.name}}</vn-td>
<vn-one pad-medium-h>{{::expedition.worker.firstName}} {{::expedition.worker.name}}</vn-one> <vn-td number>{{::expedition.counter}}</vn-td>
<vn-one pad-medium-h>{{::expedition.created | date:'dd/MM/yyyy'}}</vn-one> <vn-td number>{{::expedition.checked}}</vn-td>
</vn-horizontal> <vn-td>{{::expedition.worker.firstName}} {{::expedition.worker.name}}</vn-td>
</vn-one> <vn-td>{{::expedition.created | date:'dd/MM/yyyy'}}</vn-td>
<vn-one class="text-center pad-small-v" ng-if="index.model.count === 0" translate>No results</vn-one> </vn-tr>
<vn-horizontal vn-one class="list list-footer"></vn-horizontal> </vn-tbody>
<vn-empty-rows ng-if="model.data.length === 0" translate>
No results
</vn-empty-rows>
</vn-table>
</vn-vertical> </vn-vertical>
<vn-pagination
model="model"
scroll-selector="ui-view">
</vn-pagination>
</vn-card> </vn-card>
<vn-paging vn-one margin-large-top index="index" total="index.model.count"></vn-paging>
</vn-vertical> </vn-vertical>
<vn-item-descriptor-popover vn-id="descriptor"></vn-item-descriptor-popover> <vn-item-descriptor-popover vn-id="descriptor"></vn-item-descriptor-popover>

View File

@ -1,17 +1,33 @@
import ngModule from '../module'; import ngModule from '../module';
import FilterTicketList from '../filter-ticket-list';
class Controller extends FilterTicketList { class Controller {
constructor($scope, $timeout, $stateParams, $http) { constructor($scope, $stateParams, $http) {
super($scope, $timeout, $stateParams);
this.$scope = $scope; this.$scope = $scope;
this.params = $stateParams; this.$stateParams = $stateParams;
this.$http = $http; this.$http = $http;
this.filter = {
include: [{
relation: 'item',
scope: {
fields: ['name']
}
},
{
relation: 'box',
scope: {
fields: ['name']
}
},
{
relation: 'worker',
scope: {fields: ['firstName', 'name']}
}]
};
} }
deleteExpedition(expedition) { deleteExpedition(expedition) {
this.$http.delete(`/ticket/api/Expeditions/${expedition.id}`, this.params).then( this.$http.delete(`/ticket/api/Expeditions/${expedition.id}`, this.params).then(
() => this.$.index.accept() () => this.$scope.model.refresh()
); );
} }
@ -26,7 +42,7 @@ class Controller extends FilterTicketList {
} }
} }
Controller.$inject = ['$scope', '$timeout', '$state', '$http']; Controller.$inject = ['$scope', '$stateParams', '$http'];
ngModule.component('vnTicketExpedition', { ngModule.component('vnTicketExpedition', {
template: require('./index.html'), template: require('./index.html'),

View File

@ -6,7 +6,11 @@ vn-fetched-tags {
flex-direction: column; flex-direction: column;
text-align: center; text-align: center;
& vn-two { & > vn-one {
padding: 0 0 0.2em 0;
}
& > vn-two {
text-align: center; text-align: center;
margin: 0 auto margin: 0 auto
} }
@ -29,7 +33,7 @@ vn-fetched-tags {
& vn-one { & vn-one {
padding-top: 6px padding-top: 0.2em
} }
& vn-two { & vn-two {

View File

@ -12,7 +12,7 @@ Counter: Contador
Created : Añadido Created : Añadido
Date : Fecha Date : Fecha
Delete: Borrar Delete: Borrar
delete expedition: borrar expedición Delete expedition: Borrar expedición
Description: Descripción Description: Descripción
Discount: Descuento Discount: Descuento
Employee : Empleado Employee : Empleado

View File

@ -1,37 +1,49 @@
<mg-ajax path="/ticket/api/sales/filter" options="vnIndexNonAuto"></mg-ajax> <vn-crud-model
vn-id="model"
url="/ticket/api/sales"
filter="::$ctrl.filter"
link="{ticketFk: $ctrl.$stateParams.id}"
limit="20"
data="sales">
</vn-crud-model>
<vn-vertical> <vn-vertical>
<vn-card pad-large> <vn-card pad-large>
<vn-vertical> <vn-vertical>
<vn-title>Sale checked</vn-title> <vn-title>Sale checked</vn-title>
<table class="vn-grid"> <vn-table model="model">
<thead> <vn-thead>
<tr> <vn-tr>
<th style="text-align:center" translate>Is checked</th> <vn-th field="isChecked" center>Is checked</vn-th>
<th number translate>Item</th> <vn-th field="itemFk" number>Item</vn-th>
<th translate>Description</th> <vn-th field="concept" default-order="ASC">Description</vn-th>
<th number translate>Quantity</th> <vn-th field="quantity" number>Quantity</vn-th>
</tr> </vn-tr>
</thead> </vn-thead>
<tbody> <vn-tbody>
<tr ng-repeat="sale in index.model.instances track by sale.id"> <vn-tr ng-repeat="sale in sales">
<td style="text-align:center!important"> <vn-td center>
<vn-check style="text-align:center!important" <vn-check
vn-one field="sale.isChecked.isChecked" vn-one field="sale.isChecked.isChecked"
disabled="true"> disabled="true">
</vn-check> </vn-check>
</td> </vn-td>
<td number pointer <vn-td number pointer
ng-click="$ctrl.showDescriptor($event, sale.itemFk)">{{::sale.itemFk}}</td> ng-click="$ctrl.showDescriptor($event, sale.itemFk)">
<td><vn-fetched-tags sale="sale"/></td> {{::sale.itemFk}}
<td number>{{::sale.quantity}}</td> </vn-td>
</tr> <vn-td><vn-fetched-tags sale="sale"/></vn-td>
<tr ng-if="index.model.count === 0" class="list list-element"> <vn-td number>{{::sale.quantity}}</vn-td>
<td colspan="4" style="text-align: center" translate>No results</td> </vn-tr>
</tr> </vn-tbody>
</tbody> <vn-empty-rows ng-if="model.data.length === 0" translate>
</table> No results
</vn-empty-rows>
</vn-table>
</vn-vertical> </vn-vertical>
<vn-pagination
model="model"
scroll-selector="ui-view">
</vn-pagination>
</vn-card> </vn-card>
<vn-paging vn-one margin-large-top index="index" total="index.model.count"></vn-paging> </vn-vertical>
</vn-vertical>
<vn-item-descriptor-popover vn-id="descriptor"></vn-item-descriptor-popover> <vn-item-descriptor-popover vn-id="descriptor"></vn-item-descriptor-popover>

View File

@ -1,11 +1,36 @@
import ngModule from '../module'; import ngModule from '../module';
import FilterTicketList from '../filter-ticket-list';
class Controller extends FilterTicketList { class Controller {
constructor($scope, $timeout, $state) { constructor($scope, $stateParams) {
super($scope, $timeout, $state);
this.$scope = $scope; this.$scope = $scope;
this.onOrder('quantity', 'ASC'); this.$stateParams = $stateParams;
this.filter = {
include: [{
relation: 'item',
scope: {
include: {
relation: 'tags',
scope: {
fields: ['tagFk', 'value'],
include: {
relation: 'tag',
scope: {
fields: ['name']
}
},
limit: 6
}
},
fields: ['itemFk', 'name']
}
},
{
relation: 'isChecked',
scope: {
fields: ['isChecked']
}
}]
};
} }
showDescriptor(event, itemFk) { showDescriptor(event, itemFk) {
@ -19,7 +44,7 @@ class Controller extends FilterTicketList {
} }
} }
Controller.$inject = ['$scope', '$timeout', '$state']; Controller.$inject = ['$scope', '$stateParams'];
ngModule.component('vnTicketSaleChecked', { ngModule.component('vnTicketSaleChecked', {
template: require('./index.html'), template: require('./index.html'),

View File

@ -1,10 +1,11 @@
<vn-crud-model <vn-crud-model
vn-id="model" vn-id="model"
url="/ticket/api/SaleTrackings/listSaleTracking" url="/ticket/api/SaleTrackings/listSaleTracking"
filter="::$ctrl.filter" filter="{}"
link="{ticketFk: $ctrl.$stateParams.id}"
limit="20" limit="20"
data="sales" data="sales"
auto-load="true" on-data-change="$ctrl.getTags()"> on-data-change="$ctrl.getTags()">
</vn-crud-model> </vn-crud-model>
<vn-vertical> <vn-vertical>
<vn-card pad-large> <vn-card pad-large>
@ -51,12 +52,11 @@
</vn-empty-rows> </vn-empty-rows>
</vn-table> </vn-table>
</vn-vertical> </vn-vertical>
<vn-pagination
model="model"
scroll-selector="ui-view">
</vn-pagination>
</vn-card> </vn-card>
<vn-pagination
model="model"
scroll-selector="ui-view">
</vn-pagination>
</vn-vertical> </vn-vertical>
<vn-item-descriptor-popover vn-id="descriptor"></vn-item-descriptor-popover> <vn-item-descriptor-popover vn-id="descriptor"></vn-item-descriptor-popover>

View File

@ -1,12 +1,9 @@
import ngModule from '../module'; import ngModule from '../module';
class Controller { class Controller {
constructor($scope, $state, $http) { constructor($scope, $stateParams) {
this.$scope = $scope; this.$scope = $scope;
this.$http = $http; this.$stateParams = $stateParams;
this.filter = {
where: {ticketFk: $state.params.id}
};
} }
showDescriptor(event, itemFk) { showDescriptor(event, itemFk) {
@ -20,7 +17,7 @@ class Controller {
} }
} }
Controller.$inject = ['$scope', '$state', '$http']; Controller.$inject = ['$scope', '$stateParams'];
ngModule.component('vnTicketSaleTracking', { ngModule.component('vnTicketSaleTracking', {
template: require('./index.html'), template: require('./index.html'),

View File

@ -1,3 +1,10 @@
<vn-crud-model
vn-id="model"
url="/api/Tickets/{{$ctrl.$stateParams.id}}/getSales"
filter="{}"
data="sales" on-data-change="$ctrl.onDataChange()">
</vn-crud-model>
<vn-vertical> <vn-vertical>
<vn-card pad-large> <vn-card pad-large>
<vn-vertical> <vn-vertical>
@ -38,99 +45,125 @@
icon="call_split"> icon="call_split">
</vn-button> </vn-button>
</vn-tool-bar> </vn-tool-bar>
<table class="vn-grid"> <vn-table model="model">
<thead> <vn-thead>
<tr> <vn-tr>
<th number> <vn-th number>
<vn-multi-check <vn-multi-check
data="$ctrl.sales" data="$ctrl.sales"
disabled="!$ctrl.isEditable"> disabled="!$ctrl.isEditable">
</vn-multi-check> </vn-multi-check>
</th> </vn-th>
<th></th> <vn-th></vn-th>
<th style="text-align: center" translate>Item</th> <vn-th>Item</vn-th>
<th number translate>Id</th> <vn-th number>Id</vn-th>
<th style="text-align: center" translate>Description</th> <vn-th>Description</vn-th>
<th number translate>Quantity</th> <vn-th number>Quantity</vn-th>
<th number translate>Price</th> <vn-th number>Price</vn-th>
<th number translate>Disc</th> <vn-th number>Disc</vn-th>
<th number translate>Amount</th> <vn-th number>Amount</vn-th>
</tr> </vn-tr>
</thead> </vn-thead>
<tbody> <vn-tbody>
<tr ng-repeat="sale in $ctrl.sales"> <vn-tr ng-repeat="sale in sales">
<td number> <vn-td number>
<vn-check <vn-check
field="sale.checked" field="sale.checked"
disabled="!$ctrl.isEditable"> disabled="!$ctrl.isEditable">
</vn-check> </vn-check>
</td> </vn-td>
<td> <vn-td>
<vn-icon ng-show="sale.visible" icon="warning" vn-tooltip="Visible: {{::sale.visible}}"></vn-icon> <vn-icon
<vn-icon ng-show="sale.avaible" icon="warning" vn-tooltip="Avaible: {{::sale.avaible}}"></vn-icon> ng-show="sale.visible"
icon="warning"
vn-tooltip="Visible: {{::sale.visible}}">
</vn-icon>
<vn-icon
ng-show="sale.avaible"
icon="warning"
vn-tooltip="Avaible: {{::sale.avaible}}">
</vn-icon>
<vn-icon ng-show="sale.reserved" icon="icon-reserved"></vn-icon> <vn-icon ng-show="sale.reserved" icon="icon-reserved"></vn-icon>
</td> </vn-td>
<td style="text-align: center"> <vn-td style="text-align: center">
<img <img
ng-src="//verdnatura.es/vn-image-data/catalog/50x50/{{sale.image}}" ng-src="//verdnatura.es/vn-image-data/catalog/50x50/{{sale.image}}"
zoom-image="//verdnatura.es/vn-image-data/catalog/900x900/{{sale.image}}" zoom-image="//verdnatura.es/vn-image-data/catalog/900x900/{{sale.image}}"
on-error-src/> on-error-src/>
</td> </vn-td>
<td <vn-td ng-click="$ctrl.showDescriptor($event, sale.itemFk)"
pointer pointer number>
number
ng-click="$ctrl.showDescriptor($event, sale.itemFk)">
{{::sale.itemFk}} {{::sale.itemFk}}
</td> </vn-td>
<vn-td><vn-fetched-tags sale="sale"/></vn-td>
<td><vn-fetched-tags sale="sale"/></td> <vn-td ng-if="!$ctrl.isEditable" number>{{sale.quantity}}</vn-td>
<td ng-if="!$ctrl.isEditable" number>{{sale.quantity}}</td> <vn-td ng-if="$ctrl.isEditable" number>
<td ng-if="$ctrl.isEditable" number>
<vn-textfield <vn-textfield
model="sale.quantity" model="sale.quantity"
on-change="$ctrl.updateQuantity(sale.id,sale.quantity)" on-change="$ctrl.updateQuantity(sale.id,sale.quantity)"
type="text"> type="text">
</vn-textfield> </vn-textfield>
</td> </vn-td>
<td number <vn-td number
ng-if="$ctrl.isEditable" ng-if="$ctrl.isEditable"
ng-click="$ctrl.showEditPricePopover($event, sale)" ng-click="$ctrl.showEditPricePopover($event, sale)"
pointer pointer
vn-tooltip="Edit price"> vn-tooltip="Edit price">
{{sale.price | currency:'€':2}} {{sale.price | currency:'€':2}}
</td> </vn-td>
<td number ng-if="!$ctrl.isEditable"> <vn-td number ng-if="!$ctrl.isEditable">
{{sale.price | currency:'€':2}} {{sale.price | currency:'€':2}}
</td> </vn-td>
<td number <vn-td number
ng-if="$ctrl.isEditable" ng-if="$ctrl.isEditable"
ng-click="$ctrl.showEditPopover($event, sale)" ng-click="$ctrl.showEditPopover($event, sale)"
pointer pointer
vn-tooltip="Edit discount"> vn-tooltip="Edit discount">
{{sale.discount}} % {{sale.discount}} %
</td> </vn-td>
<td number <vn-td number
ng-if="!$ctrl.isEditable"> ng-if="!$ctrl.isEditable">
{{sale.discount}} % {{sale.discount}} %
</td> </vn-td>
<td number>{{(sale.quantity * sale.price) - ((sale.discount * (sale.quantity * sale.price))/100) | currency:' €':2}}</td> <vn-td number>
</tr> {{(sale.quantity * sale.price) -
<tr ng-if="$ctrl.sales.length === 0 || !$ctrl.sales" class="list list-element"> ((sale.discount * (sale.quantity * sale.price))/100) | currency:' €':2
<td colspan="9" style="text-align: center" translate>No results</td> }}
</tr> </vn-td>
<tfoot> </vn-tr>
<tr> </vn-tbody>
<td number colspan="9"> <vn-empty-rows ng-if="model.data.length === 0" translate>
<section> No results
<p><vn-label translate>Subtotal</vn-label> {{$ctrl.subTotal | currency:' €':2}}</p> </vn-empty-rows>
<p><vn-label translate>VAT</vn-label> {{$ctrl.VAT | currency:' €':2}}</p> <vn-tfoot>
<p><vn-label><strong>Total</strong></vn-label> <strong>{{$ctrl.total | currency:' €':2}}</strong></p> <vn-tr ng-if="model.data.length > 0">
</section> <vn-td></vn-td>
</td> <vn-td></vn-td>
</tr> <vn-td></vn-td>
</tfoot> <vn-td></vn-td>
</tbody> <vn-td></vn-td>
</table> <vn-td></vn-td>
<vn-td></vn-td>
<vn-td></vn-td>
<vn-td number>
<section>
<p>
<vn-label translate>Subtotal</vn-label>
<span>{{$ctrl.subTotal | currency:' €':2}}</span>
</p>
<p>
<vn-label translate>VAT</vn-label>
<span>{{$ctrl.VAT | currency:' €':2}}</span>
</p>
<p>
<vn-label><strong>Total</strong></vn-label>
<strong>{{$ctrl.total | currency:' €':2}}</strong>
</p>
</section>
</vn-td>
</vn-tr>
</vn-tfoot>
</vn-table>
</vn-vertical> </vn-vertical>
</vn-card> </vn-card>
<vn-item-descriptor-popover vn-id="descriptor"> <vn-item-descriptor-popover vn-id="descriptor">
@ -298,7 +331,7 @@
</vn-vertical> </vn-vertical>
<vn-confirm <vn-confirm
vn-id="deleteConfirmation" vn-id="deleteConfirmation"
on-response="$ctrl.deleteTicket(response)" on-response="$ctrl.returnDeleteTicketDialog(response)"
question="You are going to delete this ticket" question="You are going to delete this ticket"
message="Continue anyway?"> message="Continue anyway?">
</vn-confirm> </vn-confirm>

View File

@ -2,12 +2,12 @@ import ngModule from '../module';
import './style.scss'; import './style.scss';
class Controller { class Controller {
constructor($scope, $timeout, $stateParams, $http, vnApp, $translate) { constructor($scope, $state, $http, vnApp, $translate) {
this.$ = $scope; this.$scope = $scope;
this.vnApp = vnApp; this.vnApp = vnApp;
this.translate = $translate; this.translate = $translate;
this.$timeout = $timeout; this.$state = $state;
this.$state = $stateParams; this.$stateParams = $state.params;
this.$http = $http; this.$http = $http;
this.deletable = false; this.deletable = false;
this.edit = {}; this.edit = {};
@ -20,24 +20,21 @@ class Controller {
]; ];
} }
getSales() { onDataChange() {
this.$http.get(`/api/Tickets/${this.ticket.id}/getSales`).then(res => { this.sales = this.$scope.model.data;
this.sales = res.data; this.getTaxes();
this.getTaxes();
});
}
$onChanges() {
if (this.ticket && this.ticket.clientFk)
this.getSales(this.ticket.clientFk);
} }
onMoreOpen() { onMoreOpen() {
let options = this.moreOptions.filter(o => o.always || this.isChecked); let options = this.moreOptions.filter(o => o.always || this.isChecked);
this.$.moreButton.data = options; this.$scope.moreButton.data = options;
} }
getTaxes() { getTaxes() {
this.getSubTotal(); this.getSubTotal();
this.getVAT(); this.getVAT();
} }
getSubTotal() { getSubTotal() {
let sales = this.sales; let sales = this.sales;
@ -46,12 +43,14 @@ class Controller {
this.subTotal += (sale.quantity * sale.price) - ((sale.discount * (sale.quantity * sale.price)) / 100); this.subTotal += (sale.quantity * sale.price) - ((sale.discount * (sale.quantity * sale.price)) / 100);
}); });
} }
getVAT() { getVAT() {
this.$http.get(`/ticket/api/Tickets/${this.ticket.id}/getVAT`).then(res => { this.$http.get(`/ticket/api/Tickets/${this.ticket.id}/getVAT`).then(res => {
this.VAT = res.data || 0; this.VAT = res.data || 0;
this.total = this.subTotal + this.VAT; this.total = this.subTotal + this.VAT;
}); });
} }
get isEditable() { get isEditable() {
try { try {
return !this.ticket.tracking.state.alertLevel; return !this.ticket.tracking.state.alertLevel;
@ -59,6 +58,7 @@ class Controller {
return true; return true;
} }
get isChecked() { get isChecked() {
let data = this.sales; let data = this.sales;
if (data) if (data)
@ -68,6 +68,7 @@ class Controller {
return false; return false;
} }
getCheckedLines() { getCheckedLines() {
let lines = []; let lines = [];
let data = this.sales; let data = this.sales;
@ -78,9 +79,11 @@ class Controller {
return lines; return lines;
} }
onMoreChange(callback) { onMoreChange(callback) {
callback.call(this); callback.call(this);
} }
// Change State // Change State
onStateOkClick() { onStateOkClick() {
let filter = {where: {code: "OK"}, fields: ["id"]}; let filter = {where: {code: "OK"}, fields: ["id"]};
@ -89,6 +92,7 @@ class Controller {
this.onStateChange(res.data[0].id); this.onStateChange(res.data[0].id);
}); });
} }
onStateChange(value) { onStateChange(value) {
let params = {ticketFk: this.$state.params.id, stateFk: value}; let params = {ticketFk: this.$state.params.id, stateFk: value};
this.$http.post(`/ticket/api/TicketTrackings/changeState`, params).then(() => { this.$http.post(`/ticket/api/TicketTrackings/changeState`, params).then(() => {
@ -96,21 +100,25 @@ class Controller {
this.vnApp.showSuccess(this.translate.instant('Data saved!')); this.vnApp.showSuccess(this.translate.instant('Data saved!'));
}); });
} }
// Add Turn // Add Turn
showAddTurnDialog() { showAddTurnDialog() {
this.$.addTurn.show(); this.$scope.addTurn.show();
} }
addTurn(day) { addTurn(day) {
let params = {ticketFk: this.$state.params.id, weekDay: day}; let params = {ticketFk: this.$state.params.id, weekDay: day};
this.$http.patch(`/ticket/api/TicketWeeklies`, params).then(() => { this.$http.patch(`/ticket/api/TicketWeeklies`, params).then(() => {
this.$.addTurn.hide(); this.$scope.addTurn.hide();
this.vnApp.showSuccess(this.translate.instant('Data saved!')); this.vnApp.showSuccess(this.translate.instant('Data saved!'));
}); });
} }
// Delete Ticket // Delete Ticket
showDeleteTicketDialog() { showDeleteTicketDialog() {
this.$.deleteConfirmation.show(); this.$scope.deleteConfirmation.show();
} }
deleteTicket(response) { deleteTicket(response) {
if (response === 'ACCEPT') { if (response === 'ACCEPT') {
let params = {id: this.$state.params.id}; let params = {id: this.$state.params.id};
@ -120,6 +128,7 @@ class Controller {
}); });
} }
} }
// Remove Lines // Remove Lines
onRemoveLinesClick(response) { onRemoveLinesClick(response) {
if (response === 'ACCEPT') { if (response === 'ACCEPT') {
@ -131,14 +140,17 @@ class Controller {
}); });
} }
} }
removeInstances(instances) { removeInstances(instances) {
for (let i = instances.length - 1; i >= 0; i--) { for (let i = instances.length - 1; i >= 0; i--) {
this.sales.splice(instances[i].instance, 1); this.sales.splice(instances[i].instance, 1);
} }
} }
showRemoveLinesDialog() { showRemoveLinesDialog() {
this.$.deleteLines.show(); this.$scope.deleteLines.show();
} }
// Move Lines // Move Lines
showTransferPopover(event) { showTransferPopover(event) {
let filter = {clientFk: this.ticket.clientFk, ticketFk: this.ticket.id}; let filter = {clientFk: this.ticket.clientFk, ticketFk: this.ticket.id};
@ -147,9 +159,10 @@ class Controller {
this.$http.get(query).then(res => { this.$http.get(query).then(res => {
this.lastThreeTickets = res.data; this.lastThreeTickets = res.data;
}); });
this.$.transfer.parent = event.target; this.$scope.transfer.parent = event.target;
this.$.transfer.show(); this.$scope.transfer.show();
} }
moveLines(ticketID) { moveLines(ticketID) {
let sales = this.getCheckedLines(); let sales = this.getCheckedLines();
@ -158,6 +171,7 @@ class Controller {
this.goToTicket(ticketID); this.goToTicket(ticketID);
}); });
} }
// In Progress // In Progress
linesToNewTicket() { linesToNewTicket() {
let ticket = { let ticket = {
@ -173,13 +187,15 @@ class Controller {
this.$http.post(`/api/Sales/MoveToNewTicket`, {ticket: ticket, sales: sales}).then(res => { this.$http.post(`/api/Sales/MoveToNewTicket`, {ticket: ticket, sales: sales}).then(res => {
let url = this.$state.href("ticket.card.sale", {id: res.data}, {absolute: true}); let url = this.$state.href("ticket.card.sale", {id: res.data}, {absolute: true});
window.open(url, '_blank'); window.open(url, '_blank');
this.$.transfer.hide(); this.$scope.transfer.hide();
this.getSales(); this.$scope.model.refresh();
}); });
} }
goToTicket(ticketID) { goToTicket(ticketID) {
this.$state.go("ticket.card.sale", {id: ticketID}); this.$state.go("ticket.card.sale", {id: ticketID});
} }
// Focus First Input // Focus First Input
focusFirstInput(e) { focusFirstInput(e) {
let firstFocusable = e.querySelector('input, textarea'); let firstFocusable = e.querySelector('input, textarea');
@ -192,21 +208,25 @@ class Controller {
}, 200); }, 200);
} }
} }
// Slesperson Mana // Slesperson Mana
getManaSalespersonMana() { getManaSalespersonMana() {
this.$http.get(`/api/Tickets/${this.$state.params.id}/getSalesPersonMana`).then(res => { this.$http.get(`/api/Tickets/${this.$state.params.id}/getSalesPersonMana`).then(res => {
this.mana = res.data; this.mana = res.data;
}); });
} }
// Item Descriptor // Item Descriptor
showDescriptor(event, itemFk) { showDescriptor(event, itemFk) {
this.$.descriptor.itemFk = itemFk; this.$scope.descriptor.itemFk = itemFk;
this.$.descriptor.parent = event.target; this.$scope.descriptor.parent = event.target;
this.$.descriptor.show(); this.$scope.descriptor.show();
} }
onDescriptorLoad() { onDescriptorLoad() {
this.$.popover.relocate(); this.$scope.popover.relocate();
} }
// Edit Line // Edit Line
showEditPricePopover(event, sale) { showEditPricePopover(event, sale) {
this.sale = sale; this.sale = sale;
@ -216,19 +236,21 @@ class Controller {
id: sale.id, id: sale.id,
quantity: sale.quantity quantity: sale.quantity
}; };
this.$.editPricePopover.parent = event.target; this.$scope.editPricePopover.parent = event.target;
this.$.editPricePopover.show(); this.$scope.editPricePopover.show();
this.focusFirstInput(this.$.editPricePopover.$element[0]); this.focusFirstInput(this.$scope.editPricePopover.$element[0]);
} }
updatePrice() { updatePrice() {
if (this.editedPrice != this.sale.price) { if (this.editedPrice != this.sale.price) {
this.$http.post(`/ticket/api/Sales/updatePrice`, {id: this.edit.id, price: this.editedPrice, ticketFk: this.ticket.id}).then(() => { this.$http.post(`/ticket/api/Sales/updatePrice`, {id: this.edit.id, price: this.editedPrice, ticketFk: this.ticket.id}).then(() => {
this.sale.price = this.edit.price; this.sale.price = this.edit.price;
this.getSales(); this.$scope.model.refresh();
}); });
} }
this.$.editPricePopover.hide(); this.$scope.editPricePopover.hide();
} }
showEditPopover(event, sale) { showEditPopover(event, sale) {
this.sale = sale; this.sale = sale;
this.edit = [{ this.edit = [{
@ -238,29 +260,33 @@ class Controller {
price: sale.price, price: sale.price,
discount: sale.discount discount: sale.discount
}]; }];
this.$.editPopover.parent = event.target; this.$scope.editPopover.parent = event.target;
this.$.editPopover.show(); this.$scope.editPopover.show();
this.focusFirstInput(this.$.editPopover.$element[0]); this.focusFirstInput(this.$scope.editPopover.$element[0]);
} }
showEditDialog() { showEditDialog() {
this.edit = this.getCheckedLines(); this.edit = this.getCheckedLines();
this.$.editDialog.show(); this.$scope.editDialog.show();
this.focusFirstInput(this.$.editDialog.$element[0]); this.focusFirstInput(this.$scope.editDialog.$element[0]);
} }
hideEditDialog() { hideEditDialog() {
this.getSales(); this.$scope.model.refresh();
this.$.editDialog.hide(); this.$scope.editDialog.hide();
} }
hideEditPopover() { hideEditPopover() {
this.getSales(); this.$scope.model.refresh();
this.$.editPopover.hide(); this.$scope.editPopover.hide();
} }
updateQuantity(id, quantity) { updateQuantity(id, quantity) {
this.$http.post(`/ticket/api/Sales/${id}/updateQuantity`, {quantity: parseInt(quantity)}).then(() => { this.$http.post(`/ticket/api/Sales/${id}/updateQuantity`, {quantity: parseInt(quantity)}).then(() => {
this.vnApp.showSuccess(this.translate.instant('Data saved!')); this.vnApp.showSuccess(this.translate.instant('Data saved!'));
}).catch(e => { }).catch(e => {
this.vnApp.showError(this.translate.instant(e.data.error.message)); this.vnApp.showError(this.translate.instant(e.data.error.message));
this.getSales(); this.$scope.model.refresh();
}); });
} }
@ -283,12 +309,12 @@ class Controller {
let params = {sales: sales, ticketFk: this.ticket.id, reserved: reserved}; let params = {sales: sales, ticketFk: this.ticket.id, reserved: reserved};
this.$http.post(`/ticket/api/Sales/reserve`, params).then(() => { this.$http.post(`/ticket/api/Sales/reserve`, params).then(() => {
this.getSales(); this.$scope.model.refresh();
}); });
} }
} }
Controller.$inject = ['$scope', '$timeout', '$state', '$http', 'vnApp', '$translate']; Controller.$inject = ['$scope', '$state', '$http', 'vnApp', '$translate'];
ngModule.component('vnTicketSale', { ngModule.component('vnTicketSale', {
template: require('./index.html'), template: require('./index.html'),

View File

@ -22,7 +22,7 @@ describe('Ticket', () => {
$state.params.id = 1; $state.params.id = 1;
controller = $componentController('vnTicketSale', {$scope: $scope}, {$state: $state}); controller = $componentController('vnTicketSale', {$scope: $scope}, {$state: $state});
controller.ticket = {id: 1}; controller.ticket = {id: 1};
controller.$ = {index: {model: {instances: [ controller.$scope = {model: {data: [
{ {
id: 1, id: 1,
quantity: 5, quantity: 5,
@ -41,16 +41,32 @@ describe('Ticket', () => {
return { return {
then: () => {} then: () => {}
}; };
}}}; }};
})); }));
describe('getSales()', () => { describe('getSales()', () => {
it('should make a query and call getTaxes()', () => { it('should make a query and call getTaxes()', () => {
spyOn(controller, 'getTaxes'); let data = [
$httpBackend.expectGET(`/api/Tickets/1/getSales`).respond(); {
controller.getSales(); id: 1,
$httpBackend.flush(); quantity: 5,
price: 23.5,
discount: 0,
checked: true
},
{
id: 4,
quantity: 20,
price: 5.5,
discount: 0,
checked: true
}
];
spyOn(controller, 'getTaxes');
controller.onDataChange();
expect(controller.sales).toEqual(data);
expect(controller.getTaxes).toHaveBeenCalledWith(); expect(controller.getTaxes).toHaveBeenCalledWith();
}); });
}); });
@ -123,22 +139,22 @@ describe('Ticket', () => {
}); });
describe('showAddTurnDialog()', () => { describe('showAddTurnDialog()', () => {
it('should call contrtoller.$.addTurn.show()', () => { it('should call contrtoller.$scope.addTurn.show()', () => {
controller.$.addTurn = {show: () => {}}; controller.$scope.addTurn = {show: () => {}};
spyOn(controller.$.addTurn, 'show'); spyOn(controller.$scope.addTurn, 'show');
controller.showAddTurnDialog(); controller.showAddTurnDialog();
expect(controller.$.addTurn.show).toHaveBeenCalledWith(); expect(controller.$scope.addTurn.show).toHaveBeenCalledWith();
}); });
}); });
xdescribe('addTurn(day)', () => { xdescribe('addTurn(day)', () => {
it('should make a query and call $.addTurn.hide() and vnApp.showSuccess()', () => { it('should make a query and call $.addTurn.hide() and vnApp.showSuccess()', () => {
controller.$.addTurn = {hide: () => {}}; controller.$scope.addTurn = {hide: () => {}};
spyOn(controller.$.addTurn, 'hide'); spyOn(controller.$scope.addTurn, 'hide');
controller.showAddTurnDialog(); controller.showAddTurnDialog();
expect(controller.$.addTurn.show).toHaveBeenCalledWith(); expect(controller.$scope.addTurn.show).toHaveBeenCalledWith();
}); });
}); });

View File

@ -52,7 +52,7 @@ vn-ticket-sale {
} }
vn-popover.transfer{ vn-popover.transfer{
table { vn-table {
min-width: 650px; min-width: 650px;
margin-bottom: 10px; margin-bottom: 10px;
} }
@ -71,7 +71,7 @@ vn-ticket-sale {
} }
} }
table { vn-table {
vn-textfield { vn-textfield {
max-width: 100px; max-width: 100px;
float: right; float: right;

View File

@ -1,29 +1,42 @@
<mg-ajax path="/ticket/api/TicketTrackings/filter" options="vnIndexNonAuto"></mg-ajax> <vn-crud-model
vn-id="model"
url="/ticket/api/TicketTrackings"
filter="::$ctrl.filter"
link="{ticketFk: $ctrl.$stateParams.id}"
limit="20"
data="trackings">
</vn-crud-model>
<vn-vertical> <vn-vertical>
<vn-card pad-large> <vn-card pad-large>
<vn-vertical> <vn-vertical>
<vn-title>Tracking</vn-title> <vn-title>Tracking</vn-title>
<vn-grid-header on-order="$ctrl.onOrder(field, order)"> <vn-table model="model">
<vn-column-header vn-one pad-medium-h field="state.name" text="State" order-locked></vn-column-header> <vn-thead>
<vn-column-header vn-two pad-medium-h field="employee" text="Employee" order-locked></vn-column-header> <vn-tr>
<vn-column-header vn-two pad-medium-h field="created" text="Created" default-order="ASC"></vn-column-header> <vn-th field="state">State</vn-th>
</vn-grid-header> <vn-th field="worker">Worker</vn-th>
<vn-one class="list list-content"> <vn-th field="created" default-order="DESC">Created</vn-th>
<vn-horizontal </vn-tr>
vn-one class="list list-element text-center" </vn-thead>
pad-small-bottom <vn-tbody>
ng-repeat="ticket in index.model.instances track by ticket.id"> <vn-tr ng-repeat="tracking in trackings">
<vn-one pad-medium-h>{{::ticket.state.name}}</vn-one> <vn-td>{{::tracking.state.name}}</vn-td>
<vn-two pad-medium-h>{{::ticket.worker.firstName}} {{ticket.worker.name}}</vn-two> <vn-td>{{::tracking.worker.firstName}} {{ticket.worker.name}}</vn-td>
<vn-two pad-medium-h>{{::ticket.created | date:'dd/MM/yyyy HH:mm'}}</vn-two> <vn-td>{{::tracking.created | date:'dd/MM/yyyy HH:mm'}}</vn-td>
</vn-horizontal> </vn-tr>
</vn-one> </vn-tbody>
<vn-one class="text-center pad-small-v" ng-if="index.model.count === 0" translate>No results</vn-one> <vn-empty-rows ng-if="model.data.length === 0" translate>
<vn-horizontal vn-one class="list list-footer"></vn-horizontal> No results
</vn-empty-rows>
</vn-table>
</vn-vertical> </vn-vertical>
<vn-pagination
model="model"
scroll-selector="ui-view">
</vn-pagination>
</vn-card> </vn-card>
<vn-paging vn-one margin-large-top index="index" total="index.model.count"></vn-paging> </vn-vertical>
</vn-vertical>
<a ui-sref="ticket.card.tracking.edit" vn-bind="+" vn-visible-by="production" fixed-bottom-right> <a ui-sref="ticket.card.tracking.edit" vn-bind="+" vn-visible-by="production" fixed-bottom-right>
<vn-float-button icon="add"></vn-float-button> <vn-float-button icon="add"></vn-float-button>
</a> </a>

View File

@ -1,7 +1,30 @@
import ngModule from '../../module'; import ngModule from '../../module';
import FilterTicketList from '../../filter-ticket-list';
class Controller {
constructor($stateParams) {
this.$stateParams = $stateParams;
this.filter = {
include: [
{
relation: "worker",
scope: {
fields: ["firstName", "name"]
}
},
{
relation: "state",
scope: {
fields: ["name"]
}
}
]
};
}
}
Controller.$inject = ['$stateParams'];
ngModule.component('vnTicketTrackingIndex', { ngModule.component('vnTicketTrackingIndex', {
template: require('./index.html'), template: require('./index.html'),
controller: FilterTicketList controller: Controller
}); });

View File

@ -1,5 +1,12 @@
<mg-ajax path="/ticket/api/sales/filter" options="vnIndexNonAuto" actions="$ctrl.setVolumes()"></mg-ajax> <vn-crud-model
<mg-ajax path="/client/api/tickets/{{edit.params.id}}/getTotalVolume" options="mgEdit"></mg-ajax> vn-id="model"
url="/ticket/api/sales"
filter="::$ctrl.filter"
link="{itemFk: $ctrl.$stateParams.id}"
limit="20"
data="sales" on-data-change="$ctrl.onDataChange()">
</vn-crud-model>
<mg-ajax path="/client/api/tickets/{{$ctrl.$stateParams.id}}/getTotalVolume" options="mgEdit"></mg-ajax>
<vn-vertical> <vn-vertical>
<vn-card pad-large> <vn-card pad-large>
<vn-vertical> <vn-vertical>
@ -12,31 +19,36 @@
value="{{::edit.model.totalBoxes}}"> value="{{::edit.model.totalBoxes}}">
</vn-label-value> </vn-label-value>
</vn-one> </vn-one>
<table class="vn-grid"> <vn-table model="model">
<thead> <vn-thead>
<tr> <vn-tr>
<th number translate>Item</th> <vn-th field="itemFk" number>Item</vn-th>
<th translate>Description</th> <vn-th field="concept" default-order="ASC">Description</vn-th>
<th number translate>Quantity</th> <vn-th field="quantity" number>Quantity</vn-th>
<th number translate>m³ per quantity</th> <vn-th number>m³ per quantity</vn-th>
</tr> </vn-tr>
</thead> </vn-thead>
<tbody> <vn-tbody>
<tr ng-repeat="sale in index.model.instances track by sale.id" class="list list-element"> <vn-tr ng-repeat="sale in sales">
<td number pointer <vn-td number pointer
ng-click="$ctrl.showDescriptor($event, sale.itemFk)">{{::sale.itemFk}}</td> ng-click="$ctrl.showDescriptor($event, sale.itemFk)">
<td><vn-fetched-tags sale="sale"/></td> {{::sale.itemFk}}
<td number>{{::sale.quantity}}</td> </vn-td>
<td number>{{::sale.volume.m3 | number:3}}</td> <vn-td><vn-fetched-tags sale="sale"/></vn-td>
</tr> <vn-td number>{{::sale.quantity}}</vn-td>
<tr ng-if="index.model.count === 0" class="list list-element"> <vn-td number>{{::sale.volume.m3 | number:3}}</vn-td>
<td colspan="6" style="text-align: center" translate>No results</td> </vn-tr>
</tr> </vn-tbody>
</tbody> <vn-empty-rows ng-if="model.data.length === 0" translate>
</table> No results
</vn-empty-rows>
</vn-table>
</vn-vertical> </vn-vertical>
<vn-pagination
model="model"
scroll-selector="ui-view">
</vn-pagination>
</vn-card> </vn-card>
<vn-paging vn-one margin-large-top index="index" total="index.model.count"></vn-paging> </vn-vertical>
</vn-vertical>
<vn-item-descriptor-popover vn-id="descriptor"></vn-item-descriptor-popover> <vn-item-descriptor-popover vn-id="descriptor"></vn-item-descriptor-popover>

View File

@ -1,24 +1,41 @@
import ngModule from '../module'; import ngModule from '../module';
import FilterTicketList from '../filter-ticket-list';
import './style.scss'; import './style.scss';
class Controller extends FilterTicketList { class Controller {
constructor($scope, $http, $translate, $timeout, $state) { constructor($scope, $http, $stateParams) {
super($scope, $timeout, $state);
this.$scope = $scope; this.$scope = $scope;
this.$http = $http; this.$http = $http;
this.$translate = $translate; this.$stateParams = $stateParams;
this.onOrder('itemFk', 'ASC'); this.filter = {
include: [{
relation: 'item',
scope: {
include: {
relation: 'tags',
scope: {
fields: ['tagFk', 'value'],
include: {
relation: 'tag',
scope: {
fields: ['name']
}
},
limit: 6
}
},
fields: ['itemFk', 'name']
}
}]
};
this.ticketVolumes = []; this.ticketVolumes = [];
} }
setVolumes() { onDataChange() {
if (!this.$scope.index) return;
this.$http.get(`/api/tickets/${this.ticket.id}/getVolume`) this.$http.get(`/api/tickets/${this.ticket.id}/getVolume`)
.then(response => { .then(response => {
if (response.data) { if (response.data) {
this.$scope.index.model.instances.forEach(sale => { this.$scope.model.data.forEach(sale => {
response.data.volumes.forEach(volume => { response.data.volumes.forEach(volume => {
if (sale.id === volume.saleFk) { if (sale.id === volume.saleFk) {
sale.volume = volume; sale.volume = volume;
@ -40,7 +57,7 @@ class Controller extends FilterTicketList {
} }
} }
Controller.$inject = ['$scope', '$http', '$translate', '$timeout', '$state']; Controller.$inject = ['$scope', '$http', '$stateParams'];
ngModule.component('vnTicketVolume', { ngModule.component('vnTicketVolume', {
template: require('./index.html'), template: require('./index.html'),

View File

@ -17,7 +17,7 @@ describe('ticket', () => {
$httpBackend = _$httpBackend_; $httpBackend = _$httpBackend_;
$httpBackend.when('GET', /\/locale\/\w+\/[a-z]{2}\.json/).respond({}); $httpBackend.when('GET', /\/locale\/\w+\/[a-z]{2}\.json/).respond({});
$scope = $rootScope.$new(); $scope = $rootScope.$new();
$scope.index = {model: {instances: [{id: 1}, {id: 2}]}, accept: () => { $scope.model = {data: [{id: 1}, {id: 2}], accept: () => {
return { return {
then: () => {} then: () => {}
}; };
@ -32,11 +32,11 @@ describe('ticket', () => {
let response = {volumes: [{saleFk: 1, m3: 0.008}, {saleFk: 2, m3: 0.003}]}; let response = {volumes: [{saleFk: 1, m3: 0.008}, {saleFk: 2, m3: 0.003}]};
$httpBackend.whenGET(`/api/tickets/1/getVolume`).respond(response); $httpBackend.whenGET(`/api/tickets/1/getVolume`).respond(response);
$httpBackend.expectGET(`/api/tickets/1/getVolume`); $httpBackend.expectGET(`/api/tickets/1/getVolume`);
controller.setVolumes(); controller.onDataChange();
$httpBackend.flush(); $httpBackend.flush();
expect($scope.index.model.instances[0].volume.m3).toBe(0.008); expect($scope.model.data[0].volume.m3).toBe(0.008);
expect($scope.index.model.instances[1].volume.m3).toBe(0.003); expect($scope.model.data[1].volume.m3).toBe(0.003);
}); });
}); });
}); });

View File

@ -292,8 +292,8 @@ export default {
}, },
ticketExpedition: { ticketExpedition: {
expeditionButton: `vn-menu-item a[ui-sref="ticket.card.expedition"]`, expeditionButton: `vn-menu-item a[ui-sref="ticket.card.expedition"]`,
secondExpeditionRemoveButton: `body > vn-app > vn-vertical > vn-vertical > ui-view > vn-ticket-card > vn-main-block > vn-horizontal > vn-one > vn-vertical > vn-ticket-expedition > vn-vertical > vn-card > div > vn-vertical > vn-one > vn-horizontal:nth-child(2) > vn-one:nth-child(1) > i`, secondExpeditionRemoveButton: `vn-ticket-expedition vn-table div > vn-tbody > vn-tr:nth-child(2) > vn-td:nth-child(1) > i`,
secondExpeditionText: `body > vn-app > vn-vertical > vn-vertical > ui-view > vn-ticket-card > vn-main-block > vn-horizontal > vn-one > vn-vertical > vn-ticket-expedition > vn-vertical > vn-card > div > vn-vertical > vn-one > vn-horizontal:nth-child(2)` secondExpeditionText: `vn-ticket-expedition vn-table div > vn-tbody > vn-tr:nth-child(2)`
}, },
ticketPackages: { ticketPackages: {
packagesButton: `vn-menu-item a[ui-sref="ticket.card.package.index"]`, packagesButton: `vn-menu-item a[ui-sref="ticket.card.package.index"]`,
@ -307,14 +307,14 @@ export default {
}, },
ticketSales: { ticketSales: {
saleButton: `vn-menu-item a[ui-sref="ticket.card.sale"]`, saleButton: `vn-menu-item a[ui-sref="ticket.card.sale"]`,
firstSaleText: `table > tbody > tr:nth-child(1)`, firstSaleText: `vn-table div > vn-tbody > vn-tr:nth-child(1)`,
secondSaleText: `table > tbody > tr:nth-child(2)` secondSaleText: `vn-table div > vn-tbody > vn-tr:nth-child(2)`
}, },
ticketTracking: { ticketTracking: {
trackingButton: `vn-menu-item a[ui-sref="ticket.card.tracking.index"]`, trackingButton: `vn-menu-item a[ui-sref="ticket.card.tracking.index"]`,
createStateButton: `${components.vnFloatButton}`, createStateButton: `${components.vnFloatButton}`,
firstSaleText: `table > tbody > tr:nth-child(1)`, firstSaleText: `vn-table div > vn-tbody > vn-tr:nth-child(1)`,
secondSaleText: `table > tbody > tr:nth-child(2)` secondSaleText: `vn-table div > vn-tbody > vn-tr:nth-child(2)`
}, },
createStateView: { createStateView: {
stateInput: `vn-autocomplete[field="$ctrl.ticket.stateFk"] > div > div > input`, stateInput: `vn-autocomplete[field="$ctrl.ticket.stateFk"] > div > div > input`,

View File

@ -1,7 +1,7 @@
import selectors from '../../helpers/selectors.js'; import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/helpers'; import createNightmare from '../../helpers/helpers';
describe('Item', () => { fdescribe('Item', () => {
describe('Create botanical path', () => { describe('Create botanical path', () => {
const nightmare = createNightmare(); const nightmare = createNightmare();

View File

@ -46,7 +46,7 @@ describe('Ticket', () => {
}); });
}); });
it('should confirm the fist ticket sale is the expected one', () => { it('should confirm the first ticket sale is the expected one', () => {
return nightmare return nightmare
.wait(selectors.ticketSales.firstSaleText) .wait(selectors.ticketSales.firstSaleText)
.getInnerText(selectors.ticketSales.firstSaleText) .getInnerText(selectors.ticketSales.firstSaleText)

View File

@ -20,6 +20,9 @@
}, },
"life": { "life": {
"type": "Number" "type": "Number"
},
"isPackaging": {
"type": "Boolean"
} }
}, },
"relations": { "relations": {

View File

@ -45,6 +45,16 @@
"type": "belongsTo", "type": "belongsTo",
"model": "Worker", "model": "Worker",
"foreignKey": "workerFk" "foreignKey": "workerFk"
},
"packages": {
"type": "hasMany",
"model": "TicketPackaging",
"foreignKey": "ticketFk"
},
"box": {
"type": "belongsTo",
"model": "Item",
"foreignKey": "isBox"
} }
} }
} }