diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js
index c09c10f50..67fc7e2fd 100644
--- a/e2e/helpers/selectors.js
+++ b/e2e/helpers/selectors.js
@@ -136,7 +136,7 @@ export default {
addCreditFloatButton: `vn-float-button`,
creditInput: `vn-input-number input[name="credit"]`,
saveButton: `button[type=submit]`,
- firstCreditText: 'vn-client-credit-index vn-card > div vn-table vn-tbody > vn-tr'
+ firstCreditText: 'vn-client-credit-index vn-card vn-table vn-tbody > vn-tr'
},
clientGreuge: {
addGreugeFloatButton: `vn-float-button`,
@@ -144,13 +144,13 @@ export default {
descriptionInput: `vn-textfield input[name="description"]`,
typeAutocomplete: 'vn-autocomplete[ng-model="$ctrl.greuge.greugeTypeFk"]',
saveButton: `button[type=submit]`,
- firstGreugeText: 'vn-client-greuge-index vn-card > div vn-table vn-tbody > vn-tr'
+ firstGreugeText: 'vn-client-greuge-index vn-card vn-table vn-tbody > vn-tr'
},
clientMandate: {
- firstMandateText: 'vn-client-mandate vn-card > div vn-table vn-tbody > vn-tr'
+ firstMandateText: 'vn-client-mandate vn-card vn-table vn-tbody > vn-tr'
},
clientInvoices: {
- firstInvoiceText: 'vn-client-invoice vn-card > div vn-table vn-tbody > vn-tr'
+ firstInvoiceText: 'vn-client-invoice vn-card vn-table vn-tbody > vn-tr'
},
clientLog: {
logButton: 'vn-left-menu a[ui-sref="client.card.log"]',
@@ -307,7 +307,7 @@ export default {
fifthLineCreatedProperty: 'vn-item-log > vn-log vn-tbody > vn-tr:nth-child(5) > vn-td > vn-one:nth-child(3) > div span:nth-child(3)',
},
ticketSummary: {
- header: 'vn-ticket-summary > vn-card > div > h5',
+ header: 'vn-ticket-summary > vn-card > h5',
state: 'vn-ticket-summary vn-label-value[label="State"] > section > span',
route: 'vn-ticket-summary vn-label-value[label="Route"] > section > a',
total: 'vn-ticket-summary vn-one.taxes > p:nth-child(3) > strong',
@@ -319,14 +319,14 @@ export default {
popoverDiaryButton: '.vn-popover.shown vn-item-descriptor vn-icon[icon="icon-transaction"]',
firstSaleQuantity: 'vn-ticket-summary [name="sales"] vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(3)',
firstSaleDiscount: 'vn-ticket-summary [name="sales"] vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(6)',
- invoiceOutRef: 'vn-ticket-summary > vn-card > div > vn-horizontal > vn-one:nth-child(1) > vn-label-value:nth-child(6) > section > span',
+ invoiceOutRef: 'vn-ticket-summary > vn-card > vn-horizontal > vn-one:nth-child(1) > vn-label-value:nth-child(6) > section > span',
setOk: 'vn-ticket-summary vn-button[label="SET OK"] > button'
},
ticketsIndex: {
openAdvancedSearchButton: 'vn-ticket-index vn-searchbar .append vn-icon[icon="arrow_drop_down"]',
advancedSearchInvoiceOut: 'vn-ticket-search-panel vn-textfield[ng-model="filter.refFk"] input',
newTicketButton: 'vn-ticket-index > a',
- searchResult: 'vn-ticket-index vn-card > div > vn-table > div > vn-tbody > a.vn-tr',
+ searchResult: 'vn-ticket-index vn-card > vn-table > div > vn-tbody > a.vn-tr',
searchWeeklyResult: 'vn-ticket-weekly-index vn-table vn-tbody > vn-tr',
searchResultDate: 'vn-ticket-index vn-table vn-tbody > a:nth-child(1) > vn-td:nth-child(5)',
searchTicketInput: `vn-ticket-index vn-textfield input`,
@@ -403,7 +403,7 @@ export default {
saleDescriptorPopoverSummaryButton: '.vn-popover.shown vn-item-descriptor a[ui-sref="item.card.summary({id: $ctrl.item.id})"]',
descriptorItemDiaryButton: 'vn-item-descriptor .quicklinks.ng-scope > vn-horizontal > a > vn-icon > i',
newItemFromCatalogButton: 'vn-ticket-sale vn-float-button[icon="add"]',
- newItemButton: 'vn-ticket-sale > vn-vertical > vn-card > div > vn-vertical > vn-one > vn-icon-button > button > vn-icon > i',
+ newItemButton: 'vn-ticket-sale > vn-vertical > vn-card > vn-vertical > vn-one > vn-icon-button > button > vn-icon > i',
moreMenu: 'vn-ticket-sale vn-tool-bar > vn-button-menu[vn-id="more-button"] > div > button',
moreMenuCreateClaim: '.vn-popover.shown .vn-drop-down li[name="Add claim"]',
moreMenuReserve: '.vn-popover.shown .vn-drop-down li[name="Mark as reserved"]',
@@ -443,7 +443,7 @@ export default {
secondSaleQuantity: 'vn-ticket-sale vn-table vn-tr:nth-child(2) vn-input-number input',
secondSaleConceptCell: 'vn-ticket-sale vn-table vn-tbody > vn-tr:nth-child(2) > vn-td-editable:nth-child(6)',
secondSaleConceptInput: 'vn-ticket-sale vn-table vn-tr:nth-child(2) > vn-td-editable.ng-isolate-scope.selected vn-textfield input',
- totalImport: 'vn-ticket-sale > vn-vertical > vn-card > div > vn-vertical > vn-horizontal > vn-one > p:nth-child(3) > strong',
+ totalImport: 'vn-ticket-sale > vn-vertical > vn-card > vn-vertical > vn-horizontal > vn-one > p:nth-child(3) > strong',
selectAllSalesCheckbox: 'vn-ticket-sale vn-thead vn-check',
secondSaleCheckbox: 'vn-ticket-sale vn-tr:nth-child(2) vn-check[ng-model="sale.checked"]',
thirdSaleCheckbox: 'vn-ticket-sale vn-tr:nth-child(3) vn-check[ng-model="sale.checked"]',
@@ -472,7 +472,7 @@ export default {
zoneAutocomplete: 'vn-autocomplete[ng-model="$ctrl.zoneId"]',
nextStepButton: 'vn-step-control .buttons > section:last-child vn-button',
finalizeButton: 'vn-step-control .buttons > section:last-child button[type=submit]',
- stepTwoTotalPriceDif: 'vn-ticket-basic-data-step-two > form > vn-card > div > vn-horizontal > table > tfoot > tr > td:nth-child(4)',
+ stepTwoTotalPriceDif: 'vn-ticket-basic-data-step-two > form > vn-card > vn-horizontal > table > tfoot > tr > td:nth-child(4)',
chargesReasonAutocomplete: 'vn-autocomplete[ng-model="$ctrl.ticket.option"]',
},
ticketComponents: {
@@ -481,7 +481,7 @@ export default {
ticketRequests: {
addRequestButton: 'vn-ticket-request-index > a > vn-float-button > button',
request: 'vn-ticket-request-index vn-table vn-tr',
- descriptionInput: 'vn-ticket-request-create > form > div > vn-card > div > vn-horizontal:nth-child(1) > vn-textfield input',
+ descriptionInput: 'vn-ticket-request-create > form > div > vn-card > vn-horizontal:nth-child(1) > vn-textfield input',
atenderAutocomplete: 'vn-ticket-request-create vn-autocomplete[ng-model="$ctrl.ticketRequest.atenderFk"]',
quantityInput: 'vn-ticket-request-create vn-input-number input[name=quantity]',
priceInput: 'vn-ticket-request-create vn-input-number input[name=price]',
@@ -505,7 +505,7 @@ export default {
firstVatTypeAutocomplete: 'vn-ticket-service vn-autocomplete[label="Tax class"]',
fistDeleteServiceButton: 'vn-ticket-service form vn-horizontal:nth-child(1) vn-icon-button[icon="delete"]',
newDescriptionInput: 'vn-ticket-service > vn-dialog vn-textfield[ng-model="$ctrl.newServiceType.name"] input',
- serviceLine: 'vn-ticket-service > form > vn-card > div > vn-one:nth-child(2) > vn-horizontal',
+ serviceLine: 'vn-ticket-service > form > vn-card > vn-one:nth-child(2) > vn-horizontal',
saveServiceButton: `button[type=submit]`,
saveDescriptionButton: 'vn-ticket-service > vn-dialog[vn-id="createServiceTypeDialog"] > div > form > div.buttons > tpl-buttons > button'
},
@@ -517,7 +517,7 @@ export default {
},
claimsIndex: {
searchClaimInput: `vn-claim-index vn-textfield input`,
- searchResult: 'vn-claim-index vn-card > div > vn-table > div > vn-tbody > a',
+ searchResult: 'vn-claim-index vn-card > vn-table > div > vn-tbody > a',
searchButton: 'vn-claim-index vn-searchbar vn-icon[icon="search"]'
},
claimDescriptor: {
@@ -526,7 +526,7 @@ export default {
acceptDeleteClaim: 'vn-claim-descriptor > vn-confirm[vn-id="confirm-delete-claim"] button[response="ACCEPT"]'
},
claimSummary: {
- header: 'vn-claim-summary > vn-card > div > h5',
+ header: 'vn-claim-summary > vn-card > h5',
state: 'vn-claim-summary vn-label-value[label="State"] > section > span',
observation: 'vn-claim-summary vn-textarea[ng-model="$ctrl.summary.claim.observation"] textarea',
firstSaleItemId: 'vn-claim-summary vn-horizontal > vn-auto:nth-child(4) vn-table > div > vn-tbody > vn-tr:nth-child(1) > vn-td:nth-child(1) > span',
@@ -535,7 +535,7 @@ export default {
itemDescriptorPopoverItemDiaryButton: '.vn-popover.shown vn-item-descriptor a[href="#!/item/2/diary"]',
firstDevelopmentWorker: 'vn-claim-summary vn-horizontal > vn-auto:nth-child(5) vn-table > div > vn-tbody > vn-tr:nth-child(1) > vn-td:nth-child(4) > span',
firstDevelopmentWorkerGoToClientButton: '.vn-popover.shown vn-worker-descriptor div.quicklinks > a[href="#!/client/21/summary"]',
- firstActionTicketId: 'vn-claim-summary > vn-card > div > vn-horizontal > vn-auto:nth-child(6) vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(2) > span',
+ firstActionTicketId: 'vn-claim-summary > vn-card > vn-horizontal > vn-auto:nth-child(6) vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(2) > span',
firstActionTicketDescriptor: '.vn-popover.shown vn-ticket-descriptor'
},
claimBasicData: {
@@ -545,19 +545,19 @@ export default {
saveButton: `button[type=submit]`
},
claimDetail: {
- secondItemDiscount: 'vn-claim-detail > vn-vertical > vn-card > div > vn-vertical > vn-table > div > vn-tbody > vn-tr:nth-child(2) > vn-td:nth-child(6) > span',
+ secondItemDiscount: 'vn-claim-detail > vn-vertical > vn-card > vn-vertical > vn-table > div > vn-tbody > vn-tr:nth-child(2) > vn-td:nth-child(6) > span',
discountInput: '.vn-popover.shown vn-input-number[ng-model="$ctrl.newDiscount"] input',
discoutPopoverMana: '.vn-popover.shown .content > div > vn-horizontal > h5',
addItemButton: 'vn-claim-detail a vn-float-button',
firstClaimableSaleFromTicket: 'vn-claim-detail > vn-dialog vn-tbody > vn-tr',
- claimDetailLine: 'vn-claim-detail > vn-vertical > vn-card > div > vn-vertical > vn-table > div > vn-tbody > vn-tr',
+ claimDetailLine: 'vn-claim-detail > vn-vertical > vn-card > vn-vertical > vn-table > div > vn-tbody > vn-tr',
firstItemQuantityInput: 'vn-claim-detail vn-tr:nth-child(1) vn-input-number[ng-model="saleClaimed.quantity"] input',
- totalClaimed: 'vn-claim-detail > vn-vertical > vn-card > div > vn-vertical > vn-horizontal > div > vn-label-value:nth-child(2) > section > span',
- secondItemDeleteButton: 'vn-claim-detail > vn-vertical > vn-card > div > vn-vertical > vn-table > div > vn-tbody > vn-tr:nth-child(2) > vn-td:nth-child(8) > vn-icon-button > button > vn-icon > i'
+ totalClaimed: 'vn-claim-detail > vn-vertical > vn-card > vn-vertical > vn-horizontal > div > vn-label-value:nth-child(2) > section > span',
+ secondItemDeleteButton: 'vn-claim-detail > vn-vertical > vn-card > vn-vertical > vn-table > div > vn-tbody > vn-tr:nth-child(2) > vn-td:nth-child(8) > vn-icon-button > button > vn-icon > i'
},
claimDevelopment: {
- addDevelopmentButton: 'vn-claim-development > vn-vertical > vn-card > div > vn-vertical > vn-one > vn-icon-button > button > vn-icon',
- firstDeleteDevelopmentButton: 'vn-claim-development > vn-vertical > vn-card > div > vn-vertical > form > vn-horizontal:nth-child(2) > vn-icon-button > button > vn-icon',
+ addDevelopmentButton: 'vn-claim-development > vn-vertical > vn-card > vn-vertical > vn-one > vn-icon-button > button > vn-icon',
+ firstDeleteDevelopmentButton: 'vn-claim-development > vn-vertical > vn-card > vn-vertical > form > vn-horizontal:nth-child(2) > vn-icon-button > button > vn-icon',
firstClaimReasonAutocomplete: 'vn-claim-development vn-horizontal:nth-child(1) vn-autocomplete[ng-model="claimDevelopment.claimReasonFk"]',
firstClaimResultAutocomplete: 'vn-claim-development vn-horizontal:nth-child(1) vn-autocomplete[ng-model="claimDevelopment.claimResultFk"]',
firstClaimResponsibleAutocomplete: 'vn-claim-development vn-horizontal:nth-child(1) vn-autocomplete[ng-model="claimDevelopment.claimResponsibleFk"]',
@@ -580,7 +580,7 @@ export default {
isPaidWithManaCheckbox: 'vn-check[ng-model="$ctrl.claim.isChargedToMana"]'
},
ordersIndex: {
- searchResult: 'vn-order-index vn-card > div > vn-table > div > vn-tbody > a.vn-tr',
+ searchResult: 'vn-order-index vn-card > vn-table > div > vn-tbody > a.vn-tr',
searchResultDate: 'vn-order-index vn-table vn-tbody > a:nth-child(1) > vn-td:nth-child(4)',
searchResultAddress: 'vn-order-index vn-table vn-tbody > a:nth-child(1) > vn-td:nth-child(6)',
searchOrderInput: `vn-order-index vn-textfield input`,
@@ -641,7 +641,7 @@ export default {
volume: 'vn-route-descriptor vn-label-value[label="Volume"] > section > span'
},
routeSummary: {
- routeId: 'vn-route-summary > vn-card > div > vn-horizontal > vn-one:nth-child(1) > vn-label-value:nth-child(1) > section > span'
+ routeId: 'vn-route-summary > vn-card > vn-horizontal > vn-one:nth-child(1) > vn-label-value:nth-child(1) > section > span'
},
routeBasicData: {
workerAutoComplete: 'vn-route-basic-data vn-autocomplete[ng-model="$ctrl.route.workerFk"]',
@@ -671,57 +671,57 @@ export default {
},
workerTimeControl: {
timeDialogInput: '.vn-dialog.shown [ng-model="$ctrl.newTime"]',
- mondayAddTimeButton: 'vn-worker-time-control > div > vn-card > div > vn-horizontal > vn-table > div > vn-tfoot > vn-tr:nth-child(2) > vn-td:nth-child(1) > vn-icon-button > button > vn-icon',
- tuesdayAddTimeButton: 'vn-worker-time-control > div > vn-card > div > vn-horizontal > vn-table > div > vn-tfoot > vn-tr:nth-child(2) > vn-td:nth-child(2) > vn-icon-button > button > vn-icon',
- wednesdayAddTimeButton: 'vn-worker-time-control > div > vn-card > div > vn-horizontal > vn-table > div > vn-tfoot > vn-tr:nth-child(2) > vn-td:nth-child(3) > vn-icon-button > button > vn-icon',
- thursdayAddTimeButton: 'vn-worker-time-control > div > vn-card > div > vn-horizontal > vn-table > div > vn-tfoot > vn-tr:nth-child(2) > vn-td:nth-child(4) > vn-icon-button > button > vn-icon',
- fridayAddTimeButton: 'vn-worker-time-control > div > vn-card > div > vn-horizontal > vn-table > div > vn-tfoot > vn-tr:nth-child(2) > vn-td:nth-child(5) > vn-icon-button > button > vn-icon',
- saturdayAddTimeButton: 'vn-worker-time-control > div > vn-card > div > vn-horizontal > vn-table > div > vn-tfoot > vn-tr:nth-child(2) > vn-td:nth-child(6) > vn-icon-button > button > vn-icon',
- sundayAddTimeButton: 'vn-worker-time-control > div > vn-card > div > vn-horizontal > vn-table > div > vn-tfoot > vn-tr:nth-child(2) > vn-td:nth-child(7) > vn-icon-button > button > vn-icon',
+ mondayAddTimeButton: 'vn-worker-time-control vn-table > div > vn-tfoot > vn-tr:nth-child(2) > vn-td:nth-child(1) > vn-icon-button',
+ tuesdayAddTimeButton: 'vn-worker-time-control vn-table > div > vn-tfoot > vn-tr:nth-child(2) > vn-td:nth-child(2) > vn-icon-button',
+ wednesdayAddTimeButton: 'vn-worker-time-control vn-table > div > vn-tfoot > vn-tr:nth-child(2) > vn-td:nth-child(3) > vn-icon-button',
+ thursdayAddTimeButton: 'vn-worker-time-control vn-table > div > vn-tfoot > vn-tr:nth-child(2) > vn-td:nth-child(4) > vn-icon-button',
+ fridayAddTimeButton: 'vn-worker-time-control vn-table > div > vn-tfoot > vn-tr:nth-child(2) > vn-td:nth-child(5) > vn-icon-button',
+ saturdayAddTimeButton: 'vn-worker-time-control vn-table > div > vn-tfoot > vn-tr:nth-child(2) > vn-td:nth-child(6) > vn-icon-button',
+ sundayAddTimeButton: 'vn-worker-time-control vn-table > div > vn-tfoot > vn-tr:nth-child(2) > vn-td:nth-child(7) > vn-icon-button',
confirmButton: 'vn-worker-time-control > vn-dialog > div > form > div.buttons > tpl-buttons > button',
- firstEntryOfMonday: 'vn-worker-time-control > div > vn-card > div > vn-horizontal > vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(1) > section:nth-child(1) > span',
- firstEntryOfTuesday: 'vn-worker-time-control > div > vn-card > div > vn-horizontal > vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(2) > section:nth-child(1) > span',
- firstEntryOfWednesday: 'vn-worker-time-control > div > vn-card > div > vn-horizontal > vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(3) > section:nth-child(1) > span',
- firstEntryOfThursday: 'vn-worker-time-control > div > vn-card > div > vn-horizontal > vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(4) > section:nth-child(1) > span',
- firstEntryOfFriday: 'vn-worker-time-control > div > vn-card > div > vn-horizontal > vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(5) > section:nth-child(1) > span',
- firstEntryOfSaturday: 'vn-worker-time-control > div > vn-card > div > vn-horizontal > vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(6) > section:nth-child(1) > span',
- firstEntryOfSunday: 'vn-worker-time-control > div > vn-card > div > vn-horizontal > vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(7) > section:nth-child(1) > span',
- secondEntryOfMonday: 'vn-worker-time-control > div > vn-card > div > vn-horizontal > vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(1) > section:nth-child(2) > span',
- secondEntryOfTuesday: 'vn-worker-time-control > div > vn-card > div > vn-horizontal > vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(2) > section:nth-child(2) > span',
- secondEntryOfWednesday: 'vn-worker-time-control > div > vn-card > div > vn-horizontal > vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(3) > section:nth-child(2) > span',
- secondEntryOfThursday: 'vn-worker-time-control > div > vn-card > div > vn-horizontal > vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(4) > section:nth-child(2) > span',
- secondEntryOfFriday: 'vn-worker-time-control > div > vn-card > div > vn-horizontal > vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(5) > section:nth-child(2) > span',
- secondEntryOfSaturday: 'vn-worker-time-control > div > vn-card > div > vn-horizontal > vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(6) > section:nth-child(2) > span',
- secondEntryOfSunday: 'vn-worker-time-control > div > vn-card > div > vn-horizontal > vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(7) > section:nth-child(2) > span',
- thirdEntryOfMonday: 'vn-worker-time-control > div > vn-card > div > vn-horizontal > vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(1) > section:nth-child(3) > span',
- thirdEntryOfTuesday: 'vn-worker-time-control > div > vn-card > div > vn-horizontal > vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(2) > section:nth-child(3) > span',
- thirdEntryOfWednesday: 'vn-worker-time-control > div > vn-card > div > vn-horizontal > vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(3) > section:nth-child(3) > span',
- thirdEntryOfThursday: 'vn-worker-time-control > div > vn-card > div > vn-horizontal > vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(4) > section:nth-child(3) > span',
- thirdEntryOfFriday: 'vn-worker-time-control > div > vn-card > div > vn-horizontal > vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(5) > section:nth-child(3) > span',
- thirdEntryOfSaturday: 'vn-worker-time-control > div > vn-card > div > vn-horizontal > vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(6) > section:nth-child(3) > span',
- thirdEntryOfSunday: 'vn-worker-time-control > div > vn-card > div > vn-horizontal > vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(7) > section:nth-child(3) > span',
- fourthEntryOfMonday: 'vn-worker-time-control > div > vn-card > div > vn-horizontal > vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(1) > section:nth-child(4) > span',
- fourthEntryOfTuesday: 'vn-worker-time-control > div > vn-card > div > vn-horizontal > vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(2) > section:nth-child(4) > span',
- fourthEntryOfWednesday: 'vn-worker-time-control > div > vn-card > div > vn-horizontal > vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(3) > section:nth-child(4) > span',
- fourthEntryOfThursday: 'vn-worker-time-control > div > vn-card > div > vn-horizontal > vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(4) > section:nth-child(4) > span',
- fourthEntryOfFriday: 'vn-worker-time-control > div > vn-card > div > vn-horizontal > vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(5) > section:nth-child(4) > span',
- fourthEntryOfSaturday: 'vn-worker-time-control > div > vn-card > div > vn-horizontal > vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(6) > section:nth-child(4) > span',
- fourthEntryOfSunday: 'vn-worker-time-control > div > vn-card > div > vn-horizontal > vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(7) > section:nth-child(4) > span',
- mondayWorkedHours: 'vn-worker-time-control > div > vn-card > div > vn-horizontal > vn-table > div > vn-tfoot > vn-tr:nth-child(1) > vn-td:nth-child(1)',
- tuesdayWorkedHours: 'vn-worker-time-control > div > vn-card > div > vn-horizontal > vn-table > div > vn-tfoot > vn-tr:nth-child(1) > vn-td:nth-child(2)',
- wednesdayWorkedHours: 'vn-worker-time-control > div > vn-card > div > vn-horizontal > vn-table > div > vn-tfoot > vn-tr:nth-child(1) > vn-td:nth-child(3)',
- thursdayWorkedHours: 'vn-worker-time-control > div > vn-card > div > vn-horizontal > vn-table > div > vn-tfoot > vn-tr:nth-child(1) > vn-td:nth-child(4)',
- fridayWorkedHours: 'vn-worker-time-control > div > vn-card > div > vn-horizontal > vn-table > div > vn-tfoot > vn-tr:nth-child(1) > vn-td:nth-child(5)',
- saturdayWorkedHours: 'vn-worker-time-control > div > vn-card > div > vn-horizontal > vn-table > div > vn-tfoot > vn-tr:nth-child(1) > vn-td:nth-child(6)',
- sundayWorkedHours: 'vn-worker-time-control > div > vn-card > div > vn-horizontal > vn-table > div > vn-tfoot > vn-tr:nth-child(1) > vn-td:nth-child(7)',
- weekWorkedHours: 'vn-worker-time-control > div > vn-side-menu > div > vn-vertical > vn-vertical > vn-label-value > section > span',
- nextMonthButton: 'vn-worker-time-control > div > vn-side-menu > div > vn-calendar > div > vn-horizontal > vn-auto:nth-child(3) > vn-icon',
+ firstEntryOfMonday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(1) > section:nth-child(1) > span',
+ firstEntryOfTuesday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(2) > section:nth-child(1) > span',
+ firstEntryOfWednesday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(3) > section:nth-child(1) > span',
+ firstEntryOfThursday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(4) > section:nth-child(1) > span',
+ firstEntryOfFriday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(5) > section:nth-child(1) > span',
+ firstEntryOfSaturday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(6) > section:nth-child(1) > span',
+ firstEntryOfSunday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(7) > section:nth-child(1) > span',
+ secondEntryOfMonday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(1) > section:nth-child(2) > span',
+ secondEntryOfTuesday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(2) > section:nth-child(2) > span',
+ secondEntryOfWednesday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(3) > section:nth-child(2) > span',
+ secondEntryOfThursday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(4) > section:nth-child(2) > span',
+ secondEntryOfFriday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(5) > section:nth-child(2) > span',
+ secondEntryOfSaturday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(6) > section:nth-child(2) > span',
+ secondEntryOfSunday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(7) > section:nth-child(2) > span',
+ thirdEntryOfMonday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(1) > section:nth-child(3) > span',
+ thirdEntryOfTuesday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(2) > section:nth-child(3) > span',
+ thirdEntryOfWednesday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(3) > section:nth-child(3) > span',
+ thirdEntryOfThursday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(4) > section:nth-child(3) > span',
+ thirdEntryOfFriday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(5) > section:nth-child(3) > span',
+ thirdEntryOfSaturday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(6) > section:nth-child(3) > span',
+ thirdEntryOfSunday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(7) > section:nth-child(3) > span',
+ fourthEntryOfMonday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(1) > section:nth-child(4) > span',
+ fourthEntryOfTuesday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(2) > section:nth-child(4) > span',
+ fourthEntryOfWednesday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(3) > section:nth-child(4) > span',
+ fourthEntryOfThursday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(4) > section:nth-child(4) > span',
+ fourthEntryOfFriday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(5) > section:nth-child(4) > span',
+ fourthEntryOfSaturday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(6) > section:nth-child(4) > span',
+ fourthEntryOfSunday: 'vn-worker-time-control vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(7) > section:nth-child(4) > span',
+ mondayWorkedHours: 'vn-worker-time-control vn-table > div > vn-tfoot > vn-tr:nth-child(1) > vn-td:nth-child(1)',
+ tuesdayWorkedHours: 'vn-worker-time-control vn-table > div > vn-tfoot > vn-tr:nth-child(1) > vn-td:nth-child(2)',
+ wednesdayWorkedHours: 'vn-worker-time-control vn-table > div > vn-tfoot > vn-tr:nth-child(1) > vn-td:nth-child(3)',
+ thursdayWorkedHours: 'vn-worker-time-control vn-table > div > vn-tfoot > vn-tr:nth-child(1) > vn-td:nth-child(4)',
+ fridayWorkedHours: 'vn-worker-time-control vn-table > div > vn-tfoot > vn-tr:nth-child(1) > vn-td:nth-child(5)',
+ saturdayWorkedHours: 'vn-worker-time-control vn-table > div > vn-tfoot > vn-tr:nth-child(1) > vn-td:nth-child(6)',
+ sundayWorkedHours: 'vn-worker-time-control vn-table > div > vn-tfoot > vn-tr:nth-child(1) > vn-td:nth-child(7)',
+ weekWorkedHours: 'vn-worker-time-control vn-side-menu vn-label-value > section > span',
+ nextMonthButton: 'vn-worker-time-control vn-side-menu vn-calendar vn-button[icon=keyboard_arrow_right]',
navigateBackToIndex: 'vn-worker-descriptor vn-icon[icon="chevron_left"]'
},
invoiceOutIndex: {
searchInvoiceOutInput: `vn-invoice-out-index vn-textfield input`,
searchButton: 'vn-invoice-out-index vn-searchbar vn-icon[icon="search"]',
- searchResult: 'vn-invoice-out-index vn-card > div > vn-table > div > vn-tbody > a.vn-tr',
+ searchResult: 'vn-invoice-out-index vn-card > vn-table > div > vn-tbody > a.vn-tr',
},
invoiceOutDescriptor: {
moreMenu: 'vn-invoice-out-descriptor vn-icon-menu[icon=more_vert]',
@@ -732,6 +732,6 @@ export default {
acceptBookingButton: 'vn-invoice-out-descriptor > vn-confirm[vn-id="bookConfirmation"] button[response="ACCEPT"]'
},
invoiceOutSummary: {
- bookedLabel: 'vn-invoice-out-summary > vn-card > div > vn-horizontal > vn-one > vn-label-value:nth-child(4) > section > span'
+ bookedLabel: 'vn-invoice-out-summary > vn-card > vn-horizontal > vn-one > vn-label-value:nth-child(4) > section > span'
}
};
diff --git a/front/core/components/calendar/index.html b/front/core/components/calendar/index.html
index b2fc023ae..0efff2492 100644
--- a/front/core/components/calendar/index.html
+++ b/front/core/components/calendar/index.html
@@ -1,82 +1,46 @@
-
-
\ No newline at end of file
+
+
\ No newline at end of file
diff --git a/front/salix/components/main-menu/style.scss b/front/salix/components/main-menu/style.scss
index 68744aad6..cd38472ab 100644
--- a/front/salix/components/main-menu/style.scss
+++ b/front/salix/components/main-menu/style.scss
@@ -18,6 +18,9 @@ vn-main-menu {
vertical-align: middle;
font-weight: bold;
margin-right: .2em;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ overflow: hidden;
cursor: pointer;
}
& > .vn-button {
diff --git a/front/salix/components/summary/style.scss b/front/salix/components/summary/style.scss
index 558b9b758..fbab066f8 100644
--- a/front/salix/components/summary/style.scss
+++ b/front/salix/components/summary/style.scss
@@ -4,50 +4,48 @@
margin: 0 auto;
max-width: 950px;
- & > div {
- & > h5 {
- padding: $spacing-sm;
- border: none;
- background: $color-main;
- color: $color-font-dark;
- margin: 0;
- text-align: center;
- line-height: 1.3em;
+ & > h5 {
+ padding: $spacing-sm;
+ border: none;
+ background: $color-main;
+ color: $color-font-dark;
+ margin: 0;
+ text-align: center;
+ line-height: 1.3em;
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ }
+ & > vn-horizontal {
+ flex-wrap: wrap;
+ padding: $spacing-md;
+ overflow: hidden;
+ align-items: flex-start;
+
+ h4 {
+ margin-bottom: $spacing-md;
+ text-transform: uppercase;
+ font-size: 15pt;
+ line-height: 1;
+ padding: 7px;
+ padding-bottom: 4px; /* Bottom line-height fix */
+ font-weight: lighter;
+ background-color: $color-main-light;
+ border-bottom: .1em solid $color-main;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
- & > vn-horizontal {
- flex-wrap: wrap;
- padding: $spacing-md;
- overflow: hidden;
- align-items: flex-start;
-
- h4 {
- margin-bottom: $spacing-md;
- text-transform: uppercase;
- font-size: 15pt;
- line-height: 1;
- padding: 7px;
- padding-bottom: 4px; /* Bottom line-height fix */
- font-weight: lighter;
- background-color: $color-main-light;
- border-bottom: .1em solid $color-main;
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
- }
- & > * {
- margin: $spacing-sm;
- min-width: 14em;
- padding: 0;
- }
- & > vn-auto {
- width: 100%;
- }
- vn-label-value > section {
- margin-bottom: .3em;
- }
+ & > * {
+ margin: $spacing-sm;
+ min-width: 14em;
+ padding: 0;
+ }
+ & > vn-auto {
+ width: 100%;
+ }
+ vn-label-value > section {
+ margin-bottom: .3em;
}
}
p:after {
diff --git a/front/salix/styles/misc.scss b/front/salix/styles/misc.scss
index 0983264bc..82f4615c9 100644
--- a/front/salix/styles/misc.scss
+++ b/front/salix/styles/misc.scss
@@ -61,11 +61,11 @@ vn-bg-title {
}
.totalBox {
border: 1px solid #CCC;
- text-align: right !important;
+ text-align: right;
justify-content: center;
align-items: center;
- padding: 18px;
- max-width: 12em;
+ padding: $spacing-md;
+ max-width: 14em;
}
.form {
height: 100%;
diff --git a/front/salix/styles/order-product.scss b/front/salix/styles/order-product.scss
index 9c44b30eb..df14f5558 100644
--- a/front/salix/styles/order-product.scss
+++ b/front/salix/styles/order-product.scss
@@ -11,7 +11,7 @@
width: 28em;
overflow: hidden;
- & > vn-card > div {
+ & > vn-card {
display: flex;
height: 12em;
diff --git a/modules/agency/front/calendar/index.html b/modules/agency/front/calendar/index.html
index 6b0714734..9a5f97269 100644
--- a/modules/agency/front/calendar/index.html
+++ b/modules/agency/front/calendar/index.html
@@ -1,22 +1,28 @@
-
-
-
-
\ No newline at end of file
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/modules/agency/front/calendar/index.js b/modules/agency/front/calendar/index.js
index 74588d9ef..00c6a7dff 100644
--- a/modules/agency/front/calendar/index.js
+++ b/modules/agency/front/calendar/index.js
@@ -5,96 +5,151 @@ import './style.scss';
class Controller extends Section {
constructor($el, $, $t, $http, $state) {
super($el, $, $t, $http, $state);
+ this.nMonths = 4;
- this.excls = {};
- this.resetEvents();
- this.ndMonthDate = new Date();
- this.ndMonthDate.setMonth(this.ndMonthDate.getMonth() + 1);
+ let date = new Date();
+ date.setDate(1);
+ date.setHours(0, 0, 0, 0);
+ this.date = date;
+ }
+
+ get date() {
+ return this._date;
+ }
+
+ set date(value) {
+ this._date = value;
+ let stamp = value.getTime();
+
+ let firstDay = new Date(stamp);
+ firstDay.setDate(1);
+ this.firstDay = firstDay;
+
+ let lastDay = new Date(stamp);
+ lastDay.setMonth(lastDay.getMonth() + this.nMonths);
+ lastDay.setDate(0);
+ this.lastDay = lastDay;
+
+ this.months = [];
+ for (let i = 0; i < this.nMonths; i++) {
+ let monthDate = new Date(stamp);
+ monthDate.setMonth(value.getMonth() + i);
+ this.months.push(monthDate);
+ }
+
+ this.refreshEvents();
+ }
+
+ step(direction) {
+ let date = new Date(this.date.getTime());
+ date.setMonth(date.getMonth() + (this.nMonths * direction));
+ this.date = date;
+ }
+
+ get data() {
+ return this._data;
+ }
+
+ set data(value) {
+ this._data = value;
+
+ value = value || {};
+ this.events = value.events;
+ this.exclusions = value.exclusions;
+
+ if (this.events) {
+ let codes = ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'];
+ for (event of this.events) {
+ if (!event.weekDays) continue;
+ let weekDays = event.weekDays.split(',');
+ event.wdays = [];
+ for (let wday of weekDays) {
+ let index = codes.indexOf(wday);
+ if (index !== -1) event.wdays[index] = true;
+ }
+ }
+ }
+
+ this.refreshEvents();
+
+ let calendars = this.element.querySelectorAll('vn-calendar');
+ for (let calendar of calendars)
+ calendar.$ctrl.repaint();
+ }
+
+ refreshEvents() {
+ function getDate(date) {
+ return date && new Date(date).setHours(0, 0, 0, 0);
+ }
+
+ let exclusionsMap = {};
+ if (this.exclusions) {
+ for (let exclusion of this.exclusions)
+ exclusionsMap[getDate(exclusion.day)] = exclusion;
+ }
+
+ this.days = {};
+ let day = new Date(this.firstDay.getTime());
+
+ while (day < this.lastDay) {
+ let stamp = day.getTime();
+ let wday = day.getDay();
+ let dayEvents = [];
+
+ if (this.events) {
+ for (let event of this.events) {
+ let match;
+ let from = getDate(event.from);
+ let to = getDate(event.to);
+
+ if (event.from && event.to) {
+ match = stamp >= from && stamp <= to
+ && event.wdays[wday];
+ } else if (event.from)
+ match = from == stamp;
+ else
+ match = event.wdays[wday];
+
+ if (match)
+ dayEvents.push(event);
+ }
+ }
+
+ let exclusion = exclusionsMap[stamp];
+
+ if (dayEvents.length || exclusion) {
+ let dayData = {};
+ if (dayEvents.length) dayData.events = dayEvents;
+ if (exclusion) dayData.exclusion = exclusion;
+ this.days[stamp] = dayData;
+ }
+
+ day.setDate(day.getDate() + 1);
+ }
}
onSelection($days, $type, $weekday) {
- this.emit('selection', {$days, $type, $weekday});
- }
-
- resetEvents() {
- this.wdays = [];
- this.days = {};
- this.ranges = [];
- }
-
- get events() {
- return this._events;
- }
-
- set events(value) {
- this._events = value;
- this.resetEvents();
- if (!value) return;
-
- function setWdays(wdays, weekDays) {
- let codes = ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'];
- if (!weekDays) return [];
- weekDays = weekDays.split(',');
- for (let wday of weekDays)
- wdays[codes.indexOf(wday)] = true;
- return wdays;
+ let $data = [];
+ for (let day of $days) {
+ let dayData = this.days[day.getTime()];
+ if (dayData) $data.push(dayData);
}
- for (let event of value) {
- if (event.from && event.to) {
- this.ranges.push({
- from: new Date(event.from).setHours(0, 0, 0, 0),
- to: new Date(event.to).setHours(0, 0, 0, 0),
- wdays: setWdays([], event.weekDays)
- });
- } else if (event.from) {
- let day = new Date(event.from).setHours(0, 0, 0, 0);
- this.days[day] = true;
- } else
- setWdays(this.wdays, event.weekDays);
- }
-
- this.repaint();
- }
-
- get exclusions() {
- return this._exclusions;
- }
-
- set exclusions(value) {
- this._exclusions = value;
- this.excls = {};
- if (!value) return;
-
- value.forEach(exclusion => {
- let day = new Date(exclusion.day).setHours(0, 0, 0, 0);
- this.excls[day] = true;
+ this.emit('selection', {
+ $days,
+ $type,
+ $weekday,
+ $data
});
-
- this.repaint();
- }
-
- hasRange(time, wday) {
- let range = this.ranges.find(e => e.from <= time && e.to >= time);
- return range && range.wdays[wday];
}
hasEvents(day) {
- let time = day.getTime();
- let wday = day.getDay();
- return this.wdays[wday]
- || this.days[time]
- || this.hasRange(time, wday);
+ return this.days[day.getTime()] != null;
}
getClass(day) {
- if (this.excls[day.getTime()])
- return 'excluded';
- }
-
- repaint() {
- this.$.stMonth.repaint();
- this.$.ndMonth.repaint();
+ let dayData = this.days[day.getTime()];
+ return dayData && dayData.exclusion ? 'excluded' : '';
}
}
@@ -102,7 +157,6 @@ ngModule.component('vnZoneCalendar', {
template: require('./index.html'),
controller: Controller,
bindings: {
- events: '',
- exclusions: ''
+ data: ''
}
});
diff --git a/modules/agency/front/calendar/style.scss b/modules/agency/front/calendar/style.scss
index caae88ea7..f48c7d6b6 100644
--- a/modules/agency/front/calendar/style.scss
+++ b/modules/agency/front/calendar/style.scss
@@ -1,13 +1,40 @@
@import "variables";
vn-zone-calendar {
- vn-calendar .day {
- &.primary .day-number {
- background-color: $color-success;
+ display: block;
+
+ & > vn-card {
+ & > .header {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ background-color: $color-main;
+ color: white;
+ font-weight: bold;
+ height: 45px;
+
+ & > .vn-button {
+ color: inherit;
+ height: 100%;
+ }
}
- &.excluded .day-number {
- background-color: $color-alert;
- color: $color-font-dark;
+ & > .calendars {
+ display: flex;
+ flex-wrap: wrap;
+ justify-content: space-evenly;
+
+ & > vn-calendar {
+ max-width: 18em;
+
+ .day {
+ &.event .day-number {
+ background-color: $color-success;
+ }
+ &.excluded .day-number {
+ background-color: $color-alert;
+ }
+ }
+ }
}
}
}
\ No newline at end of file
diff --git a/modules/agency/front/delivery-days/index.html b/modules/agency/front/delivery-days/index.html
index 6d5b3a42b..af71f75d0 100644
--- a/modules/agency/front/delivery-days/index.html
+++ b/modules/agency/front/delivery-days/index.html
@@ -1,47 +1,43 @@
-
+
diff --git a/modules/agency/front/delivery-days/index.js b/modules/agency/front/delivery-days/index.js
index cc3302ecc..12e0c4b30 100644
--- a/modules/agency/front/delivery-days/index.js
+++ b/modules/agency/front/delivery-days/index.js
@@ -11,7 +11,7 @@ class Controller {
onSubmit() {
this.$http.get(`/api/Zones/getEvents`, {params: this.params})
- .then(res => this.$.events = res.data);
+ .then(res => this.$.data = res.data);
}
}
Controller.$inject = ['$scope', '$http'];
diff --git a/modules/agency/front/events/index.html b/modules/agency/front/events/index.html
index 91864dc7c..a72045555 100644
--- a/modules/agency/front/events/index.html
+++ b/modules/agency/front/events/index.html
@@ -1,27 +1,60 @@
-
+
+
+
+
+
+ Edit mode
+
+
+
+
+
+
+
+
+
+ Events
+
+
-
-
-
-
-
-
- {{wday.abr}}
-
-
+ ng-model="$ctrl.selected.wdays">
+
-
-
+
+
+
+
this.$.exclusions = res.data);
-
- this.path = `/api/Zones/${this.$stateParams.id}/events`;
+ this.path = `api/Zones/${this.$stateParams.id}/events`;
+ this.exclusionsPath = `api/Zones/${this.$stateParams.id}/exclusions`;
this.refresh();
}
refresh() {
- this.$http.get(this.path)
- .then(res => this.$.data = res.data);
+ let data = {};
+ this.$q.all([
+ this.$http.get(this.path)
+ .then(res => data.events = res.data),
+ this.$http.get(this.exclusionsPath)
+ .then(res => data.exclusions = res.data)
+ ]).finally(() => {
+ this.$.data = data;
+ });
}
formatWdays(weekDays) {
@@ -55,16 +30,43 @@ class Controller extends Section {
let abrWdays = [];
for (let wday of weekDays.split(','))
- abrWdays.push(this.abrWdays[wday]);
+ abrWdays.push(this.vnWeekDays.map[wday].localeAbr);
return abrWdays.length < 7
? abrWdays.join(', ')
: this._('Everyday');
}
- onEdit(row, event) {
- if (event.defaultPrevented) return;
+ onSelection(days, type, weekday, data) {
+ if (this.editMode == 'include') {
+ let dayData = data[0] || {};
+ let event = dayData.events && dayData.events[0];
+ if (event)
+ this.edit(event);
+ else
+ this.create(days, type, weekday);
+ } else {
+ let exclusions = [];
+ for (let dayData of data) {
+ if (dayData.exclusion)
+ exclusions.push(dayData.exclusion.id);
+ }
+
+ if (exclusions.length)
+ this.exclusionDelete(exclusions);
+ else
+ this.exclusionCreate(days);
+ }
+ }
+
+ onEditClick(row, event) {
+ if (event.defaultPrevented) return;
+ event.preventDefault();
+ this.edit(row);
+ }
+
+ edit(row) {
this.isNew = false;
if (row.from && !row.to)
@@ -86,67 +88,74 @@ class Controller extends Section {
this.$.dialog.show();
}
- onCreate($day, $type, $weekday) {
+ create(days, type, weekday) {
this.isNew = true;
- this.eventType = $type == 'day' ? 'day' : 'indefinitely';
+ this.eventType = type == 'day' ? 'day' : 'indefinitely';
- if ($type == 'weekday') {
+ if (type == 'weekday') {
let wdays = [];
- let index = $weekday - 1;
- if (index < 0) index = 7 - index;
- wdays[this.wdays[index].code] = true;
+ let code = this.vnWeekDays.days[weekday].code;
+ wdays[code] = true;
this.selected = {wdays};
} else
- this.selected = {from: $day[0]};
+ this.selected = {from: days[0]};
this.$.dialog.show();
}
onSave(response) {
- if (response != 'ACCEPT') return;
+ if (response == 'ACCEPT') {
+ let selected = this.selected;
- let selected = this.selected;
-
- if (this.eventType == 'indefinitely') {
- selected.from = null;
- selected.to = null;
- }
-
- if (this.eventType != 'day') {
- let weekDays = [];
-
- for (let wday in selected.wdays) {
- if (selected.wdays[wday])
- weekDays.push(wday);
+ if (this.eventType == 'indefinitely') {
+ selected.from = null;
+ selected.to = null;
}
- selected.weekDays = weekDays.join(',');
- } else {
- selected.to = null;
- selected.weekDays = '';
+ if (this.eventType != 'day') {
+ let weekDays = [];
+
+ for (let wday in selected.wdays) {
+ if (selected.wdays[wday])
+ weekDays.push(wday);
+ }
+
+ selected.weekDays = weekDays.join(',');
+ } else {
+ selected.to = null;
+ selected.weekDays = '';
+ }
+
+ let req;
+
+ if (this.isNew)
+ req = this.$http.post(this.path, selected);
+ else
+ req = this.$http.put(`${this.path}/${selected.id}`, selected);
+
+ 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;
}
-
- let req;
-
- if (this.isNew)
- req = this.$http.post(this.path, selected);
- else
- req = this.$http.put(`${this.path}/${selected.id}`, selected);
-
- req.then(() => {
- this.selected = null;
- this.isNew = null;
- this.$.dialog.hide();
- this.refresh();
- });
-
- return false;
}
- onDelete(id, event) {
+ onDeleteClick(id, event) {
+ if (event.defaultPrevented) return;
event.preventDefault();
- this.$.confirm.show();
+ this.onDelete(id);
+ }
+
+ onDelete(id) {
this.deleteId = id;
+ this.$.confirm.show();
}
delete(response) {
@@ -156,9 +165,33 @@ class Controller extends Section {
.then(() => {
this.refresh();
this.deleteId = null;
+ this.$.dialog.hide();
});
}
+
+ exclusionCreate(days) {
+ let exclusions = days.map(day => {
+ return {day};
+ });
+
+ this.$http.post(this.exclusionsPath, exclusions)
+ .then(() => this.refresh());
+ }
+
+ exclusionDelete(ids) {
+ let promises = [];
+
+ for (let id of ids) {
+ promises.push(
+ this.$http.delete(`${this.exclusionsPath}/${id}`)
+ );
+ }
+
+ this.$q.all(promises)
+ .then(() => this.refresh());
+ }
}
+Controller.$inject = ['$element', '$scope', '$translate', '$http', '$state', '$q', 'vnWeekDays'];
ngModule.component('vnZoneEvents', {
template: require('./index.html'),
diff --git a/modules/agency/front/events/locale/es.yml b/modules/agency/front/events/locale/es.yml
new file mode 100644
index 000000000..eb0894c63
--- /dev/null
+++ b/modules/agency/front/events/locale/es.yml
@@ -0,0 +1,4 @@
+Edit mode: Modo de edición
+Include: Incluir
+Exclude: Excluir
+Events: Eventos
\ No newline at end of file
diff --git a/modules/agency/front/events/style.scss b/modules/agency/front/events/style.scss
deleted file mode 100644
index 4e14aa75c..000000000
--- a/modules/agency/front/events/style.scss
+++ /dev/null
@@ -1,28 +0,0 @@
-@import "effects";
-
-vn-zone-events {
- .week-days {
- margin-top: $spacing-sm;
- margin-bottom: $spacing-md;
- text-align: center;
-
- & > span {
- @extend %clickable;
- border-radius: 50%;
- padding: .4em;
- margin: .2em;
- display: inline-flex;
- width: 1.5em;
- height: 1.5em;
- justify-content: center;
- align-items: center;
- outline: none;
- background-color: rgba(0, 0, 0, .05);
-
- &.marked {
- background: $color-main;
- color: $color-font-dark;
- }
- }
- }
-}
\ No newline at end of file
diff --git a/modules/agency/front/exclusions/index.html b/modules/agency/front/exclusions/index.html
deleted file mode 100644
index d6e20d060..000000000
--- a/modules/agency/front/exclusions/index.html
+++ /dev/null
@@ -1,30 +0,0 @@
-
-
-
-
-
-
- {{::row.day | date:'dd/MM/yyyy'}}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/modules/agency/front/exclusions/index.js b/modules/agency/front/exclusions/index.js
deleted file mode 100644
index 133882671..000000000
--- a/modules/agency/front/exclusions/index.js
+++ /dev/null
@@ -1,35 +0,0 @@
-import ngModule from '../module';
-import Section from 'core/lib/section';
-
-class Controller extends Section {
- constructor($el, $, $t, $http, $state) {
- super($el, $, $t, $http, $state);
-
- this.$http.get(`/api/Zones/${this.$stateParams.id}/events`)
- .then(res => this.$.events = res.data);
-
- this.path = `/api/Zones/${this.$stateParams.id}/exclusions`;
- this.refresh();
- }
-
- refresh() {
- this.$http.get(this.path)
- .then(res => this.$.data = res.data);
- }
-
- onCreate($days) {
- this.$http.post(this.path, {day: $days[0]})
- .then(() => this.refresh());
- }
-
- onDelete(id) {
- if (!id) return;
- this.$http.delete(`${this.path}/${id}`)
- .then(() => this.refresh());
- }
-}
-
-ngModule.component('vnZoneExclusions', {
- template: require('./index.html'),
- controller: Controller
-});
diff --git a/modules/agency/front/index.js b/modules/agency/front/index.js
index e182ad061..556ec58ad 100644
--- a/modules/agency/front/index.js
+++ b/modules/agency/front/index.js
@@ -12,6 +12,5 @@ import './basic-data';
import './warehouses';
import './events';
import './calendar';
-import './exclusions';
import './location';
import './calendar';
diff --git a/modules/agency/front/routes.json b/modules/agency/front/routes.json
index 534281595..26d619172 100644
--- a/modules/agency/front/routes.json
+++ b/modules/agency/front/routes.json
@@ -8,8 +8,7 @@
{"state": "zone.card.basicData", "icon": "settings"},
{"state": "zone.card.location", "icon": "my_location"},
{"state": "zone.card.warehouses", "icon": "home"},
- {"state": "zone.card.events", "icon": "today"},
- {"state": "zone.card.exclusions", "icon": "block"}
+ {"state": "zone.card.events", "icon": "today"}
],
"routes": [
{
@@ -65,11 +64,6 @@
"state": "zone.card.events",
"component": "vn-zone-events",
"description": "Calendar"
- }, {
- "url": "/exclusions",
- "state": "zone.card.exclusions",
- "component": "vn-zone-exclusions",
- "description": "Exclusions"
}, {
"url": "/location?q",
"state": "zone.card.location",
diff --git a/modules/worker/front/calendar/index.html b/modules/worker/front/calendar/index.html
index a8225981f..cbebb18ed 100644
--- a/modules/worker/front/calendar/index.html
+++ b/modules/worker/front/calendar/index.html
@@ -1,36 +1,39 @@
+ url="api/AbsenceTypes"
+ data="absenceTypes"
+ auto-load="true">
-
-
-
-
-
-
-
-
- Holidays
-
- {{'Used' | translate}} {{$ctrl.calendar.holidaysEnjoyed}}
- {{'of' | translate}} {{$ctrl.calendar.totalHolidays}} {{'days' | translate}}
-
-
+
+
+
+
+
+
+
+
+
+
+
Holidays
-
-
-
- {{legend.name}}
-
+ {{'Used' | translate}} {{$ctrl.calendar.holidaysEnjoyed}}
+ {{'of' | translate}} {{$ctrl.calendar.totalHolidays}} {{'days' | translate}}
-
-
-
\ No newline at end of file
+
+
+
+
+
+ {{absenceType.name}}
+
+
+
+
\ No newline at end of file
diff --git a/modules/worker/front/calendar/index.js b/modules/worker/front/calendar/index.js
index d1b042619..a25a4a113 100644
--- a/modules/worker/front/calendar/index.js
+++ b/modules/worker/front/calendar/index.js
@@ -2,11 +2,39 @@ import ngModule from '../module';
import './style.scss';
class Controller {
- constructor($scope, $http) {
- this.$scope = $scope;
+ constructor($element, $http) {
+ this.element = $element[0];
this.$http = $http;
- this.months = this.monthsOfYear();
- this.events = [];
+ this.date = new Date();
+ this.events = {};
+ }
+
+ get date() {
+ return this._date;
+ }
+
+ set date(value) {
+ this._date = value;
+ value.setHours(0, 0, 0, 0);
+
+ const started = new Date(value.getTime());
+ started.setMonth(0);
+ started.setDate(1);
+ this.started = started;
+
+ const ended = new Date(value.getTime());
+ ended.setMonth(12);
+ ended.setDate(0);
+ this.ended = ended;
+
+ this.months = new Array(12);
+
+ for (let i = 0; i < this.months.length; i++) {
+ const now = new Date(value.getTime());
+ now.setDate(1);
+ now.setMonth(i);
+ this.months[i] = now;
+ }
}
get worker() {
@@ -15,118 +43,67 @@ class Controller {
set worker(value) {
this._worker = value;
-
if (!value) return;
- let params = {params: {
+ let params = {
workerFk: this.worker.id,
started: this.started,
ended: this.ended
- }};
-
- let query = `/worker/api/WorkerCalendars/absences`;
- this.$http.get(query, params).then(res => {
- if (!res.data) return;
-
- this.setHolidays(res.data);
- this.setWorkerCalendar(res.data);
- this.calendar = res.data.calendar;
- });
+ };
+ this.$http.get(`api/WorkerCalendars/absences`, {params})
+ .then(res => this.onData(res.data));
}
- setHolidays(data) {
- if (!data.holidays) return;
+ onData(data) {
+ this.events = {};
+ this.calendar = data.calendar;
- const holidays = data.holidays;
- const events = [];
- holidays.forEach(holiday => {
- const holidayDetail = holiday.detail && holiday.detail.description;
- const holidayType = holiday.type && holiday.type.name;
- const holidayName = holidayDetail || holidayType;
+ let addEvent = (day, event) => {
+ this.events[new Date(day).getTime()] = event;
+ };
- events.push({
- name: holidayName,
- description: holidayName,
- dated: holiday.dated,
- isRemovable: false,
- style: {backgroundColor: '#FFFF00'}
- });
- });
- this.events = this.events.concat(events);
- }
+ if (data.holidays) {
+ data.holidays.forEach(holiday => {
+ const holidayDetail = holiday.detail && holiday.detail.description;
+ const holidayType = holiday.type && holiday.type.name;
+ const holidayName = holidayDetail || holidayType;
- setWorkerCalendar(data) {
- if (!data.absences) return;
-
- const absences = data.absences;
- const events = [];
- absences.forEach(absence => {
- const absenceType = absence.absenceType;
- events.push({
- name: absenceType.name,
- description: absenceType.name,
- dated: absence.dated,
- style: {backgroundColor: absenceType.rgb}
- });
- });
- this.events = this.events.concat(events);
- }
-
- get started() {
- const started = new Date();
- started.setHours(0, 0, 0, 0);
- started.setMonth(0);
- started.setDate(1);
-
- return started;
- }
-
- get ended() {
- const monthIndex = 11;
- const ended = new Date();
- ended.setHours(0, 0, 0, 0);
- ended.setMonth(monthIndex + 1);
- // Last day of previous month (January)
- ended.setDate(0);
-
- return ended;
- }
-
- monthsOfYear() {
- let months = new Array(12);
-
- for (let i = 0; i < months.length; i++) {
- const now = new Date();
- now.setHours(0, 0, 0, 0);
- now.setDate(1);
- now.setMonth(i);
-
- months[i] = now;
- }
-
- return months;
- }
-
- get absenceTypes() {
- return this._absenceTypes;
- }
-
- set absenceTypes(value) {
- if (value) {
- this._absenceTypes = value;
- this.legends = [];
- this._absenceTypes.forEach(absenceType => {
- let legend = {};
- legend.id = absenceType.id;
- legend.color = absenceType.rgb;
- legend.name = absenceType.name;
- this.legends.push(legend);
+ addEvent(holiday.dated, {
+ name: holidayName,
+ color: '#ff0'
+ });
});
}
+ if (data.absences) {
+ data.absences.forEach(absence => {
+ let type = absence.absenceType;
+ addEvent(absence.dated, {
+ name: type.name,
+ color: type.rgb
+ });
+ });
+ }
+
+ this.repaint();
+ }
+
+ repaint() {
+ let calendars = this.element.querySelectorAll('vn-calendar');
+ for (let calendar of calendars)
+ calendar.$ctrl.repaint();
+ }
+
+ formatDay(day, element) {
+ let event = this.events[day.getTime()];
+ if (!event) return;
+
+ let dayNumber = element.firstElementChild;
+ dayNumber.title = event.name;
+ dayNumber.style.backgroundColor = event.color;
+ dayNumber.style.color = 'white';
}
}
-
-Controller.$inject = ['$scope', '$http'];
+Controller.$inject = ['$element', '$http'];
ngModule.component('vnWorkerCalendar', {
template: require('./index.html'),
diff --git a/modules/worker/front/calendar/index.spec.js b/modules/worker/front/calendar/index.spec.js
index 90c50ba01..361c0efbf 100644
--- a/modules/worker/front/calendar/index.spec.js
+++ b/modules/worker/front/calendar/index.spec.js
@@ -2,147 +2,111 @@ import './index';
describe('Worker', () => {
describe('Component vnWorkerCalendar', () => {
- let $componentController;
- let $httpParamSerializer;
let $httpBackend;
let $scope;
+ let $element;
let controller;
+ let year = new Date().getFullYear();
beforeEach(angular.mock.module('worker', $translateProvider => {
$translateProvider.translations('en', {});
}));
- beforeEach(angular.mock.inject((_$componentController_, $rootScope, _$httpBackend_, _$httpParamSerializer_) => {
- $componentController = _$componentController_;
+ beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_) => {
$scope = $rootScope.$new();
$httpBackend = _$httpBackend_;
- $httpParamSerializer = _$httpParamSerializer_;
- controller = $componentController('vnWorkerCalendar', {$scope, $httpBackend});
+ $element = angular.element('');
+ controller = $componentController('vnWorkerCalendar', {$element, $scope});
}));
- describe('started() getter', () => {
- it(`should return first day and month of current year`, () => {
- let started = new Date();
- started.setHours(0, 0, 0, 0);
- started.setMonth(0);
- started.setDate(1);
+ afterEach(() => {
+ $element.remove();
+ $scope.$destroy();
+ });
+ describe('started property', () => {
+ it(`should return first day and month of current year`, () => {
+ let started = new Date(year, 0, 1);
expect(controller.started).toEqual(started);
});
});
- describe('ended() getter', () => {
+ describe('ended property', () => {
it(`should return last day and month of current year`, () => {
- const monthIndex = 11;
- const ended = new Date();
- ended.setHours(0, 0, 0, 0);
- ended.setMonth(monthIndex + 1);
- // Last day of previous month (January)
- ended.setDate(0);
+ let ended = new Date(year, 11, 31);
expect(controller.ended).toEqual(ended);
});
});
- describe('monthsOfYear()', () => {
+ describe('months property', () => {
it(`should return an array of twelve months length`, () => {
- const months = controller.monthsOfYear();
- const ended = new Date();
- ended.setHours(0, 0, 0, 0);
- ended.setMonth(11);
- ended.setDate(1);
+ const ended = new Date(year, 11, 1);
- expect(months.length).toEqual(12);
- expect(months[0]).toEqual(controller.started);
- expect(months[11]).toEqual(ended);
+ expect(controller.months.length).toEqual(12);
+ expect(controller.months[0]).toEqual(controller.started);
+ expect(controller.months[11]).toEqual(ended);
});
});
describe('worker() setter', () => {
- it(`should perform a get query and call setHolidays() and setWorkerCalendar() methods`, () => {
- const worker = {id: 106};
- spyOn(controller, 'setHolidays');
- spyOn(controller, 'setWorkerCalendar');
+ it(`should perform a get query and set the reponse data on the model`, () => {
+ let today = new Date();
- const expectedData = {
- calendar: {},
- absences: {}
- };
- let params = $httpParamSerializer({
- workerFk: worker.id,
- started: controller.started,
- ended: controller.ended
- });
- $httpBackend.when('GET', `/worker/api/WorkerCalendars/absences?${params}`).respond(expectedData);
- $httpBackend.expect('GET', `/worker/api/WorkerCalendars/absences?${params}`);
+ let tomorrow = new Date(today.getTime());
+ tomorrow.setDate(tomorrow.getDate() + 1);
- controller.worker = worker;
+ let yesterday = new Date(today.getTime());
+ yesterday.setDate(yesterday.getDate() - 1);
+ let path = `api/WorkerCalendars/absences`;
+ $httpBackend.whenGET(url => url.startsWith(path))
+ .respond({
+ holidays: [
+ {dated: today, detail: {description: 'New year'}},
+ {dated: tomorrow, detail: {description: 'Easter'}}
+ ],
+ absences: [
+ {dated: today, absenceType: {name: 'Holiday', rgb: '#aaa'}},
+ {dated: yesterday, absenceType: {name: 'Leave', rgb: '#bbb'}}
+ ]
+ });
+
+ controller.worker = {id: 1};
$httpBackend.flush();
- expect(controller.setHolidays).toHaveBeenCalledWith(expectedData);
- expect(controller.setHolidays).toHaveBeenCalledWith(expectedData);
+ let events = controller.events;
+
+ expect(events[today.getTime()].name).toEqual('Holiday');
+ expect(events[tomorrow.getTime()].name).toEqual('Easter');
+ expect(events[yesterday.getTime()].name).toEqual('Leave');
+ expect(events[yesterday.getTime()].color).toEqual('#bbb');
});
});
- describe('setHolidays()', () => {
- it(`should set holidays`, () => {
- const data = {holidays: [
- {dated: new Date(), detail: {description: 'New year'}},
- {dated: new Date(), detail: {description: 'Easter'}}
- ]};
- controller.setHolidays(data);
+ describe('formatDay()', () => {
+ it(`should set the day element style`, () => {
+ let today = new Date();
- expect(controller.events.length).toEqual(2);
- expect(controller.events[0].name).toEqual('New year');
- expect(controller.events[0].isRemovable).toEqual(false);
- });
- });
+ let path = `api/WorkerCalendars/absences`;
+ $httpBackend.whenGET(url => url.startsWith(path))
+ .respond({
+ absences: [
+ {dated: today, absenceType: {name: 'Holiday', rgb: '#000'}}
+ ]
+ });
- describe('setWorkerCalendar()', () => {
- it(`should set absences of differente types`, () => {
- const data = {absences: [
- {dated: new Date(), absenceType: {name: 'Holiday', rgb: '#000'}},
- {dated: new Date(), absenceType: {name: 'Leave', rgb: '#000'}}
- ]};
- controller.setWorkerCalendar(data);
+ controller.worker = {id: 1};
+ $httpBackend.flush();
- expect(controller.events.length).toEqual(2);
- expect(controller.events[0].name).toEqual('Holiday');
- expect(controller.events[0].style).toBeDefined();
- expect(controller.events[1].name).toEqual('Leave');
- expect(controller.events[1].style).toBeDefined();
- });
- });
+ let dayElement = angular.element('')[0];
+ let dayNumber = dayElement.firstElementChild;
- describe('absenceTypes() setter', () => {
- it(`should set the absence types in the controller`, () => {
- const absenceTypes = [
- {id: 1, name: 'Holiday', rgb: '#000'},
- {id: 2, name: 'Leave', rgb: '#000'}
- ];
+ controller.formatDay(today, dayElement);
- expect(controller._absenceTypes).not.toBeDefined();
-
- controller.absenceTypes = absenceTypes;
-
- expect(controller._absenceTypes.length).toEqual(2);
- });
-
- it(`should set the absence types in the controller as formated legends`, () => {
- const absenceTypes = [
- {id: 1, name: 'Holiday', rgb: '#000'},
- {id: 2, name: 'Leave', rgb: '#000'}
- ];
-
- expect(controller.legends).not.toBeDefined();
-
- controller.absenceTypes = absenceTypes;
-
- expect(controller.legends.length).toEqual(2);
- expect(controller.legends[0].color).toBeDefined();
- expect(controller.legends[1].color).toBeDefined();
+ expect(dayNumber.title).toEqual('Holiday');
+ expect(dayNumber.style.backgroundColor).toEqual('rgb(0, 0, 0)');
});
});
});
diff --git a/modules/worker/front/calendar/style.scss b/modules/worker/front/calendar/style.scss
index cb93174af..e622dda64 100644
--- a/modules/worker/front/calendar/style.scss
+++ b/modules/worker/front/calendar/style.scss
@@ -1,34 +1,19 @@
@import "variables";
-
-/* .calendar-list .calendar:nth-child(2n + 1) {
- border-right:1px solid #ddd
-} */
-
-.calendar-list {
- align-items: flex-start;
- flex-wrap: wrap;
- justify-content: center;
-
- .calendar {
+vn-worker-calendar {
+ .calendars {
+ display: flex;
+ flex-wrap: wrap;
+ justify-content: center;
+ align-items: center;
box-sizing: border-box;
padding: $spacing-md;
- overflow: hidden;
- min-width: 18em;
- width: 25%;
-
- vn-calendar {
+
+ & > vn-calendar {
border: 1px solid #ddd;
- padding: 0.5em
+ margin: $spacing-md;
+ padding: $spacing-xs;
+ max-width: 18em;
}
}
}
-
-vn-horizontal.header {
- justify-content: flex-end;
- margin-bottom: 0.5em;
-
- .totalBox {
- max-width: 15em
- }
-}
\ No newline at end of file
diff --git a/modules/worker/front/time-control/index.html b/modules/worker/front/time-control/index.html
index 7eaed4ec5..54c44973c 100644
--- a/modules/worker/front/time-control/index.html
+++ b/modules/worker/front/time-control/index.html
@@ -1,76 +1,73 @@
-
-
-
-
-
-
- {{::$ctrl.weekdayNames[$index].name}}
- {{::weekday.dated | date: 'dd'}}
-
- {{::weekday.dated | date: 'MMMM'}}
-
-
-
-
-
-
-
-
-
-
- {{hour.timed | date: 'HH:mm'}}
-
-
-
-
-
+
+
+
-
+
+ {{::$ctrl.weekdayNames[$index].name}}
+ {{::weekday.dated | date: 'dd'}}
+
+ {{::weekday.dated | date: 'MMMM'}}
+
+
+
+
+
+
+
+
+
+
+ {{hour.timed | date: 'HH:mm'}}
+
+
+
+
+
+
+
{{$ctrl.getWeekdayTotalHours(weekday)}} h.
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
+
+
Hours
+ value="{{$ctrl.weekTotalHours}} h.">
-
-
-
-
+
+
+
+
-
-
diff --git a/modules/worker/front/time-control/index.js b/modules/worker/front/time-control/index.js
index 9bb04ac03..622ecd16e 100644
--- a/modules/worker/front/time-control/index.js
+++ b/modules/worker/front/time-control/index.js
@@ -2,155 +2,91 @@ import ngModule from '../module';
import './style.scss';
class Controller {
- constructor($scope, $http, $stateParams, $element) {
+ constructor($scope, $http, $stateParams, $element, vnWeekDays) {
this.$stateParams = $stateParams;
this.$ = $scope;
this.$http = $http;
this.$element = $element;
- this.defaultDate = new Date();
- this.currentWeek = [];
this.weekDays = [];
- this.weekdayNames = [
- {name: 'Monday'},
- {name: 'Tuesday'},
- {name: 'Wednesday'},
- {name: 'Thursday'},
- {name: 'Friday'},
- {name: 'Saturday'},
- {name: 'Sunday'}
- ];
+ this.weekdayNames = vnWeekDays.locales;
}
+ $postLink() {
+ this.date = new Date();
+ }
/**
- * Gets worker data
+ * The current selected date
*/
- get worker() {
- return this._worker;
+ get date() {
+ return this._date;
+ }
+
+ set date(value) {
+ this._date = value;
+ value.setHours(0, 0, 0, 0);
+
+ let weekOffset = value.getDay() - 1;
+ if (weekOffset < 0) weekOffset = 6;
+
+ let started = new Date(value.getTime());
+ started.setDate(started.getDate() - weekOffset);
+ this.started = started;
+
+ let ended = new Date(started.getTime());
+ ended.setDate(ended.getDate() + 7);
+ this.ended = ended;
+
+ this.fetchHours();
}
/**
- * Sets worker data and retrieves
- * worker hours
- *
- * @param {Object} value - Worker data
- */
- set worker(value) {
- this._worker = value;
-
- if (value) {
- this.$.$applyAsync(() => {
- this.getHours();
- });
- }
- }
-
- /**
- * Gets worker hours data
- *
+ * Worker hours data
*/
get hours() {
return this._hours;
}
- /**
- * Gets worker hours data
- *
- * @param {Object} value - Hours data
- */
set hours(value) {
this._hours = value;
- if (value) this.build();
+ this.weekDays = [];
+ if (!this.hours) return;
+
+ let dayIndex = new Date(this.started.getTime());
+
+ while (dayIndex < this.ended) {
+ let weekDay = dayIndex.getDay();
+
+ let hours = this.hours
+ .filter(hour => new Date(hour.timed).getDay() == weekDay)
+ .sort((a, b) => new Date(a.timed) - new Date(b.timed));
+
+ this.weekDays.push({
+ dated: new Date(dayIndex.getTime()),
+ hours
+ });
+ dayIndex.setDate(dayIndex.getDate() + 1);
+ }
}
- getHours() {
- const params = {workerFk: this.worker.id};
+ fetchHours() {
+ const params = {workerFk: this.$stateParams.id};
const filter = {
- where: {
- timed: {between: [this.started, this.ended]}
- }
+ where: {and: [
+ {timed: {gte: this.started}},
+ {timed: {lt: this.ended}}
+ ]}
};
- return this.$.model.applyFilter(filter, params);
+ this.$.model.applyFilter(filter, params);
}
- refresh() {
- this.getHours().then(() => this.build());
- }
-
- build() {
- let weekdays = new Array(7);
- const currentWeek = [];
-
- for (let i = 0; i < weekdays.length; i++) {
- const dated = new Date();
- dated.setHours(23, 59, 0, 0);
- dated.setMonth(this.started.getMonth());
- dated.setDate(this.started.getDate() + i);
-
- const hours = this.hours.filter(hour => {
- const timed = new Date(hour.timed);
- const weekDay = timed.getDay() == 0 ? 7 : timed.getDay();
- return weekDay == (i + 1);
- });
-
- const sortedHours = hours.sort((a, b) => {
- return new Date(a.timed) - new Date(b.timed);
- });
-
- weekdays[i] = {dated, hours: sortedHours};
-
- currentWeek.push({
- dated: dated,
- className: 'orange-circle',
- title: 'Current week',
- isRemovable: false
- });
- }
-
- this.currentWeek = currentWeek;
- this.weekDays = weekdays;
+ hasEvents(day) {
+ return day >= this.started && day < this.ended;
}
hourColor(weekDay) {
- if (weekDay.manual)
- return 'alert';
-
- return 'warning';
- }
- get weekOffset() {
- const timed = this.defaultDate;
- const weekDay = timed.getDay() == 0 ? 7 : timed.getDay();
-
- return weekDay - 1;
- }
-
- /**
- * Returns week start date
- * from current selected week
- */
- get started() {
- const started = new Date();
- const offset = this.weekOffset;
-
- started.setMonth(this.defaultDate.getMonth());
- started.setDate(this.defaultDate.getDate() - offset);
- started.setHours(0, 0, 0, 0);
-
- return started;
- }
-
- /**
- * Returns week end date
- * from current selected week
- */
- get ended() {
- const ended = new Date();
- ended.setHours(0, 0, 0, 0);
- ended.setMonth(this.started.getMonth());
- ended.setDate(this.started.getDate() + 7);
-
- return ended;
+ return weekDay.manual ? 'alert' : 'warning';
}
getWeekdayTotalHours(weekday) {
@@ -200,20 +136,6 @@ class Controller {
return `${hour}:${min}`;
}
- onMoveNext() {
- this.refresh();
- }
-
- onMovePrevious() {
- this.refresh();
- }
-
- onSelection($days) {
- this.defaultDate.setMonth($days[0].getMonth());
- this.defaultDate.setDate($days[0].getDate());
- this.refresh();
- }
-
showAddTimeDialog(weekday) {
const timed = new Date(weekday.dated);
const now = new Date();
@@ -226,26 +148,25 @@ class Controller {
this.selectedWeekday = weekday;
this.$.addTimeDialog.show();
- const selector = 'vn-dialog[vn-id="addTimeDialog"] input[type="time"]';
+ const selector = '[vn-id=addTimeDialog] input[type=time]';
const input = this.$element[0].querySelector(selector);
input.focus();
}
addTime(response) {
- if (response === 'ACCEPT') {
- let data = {workerFk: this.worker.id, timed: this.newTime};
- let query = `/api/WorkerTimeControls/addTime`;
- this.$http.post(query, data).then(() => this.refresh());
- }
+ if (response !== 'ACCEPT') return;
+ let data = {
+ workerFk: this.$stateParams.id,
+ timed: this.newTime
+ };
+ this.$http.post(`api/WorkerTimeControls/addTime`, data)
+ .then(() => this.fetchHours());
}
}
-Controller.$inject = ['$scope', '$http', '$stateParams', '$element'];
+Controller.$inject = ['$scope', '$http', '$stateParams', '$element', 'vnWeekDays'];
ngModule.component('vnWorkerTimeControl', {
template: require('./index.html'),
- controller: Controller,
- bindings: {
- worker: '<'
- }
+ controller: Controller
});
diff --git a/modules/worker/front/time-control/index.spec.js b/modules/worker/front/time-control/index.spec.js
index 1e5ae5e97..550db10f9 100644
--- a/modules/worker/front/time-control/index.spec.js
+++ b/modules/worker/front/time-control/index.spec.js
@@ -2,37 +2,56 @@ import './index.js';
describe('Worker', () => {
describe('Component vnWorkerTimeControl', () => {
+ let $httpBackend;
let $scope;
- let controller;
let $element;
+ let controller;
beforeEach(angular.mock.module('worker', $translateProvider => {
$translateProvider.translations('en', {});
}));
- beforeEach(angular.mock.inject(($componentController, $rootScope) => {
+ beforeEach(angular.mock.inject(($compile, $rootScope, $stateParams, _$httpBackend_) => {
+ $stateParams.id = 1;
+ $httpBackend = _$httpBackend_;
$scope = $rootScope.$new();
- $element = angular.element('');
- controller = $componentController('vnWorkerTimeControl', {$scope, $element});
+ $element = $compile('')($scope);
+ controller = $element.controller('vnWorkerTimeControl');
}));
- describe('worker() setter', () => {
- it(`should set worker data and then call getHours() method`, () => {
- spyOn(controller, 'getHours');
- controller.worker = {id: 106};
- $scope.$apply();
-
- expect(controller.getHours).toHaveBeenCalledWith();
- });
+ afterEach(() => {
+ $scope.$destroy();
+ $element.remove();
});
describe('hours() setter', () => {
- it(`should set hours data and then call build() method`, () => {
- spyOn(controller, 'build');
- controller.hours = [{id: 1}, {id: 2}];
- $scope.$apply();
+ it(`should set hours data at it's corresponding week day`, () => {
+ let wednesday = new Date(controller.started.getTime());
+ wednesday.setDate(wednesday.getDate() + 2);
- expect(controller.build).toHaveBeenCalledWith();
+ let path = `api/WorkerTimeControls/filter`;
+ $httpBackend.whenGET(url => url.startsWith(path))
+ .respond([
+ {
+ id: 1,
+ timed: controller.started.toJSON(),
+ userFk: 1
+ }, {
+ id: 2,
+ timed: wednesday.toJSON(),
+ userFk: 1
+ }, {
+ id: 3,
+ timed: wednesday.toJSON(),
+ userFk: 1
+ }
+ ]);
+
+ $httpBackend.flush();
+
+ expect(controller.weekDays.length).toEqual(7);
+ expect(controller.weekDays[0].hours.length).toEqual(1);
+ expect(controller.weekDays[2].hours.length).toEqual(2);
});
});
diff --git a/modules/worker/front/time-control/locale/es.yml b/modules/worker/front/time-control/locale/es.yml
index cfb0239a6..9a3484fc6 100644
--- a/modules/worker/front/time-control/locale/es.yml
+++ b/modules/worker/front/time-control/locale/es.yml
@@ -3,5 +3,5 @@ Out: Salida
Hour: Hora
Hours: Horas
Add time: Añadir hora
-Week total: Total por semana
+Week total: Total semana
Current week: Semana actual
\ No newline at end of file
diff --git a/modules/worker/front/time-control/style.scss b/modules/worker/front/time-control/style.scss
index 9917fa3fb..978a600a2 100644
--- a/modules/worker/front/time-control/style.scss
+++ b/modules/worker/front/time-control/style.scss
@@ -5,23 +5,20 @@ vn-worker-time-control {
margin-bottom: 5px;
color: $color-main
}
-
vn-td.hours {
vertical-align: top;
& > section {
- position: relative;
- padding: .6em 0;
+ display: flex;
+ align-items: center;
+ padding: .3em 0;
& > vn-icon {
- position: absolute;
- margin-left: -1.3em;
- margin-top: -3px;
color: $color-font-secondary;
+ padding-right: .1em;
}
}
}
-
.totalBox {
max-width: none
}
diff --git a/webpack.config.js b/webpack.config.js
index 1efcf5f01..66f2179a9 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -103,6 +103,9 @@ let baseConfig = {
favicon: 'front/salix/favicon.ico',
filename: 'index.html',
chunks: ['salix']
+ }),
+ new webpack.DefinePlugin({
+ 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
})
],
devtool: 'source-map',