aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFélix Sipma <felix.sipma@no-log.org>2018-08-07 15:44:10 +0200
committerFélix Sipma <felix.sipma@no-log.org>2018-08-07 15:44:10 +0200
commita45e288f721ea34ad6af5214e241585072eea209 (patch)
tree6f6c2a2c99ef9119cc40ffcfb81de1dce45fac26
parent77d85203c9a80c4476c2fdbcc591fd7551ce26fe (diff)
use date intervals for holidays
-rw-r--r--Makefile3
-rw-r--r--data/fournil.yaml17
-rw-r--r--package-lock.json50
-rw-r--r--package.json1
-rw-r--r--shop-client/src/Shop.js7
5 files changed, 60 insertions, 18 deletions
diff --git a/Makefile b/Makefile
index 0420219..b03d5cd 100644
--- a/Makefile
+++ b/Makefile
@@ -63,8 +63,9 @@ data: npm
shopclient: npm
cd shop-client && make
- cat \
+ awk 1 \
node_modules/moment/moment.js \
+ node_modules/moment-range/dist/moment-range.js \
node_modules/pikaday/pikaday.js \
shop-client/dist/fournil-shop-client.js \
> $(TMP)/js/fournil-shop-client.js
diff --git a/data/fournil.yaml b/data/fournil.yaml
index 1add644..ac61257 100644
--- a/data/fournil.yaml
+++ b/data/fournil.yaml
@@ -91,22 +91,7 @@ produits:
poids: 1000
prix: 200
holidays:
- - "2018-08-05"
- - "2018-08-06"
- - "2018-08-07"
- - "2018-08-08"
- - "2018-08-09"
- - "2018-08-10"
- - "2018-08-11"
- - "2018-08-12"
- - "2018-08-13"
- - "2018-08-14"
- - "2018-08-15"
- - "2018-08-16"
- - "2018-08-17"
- - "2018-08-18"
- - "2018-08-19"
- - "2018-08-20"
+ - "2018-08-05/2018-08-20"
serverUrl: 'https://api.fournilsipma.fr'
chargeUrl: /charge
stripeImage: /img/secured-payment-stripe.png
diff --git a/package-lock.json b/package-lock.json
index 0a15089..8bef028 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -181,6 +181,43 @@
}
}
},
+ "d": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/d/-/d-1.0.0.tgz",
+ "integrity": "sha1-dUu1v+VUUdpppYuU1F9MWwRi1Y8=",
+ "requires": {
+ "es5-ext": "^0.10.9"
+ }
+ },
+ "es5-ext": {
+ "version": "0.10.45",
+ "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.45.tgz",
+ "integrity": "sha512-FkfM6Vxxfmztilbxxz5UKSD4ICMf5tSpRFtDNtkAhOxZ0EKtX6qwmXNyH/sFyIbX2P/nU5AMiA9jilWsUGJzCQ==",
+ "requires": {
+ "es6-iterator": "~2.0.3",
+ "es6-symbol": "~3.1.1",
+ "next-tick": "1"
+ }
+ },
+ "es6-iterator": {
+ "version": "2.0.3",
+ "resolved": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.3.tgz",
+ "integrity": "sha1-p96IkUGgWpSwhUQDstCg+/qY87c=",
+ "requires": {
+ "d": "1",
+ "es5-ext": "^0.10.35",
+ "es6-symbol": "^3.1.1"
+ }
+ },
+ "es6-symbol": {
+ "version": "3.1.1",
+ "resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.1.tgz",
+ "integrity": "sha1-vwDvT9q2uhtG7Le2KbTH7VcVzHc=",
+ "requires": {
+ "d": "1",
+ "es5-ext": "~0.10.14"
+ }
+ },
"escape-string-regexp": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz",
@@ -905,12 +942,25 @@
"resolved": "https://registry.npmjs.org/moment/-/moment-2.22.2.tgz",
"integrity": "sha1-PCV/mDn8DpP/UxSWMiOeuQeD/2Y="
},
+ "moment-range": {
+ "version": "4.0.1",
+ "resolved": "https://registry.npmjs.org/moment-range/-/moment-range-4.0.1.tgz",
+ "integrity": "sha1-GujPIJ3e0KXOXhZgMUYmWzkGqG8=",
+ "requires": {
+ "es6-symbol": "^3.1.0"
+ }
+ },
"nan": {
"version": "2.10.0",
"resolved": "https://registry.npmjs.org/nan/-/nan-2.10.0.tgz",
"integrity": "sha512-bAdJv7fBLhWC+/Bls0Oza+mvTaNQtP+1RyhhhvD95pgUJz6XM5IzgmxOkItJ9tkoCiplvAnXI1tNmmUD/eScyA==",
"optional": true
},
+ "next-tick": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.0.0.tgz",
+ "integrity": "sha1-yobR/ogoFpsBICCOPchCS524NCw="
+ },
"normalize-path": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz",
diff --git a/package.json b/package.json
index b672b89..cdfdeab 100644
--- a/package.json
+++ b/package.json
@@ -10,6 +10,7 @@
"jquery": "^3.3.1",
"leaflet": "^1.3.3",
"moment": "^2.22.2",
+ "moment-range": "^4.0.1",
"pikaday": "^1.7.0",
"popper.js": "^1.14.4",
"uglify-js": "^3.4.6",
diff --git a/shop-client/src/Shop.js b/shop-client/src/Shop.js
index d866388..546f9f7 100644
--- a/shop-client/src/Shop.js
+++ b/shop-client/src/Shop.js
@@ -1,5 +1,7 @@
"use strict";
+window['moment-range'].extendMoment(moment);
+
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/includes
// https://tc39.github.io/ecma262/#sec-array.prototype.includes
if (!Array.prototype.includes) {
@@ -55,7 +57,10 @@ if (!Array.prototype.includes) {
exports.pikadayNew = function (elementid) {
return function(holidays) {
- var holidayarray = holidays.map(function(d) { return moment(d).valueOf(); });
+ var holidayranges = holidays.map(function(dr) {
+ return Array.from(moment.range(dr).by('days')).map(function(r) { return r.valueOf(); })
+ });
+ var holidayarray = [].concat.apply([], holidayranges);
return function () {
var date = moment().add(2, 'd').toDate();
var picker = new Pikaday({