Merge branch 'dev' into 2961-summary_tickets
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
commit
f5ad0c9c1c
|
@ -43,14 +43,14 @@ export default class Contextmenu {
|
|||
get row() {
|
||||
if (!this.target) return null;
|
||||
|
||||
return this.target.closest('vn-tr, .vn-tr');
|
||||
return this.target.closest('[ng-repeat]');
|
||||
}
|
||||
|
||||
get rowIndex() {
|
||||
if (!this.row) return null;
|
||||
|
||||
const table = this.row.closest('vn-table, .vn-table');
|
||||
const tBody = table.querySelector('vn-tbody, .vn-tbody');
|
||||
const rows = tBody.querySelectorAll('vn-tr, .vn-tr');
|
||||
const rows = table.querySelectorAll('[ng-repeat]');
|
||||
|
||||
return Array.from(rows).findIndex(
|
||||
rowItem => rowItem == this.row
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
<vn-tr ng-repeat="transaction in transactions">
|
||||
<vn-td shrink>
|
||||
<vn-icon
|
||||
vn-tooltip="{{$ctrl.getFormattedMessage(transaction)}}"
|
||||
vn-tooltip="{{::$ctrl.getFormattedMessage(transaction)}}"
|
||||
ng-show="::((transaction.errorMessage || transaction.responseMessage) && !transaction.isConfirmed)"
|
||||
icon="clear">
|
||||
</vn-icon>
|
||||
|
|
|
@ -48,21 +48,15 @@ module.exports = Self => {
|
|||
switch (field) {
|
||||
case 'size':
|
||||
case 'density':
|
||||
case 'minPrice':
|
||||
case 'description':
|
||||
case 'packingOut':
|
||||
modelName = 'Item';
|
||||
identifier = 'itemFk';
|
||||
break;
|
||||
case 'quantity':
|
||||
case 'buyingValue':
|
||||
case 'freightValue':
|
||||
case 'packing':
|
||||
case 'grouping':
|
||||
case 'groupingMode':
|
||||
case 'comissionValue':
|
||||
case 'packageValue':
|
||||
case 'price2':
|
||||
case 'price3':
|
||||
case 'weight':
|
||||
modelName = 'Buy';
|
||||
identifier = 'id';
|
||||
|
|
|
@ -10,54 +10,59 @@ module.exports = Self => {
|
|||
accepts: [
|
||||
{
|
||||
arg: 'filter',
|
||||
type: 'Object',
|
||||
type: 'object',
|
||||
description: 'Filter defining where, order, offset, and limit - must be a JSON-encoded string',
|
||||
},
|
||||
{
|
||||
arg: 'search',
|
||||
type: 'String',
|
||||
type: 'string',
|
||||
description: `If it's and integer searchs by id, otherwise it searchs by name`,
|
||||
},
|
||||
{
|
||||
arg: 'id',
|
||||
type: 'Integer',
|
||||
type: 'integer',
|
||||
description: 'Item id',
|
||||
},
|
||||
{
|
||||
arg: 'tags',
|
||||
type: ['Object'],
|
||||
type: ['object'],
|
||||
description: 'List of tags to filter with',
|
||||
http: {source: 'query'}
|
||||
},
|
||||
{
|
||||
arg: 'description',
|
||||
type: 'String',
|
||||
type: 'string',
|
||||
description: 'The item description',
|
||||
},
|
||||
{
|
||||
arg: 'salesPersonFk',
|
||||
type: 'Integer',
|
||||
type: 'integer',
|
||||
description: 'The buyer of the item',
|
||||
},
|
||||
{
|
||||
arg: 'active',
|
||||
type: 'Boolean',
|
||||
type: 'boolean',
|
||||
description: 'Whether the item is or not active',
|
||||
},
|
||||
{
|
||||
arg: 'visible',
|
||||
type: 'Boolean',
|
||||
type: 'boolean',
|
||||
description: 'Whether the item is or not visible',
|
||||
},
|
||||
{
|
||||
arg: 'typeFk',
|
||||
type: 'Integer',
|
||||
type: 'integer',
|
||||
description: 'Type id',
|
||||
},
|
||||
{
|
||||
arg: 'categoryFk',
|
||||
type: 'Integer',
|
||||
type: 'integer',
|
||||
description: 'Category id',
|
||||
},
|
||||
{
|
||||
arg: 'packingOut',
|
||||
type: 'integer',
|
||||
description: 'the packingOut',
|
||||
}
|
||||
],
|
||||
returns: {
|
||||
|
@ -84,7 +89,10 @@ module.exports = Self => {
|
|||
? {'i.id': value}
|
||||
: {'i.name': {like: `%${value}%`}};
|
||||
case 'id':
|
||||
return {'i.id': value};
|
||||
case 'packingOut':
|
||||
case 'typeFk':
|
||||
param = `i.${param}`;
|
||||
return {[param]: value};
|
||||
case 'description':
|
||||
return {'i.description': {like: `%${value}%`}};
|
||||
case 'categoryFk':
|
||||
|
@ -93,8 +101,6 @@ module.exports = Self => {
|
|||
return {'it.workerFk': value};
|
||||
case 'code':
|
||||
return {'it.code': value};
|
||||
case 'typeFk':
|
||||
return {'i.typeFk': value};
|
||||
case 'active':
|
||||
return {'i.isActive': value};
|
||||
case 'visible':
|
||||
|
@ -126,6 +132,7 @@ module.exports = Self => {
|
|||
i.description,
|
||||
i.name,
|
||||
i.subName,
|
||||
i.packingOut,
|
||||
i.tag5,
|
||||
i.value5,
|
||||
i.tag6,
|
||||
|
|
|
@ -57,6 +57,7 @@
|
|||
<vn-th field="ektFk">Ekt</vn-th>
|
||||
<vn-th field="weight">Weight</vn-th>
|
||||
<vn-th field="packageFk" expand>PackageName</vn-th>
|
||||
<vn-th field="packingOut" expand>PackingOut</vn-th>
|
||||
</vn-tr>
|
||||
</vn-thead>
|
||||
<vn-tbody>
|
||||
|
@ -147,6 +148,7 @@
|
|||
<vn-td number>{{::buy.ektFk | dashIfEmpty}}</vn-td>
|
||||
<vn-td number>{{::buy.weight}}</vn-td>
|
||||
<vn-td number>{{::buy.packageFk}}</vn-td>
|
||||
<vn-td number>{{::buy.packingOut}}</vn-td>
|
||||
</a>
|
||||
</vn-tbody>
|
||||
</vn-table>
|
||||
|
|
|
@ -16,20 +16,14 @@ export default class Controller extends Section {
|
|||
if (this._columns) return this._columns;
|
||||
|
||||
this._columns = [
|
||||
{field: 'quantity', displayName: this.$t('Quantity')},
|
||||
{field: 'buyingValue', displayName: this.$t('Buying value')},
|
||||
{field: 'freightValue', displayName: this.$t('Freight value')},
|
||||
{field: 'packing', displayName: this.$t('Packing')},
|
||||
{field: 'grouping', displayName: this.$t('Grouping')},
|
||||
{field: 'comissionValue', displayName: this.$t('Commission value')},
|
||||
{field: 'packageValue', displayName: this.$t('Package value')},
|
||||
{field: 'price2', displayName: this.$t('Grouping price')},
|
||||
{field: 'price3', displayName: this.$t('Packing price')},
|
||||
{field: 'weight', displayName: this.$t('Weight')},
|
||||
{field: 'description', displayName: this.$t('Description')},
|
||||
{field: 'minPrice', displayName: this.$t('Min price')},
|
||||
{field: 'size', displayName: this.$t('Size')},
|
||||
{field: 'density', displayName: this.$t('Density')}
|
||||
{field: 'density', displayName: this.$t('Density')},
|
||||
{field: 'packingOut', displayName: this.$t('PackingOut')}
|
||||
];
|
||||
|
||||
return this._columns;
|
||||
|
|
|
@ -14,3 +14,4 @@ Field to edit: Campo a editar
|
|||
PackageName: Cubo
|
||||
Edit: Editar
|
||||
buy(s): compra(s)
|
||||
PackingOut: Packing envíos
|
|
@ -137,6 +137,9 @@
|
|||
"minPrice": {
|
||||
"type": "number"
|
||||
},
|
||||
"packingOut": {
|
||||
"type": "number"
|
||||
},
|
||||
"hasMinPrice": {
|
||||
"type": "boolean"
|
||||
},
|
||||
|
|
|
@ -10,6 +10,11 @@
|
|||
Clients on website
|
||||
</vn-one>
|
||||
<vn-none>
|
||||
<vn-icon class="arrow"
|
||||
icon="keyboard_arrow_up"
|
||||
vn-tooltip="Minimize/Maximize"
|
||||
ng-click="$ctrl.main.toggle()">
|
||||
</vn-icon>
|
||||
<vn-icon
|
||||
icon="refresh"
|
||||
vn-tooltip="Refresh"
|
||||
|
@ -17,7 +22,7 @@
|
|||
</vn-icon>
|
||||
</vn-none>
|
||||
</vn-horizontal>
|
||||
<vn-card>
|
||||
<vn-card vn-id="card">
|
||||
<vn-table model="model" class="scrollable sm">
|
||||
<vn-thead>
|
||||
<vn-tr>
|
||||
|
@ -52,12 +57,6 @@
|
|||
</vn-tr>
|
||||
</vn-tbody>
|
||||
</vn-table>
|
||||
<div
|
||||
ng-if="!model.data.length"
|
||||
class="empty-rows vn-pa-sm"
|
||||
translate>
|
||||
No results
|
||||
</div>
|
||||
<vn-pagination
|
||||
model="model"
|
||||
class="vn-pt-xs"
|
||||
|
|
|
@ -26,5 +26,8 @@ export default class Controller extends Section {
|
|||
|
||||
ngModule.vnComponent('vnMonitorSalesClients', {
|
||||
template: require('./index.html'),
|
||||
controller: Controller
|
||||
controller: Controller,
|
||||
require: {
|
||||
main: '^vnMonitorIndex'
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,11 +1,5 @@
|
|||
<vn-horizontal>
|
||||
<vn-three class="vn-mr-sm">
|
||||
<vn-monitor-sales-tickets></vn-monitor-sales-tickets>
|
||||
</vn-three>
|
||||
<vn-one>
|
||||
<vn-vertical>
|
||||
<vn-monitor-sales-clients class="vn-mb-sm"></vn-monitor-sales-clients>
|
||||
<vn-monitor-sales-orders></vn-monitor-sales-orders>
|
||||
</vn-vertical>
|
||||
</vn-one>
|
||||
</vn-horizontal>
|
||||
<vn-monitor-sales-tickets></vn-monitor-sales-tickets>
|
|
@ -2,7 +2,22 @@ import ngModule from '../module';
|
|||
import Section from 'salix/components/section';
|
||||
import './style.scss';
|
||||
|
||||
export default class Controller extends Section {
|
||||
toggle() {
|
||||
const monitor = this.element.querySelector('vn-horizontal');
|
||||
const isHidden = monitor.classList.contains('hidden');
|
||||
|
||||
if (!isHidden)
|
||||
monitor.classList.add('hidden');
|
||||
else
|
||||
monitor.classList.remove('hidden');
|
||||
}
|
||||
}
|
||||
|
||||
ngModule.vnComponent('vnMonitorIndex', {
|
||||
template: require('./index.html'),
|
||||
controller: Section
|
||||
controller: Controller,
|
||||
require: {
|
||||
main: '^vnMonitorIndex'
|
||||
}
|
||||
});
|
||||
|
|
|
@ -5,3 +5,4 @@ Search tickets: Buscar tickets
|
|||
Delete selected elements: Eliminar los elementos seleccionados
|
||||
All the selected elements will be deleted. Are you sure you want to continue?: Todos los elementos seleccionados serán eliminados. ¿Seguro que quieres continuar?
|
||||
Component lack: Faltan componentes
|
||||
Minimize/Maximize: Minimizar/Maximizar
|
|
@ -1,4 +1,4 @@
|
|||
<vn-crud-model
|
||||
<vn-crud-model auto-load="true"
|
||||
vn-id="model"
|
||||
url="SalesMonitors/ordersFilter"
|
||||
limit="6"
|
||||
|
@ -15,6 +15,11 @@
|
|||
ng-if="$ctrl.totalChecked > 0"
|
||||
ng-click="delete.show()">
|
||||
</vn-icon>
|
||||
<vn-icon class="arrow"
|
||||
icon="keyboard_arrow_up"
|
||||
vn-tooltip="Minimize/Maximize"
|
||||
ng-click="$ctrl.main.toggle()">
|
||||
</vn-icon>
|
||||
<vn-icon
|
||||
icon="refresh"
|
||||
vn-tooltip="Refresh"
|
||||
|
@ -31,13 +36,13 @@
|
|||
model="model">
|
||||
</vn-multi-check>
|
||||
</vn-th>
|
||||
<vn-th field="date_make" shrink-datetime default-order="DESC">Date</vn-th>
|
||||
<vn-th field="date_send" shrink-datetime>Date</vn-th>
|
||||
<vn-th field="clientFk">Client</vn-th>
|
||||
<vn-th>Import</vn-th>
|
||||
<vn-th field="salesPersonFk" shrink>SalesPerson</vn-th>
|
||||
</vn-tr>
|
||||
</vn-thead>
|
||||
<a ng-repeat="order in model.data"
|
||||
class="clickable vn-tbody search-result"
|
||||
class="clickable vn-tbody"
|
||||
ui-sref="order.card.summary({id: {{::order.id}}})" target="_blank">
|
||||
<vn-tr>
|
||||
<vn-td>
|
||||
|
@ -47,7 +52,7 @@
|
|||
</vn-check>
|
||||
</vn-td>
|
||||
<vn-td>
|
||||
<span class="chip success">
|
||||
<span class="chip {{::$ctrl.chipColor(order.date_send)}}">
|
||||
{{::order.date_send | date: 'dd/MM/yyyy'}}
|
||||
</span>
|
||||
</vn-td>
|
||||
|
@ -59,11 +64,18 @@
|
|||
{{::order.clientName}}
|
||||
</span>
|
||||
</vn-td>
|
||||
<vn-td number>{{::order.import | currency: 'EUR':2}}</vn-td>
|
||||
<vn-td>
|
||||
<span
|
||||
title="{{::order.salesPerson}}"
|
||||
vn-click-stop="workerDescriptor.show($event, order.salesPersonFk)"
|
||||
class="link">
|
||||
{{::order.salesPerson | dashIfEmpty}}
|
||||
</span>
|
||||
</vn-td>
|
||||
</vn-tr>
|
||||
<vn-tr>
|
||||
<vn-td></vn-td>
|
||||
<vn-td shrink-datetime>
|
||||
<vn-td>
|
||||
<span>
|
||||
{{::order.date_make | date: 'dd/MM/yyyy HH:mm'}}
|
||||
</span>
|
||||
|
@ -74,22 +86,11 @@
|
|||
</span>
|
||||
</vn-td>
|
||||
<vn-td>
|
||||
<span
|
||||
title="{{::order.salesPerson}}"
|
||||
vn-click-stop="workerDescriptor.show($event, order.salesPersonFk)"
|
||||
class="link">
|
||||
{{::order.salesPerson | dashIfEmpty}}
|
||||
</span>
|
||||
{{::order.import | currency: 'EUR':2}}
|
||||
</vn-td>
|
||||
</vn-tr>
|
||||
</a>
|
||||
</vn-table>
|
||||
<div
|
||||
ng-if="!model.data.length"
|
||||
class="empty-rows vn-pa-sm"
|
||||
translate>
|
||||
No results
|
||||
</div>
|
||||
<vn-pagination
|
||||
model="model"
|
||||
class="vn-pt-xs"
|
||||
|
@ -103,6 +104,35 @@
|
|||
<vn-client-descriptor-popover
|
||||
vn-id="clientDescriptor">
|
||||
</vn-client-descriptor-popover>
|
||||
<vn-contextmenu vn-id="contextmenu" targets="['vn-monitor-sales-orders vn-table']" model="model"
|
||||
expr-builder="$ctrl.exprBuilder(param, value)">
|
||||
<slot-menu>
|
||||
<vn-item translate
|
||||
ng-if="contextmenu.isFilterAllowed()"
|
||||
ng-click="contextmenu.filterBySelection()">
|
||||
Filter by selection
|
||||
</vn-item>
|
||||
<vn-item translate
|
||||
ng-if="contextmenu.isFilterAllowed()"
|
||||
ng-click="contextmenu.excludeSelection()">
|
||||
Exclude selection
|
||||
</vn-item>
|
||||
<vn-item translate
|
||||
ng-if="contextmenu.isFilterAllowed()"
|
||||
ng-click="contextmenu.removeFilter()">
|
||||
Remove filter
|
||||
</vn-item>
|
||||
<vn-item translate
|
||||
ng-click="contextmenu.removeAllFilters()">
|
||||
Remove all filters
|
||||
</vn-item>
|
||||
<vn-item translate
|
||||
ng-if="contextmenu.isActionAllowed()"
|
||||
ng-click="contextmenu.copyValue()">
|
||||
Copy value
|
||||
</vn-item>
|
||||
</slot-menu>
|
||||
</vn-contextmenu>
|
||||
<vn-confirm
|
||||
vn-id="delete"
|
||||
on-accept="$ctrl.onDelete()"
|
||||
|
|
|
@ -24,9 +24,51 @@ export default class Controller extends Section {
|
|||
this.$http.post(query, params).then(
|
||||
() => this.$.model.refresh());
|
||||
}
|
||||
|
||||
chipColor(date) {
|
||||
const today = new Date();
|
||||
today.setHours(0, 0, 0, 0);
|
||||
|
||||
const orderLanded = new Date(date);
|
||||
orderLanded.setHours(0, 0, 0, 0);
|
||||
|
||||
const difference = today - orderLanded;
|
||||
|
||||
if (difference == 0)
|
||||
return 'warning';
|
||||
if (difference < 0)
|
||||
return 'success';
|
||||
if (difference > 0)
|
||||
return 'alert';
|
||||
}
|
||||
|
||||
exprBuilder(param, value) {
|
||||
switch (param) {
|
||||
case 'date_send':
|
||||
return {[`o.date_send`]: {
|
||||
between: this.dateRange(value)}
|
||||
};
|
||||
case 'clientFk':
|
||||
return {[`c.id`]: value};
|
||||
case 'salesPersonFk':
|
||||
return {[`c.${param}`]: value};
|
||||
}
|
||||
}
|
||||
|
||||
dateRange(value) {
|
||||
const minHour = new Date(value);
|
||||
minHour.setHours(0, 0, 0, 0);
|
||||
const maxHour = new Date(value);
|
||||
maxHour.setHours(23, 59, 59, 59);
|
||||
|
||||
return [minHour, maxHour];
|
||||
}
|
||||
}
|
||||
|
||||
ngModule.vnComponent('vnMonitorSalesOrders', {
|
||||
template: require('./index.html'),
|
||||
controller: Controller
|
||||
controller: Controller,
|
||||
require: {
|
||||
main: '^vnMonitorIndex'
|
||||
}
|
||||
});
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
|
||||
vn-monitor-sales-orders {
|
||||
vn-table.scrollable {
|
||||
max-height: 350px
|
||||
max-height: 350px;
|
||||
overflow-x: hidden
|
||||
}
|
||||
|
||||
vn-table a.vn-tbody {
|
||||
|
|
|
@ -21,21 +21,7 @@
|
|||
ng-model="filter.orderFk">
|
||||
</vn-textfield>
|
||||
</vn-horizontal>
|
||||
<section class="vn-px-md">
|
||||
<vn-horizontal class="manifold-panel vn-pa-md">
|
||||
<vn-date-picker
|
||||
vn-one
|
||||
label="From"
|
||||
ng-model="filter.from"
|
||||
on-change="$ctrl.from = value">
|
||||
</vn-date-picker>
|
||||
<vn-date-picker
|
||||
vn-one
|
||||
label="To"
|
||||
ng-model="filter.to"
|
||||
on-change="$ctrl.to = value">
|
||||
</vn-date-picker>
|
||||
<vn-none class="or vn-px-md" translate>Or</vn-none>
|
||||
<vn-horizontal class="vn-px-lg">
|
||||
<vn-input-number
|
||||
vn-one
|
||||
min="0"
|
||||
|
@ -45,12 +31,7 @@
|
|||
on-change="$ctrl.scopeDays = value"
|
||||
display-controls="true">
|
||||
</vn-input-number>
|
||||
<vn-icon color-marginal
|
||||
icon="info"
|
||||
vn-tooltip="Cannot choose a range of dates and days onward at the same time">
|
||||
</vn-icon>
|
||||
</vn-horizontal>
|
||||
</section>
|
||||
<vn-horizontal class="vn-px-lg">
|
||||
<vn-textfield
|
||||
vn-one
|
||||
|
|
|
@ -3,53 +3,82 @@
|
|||
|
||||
vn-monitor-index {
|
||||
.header {
|
||||
padding: 12px 0;
|
||||
padding: 12px 0 5px 0;
|
||||
color: gray;
|
||||
font-size: 1.2rem;
|
||||
border-bottom: 2px solid $color-font-secondary;
|
||||
margin-bottom: 10px;
|
||||
|
||||
& > vn-none > vn-icon {
|
||||
@extend %clickable-light;
|
||||
color: $color-button;
|
||||
font-size: 1.4rem;
|
||||
}
|
||||
}
|
||||
.empty-rows {
|
||||
color: $color-font-secondary;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
vn-vertical {
|
||||
position: fixed;
|
||||
width: 400px
|
||||
vn-none > .arrow {
|
||||
transition: transform 200ms;
|
||||
}
|
||||
|
||||
vn-horizontal {
|
||||
flex-wrap: wrap
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width:1500px) {
|
||||
vn-monitor-index {
|
||||
& > vn-horizontal {
|
||||
flex-direction: column-reverse;
|
||||
}
|
||||
|
||||
& > vn-horizontal > vn-one {
|
||||
flex: none;
|
||||
width: 100%;
|
||||
|
||||
& > vn-vertical {
|
||||
position: initial;
|
||||
flex-direction: row;
|
||||
width: 100%;
|
||||
|
||||
vn-monitor-sales-clients {
|
||||
margin-right: 15px
|
||||
vn-card {
|
||||
margin-right: 15px;
|
||||
}
|
||||
|
||||
.header {
|
||||
padding-right: 15px;
|
||||
|
||||
& > vn-none > .arrow {
|
||||
display: none
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
vn-table.scrollable {
|
||||
height: 300px
|
||||
}
|
||||
|
||||
vn-horizontal {
|
||||
flex-wrap: wrap
|
||||
}
|
||||
|
||||
.hidden {
|
||||
vn-card {
|
||||
display: none
|
||||
}
|
||||
|
||||
.header > vn-none > .arrow {
|
||||
transform: rotate(180deg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width:1150px) {
|
||||
vn-monitor-index {
|
||||
& > vn-horizontal {
|
||||
flex-direction: column;
|
||||
|
||||
vn-monitor-sales-clients,
|
||||
vn-monitor-sales-orders {
|
||||
width: 100%
|
||||
}
|
||||
|
||||
vn-monitor-sales-clients {
|
||||
margin-bottom: 15px
|
||||
}
|
||||
}
|
||||
|
||||
vn-monitor-sales-clients {
|
||||
vn-card {
|
||||
margin-right: 0
|
||||
}
|
||||
|
||||
.header {
|
||||
padding-right: 0;
|
||||
|
||||
& > vn-none > .arrow {
|
||||
display: inline-block
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -115,6 +115,14 @@ describe('Component vnMonitorSalesTickets', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('totalPriceColor()', () => {
|
||||
it('should return "warning" when the ticket amount is less than 50€', () => {
|
||||
const result = controller.totalPriceColor({totalWithVat: '8.50'});
|
||||
|
||||
expect(result).toEqual('warning');
|
||||
});
|
||||
});
|
||||
|
||||
describe('preview()', () => {
|
||||
it('should show the dialog summary', () => {
|
||||
controller.$.summary = {show: () => {}};
|
||||
|
|
|
@ -18,6 +18,13 @@
|
|||
translate>
|
||||
Clone travel and his entries
|
||||
</vn-item>
|
||||
<vn-item
|
||||
id="delete"
|
||||
ng-click="delete.show()"
|
||||
ng-show="$ctrl.isBuyer && !$ctrl.entries.length"
|
||||
translate>
|
||||
Delete travel
|
||||
</vn-item>
|
||||
<a class="vn-item"
|
||||
ui-sref="entry.create({travelFk: $ctrl.travel.id})"
|
||||
name="addEntry"
|
||||
|
@ -35,6 +42,14 @@
|
|||
message="All it's properties will be copied">
|
||||
</vn-confirm>
|
||||
|
||||
<!-- Delete travel popup -->
|
||||
<vn-confirm
|
||||
vn-id="delete"
|
||||
on-accept="$ctrl.onDeleteAccept()"
|
||||
question="Do you want to delete this travel?"
|
||||
message="The travel will be deleted">
|
||||
</vn-confirm>
|
||||
|
||||
<!-- Clone travel popup -->
|
||||
<vn-confirm
|
||||
vn-id="cloneWithEntries"
|
||||
|
|
|
@ -44,14 +44,23 @@ class Controller extends Section {
|
|||
}
|
||||
]
|
||||
};
|
||||
return this.$http.get(`Travels/${this.travelId}`, {filter})
|
||||
this.$http.get(`Travels/${this.travelId}`, {filter})
|
||||
.then(res => this.travel = res.data);
|
||||
|
||||
this.$http.get(`Travels/${this.travelId}/getEntries`)
|
||||
.then(res => this.entries = res.data);
|
||||
}
|
||||
|
||||
get isBuyer() {
|
||||
return this.aclService.hasAny(['buyer']);
|
||||
}
|
||||
|
||||
onDeleteAccept() {
|
||||
this.$http.delete(`Travels/${this.travelId}`)
|
||||
.then(() => this.$state.go('travel.index'))
|
||||
.then(() => this.vnApp.showSuccess(this.$t('Travel deleted')));
|
||||
}
|
||||
|
||||
onCloneAccept() {
|
||||
const params = JSON.stringify({
|
||||
ref: this.travel.ref,
|
||||
|
|
|
@ -40,6 +40,21 @@ describe('Travel Component vnTravelDescriptorMenu', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('onDeleteAccept()', () => {
|
||||
it('should perform a delete query', () => {
|
||||
jest.spyOn(controller.$state, 'go').mockReturnValue('ok');
|
||||
controller.travelId = 1;
|
||||
|
||||
$httpBackend.when('GET', `Travels/${controller.travelId}`).respond(200);
|
||||
$httpBackend.when('GET', `Travels/${controller.travelId}/getEntries`).respond(200);
|
||||
$httpBackend.expect('DELETE', `Travels/${controller.travelId}`).respond(200);
|
||||
controller.onDeleteAccept();
|
||||
$httpBackend.flush();
|
||||
|
||||
expect(controller.$state.go).toHaveBeenCalledWith('travel.index');
|
||||
});
|
||||
});
|
||||
|
||||
describe('onCloneWithEntriesAccept()', () => {
|
||||
it('should make an HTTP query and then call to the $state.go method with the returned id', () => {
|
||||
jest.spyOn(controller.$state, 'go').mockReturnValue('ok');
|
||||
|
|
|
@ -2,3 +2,7 @@ Clone travel: Clonar envío
|
|||
Add entry: Añadir entrada
|
||||
Clone travel and his entries: Clonar travel y sus entradas
|
||||
Do you want to clone this travel and all containing entries?: ¿Quieres clonar este travel y todas las entradas que contiene?
|
||||
Delete travel: Eliminar envío
|
||||
The travel will be deleted: El envío será eliminado
|
||||
Do you want to delete this travel?: ¿Quieres eliminar este envío?
|
||||
Travel deleted: Envío eliminado
|
Loading…
Reference in New Issue