Added descriptor-menu component
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Joan Sanchez 2020-11-09 14:52:25 +01:00
parent 53f69ae8e5
commit 637116b17d
23 changed files with 679 additions and 27345 deletions

View File

@ -413,7 +413,7 @@ export default {
stateLabelValue: 'vn-ticket-descriptor vn-label-value[label="State"]', stateLabelValue: 'vn-ticket-descriptor vn-label-value[label="State"]',
isDeletedIcon: 'vn-ticket-descriptor vn-icon[icon="icon-deletedTicket"]', isDeletedIcon: 'vn-ticket-descriptor vn-icon[icon="icon-deletedTicket"]',
goBackToModuleIndexButton: 'vn-ticket-descriptor a[ui-sref="ticket.index"]', goBackToModuleIndexButton: 'vn-ticket-descriptor a[ui-sref="ticket.index"]',
moreMenu: 'vn-ticket-descriptor vn-icon-button[icon=more_vert]', moreMenu: 'vn-ticket-descriptor vn-ticket-descriptor-menu > vn-icon-button[icon=more_vert]',
moreMenuAddStowaway: '.vn-menu [name="addStowaway"]', moreMenuAddStowaway: '.vn-menu [name="addStowaway"]',
moreMenuDeleteStowawayButton: '.vn-menu [name="deleteStowaway"]', moreMenuDeleteStowawayButton: '.vn-menu [name="deleteStowaway"]',
moreMenuAddToTurn: '.vn-menu [name="addTurn"]', moreMenuAddToTurn: '.vn-menu [name="addTurn"]',

View File

@ -1,7 +1,7 @@
import selectors from '../../../helpers/selectors.js'; import selectors from '../../../helpers/selectors.js';
import getBrowser from '../../../helpers/puppeteer'; import getBrowser from '../../../helpers/puppeteer';
describe('Ticket List sale path', () => { fdescribe('Ticket List sale path', () => {
let browser; let browser;
let page; let page;
@ -62,6 +62,7 @@ describe('Ticket List sale path', () => {
.querySelectorAll('li'); .querySelectorAll('li');
}, selectors.ticketSales.secondSaleIdAutocomplete); }, selectors.ticketSales.secondSaleIdAutocomplete);
await page.waitFor(3000);
await page.write(`.vn-drop-down.shown`, searchValue); await page.write(`.vn-drop-down.shown`, searchValue);
await page.waitForFunction((selector, searchValue) => { await page.waitForFunction((selector, searchValue) => {
let element = document let element = document

View File

@ -32,6 +32,7 @@ describe('Ticket descriptor path', () => {
}); });
it(`should confirm the ticket descriptor shows the correct shipping hour`, async() => { it(`should confirm the ticket descriptor shows the correct shipping hour`, async() => {
await page.waitForState('ticket.card.summary');
const result = await page const result = await page
.waitToGetProperty(selectors.ticketDescriptor.descriptorDeliveryDate, 'innerText'); .waitToGetProperty(selectors.ticketDescriptor.descriptorDeliveryDate, 'innerText');
@ -67,6 +68,7 @@ describe('Ticket descriptor path', () => {
await page.waitToClick(selectors.ticketDescriptor.moreMenu); await page.waitToClick(selectors.ticketDescriptor.moreMenu);
await page.waitToClick(selectors.ticketDescriptor.moreMenuRestoreTicket); await page.waitToClick(selectors.ticketDescriptor.moreMenuRestoreTicket);
await page.waitToClick(selectors.ticketDescriptor.acceptDialog); await page.waitToClick(selectors.ticketDescriptor.acceptDialog);
await page.waitForState('ticket.card.summary');
const message = await page.waitForSnackbar(); const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!'); expect(message.text).toBe('Data saved!');
@ -77,7 +79,7 @@ describe('Ticket descriptor path', () => {
}); });
}); });
describe('add stowaway', () => { describe('Add stowaway', () => {
it('should search for a ticket', async() => { it('should search for a ticket', async() => {
await page.accessToSearchResult('16'); await page.accessToSearchResult('16');
await page.waitForState('ticket.card.summary'); await page.waitForState('ticket.card.summary');
@ -85,7 +87,7 @@ describe('Ticket descriptor path', () => {
it('should open the add stowaway dialog', async() => { it('should open the add stowaway dialog', async() => {
await page.waitForFunction(() => { await page.waitForFunction(() => {
let element = document.querySelector('vn-ticket-descriptor'); let element = document.querySelector('vn-ticket-descriptor-menu');
return element.$ctrl.canShowStowaway === true; return element.$ctrl.canShowStowaway === true;
}); });
await page.waitToClick(selectors.ticketDescriptor.moreMenu); await page.waitToClick(selectors.ticketDescriptor.moreMenu);

View File

@ -17,11 +17,14 @@
ui-sref="{{::$ctrl.summaryState}}({id: $ctrl.descriptor.id})"> ui-sref="{{::$ctrl.summaryState}}({id: $ctrl.descriptor.id})">
<vn-icon icon="desktop_windows"></vn-icon> <vn-icon icon="desktop_windows"></vn-icon>
</a> </a>
<vn-icon-button <vn-icon-button ng-if="$ctrl.$transclude.isSlotFilled('menu')"
ng-class="::{invisible: !$ctrl.$transclude.isSlotFilled('menu')}" ng-class="::{invisible: !$ctrl.$transclude.isSlotFilled('menu')}"
icon="more_vert" icon="more_vert"
vn-popover="menu"> vn-popover="menu">
</vn-icon-button> </vn-icon-button>
<div ng-if="$ctrl.$transclude.isSlotFilled('dotMenu')"
ng-transclude="dotMenu">
</div>
</div> </div>
<vn-menu vn-id="menu"> <vn-menu vn-id="menu">
<vn-list ng-transclude="menu"></vn-list> <vn-list ng-transclude="menu"></vn-list>

View File

@ -130,6 +130,7 @@ ngModule.vnComponent('vnDescriptorContent', {
body: 'slotBody', body: 'slotBody',
before: '?slotBefore', before: '?slotBefore',
after: '?slotAfter', after: '?slotAfter',
menu: '?slotMenu' menu: '?slotMenu',
dotMenu: '?slotDotMenu'
} }
}); });

View File

@ -21,7 +21,8 @@ vn-descriptor-content {
align-items: stretch; align-items: stretch;
color: $color-font-dark; color: $color-font-dark;
& > * { & > a,
& > vn-icon-button {
display: flex; display: flex;
min-width: 45px; min-width: 45px;
height: 45px; height: 45px;

View File

@ -189,6 +189,22 @@ function e2eSingleRun() {
summary: { summary: {
displayStacktrace: 'pretty', displayStacktrace: 'pretty',
displayPending: false displayPending: false
},
colors: {
enabled: true,
successful: 'brightGreen',
failed: 'brightRed'
},
stacktrace: {
filter: stacktrace => {
const lines = stacktrace.split('\n');
const filtered = [];
for (let i = 1; i < lines.length; i++) {
if (/e2e\/paths/.test(lines[i]))
filtered.push(lines[i]);
}
return filtered.join('\n');
}
} }
}) })
] ]

View File

@ -159,5 +159,6 @@
"companyFk": "Empresa", "companyFk": "Empresa",
"The social name cannot be empty": "La razón social no puede quedar en blanco", "The social name cannot be empty": "La razón social no puede quedar en blanco",
"The nif cannot be empty": "El NIF no puede quedar en blanco", "The nif cannot be empty": "El NIF no puede quedar en blanco",
"You need to fill sage information before you check verified data": "Debes rellenar la información de sage antes de marcar datos comprobados" "You need to fill sage information before you check verified data": "Debes rellenar la información de sage antes de marcar datos comprobados",
"ASSIGN_ZONE_FIRST": "ASSIGN_ZONE_FIRST"
} }

View File

@ -31,7 +31,9 @@ module.exports = Self => {
}); });
const warehouse = await models.Warehouse.findById(ticket.warehouseFk); const warehouse = await models.Warehouse.findById(ticket.warehouseFk);
const hasStowaway = ticket.ship() ? true : false; const hasStowaway = ticket.ship() ? true : false;
if (warehouse && warehouse.hasStowaway && !hasStowaway) const validStowaway = warehouse && warehouse.hasStowaway && !hasStowaway;
if (!ticket.isDeleted && validStowaway)
return true; return true;
return false; return false;

View File

@ -0,0 +1,221 @@
<vn-icon-button
icon="more_vert"
vn-popover="menu">
</vn-icon-button>
<vn-menu vn-id="menu">
<vn-list>
<vn-item
ng-click="addTurn.show()"
vn-acl="buyer"
ng-show="$ctrl.isEditable"
vn-acl-action="remove"
name="addTurn"
translate>
Add turn
</vn-item>
<vn-item
ng-click="$ctrl.showDeliveryNote()"
translate>
Show Delivery Note
</vn-item>
<vn-item
ng-click="confirmDeliveryNote.show()"
translate>
Send Delivery Note
</vn-item>
<vn-item
ng-click="deleteConfirmation.show()"
ng-show="$ctrl.isEditable"
name="deleteTicket"
translate>
Delete ticket
</vn-item>
<vn-item
ng-click="restoreConfirmation.show()"
ng-show="$ctrl.canRestoreTicket"
name="restoreTicket"
translate>
Restore ticket
</vn-item>
<vn-item
ng-click="$ctrl.showChangeShipped()"
ng-show="$ctrl.isEditable"
name="changeShipped"
translate>
Change shipped hour
</vn-item>
<vn-item
ng-click="$ctrl.sendPaymentSms()"
translate>
SMS Pending payment
</vn-item>
<vn-item
ng-click="$ctrl.sendImportSms()"
translate>
SMS Minimum import
</vn-item>
<vn-item
ng-click="addStowaway.show()"
ng-show="$ctrl.canShowStowaway"
name="addStowaway"
translate>
Add stowaway
</vn-item>
<vn-item
ng-click="deleteStowaway.show()"
ng-show="$ctrl.canDeleteStowaway"
name="deleteStowaway"
translate>
Delete stowaway
</vn-item>
<vn-item
ng-click="makeInvoiceConfirmation.show()"
ng-show="$ctrl.isEditable"
vn-acl="invoicing"
vn-acl-action="remove"
name="makeInvoice"
translate>
Make invoice
</vn-item>
<vn-item
ng-click="regenerateInvoiceConfirmation.show()"
ng-show="$ctrl.isInvoiced"
vn-acl="invoicing"
vn-acl-action="remove"
translate>
Regenerate invoice
</vn-item>
<vn-item
ng-click="recalculateComponentsConfirmation.show()"
ng-show="$ctrl.isEditable"
translate>
Recalculate components
</vn-item>
</vn-list>
</vn-menu>
<!-- Add turn popup -->
<vn-popup vn-id="addTurn">
<div class="vn-pa-md">
<h5 style="text-align: center" translate>
In which day you want to add the ticket?
</h5>
<vn-tool-bar class="vn-mt-md">
<vn-button
label="Monday"
ng-click="$ctrl.addTurn(0)">
</vn-button>
<vn-button
label="Tuesday"
ng-click="$ctrl.addTurn(1)">
</vn-button>
<vn-button
label="Wednesday"
ng-click="$ctrl.addTurn(2)">
</vn-button>
<vn-button
label="Thursday"
ng-click="$ctrl.addTurn(3)">
</vn-button>
<vn-button
label="Friday"
ng-click="$ctrl.addTurn(4)">
</vn-button>
<vn-button
label="Saturday"
ng-click="$ctrl.addTurn(5)">
</vn-button>
<vn-button
label="Sunday"
ng-click="$ctrl.addTurn(6)">
</vn-button>
</vn-tool-bar>
</div>
</vn-popup>
<!-- Send delivery note confirmation popup -->
<vn-confirm
vn-id="confirmDeliveryNote"
on-accept="$ctrl.sendDeliveryNote()"
question="Are you sure you want to send it?"
message="Send Delivery Note">
</vn-confirm>
<!-- Delete ticket confirmation popup -->
<vn-confirm
vn-id="deleteConfirmation"
on-accept="$ctrl.deleteTicket()"
question="You are going to delete this ticket"
message="This ticket will be removed from current route! Continue anyway?">
</vn-confirm>
<!-- Restore ticket confirmation popup -->
<vn-confirm
vn-id="restoreConfirmation"
on-accept="$ctrl.restoreTicket()"
question="You are going to restore this ticket"
message="Are you sure you want to restore this ticket?">
</vn-confirm>
<!-- Change shipped dialog -->
<vn-dialog
vn-id="changeShippedDialog"
on-accept="$ctrl.changeShipped()"
message="Change shipped hour">
<tpl-body>
<vn-input-time
ng-model="$ctrl.newShipped"
label="Shipped hour"
vn-focus>
</vn-input-time>
</tpl-body>
<tpl-buttons>
<input type="button" response="cancel" translate-attr="{value: 'Cancel'}"/>
<button response="accept" translate>Save</button>
</tpl-buttons>
</vn-dialog>
<!-- Send SMS popup -->
<vn-ticket-sms
vn-id="sms"
sms="$ctrl.newSMS">
</vn-ticket-sms>
<!-- Add stowaway dialog -->
<vn-add-stowaway
vn-id="addStowaway"
card-reload="$ctrl.reload()"
ticket="$ctrl.ticket">
</vn-add-stowaway>
<!-- Delete stowaway confirmation dialog -->
<vn-confirm
vn-id="deleteStowaway"
on-accept="$ctrl.deleteStowaway()"
question="Delete stowaway"
message="Are you sure you want to delete this stowaway?">
</vn-confirm>
<!-- Make invoice confirmation dialog -->
<vn-confirm
vn-id="makeInvoiceConfirmation"
on-accept="$ctrl.makeInvoice()"
question="You are going to invoice this ticket"
message="Are you sure you want to invoice this ticket?">
</vn-confirm>
<!-- Regenerate invoice confirmation dialog -->
<vn-confirm
vn-id="regenerateInvoiceConfirmation"
on-accept="$ctrl.regenerateInvoice()"
question="You are going to regenerate the invoice"
message="Are you sure you want to regenerate the invoice?">
</vn-confirm>
<!-- Recalculate components confirmation dialog -->
<vn-confirm
vn-id="recalculateComponentsConfirmation"
on-accept="$ctrl.recalculateComponents()"
question="Are you sure you want to recalculate the components?"
message="Recalculate components">
</vn-confirm>

View File

@ -0,0 +1,240 @@
import ngModule from '../module';
import Section from 'salix/components/section';
import './style.scss';
class Controller extends Section {
constructor($element, $, vnReport, vnEmail) {
super($element, $);
this.vnReport = vnReport;
this.vnEmail = vnEmail;
}
get ticketId() {
return this._ticketId;
}
set ticketId(value) {
this._ticketId = value;
this.id = value;
}
get id() {
return this._id;
}
set id(value) {
this._id = value;
if (value) this.loadData();
}
loadData() {
const filter = {
include: [{
relation: 'address',
}, {
relation: 'client',
scope: {
fields: [
'salesPersonFk',
'name',
'isActive',
'isFreezed',
'isTaxDataChecked',
'credit',
'email',
'phone',
'mobile'
],
include: {
relation: 'salesPersonUser',
scope: {
fields: ['id', 'name']
}
}
}
},
{relation: 'ship'},
{relation: 'stowaway'}]
};
return this.$http.get(`Tickets/${this.ticketId}`, {filter})
.then(res => this.ticket = res.data)
.then(() => {
this.canStowaway();
this.isTicketEditable();
});
}
reload() {
return this.loadData().then(
() => this.cardReload());
}
get isInvoiced() {
return this.ticket.refFk !== null;
}
get isTicketModule() {
return this.$state.getCurrentPath()[1].state.name === 'ticket';
}
isTicketEditable() {
if (!this.ticket) return;
this.$http.get(`Tickets/${this.id}/isEditable`).then(res => {
this.isEditable = res.data;
});
}
addTurn(day) {
const params = {
ticketFk: this.id,
weekDay: day,
agencyModeFk: this.ticket.agencyModeFk
};
return this.$http.patch(`TicketWeeklies`, params)
.then(() => {
this.$.addTurn.hide();
this.vnApp.showSuccess(this.$t('Data saved!'));
});
}
showDeliveryNote() {
this.vnReport.show('delivery-note', {
recipientId: this.ticket.client.id,
ticketId: this.id,
});
}
sendDeliveryNote() {
return this.vnEmail.send('delivery-note', {
recipientId: this.ticket.client.id,
recipient: this.ticket.client.email,
ticketId: this.id
});
}
deleteTicket() {
return this.$http.post(`Tickets/${this.id}/setDeleted`)
.then(() => this.reload())
.then(() => {
this.$state.go('ticket.index');
this.vnApp.showSuccess(this.$t('Ticket deleted. You can undo this action within the first hour'));
});
}
get canRestoreTicket() {
const isDeleted = this.ticket.isDeleted;
const now = new Date();
const maxDate = new Date(this.ticket.updated);
maxDate.setHours(maxDate.getHours() + 1);
return isDeleted && (now <= maxDate);
}
restoreTicket() {
return this.$http.post(`Tickets/${this.id}/restore`)
.then(() => this.reload())
.then(() => this.vnApp.showSuccess(this.$t('Data saved!')));
}
showChangeShipped() {
this.newShipped = this.ticket.shipped;
this.$.changeShippedDialog.show();
}
changeShipped() {
const data = {shipped: this.newShipped};
return this.$http.post(`Tickets/${this.id}/updateEditableTicket`, data)
.then(() => this.reload())
.then(() => this.vnApp.showSuccess(this.$t('Shipped hour updated')));
}
sendImportSms() {
const params = {
ticketId: this.id,
created: this.ticket.updated
};
this.showSMSDialog({
message: this.$params.message || this.$t('Minimum is needed', params)
});
}
sendPaymentSms() {
this.showSMSDialog({
message: this.$params.message || this.$t('Make a payment')
});
}
showSMSDialog(params) {
const address = this.ticket.address;
const client = this.ticket.client;
const phone = this.$params.phone
|| address.mobile
|| address.phone
|| client.mobile
|| client.phone;
this.newSMS = Object.assign({
ticketId: this.id,
destinationFk: this.ticket.clientFk,
destination: phone
}, params);
this.$.sms.open();
}
canStowaway() {
this.canShowStowaway = false;
if (!this.isTicketModule || !this.ticket) return;
this.$http.get(`Tickets/${this.id}/canHaveStowaway`)
.then(res => this.canShowStowaway = !!res.data);
}
get canDeleteStowaway() {
if (!this.ticket || !this.isTicketModule)
return false;
return this.ticket.stowaway || this.ticket.ship;
}
deleteStowaway() {
return this.$http.post(`Tickets/${this.id}/deleteStowaway`)
.then(() => this.reload())
.then(() => this.vnApp.showSuccess(this.$t('Data saved!')));
}
makeInvoice() {
return this.$http.post(`Tickets/${this.id}/makeInvoice`)
.then(() => this.reload())
.then(() => this.vnApp.showSuccess(this.$t('Ticket invoiced')));
}
regenerateInvoice() {
const invoiceId = this.ticket.invoiceOut.id;
return this.$http.post(`InvoiceOuts/${invoiceId}/regenerate`)
.then(() => {
const snackbarMessage = this.$t(
`Invoice sent for a regeneration, will be available in a few minutes`);
this.vnApp.showSuccess(snackbarMessage);
});
}
recalculateComponents() {
return this.$http.post(`Tickets/${this.id}/recalculateComponents`)
.then(() => this.reload())
.then(() => this.vnApp.showSuccess(this.$t('Data saved!')));
}
}
Controller.$inject = ['$element', '$scope', 'vnReport', 'vnEmail'];
ngModule.vnComponent('vnTicketDescriptorMenu', {
template: require('./index.html'),
controller: Controller,
bindings: {
ticketId: '<',
reload: '&'
}
});

View File

@ -0,0 +1,24 @@
@import "./effects";
@import "variables";
vn-ticket-descriptor-menu {
& > vn-icon-button[icon="more_vert"] {
display: flex;
min-width: 45px;
height: 45px;
box-sizing: border-box;
align-items: center;
justify-content: center;
}
& > vn-icon-button[icon="more_vert"] {
@extend %clickable;
color: inherit;
& > vn-icon {
padding: 10px;
}
vn-icon {
font-size: 1.75rem;
}
}
}

View File

@ -1,5 +1,5 @@
<vn-crud-model vn-id="model" <vn-crud-model vn-id="model"
url="Tickets/{{$ctrl.$params.id}}/getPossibleStowaways" url="Tickets/{{$ctrl.ticket.id}}/getPossibleStowaways"
data="possibleStowaways"> data="possibleStowaways">
</vn-crud-model> </vn-crud-model>
<vn-dialog <vn-dialog
@ -8,7 +8,7 @@
on-open="model.refresh()" on-open="model.refresh()"
message="Stowaways to add"> message="Stowaways to add">
<tpl-body> <tpl-body>
<vn-horizontal class="add-stowaway vn-pa-md"> <vn-horizontal class="add-stowaway">
<vn-data-viewer model="model"> <vn-data-viewer model="model">
<vn-table model="model" auto-load="false"> <vn-table model="model" auto-load="false">
<vn-thead> <vn-thead>

View File

@ -1,95 +1,9 @@
<vn-descriptor-content <vn-descriptor-content
module="ticket" module="ticket"
description="$ctrl.ticket.client.name"> description="$ctrl.ticket.client.name">
<slot-menu> <slot-dot-menu>
<vn-item <vn-ticket-descriptor-menu ticket-id="$ctrl.ticket.id" reload="$ctrl.cardReload()"/>
ng-click="addTurn.show()" </slot-dot-menu>
vn-acl="buyer"
ng-show="$ctrl.isEditable"
vn-acl-action="remove"
name="addTurn"
translate>
Add turn
</vn-item>
<vn-item
ng-click="$ctrl.showDeliveryNote()"
translate>
Show Delivery Note
</vn-item>
<vn-item
ng-click="confirmDeliveryNote.show()"
translate>
Send Delivery Note
</vn-item>
<vn-item
ng-click="deleteConfirmation.show()"
ng-show="$ctrl.isEditable"
name="deleteTicket"
translate>
Delete ticket
</vn-item>
<vn-item
ng-click="restoreConfirmation.show()"
ng-show="$ctrl.canRestoreTicket"
name="restoreTicket"
translate>
Restore ticket
</vn-item>
<vn-item
ng-click="$ctrl.showChangeShipped()"
ng-show="$ctrl.isEditable"
name="changeShipped"
translate>
Change shipped hour
</vn-item>
<vn-item
ng-click="$ctrl.sendPaymentSms()"
translate>
SMS Pending payment
</vn-item>
<vn-item
ng-click="$ctrl.sendImportSms()"
translate>
SMS Minimum import
</vn-item>
<vn-item
ng-click="addStowaway.show()"
ng-show="$ctrl.canShowStowaway"
name="addStowaway"
translate>
Add stowaway
</vn-item>
<vn-item
ng-click="deleteStowaway.show()"
ng-show="$ctrl.shouldShowDeleteStowaway"
name="deleteStowaway"
translate>
Delete stowaway
</vn-item>
<vn-item
ng-click="makeInvoiceConfirmation.show()"
ng-show="$ctrl.isEditable"
vn-acl="invoicing"
vn-acl-action="remove"
name="makeInvoice"
translate>
Make invoice
</vn-item>
<vn-item
ng-click="regenerateInvoiceConfirmation.show()"
ng-show="$ctrl.isInvoiced"
vn-acl="invoicing"
vn-acl-action="remove"
translate>
Regenerate invoice
</vn-item>
<vn-item
ng-click="recalculateComponentsConfirmation.show()"
ng-show="$ctrl.isEditable"
translate>
Recalculate components
</vn-item>
</slot-menu>
<slot-body> <slot-body>
<div class="attributes"> <div class="attributes">
<vn-label-value <vn-label-value
@ -203,68 +117,32 @@
</div> </div>
</slot-body> </slot-body>
</vn-descriptor-content> </vn-descriptor-content>
<vn-popup vn-id="addTurn">
<div class="vn-pa-md"> <!-- <vn-confirm
<h5 style="text-align: center" translate>
In which day you want to add the ticket?
</h5>
<vn-tool-bar class="vn-mt-md">
<vn-button
label="Monday"
ng-click="$ctrl.addTurn(0)">
</vn-button>
<vn-button
label="Tuesday"
ng-click="$ctrl.addTurn(1)">
</vn-button>
<vn-button
label="Wednesday"
ng-click="$ctrl.addTurn(2)">
</vn-button>
<vn-button
label="Thursday"
ng-click="$ctrl.addTurn(3)">
</vn-button>
<vn-button
label="Friday"
ng-click="$ctrl.addTurn(4)">
</vn-button>
<vn-button
label="Saturday"
ng-click="$ctrl.addTurn(5)">
</vn-button>
<vn-button
label="Sunday"
ng-click="$ctrl.addTurn(6)">
</vn-button>
</vn-tool-bar>
</div>
</vn-popup>
<vn-confirm
vn-id="deleteConfirmation" vn-id="deleteConfirmation"
on-accept="$ctrl.deleteTicket()" on-accept="$ctrl.deleteTicket()"
question="You are going to delete this ticket" question="You are going to delete this ticket"
message="This ticket will be removed from current route! Continue anyway?"> message="This ticket will be removed from current route! Continue anyway?">
</vn-confirm> </vn-confirm> -->
<vn-confirm <!-- <vn-confirm
vn-id="restoreConfirmation" vn-id="restoreConfirmation"
on-accept="$ctrl.restoreTicket()" on-accept="$ctrl.restoreTicket()"
question="You are going to restore this ticket" question="You are going to restore this ticket"
message="Are you sure you want to restore this ticket?"> message="Are you sure you want to restore this ticket?">
</vn-confirm> </vn-confirm> -->
<vn-confirm <!-- <vn-confirm
vn-id="deleteStowaway" vn-id="deleteStowaway"
on-accept="$ctrl.deleteStowaway()" on-accept="$ctrl.deleteStowaway()"
question="Delete stowaway" question="Delete stowaway"
message="Are you sure you want to delete this stowaway?"> message="Are you sure you want to delete this stowaway?">
</vn-confirm> </vn-confirm> -->
<vn-confirm <vn-confirm
vn-id="confirmDialog" vn-id="confirmDialog"
on-accept="$ctrl.returnDialog()" on-accept="$ctrl.returnDialog()"
question="Pickup order" question="Pickup order"
message="Do you want to send it directly?"> message="Do you want to send it directly?">
</vn-confirm> </vn-confirm>
<vn-confirm <!-- <vn-confirm
vn-id="makeInvoiceConfirmation" vn-id="makeInvoiceConfirmation"
on-accept="$ctrl.makeInvoice()" on-accept="$ctrl.makeInvoice()"
question="You are going to invoice this ticket" question="You are going to invoice this ticket"
@ -275,29 +153,29 @@
on-accept="$ctrl.regenerateInvoice()" on-accept="$ctrl.regenerateInvoice()"
question="You are going to regenerate the invoice" question="You are going to regenerate the invoice"
message="Are you sure you want to regenerate the invoice?"> message="Are you sure you want to regenerate the invoice?">
</vn-confirm> </vn-confirm> -->
<vn-confirm <!-- <vn-confirm
vn-id="confirmDeliveryNote" vn-id="confirmDeliveryNote"
on-accept="$ctrl.sendDeliveryNote()" on-accept="$ctrl.sendDeliveryNote()"
question="Are you sure you want to send it?" question="Are you sure you want to send it?"
message="Send Delivery Note"> message="Send Delivery Note">
</vn-confirm> </vn-confirm> -->
<vn-confirm <!-- <vn-confirm
vn-id="recalculateComponentsConfirmation" vn-id="recalculateComponentsConfirmation"
on-accept="$ctrl.recalculateComponents()" on-accept="$ctrl.recalculateComponents()"
question="Are you sure you want to recalculate the components?" question="Are you sure you want to recalculate the components?"
message="Recalculate components"> message="Recalculate components">
</vn-confirm> </vn-confirm> -->
<vn-ticket-sms <!-- <vn-ticket-sms
vn-id="sms" vn-id="sms"
sms="$ctrl.newSMS"> sms="$ctrl.newSMS">
</vn-ticket-sms> </vn-ticket-sms> -->
<vn-add-stowaway <!-- <vn-add-stowaway
vn-id="addStowaway" vn-id="addStowaway"
card-reload="$ctrl.cardReload()" card-reload="$ctrl.cardReload()"
ticket="$ctrl.ticket"> ticket="$ctrl.ticket">
</vn-add-stowaway> </vn-add-stowaway> -->
<vn-dialog <!-- <vn-dialog
vn-id="changeShippedDialog" vn-id="changeShippedDialog"
on-accept="$ctrl.changeShipped()" on-accept="$ctrl.changeShipped()"
message="Change shipped hour"> message="Change shipped hour">
@ -315,4 +193,4 @@
</vn-dialog> </vn-dialog>
<vn-worker-descriptor-popover <vn-worker-descriptor-popover
vn-id="workerDescriptor"> vn-id="workerDescriptor">
</vn-worker-descriptor-popover> </vn-worker-descriptor-popover> -->

View File

@ -16,7 +16,7 @@ class Controller extends Descriptor {
set entity(value) { set entity(value) {
super.entity = value; super.entity = value;
this.canStowaway(); // this.canStowaway();
this.isTicketEditable(); this.isTicketEditable();
if (value && this.$params.sendSMS) if (value && this.$params.sendSMS)
@ -44,14 +44,14 @@ class Controller extends Descriptor {
return null; return null;
} }
get canRestoreTicket() { /* get canRestoreTicket() {
const isDeleted = this.ticket.isDeleted; const isDeleted = this.ticket.isDeleted;
const now = new Date(); const now = new Date();
const maxDate = new Date(this.ticket.updated); const maxDate = new Date(this.ticket.updated);
maxDate.setHours(maxDate.getHours() + 1); maxDate.setHours(maxDate.getHours() + 1);
return isDeleted && (now <= maxDate); return isDeleted && (now <= maxDate);
} } */
isTicketEditable() { isTicketEditable() {
if (!this.ticket) return; if (!this.ticket) return;
@ -60,7 +60,7 @@ class Controller extends Descriptor {
}); });
} }
showChangeShipped() { /* showChangeShipped() {
this.newShipped = this.ticket.shipped; this.newShipped = this.ticket.shipped;
this.$.changeShippedDialog.show(); this.$.changeShippedDialog.show();
} }
@ -72,13 +72,13 @@ class Controller extends Descriptor {
return this.$http.post(`Tickets/${this.id}/updateEditableTicket`, data) return this.$http.post(`Tickets/${this.id}/updateEditableTicket`, data)
.then(() => this.cardReload()) .then(() => this.cardReload())
.then(() => this.vnApp.showSuccess(this.$t('Shipped hour updated'))); .then(() => this.vnApp.showSuccess(this.$t('Shipped hour updated')));
} } */
goToTicket(ticketId) { goToTicket(ticketId) {
this.$state.go('ticket.card.sale', {id: ticketId}, {absolute: true}); this.$state.go('ticket.card.sale', {id: ticketId}, {absolute: true});
} }
addTurn(day) { /* addTurn(day) {
let params = { let params = {
ticketFk: this.id, ticketFk: this.id,
weekDay: day, weekDay: day,
@ -105,25 +105,25 @@ class Controller extends Descriptor {
this.vnApp.showSuccess(this.$t('Data saved!')); this.vnApp.showSuccess(this.$t('Data saved!'));
this.cardReload(); this.cardReload();
}); });
} } */
canStowaway() { /* canStowaway() {
this.canShowStowaway = false; this.canShowStowaway = false;
if (!this.isTicketModule || !this.ticket) return; if (!this.isTicketModule || !this.ticket) return;
this.$http.get(`Tickets/${this.id}/canHaveStowaway`) this.$http.get(`Tickets/${this.id}/canHaveStowaway`)
.then(res => this.canShowStowaway = !!res.data); .then(res => this.canShowStowaway = !!res.data);
} } */
deleteStowaway() { /* deleteStowaway() {
return this.$http.post(`Tickets/${this.id}/deleteStowaway`) return this.$http.post(`Tickets/${this.id}/deleteStowaway`)
.then(() => { .then(() => {
this.vnApp.showSuccess(this.$t('Data saved!')); this.vnApp.showSuccess(this.$t('Data saved!'));
this.cardReload(); this.cardReload();
}); });
} } */
showDeliveryNote() { /* showDeliveryNote() {
this.vnReport.show('delivery-note', { this.vnReport.show('delivery-note', {
recipientId: this.ticket.client.id, recipientId: this.ticket.client.id,
ticketId: this.id, ticketId: this.id,
@ -168,9 +168,9 @@ class Controller extends Descriptor {
destination: phone destination: phone
}, params); }, params);
this.$.sms.open(); this.$.sms.open();
} } */
makeInvoice() { /* makeInvoice() {
return this.$http.post(`Tickets/${this.id}/makeInvoice`) return this.$http.post(`Tickets/${this.id}/makeInvoice`)
.then(() => { .then(() => {
this.vnApp.showSuccess(this.$t('Ticket invoiced')); this.vnApp.showSuccess(this.$t('Ticket invoiced'));
@ -186,12 +186,12 @@ class Controller extends Descriptor {
`Invoice sent for a regeneration, will be available in a few minutes`); `Invoice sent for a regeneration, will be available in a few minutes`);
this.vnApp.showSuccess(snackbarMessage); this.vnApp.showSuccess(snackbarMessage);
}); });
} } */
recalculateComponents() { /* recalculateComponents() {
return this.$http.post(`Tickets/${this.id}/recalculateComponents`) return this.$http.post(`Tickets/${this.id}/recalculateComponents`)
.then(() => this.vnApp.showSuccess(this.$t('Data saved!'))); .then(() => this.vnApp.showSuccess(this.$t('Data saved!')));
} } */
cardReload() { cardReload() {
// Prevents error when not defined // Prevents error when not defined

View File

@ -7,6 +7,7 @@ import './card';
import './descriptor'; import './descriptor';
import './descriptor/addStowaway'; import './descriptor/addStowaway';
import './descriptor-popover'; import './descriptor-popover';
import './descriptor-menu';
import './create/card'; import './create/card';
import './create/index'; import './create/index';
import './summary'; import './summary';

View File

@ -25,7 +25,7 @@ class Controller extends Component {
if (this.charactersRemaining() < 0) if (this.charactersRemaining() < 0)
throw new Error(`The message it's too long`); throw new Error(`The message it's too long`);
this.$http.post(`Tickets/${this.$params.id}/sendSms`, this.sms).then(res => { this.$http.post(`Tickets/${this.sms.ticketId}/sendSms`, this.sms).then(res => {
this.vnApp.showMessage(this.$t('SMS sent!')); this.vnApp.showMessage(this.$t('SMS sent!'));
if (res.data) this.emit('send', {response: res.data}); if (res.data) this.emit('send', {response: res.data});

View File

@ -1,5 +1,11 @@
<vn-card class="summary"> <vn-card class="summary">
<h5> <h5>
<a ng-if="::$ctrl.summary.id"
translate-attr="{title: 'Go to ticket summary'}"
ui-sref="ticket.card.summary({id: {{::$ctrl.summary.id}}})"
name="goToTicketSummary">
<vn-icon-button icon="open_in_full"></vn-icon-button>
</a>
<span> <span>
Ticket #{{$ctrl.summary.id}} - {{$ctrl.summary.client.name}} Ticket #{{$ctrl.summary.id}} - {{$ctrl.summary.client.name}}
({{$ctrl.summary.client.id}}) - {{$ctrl.summary.nickname}} ({{$ctrl.summary.client.id}}) - {{$ctrl.summary.nickname}}
@ -12,6 +18,7 @@
ng-click="$ctrl.setOkState()" ng-click="$ctrl.setOkState()"
vn-tooltip="Change ticket state to 'Ok'"> vn-tooltip="Change ticket state to 'Ok'">
</vn-button> </vn-button>
<vn-ticket-descriptor-menu ticket-id="$ctrl.summary.id" reload="$ctrl.reload()"/>
</h5> </h5>
<vn-horizontal> <vn-horizontal>
<vn-one> <vn-one>

View File

@ -10,7 +10,7 @@ class Controller extends Section {
set ticket(value) { set ticket(value) {
this._ticket = value; this._ticket = value;
if (value) this.getSummary(); if (value) this.loadData();
} }
get formattedAddress() { get formattedAddress() {
@ -22,13 +22,24 @@ class Controller extends Section {
return `${address.street} - ${address.city} ${province}`; return `${address.street} - ${address.city} ${province}`;
} }
getSummary() { loadData() {
this.$http.get(`Tickets/${this.ticket.id}/summary`).then(res => { return this.$http.get(`Tickets/${this.ticket.id}/summary`).then(res => {
if (res && res.data) if (res && res.data)
this.summary = res.data; this.summary = res.data;
}); });
} }
reload() {
this.loadData()
.then(() => {
if (this.card)
this.card.reload();
// Refresh index model
if (this.model)
this.model.refresh();
});
}
get isEditable() { get isEditable() {
try { try {
return !this.ticket.ticketState.state.alertLevel; return !this.ticket.ticketState.state.alertLevel;
@ -53,16 +64,10 @@ class Controller extends Section {
params.code = 'OK'; params.code = 'OK';
this.$http.post(`TicketTrackings/changeState`, params).then(() => { this.$http.post(`TicketTrackings/changeState`, params)
.then(() => this.reload())
.then(() => {
this.vnApp.showSuccess(this.$t('Data saved!')); this.vnApp.showSuccess(this.$t('Data saved!'));
if (this.card)
this.card.reload();
else {
this.getSummary();
// Refresh index model
if (this.model)
this.model.refresh();
}
}); });
} }

View File

@ -1,5 +1,12 @@
@import "./effects";
@import "./variables"; @import "./variables";
vn-ticket-card vn-ticket-summary {
a[name="goToTicketSummary"],
vn-ticket-descriptor-menu {
display: none
}
}
vn-ticket-summary .summary { vn-ticket-summary .summary {
max-width: $width-lg; max-width: $width-lg;
@ -9,6 +16,26 @@ vn-ticket-summary .summary {
align-items: center; align-items: center;
align-content: center; align-content: center;
& > a > vn-icon-button[icon="open_in_full"] {
display: flex;
min-width: 45px;
height: 45px;
box-sizing: border-box;
align-items: center;
justify-content: center;
}
& > a > vn-icon-button[icon="open_in_full"] {
@extend %clickable;
color: $color-font-dark;
& > vn-icon {
padding: 10px;
}
vn-icon {
font-size: 1.75rem;
}
}
span { span {
flex: 1; flex: 1;

27208
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -73,9 +73,9 @@
"html-loader-jest": "^0.2.1", "html-loader-jest": "^0.2.1",
"html-webpack-plugin": "^4.0.0-beta.11", "html-webpack-plugin": "^4.0.0-beta.11",
"identity-obj-proxy": "^3.0.0", "identity-obj-proxy": "^3.0.0",
"jasmine": "^3.5.0", "jasmine": "^3.6.3",
"jasmine-reporters": "^2.3.2", "jasmine-reporters": "^2.3.2",
"jasmine-spec-reporter": "^4.2.1", "jasmine-spec-reporter": "^6.0.0",
"jest": "^26.0.1", "jest": "^26.0.1",
"jest-junit": "^8.0.0", "jest-junit": "^8.0.0",
"json-loader": "^0.5.7", "json-loader": "^0.5.7",

View File

@ -5,8 +5,8 @@ let env = process.env.NODE_ENV ? process.env.NODE_ENV : 'development';
let configPath = `/etc/salix`; let configPath = `/etc/salix`;
let config = require('../config/print.json'); let config = require('../config/print.json');
let configFiles = [ let configFiles = [
`${__dirname}/../config/print.local.json`, `../config/print.local.json`,
`${__dirname}/../config/print.${env}.json`, `../config/print.${env}.json`,
`${configPath}/print.json`, `${configPath}/print.json`,
`${configPath}/print.local.json`, `${configPath}/print.local.json`,
`${configPath}/print.${env}.json` `${configPath}/print.${env}.json`