#1847 vnDialog refactor

This commit is contained in:
Juan Ferrer 2019-10-30 16:57:14 +01:00
parent 0a4a22ec87
commit c41fb1d0f4
104 changed files with 355 additions and 275 deletions

View File

@ -52,7 +52,7 @@ let actions = {
let logoutClicked = await this.clickIfExists('#logout');
if (logoutClicked) {
let buttonSelector = '.vn-dialog.shown button[response=ACCEPT]';
let buttonSelector = '.vn-dialog.shown button[response=accept]';
await this.wait(buttonSelector => {
return document.querySelector(buttonSelector) != null
|| location.hash == '#!/login';
@ -392,7 +392,7 @@ let actions = {
forceReloadSection: function(sectionRoute) {
return this.waitToClick('vn-icon[icon="desktop_windows"]')
.waitToClick('button[response="ACCEPT"]')
.waitToClick('button[response="accept"]')
.wait('vn-card.summary')
.waitToClick(`vn-left-menu li > a[ui-sref="${sectionRoute}"]`);
},

View File

@ -18,7 +18,7 @@ export default {
userConfigFirstAutocompleteClear: '#localWarehouse .icons > vn-icon[icon=clear]',
userConfigSecondAutocompleteClear: '#localBank .icons > vn-icon[icon=clear]',
userConfigThirdAutocompleteClear: '#localCompany .icons > vn-icon[icon=clear]',
acceptButton: '.vn-confirm.shown button[response=ACCEPT]'
acceptButton: '.vn-confirm.shown button[response=accept]'
},
clientsIndex: {
searchClientInput: `vn-textfield input`,
@ -62,7 +62,7 @@ export default {
socialNameInput: `vn-textfield input[name="socialName"]`,
fiscalIdInput: `vn-textfield input[name="fi"]`,
equalizationTaxCheckbox: 'vn-check[ng-model="$ctrl.client.isEqualizated"]',
acceptPropagationButton: '.vn-confirm.shown button[response=ACCEPT]',
acceptPropagationButton: '.vn-confirm.shown button[response=accept]',
addressInput: `vn-textfield input[name="street"]`,
postcodeInput: `vn-textfield input[name="postcode"]`,
cityInput: `vn-textfield input[name="city"]`,
@ -90,7 +90,7 @@ export default {
newBankEntityName: '.vn-dialog.shown vn-textfield[label="Name"] input',
newBankEntityBIC: '.vn-dialog.shown vn-textfield[label="Swift / BIC"] input',
newBankEntityCode: '.vn-dialog.shown vn-textfield[label="Entity Code"] input',
acceptBankEntityButton: '.vn-dialog.shown button[response="ACCEPT"]',
acceptBankEntityButton: '.vn-dialog.shown button[response="accept"]',
saveButton: `button[type=submit]`
},
clientAddresses: {
@ -177,7 +177,7 @@ export default {
deleteFileButton: 'vn-client-dms-index vn-tr:nth-child(1) vn-icon-button[icon="delete"]',
firstDocWorker: 'vn-client-dms-index vn-td:nth-child(8) > span',
firstDocWorkerDescriptor: '.vn-popover.shown vn-worker-descriptor',
acceptDeleteButton: '.vn-confirm.shown button[response="ACCEPT"]'
acceptDeleteButton: '.vn-confirm.shown button[response="accept"]'
},
itemsIndex: {
searchIcon: 'vn-item-index vn-searchbar vn-icon[icon="search"]',
@ -185,7 +185,7 @@ export default {
searchResult: 'vn-item-index a.vn-tr',
searchResultPreviewButton: 'vn-item-index .buttons > [icon="desktop_windows"]',
searchResultCloneButton: 'vn-item-index .buttons > [icon="icon-clone"]',
acceptClonationAlertButton: '.vn-confirm.shown [response="ACCEPT"]',
acceptClonationAlertButton: '.vn-confirm.shown [response="accept"]',
searchItemInput: 'vn-searchbar vn-textfield input',
searchButton: 'vn-searchbar vn-icon[icon="search"]',
closeItemSummaryPreview: '.vn-popup.shown',
@ -340,7 +340,7 @@ export default {
sixthWeeklyTicket: 'vn-ticket-weekly-index vn-table vn-tr:nth-child(6) vn-autocomplete[ng-model="weekly.weekDay"] input',
weeklyTicket: 'vn-ticket-weekly-index vn-table > div > vn-tbody > vn-tr',
firstWeeklyTicketDeleteIcon: 'vn-ticket-weekly-index vn-tr:nth-child(1) vn-icon-button[icon="delete"]',
acceptDeleteTurn: '.vn-confirm.shown button[response="ACCEPT"]'
acceptDeleteTurn: '.vn-confirm.shown button[response="accept"]'
},
createTicketView: {
clientAutocomplete: 'vn-ticket-create vn-autocomplete[ng-model="$ctrl.clientFk"]',
@ -368,11 +368,11 @@ export default {
thursdayButton: '.vn-popup.shown vn-tool-bar > vn-button:nth-child(4)',
saturdayButton: '.vn-popup.shown vn-tool-bar > vn-button:nth-child(6)',
closeStowawayDialog: '.vn-dialog.shown button[class="close"]',
acceptDeleteButton: '.vn-dialog.shown button[response="ACCEPT"]',
acceptChangeHourButton: '.vn-dialog.shown button[response="ACCEPT"]',
acceptDeleteButton: '.vn-dialog.shown button[response="accept"]',
acceptChangeHourButton: '.vn-dialog.shown button[response="accept"]',
descriptorDeliveryDate: 'vn-ticket-descriptor > div > div.body > div.attributes > vn-label-value:nth-child(6) > section > span',
acceptInvoiceOutButton: '.vn-confirm.shown button[response="ACCEPT"]',
acceptDeleteStowawayButton: '.vn-dialog.shown button[response="ACCEPT"]'
acceptInvoiceOutButton: '.vn-confirm.shown button[response="accept"]',
acceptDeleteStowawayButton: '.vn-dialog.shown button[response="accept"]'
},
ticketNotes: {
firstNoteRemoveButton: 'vn-icon[icon="delete"]',
@ -384,7 +384,7 @@ export default {
ticketExpedition: {
expeditionButton: 'vn-left-menu a[ui-sref="ticket.card.expedition"]',
secondExpeditionRemoveButton: 'vn-ticket-expedition vn-table div > vn-tbody > vn-tr:nth-child(2) > vn-td:nth-child(1) > vn-icon-button[icon="delete"]',
acceptDeleteRowButton: '.vn-confirm.shown button[response=ACCEPT]',
acceptDeleteRowButton: '.vn-confirm.shown button[response=accept]',
expeditionRow: 'vn-ticket-expedition vn-table vn-tbody > vn-tr'
},
ticketPackages: {
@ -453,8 +453,8 @@ export default {
moveToTicketInputClearButton: '.vn-popover.shown i[title="Clear"]',
moveToTicketButton: '.vn-popover.shown vn-icon[icon="arrow_forward_ios"]',
moveToNewTicketButton: '.vn-popover.shown vn-button[label="New ticket"]',
acceptDeleteLineButton: '.vn-confirm.shown button[response=ACCEPT]',
acceptDeleteTicketButton: '.vn-confirm.shown button[response=ACCEPT]',
acceptDeleteLineButton: '.vn-confirm.shown button[response=accept]',
acceptDeleteTicketButton: '.vn-confirm.shown button[response=accept]',
stateMenuButton: 'vn-ticket-sale vn-tool-bar > vn-button-menu[label="State"]'
},
ticketTracking: {
@ -523,7 +523,7 @@ export default {
claimDescriptor: {
moreMenu: 'vn-claim-descriptor vn-icon-menu[icon=more_vert]',
moreMenuDeleteClaim: '.vn-drop-down.shown li[name="Delete claim"]',
acceptDeleteClaim: '.vn-confirm.shown button[response="ACCEPT"]'
acceptDeleteClaim: '.vn-confirm.shown button[response="accept"]'
},
claimSummary: {
header: 'vn-claim-summary > vn-card > h5',
@ -589,7 +589,7 @@ export default {
},
orderDescriptor: {
returnToModuleIndexButton: 'vn-order-descriptor a[ui-sref="order.index"]',
acceptNavigationButton: '.vn-confirm.shown button[response=ACCEPT]'
acceptNavigationButton: '.vn-confirm.shown button[response=accept]'
},
createOrderView: {
clientAutocomplete: 'vn-autocomplete[label="Client"]',
@ -618,13 +618,13 @@ export default {
agencyAutocomplete: 'vn-autocomplete[label="Agency"]',
observationInput: 'vn-textarea[label="Observation"] textarea',
saveButton: `button[type=submit]`,
acceptButton: '.vn-confirm.shown button[response="ACCEPT"]'
acceptButton: '.vn-confirm.shown button[response="accept"]'
},
orderLine: {
orderSubtotal: 'vn-order-line .header :first-child',
firstLineDeleteButton: 'vn-order-line vn-tbody > vn-tr:nth-child(1) vn-icon[icon="delete"]',
confirmOrder: 'vn-order-line vn-float-button',
confirmButton: '.vn-confirm.shown button[response="ACCEPT"]',
confirmButton: '.vn-confirm.shown button[response="accept"]',
},
routeIndex: {
addNewRouteButton: 'vn-route-index > a[ui-sref="route.create"]'
@ -663,7 +663,7 @@ export default {
firstTicketCheckbox: 'vn-route-tickets vn-tr:nth-child(1) vn-check',
buscamanButton: 'vn-route-tickets vn-button[icon="icon-buscaman"]',
firstTicketDeleteButton: 'vn-route-tickets vn-tr:nth-child(1) vn-icon[icon="delete"]',
confirmButton: '.vn-confirm.shown button[response="ACCEPT"]'
confirmButton: '.vn-confirm.shown button[response="accept"]'
},
workerPbx: {
extensionInput: 'vn-worker-pbx vn-textfield[ng-model="$ctrl.worker.sip.extension"] input',
@ -729,8 +729,8 @@ export default {
moreMenuDeleteInvoiceOut: '.vn-drop-down.shown li[name="Delete Invoice"]',
moreMenuBookInvoiceOut: '.vn-drop-down.shown li[name="Book invoice"]',
moreMenuShowInvoiceOutPdf: '.vn-drop-down.shown li[name="Show invoice PDF"]',
acceptDeleteButton: '.vn-confirm.shown button[response="ACCEPT"]',
acceptBookingButton: '.vn-confirm.shown button[response="ACCEPT"]'
acceptDeleteButton: '.vn-confirm.shown button[response="accept"]',
acceptBookingButton: '.vn-confirm.shown button[response="accept"]'
},
invoiceOutSummary: {
bookedLabel: 'vn-invoice-out-summary > vn-card > vn-horizontal > vn-one > vn-label-value:nth-child(4) > section > span'

View File

@ -110,7 +110,7 @@ describe('Client Add address path', () => {
it(`should go back to the addreses section by clicking the cancel button`, async() => {
const url = await nightmare
.waitToClick(selectors.clientAddresses.cancelEditAddressButton)
.waitToClick('.vn-confirm.shown button[response="ACCEPT"]')
.waitToClick('.vn-confirm.shown button[response="accept"]')
.waitForURL('address/index')
.parsedUrl();

View File

@ -1,19 +1,16 @@
@import "variables";
vn-chip {
border-radius: 16px;
border-radius: 1em;
background-color: $color-bg;
margin: 0 0.5em 0.5em 0;
color: $color-font;
font-size: 14px;
margin: .25em;
font-size: .9rem;
margin: .25em 0;
display: inline-flex;
align-items: center;
text-overflow: ellipsis;
white-space: nowrap;
height: 28px;
padding: 0 .7em;
overflow: hidden;
height: 2em;
max-width: 100%;
box-sizing: border-box;
&.colored {
background-color: $color-main;
@ -22,17 +19,24 @@ vn-chip {
& > div {
display: flex;
align-items: center;
max-width: 100%;
height: 100%;
padding: 0 .7em;
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
line-height: 2em;
& > vn-avatar {
margin-left: -0.7em;
margin-right: .4em;
margin-right: .3em;
vertical-align: middle;
height: 1.9em;
width: 2em;
}
}
& > vn-icon {
margin-left: .2em;
margin-right: -0.3em;
margin-right: .12em;
margin-left: -.12em;
vertical-align: middle;
opacity: .6;
cursor: pointer;
@ -47,7 +51,6 @@ vn-chip {
vn-avatar {
display: inline-block;
height: 28px;
width: 28px;
min-width: 2em;
border-radius: 50%;
}

View File

@ -4,7 +4,7 @@
<span translate>{{::$ctrl.question}}</span>
</tpl-body>
<tpl-buttons>
<button response="CANCEL" translate>Cancel</button>
<button response="ACCEPT" translate>Accept</button>
<button response="cancel" translate>Cancel</button>
<button response="accept" translate vn-focus>Accept</button>
</tpl-buttons>
</div>

View File

@ -1,3 +1,8 @@
<div
ng-if="$ctrl.loading"
class="loading-overlap shown">
<vn-spinner enable="true"></vn-spinner>
</div>
<vn-button
ng-click="$ctrl.hide()"
translate-attr="{title: 'Close'}"

View File

@ -6,8 +6,10 @@ import './style.scss';
/**
* Dialog component.
*
* @property {HTMLElement} body The dialog HTML body
* @property {HTMLElement} buttons The dialog HTML buttons
* @property {Function} onResponse Handler for dialog response
* @property {Function} onAccept Shortcut handler for accept response
* @slot body The dialog HTML body
* @slot buttons The dialog HTML buttons
*/
export default class Dialog extends Popup {
constructor($element, $, $transclude) {
@ -16,24 +18,88 @@ export default class Dialog extends Popup {
}
/**
* Hides the dialog calling the response handler.
* Shows the dialog and optionally registers a handler for the response.
*
* @param {*} data Optional user data to pass to response handler
* @param {Function} responseHandler An optional response handler
* @return {Promise} A promise that will be resolved with response when dialog is closed
*/
hide() {
this.fireResponse();
show(data, responseHandler) {
if (typeof data == 'function') {
responseHandler = data;
data = null;
}
this.data = data;
this.showHandler = responseHandler;
super.show();
return this.$q(resolve => {
this.resolve = resolve;
});
}
/**
* Hides the dialog.
*
* @param {String} response The response
*/
hide(response) {
this.showHandler = null;
super.hide();
if (this.resolve)
this.resolve(response);
}
/**
* Calls the response handler.
*
* @param {String} response The response code
* @return {Boolean} %true if response was canceled, %false otherwise
* @return {Boolean} The response handler return
*/
fireResponse(response) {
let cancel;
respond(response) {
let handlerArgs = {
$response: response,
$data: this.data
};
let cancellers = [];
if (this.onResponse)
cancel = this.onResponse({response: response});
return cancel;
cancellers.push(this.onResponse(handlerArgs));
if (response == 'accept' && this.onAccept)
cancellers.push(this.onAccept(handlerArgs));
if (this.showHandler)
cancellers.push(this.showHandler(response, this.data));
let promises = [];
let resolvedCancellers = [];
for (let canceller of cancellers) {
if (canceller instanceof Object && canceller.then)
promises.push(canceller);
else
resolvedCancellers.push(canceller);
}
let close = () => {
if (resolvedCancellers.indexOf(false) == -1)
this.hide(response);
else
return false;
};
if (promises.length) {
this.loading = true;
return this.$q.all(promises)
.then(res => {
resolvedCancellers = resolvedCancellers.concat(res);
return close();
})
.finally(() => {
this.loading = false;
});
} else
return this.$q.resolve(close());
}
onButtonClick(event) {
@ -45,17 +111,7 @@ export default class Dialog extends Popup {
node = node.parentNode;
}
let response = node.getAttribute('response');
let cancel = this.fireResponse(response);
let close = res => {
if (res !== false) super.hide();
};
if (cancel instanceof Object && cancel.then)
cancel.then(close);
else
close(cancel);
this.respond(node.getAttribute('response'));
}
}
@ -66,6 +122,7 @@ ngModule.vnComponent('vnDialog', {
buttons: '?tplButtons'
},
bindings: {
onResponse: '&?'
onResponse: '&?',
onAccept: '&?'
}
});

View File

@ -10,27 +10,21 @@ describe('Component vnDialog', () => {
controller.emit = jasmine.createSpy('emit');
}));
describe('hide()', () => {
describe('fireResponse()', () => {
describe('respond()', () => {
it(`should call onResponse() if it's defined in the controller`, () => {
controller.onResponse = () => {};
spyOn(controller, 'onResponse');
controller.hide();
controller.respond();
expect(controller.onResponse).toHaveBeenCalledWith(jasmine.any(Object));
});
it(`should call onResponse() with a response`, () => {
let responseRes;
controller.onResponse = response => {
responseRes = response;
return false;
};
let responseRet = controller.fireResponse('answer');
controller.onResponse = () => {};
spyOn(controller, 'onResponse');
controller.respond('answer');
expect(responseRes).toEqual({response: 'answer'});
expect(responseRet).toEqual(false);
});
expect(controller.onResponse).toHaveBeenCalledWith({$response: 'answer'});
});
});
});

View File

@ -1,7 +1,7 @@
@import "effects";
.vn-dialog > .window {
padding: $spacing-lg;
position: relative;
& > .close {
@extend %clickable;
@ -16,6 +16,8 @@
color: #666;
}
& > form {
padding: $spacing-lg;
& > .body > tpl-body {
display: block;
min-width: 16em;
@ -42,4 +44,20 @@
}
}
}
& > .loading-overlap {
position: absolute;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, .2);
display: flex;
align-items: center;
justify-content: center;
z-index: 1;
opacity: 0;
transition: opacity 200ms ease-in-out;
&.shown {
opacity: 1;
}
}
}

View File

@ -2,5 +2,5 @@
vn-id="confirm"
question="Are you sure exit without saving?"
message="Unsaved changes will be lost"
on-response="$ctrl.onConfirmResponse(response)">
on-response="$ctrl.onConfirmResponse($response)">
</vn-confirm>

View File

@ -203,7 +203,7 @@ export default class Watcher extends Component {
}
onConfirmResponse(response) {
if (response === 'ACCEPT') {
if (response === 'accept') {
if (this.data)
Object.assign(this.data, this.orgData);
this.$state.go(this.state);

View File

@ -223,9 +223,9 @@ describe('Component vnWatcher', () => {
});
describe(`onConfirmResponse()`, () => {
describe(`when response is ACCEPT`, () => {
describe(`when response is accept`, () => {
it(`should call Object.assing on controlle.data with controller.orgData then call go() on state`, () => {
let response = 'ACCEPT';
let response = 'accept';
controller.data = {};
controller.orgData = {name: 'Batman'};
controller.$state = {go: jasmine.createSpy('go')};
@ -237,9 +237,9 @@ describe('Component vnWatcher', () => {
});
});
describe(`when response is not ACCEPT`, () => {
describe(`when response is not accept`, () => {
it(`should set controller.state to null`, () => {
let response = 'anything but ACCEPT';
let response = 'anything but accept';
controller.state = 'Batman';
controller.onConfirmResponse(response);

View File

@ -21,9 +21,12 @@ export function focus($scope, input) {
}
input.focus();
if (input.select) {
$scope.$applyAsync(() => {
input.select();
});
}
}
/**

View File

@ -112,5 +112,6 @@
"This phone already exists": "Este teléfono ya existe",
"You cannot move a parent to any of its sons": "You cannot move a parent to any of its sons",
"You cannot move a parent to its own sons": "You cannot move a parent to its own sons",
"You can't create a claim for a removed ticket": "No puedes crear una reclamación para un ticket eliminado"
"You can't create a claim for a removed ticket": "No puedes crear una reclamación para un ticket eliminado",
"AMOUNT_NOT_MATCH_GROUPING": "AMOUNT_NOT_MATCH_GROUPING"
}

View File

@ -47,7 +47,7 @@
</div>
<vn-confirm
vn-id="delete-zone"
on-response="$ctrl.returnDialog(response)"
on-response="$ctrl.returnDialog($response)"
question="Are you sure you want to delete this zone?"
message="This zone will be removed">
</vn-confirm>

View File

@ -19,7 +19,7 @@ class Controller {
}
returnDialog(response) {
if (response === 'ACCEPT') {
if (response === 'accept') {
this.$http.delete(`Zones/${this.zone.id}`).then(() => {
this.$state.go('zone.index');
});

View File

@ -94,7 +94,7 @@
</vn-side-menu>
<vn-dialog
vn-id="dialog"
on-response="$ctrl.onSave(response)">
on-response="$ctrl.onIncludeResponse($response)">
<tpl-body>
<vn-vertical>
<vn-vertical class="vn-pb-md">
@ -162,7 +162,7 @@
<tpl-buttons>
<input
type="button"
response="CANCEL"
response="cancel"
translate-attr="{value: 'Cancel'}">
</input>
<button
@ -171,7 +171,7 @@
translate>
Delete
</button>
<button response="ACCEPT">
<button response="accept">
<span ng-if="$ctrl.isNew" translate>Add</span>
<span ng-if="!$ctrl.isNew" translate>Save</span>
</button>
@ -180,6 +180,5 @@
<vn-confirm
vn-id="confirm"
message="This item will be deleted"
question="Are you sure you want to continue?"
on-response="$ctrl.delete(response)">
question="Are you sure you want to continue?">
</vn-confirm>

View File

@ -101,8 +101,9 @@ class Controller extends Component {
this.$.dialog.show();
}
onSave(response) {
if (response == 'ACCEPT') {
onIncludeResponse(response) {
switch (response) {
case 'accept': {
let selected = this.selected;
if (this.eventType == 'indefinitely') {
@ -131,17 +132,15 @@ class Controller extends Component {
else
req = this.$http.put(`${this.path}/${selected.id}`, selected);
req.then(() => {
return req.then(() => {
this.selected = null;
this.isNew = null;
this.$.dialog.hide();
this.refresh();
});
return false;
} else if (response == 'DELETE') {
this.onDelete(this.selected.id);
return false;
}
case 'DELETE':
return this.onDelete(this.selected.id)
.then(response => response == 'accept');
}
}
@ -152,19 +151,14 @@ class Controller extends Component {
}
onDelete(id) {
this.deleteId = id;
this.$.confirm.show();
return this.$.confirm.show(
response => this.onDeleteResponse(response, id));
}
delete(response) {
if (response != 'ACCEPT') return;
if (!this.deleteId) return;
this.$http.delete(`${this.path}/${this.deleteId}`)
.then(() => {
this.refresh();
this.deleteId = null;
this.$.dialog.hide();
});
onDeleteResponse(response, id) {
if (response != 'accept' || !id) return;
return this.$http.delete(`${this.path}/${id}`)
.then(() => this.refresh());
}
exclusionCreate(days) {

View File

@ -68,7 +68,7 @@
</vn-popup>
<vn-confirm
vn-id="clone"
on-response="$ctrl.onCloneAccept(response)"
on-response="$ctrl.onCloneAccept($response)"
question="Do you want to clone this zone?"
message="All it's properties will be copied">
</vn-confirm>

View File

@ -39,10 +39,10 @@ export default class Controller {
/**
* Clone response callback
* @param {String} response - Response string (['ACCEPT', 'CANCEL'])
* @param {String} response - Response string (['accept', 'cancel'])
*/
onCloneAccept(response) {
if (!(response == 'ACCEPT' && this.selectedZone)) return;
if (!(response == 'accept' && this.selectedZone)) return;
const query = `Zones/${this.selectedZone.id}/clone`;
this.$http.post(query).then(res => {
if (res && res.data)

View File

@ -28,7 +28,7 @@
</vn-float-button>
<vn-dialog
vn-id="dialog"
on-response="$ctrl.onSave(response)">
on-response="$ctrl.onSave($response)">
<tpl-body>
<vn-vertical>
<vn-autocomplete
@ -41,13 +41,13 @@
</vn-vertical>
</tpl-body>
<tpl-buttons>
<input type="button" response="CANCEL" translate-attr="{value: 'Cancel'}"/>
<button response="ACCEPT" translate>Save</button>
<input type="button" response="cancel" translate-attr="{value: 'Cancel'}"/>
<button response="accept" translate>Save</button>
</tpl-buttons>
</vn-dialog>
<vn-confirm
vn-id="confirm"
message="This item will be deleted"
question="Are you sure you want to continue?"
on-response="$ctrl.delete(response)">
on-response="$ctrl.delete($response)">
</vn-confirm>

View File

@ -21,7 +21,7 @@ class Controller extends Component {
}
onSave(response) {
if (response != 'ACCEPT') return;
if (response != 'accept') return;
this.$http.post(this.path, this.selected)
.then(() => {
@ -40,7 +40,7 @@ class Controller extends Component {
}
delete(response) {
if (response != 'ACCEPT') return;
if (response != 'accept') return;
let id = this.$.data[this.deleteIndex].id;
if (!id) return;
this.$http.delete(`${this.path}/${id}`)

View File

@ -201,5 +201,5 @@
vn-id="update-greuge"
question="Insert greuges on client card"
message="Do you want to insert greuges?"
on-response="$ctrl.onUpdateGreugeResponse(response)">
on-response="$ctrl.onUpdateGreugeResponse($response)">
</vn-confirm>

View File

@ -133,7 +133,7 @@ class Controller {
}
onUpdateGreugeResponse(response) {
if (response !== 'ACCEPT')
if (response !== 'accept')
return;
let greugeTypeFreight = 7;
let query = `Greuges/`;

View File

@ -154,7 +154,7 @@ describe('claim', () => {
spyOn(controller.card, 'reload');
spyOn(controller.vnApp, 'showSuccess');
controller.onUpdateGreugeResponse('CANCEL');
controller.onUpdateGreugeResponse('cancel');
expect(controller.$http.post).not.toHaveBeenCalledWith();
expect(controller.card.reload).not.toHaveBeenCalledWith();
@ -174,7 +174,7 @@ describe('claim', () => {
ticketFk: controller.claim.ticketFk
};
$httpBackend.expect('POST', `Greuges/`, data).respond();
controller.onUpdateGreugeResponse('ACCEPT');
controller.onUpdateGreugeResponse('accept');
$httpBackend.flush();
expect(controller.card.reload).toHaveBeenCalledWith();

View File

@ -49,13 +49,13 @@
</div>
<vn-confirm
vn-id="confirm-pickup-order"
on-response="$ctrl.sendPickupOrder(response)"
on-response="$ctrl.sendPickupOrder($response)"
question="Send Pickup order"
message="Are you sure you want to send it?">
</vn-confirm>
<vn-confirm
vn-id="confirm-delete-claim"
on-response="$ctrl.deleteClaim(response)"
on-response="$ctrl.deleteClaim($response)"
question="Delete claim"
message="Are you sure you want to delete this claim?">
</vn-confirm>

View File

@ -69,7 +69,7 @@ class Controller {
}
sendPickupOrder(response) {
if (response === 'ACCEPT') {
if (response === 'accept') {
this.$http.post(`email/claim-pickup-order`, {claimFk: this.claim.id}).then(
() => this.vnApp.showMessage(this.$translate.instant('Notification sent!'))
);
@ -81,7 +81,7 @@ class Controller {
}
deleteClaim(response) {
if (response === 'ACCEPT') {
if (response === 'accept') {
this.$http.delete(`Claims/${this.claim.id}`).then(() => {
this.vnApp.showSuccess(this.$translate.instant('Claim deleted!'));
this.$state.go('claim.index');

View File

@ -35,12 +35,12 @@ describe('Item Component vnClaimDescriptor', () => {
});
describe('sendPickupOrder(response)', () => {
it('should make a query and call vnApp.showMessage() if the response is ACCEPT', () => {
it('should make a query and call vnApp.showMessage() if the response is accept', () => {
spyOn(controller.vnApp, 'showMessage');
$httpBackend.when('POST', `email/claim-pickup-order`, {claimFk: 2}).respond();
$httpBackend.expect('POST', `email/claim-pickup-order`, {claimFk: 2}).respond();
controller.sendPickupOrder('ACCEPT');
controller.sendPickupOrder('accept');
$httpBackend.flush();
expect(controller.vnApp.showMessage).toHaveBeenCalledWith('Notification sent!');
@ -60,8 +60,8 @@ describe('Item Component vnClaimDescriptor', () => {
});
describe('deleteClaime(response)', () => {
it('should perform a query and call showSuccess if the response is ACCEPT', () => {
let response = 'ACCEPT';
it('should perform a query and call showSuccess if the response is accept', () => {
let response = 'accept';
controller.claim = {id: 2};
spyOn(controller.vnApp, 'showSuccess');

View File

@ -37,5 +37,5 @@
vn-id="confirm"
message="This file will be deleted"
question="Are you sure you want to continue?"
on-response="$ctrl.deleteDms(response)">
on-response="$ctrl.deleteDms($response)">
</vn-confirm>

View File

@ -26,7 +26,7 @@ class Controller {
}
deleteDms(response) {
if (response === 'ACCEPT') {
if (response === 'accept') {
const dmsFk = this.photos[this.dmsIndex].dmsFk;
const query = `claimDms/${dmsFk}/removeFile`;
this.$http.post(query).then(() => {

View File

@ -35,7 +35,7 @@ describe('Claim', () => {
$httpBackend.when('POST', `claimDms/${dmsId}/removeFile`).respond({});
$httpBackend.expect('POST', `claimDms/${dmsId}/removeFile`);
controller.deleteDms('ACCEPT');
controller.deleteDms('accept');
$httpBackend.flush();
expect(controller.$.model.remove).toHaveBeenCalledWith(dmsIndex);

View File

@ -128,5 +128,5 @@
<!-- New postcode dialog -->
<vn-client-postcode vn-id="postcode"
on-response="$ctrl.onResponse(response)">
on-response="$ctrl.onResponse($response)">
</vn-client-postcode>

View File

@ -174,6 +174,6 @@
<!-- New postcode dialog -->
<vn-client-postcode vn-id="postcode"
on-response="$ctrl.onResponse(response)">
on-response="$ctrl.onResponse($response)">
</vn-client-postcode>

View File

@ -99,7 +99,7 @@
<vn-dialog class="edit"
vn-id="bankEntityDialog"
on-open="$ctrl.onBankEntityOpen()"
on-response="$ctrl.onBankEntityResponse(response)">
on-response="$ctrl.onBankEntityResponse($response)">
<tpl-body>
<h5 class="vn-py-sm" translate>New bank entity</h5>
<vn-horizontal>
@ -141,7 +141,7 @@
</vn-horizontal>
</tpl-body>
<tpl-buttons>
<input type="button" response="CANCEL" translate-attr="{value: 'Cancel'}"/>
<button response="ACCEPT" translate>Create</button>
<input type="button" response="cancel" translate-attr="{value: 'Cancel'}"/>
<button response="accept" translate>Create</button>
</tpl-buttons>
</vn-dialog>

View File

@ -55,7 +55,7 @@ export default class Controller {
}
onBankEntityResponse(response) {
if (response == 'ACCEPT') {
if (response == 'accept') {
try {
if (!this.newBankEntity.name)
throw new Error(`Name can't be empty`);

View File

@ -53,7 +53,7 @@ describe('Client', () => {
countryFk: 1,
id: 999
};
controller.onBankEntityResponse('ACCEPT');
controller.onBankEntityResponse('accept');
expect(vnApp.showError).toHaveBeenCalledWith(`Name can't be empty`);
});
@ -65,7 +65,7 @@ describe('Client', () => {
countryFk: 1,
id: 999
};
controller.onBankEntityResponse('ACCEPT');
controller.onBankEntityResponse('accept');
expect(vnApp.showError).toHaveBeenCalledWith(`Swift / BIC can't be empty`);
});
@ -80,7 +80,7 @@ describe('Client', () => {
controller.newBankEntity = newBankEntity;
$httpBackend.when('POST', 'BankEntities').respond('done');
$httpBackend.expectPOST('BankEntities', newBankEntity);
controller.onBankEntityResponse('ACCEPT');
controller.onBankEntityResponse('accept');
$httpBackend.flush();
});
});

View File

@ -149,6 +149,6 @@
<!-- New postcode dialog -->
<vn-client-postcode vn-id="postcode"
on-response="$ctrl.onResponse(response)">
on-response="$ctrl.onResponse($response)">
</vn-client-postcode>
</div>

View File

@ -60,7 +60,7 @@
</vn-float-button>
<vn-confirm
vn-id="close-contract"
on-response="$ctrl.returnDialog(response)"
on-response="$ctrl.returnDialog($response)"
question="Close contract"
message="Are you sure you want to close this contract?">
</vn-confirm>

View File

@ -56,7 +56,7 @@ class Controller {
}
returnDialog(response) {
if (response === 'ACCEPT') {
if (response === 'accept') {
let params = {finished: Date.now()};
this.$http.patch(`CreditClassifications/${this.classificationId}`, params).then(() => {
this._getClassifications(this.client.id);

View File

@ -76,7 +76,7 @@ describe('Client', () => {
controller.classificationId = 1;
$httpBackend.when('PATCH', `CreditClassifications/1`).respond(200);
$httpBackend.expect('PATCH', `CreditClassifications/1`);
controller.returnDialog('ACCEPT');
controller.returnDialog('accept');
$httpBackend.flush();
expect(controller._getClassifications).toHaveBeenCalledWith(101);

View File

@ -25,7 +25,7 @@
</form>
<vn-confirm
vn-id="confirmation"
on-response="$ctrl.returnDialog(response)"
on-response="$ctrl.returnDialog($response)"
question="Esta modificación retrasará el plazo del próximo recobro"
message="¿Desea continuar?">
</vn-confirm>

View File

@ -22,7 +22,7 @@ class Controller {
}
returnDialog(response) {
if (response === 'ACCEPT')
if (response === 'accept')
this.addCredit();
}

View File

@ -72,9 +72,9 @@ describe('Client', () => {
});
describe('returnDialog()', () => {
it('should call addCredit() when is called with ACCEPT', () => {
it('should call addCredit() when is called with accept', () => {
spyOn(controller, 'addCredit');
controller.returnDialog('ACCEPT');
controller.returnDialog('accept');
expect(controller.addCredit).toHaveBeenCalledWith();
});

View File

@ -113,5 +113,5 @@
vn-id="confirm"
message="This file will be deleted"
question="Are you sure you want to continue?"
on-response="$ctrl.deleteDms(response)">
on-response="$ctrl.deleteDms($response)">
</vn-confirm>

View File

@ -60,7 +60,7 @@ class Controller {
}
deleteDms(response) {
if (response === 'ACCEPT') {
if (response === 'accept') {
const dmsFk = this.clientDms[this.dmsIndex].dmsFk;
const query = `clientDms/${dmsFk}/removeFile`;
this.$http.post(query).then(() => {

View File

@ -29,7 +29,7 @@ describe('Client', () => {
$httpBackend.when('POST', `clientDms/${dmsId}/removeFile`).respond({});
$httpBackend.expect('POST', `clientDms/${dmsId}/removeFile`);
controller.deleteDms('ACCEPT');
controller.deleteDms('accept');
$httpBackend.flush();
expect(controller.$.model.remove).toHaveBeenCalledWith(dmsIndex);

View File

@ -148,5 +148,5 @@
vn-id="propagate-isEqualizated"
question="You changed the equalization tax"
message="Do you want to spread the change?"
on-response="$ctrl.returnDialogEt(response)">
on-response="$ctrl.returnDialogEt($response)">
</vn-confirm>

View File

@ -41,13 +41,13 @@ export default class Controller {
if (!equals && !this.oldHasToInvoiceByAddress)
this.$.propagateIsEqualizated.show();
else if (!equals)
this.returnDialogEt('ACCEPT');
this.returnDialogEt('accept');
delete this.oldHasToInvoiceByAddress;
}
returnDialogEt(response) {
if (response === 'ACCEPT') {
if (response === 'accept') {
this.$http.patch(`Clients/${this.client.id}/addressesPropagateRe`, {isEqualizated: this.client.isEqualizated}).then(
res => {
if (res.data)

View File

@ -20,7 +20,7 @@ describe('Client', () => {
controller.client = {id: 123, isEqualizated: false};
$httpBackend.when('PATCH', `Clients/${controller.client.id}/addressesPropagateRe`, {isEqualizated: controller.client.isEqualizated}).respond('done');
$httpBackend.expectPATCH(`Clients/${controller.client.id}/addressesPropagateRe`, {isEqualizated: controller.client.isEqualizated});
controller.returnDialogEt('ACCEPT');
controller.returnDialogEt('accept');
$httpBackend.flush();
});
});

View File

@ -1,7 +1,7 @@
<vn-dialog class="edit"
vn-id="postcodeDialog"
on-open="$ctrl.onOpen()"
on-response="$ctrl.onResponse(response)">
on-response="$ctrl.onResponse($response)">
<tpl-body>
<h5 class="vn-py-sm" translate>New postcode</h5>
<p translate>Please, ensure you put the correct data!</p>
@ -44,7 +44,7 @@
</vn-horizontal>
</tpl-body>
<tpl-buttons>
<input type="button" response="CANCEL" translate-attr="{value: 'Cancel'}"/>
<button response="ACCEPT" translate>Save</button>
<input type="button" response="cancel" translate-attr="{value: 'Cancel'}"/>
<button response="accept" translate>Save</button>
</tpl-buttons>
</vn-dialog>

View File

@ -36,7 +36,7 @@ class Controller extends Component {
}
onResponse(response) {
if (response == 'ACCEPT') {
if (response == 'accept') {
try {
if (!this.data.code)
throw new Error(`The postcode can't be empty`);

View File

@ -24,7 +24,7 @@ describe('Client', () => {
$httpBackend.when('PATCH', `postcodes`, params).respond(200, params);
$httpBackend.expect('PATCH', `postcodes`, params).respond(params);
controller.onResponse('ACCEPT');
controller.onResponse('accept');
$httpBackend.flush();
expect(controller.vnApp.showMessage).toHaveBeenCalledWith('The postcode has been saved');

View File

@ -1,6 +1,6 @@
<vn-dialog
vn-id="SMSDialog"
on-response="$ctrl.onResponse(response)">
on-response="$ctrl.onResponse($response)">
<tpl-body>
<h5 class="vn-py-sm" translate>Send SMS</h5>
<vn-horizontal>
@ -20,7 +20,7 @@
</vn-horizontal>
</tpl-body>
<tpl-buttons>
<input type="button" response="CANCEL" translate-attr="{value: 'Cancel'}"/>
<button response="ACCEPT" translate>Send</button>
<input type="button" response="cancel" translate-attr="{value: 'Cancel'}"/>
<button response="accept" translate>Send</button>
</tpl-buttons>
</vn-dialog>

View File

@ -17,7 +17,7 @@ class Controller extends Component {
}
onResponse(response) {
if (response === 'ACCEPT') {
if (response === 'accept') {
this.$http.post(`Sms/send`, this.sms).then(res => {
this.vnApp.showMessage(this.$translate.instant('SMS sent!'));

View File

@ -24,7 +24,7 @@ describe('Client', () => {
$httpBackend.when('POST', `Sms/send`, params).respond(200, params);
$httpBackend.expect('POST', `Sms/send`, params).respond(params);
controller.onResponse('ACCEPT');
controller.onResponse('accept');
$httpBackend.flush();
expect(controller.vnApp.showMessage).toHaveBeenCalledWith('SMS sent!');

View File

@ -34,7 +34,7 @@
<vn-dialog
vn-id="change-pass"
on-open="$ctrl.onPassOpen()"
on-response="$ctrl.onPassChange(response)">
on-response="$ctrl.onPassChange($response)">
<tpl-body>
<vn-textfield
type="password"
@ -48,7 +48,7 @@
</vn-textfield>
</tpl-body>
<tpl-buttons>
<input type="button" response="CANCEL" translate-attr="{value: 'Cancel'}"/>
<button response="ACCEPT" translate>Change password</button>
<input type="button" response="cancel" translate-attr="{value: 'Cancel'}"/>
<button response="accept" translate>Change password</button>
</tpl-buttons>
</vn-dialog>

View File

@ -41,7 +41,7 @@ export default class Controller {
}
onPassChange(response) {
if (response == 'ACCEPT') {
if (response == 'accept') {
try {
if (!this.newPassword)
throw new Error(`You must enter a new password`);

View File

@ -73,7 +73,7 @@ describe('Component VnClientWebAccess', () => {
controller.canChangePassword = true;
$httpBackend.when('PATCH', 'Accounts/1234').respond('done');
$httpBackend.expectPATCH('Accounts/1234', {password: 'm24x8'});
controller.onPassChange('ACCEPT');
controller.onPassChange('accept');
$httpBackend.flush();
});
@ -82,7 +82,7 @@ describe('Component VnClientWebAccess', () => {
controller.client = {id: '1234'};
controller.newPassword = '';
controller.canChangePassword = true;
controller.onPassChange('ACCEPT');
controller.onPassChange('accept');
expect(vnApp.showError).toHaveBeenCalledWith(`You must enter a new password`);
});
@ -94,7 +94,7 @@ describe('Component VnClientWebAccess', () => {
controller.newPassword = 'm24x8';
controller.canChangePassword = true;
controller.repeatPassword = 'notMatchingPassword';
controller.onPassChange('ACCEPT');
controller.onPassChange('accept');
expect(vnApp.showError).toHaveBeenCalledWith(`Passwords don't match`);
});

View File

@ -40,11 +40,11 @@
</div>
<vn-confirm
vn-id="deleteConfirmation"
on-response="$ctrl.deleteInvoiceOut(response)"
on-response="$ctrl.deleteInvoiceOut($response)"
question="Are you sure you want to delete this invoice?">
</vn-confirm>
<vn-confirm
vn-id="bookConfirmation"
on-response="$ctrl.bookInvoiceOut(response)"
on-response="$ctrl.bookInvoiceOut($response)"
question="Are you sure you want to book this invoice?">
</vn-confirm>

View File

@ -66,7 +66,7 @@ class Controller {
}
deleteInvoiceOut(response) {
if (response === 'ACCEPT') {
if (response === 'accept') {
const query = `InvoiceOuts/${this.invoiceOut.id}/delete`;
this.$http.post(query).then(() => {
this.vnApp.showSuccess(this.$translate.instant('InvoiceOut deleted'));
@ -76,7 +76,7 @@ class Controller {
}
bookInvoiceOut(response) {
if (response === 'ACCEPT') {
if (response === 'accept') {
const query = `InvoiceOuts/${this.invoiceOut.ref}/book`;
this.$http.post(query).then(() => {
this.vnApp.showSuccess(this.$translate.instant('InvoiceOut booked'));

View File

@ -72,7 +72,7 @@
<vn-dialog
vn-id="regularize"
on-open="$ctrl.clearRegularizeDialog()"
on-response="$ctrl.saveRegularize(response)">
on-response="$ctrl.saveRegularize($response)">
<tpl-body>
<div>
<h5 style="text-align: center">
@ -98,7 +98,7 @@
</div>
</tpl-body>
<tpl-buttons>
<input type="button" response="CANCEL" translate-attr="{value: 'Cancel'}"/>
<button response="ACCEPT" translate>Save</button>
<input type="button" response="cancel" translate-attr="{value: 'Cancel'}"/>
<button response="accept" translate>Save</button>
</tpl-buttons>
</vn-dialog>

View File

@ -76,7 +76,7 @@ class Controller {
}
saveRegularize(response) {
if (response == 'ACCEPT') {
if (response == 'accept') {
this.$http.post(`Items/regularize`, {
itemFk: this.item.id,
quantity: this.quantity,

View File

@ -136,7 +136,7 @@
</vn-popup>
<vn-confirm
vn-id="clone"
on-response="$ctrl.onCloneAccept(response)"
on-response="$ctrl.onCloneAccept($response)"
question="Do you want to clone this item?"
message="All it's properties will be copied">
</vn-confirm>

View File

@ -74,7 +74,7 @@ class Controller {
}
onCloneAccept(response) {
if (!(response == 'ACCEPT' && this.itemSelected))
if (!(response == 'accept' && this.itemSelected))
return;
this.$http.post(`Items/${this.itemSelected.id}/clone`).then(res => {

View File

@ -15,7 +15,7 @@ describe('Item', () => {
}));
describe('onCloneAccept()', () => {
it('should do nothing if response is not ACCEPT', () => {
it('should do nothing if response is not accept', () => {
spyOn(controller.$state, 'go');
let response = 'ERROR!';
@ -27,10 +27,10 @@ describe('Item', () => {
expect(controller.itemSelected).toEqual('check me');
});
it('should do nothing if response is ACCEPT but itemSelected is not defined in the controller', () => {
it('should do nothing if response is accept but itemSelected is not defined in the controller', () => {
spyOn(controller.$state, 'go');
let response = 'ACCEPT';
let response = 'accept';
controller.itemSelected = undefined;
controller.onCloneAccept(response);
@ -42,7 +42,7 @@ describe('Item', () => {
it('should perform a post query and then call go() then update itemSelected in the controller', () => {
spyOn(controller.$state, 'go');
let response = 'ACCEPT';
let response = 'accept';
controller.itemSelected = {id: 1};
$httpBackend.when('POST', `Items/1/clone`).respond({id: 99});

View File

@ -124,7 +124,7 @@
</vn-item-descriptor-popover>
<vn-dialog
vn-id="denyReason"
on-response="$ctrl.denyRequest(response)">
on-response="$ctrl.denyRequest($response)">
<tpl-body>
<h5 class="vn-pa-md" translate>Specify the reasons to deny this request</h5>
<vn-horizontal class="vn-pa-md">
@ -134,7 +134,7 @@
</vn-horizontal>
</tpl-body>
<tpl-buttons>
<input type="button" response="CANCEL" translate-attr="{value: 'Cancel'}"/>
<button response="ACCEPT" translate>Save</button>
<input type="button" response="cancel" translate-attr="{value: 'Cancel'}"/>
<button response="accept" translate>Save</button>
</tpl-buttons>
</vn-dialog>

View File

@ -104,7 +104,7 @@ export default class Controller extends Component {
}
denyRequest(response) {
if (response !== 'ACCEPT') return;
if (response !== 'accept') return;
let params = {
observation: this.denyObservation

View File

@ -122,7 +122,7 @@ describe('Item', () => {
$httpBackend.when('POST', `TicketRequests/${request.id}/deny`).respond(expectedResult);
$httpBackend.expect('POST', `TicketRequests/${request.id}/deny`).respond(expectedResult);
controller.denyRequest('ACCEPT');
controller.denyRequest('accept');
$httpBackend.flush();
expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!');

View File

@ -53,7 +53,7 @@
</div>
<vn-confirm
vn-id="deleteOrderConfirmation"
on-response="$ctrl.deleteOrder(response)"
on-response="$ctrl.deleteOrder($response)"
message="You are going to delete this order"
question="continue anyway?">
</vn-confirm>

View File

@ -44,7 +44,7 @@ class Controller {
}
deleteOrder(response) {
if (response === 'ACCEPT') {
if (response === 'accept') {
const params = {id: this.order.id};
this.$http.delete(`Orders/${params.id}`).then(() => {
this.$state.go('order.index');

View File

@ -13,7 +13,7 @@ describe('Order Component vnOrderDescriptor', () => {
}));
describe('deleteOrder()', () => {
it(`should do nothing if the response isn't ACCEPT`, () => {
it(`should do nothing if the response isn't accept`, () => {
let response = 'WAGH!';
spyOn(controller.vnApp, 'showSuccess');
@ -24,8 +24,8 @@ describe('Order Component vnOrderDescriptor', () => {
expect(controller.$state.go).not.toHaveBeenCalledWith('order.index');
});
it(`should perform a DELETE query if the response was ACCEPT`, () => {
let response = 'ACCEPT';
it(`should perform a DELETE query if the response was accept`, () => {
let response = 'accept';
spyOn(controller.vnApp, 'showSuccess');
spyOn(controller.$state, 'go');

View File

@ -84,7 +84,7 @@
</vn-item-descriptor-popover>
<vn-confirm
vn-id="delete-row"
on-response="$ctrl.deleteRow(response)"
on-response="$ctrl.deleteRow($response)"
question="Delete row"
message="Are you sure you want to delete this row?">
</vn-confirm>

View File

@ -58,7 +58,7 @@ class Controller {
}
deleteRow(response) {
if (response == 'ACCEPT') {
if (response == 'accept') {
let [lineRemoved] = this.rows.splice(this.lineIdToRemove, 1);
this.idsToRemove.push(lineRemoved.id);
let params = {

View File

@ -48,12 +48,12 @@ describe('Order', () => {
});
describe('deleteRow()', () => {
it('should remove a row from rows and add save the data if the response is ACCEPT', () => {
it('should remove a row from rows and add save the data if the response is accept', () => {
expect(controller.rows.length).toBe(1);
spyOn(controller.vnApp, 'showSuccess');
spyOn(controller, 'getVAT');
spyOn(controller.card, 'reload');
controller.deleteRow('ACCEPT');
controller.deleteRow('accept');
$httpBackend.expectPOST(`OrderRows/removes`).respond();
$httpBackend.flush();

View File

@ -53,6 +53,6 @@
</div>
<vn-confirm
vn-id="updateVolumeConfirmation"
on-response="$ctrl.updateVolume(response)"
on-response="$ctrl.updateVolume($response)"
question="Are you sure you want to update the volume?">
</vn-confirm>

View File

@ -52,7 +52,7 @@ class Controller {
}
updateVolume(response) {
if (response === 'ACCEPT') {
if (response === 'accept') {
let url = `Routes/${this.route.id}/updateVolume`;
this.$http.post(url).then(() => {
this.vnApp.showSuccess(this.$translate.instant('Volume updated'));

View File

@ -109,7 +109,7 @@
<vn-confirm
vn-id="confirm"
question="Delete ticket from route?"
on-response="$ctrl.removeTicketFromRoute(response)">
on-response="$ctrl.removeTicketFromRoute($response)">
</vn-confirm>
<vn-crud-model
vn-id="possibleTicketsModel"
@ -119,7 +119,7 @@
</vn-crud-model>
<vn-dialog
vn-id="possibleTicketsDialog"
on-response="$ctrl.setTicketsRoute(response)">
on-response="$ctrl.setTicketsRoute($response)">
<tpl-body>
<section class="header vn-pa-md">
<h5><span translate>Tickets to add</span></h5>
@ -166,8 +166,8 @@
</vn-data-viewer>
</tpl-body>
<tpl-buttons>
<input type="button" response="CANCEL" translate-attr="{value: 'Cancel'}"/>
<button response="ACCEPT" translate>Add</button>
<input type="button" response="cancel" translate-attr="{value: 'Cancel'}"/>
<button response="accept" translate>Add</button>
</tpl-buttons>
</vn-dialog>
<vn-float-button

View File

@ -105,7 +105,7 @@ class Controller {
}
removeTicketFromRoute(response) {
if (response === 'ACCEPT') {
if (response === 'accept') {
let params = {routeFk: null};
let query = `Tickets/${this.selectedTicket}/`;
this.$http.patch(query, params).then(() => {
@ -151,7 +151,7 @@ class Controller {
}
setTicketsRoute(response) {
if (response === 'ACCEPT') {
if (response === 'accept') {
let tickets = this.getSelectedItems(this.possibleTickets);
for (let i = 0; i < tickets.length; i++) {

View File

@ -160,7 +160,7 @@ describe('Route', () => {
controller.selectedTicket = ticketId;
$httpBackend.expectPATCH(`Tickets/${ticketId}/`).respond('ok');
controller.removeTicketFromRoute('ACCEPT');
controller.removeTicketFromRoute('accept');
$httpBackend.flush();
expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Ticket removed from route');
@ -273,14 +273,14 @@ describe('Route', () => {
{id: 5, routeFk: 111}
];
controller.setTicketsRoute('ACCEPT').then(() => {
controller.setTicketsRoute('accept').then(() => {
expect(controller.$.model.data).toEqual(expectedResult);
done();
}).catch(done.fail);
});
it('should just return a promise', () => {
expect(controller.setTicketsRoute('CANCEL')).toEqual(jasmine.any(Promise));
expect(controller.setTicketsRoute('cancel')).toEqual(jasmine.any(Promise));
});
});
});

View File

@ -130,7 +130,7 @@
</vn-popup>
<vn-confirm
vn-id="deleteConfirmation"
on-response="$ctrl.deleteTicket(response)"
on-response="$ctrl.deleteTicket($response)"
question="You are going to delete this ticket"
message="This ticket will be removed from current route! Continue anyway?">
</vn-confirm>
@ -146,13 +146,13 @@
</vn-remove-stowaway>
<vn-confirm
vn-id="confirm-dialog"
on-response="$ctrl.returnDialog(response)"
on-response="$ctrl.returnDialog($response)"
question="Pickup order"
message="Do you want to send it directly?">
</vn-confirm>
<vn-dialog
vn-id="changeShippedDialog"
on-response="$ctrl.changeShipped(response)">
on-response="$ctrl.changeShipped($response)">
<tpl-body>
<div>
<h5 style="text-align: center">
@ -168,15 +168,15 @@
</div>
</tpl-body>
<tpl-buttons>
<input type="button" response="CANCEL" translate-attr="{value: 'Cancel'}"/>
<button response="ACCEPT" translate>Save</button>
<input type="button" response="cancel" translate-attr="{value: 'Cancel'}"/>
<button response="accept" translate>Save</button>
</tpl-buttons>
</vn-dialog>
<!-- Make invoice dialog -->
<vn-confirm
vn-id="makeInvoiceConfirmation"
on-response="$ctrl.makeInvoice(response)"
on-response="$ctrl.makeInvoice($response)"
question="You are going to invoice this ticket"
message="Are you sure you want to invoice this ticket?">
</vn-confirm>
@ -185,7 +185,7 @@
<!-- Regenerate invoice dialog -->
<vn-confirm
vn-id="regenerateInvoiceConfirmation"
on-response="$ctrl.regenerateInvoice(response)"
on-response="$ctrl.regenerateInvoice($response)"
question="You are going to regenerate the invoice"
message="Are you sure you want to regenerate the invoice?">
</vn-confirm>
@ -197,7 +197,7 @@
<vn-confirm
vn-id="confirm-delivery-note"
on-response="$ctrl.sendDeliveryNote(response)"
on-response="$ctrl.sendDeliveryNote($response)"
question="Send Delivery Note"
message="Are you sure you want to send it?">
</vn-confirm>

View File

@ -50,7 +50,7 @@ class Controller {
}
changeShipped(response) {
if (response === 'ACCEPT') {
if (response === 'accept') {
let data = {shipped: this.newShipped};
let query = `Tickets/${this.ticket.id}/updateEditableTicket`;
this.$http.post(query, data).then(() => {
@ -137,7 +137,7 @@ class Controller {
}
deleteTicket(response) {
if (response === 'ACCEPT') {
if (response === 'accept') {
const query = `Tickets/${this.ticket.id}/setDeleted`;
this.$http.post(query).then(() => {
this.$state.go('ticket.index');
@ -229,7 +229,7 @@ class Controller {
* @param {String} response - Response result
*/
makeInvoice(response) {
if (response === 'ACCEPT') {
if (response === 'accept') {
const query = `Tickets/${this.ticket.id}/makeInvoice`;
this.$http.post(query).then(() => {
this.vnApp.showSuccess(this.$translate.instant('Ticket invoiced'));
@ -252,7 +252,7 @@ class Controller {
* @param {String} response - Response result
*/
regenerateInvoice(response) {
if (response === 'ACCEPT') {
if (response === 'accept') {
const invoiceId = this.ticket.invoiceOut.id;
const query = `InvoiceOuts/${invoiceId}/regenerate`;
this.$http.post(query).then(() => {
@ -277,7 +277,7 @@ class Controller {
}
sendDeliveryNote(response) {
if (response === 'ACCEPT') {
if (response === 'accept') {
this.$http.post(`email/delivery-note`, {ticketFk: this.ticket.id}).then(
() => this.vnApp.showMessage(this.$translate.instant('Notification sent!'))
);

View File

@ -66,12 +66,12 @@ describe('Ticket Component vnTicketDescriptor', () => {
});
describe('deleteTicket()', () => {
it('should make a query and call vnApp.showSuccess() if the response is ACCEPT', () => {
it('should make a query and call vnApp.showSuccess() if the response is accept', () => {
spyOn(controller.$state, 'go');
spyOn(controller.vnApp, 'showSuccess');
$httpBackend.expectPOST(`Tickets/2/setDeleted`).respond();
controller.deleteTicket('ACCEPT');
controller.deleteTicket('accept');
$httpBackend.flush();
expect(controller.$state.go).toHaveBeenCalledWith('ticket.index');
@ -90,13 +90,13 @@ describe('Ticket Component vnTicketDescriptor', () => {
});
describe('makeInvoice()', () => {
it('should make a query and call $state.reload() method if the response is ACCEPT', () => {
it('should make a query and call $state.reload() method if the response is accept', () => {
spyOn(controller.$state, 'reload');
spyOn(controller.vnApp, 'showSuccess');
$httpBackend.when('POST', 'Tickets/2/makeInvoice').respond();
$httpBackend.expect('POST', 'Tickets/2/makeInvoice').respond();
controller.makeInvoice('ACCEPT');
controller.makeInvoice('accept');
$httpBackend.flush();
expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Ticket invoiced');
@ -105,12 +105,12 @@ describe('Ticket Component vnTicketDescriptor', () => {
});
describe('regenerateInvoice()', () => {
it('should make a query and show a success snackbar if the response is ACCEPT', () => {
it('should make a query and show a success snackbar if the response is accept', () => {
spyOn(controller.vnApp, 'showSuccess');
$httpBackend.when('POST', 'InvoiceOuts/1/regenerate').respond();
$httpBackend.expect('POST', 'InvoiceOuts/1/regenerate').respond();
controller.regenerateInvoice('ACCEPT');
controller.regenerateInvoice('accept');
$httpBackend.flush();
expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Invoice sent for a regeneration, will be available in a few minutes');
@ -118,14 +118,14 @@ describe('Ticket Component vnTicketDescriptor', () => {
});
describe('changeShipped()', () => {
it('should make a query and change the shipped hour if the response is ACCEPT', () => {
it('should make a query and change the shipped hour if the response is accept', () => {
controller.ticket.id = 12;
spyOn(controller.vnApp, 'showSuccess');
spyOn(controller, 'cardReload');
$httpBackend.when('POST', 'Tickets/12/updateEditableTicket').respond();
$httpBackend.expect('POST', 'Tickets/12/updateEditableTicket').respond();
controller.changeShipped('ACCEPT');
controller.changeShipped('accept');
$httpBackend.flush();
expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Shipped hour updated');

View File

@ -32,7 +32,7 @@
<vn-confirm
vn-id="confirmation-dialog"
on-response="$ctrl.deleteStowaway(response)"
on-response="$ctrl.deleteStowaway($response)"
question="Delete stowaway"
message="Are you sure you want to delete this stowaway?">
</vn-confirm>

View File

@ -44,7 +44,7 @@ class Controller {
}
deleteStowaway(response) {
if (response === 'ACCEPT') {
if (response === 'accept') {
this.$http.delete(`Stowaways/${this.stowawayToDelete.id}`).then(res => {
this.cardReload();
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));

View File

@ -111,5 +111,5 @@
vn-id="confirm"
message="This file will be deleted"
question="Are you sure you want to continue?"
on-response="$ctrl.deleteDms(response)">
on-response="$ctrl.deleteDms($response)">
</vn-confirm>

View File

@ -60,7 +60,7 @@ class Controller {
}
deleteDms(response) {
if (response === 'ACCEPT') {
if (response === 'accept') {
const dmsFk = this.ticketDms[this.dmsIndex].dmsFk;
const query = `ticketDms/${dmsFk}/removeFile`;
this.$http.post(query).then(() => {

View File

@ -29,7 +29,7 @@ describe('Ticket', () => {
$httpBackend.when('POST', `ticketDms/${dmsId}/removeFile`).respond({});
$httpBackend.expect('POST', `ticketDms/${dmsId}/removeFile`);
controller.deleteDms('ACCEPT');
controller.deleteDms('accept');
$httpBackend.flush();
expect(controller.$.model.remove).toHaveBeenCalledWith(dmsIndex);

View File

@ -68,7 +68,7 @@
</vn-worker-descriptor-popover>
<vn-confirm
vn-id="delete-expedition"
on-response="$ctrl.returnDialog(response)"
on-response="$ctrl.returnDialog($response)"
question="Delete expedition"
message="Are you sure you want to delete this expedition?">
</vn-confirm>

View File

@ -13,7 +13,7 @@ class Controller {
}
returnDialog(response) {
if (response === 'ACCEPT') {
if (response === 'accept') {
this.$http.delete(`Expeditions/${this.expeditionId}`).then(
() => this.$.model.refresh()
);

View File

@ -23,7 +23,7 @@ describe('Ticket', () => {
it('should perform a DELETE query', () => {
spyOn($scope.model, 'refresh');
let response = 'ACCEPT';
let response = 'accept';
controller.expeditionId = 1;
$httpBackend.when('DELETE', `Expeditions/1`).respond(200);

View File

@ -380,12 +380,12 @@
vn-id="delete-lines"
question="You are going to delete lines of the ticket"
message="Continue anyway?"
on-response="$ctrl.onRemoveLinesClick(response)">
on-response="$ctrl.onRemoveLinesClick($response)">
</vn-confirm>
<vn-confirm
vn-id="delete-ticket"
question="Do you want to delete it?"
message="This ticket is now empty"
on-response="$ctrl.transferSales($ctrl.transfer.ticketId, response)">
on-response="$ctrl.transferSales($ctrl.transfer.ticketId, $response)">
</vn-confirm>

View File

@ -214,7 +214,7 @@ class Controller {
}
onRemoveLinesClick(response) {
if (response === 'ACCEPT') {
if (response === 'accept') {
let sales = this.checkedLines();
// Remove unsaved instances

View File

@ -140,7 +140,7 @@ describe('Ticket', () => {
$httpBackend.whenGET(`Tickets/1/subtotal`).respond(200, 227.5);
$httpBackend.whenGET(`Tickets/1/getVAT`).respond(200, 10.5);
$httpBackend.whenGET(`Tickets/1/isEditable`).respond();
controller.onRemoveLinesClick('ACCEPT');
controller.onRemoveLinesClick('accept');
$httpBackend.flush();
expect(controller.sales.length).toEqual(1);

View File

@ -75,7 +75,7 @@
<vn-dialog class="edit"
vn-id="createServiceTypeDialog"
on-open="$ctrl.onNewServiceTypeOpen()"
on-response="$ctrl.onNewServiceTypeResponse(response)">
on-response="$ctrl.onNewServiceTypeResponse($response)">
<tpl-body>
<h5 class="vn-py-sm" translate>New service type</h5>
<vn-horizontal>
@ -88,7 +88,7 @@
</vn-horizontal>
</tpl-body>
<tpl-buttons>
<input type="button" response="CANCEL" translate-attr="{value: 'Cancel'}"/>
<button response="ACCEPT" translate>Create</button>
<input type="button" response="cancel" translate-attr="{value: 'Cancel'}"/>
<button response="accept" translate>Create</button>
</tpl-buttons>
</vn-dialog>

View File

@ -51,7 +51,7 @@ class Controller {
}
onNewServiceTypeResponse(response) {
if (response == 'ACCEPT') {
if (response == 'accept') {
if (!this.newServiceType.name)
throw new UserError(`Name can't be empty`);

View File

@ -43,7 +43,7 @@ describe('Ticket component vnTicketService', () => {
let error;
try {
controller.onNewServiceTypeResponse('ACCEPT');
controller.onNewServiceTypeResponse('accept');
} catch (e) {
error = e.message;
}
@ -60,7 +60,7 @@ describe('Ticket component vnTicketService', () => {
controller.currentServiceIndex = 0;
$httpBackend.when('POST', 'TicketServiceTypes').respond({id: 4001, name: 'great service!'});
controller.onNewServiceTypeResponse('ACCEPT');
controller.onNewServiceTypeResponse('accept');
$httpBackend.flush();
expect(controller.services[0].description).toEqual('great service!');

View File

@ -66,6 +66,6 @@
<!-- New postcode dialog -->
<vn-client-postcode vn-id="postcode"
on-response="$ctrl.onResponse(response)">
on-response="$ctrl.onResponse($response)">
</vn-client-postcode>
</div>

View File

@ -93,7 +93,7 @@
</vn-worker-descriptor-popover>
<vn-confirm
vn-id="deleteWeekly"
on-response="$ctrl.returnDialog(response)"
on-response="$ctrl.returnDialog($response)"
question="This ticket will be removed from weekly tickets! Continue anyway?"
message="You are going to delete this weekly ticket">
</vn-confirm>

View File

@ -76,7 +76,7 @@ export default class Controller {
returnDialog(response) {
const ticket = this.$.model.data[this.ticketIndex];
if (response === 'ACCEPT') {
if (response === 'accept') {
this.$http.delete(`TicketWeeklies/${ticket.ticketFk}`).then(() => {
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
this.$.model.remove(this.ticketIndex);

View File

@ -27,13 +27,19 @@
{{'of' | translate}} {{$ctrl.calendar.totalHolidays}} {{'days' | translate}}
</div>
</div>
<div class="vn-pt-md">
<div class="vn-pt-md" style="overflow: hidden;">
<vn-chip ng-repeat="absenceType in absenceTypes">
<vn-avatar
ng-style="{backgroundColor: absenceType.rgb}">
</vn-avatar>
{{absenceType.name}}
</vn-chip>
<vn-chip>
<vn-avatar
ng-style="{backgroundColor: 'orange'}">
</vn-avatar>
My longer overflowing absence type in chip
</vn-chip>
</div>
</div>
</vn-side-menu>

Some files were not shown because too many files have changed in this diff Show More