Agency events, delivery days viewer
This commit is contained in:
parent
6d50012fab
commit
98cc3ce00e
|
@ -9,10 +9,10 @@
|
||||||
</vn-icon>
|
</vn-icon>
|
||||||
</vn-auto>
|
</vn-auto>
|
||||||
<vn-one>
|
<vn-one>
|
||||||
<strong>
|
<div>
|
||||||
<span translate>{{$ctrl.defaultDate | date: 'MMMM'}}</span>
|
<span translate>{{$ctrl.defaultDate | date: 'MMMM'}}</span>
|
||||||
<span>{{$ctrl.defaultDate | date: 'yyyy'}}</span>
|
<span>{{$ctrl.defaultDate | date: 'yyyy'}}</span>
|
||||||
</strong>
|
</div>
|
||||||
</vn-one>
|
</vn-one>
|
||||||
<vn-auto>
|
<vn-auto>
|
||||||
<vn-icon
|
<vn-icon
|
||||||
|
@ -23,7 +23,6 @@
|
||||||
</vn-icon>
|
</vn-icon>
|
||||||
</vn-auto>
|
</vn-auto>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
|
|
||||||
<vn-vertical class="body">
|
<vn-vertical class="body">
|
||||||
<vn-horizontal class="weekdays">
|
<vn-horizontal class="weekdays">
|
||||||
<section title="{{'Monday' | translate}}"
|
<section title="{{'Monday' | translate}}"
|
||||||
|
@ -56,8 +55,10 @@
|
||||||
</section>
|
</section>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
<vn-horizontal class="days">
|
<vn-horizontal class="days">
|
||||||
<section ng-repeat="day in $ctrl.days" class="day"
|
<section
|
||||||
ng-class="{'primary': day.events.length > 0}">
|
ng-repeat="day in $ctrl.days"
|
||||||
|
class="day {{::$ctrl.getClass({$day: day.dated})}}"
|
||||||
|
ng-class="::{primary: day.events.length > 0 || $ctrl.hasEvents({$day: day.dated})}">
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<div class="day-number"
|
<div class="day-number"
|
||||||
title="{{(day.eventName) | translate}}"
|
title="{{(day.eventName) | translate}}"
|
||||||
|
|
|
@ -5,6 +5,9 @@ import './style.scss';
|
||||||
/**
|
/**
|
||||||
* Flat calendar.
|
* Flat calendar.
|
||||||
*
|
*
|
||||||
|
* @property {Array} data Array of events
|
||||||
|
* @property {Function} hasEvents Determines if an events exists for a day
|
||||||
|
* @property {Function} getClass Class to apply to specific day
|
||||||
*/
|
*/
|
||||||
export default class Calendar extends Component {
|
export default class Calendar extends Component {
|
||||||
constructor($element, $scope) {
|
constructor($element, $scope) {
|
||||||
|
@ -48,15 +51,24 @@ export default class Calendar extends Component {
|
||||||
* @param {Date} value - New default date
|
* @param {Date} value - New default date
|
||||||
*/
|
*/
|
||||||
set defaultDate(value) {
|
set defaultDate(value) {
|
||||||
this._defaultDate = value;
|
if (value) {
|
||||||
|
value = new Date(value);
|
||||||
|
value.setHours(0, 0, 0, 0);
|
||||||
|
value.setDate(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
this._defaultDate = value;
|
||||||
this.repaint();
|
this.repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets initial events
|
* Sets events
|
||||||
*
|
*
|
||||||
* @param {Array} value - Array of events
|
* @param {Array} value - Array of events
|
||||||
|
* @param {Date} event.dated - Day to add event
|
||||||
|
* @param {String} event.name - Tooltip description
|
||||||
|
* @param {String} event.className - ClassName style
|
||||||
|
* @param {Object} event.style - Style properties
|
||||||
*/
|
*/
|
||||||
set data(value) {
|
set data(value) {
|
||||||
if (!value) return;
|
if (!value) return;
|
||||||
|
@ -64,7 +76,9 @@ export default class Calendar extends Component {
|
||||||
this.events = [];
|
this.events = [];
|
||||||
|
|
||||||
value.forEach(event => {
|
value.forEach(event => {
|
||||||
this.addEvent(event);
|
event.dated = new Date(event.dated);
|
||||||
|
event.dated.setHours(0, 0, 0, 0);
|
||||||
|
this.events.push(event);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (value.length && this.defaultDate) {
|
if (value.length && this.defaultDate) {
|
||||||
|
@ -197,10 +211,10 @@ export default class Calendar extends Component {
|
||||||
const hasEvents = events.length > 0;
|
const hasEvents = events.length > 0;
|
||||||
|
|
||||||
if (isCurrentMonth && isSunday && !hasEvents)
|
if (isCurrentMonth && isSunday && !hasEvents)
|
||||||
params.style = {color: '#f42121'};
|
params.style = {color: '#999'};
|
||||||
|
|
||||||
if (isCurrentMonth && isSaturday && !hasEvents)
|
if (isCurrentMonth && isSaturday && !hasEvents)
|
||||||
params.style = {color: '#666666'};
|
params.style = {color: '#999'};
|
||||||
|
|
||||||
if (!isCurrentMonth)
|
if (!isCurrentMonth)
|
||||||
params.style = {opacity: '0.5'};
|
params.style = {opacity: '0.5'};
|
||||||
|
@ -217,42 +231,6 @@ export default class Calendar extends Component {
|
||||||
this.days.push(params);
|
this.days.push(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds a new calendar event
|
|
||||||
*
|
|
||||||
* @param {Object} options - Event params
|
|
||||||
* @param {Date} options.dated - Day to add event
|
|
||||||
* @param {String} options.name - Tooltip description
|
|
||||||
* @param {String} options.className - ClassName style
|
|
||||||
* @param {Object} options.style - Style properties
|
|
||||||
* @param {Boolean} options.isRemovable - True if is removable by users
|
|
||||||
*/
|
|
||||||
addEvent(options) {
|
|
||||||
if (!Object.hasOwnProperty.call(options, 'isRemovable'))
|
|
||||||
options.isRemovable = true;
|
|
||||||
|
|
||||||
options.dated = new Date(options.dated);
|
|
||||||
options.dated.setHours(0, 0, 0, 0);
|
|
||||||
|
|
||||||
this.events.push(options);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes an event from an array of events
|
|
||||||
* @param {Object} dated - Dated event
|
|
||||||
*/
|
|
||||||
removeEvent(dated) {
|
|
||||||
dated = new Date(dated);
|
|
||||||
dated.setHours(0, 0, 0, 0);
|
|
||||||
|
|
||||||
const event = this.events.findIndex(event => {
|
|
||||||
return event.dated >= dated && event.dated <= dated;
|
|
||||||
});
|
|
||||||
|
|
||||||
if (event > -1)
|
|
||||||
this.events.splice(event, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Moves to next month(s)
|
* Moves to next month(s)
|
||||||
*
|
*
|
||||||
|
@ -261,10 +239,7 @@ export default class Calendar extends Component {
|
||||||
moveNext(skip = 1) {
|
moveNext(skip = 1) {
|
||||||
let next = this.defaultDate.getMonth() + skip;
|
let next = this.defaultDate.getMonth() + skip;
|
||||||
this.defaultDate.setMonth(next);
|
this.defaultDate.setMonth(next);
|
||||||
this.defaultDate.setHours(0, 0, 0, 0);
|
|
||||||
this.defaultDate.setDate(1);
|
|
||||||
this.repaint();
|
this.repaint();
|
||||||
|
|
||||||
this.emit('moveNext');
|
this.emit('moveNext');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -276,12 +251,7 @@ export default class Calendar extends Component {
|
||||||
movePrevious(skip = 1) {
|
movePrevious(skip = 1) {
|
||||||
let previous = this.defaultDate.getMonth() - skip;
|
let previous = this.defaultDate.getMonth() - skip;
|
||||||
this.defaultDate.setMonth(previous);
|
this.defaultDate.setMonth(previous);
|
||||||
this.defaultDate.setHours(0, 0, 0, 0);
|
|
||||||
|
|
||||||
const lastDate = this.lastDay(this.defaultDate);
|
|
||||||
this.defaultDate.setDate(lastDate.getDate());
|
|
||||||
this.repaint();
|
this.repaint();
|
||||||
|
|
||||||
this.emit('movePrevious');
|
this.emit('movePrevious');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -327,6 +297,14 @@ export default class Calendar extends Component {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hasEvents() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
getClass() {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Calendar.$inject = ['$element', '$scope'];
|
Calendar.$inject = ['$element', '$scope'];
|
||||||
|
@ -341,6 +319,8 @@ ngModule.component('vnCalendar', {
|
||||||
onSelection: '&?',
|
onSelection: '&?',
|
||||||
onMoveNext: '&?',
|
onMoveNext: '&?',
|
||||||
onMovePrevious: '&?',
|
onMovePrevious: '&?',
|
||||||
|
hasEvents: '&?',
|
||||||
|
getClass: '&?',
|
||||||
displayControls: '<?',
|
displayControls: '<?',
|
||||||
disabled: '<?',
|
disabled: '<?',
|
||||||
skip: '<?'
|
skip: '<?'
|
||||||
|
|
|
@ -29,54 +29,6 @@ describe('Component vnCalendar', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('addEvent()', () => {
|
|
||||||
it(`should add an event to an array of events`, () => {
|
|
||||||
controller.events = [];
|
|
||||||
controller.addEvent({
|
|
||||||
dated: new Date(),
|
|
||||||
name: 'My event'
|
|
||||||
});
|
|
||||||
const firstEvent = controller.events[0];
|
|
||||||
|
|
||||||
expect(firstEvent.name).toEqual('My event');
|
|
||||||
expect(firstEvent.isRemovable).toBeDefined();
|
|
||||||
expect(firstEvent.isRemovable).toBeTruthy();
|
|
||||||
});
|
|
||||||
|
|
||||||
it(`should not repeat an event for the same date`, () => {
|
|
||||||
const curDate = new Date();
|
|
||||||
curDate.setHours(0, 0, 0, 0);
|
|
||||||
|
|
||||||
controller.events = [{
|
|
||||||
dated: curDate,
|
|
||||||
name: 'My event 1'
|
|
||||||
}];
|
|
||||||
controller.addEvent({
|
|
||||||
dated: curDate,
|
|
||||||
name: 'My event 2'
|
|
||||||
});
|
|
||||||
|
|
||||||
const firstEvent = controller.events[0];
|
|
||||||
|
|
||||||
expect(controller.events.length).toEqual(2);
|
|
||||||
expect(firstEvent.name).toEqual('My event 1');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('removeEvent()', () => {
|
|
||||||
it(`should remove an event from an array of events`, () => {
|
|
||||||
const curDate = new Date();
|
|
||||||
controller._events = [{
|
|
||||||
dated: curDate,
|
|
||||||
name: 'My event 1',
|
|
||||||
className: 'color'
|
|
||||||
}];
|
|
||||||
controller.removeEvent(curDate);
|
|
||||||
|
|
||||||
expect(controller.events.length).toEqual(0);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('moveNext()', () => {
|
describe('moveNext()', () => {
|
||||||
it(`should shift to the next n months, then emit a 'moveNext' event`, () => {
|
it(`should shift to the next n months, then emit a 'moveNext' event`, () => {
|
||||||
spyOn(controller, 'emit');
|
spyOn(controller, 'emit');
|
||||||
|
|
|
@ -5,7 +5,6 @@ vn-calendar.small {
|
||||||
display: none
|
display: none
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vn-calendar {
|
vn-calendar {
|
||||||
display: block;
|
display: block;
|
||||||
|
|
||||||
|
@ -14,8 +13,6 @@ vn-calendar {
|
||||||
padding: 0.2em 0;
|
padding: 0.2em 0;
|
||||||
height: 1.5em
|
height: 1.5em
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.weekdays {
|
.weekdays {
|
||||||
color: $color-font-secondary;
|
color: $color-font-secondary;
|
||||||
margin-bottom: 0.5em;
|
margin-bottom: 0.5em;
|
||||||
|
@ -23,11 +20,9 @@ vn-calendar {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
font-size: 0.8em;
|
font-size: 0.8em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.weekdays section {
|
.weekdays section {
|
||||||
cursor: pointer
|
cursor: pointer
|
||||||
}
|
}
|
||||||
|
|
||||||
.weekdays section, .day {
|
.weekdays section, .day {
|
||||||
position: relative;
|
position: relative;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
@ -35,14 +30,11 @@ vn-calendar {
|
||||||
width: 14.28%;
|
width: 14.28%;
|
||||||
outline: 0;
|
outline: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.days {
|
.days {
|
||||||
justify-content: flex-start;
|
justify-content: flex-start;
|
||||||
align-items: flex-start;
|
align-items: flex-start;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.day {
|
.day {
|
||||||
.content {
|
.content {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
@ -51,7 +43,6 @@ vn-calendar {
|
||||||
left: 0;
|
left: 0;
|
||||||
top: 0
|
top: 0
|
||||||
}
|
}
|
||||||
|
|
||||||
.day-number {
|
.day-number {
|
||||||
transition: background-color 0.3s;
|
transition: background-color 0.3s;
|
||||||
text-align:center;
|
text-align:center;
|
||||||
|
@ -65,30 +56,24 @@ vn-calendar {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
outline: 0
|
outline: 0
|
||||||
}
|
}
|
||||||
|
|
||||||
.day-number:hover {
|
.day-number:hover {
|
||||||
background-color: lighten($color-font-secondary, 20%);
|
background-color: lighten($color-font-secondary, 20%);
|
||||||
opacity: 0.8
|
opacity: 0.8
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.day::after {
|
.day::after {
|
||||||
content: "";
|
content: "";
|
||||||
display: block;
|
display: block;
|
||||||
padding-top: 100%;
|
padding-top: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.day.primary .day-number {
|
.day.primary .day-number {
|
||||||
background-color: $color-main;
|
background-color: $color-main;
|
||||||
color: $color-font-bg;
|
color: $color-font-dark;
|
||||||
}
|
}
|
||||||
|
|
||||||
.events {
|
.events {
|
||||||
margin-top: 0.5em;
|
margin-top: 0.5em;
|
||||||
font-size: 0.6em
|
font-size: 0.6em
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.events {
|
.events {
|
||||||
color: $color-font-secondary;
|
color: $color-font-secondary;
|
||||||
|
|
||||||
|
@ -96,7 +81,6 @@ vn-calendar {
|
||||||
margin-bottom: .1em;
|
margin-bottom: .1em;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.chip {
|
.chip {
|
||||||
background-color: $color-main;
|
background-color: $color-main;
|
||||||
color: $color-font-bg;
|
color: $color-font-bg;
|
||||||
|
@ -105,15 +89,11 @@ vn-calendar {
|
||||||
padding: 0.3em .8em;
|
padding: 0.3em .8em;
|
||||||
max-width: 5em;
|
max-width: 5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.day.gray {
|
.day.gray {
|
||||||
.day-number {
|
.day-number {
|
||||||
color: $color-font-secondary
|
color: $color-font-secondary
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.day.sunday {
|
.day.sunday {
|
||||||
.day-number {
|
.day-number {
|
||||||
color: $color-alert;
|
color: $color-alert;
|
||||||
|
|
|
@ -51,3 +51,8 @@ Create new one: Crear nuevo
|
||||||
Toggle: Desplegar/Plegar
|
Toggle: Desplegar/Plegar
|
||||||
Check all: Seleccionar todo
|
Check all: Seleccionar todo
|
||||||
Select a file: Selecciona un fichero
|
Select a file: Selecciona un fichero
|
||||||
|
Edit: Editar
|
||||||
|
Edit item: Editar elemento
|
||||||
|
No records found: No se han encontrado elementos
|
||||||
|
Day: Día
|
||||||
|
Days: Días
|
|
@ -34,6 +34,13 @@ a, .link {
|
||||||
text-decoration: underline;
|
text-decoration: underline;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
vn-bg-title {
|
||||||
|
display: block;
|
||||||
|
text-align: center;
|
||||||
|
padding: 1em;
|
||||||
|
color: gray;
|
||||||
|
font-size: 1.3em;
|
||||||
|
}
|
||||||
.totalBox {
|
.totalBox {
|
||||||
border: 1px solid #CCC;
|
border: 1px solid #CCC;
|
||||||
text-align: right !important;
|
text-align: right !important;
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
"helmet#hsts": {
|
"helmet#hsts": {
|
||||||
"params": {
|
"params": {
|
||||||
"maxAge": 0,
|
"maxAge": 0,
|
||||||
"includeSubdomains": true
|
"includeSubDomains": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"helmet#hidePoweredBy": {},
|
"helmet#hidePoweredBy": {},
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
|
||||||
|
module.exports = Self => {
|
||||||
|
Self.remoteMethod('getEvents', {
|
||||||
|
description: 'Returns delivery days for a postcode',
|
||||||
|
accepts: [
|
||||||
|
{
|
||||||
|
arg: 'agencyModeFk',
|
||||||
|
type: 'Number',
|
||||||
|
description: 'The agency mode id',
|
||||||
|
required: true
|
||||||
|
}, {
|
||||||
|
arg: 'provinceFk',
|
||||||
|
type: 'Number',
|
||||||
|
description: 'The province id',
|
||||||
|
required: true
|
||||||
|
}, {
|
||||||
|
arg: 'postCode',
|
||||||
|
type: 'String',
|
||||||
|
description: 'The postcode',
|
||||||
|
required: true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
returns: {
|
||||||
|
type: 'Object',
|
||||||
|
root: true
|
||||||
|
},
|
||||||
|
http: {
|
||||||
|
path: `/getEvents`,
|
||||||
|
verb: 'GET'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Self.getEvents = async(agencyModeFk, provinceFk, postCode) => {
|
||||||
|
let [events, exclusions] = await Self.rawSql(
|
||||||
|
`CALL zone_getEvents(?, ?, ?)`,
|
||||||
|
[agencyModeFk, provinceFk, postCode]
|
||||||
|
);
|
||||||
|
|
||||||
|
return {events, exclusions};
|
||||||
|
};
|
||||||
|
};
|
|
@ -14,10 +14,19 @@
|
||||||
"ZoneGeo": {
|
"ZoneGeo": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
|
"ZoneEvent": {
|
||||||
|
"dataSource": "vn"
|
||||||
|
},
|
||||||
|
"ZoneExclusion": {
|
||||||
|
"dataSource": "vn"
|
||||||
|
},
|
||||||
"ZoneCalendar": {
|
"ZoneCalendar": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
"ZoneIncluded": {
|
"ZoneIncluded": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
|
},
|
||||||
|
"ZoneWarehouse": {
|
||||||
|
"dataSource": "vn"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
module.exports = Self => {
|
||||||
|
function rangeValid(err) {
|
||||||
|
if (this.from && this.to && this.from >= this.to)
|
||||||
|
err();
|
||||||
|
}
|
||||||
|
Self.validate('rangeValid', rangeValid, {
|
||||||
|
message: `Start date should be lower than end date`
|
||||||
|
});
|
||||||
|
};
|
|
@ -0,0 +1,47 @@
|
||||||
|
{
|
||||||
|
"name": "ZoneEvent",
|
||||||
|
"base": "VnModel",
|
||||||
|
"options": {
|
||||||
|
"mysql": {
|
||||||
|
"table": "zoneEvent"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"properties": {
|
||||||
|
"id": {
|
||||||
|
"id": true,
|
||||||
|
"type": "Number"
|
||||||
|
},
|
||||||
|
"zoneFk": {
|
||||||
|
"id": true,
|
||||||
|
"type": "Number"
|
||||||
|
},
|
||||||
|
"from": {
|
||||||
|
"type": "Date"
|
||||||
|
},
|
||||||
|
"to": {
|
||||||
|
"type": "Date"
|
||||||
|
},
|
||||||
|
"weekDays": {
|
||||||
|
"type": "String"
|
||||||
|
},
|
||||||
|
"hour": {
|
||||||
|
"type": "Date"
|
||||||
|
},
|
||||||
|
"travelingDays": {
|
||||||
|
"type": "Number"
|
||||||
|
},
|
||||||
|
"price": {
|
||||||
|
"type": "Number"
|
||||||
|
},
|
||||||
|
"bonus": {
|
||||||
|
"type": "Number"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"relations": {
|
||||||
|
"zone": {
|
||||||
|
"type": "belongsTo",
|
||||||
|
"model": "Zone",
|
||||||
|
"foreignKey": "zoneFk"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
{
|
||||||
|
"name": "ZoneExclusion",
|
||||||
|
"base": "VnModel",
|
||||||
|
"options": {
|
||||||
|
"mysql": {
|
||||||
|
"table": "zoneExclusion"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"properties": {
|
||||||
|
"id": {
|
||||||
|
"id": true,
|
||||||
|
"type": "Number"
|
||||||
|
},
|
||||||
|
"day": {
|
||||||
|
"type": "Date",
|
||||||
|
"required": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"relations": {
|
||||||
|
"zone": {
|
||||||
|
"type": "belongsTo",
|
||||||
|
"model": "Zone",
|
||||||
|
"foreignKey": "zoneFk"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
{
|
||||||
|
"name": "ZoneWarehouse",
|
||||||
|
"base": "VnModel",
|
||||||
|
"options": {
|
||||||
|
"mysql": {
|
||||||
|
"table": "zoneWarehouse"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"properties": {
|
||||||
|
"id": {
|
||||||
|
"id": true,
|
||||||
|
"type": "Number"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"relations": {
|
||||||
|
"zone": {
|
||||||
|
"type": "belongsTo",
|
||||||
|
"model": "Zone",
|
||||||
|
"foreignKey": "zoneFk"
|
||||||
|
},
|
||||||
|
"warehouse": {
|
||||||
|
"type": "belongsTo",
|
||||||
|
"model": "Warehouse",
|
||||||
|
"foreignKey": "warehouseFk"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,10 +2,7 @@ module.exports = Self => {
|
||||||
require('../methods/zone/clone')(Self);
|
require('../methods/zone/clone')(Self);
|
||||||
require('../methods/zone/editPrices')(Self);
|
require('../methods/zone/editPrices')(Self);
|
||||||
require('../methods/zone/getLeaves')(Self);
|
require('../methods/zone/getLeaves')(Self);
|
||||||
|
require('../methods/zone/getEvents')(Self);
|
||||||
Self.validatesPresenceOf('warehouseFk', {
|
|
||||||
message: `Warehouse cannot be blank`
|
|
||||||
});
|
|
||||||
|
|
||||||
Self.validatesPresenceOf('agencyModeFk', {
|
Self.validatesPresenceOf('agencyModeFk', {
|
||||||
message: `Agency cannot be blank`
|
message: `Agency cannot be blank`
|
||||||
|
|
|
@ -38,15 +38,25 @@
|
||||||
"model": "ZoneGeo",
|
"model": "ZoneGeo",
|
||||||
"foreignKey": "zoneFk"
|
"foreignKey": "zoneFk"
|
||||||
},
|
},
|
||||||
"warehouse": {
|
|
||||||
"type": "belongsTo",
|
|
||||||
"model": "Warehouse",
|
|
||||||
"foreignKey": "warehouseFk"
|
|
||||||
},
|
|
||||||
"agencyMode": {
|
"agencyMode": {
|
||||||
"type": "belongsTo",
|
"type": "belongsTo",
|
||||||
"model": "AgencyMode",
|
"model": "AgencyMode",
|
||||||
"foreignKey": "agencyModeFk"
|
"foreignKey": "agencyModeFk"
|
||||||
|
},
|
||||||
|
"events": {
|
||||||
|
"type": "hasMany",
|
||||||
|
"model": "ZoneEvent",
|
||||||
|
"foreignKey": "zoneFk"
|
||||||
|
},
|
||||||
|
"exclusions": {
|
||||||
|
"type": "hasMany",
|
||||||
|
"model": "ZoneExclusion",
|
||||||
|
"foreignKey": "zoneFk"
|
||||||
|
},
|
||||||
|
"warehouses": {
|
||||||
|
"type": "hasMany",
|
||||||
|
"model": "ZoneWarehouse",
|
||||||
|
"foreignKey": "zoneFk"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -5,25 +5,16 @@
|
||||||
form="form"
|
form="form"
|
||||||
save="patch">
|
save="patch">
|
||||||
</vn-watcher>
|
</vn-watcher>
|
||||||
<form name="form" ng-submit="$ctrl.onSubmit()">
|
<form name="form" ng-submit="$ctrl.onSubmit()" compact>
|
||||||
<vn-card pad-large>
|
<vn-card pad-large>
|
||||||
<vn-horizontal>
|
<vn-horizontal>
|
||||||
<vn-textfield vn-two vn-focus
|
<vn-textfield
|
||||||
label="Name"
|
label="Name"
|
||||||
field="$ctrl.zone.name"
|
field="$ctrl.zone.name"
|
||||||
vn-acl="deliveryBoss">
|
vn-acl="deliveryBoss">
|
||||||
</vn-textfield>
|
</vn-textfield>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
<vn-horizontal>
|
<vn-horizontal>
|
||||||
<vn-autocomplete
|
|
||||||
vn-one
|
|
||||||
field="$ctrl.zone.warehouseFk"
|
|
||||||
url="/agency/api/Warehouses"
|
|
||||||
show-field="name"
|
|
||||||
value-field="id"
|
|
||||||
label="Warehouse"
|
|
||||||
vn-acl="deliveryBoss">
|
|
||||||
</vn-autocomplete>
|
|
||||||
<vn-autocomplete
|
<vn-autocomplete
|
||||||
vn-one
|
vn-one
|
||||||
field="$ctrl.zone.agencyModeFk"
|
field="$ctrl.zone.agencyModeFk"
|
||||||
|
@ -35,41 +26,46 @@
|
||||||
</vn-autocomplete>
|
</vn-autocomplete>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
<vn-horizontal>
|
<vn-horizontal>
|
||||||
<vn-input-number vn-two
|
<vn-input-number
|
||||||
label="Traveling days"
|
label="Traveling days"
|
||||||
model="$ctrl.zone.travelingDays"
|
model="$ctrl.zone.travelingDays"
|
||||||
min="0" step="1"
|
min="0"
|
||||||
|
step="1"
|
||||||
vn-acl="deliveryBoss">
|
vn-acl="deliveryBoss">
|
||||||
</vn-input-number>
|
</vn-input-number>
|
||||||
<vn-input-time vn-two
|
<vn-input-time
|
||||||
label="Estimated hour (ETD)"
|
label="Closing"
|
||||||
model="$ctrl.zone.hour"
|
model="$ctrl.zone.hour"
|
||||||
vn-acl="deliveryBoss">
|
vn-acl="deliveryBoss">
|
||||||
</vn-input-time>
|
</vn-input-time>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
<vn-horizontal>
|
<vn-horizontal>
|
||||||
<vn-input-number vn-one
|
<vn-input-number
|
||||||
label="Price"
|
label="Price"
|
||||||
model="$ctrl.zone.price"
|
model="$ctrl.zone.price"
|
||||||
min="0" step="0.01"
|
min="0"
|
||||||
|
step="0.01"
|
||||||
vn-acl="deliveryBoss">
|
vn-acl="deliveryBoss">
|
||||||
</vn-input-number>
|
</vn-input-number>
|
||||||
<vn-input-number vn-one
|
<vn-input-number
|
||||||
label="Bonus"
|
label="Bonus"
|
||||||
model="$ctrl.zone.bonus"
|
model="$ctrl.zone.bonus"
|
||||||
min="0" step="0.01"
|
min="0"
|
||||||
|
step="0.01"
|
||||||
vn-acl="deliveryBoss">
|
vn-acl="deliveryBoss">
|
||||||
</vn-input-number>
|
</vn-input-number>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
<vn-horizontal>
|
<vn-horizontal>
|
||||||
<vn-check label="Volumetric"
|
<vn-check
|
||||||
|
label="Volumetric"
|
||||||
field="$ctrl.zone.isVolumetric"
|
field="$ctrl.zone.isVolumetric"
|
||||||
vn-acl="deliveryBoss">
|
vn-acl="deliveryBoss">
|
||||||
</vn-check>
|
</vn-check>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
</vn-card>
|
</vn-card>
|
||||||
<vn-button-bar>
|
<vn-button-bar>
|
||||||
<vn-submit label="Save"
|
<vn-submit
|
||||||
|
label="Save"
|
||||||
vn-acl="deliveryBoss">
|
vn-acl="deliveryBoss">
|
||||||
</vn-submit>
|
</vn-submit>
|
||||||
</vn-button-bar>
|
</vn-button-bar>
|
||||||
|
|
|
@ -1,74 +1,20 @@
|
||||||
<vn-crud-model
|
<vn-calendar
|
||||||
vn-id="model"
|
vn-id="stMonth"
|
||||||
url="/agency/api/ZoneCalendars"
|
skip="2"
|
||||||
link="{zoneFk: $ctrl.$stateParams.id}"
|
has-events="$ctrl.hasEvents($day)"
|
||||||
data="$ctrl.data"
|
get-class="$ctrl.getClass($day)"
|
||||||
primary-key="zoneFk"
|
on-move-next="ndMonth.moveNext(2)"
|
||||||
auto-load="true">
|
on-move-previous="ndMonth.movePrevious(2)"
|
||||||
</vn-crud-model>
|
vn-acl="deliveryBoss"
|
||||||
<vn-watcher
|
pad-medium>
|
||||||
vn-id="watcher"
|
|
||||||
data="$ctrl.selectedDay">
|
|
||||||
</vn-watcher>
|
|
||||||
|
|
||||||
<vn-card pad-large>
|
|
||||||
<vn-horizontal pad-medium class="calendarControlsHeader">
|
|
||||||
<vn-icon-button icon="keyboard_arrow_left"
|
|
||||||
ng-click="$ctrl.onMovePrevious([stMonth, ndMonth])"
|
|
||||||
vn-tooltip="Previous">
|
|
||||||
</vn-icon-button>
|
|
||||||
<vn-icon-button icon="keyboard_arrow_right"
|
|
||||||
ng-click="$ctrl.onMoveNext([stMonth, ndMonth])"
|
|
||||||
vn-tooltip="Next">
|
|
||||||
</vn-icon-button>
|
|
||||||
</vn-horizontal>
|
|
||||||
<vn-horizontal>
|
|
||||||
<vn-calendar vn-id="stMonth" vn-one pad-medium
|
|
||||||
data="$ctrl.events"
|
|
||||||
display-controls="false"
|
|
||||||
on-selection="$ctrl.onSelection(values)"
|
|
||||||
skip="2" vn-acl="deliveryBoss">
|
|
||||||
</vn-calendar>
|
</vn-calendar>
|
||||||
<vn-calendar vn-id="ndMonth" vn-one pad-medium
|
<vn-calendar
|
||||||
data="$ctrl.events"
|
vn-id="ndMonth"
|
||||||
display-controls="false"
|
skip="2"
|
||||||
on-selection="$ctrl.onSelection(values)"
|
has-events="$ctrl.hasEvents($day)"
|
||||||
|
get-class="$ctrl.getClass($day)"
|
||||||
default-date="$ctrl.ndMonthDate"
|
default-date="$ctrl.ndMonthDate"
|
||||||
skip="2" vn-acl="deliveryBoss">
|
vn-acl="deliveryBoss"
|
||||||
|
display-controls="false"
|
||||||
|
pad-medium>
|
||||||
</vn-calendar>
|
</vn-calendar>
|
||||||
</vn-horizontal>
|
|
||||||
</vn-card>
|
|
||||||
|
|
||||||
<!-- Edit price dialog -->
|
|
||||||
<vn-dialog class="edit"
|
|
||||||
vn-id="priceDialog"
|
|
||||||
on-close="$ctrl.onClose()"
|
|
||||||
on-response="$ctrl.onResponse(response)">
|
|
||||||
<tpl-body>
|
|
||||||
<h5 pad-small-v translate>Edit price</h5>
|
|
||||||
<vn-horizontal>
|
|
||||||
<vn-input-number vn-one
|
|
||||||
label="Price"
|
|
||||||
model="$ctrl.selectedDay.price"
|
|
||||||
min="0" step="0.01"
|
|
||||||
required="true">
|
|
||||||
</vn-input-number>
|
|
||||||
<vn-input-number vn-one
|
|
||||||
label="Bonus"
|
|
||||||
model="$ctrl.selectedDay.bonus"
|
|
||||||
min="0" step="0.01"
|
|
||||||
required="true">
|
|
||||||
</vn-input-number>
|
|
||||||
</vn-horizontal>
|
|
||||||
<vn-horizontal>
|
|
||||||
<vn-radio-group vn-one
|
|
||||||
field="$ctrl.selectedDay.option"
|
|
||||||
options="$ctrl.options">
|
|
||||||
</vn-radio-group>
|
|
||||||
</vn-horizontal>
|
|
||||||
</tpl-body>
|
|
||||||
<tpl-buttons>
|
|
||||||
<input type="button" response="CANCEL" translate-attr="{value: 'Cancel'}"/>
|
|
||||||
<button response="ACCEPT" translate>Save</button>
|
|
||||||
</tpl-buttons>
|
|
||||||
</vn-dialog>
|
|
|
@ -2,133 +2,107 @@ import ngModule from '../module';
|
||||||
import './style.scss';
|
import './style.scss';
|
||||||
|
|
||||||
class Controller {
|
class Controller {
|
||||||
constructor($element, $scope, $http, $filter, $translate, $stateParams, vnApp) {
|
constructor($, $stateParams) {
|
||||||
this.$element = $element;
|
Object.assign(this, {
|
||||||
this.$ = $scope;
|
$,
|
||||||
this.$http = $http;
|
$stateParams
|
||||||
this.$filter = $filter;
|
});
|
||||||
this.$translate = $translate;
|
|
||||||
this.$stateParams = $stateParams;
|
this.excls = {};
|
||||||
this.vnApp = vnApp;
|
this.resetEvents();
|
||||||
this.stMonthDate = new Date();
|
|
||||||
this.ndMonthDate = new Date();
|
this.ndMonthDate = new Date();
|
||||||
this.ndMonthDate.setMonth(this.ndMonthDate.getMonth() + 1);
|
this.ndMonthDate.setMonth(this.ndMonthDate.getMonth() + 1);
|
||||||
this.selectedDay = {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$postLink() {
|
resetEvents() {
|
||||||
this.stMonth = this.$.stMonth;
|
this.wdays = [];
|
||||||
this.ndMonth = this.$.ndMonth;
|
this.days = {};
|
||||||
|
this.ranges = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
get data() {
|
get events() {
|
||||||
return this._data;
|
return this._events;
|
||||||
}
|
}
|
||||||
|
|
||||||
set data(value) {
|
set events(value) {
|
||||||
this._data = value;
|
this._events = value;
|
||||||
|
this.resetEvents();
|
||||||
if (!value) return;
|
if (!value) return;
|
||||||
|
|
||||||
const events = [];
|
function setWdays(wdays, weekDays) {
|
||||||
value.forEach(event => {
|
let codes = ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'];
|
||||||
events.push({
|
if (!weekDays) return [];
|
||||||
name: `P: ${this.$filter('currency')(event.price)}`,
|
weekDays = weekDays.split(',');
|
||||||
description: 'Price',
|
for (let wday of weekDays)
|
||||||
dated: event.delivered,
|
wdays[codes.indexOf(wday)] = true;
|
||||||
style: {backgroundColor: '#a3d131'},
|
return wdays;
|
||||||
data: {price: event.price}
|
}
|
||||||
});
|
|
||||||
events.push({
|
for (let event of value) {
|
||||||
name: `B: ${this.$filter('currency')(event.bonus)}`,
|
if (event.from && event.to) {
|
||||||
description: 'Bonus',
|
this.ranges.push({
|
||||||
dated: event.delivered,
|
from: new Date(event.from).setHours(0, 0, 0, 0),
|
||||||
data: {bonus: event.bonus}
|
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.events = events;
|
this.repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
onSelection(values) {
|
hasRange(time, wday) {
|
||||||
if (values.length > 1) return false;
|
let range = this.ranges.find(e => e.from <= time && e.to >= time);
|
||||||
|
return range && range.wdays[wday];
|
||||||
this.options = [
|
|
||||||
{label: 'Only this day', value: 'Only this day'},
|
|
||||||
{label: 'From this day', value: 'From this day'},
|
|
||||||
{label: 'All days', value: 'All days'}
|
|
||||||
];
|
|
||||||
const selection = values[0];
|
|
||||||
const events = selection.events;
|
|
||||||
const hasEvents = events.length > 0;
|
|
||||||
|
|
||||||
if (!hasEvents)
|
|
||||||
return this.vnApp.showMessage(this.$translate.instant(`There's no delivery for this day`));
|
|
||||||
|
|
||||||
this.selectedDay = {
|
|
||||||
delivered: selection.dated,
|
|
||||||
option: 'Only this day'
|
|
||||||
};
|
|
||||||
|
|
||||||
events.forEach(event => {
|
|
||||||
this.selectedDay = Object.assign(this.selectedDay, event.data);
|
|
||||||
});
|
|
||||||
this.$.priceDialog.show();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onResponse(response) {
|
hasEvents(day) {
|
||||||
if (response == 'ACCEPT') {
|
let time = day.getTime();
|
||||||
try {
|
let wday = day.getDay();
|
||||||
const data = {
|
return this.wdays[wday]
|
||||||
delivered: this.selectedDay.delivered,
|
|| this.days[time]
|
||||||
price: this.selectedDay.price,
|
|| this.hasRange(time, wday);
|
||||||
bonus: this.selectedDay.bonus,
|
}
|
||||||
option: this.selectedDay.option
|
|
||||||
};
|
|
||||||
|
|
||||||
this.$.watcher.check();
|
getClass(day) {
|
||||||
|
if (this.excls[day.getTime()])
|
||||||
|
return 'excluded';
|
||||||
|
}
|
||||||
|
|
||||||
const path = `/api/Zones/${this.zone.id}/editPrices`;
|
repaint() {
|
||||||
this.$http.post(path, data).then(() => {
|
this.$.stMonth.repaint();
|
||||||
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
|
this.$.ndMonth.repaint();
|
||||||
this.$.model.refresh();
|
|
||||||
this.card.reload();
|
|
||||||
});
|
|
||||||
} catch (e) {
|
|
||||||
this.vnApp.showError(this.$translate.instant(e.message));
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.onClose();
|
Controller.$inject = ['$scope', '$stateParams'];
|
||||||
}
|
|
||||||
|
|
||||||
onClose() {
|
|
||||||
this.$.watcher.updateOriginalData();
|
|
||||||
}
|
|
||||||
|
|
||||||
onMoveNext(calendars) {
|
|
||||||
calendars.forEach(calendar => {
|
|
||||||
calendar.moveNext(2);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
onMovePrevious(calendars) {
|
|
||||||
calendars.forEach(calendar => {
|
|
||||||
calendar.movePrevious(2);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Controller.$inject = ['$element', '$scope', '$http', '$filter', '$translate', '$stateParams', 'vnApp'];
|
|
||||||
|
|
||||||
ngModule.component('vnZoneCalendar', {
|
ngModule.component('vnZoneCalendar', {
|
||||||
template: require('./index.html'),
|
template: require('./index.html'),
|
||||||
controller: Controller,
|
controller: Controller,
|
||||||
bindings: {
|
bindings: {
|
||||||
zone: '<'
|
events: '<?',
|
||||||
},
|
exclusions: '<?'
|
||||||
require: {
|
|
||||||
card: '^vnZoneCard'
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
Prices: Precios
|
|
||||||
Edit price: Modificar precio
|
|
||||||
Only this day: Solo este día
|
|
||||||
From this day: A partir de este día
|
|
||||||
All days: Todos los días
|
|
||||||
There's no delivery for this day: No hay reparto para este día
|
|
|
@ -1,7 +1,13 @@
|
||||||
vn-calendar:nth-child(2n + 1) {
|
@import "variables";
|
||||||
border-right:1px solid #ddd
|
|
||||||
}
|
|
||||||
|
|
||||||
.calendarControlsHeader {
|
vn-zone-calendar {
|
||||||
justify-content: space-between;
|
vn-calendar .day {
|
||||||
|
&.primary .day-number {
|
||||||
|
background-color: $color-success;
|
||||||
|
}
|
||||||
|
&.excluded .day-number {
|
||||||
|
background-color: $color-alert;
|
||||||
|
color: $color-font-dark;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,7 +1,5 @@
|
||||||
<vn-main-block>
|
|
||||||
<vn-side-menu side="left">
|
<vn-side-menu side="left">
|
||||||
<vn-zone-descriptor zone="$ctrl.zone"></vn-zone-descriptor>
|
<vn-zone-descriptor zone="$ctrl.zone"></vn-zone-descriptor>
|
||||||
<vn-left-menu></vn-left-menu>
|
<vn-left-menu></vn-left-menu>
|
||||||
</vn-side-menu>
|
</vn-side-menu>
|
||||||
<div class="content-block" ui-view></div>
|
<div class="content-block" ui-view></div>
|
||||||
</vn-main-block>
|
|
||||||
|
|
|
@ -12,10 +12,10 @@ class Controller {
|
||||||
|
|
||||||
getCard() {
|
getCard() {
|
||||||
let filter = {
|
let filter = {
|
||||||
include: [
|
include: {
|
||||||
{relation: 'warehouse', fields: ['name']},
|
relation: 'agencyMode',
|
||||||
{relation: 'agencyMode', fields: ['name']}
|
scope: {fields: ['name']}
|
||||||
]
|
}
|
||||||
};
|
};
|
||||||
let json = encodeURIComponent(JSON.stringify(filter));
|
let json = encodeURIComponent(JSON.stringify(filter));
|
||||||
let query = `/agency/api/Zones/${this.$stateParams.id}?filter=${json}`;
|
let query = `/agency/api/Zones/${this.$stateParams.id}?filter=${json}`;
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
<div style="margin: 0 auto; max-width: 40em;">
|
||||||
|
<form ng-submit="$ctrl.onSubmit()">
|
||||||
|
<vn-card pad-medium>
|
||||||
|
<vn-vertical>
|
||||||
|
<vn-horizontal>
|
||||||
|
<vn-autocomplete
|
||||||
|
vn-one
|
||||||
|
label="Agency"
|
||||||
|
field="$ctrl.params.agencyModeFk"
|
||||||
|
url="/api/AgencyModes/isActive">
|
||||||
|
</vn-autocomplete>
|
||||||
|
</vn-horizontal>
|
||||||
|
<vn-horizontal>
|
||||||
|
<vn-autocomplete
|
||||||
|
vn-one
|
||||||
|
label="Province"
|
||||||
|
field="$ctrl.params.provinceFk"
|
||||||
|
url="/api/Provinces"
|
||||||
|
fields="['countryFk']"
|
||||||
|
include="'country'"
|
||||||
|
style="margin-right: .5em;">
|
||||||
|
<tpl-item>
|
||||||
|
<div>{{name}}</div>
|
||||||
|
<div style="font-size: .9em; color: gray; line-height: .8em;">
|
||||||
|
{{country.country}}
|
||||||
|
</div>
|
||||||
|
</tpl-item>
|
||||||
|
</vn-autocomplete>
|
||||||
|
<vn-textfield
|
||||||
|
vn-one
|
||||||
|
label="Postcode"
|
||||||
|
model="$ctrl.params.postCode">
|
||||||
|
</vn-textfield>
|
||||||
|
</vn-horizontal>
|
||||||
|
</vn-vertical>
|
||||||
|
</vn-card>
|
||||||
|
<vn-button-bar>
|
||||||
|
<vn-submit label="Send"></vn-submit>
|
||||||
|
</vn-button-bar>
|
||||||
|
</form>
|
||||||
|
<vn-card pad-medium margin-medium-top>
|
||||||
|
<vn-zone-calendar
|
||||||
|
events="events.events"
|
||||||
|
exclusions="events.exclusions">
|
||||||
|
</vn-zone-calendar>
|
||||||
|
</vn-card>
|
||||||
|
</div>
|
|
@ -0,0 +1,22 @@
|
||||||
|
import ngModule from '../module';
|
||||||
|
import './style.scss';
|
||||||
|
|
||||||
|
class Controller {
|
||||||
|
constructor($, $http) {
|
||||||
|
Object.assign(this, {
|
||||||
|
$,
|
||||||
|
$http
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
onSubmit() {
|
||||||
|
this.$http.get(`/api/Zones/getEvents`, {params: this.params})
|
||||||
|
.then(res => this.$.events = res.data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Controller.$inject = ['$scope', '$http'];
|
||||||
|
|
||||||
|
ngModule.component('vnZoneDeliveryDays', {
|
||||||
|
template: require('./index.html'),
|
||||||
|
controller: Controller
|
||||||
|
});
|
|
@ -0,0 +1,12 @@
|
||||||
|
|
||||||
|
vn-zone-delivery-days {
|
||||||
|
vn-zone-calendar {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
|
||||||
|
& > vn-calendar {
|
||||||
|
min-width: 15em;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,147 @@
|
||||||
|
<div class="main-with-right-menu">
|
||||||
|
<div class="vn-list" style="max-width: 30em;">
|
||||||
|
<vn-card ng-if="data.length">
|
||||||
|
<a
|
||||||
|
ng-repeat="row in data"
|
||||||
|
translate-attr="{title: 'Edit'}"
|
||||||
|
ng-click="$ctrl.onEdit(row, $event)"
|
||||||
|
class="vn-list-item">
|
||||||
|
<vn-horizontal>
|
||||||
|
<vn-one>
|
||||||
|
<div
|
||||||
|
ng-if="::row.from && !row.to"
|
||||||
|
margin-small-bottom>
|
||||||
|
{{::row.from | dateTime:'dd/MM/yyyy'}}
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
ng-if="::!row.from || row.to"
|
||||||
|
margin-small-bottom>
|
||||||
|
<span ng-if="row.to">
|
||||||
|
{{::row.from | dateTime:'dd/MM/yyyy'}} - {{::row.to | dateTime:'dd/MM/yyyy'}}
|
||||||
|
</span>
|
||||||
|
<span ng-if="!row.to" translate>
|
||||||
|
Always
|
||||||
|
</span>
|
||||||
|
<span ng-if="row.weekDays">
|
||||||
|
({{::$ctrl.formatWdays(row.weekDays)}})
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<vn-label-value
|
||||||
|
label="Closing"
|
||||||
|
value="{{::row.hour | dateTime:'hh:mm'}}">
|
||||||
|
</vn-label-value>
|
||||||
|
<vn-label-value
|
||||||
|
label="Traveling days"
|
||||||
|
value="{{::row.travelingDays}}">
|
||||||
|
</vn-label-value>
|
||||||
|
<vn-label-value
|
||||||
|
label="Price"
|
||||||
|
value="{{::row.price | currency:'EUR':2}}">
|
||||||
|
</vn-label-value>
|
||||||
|
<vn-label-value
|
||||||
|
label="Bonus"
|
||||||
|
value="{{::row.bonus | currency:'EUR':2}}">
|
||||||
|
</vn-label-value>
|
||||||
|
</vn-one>
|
||||||
|
<vn-horizontal class="buttons">
|
||||||
|
<vn-icon-button
|
||||||
|
icon="delete"
|
||||||
|
translate-attr="{title: 'Delete'}"
|
||||||
|
ng-click="$ctrl.onDelete(row.id, $event)">
|
||||||
|
</vn-icon-button>
|
||||||
|
</vn-horizontal>
|
||||||
|
</vn-horizontal>
|
||||||
|
</a>
|
||||||
|
</vn-card>
|
||||||
|
</div>
|
||||||
|
<vn-bg-title ng-if="!data">
|
||||||
|
<vn-spinner enable="true"></vn-spinner>
|
||||||
|
</vn-bg-title>
|
||||||
|
<vn-bg-title ng-if="data.length == 0" translate>
|
||||||
|
No records found
|
||||||
|
</vn-bg-title>
|
||||||
|
</div>
|
||||||
|
<vn-side-menu side="right">
|
||||||
|
<vn-zone-calendar
|
||||||
|
events="data"
|
||||||
|
exclusions="exclusions">
|
||||||
|
</vn-zone-calendar>
|
||||||
|
</vn-side-menu>
|
||||||
|
<vn-float-button
|
||||||
|
icon="add"
|
||||||
|
translate-attr="{title: 'Add'}"
|
||||||
|
vn-bind="+"
|
||||||
|
ng-click="$ctrl.onCreate()"
|
||||||
|
fixed-bottom-right
|
||||||
|
style="z-index: 10;">
|
||||||
|
</vn-float-button>
|
||||||
|
<vn-dialog
|
||||||
|
vn-id="dialog"
|
||||||
|
on-response="$ctrl.onSave(response)">
|
||||||
|
<tpl-body>
|
||||||
|
<vn-vertical>
|
||||||
|
<vn-radio-group
|
||||||
|
field="$ctrl.eventType"
|
||||||
|
options="$ctrl.options">
|
||||||
|
</vn-radio-group>
|
||||||
|
<div
|
||||||
|
ng-if="$ctrl.eventType != 'day'"
|
||||||
|
class="week-days">
|
||||||
|
<span
|
||||||
|
ng-repeat="wday in $ctrl.wdays"
|
||||||
|
ng-class="{marked: $ctrl.selected.wdays[wday.code]}"
|
||||||
|
ng-click="$ctrl.selected.wdays[wday.code] = !$ctrl.selected.wdays[wday.code]">
|
||||||
|
{{wday.abr}}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<vn-vertical ng-if="$ctrl.eventType == 'day'">
|
||||||
|
<vn-date-picker
|
||||||
|
label="Day"
|
||||||
|
model="$ctrl.selected.from">
|
||||||
|
</vn-date-picker>
|
||||||
|
</vn-vertical>
|
||||||
|
<vn-horizontal ng-if="$ctrl.eventType == 'range'">
|
||||||
|
<vn-date-picker
|
||||||
|
label="From"
|
||||||
|
model="$ctrl.selected.from">
|
||||||
|
</vn-date-picker>
|
||||||
|
<vn-date-picker
|
||||||
|
label="To"
|
||||||
|
model="$ctrl.selected.to">
|
||||||
|
</vn-date-picker>
|
||||||
|
</vn-horizontal>
|
||||||
|
<vn-input-time
|
||||||
|
label="Closing"
|
||||||
|
model="$ctrl.selected.hour">
|
||||||
|
</vn-input-time>
|
||||||
|
<vn-input-number
|
||||||
|
label="Traveling days"
|
||||||
|
model="$ctrl.selected.travelingDays"
|
||||||
|
min="0"
|
||||||
|
step="1">
|
||||||
|
</vn-input-number>
|
||||||
|
<vn-input-number
|
||||||
|
label="Price"
|
||||||
|
model="$ctrl.selected.price"
|
||||||
|
min="0"
|
||||||
|
step="0.01">
|
||||||
|
</vn-input-number>
|
||||||
|
<vn-input-number
|
||||||
|
label="Bonus"
|
||||||
|
model="$ctrl.selected.bonus"
|
||||||
|
min="0"
|
||||||
|
step="0.01">
|
||||||
|
</vn-input-number>
|
||||||
|
</vn-vertical>
|
||||||
|
</tpl-body>
|
||||||
|
<tpl-buttons>
|
||||||
|
<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)">
|
||||||
|
</vn-confirm>
|
|
@ -0,0 +1,174 @@
|
||||||
|
import ngModule from '../module';
|
||||||
|
import './style.scss';
|
||||||
|
|
||||||
|
class Controller {
|
||||||
|
constructor($, _, $http, $stateParams) {
|
||||||
|
Object.assign(this, {
|
||||||
|
$,
|
||||||
|
_,
|
||||||
|
$http
|
||||||
|
});
|
||||||
|
|
||||||
|
this.wdays = [
|
||||||
|
{
|
||||||
|
code: 'mon',
|
||||||
|
name: 'Monday'
|
||||||
|
}, {
|
||||||
|
code: 'tue',
|
||||||
|
name: 'Tuesday'
|
||||||
|
}, {
|
||||||
|
code: 'wed',
|
||||||
|
name: 'Wednesday'
|
||||||
|
}, {
|
||||||
|
code: 'thu',
|
||||||
|
name: 'Thursday'
|
||||||
|
}, {
|
||||||
|
code: 'fri',
|
||||||
|
name: 'Friday'
|
||||||
|
}, {
|
||||||
|
code: 'sat',
|
||||||
|
name: 'Saturday'
|
||||||
|
}, {
|
||||||
|
code: 'sun',
|
||||||
|
name: 'Sunday'
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
this.abrWdays = {};
|
||||||
|
for (let wday of this.wdays) {
|
||||||
|
let locale = _.instant(wday.name);
|
||||||
|
this.abrWdays[wday.code] = locale.substr(0, 3);
|
||||||
|
wday.abr = locale.substr(0, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.options = [
|
||||||
|
{
|
||||||
|
label: 'Specific day',
|
||||||
|
value: 'day'
|
||||||
|
}, {
|
||||||
|
label: 'Range of dates',
|
||||||
|
value: 'range'
|
||||||
|
}, {
|
||||||
|
label: 'Always',
|
||||||
|
value: 'always'
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
this.$http.get(`/api/Zones/${$stateParams.id}/exclusions`)
|
||||||
|
.then(res => this.$.exclusions = res.data);
|
||||||
|
|
||||||
|
this.path = `/api/Zones/${$stateParams.id}/events`;
|
||||||
|
this.refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
refresh() {
|
||||||
|
this.$http.get(this.path)
|
||||||
|
.then(res => this.$.data = res.data);
|
||||||
|
}
|
||||||
|
|
||||||
|
formatWdays(weekDays) {
|
||||||
|
if (!weekDays) return;
|
||||||
|
|
||||||
|
let abrWdays = [];
|
||||||
|
for (let wday of weekDays.split(','))
|
||||||
|
abrWdays.push(this.abrWdays[wday]);
|
||||||
|
|
||||||
|
return abrWdays.length < 7
|
||||||
|
? abrWdays.join(', ')
|
||||||
|
: this._.instant('Everyday');
|
||||||
|
}
|
||||||
|
|
||||||
|
onEdit(row, event) {
|
||||||
|
if (event.defaultPrevented) return;
|
||||||
|
|
||||||
|
this.isNew = false;
|
||||||
|
|
||||||
|
if (row.from && !row.to)
|
||||||
|
this.eventType = 'day';
|
||||||
|
else if (!row.from)
|
||||||
|
this.eventType = 'always';
|
||||||
|
else
|
||||||
|
this.eventType = 'range';
|
||||||
|
|
||||||
|
this.selected = angular.copy(row);
|
||||||
|
this.selected.wdays = {};
|
||||||
|
|
||||||
|
if (row.weekDays) {
|
||||||
|
let weekDays = row.weekDays.split(',');
|
||||||
|
for (let day of weekDays)
|
||||||
|
this.selected.wdays[day] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.$.dialog.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
onCreate() {
|
||||||
|
this.isNew = true;
|
||||||
|
this.eventType = 'day';
|
||||||
|
this.selected = {};
|
||||||
|
this.$.dialog.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
onSave(response) {
|
||||||
|
if (response != 'ACCEPT') return;
|
||||||
|
|
||||||
|
let selected = this.selected;
|
||||||
|
|
||||||
|
if (this.eventType == 'always') {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
onDelete(id, event) {
|
||||||
|
event.preventDefault();
|
||||||
|
this.$.confirm.show();
|
||||||
|
this.deleteId = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
delete(response) {
|
||||||
|
if (response != 'ACCEPT') return;
|
||||||
|
if (!this.deleteId) return;
|
||||||
|
this.$http.delete(`${this.path}/${this.deleteId}`)
|
||||||
|
.then(() => {
|
||||||
|
this.refresh();
|
||||||
|
this.deleteId = null;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Controller.$inject = ['$scope', '$translate', '$http', '$stateParams'];
|
||||||
|
|
||||||
|
ngModule.component('vnZoneEvents', {
|
||||||
|
template: require('./index.html'),
|
||||||
|
controller: Controller
|
||||||
|
});
|
|
@ -0,0 +1,27 @@
|
||||||
|
@import "effects";
|
||||||
|
|
||||||
|
vn-zone-events {
|
||||||
|
.week-days {
|
||||||
|
margin-top: $margin-small;
|
||||||
|
margin-bottom: $margin-medium;
|
||||||
|
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;
|
||||||
|
|
||||||
|
&.marked {
|
||||||
|
background: $color-main;
|
||||||
|
color: $color-font-dark;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,53 @@
|
||||||
|
<vn-card
|
||||||
|
ng-if="data.length"
|
||||||
|
style="max-width: 25em; margin: 0 auto;">
|
||||||
|
<vn-table>
|
||||||
|
<vn-tbody>
|
||||||
|
<vn-tr ng-repeat="row in data | orderBy:'day'">
|
||||||
|
<vn-td>{{::row.day | dateTime:'dd/MM/yyyy'}}</vn-td>
|
||||||
|
<vn-td style="width: 1px; text-align: center">
|
||||||
|
<vn-icon-button
|
||||||
|
icon="delete"
|
||||||
|
translate-attr="{title: 'Delete'}"
|
||||||
|
ng-click="$ctrl.onDelete($index)">
|
||||||
|
</vn-icon-button>
|
||||||
|
</vn-td>
|
||||||
|
</vn-tr>
|
||||||
|
</vn-tbody>
|
||||||
|
</vn-table>
|
||||||
|
</vn-card>
|
||||||
|
<vn-bg-title ng-if="!data">
|
||||||
|
<vn-spinner enable="true"></vn-spinner>
|
||||||
|
</vn-bg-title>
|
||||||
|
<vn-bg-title ng-if="data.length == 0" translate>
|
||||||
|
No records found
|
||||||
|
</vn-bg-title>
|
||||||
|
<vn-float-button
|
||||||
|
icon="add"
|
||||||
|
translate-attr="{title: 'Add'}"
|
||||||
|
vn-bind="+"
|
||||||
|
ng-click="$ctrl.onCreate()"
|
||||||
|
fixed-bottom-right>
|
||||||
|
</vn-float-button>
|
||||||
|
<vn-dialog
|
||||||
|
vn-id="dialog"
|
||||||
|
on-response="$ctrl.onSave(response)">
|
||||||
|
<tpl-body>
|
||||||
|
<vn-vertical>
|
||||||
|
<vn-date-picker
|
||||||
|
label="Day"
|
||||||
|
model="$ctrl.selected.day">
|
||||||
|
</vn-date-picker>
|
||||||
|
</vn-vertical>
|
||||||
|
</tpl-body>
|
||||||
|
<tpl-buttons>
|
||||||
|
<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)">
|
||||||
|
</vn-confirm>
|
|
@ -0,0 +1,60 @@
|
||||||
|
import ngModule from '../module';
|
||||||
|
|
||||||
|
class Controller {
|
||||||
|
constructor($, $http, $stateParams) {
|
||||||
|
Object.assign(this, {
|
||||||
|
$,
|
||||||
|
$http
|
||||||
|
});
|
||||||
|
|
||||||
|
this.path = `/api/Zones/${$stateParams.id}/exclusions`;
|
||||||
|
this.refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
refresh() {
|
||||||
|
this.$http.get(this.path)
|
||||||
|
.then(res => this.$.data = res.data);
|
||||||
|
}
|
||||||
|
|
||||||
|
onCreate() {
|
||||||
|
this.isNew = true;
|
||||||
|
this.selected = {};
|
||||||
|
this.$.dialog.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
onSave(response) {
|
||||||
|
if (response != 'ACCEPT') return;
|
||||||
|
|
||||||
|
this.$http.post(this.path, this.selected)
|
||||||
|
.then(() => {
|
||||||
|
this.selected = null;
|
||||||
|
this.isNew = null;
|
||||||
|
this.$.dialog.hide();
|
||||||
|
this.refresh();
|
||||||
|
});
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
onDelete(index) {
|
||||||
|
this.$.confirm.show();
|
||||||
|
this.deleteIndex = index;
|
||||||
|
}
|
||||||
|
|
||||||
|
delete(response) {
|
||||||
|
if (response != 'ACCEPT') return;
|
||||||
|
let id = this.$.data[this.deleteIndex].id;
|
||||||
|
if (!id) return;
|
||||||
|
this.$http.delete(`${this.path}/${id}`)
|
||||||
|
.then(() => {
|
||||||
|
this.$.data.splice(this.deleteIndex, 1);
|
||||||
|
this.deleteIndex = null;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Controller.$inject = ['$scope', '$http', '$stateParams'];
|
||||||
|
|
||||||
|
ngModule.component('vnZoneExclusions', {
|
||||||
|
template: require('./index.html'),
|
||||||
|
controller: Controller
|
||||||
|
});
|
|
@ -1,12 +1,17 @@
|
||||||
export * from './module';
|
export * from './module';
|
||||||
|
|
||||||
|
import './main';
|
||||||
import './index/';
|
import './index/';
|
||||||
|
import './delivery-days';
|
||||||
import './summary';
|
import './summary';
|
||||||
import './card';
|
import './card';
|
||||||
import './descriptor';
|
import './descriptor';
|
||||||
import './search-panel';
|
import './search-panel';
|
||||||
import './create';
|
import './create';
|
||||||
import './basic-data';
|
import './basic-data';
|
||||||
import './location';
|
import './warehouses';
|
||||||
import './location/calendar';
|
import './events';
|
||||||
|
import './calendar';
|
||||||
|
import './exclusions';
|
||||||
|
import './location';
|
||||||
import './calendar';
|
import './calendar';
|
||||||
|
|
|
@ -18,27 +18,28 @@
|
||||||
</vn-searchbar>
|
</vn-searchbar>
|
||||||
</vn-card>
|
</vn-card>
|
||||||
</div>
|
</div>
|
||||||
<vn-card margin-medium-v margin-huge-bottom>
|
<vn-card margin-medium-v margin-huge-bottom compact>
|
||||||
<vn-table model="model">
|
<vn-table model="model">
|
||||||
<vn-thead>
|
<vn-thead>
|
||||||
<vn-tr>
|
<vn-tr>
|
||||||
<vn-th field="id" number>Id</vn-th>
|
<vn-th field="id" number>Id</vn-th>
|
||||||
<vn-th field="name" expand>Name</vn-th>
|
<vn-th field="name" expand>Name</vn-th>
|
||||||
<vn-th field="agencyModeFk">Agency</vn-th>
|
<vn-th field="agencyModeFk">Agency</vn-th>
|
||||||
<vn-th field="warehouseFK">Warehouse</vn-th>
|
<vn-th field="hour" shrink>Closing</vn-th>
|
||||||
<vn-th field="hour" vn-tooltip="ETD" default-order="DESC" shrink>Hour</vn-th>
|
<vn-th field="price" number>Price</vn-th>
|
||||||
<vn-th field="price" number shrink>Price</vn-th>
|
|
||||||
<vn-th shrink></vn-th>
|
<vn-th shrink></vn-th>
|
||||||
</vn-tr>
|
</vn-tr>
|
||||||
</vn-thead>
|
</vn-thead>
|
||||||
<vn-tbody>
|
<vn-tbody>
|
||||||
<vn-tr ng-repeat="zone in zones" ui-sref="zone.card.location({id: zone.id})" class="clickable searchResult">
|
<vn-tr
|
||||||
|
ng-repeat="zone in zones"
|
||||||
|
ui-sref="zone.card.location({id: zone.id})"
|
||||||
|
class="clickable searchResult">
|
||||||
<vn-td number>{{::zone.id}}</vn-td>
|
<vn-td number>{{::zone.id}}</vn-td>
|
||||||
<vn-td expand>{{::zone.name}}</vn-td>
|
<vn-td expand>{{::zone.name}}</vn-td>
|
||||||
<vn-td>{{::zone.agencyMode.name}}</vn-td>
|
<vn-td>{{::zone.agencyMode.name}}</vn-td>
|
||||||
<vn-td>{{::zone.warehouse.name}}</vn-td>
|
|
||||||
<vn-td shrink>{{::zone.hour | dateTime: 'HH:mm'}}</vn-td>
|
<vn-td shrink>{{::zone.hour | dateTime: 'HH:mm'}}</vn-td>
|
||||||
<vn-td number shrink>{{::zone.price | currency: 'EUR':2}}</vn-td>
|
<vn-td number>{{::zone.price | currency: 'EUR':2}}</vn-td>
|
||||||
<vn-td shrink>
|
<vn-td shrink>
|
||||||
<vn-horizontal class="buttons">
|
<vn-horizontal class="buttons">
|
||||||
<vn-icon-button
|
<vn-icon-button
|
||||||
|
@ -68,15 +69,16 @@
|
||||||
<vn-zone-summary zone="$ctrl.selectedZone"></vn-zone-summary>
|
<vn-zone-summary zone="$ctrl.selectedZone"></vn-zone-summary>
|
||||||
</tpl-body>
|
</tpl-body>
|
||||||
</vn-dialog>
|
</vn-dialog>
|
||||||
<!-- Clone confirmation -->
|
|
||||||
<vn-confirm
|
<vn-confirm
|
||||||
vn-id="clone"
|
vn-id="clone"
|
||||||
on-response="$ctrl.onCloneAccept(response)"
|
on-response="$ctrl.onCloneAccept(response)"
|
||||||
question="Do you want to clone this zone?"
|
question="Do you want to clone this zone?"
|
||||||
message="All it's properties will be copied">
|
message="All it's properties will be copied">
|
||||||
</vn-confirm>
|
</vn-confirm>
|
||||||
<!-- End clone confirmation -->
|
<a ui-sref="zone.create"
|
||||||
<a ui-sref="zone.create" vn-tooltip="New zone" vn-bind="+" fixed-bottom-right>
|
vn-tooltip="New zone"
|
||||||
|
vn-bind="+"
|
||||||
|
fixed-bottom-right>
|
||||||
<vn-float-button icon="add"
|
<vn-float-button icon="add"
|
||||||
vn-acl="deliveryBoss"
|
vn-acl="deliveryBoss"
|
||||||
vn-acl-action="remove">
|
vn-acl-action="remove">
|
||||||
|
|
|
@ -6,10 +6,10 @@ export default class Controller {
|
||||||
this.$http = $http;
|
this.$http = $http;
|
||||||
this.$state = $state;
|
this.$state = $state;
|
||||||
this.filter = {
|
this.filter = {
|
||||||
include: [
|
include: {
|
||||||
{relation: 'agencyMode', fields: ['name']},
|
relation: 'agencyMode',
|
||||||
{relation: 'warehouse', fields: ['name']}
|
scope: {fields: ['name']}
|
||||||
]
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,8 @@ export default class Controller {
|
||||||
return /^\d+$/.test(value)
|
return /^\d+$/.test(value)
|
||||||
? {id: value}
|
? {id: value}
|
||||||
: {name: {like: `%${value}%`}};
|
: {name: {like: `%${value}%`}};
|
||||||
case 'warehouseFk':
|
case 'name':
|
||||||
|
return {[param]: {like: `%${value}%`}};
|
||||||
case 'agencyModeFk':
|
case 'agencyModeFk':
|
||||||
return {[param]: value};
|
return {[param]: value};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
Agency: Agencia
|
Agency: Agencia
|
||||||
|
Warehouses: Almacenes
|
||||||
|
Week days: Días de la semana
|
||||||
|
Exceptions: Excepciones
|
||||||
|
Exclusions: Exclusiones
|
||||||
Warehouse: Almacén
|
Warehouse: Almacén
|
||||||
Hour: Hora (ETD)
|
Hour: Hora
|
||||||
ETD: Tiempo de salida estimado
|
|
||||||
Price: Precio
|
Price: Precio
|
||||||
Locations: Localizaciones
|
Locations: Localizaciones
|
||||||
This zone will be removed: La zona será eliminada
|
This zone will be removed: La zona será eliminada
|
||||||
|
@ -11,3 +14,13 @@ New zone: Nueva zona
|
||||||
Volumetric: Volumétrico
|
Volumetric: Volumétrico
|
||||||
Clone: Clonar
|
Clone: Clonar
|
||||||
Search zone by id or name: Buscar zonas por identificador o nombre
|
Search zone by id or name: Buscar zonas por identificador o nombre
|
||||||
|
From: Desde
|
||||||
|
To: Hasta
|
||||||
|
Closing: Cierre
|
||||||
|
Specific day: Día específico
|
||||||
|
Range of dates: Rango de fechas
|
||||||
|
Always: Siempre
|
||||||
|
Everyday: Todos los días
|
||||||
|
Delivery days: Días de entrega
|
||||||
|
Province: Provincia
|
||||||
|
Postcode: Código postal
|
||||||
|
|
|
@ -1,23 +0,0 @@
|
||||||
<vn-crud-model
|
|
||||||
vn-id="model"
|
|
||||||
url="/agency/api/ZoneCalendars"
|
|
||||||
fields="['zoneFk', 'delivered']"
|
|
||||||
link="{zoneFk: $ctrl.$stateParams.id}"
|
|
||||||
data="$ctrl.data"
|
|
||||||
primary-key="zoneFk"
|
|
||||||
auto-load="true">
|
|
||||||
</vn-crud-model>
|
|
||||||
<vn-calendar pad-small vn-id="stMonth" skip="2"
|
|
||||||
data="$ctrl.events"
|
|
||||||
on-selection="$ctrl.onSelection(values, stMonth)"
|
|
||||||
on-move-next="$ctrl.onMoveNext(ndMonth)"
|
|
||||||
on-move-previous="$ctrl.onMovePrevious(ndMonth)"
|
|
||||||
vn-acl="deliveryBoss">
|
|
||||||
</vn-calendar>
|
|
||||||
<vn-calendar pad-small vn-id="ndMonth" skip="2"
|
|
||||||
data="$ctrl.events"
|
|
||||||
display-controls="false"
|
|
||||||
on-selection="$ctrl.onSelection(values, ndMonth)"
|
|
||||||
default-date="$ctrl.ndMonthDate"
|
|
||||||
vn-acl="deliveryBoss">
|
|
||||||
</vn-calendar>
|
|
|
@ -1,150 +0,0 @@
|
||||||
import ngModule from '../module';
|
|
||||||
|
|
||||||
class Controller {
|
|
||||||
constructor($element, $scope, $stateParams, $http) {
|
|
||||||
this.$element = $element;
|
|
||||||
this.$stateParams = $stateParams;
|
|
||||||
this.$scope = $scope;
|
|
||||||
this.$http = $http;
|
|
||||||
this.stMonthDate = new Date();
|
|
||||||
this.ndMonthDate = new Date();
|
|
||||||
this.ndMonthDate.setMonth(this.ndMonthDate.getMonth() + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
$postLink() {
|
|
||||||
this.stMonth = this.$scope.stMonth;
|
|
||||||
this.ndMonth = this.$scope.ndMonth;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Disabled until implementation
|
|
||||||
// of holidays by node
|
|
||||||
/* get zone() {
|
|
||||||
return this._zone;
|
|
||||||
}
|
|
||||||
|
|
||||||
set zone(value) {
|
|
||||||
this._zone = value;
|
|
||||||
|
|
||||||
if (!value) return;
|
|
||||||
|
|
||||||
let query = '/agency/api/LabourHolidays/getByWarehouse';
|
|
||||||
this.$http.get(query, {params: {warehouseFk: value.warehouseFk}}).then(res => {
|
|
||||||
if (!res.data) return;
|
|
||||||
const events = [];
|
|
||||||
res.data.forEach(holiday => {
|
|
||||||
events.push({
|
|
||||||
date: holiday.dated,
|
|
||||||
className: 'red',
|
|
||||||
title: holiday.description || holiday.name,
|
|
||||||
isRemovable: false
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
this.events = this.events.concat(events);
|
|
||||||
});
|
|
||||||
} */
|
|
||||||
|
|
||||||
get data() {
|
|
||||||
return this._data;
|
|
||||||
}
|
|
||||||
|
|
||||||
set data(value) {
|
|
||||||
this._data = value;
|
|
||||||
|
|
||||||
if (!value) return;
|
|
||||||
const events = [];
|
|
||||||
value.forEach(event => {
|
|
||||||
events.push({
|
|
||||||
name: 'Has delivery',
|
|
||||||
dated: event.delivered,
|
|
||||||
style: {backgroundColor: '#a3d131'}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
this.events = events;
|
|
||||||
}
|
|
||||||
|
|
||||||
onSelection(values, calendar) {
|
|
||||||
let totalEvents = 0;
|
|
||||||
values.forEach(day => {
|
|
||||||
const exists = calendar.events.findIndex(event => {
|
|
||||||
return event.dated >= day.dated && event.dated <= day.dated
|
|
||||||
&& event.isRemovable;
|
|
||||||
});
|
|
||||||
|
|
||||||
if (exists > -1) totalEvents++;
|
|
||||||
});
|
|
||||||
|
|
||||||
if (totalEvents > (values.length / 2))
|
|
||||||
this.removeEvents(calendar, values);
|
|
||||||
else
|
|
||||||
this.insertEvents(calendar, values);
|
|
||||||
}
|
|
||||||
|
|
||||||
insertEvents(calendar, days) {
|
|
||||||
days.forEach(day => {
|
|
||||||
const event = calendar.events.find(event => {
|
|
||||||
return event.dated >= day.dated && event.dated <= day.dated;
|
|
||||||
});
|
|
||||||
|
|
||||||
if (event) return false;
|
|
||||||
|
|
||||||
this.$scope.model.insert({
|
|
||||||
zoneFk: this.zone.id,
|
|
||||||
delivered: day.dated,
|
|
||||||
price: this.zone.price,
|
|
||||||
bonus: this.zone.bonus
|
|
||||||
});
|
|
||||||
|
|
||||||
calendar.addEvent({
|
|
||||||
name: 'Has delivery',
|
|
||||||
dated: day.dated,
|
|
||||||
style: {backgroundColor: '#a3d131'}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
this.$scope.model.save().then(() => {
|
|
||||||
this.events = calendar.events;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
removeEvents(calendar, days) {
|
|
||||||
let dates = [];
|
|
||||||
days.forEach(day => {
|
|
||||||
const event = calendar.events.find(event => {
|
|
||||||
return event.dated >= day.dated && event.dated <= day.dated;
|
|
||||||
});
|
|
||||||
|
|
||||||
if (event && !event.isRemovable)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
dates.push(day.dated);
|
|
||||||
|
|
||||||
calendar.removeEvent(day.dated);
|
|
||||||
});
|
|
||||||
|
|
||||||
if (dates.length == 0) return;
|
|
||||||
const params = {zoneFk: this.zone.id, dates};
|
|
||||||
this.$http.post('/agency/api/zoneCalendars/removeByDate', params).then(() => {
|
|
||||||
this.events = calendar.events;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
onMoveNext(calendar) {
|
|
||||||
calendar.moveNext(2);
|
|
||||||
}
|
|
||||||
|
|
||||||
onMovePrevious(calendar) {
|
|
||||||
calendar.movePrevious(2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Controller.$inject = ['$element', '$scope', '$stateParams', '$http'];
|
|
||||||
|
|
||||||
ngModule.component('vnZoneLocationCalendar', {
|
|
||||||
template: require('./calendar.html'),
|
|
||||||
controller: Controller,
|
|
||||||
bindings: {
|
|
||||||
zone: '<'
|
|
||||||
}
|
|
||||||
});
|
|
|
@ -3,12 +3,14 @@
|
||||||
url="/api/Zones/{{$ctrl.$stateParams.id}}/getLeaves"
|
url="/api/Zones/{{$ctrl.$stateParams.id}}/getLeaves"
|
||||||
auto-load="false">
|
auto-load="false">
|
||||||
</vn-crud-model>
|
</vn-crud-model>
|
||||||
<div class="main-with-right-menu">
|
<div compact>
|
||||||
<vn-card compact pad-large>
|
<vn-card pad-large-h>
|
||||||
<vn-searchbar
|
<vn-searchbar
|
||||||
on-search="$ctrl.onSearch($params)"
|
on-search="$ctrl.onSearch($params)"
|
||||||
vn-focus>
|
vn-focus>
|
||||||
</vn-searchbar>
|
</vn-searchbar>
|
||||||
|
</vn-card>
|
||||||
|
<vn-card pad-large margin-medium-top>
|
||||||
<vn-treeview
|
<vn-treeview
|
||||||
vn-id="treeview"
|
vn-id="treeview"
|
||||||
model="model"
|
model="model"
|
||||||
|
@ -17,8 +19,4 @@
|
||||||
selectable="true">
|
selectable="true">
|
||||||
</vn-treeview>
|
</vn-treeview>
|
||||||
</vn-card>
|
</vn-card>
|
||||||
<vn-side-menu side="right">
|
|
||||||
<vn-zone-location-calendar zone="::$ctrl.zone">
|
|
||||||
</vn-zone-location-calendar>
|
|
||||||
</vn-side-menu>
|
|
||||||
</div>
|
</div>
|
|
@ -0,0 +1,14 @@
|
||||||
|
<vn-main-block>
|
||||||
|
<vn-side-menu side="left">
|
||||||
|
<ul class="menu">
|
||||||
|
<li>
|
||||||
|
<a translate ui-sref="zone.index">Zones</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<a translate ui-sref="zone.deliveryDays">Delivery days</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</vn-side-menu>
|
||||||
|
<div class="content-block" ui-view></div>
|
||||||
|
</vn-main-block>
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
import ngModule from '../module';
|
||||||
|
import './style.scss';
|
||||||
|
|
||||||
|
ngModule.component('vnZone', {
|
||||||
|
template: require('./index.html')
|
||||||
|
});
|
|
@ -0,0 +1,18 @@
|
||||||
|
@import "effects";
|
||||||
|
|
||||||
|
vn-zone {
|
||||||
|
ul.menu {
|
||||||
|
list-style-type: none;
|
||||||
|
padding: 0;
|
||||||
|
padding-top: $pad-medium;
|
||||||
|
margin: 0;
|
||||||
|
font-size: inherit;
|
||||||
|
|
||||||
|
& > li > a {
|
||||||
|
@extend %clickable;
|
||||||
|
display: block;
|
||||||
|
color: inherit;
|
||||||
|
padding: .6em 2em;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -7,36 +7,39 @@
|
||||||
"menu": [
|
"menu": [
|
||||||
{"state": "zone.card.basicData", "icon": "settings"},
|
{"state": "zone.card.basicData", "icon": "settings"},
|
||||||
{"state": "zone.card.location", "icon": "my_location"},
|
{"state": "zone.card.location", "icon": "my_location"},
|
||||||
{"state": "zone.card.calendar", "icon": "icon-deliveryprices"}
|
{"state": "zone.card.warehouses", "icon": "home"},
|
||||||
|
{"state": "zone.card.events", "icon": "today"},
|
||||||
|
{"state": "zone.card.exclusions", "icon": "block"}
|
||||||
],
|
],
|
||||||
"routes": [
|
"routes": [
|
||||||
{
|
{
|
||||||
"url": "/zone",
|
"url": "/zone",
|
||||||
"state": "zone",
|
"state": "zone",
|
||||||
"abstract": true,
|
"abstract": true,
|
||||||
"component": "ui-view",
|
"component": "vn-zone",
|
||||||
"description": "Zones"
|
"description": "Zones"
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
"url": "/index?q",
|
"url": "/index?q",
|
||||||
"state": "zone.index",
|
"state": "zone.index",
|
||||||
"component": "vn-zone-index",
|
"component": "vn-zone-index",
|
||||||
"description": "Zones"
|
"description": "Zones"
|
||||||
},
|
}, {
|
||||||
{
|
"url": "/delivery-days",
|
||||||
|
"state": "zone.deliveryDays",
|
||||||
|
"component": "vn-zone-delivery-days",
|
||||||
|
"description": "Delivery days"
|
||||||
|
}, {
|
||||||
"url": "/create",
|
"url": "/create",
|
||||||
"state": "zone.create",
|
"state": "zone.create",
|
||||||
"component": "vn-zone-create",
|
"component": "vn-zone-create",
|
||||||
"description": "New zone"
|
"description": "New zone"
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
"url": "/:id",
|
"url": "/:id",
|
||||||
"state": "zone.card",
|
"state": "zone.card",
|
||||||
"component": "vn-zone-card",
|
"component": "vn-zone-card",
|
||||||
"abstract": true,
|
"abstract": true,
|
||||||
"description": "Detail"
|
"description": "Detail"
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
"url": "/summary",
|
"url": "/summary",
|
||||||
"state": "zone.card.summary",
|
"state": "zone.card.summary",
|
||||||
"component": "vn-zone-summary",
|
"component": "vn-zone-summary",
|
||||||
|
@ -44,8 +47,7 @@
|
||||||
"params": {
|
"params": {
|
||||||
"zone": "$ctrl.zone"
|
"zone": "$ctrl.zone"
|
||||||
}
|
}
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
"url": "/basic-data",
|
"url": "/basic-data",
|
||||||
"state": "zone.card.basicData",
|
"state": "zone.card.basicData",
|
||||||
"component": "vn-zone-basic-data",
|
"component": "vn-zone-basic-data",
|
||||||
|
@ -53,8 +55,22 @@
|
||||||
"params": {
|
"params": {
|
||||||
"zone": "$ctrl.zone"
|
"zone": "$ctrl.zone"
|
||||||
}
|
}
|
||||||
},
|
}, {
|
||||||
{
|
"url": "/warehouses",
|
||||||
|
"state": "zone.card.warehouses",
|
||||||
|
"component": "vn-zone-warehouses",
|
||||||
|
"description": "Warehouses"
|
||||||
|
}, {
|
||||||
|
"url": "/events",
|
||||||
|
"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",
|
"url": "/location?q",
|
||||||
"state": "zone.card.location",
|
"state": "zone.card.location",
|
||||||
"component": "vn-zone-location",
|
"component": "vn-zone-location",
|
||||||
|
@ -62,15 +78,6 @@
|
||||||
"params": {
|
"params": {
|
||||||
"zone": "$ctrl.zone"
|
"zone": "$ctrl.zone"
|
||||||
}
|
}
|
||||||
},
|
|
||||||
{
|
|
||||||
"url": "/calendar",
|
|
||||||
"state": "zone.card.calendar",
|
|
||||||
"component": "vn-zone-calendar",
|
|
||||||
"description": "Prices",
|
|
||||||
"params": {
|
|
||||||
"zone": "$ctrl.zone"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
|
@ -21,15 +21,7 @@
|
||||||
vn-one
|
vn-one
|
||||||
label="Agency"
|
label="Agency"
|
||||||
field="filter.agencyModeFk"
|
field="filter.agencyModeFk"
|
||||||
url="/agency/api/AgencyModes/isActive"
|
url="/api/AgencyModes/isActive"
|
||||||
show-field="name"
|
|
||||||
value-field="id">
|
|
||||||
</vn-autocomplete>
|
|
||||||
<vn-autocomplete
|
|
||||||
vn-one
|
|
||||||
label="Warehouse"
|
|
||||||
field="filter.warehouseFk"
|
|
||||||
url="/agency/api/Warehouses"
|
|
||||||
show-field="name"
|
show-field="name"
|
||||||
value-field="id">
|
value-field="id">
|
||||||
</vn-autocomplete>
|
</vn-autocomplete>
|
||||||
|
|
|
@ -8,9 +8,6 @@
|
||||||
<vn-label-value label="Name"
|
<vn-label-value label="Name"
|
||||||
value="{{$ctrl.summary.name}}">
|
value="{{$ctrl.summary.name}}">
|
||||||
</vn-label-value>
|
</vn-label-value>
|
||||||
<vn-label-value label="Warehouse"
|
|
||||||
value="{{$ctrl.summary.warehouse.name}}">
|
|
||||||
</vn-label-value>
|
|
||||||
<vn-label-value label="Agency"
|
<vn-label-value label="Agency"
|
||||||
value="{{$ctrl.summary.agencyMode.name}}">
|
value="{{$ctrl.summary.agencyMode.name}}">
|
||||||
</vn-label-value>
|
</vn-label-value>
|
||||||
|
|
|
@ -19,10 +19,7 @@ class Controller {
|
||||||
|
|
||||||
getSummary() {
|
getSummary() {
|
||||||
let filter = {
|
let filter = {
|
||||||
include: [
|
include: {relation: 'agencyMode', fields: ['name']},
|
||||||
{relation: 'warehouse', fields: ['name']},
|
|
||||||
{relation: 'agencyMode', fields: ['name']}
|
|
||||||
],
|
|
||||||
where: {id: this.zone.id}
|
where: {id: this.zone.id}
|
||||||
};
|
};
|
||||||
filter = encodeURIComponent(JSON.stringify((filter)));
|
filter = encodeURIComponent(JSON.stringify((filter)));
|
||||||
|
|
|
@ -0,0 +1,56 @@
|
||||||
|
<vn-card
|
||||||
|
ng-if="data.length"
|
||||||
|
style="max-width: 25em; margin: 0 auto;">
|
||||||
|
<vn-table>
|
||||||
|
<vn-tbody>
|
||||||
|
<vn-tr ng-repeat="row in data | orderBy:'warehouse.name'">
|
||||||
|
<vn-td>{{::row.warehouse.name}}</vn-td>
|
||||||
|
<vn-td style="width: 1px; text-align: center">
|
||||||
|
<vn-icon-button
|
||||||
|
icon="delete"
|
||||||
|
translate-attr="{title: 'Delete'}"
|
||||||
|
ng-click="$ctrl.onDelete($index)">
|
||||||
|
</vn-icon-button>
|
||||||
|
</vn-td>
|
||||||
|
</vn-tr>
|
||||||
|
</vn-tbody>
|
||||||
|
</vn-table>
|
||||||
|
</vn-card>
|
||||||
|
<vn-bg-title ng-if="!data">
|
||||||
|
<vn-spinner enable="true"></vn-spinner>
|
||||||
|
</vn-bg-title>
|
||||||
|
<vn-bg-title ng-if="data.length == 0" translate>
|
||||||
|
No records found
|
||||||
|
</vn-bg-title>
|
||||||
|
<vn-float-button
|
||||||
|
icon="add"
|
||||||
|
translate-attr="{title: 'Add'}"
|
||||||
|
vn-bind="+"
|
||||||
|
ng-click="$ctrl.onCreate()"
|
||||||
|
fixed-bottom-right>
|
||||||
|
</vn-float-button>
|
||||||
|
<vn-dialog
|
||||||
|
vn-id="dialog"
|
||||||
|
on-response="$ctrl.onSave(response)">
|
||||||
|
<tpl-body>
|
||||||
|
<vn-vertical>
|
||||||
|
<vn-autocomplete
|
||||||
|
field="$ctrl.selected.warehouseFk"
|
||||||
|
url="/api/Warehouses"
|
||||||
|
show-field="name"
|
||||||
|
value-field="id"
|
||||||
|
label="Warehouse">
|
||||||
|
</vn-autocomplete>
|
||||||
|
</vn-vertical>
|
||||||
|
</tpl-body>
|
||||||
|
<tpl-buttons>
|
||||||
|
<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)">
|
||||||
|
</vn-confirm>
|
|
@ -0,0 +1,60 @@
|
||||||
|
import ngModule from '../module';
|
||||||
|
|
||||||
|
class Controller {
|
||||||
|
constructor($, _, $http, $stateParams) {
|
||||||
|
Object.assign(this, {
|
||||||
|
$,
|
||||||
|
$http
|
||||||
|
});
|
||||||
|
|
||||||
|
this.path = `/api/Zones/${$stateParams.id}/warehouses`;
|
||||||
|
this.refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
refresh() {
|
||||||
|
let filter = {include: 'warehouse'};
|
||||||
|
this.$http.get(this.path, {params: {filter}})
|
||||||
|
.then(res => this.$.data = res.data);
|
||||||
|
}
|
||||||
|
|
||||||
|
onCreate() {
|
||||||
|
this.selected = {};
|
||||||
|
this.$.dialog.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
onSave(response) {
|
||||||
|
if (response != 'ACCEPT') return;
|
||||||
|
|
||||||
|
this.$http.post(this.path, this.selected)
|
||||||
|
.then(() => {
|
||||||
|
this.selected = null;
|
||||||
|
this.isNew = null;
|
||||||
|
this.$.dialog.hide();
|
||||||
|
this.refresh();
|
||||||
|
});
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
onDelete(index) {
|
||||||
|
this.$.confirm.show();
|
||||||
|
this.deleteIndex = index;
|
||||||
|
}
|
||||||
|
|
||||||
|
delete(response) {
|
||||||
|
if (response != 'ACCEPT') return;
|
||||||
|
let id = this.$.data[this.deleteIndex].id;
|
||||||
|
if (!id) return;
|
||||||
|
this.$http.delete(`${this.path}/${id}`)
|
||||||
|
.then(() => {
|
||||||
|
this.$.data.splice(this.deleteIndex, 1);
|
||||||
|
this.deleteIndex = null;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Controller.$inject = ['$scope', '$translate', '$http', '$stateParams'];
|
||||||
|
|
||||||
|
ngModule.component('vnZoneWarehouses', {
|
||||||
|
template: require('./index.html'),
|
||||||
|
controller: Controller
|
||||||
|
});
|
Loading…
Reference in New Issue