{
- this.addEvent(event);
+ event.dated = new Date(event.dated);
+ event.dated.setHours(0, 0, 0, 0);
+ this.events.push(event);
});
if (this.defaultDate) {
@@ -197,10 +211,10 @@ export default class Calendar extends Component {
const hasEvents = events.length > 0;
if (isCurrentMonth && isSunday && !hasEvents)
- params.style = {color: '#f42121'};
+ params.style = {color: '#999'};
if (isCurrentMonth && isSaturday && !hasEvents)
- params.style = {color: '#666666'};
+ params.style = {color: '#999'};
if (!isCurrentMonth)
params.style = {opacity: '0.5'};
@@ -217,42 +231,6 @@ export default class Calendar extends Component {
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)
*
@@ -261,10 +239,7 @@ export default class Calendar extends Component {
moveNext(skip = 1) {
let next = this.defaultDate.getMonth() + skip;
this.defaultDate.setMonth(next);
- this.defaultDate.setHours(0, 0, 0, 0);
- this.defaultDate.setDate(1);
this.repaint();
-
this.emit('moveNext');
}
@@ -276,12 +251,7 @@ export default class Calendar extends Component {
movePrevious(skip = 1) {
let previous = this.defaultDate.getMonth() - skip;
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.emit('movePrevious');
}
@@ -327,6 +297,14 @@ export default class Calendar extends Component {
};
}
}
+
+ hasEvents() {
+ return false;
+ }
+
+ getClass() {
+ return '';
+ }
}
Calendar.$inject = ['$element', '$scope'];
@@ -341,6 +319,8 @@ ngModule.component('vnCalendar', {
onSelection: '&?',
onMoveNext: '&?',
onMovePrevious: '&?',
+ hasEvents: '&?',
+ getClass: '&?',
displayControls: '',
disabled: '',
skip: ''
diff --git a/front/core/components/calendar/index.spec.js b/front/core/components/calendar/index.spec.js
index 3f9915278..dcb9ab5cf 100644
--- a/front/core/components/calendar/index.spec.js
+++ b/front/core/components/calendar/index.spec.js
@@ -31,54 +31,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()', () => {
it(`should shift to the next n months, then emit a 'moveNext' event`, () => {
spyOn(controller, 'emit');
diff --git a/front/core/components/calendar/style.scss b/front/core/components/calendar/style.scss
index 333bfb428..a8003bb78 100644
--- a/front/core/components/calendar/style.scss
+++ b/front/core/components/calendar/style.scss
@@ -5,7 +5,6 @@ vn-calendar.small {
display: none
}
}
-
vn-calendar {
display: block;
@@ -14,8 +13,6 @@ vn-calendar {
padding: 0.2em 0;
height: 1.5em
}
-
-
.weekdays {
color: $color-font-secondary;
margin-bottom: 0.5em;
@@ -23,11 +20,9 @@ vn-calendar {
font-weight: bold;
font-size: 0.8em;
}
-
.weekdays section {
cursor: pointer
}
-
.weekdays section, .day {
position: relative;
text-align: center;
@@ -35,14 +30,11 @@ vn-calendar {
width: 14.28%;
outline: 0;
}
-
.days {
justify-content: flex-start;
align-items: flex-start;
flex-wrap: wrap;
}
-
-
.day {
.content {
position: absolute;
@@ -51,7 +43,6 @@ vn-calendar {
left: 0;
top: 0
}
-
.day-number {
transition: background-color 0.3s;
text-align:center;
@@ -65,30 +56,24 @@ vn-calendar {
cursor: pointer;
outline: 0
}
-
.day-number:hover {
background-color: lighten($color-font-secondary, 20%);
opacity: 0.8
}
}
-
.day::after {
content: "";
display: block;
padding-top: 100%;
}
-
.day.primary .day-number {
background-color: $color-main;
- color: $color-font-bg;
+ color: $color-font-dark;
}
-
.events {
margin-top: 0.5em;
font-size: 0.6em
}
-
-
.events {
color: $color-font-secondary;
@@ -96,7 +81,6 @@ vn-calendar {
margin-bottom: .1em;
}
}
-
.chip {
background-color: $color-main;
color: $color-font-bg;
@@ -105,15 +89,11 @@ vn-calendar {
padding: 0.3em .8em;
max-width: 5em;
}
-
.day.gray {
.day-number {
color: $color-font-secondary
}
}
-
-
-
.day.sunday {
.day-number {
color: $color-alert;
diff --git a/front/core/locale/es.yml b/front/core/locale/es.yml
index 7d81e4f71..01a17aa48 100644
--- a/front/core/locale/es.yml
+++ b/front/core/locale/es.yml
@@ -51,4 +51,9 @@ Create new one: Crear nuevo
Toggle: Desplegar/Plegar
Check all: Seleccionar todo
Select a file: Selecciona un fichero
-Go up: Ir arriba
\ No newline at end of file
+Edit: Editar
+Edit item: Editar elemento
+No records found: No se han encontrado elementos
+Day: Día
+Days: Días
+Go up: Ir arriba
diff --git a/front/salix/styles/misc.scss b/front/salix/styles/misc.scss
index 5332a38b6..1eef5af2b 100644
--- a/front/salix/styles/misc.scss
+++ b/front/salix/styles/misc.scss
@@ -34,6 +34,13 @@ a, .link {
text-decoration: underline;
}
}
+vn-bg-title {
+ display: block;
+ text-align: center;
+ padding: 1em;
+ color: gray;
+ font-size: 1.3em;
+}
.totalBox {
border: 1px solid #CCC;
text-align: right !important;
diff --git a/front/salix/styles/variables.scss b/front/salix/styles/variables.scss
index 5fd31a8c6..5eccf0418 100644
--- a/front/salix/styles/variables.scss
+++ b/front/salix/styles/variables.scss
@@ -62,6 +62,7 @@ $color-notice-medium: lighten($color-notice, 20%);
$color-notice-light: lighten($color-notice, 35%);
$color-alert-medium: lighten($color-alert, 20%);
$color-alert-light: lighten($color-alert, 35%);
+/**/
// Dark theme
/*
diff --git a/modules/agency/back/methods/zone/getEvents.js b/modules/agency/back/methods/zone/getEvents.js
new file mode 100644
index 000000000..b294222b5
--- /dev/null
+++ b/modules/agency/back/methods/zone/getEvents.js
@@ -0,0 +1,40 @@
+
+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'
+ }
+ ],
+ 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};
+ };
+};
diff --git a/modules/agency/back/model-config.json b/modules/agency/back/model-config.json
index 9019ac246..aded3eb5d 100644
--- a/modules/agency/back/model-config.json
+++ b/modules/agency/back/model-config.json
@@ -14,10 +14,19 @@
"ZoneGeo": {
"dataSource": "vn"
},
+ "ZoneEvent": {
+ "dataSource": "vn"
+ },
+ "ZoneExclusion": {
+ "dataSource": "vn"
+ },
"ZoneCalendar": {
"dataSource": "vn"
},
"ZoneIncluded": {
"dataSource": "vn"
+ },
+ "ZoneWarehouse": {
+ "dataSource": "vn"
}
}
diff --git a/modules/agency/back/models/zone-event.js b/modules/agency/back/models/zone-event.js
new file mode 100644
index 000000000..5b1c183fd
--- /dev/null
+++ b/modules/agency/back/models/zone-event.js
@@ -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`
+ });
+};
diff --git a/modules/agency/back/models/zone-event.json b/modules/agency/back/models/zone-event.json
new file mode 100644
index 000000000..822328dc6
--- /dev/null
+++ b/modules/agency/back/models/zone-event.json
@@ -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"
+ }
+ }
+}
\ No newline at end of file
diff --git a/modules/agency/back/models/zone-exclusion.json b/modules/agency/back/models/zone-exclusion.json
new file mode 100644
index 000000000..79e2f5aae
--- /dev/null
+++ b/modules/agency/back/models/zone-exclusion.json
@@ -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"
+ }
+ }
+}
\ No newline at end of file
diff --git a/modules/agency/back/models/zone-warehouse.json b/modules/agency/back/models/zone-warehouse.json
new file mode 100644
index 000000000..afb3bc2b4
--- /dev/null
+++ b/modules/agency/back/models/zone-warehouse.json
@@ -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"
+ }
+ }
+}
\ No newline at end of file
diff --git a/modules/agency/back/models/zone.js b/modules/agency/back/models/zone.js
index 2c540603d..a6695bd02 100644
--- a/modules/agency/back/models/zone.js
+++ b/modules/agency/back/models/zone.js
@@ -2,10 +2,7 @@ module.exports = Self => {
require('../methods/zone/clone')(Self);
require('../methods/zone/editPrices')(Self);
require('../methods/zone/getLeaves')(Self);
-
- Self.validatesPresenceOf('warehouseFk', {
- message: `Warehouse cannot be blank`
- });
+ require('../methods/zone/getEvents')(Self);
Self.validatesPresenceOf('agencyModeFk', {
message: `Agency cannot be blank`
diff --git a/modules/agency/back/models/zone.json b/modules/agency/back/models/zone.json
index 997fedcc7..56beaa326 100644
--- a/modules/agency/back/models/zone.json
+++ b/modules/agency/back/models/zone.json
@@ -41,15 +41,25 @@
"model": "ZoneGeo",
"foreignKey": "zoneFk"
},
- "warehouse": {
- "type": "belongsTo",
- "model": "Warehouse",
- "foreignKey": "warehouseFk"
- },
"agencyMode": {
"type": "belongsTo",
"model": "AgencyMode",
"foreignKey": "agencyModeFk"
+ },
+ "events": {
+ "type": "hasMany",
+ "model": "ZoneEvent",
+ "foreignKey": "zoneFk"
+ },
+ "exclusions": {
+ "type": "hasMany",
+ "model": "ZoneExclusion",
+ "foreignKey": "zoneFk"
+ },
+ "warehouses": {
+ "type": "hasMany",
+ "model": "ZoneWarehouse",
+ "foreignKey": "zoneFk"
}
}
}
\ No newline at end of file
diff --git a/modules/agency/front/basic-data/index.html b/modules/agency/front/basic-data/index.html
index 7f4ed91ef..8749494e1 100644
--- a/modules/agency/front/basic-data/index.html
+++ b/modules/agency/front/basic-data/index.html
@@ -8,22 +8,13 @@