Merge branch 'master' into features/sql-vue-from-household-address-to-person

This commit is contained in:
2021-06-15 22:53:21 +02:00
208 changed files with 9047 additions and 6038 deletions

View File

@@ -0,0 +1,121 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
id="svg34"
version="1.1"
viewBox="0 0 32 32">
<metadata
id="metadata40">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs38" />
<rect
id="rect2"
x="0"
y="4"
width="4"
height="4" />
<rect
id="rect4"
x="0"
y="12"
width="4"
height="4" />
<rect
id="rect6"
x="0"
y="20"
width="4"
height="4" />
<rect
id="rect8"
x="0"
y="28"
width="4"
height="4" />
<rect
id="rect10"
x="8"
y="4"
width="4"
height="4" />
<rect
id="rect12"
x="8"
y="12"
width="4"
height="4" />
<rect
id="rect14"
x="8"
y="20"
width="4"
height="4" />
<rect
id="rect16"
x="8"
y="28"
width="4"
height="4" />
<rect
id="rect18"
x="16"
y="4"
width="4"
height="4" />
<rect
id="rect20"
x="16"
y="12"
width="4"
height="4" />
<rect
id="rect22"
x="16"
y="20"
width="4"
height="4" />
<rect
id="rect24"
x="16"
y="28"
width="4"
height="4" />
<rect
id="rect26"
x="24"
y="4"
width="4"
height="4" />
<rect
id="rect28"
x="24"
y="12"
width="4"
height="4" />
<rect
id="rect30"
x="24"
y="20"
width="4"
height="4" />
<rect
id="rect32"
x="24"
y="28"
width="4"
height="4" />
</svg>

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@@ -5,84 +5,6 @@
var chill = function() {
/* intialiase the pikaday module */
function initPikaday(locale) {
var i18n_trad = {
fr: {
previousMonth : 'Mois précédent',
nextMonth : 'Mois suivant',
months : ['Janvier','Février','Mars','Avril','Mai','Juin','Juillet','Août','Septembre','Octobre','Novembre','Décembre'],
weekdays : ['Dimanche','Lundi','Mardi','Mercredi','Jeudi','Vendredi','Samedi'],
weekdaysShort : ['Dim','Lun','Mar','Mer','Jeu','Ven','Sam']
},
nl: {
previousMonth : 'Vorig maand',
nextMonth : 'Volgende maand',
months : ['Januari','Februari','Maart','April','Mei','Juni','Juli','Augustus','September','Oktober','November','December'],
weekdays : ['Zondag','Maandag','Dinsdag','Woensdag','Donderdag','Vrijdag','Zaterdag'],
weekdaysShort : ['Zon','Ma','Di','Wo','Do','Vri','Zat']
}
};
var pikaday_options = {
format: 'D-M-YYYY',
yearRange: [parseInt(moment().format('YYYY')) - 100, parseInt(moment().format('YYYY'))],
};
if(locale in i18n_trad) {
pikaday_options.i18n = i18n_trad[locale];
}
$('.datepicker').pikaday(
pikaday_options
);
}
/* emulate the position:sticky */
function emulateSticky() {
var need_emulation = false;
$('.sticky-form-buttons').each(function(i,stick_element) {
if($(stick_element).css('position') !== 'sticky') {
need_emulation = true;
stick_element.init_offset_top = $(stick_element).offset().top;
}
});
function emulate() {
$('.sticky-form-buttons').each(function(i,stick_element) {
if (($(window).scrollTop() + $(window).height()) < stick_element.init_offset_top) {
//sticky at bottom
$(stick_element).css('position','fixed');
$(stick_element).css('bottom','0');
$(stick_element).css('top','');
$(stick_element).css('width',$(stick_element).parent().outerWidth());
} else if (stick_element.init_offset_top < $(window).scrollTop()) {
//sticky at top
$(stick_element).css('position','fixed');
$(stick_element).css('top','0');
$(stick_element).css('bottom','');
$(stick_element).css('width',$(stick_element).parent().outerWidth());
} else {
//no sticky
$(stick_element).css('position','initial');
$(stick_element).css('bottom','');
$(stick_element).css('width','');
$(stick_element).css('top','');
}
});
}
if(need_emulation) {
$(window).scroll(function() {
emulate();
});
emulate();
}
}
/**
* Display an alert message when the user wants to leave a page containing a given form
* in a given state.
@@ -411,8 +333,6 @@ var chill = function() {
}
return {
initPikaday: initPikaday,
emulateSticky: emulateSticky,
checkOtherValueOnChange: checkOtherValueOnChange,
displayAlertWhenLeavingModifiedForm: displayAlertWhenLeavingModifiedForm,
displayAlertWhenLeavingUnsubmittedForm: displayAlertWhenLeavingUnsubmittedForm,

View File

@@ -57,7 +57,6 @@ var handleAdd = function(button) {
entry.classList.add('chill-collection__list__entry');
initializeRemove(collection, entry);
collection.appendChild(entry);
chill.initPikaday('fr');
collection.dispatchEvent(event);
window.dispatchEvent(event);

View File

@@ -0,0 +1,88 @@
/**
* Some utils for manipulating dates
*
* **WARNING** experimental
*/
/**
* Return the date to local ISO date, like YYYY-mm-dd
*
* The date is valid for the same timezone as the date's locale
*
* Do not take time into account
*
* **Experimental**
*/
const dateToISO = (date) => {
return [
this.$store.state.startDate.getFullYear(),
(this.$store.state.startDate.getMonth() + 1).toString().padStart(2, '0'),
this.$store.state.startDate.getDate().toString().padStart(2, '0')
].join('-');
};
/**
* Return a date object from iso string formatted as YYYY-mm-dd
*
* **Experimental**
*/
const ISOToDate = (str) => {
let
[year, month, day] = str.split('-');
return new Date(year, month-1, day);
}
/**
* Return a date object from iso string formatted as YYYY-mm-dd:HH:MM:ss+01:00
*
* **Experimental**
*/
const ISOToDatetime = (str) => {
console.log(str);
let
[cal, times] = str.split('T'),
[year, month, date] = cal.split('-'),
[time, timezone] = cal.split(times.charAt(9)),
[hours, minutes, seconds] = cal.split(':')
;
return new Date(year, month-1, date, hours, minutes, seconds);
}
/**
* Convert a date to ISO8601, valid for usage in api
*
*/
const datetimeToISO = (date) => {
let cal, time, offset;
cal = [
date.getFullYear(),
(date.getMonth() + 1).toString().padStart(2, '0'),
date.getDate().toString().padStart(2, '0')
].join('-');
time = [
date.getHours().toString().padStart(2, '0'),
date.getMinutes().toString().padStart(2, '0'),
date.getSeconds().toString().padStart(2, '0')
].join(':');
offset = [
date.getTimezoneOffset() <= 0 ? '+' : '-',
Math.abs(Math.floor(date.getTimezoneOffset() / 60)).toString().padStart(2, '0'),
':',
Math.abs(date.getTimezoneOffset() % 60).toString().padStart(2, '0'),
].join('');
let x = cal + 'T' + time + offset;
return x;
};
export {
dateToISO,
ISOToDate,
ISOToDatetime,
datetimeToISO
};

File diff suppressed because it is too large Load Diff

View File

@@ -1,920 +0,0 @@
/*!
* Pikaday
*
* Copyright © 2014 David Bushell | BSD & MIT license | https://github.com/dbushell/Pikaday
*/
(function (root, factory)
{
'use strict';
var moment;
if (typeof exports === 'object') {
// CommonJS module
// Load moment.js as an optional dependency
try { moment = require('moment'); } catch (e) {}
module.exports = factory(moment);
} else if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(function (req)
{
// Load moment.js as an optional dependency
var id = 'moment';
moment = req.defined && req.defined(id) ? req(id) : undefined;
return factory(moment);
});
} else {
root.Pikaday = factory(root.moment);
}
}(this, function (moment)
{
'use strict';
/**
* feature detection and helper functions
*/
var hasMoment = typeof moment === 'function',
hasEventListeners = !!window.addEventListener,
document = window.document,
sto = window.setTimeout,
addEvent = function(el, e, callback, capture)
{
if (hasEventListeners) {
el.addEventListener(e, callback, !!capture);
} else {
el.attachEvent('on' + e, callback);
}
},
removeEvent = function(el, e, callback, capture)
{
if (hasEventListeners) {
el.removeEventListener(e, callback, !!capture);
} else {
el.detachEvent('on' + e, callback);
}
},
fireEvent = function(el, eventName, data)
{
var ev;
if (document.createEvent) {
ev = document.createEvent('HTMLEvents');
ev.initEvent(eventName, true, false);
ev = extend(ev, data);
el.dispatchEvent(ev);
} else if (document.createEventObject) {
ev = document.createEventObject();
ev = extend(ev, data);
el.fireEvent('on' + eventName, ev);
}
},
trim = function(str)
{
return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g,'');
},
hasClass = function(el, cn)
{
return (' ' + el.className + ' ').indexOf(' ' + cn + ' ') !== -1;
},
addClass = function(el, cn)
{
if (!hasClass(el, cn)) {
el.className = (el.className === '') ? cn : el.className + ' ' + cn;
}
},
removeClass = function(el, cn)
{
el.className = trim((' ' + el.className + ' ').replace(' ' + cn + ' ', ' '));
},
isArray = function(obj)
{
return (/Array/).test(Object.prototype.toString.call(obj));
},
isDate = function(obj)
{
return (/Date/).test(Object.prototype.toString.call(obj)) && !isNaN(obj.getTime());
},
isLeapYear = function(year)
{
// solution by Matti Virkkunen: http://stackoverflow.com/a/4881951
return year % 4 === 0 && year % 100 !== 0 || year % 400 === 0;
},
getDaysInMonth = function(year, month)
{
return [31, isLeapYear(year) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month];
},
setToStartOfDay = function(date)
{
if (isDate(date)) date.setHours(0,0,0,0);
},
compareDates = function(a,b)
{
// weak date comparison (use setToStartOfDay(date) to ensure correct result)
return a.getTime() === b.getTime();
},
extend = function(to, from, overwrite)
{
var prop, hasProp;
for (prop in from) {
hasProp = to[prop] !== undefined;
if (hasProp && typeof from[prop] === 'object' && from[prop].nodeName === undefined) {
if (isDate(from[prop])) {
if (overwrite) {
to[prop] = new Date(from[prop].getTime());
}
}
else if (isArray(from[prop])) {
if (overwrite) {
to[prop] = from[prop].slice(0);
}
} else {
to[prop] = extend({}, from[prop], overwrite);
}
} else if (overwrite || !hasProp) {
to[prop] = from[prop];
}
}
return to;
},
/**
* defaults and localisation
*/
defaults = {
// bind the picker to a form field
field: null,
// automatically show/hide the picker on `field` focus (default `true` if `field` is set)
bound: undefined,
// position of the datepicker, relative to the field (default to bottom & left)
// ('bottom' & 'left' keywords are not used, 'top' & 'right' are modifier on the bottom/left position)
position: 'bottom left',
// the default output format for `.toString()` and `field` value
format: 'YYYY-MM-DD',
// the initial date to view when first opened
defaultDate: null,
// make the `defaultDate` the initial selected value
setDefaultDate: false,
// first day of week (0: Sunday, 1: Monday etc)
firstDay: 0,
// the minimum/earliest date that can be selected
minDate: null,
// the maximum/latest date that can be selected
maxDate: null,
// number of years either side, or array of upper/lower range
yearRange: 10,
// used internally (don't config outside)
minYear: 0,
maxYear: 9999,
minMonth: undefined,
maxMonth: undefined,
isRTL: false,
// Additional text to append to the year in the calendar title
yearSuffix: '',
// Render the month after year in the calendar title
showMonthAfterYear: false,
// how many months are visible (not implemented yet)
numberOfMonths: 1,
// internationalization
i18n: {
previousMonth : 'Previous Month',
nextMonth : 'Next Month',
months : ['January','February','March','April','May','June','July','August','September','October','November','December'],
weekdays : ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],
weekdaysShort : ['Sun','Mon','Tue','Wed','Thu','Fri','Sat']
},
// callback function
onSelect: null,
onOpen: null,
onClose: null,
onDraw: null
},
/**
* templating functions to abstract HTML rendering
*/
renderDayName = function(opts, day, abbr)
{
day += opts.firstDay;
while (day >= 7) {
day -= 7;
}
return abbr ? opts.i18n.weekdaysShort[day] : opts.i18n.weekdays[day];
},
renderDay = function(i, isSelected, isToday, isDisabled, isEmpty)
{
if (isEmpty) {
return '<td class="is-empty"></td>';
}
var arr = [];
if (isDisabled) {
arr.push('is-disabled');
}
if (isToday) {
arr.push('is-today');
}
if (isSelected) {
arr.push('is-selected');
}
return '<td data-day="' + i + '" class="' + arr.join(' ') + '"><button class="pika-button" type="button">' + i + '</button>' + '</td>';
},
renderRow = function(days, isRTL)
{
return '<tr>' + (isRTL ? days.reverse() : days).join('') + '</tr>';
},
renderBody = function(rows)
{
return '<tbody>' + rows.join('') + '</tbody>';
},
renderHead = function(opts)
{
var i, arr = [];
for (i = 0; i < 7; i++) {
arr.push('<th scope="col"><abbr title="' + renderDayName(opts, i) + '">' + renderDayName(opts, i, true) + '</abbr></th>');
}
return '<thead>' + (opts.isRTL ? arr.reverse() : arr).join('') + '</thead>';
},
renderTitle = function(instance)
{
var i, j, arr,
opts = instance._o,
month = instance._m,
year = instance._y,
isMinYear = year === opts.minYear,
isMaxYear = year === opts.maxYear,
html = '<div class="pika-title">',
monthHtml,
yearHtml,
prev = true,
next = true;
for (arr = [], i = 0; i < 12; i++) {
arr.push('<option value="' + i + '"' +
(i === month ? ' selected': '') +
((isMinYear && i < opts.minMonth) || (isMaxYear && i > opts.maxMonth) ? 'disabled' : '') + '>' +
opts.i18n.months[i] + '</option>');
}
monthHtml = '<div class="pika-label">' + opts.i18n.months[month] + '<select class="pika-select pika-select-month">' + arr.join('') + '</select></div>';
if (isArray(opts.yearRange)) {
i = opts.yearRange[0];
j = opts.yearRange[1] + 1;
} else {
i = year - opts.yearRange;
j = 1 + year + opts.yearRange;
}
for (arr = []; i < j && i <= opts.maxYear; i++) {
if (i >= opts.minYear) {
arr.push('<option value="' + i + '"' + (i === year ? ' selected': '') + '>' + (i) + '</option>');
}
}
yearHtml = '<div class="pika-label">' + year + opts.yearSuffix + '<select class="pika-select pika-select-year">' + arr.join('') + '</select></div>';
if (opts.showMonthAfterYear) {
html += yearHtml + monthHtml;
} else {
html += monthHtml + yearHtml;
}
if (isMinYear && (month === 0 || opts.minMonth >= month)) {
prev = false;
}
if (isMaxYear && (month === 11 || opts.maxMonth <= month)) {
next = false;
}
html += '<button class="pika-prev' + (prev ? '' : ' is-disabled') + '" type="button">' + opts.i18n.previousMonth + '</button>';
html += '<button class="pika-next' + (next ? '' : ' is-disabled') + '" type="button">' + opts.i18n.nextMonth + '</button>';
return html += '</div>';
},
renderTable = function(opts, data)
{
return '<table cellpadding="0" cellspacing="0" class="pika-table">' + renderHead(opts) + renderBody(data) + '</table>';
},
/**
* Pikaday constructor
*/
Pikaday = function(options)
{
var self = this,
opts = self.config(options);
self._onMouseDown = function(e)
{
if (!self._v) {
return;
}
e = e || window.event;
var target = e.target || e.srcElement;
if (!target) {
return;
}
if (!hasClass(target, 'is-disabled')) {
if (hasClass(target, 'pika-button') && !hasClass(target, 'is-empty')) {
self.setDate(new Date(self._y, self._m, parseInt(target.innerHTML, 10)));
if (opts.bound) {
sto(function() {
self.hide();
}, 100);
}
return;
}
else if (hasClass(target, 'pika-prev')) {
self.prevMonth();
}
else if (hasClass(target, 'pika-next')) {
self.nextMonth();
}
}
if (!hasClass(target, 'pika-select')) {
if (e.preventDefault) {
e.preventDefault();
} else {
e.returnValue = false;
return false;
}
} else {
self._c = true;
}
};
self._onChange = function(e)
{
e = e || window.event;
var target = e.target || e.srcElement;
if (!target) {
return;
}
if (hasClass(target, 'pika-select-month')) {
self.gotoMonth(target.value);
}
else if (hasClass(target, 'pika-select-year')) {
self.gotoYear(target.value);
}
};
self._onInputChange = function(e)
{
var date;
if (e.firedBy === self) {
return;
}
if (hasMoment) {
date = moment(opts.field.value, opts.format);
date = (date && date.isValid()) ? date.toDate() : null;
}
else {
date = new Date(Date.parse(opts.field.value));
}
self.setDate(isDate(date) ? date : null);
if (!self._v) {
self.show();
}
};
self._onInputFocus = function()
{
self.show();
};
self._onInputClick = function()
{
self.show();
};
self._onInputBlur = function()
{
if (!self._c) {
self._b = sto(function() {
self.hide();
}, 50);
}
self._c = false;
};
self._onClick = function(e)
{
e = e || window.event;
var target = e.target || e.srcElement,
pEl = target;
if (!target) {
return;
}
if (!hasEventListeners && hasClass(target, 'pika-select')) {
if (!target.onchange) {
target.setAttribute('onchange', 'return;');
addEvent(target, 'change', self._onChange);
}
}
do {
if (hasClass(pEl, 'pika-single')) {
return;
}
}
while ((pEl = pEl.parentNode));
if (self._v && target !== opts.trigger) {
self.hide();
}
};
self.el = document.createElement('div');
self.el.className = 'pika-single' + (opts.isRTL ? ' is-rtl' : '');
addEvent(self.el, 'mousedown', self._onMouseDown, true);
addEvent(self.el, 'change', self._onChange);
if (opts.field) {
if (opts.bound) {
document.body.appendChild(self.el);
} else {
opts.field.parentNode.insertBefore(self.el, opts.field.nextSibling);
}
addEvent(opts.field, 'change', self._onInputChange);
if (!opts.defaultDate) {
if (hasMoment && opts.field.value) {
opts.defaultDate = moment(opts.field.value, opts.format).toDate();
} else {
opts.defaultDate = new Date(Date.parse(opts.field.value));
}
opts.setDefaultDate = true;
}
}
var defDate = opts.defaultDate;
if (isDate(defDate)) {
if (opts.setDefaultDate) {
self.setDate(defDate, true);
} else {
self.gotoDate(defDate);
}
} else {
self.gotoDate(new Date());
}
if (opts.bound) {
this.hide();
self.el.className += ' is-bound';
addEvent(opts.trigger, 'click', self._onInputClick);
addEvent(opts.trigger, 'focus', self._onInputFocus);
addEvent(opts.trigger, 'blur', self._onInputBlur);
} else {
this.show();
}
};
/**
* public Pikaday API
*/
Pikaday.prototype = {
/**
* configure functionality
*/
config: function(options)
{
if (!this._o) {
this._o = extend({}, defaults, true);
}
var opts = extend(this._o, options, true);
opts.isRTL = !!opts.isRTL;
opts.field = (opts.field && opts.field.nodeName) ? opts.field : null;
opts.bound = !!(opts.bound !== undefined ? opts.field && opts.bound : opts.field);
opts.trigger = (opts.trigger && opts.trigger.nodeName) ? opts.trigger : opts.field;
var nom = parseInt(opts.numberOfMonths, 10) || 1;
opts.numberOfMonths = nom > 4 ? 4 : nom;
if (!isDate(opts.minDate)) {
opts.minDate = false;
}
if (!isDate(opts.maxDate)) {
opts.maxDate = false;
}
if ((opts.minDate && opts.maxDate) && opts.maxDate < opts.minDate) {
opts.maxDate = opts.minDate = false;
}
if (opts.minDate) {
setToStartOfDay(opts.minDate);
opts.minYear = opts.minDate.getFullYear();
opts.minMonth = opts.minDate.getMonth();
}
if (opts.maxDate) {
setToStartOfDay(opts.maxDate);
opts.maxYear = opts.maxDate.getFullYear();
opts.maxMonth = opts.maxDate.getMonth();
}
if (isArray(opts.yearRange)) {
var fallback = new Date().getFullYear() - 10;
opts.yearRange[0] = parseInt(opts.yearRange[0], 10) || fallback;
opts.yearRange[1] = parseInt(opts.yearRange[1], 10) || fallback;
} else {
opts.yearRange = Math.abs(parseInt(opts.yearRange, 10)) || defaults.yearRange;
if (opts.yearRange > 100) {
opts.yearRange = 100;
}
}
return opts;
},
/**
* return a formatted string of the current selection (using Moment.js if available)
*/
toString: function(format)
{
return !isDate(this._d) ? '' : hasMoment ? moment(this._d).format(format || this._o.format) : this._d.toDateString();
},
/**
* return a Moment.js object of the current selection (if available)
*/
getMoment: function()
{
return hasMoment ? moment(this._d) : null;
},
/**
* set the current selection from a Moment.js object (if available)
*/
setMoment: function(date, preventOnSelect)
{
if (hasMoment && moment.isMoment(date)) {
this.setDate(date.toDate(), preventOnSelect);
}
},
/**
* return a Date object of the current selection
*/
getDate: function()
{
return isDate(this._d) ? new Date(this._d.getTime()) : null;
},
/**
* set the current selection
*/
setDate: function(date, preventOnSelect)
{
if (!date) {
this._d = null;
return this.draw();
}
if (typeof date === 'string') {
date = new Date(Date.parse(date));
}
if (!isDate(date)) {
return;
}
var min = this._o.minDate,
max = this._o.maxDate;
if (isDate(min) && date < min) {
date = min;
} else if (isDate(max) && date > max) {
date = max;
}
this._d = new Date(date.getTime());
setToStartOfDay(this._d);
this.gotoDate(this._d);
if (this._o.field) {
this._o.field.value = this.toString();
fireEvent(this._o.field, 'change', { firedBy: this });
}
if (!preventOnSelect && typeof this._o.onSelect === 'function') {
this._o.onSelect.call(this, this.getDate());
}
},
/**
* change view to a specific date
*/
gotoDate: function(date)
{
if (!isDate(date)) {
return;
}
this._y = date.getFullYear();
this._m = date.getMonth();
this.draw();
},
gotoToday: function()
{
this.gotoDate(new Date());
},
/**
* change view to a specific month (zero-index, e.g. 0: January)
*/
gotoMonth: function(month)
{
if (!isNaN( (month = parseInt(month, 10)) )) {
this._m = month < 0 ? 0 : month > 11 ? 11 : month;
this.draw();
}
},
nextMonth: function()
{
if (++this._m > 11) {
this._m = 0;
this._y++;
}
this.draw();
},
prevMonth: function()
{
if (--this._m < 0) {
this._m = 11;
this._y--;
}
this.draw();
},
/**
* change view to a specific full year (e.g. "2012")
*/
gotoYear: function(year)
{
if (!isNaN(year)) {
this._y = parseInt(year, 10);
this.draw();
}
},
/**
* change the minDate
*/
setMinDate: function(value)
{
this._o.minDate = value;
},
/**
* change the maxDate
*/
setMaxDate: function(value)
{
this._o.maxDate = value;
},
/**
* refresh the HTML
*/
draw: function(force)
{
if (!this._v && !force) {
return;
}
var opts = this._o,
minYear = opts.minYear,
maxYear = opts.maxYear,
minMonth = opts.minMonth,
maxMonth = opts.maxMonth;
if (this._y <= minYear) {
this._y = minYear;
if (!isNaN(minMonth) && this._m < minMonth) {
this._m = minMonth;
}
}
if (this._y >= maxYear) {
this._y = maxYear;
if (!isNaN(maxMonth) && this._m > maxMonth) {
this._m = maxMonth;
}
}
this.el.innerHTML = renderTitle(this) + this.render(this._y, this._m);
if (opts.bound) {
this.adjustPosition();
if(opts.field.type !== 'hidden') {
sto(function() {
opts.trigger.focus();
}, 1);
}
}
if (typeof this._o.onDraw === 'function') {
var self = this;
sto(function() {
self._o.onDraw.call(self);
}, 0);
}
},
adjustPosition: function()
{
var field = this._o.trigger, pEl = field,
width = this.el.offsetWidth, height = this.el.offsetHeight,
viewportWidth = window.innerWidth || document.documentElement.clientWidth,
viewportHeight = window.innerHeight || document.documentElement.clientHeight,
scrollTop = window.pageYOffset || document.body.scrollTop || document.documentElement.scrollTop,
left, top, clientRect;
if (typeof field.getBoundingClientRect === 'function') {
clientRect = field.getBoundingClientRect();
left = clientRect.left + window.pageXOffset;
top = clientRect.bottom + window.pageYOffset;
} else {
left = pEl.offsetLeft;
top = pEl.offsetTop + pEl.offsetHeight;
while((pEl = pEl.offsetParent)) {
left += pEl.offsetLeft;
top += pEl.offsetTop;
}
}
// default position is bottom & left
if (left + width > viewportWidth ||
(
this._o.position.indexOf('right') > -1 &&
left - width + field.offsetWidth > 0
)
) {
left = left - width + field.offsetWidth;
}
if (top + height > viewportHeight + scrollTop ||
(
this._o.position.indexOf('top') > -1 &&
top - height - field.offsetHeight > 0
)
) {
top = top - height - field.offsetHeight;
}
this.el.style.cssText = [
'position: absolute',
'left: ' + left + 'px',
'top: ' + top + 'px'
].join(';');
},
/**
* render HTML for a particular month
*/
render: function(year, month)
{
var opts = this._o,
now = new Date(),
days = getDaysInMonth(year, month),
before = new Date(year, month, 1).getDay(),
data = [],
row = [];
setToStartOfDay(now);
if (opts.firstDay > 0) {
before -= opts.firstDay;
if (before < 0) {
before += 7;
}
}
var cells = days + before,
after = cells;
while(after > 7) {
after -= 7;
}
cells += 7 - after;
for (var i = 0, r = 0; i < cells; i++)
{
var day = new Date(year, month, 1 + (i - before)),
isDisabled = (opts.minDate && day < opts.minDate) || (opts.maxDate && day > opts.maxDate),
isSelected = isDate(this._d) ? compareDates(day, this._d) : false,
isToday = compareDates(day, now),
isEmpty = i < before || i >= (days + before);
row.push(renderDay(1 + (i - before), isSelected, isToday, isDisabled, isEmpty));
if (++r === 7) {
data.push(renderRow(row, opts.isRTL));
row = [];
r = 0;
}
}
return renderTable(opts, data);
},
isVisible: function()
{
return this._v;
},
show: function()
{
if (!this._v) {
if (this._o.bound) {
addEvent(document, 'click', this._onClick);
}
removeClass(this.el, 'is-hidden');
this._v = true;
this.draw();
if (typeof this._o.onOpen === 'function') {
this._o.onOpen.call(this);
}
}
},
hide: function()
{
var v = this._v;
if (v !== false) {
if (this._o.bound) {
removeEvent(document, 'click', this._onClick);
}
this.el.style.cssText = '';
addClass(this.el, 'is-hidden');
this._v = false;
if (v !== undefined && typeof this._o.onClose === 'function') {
this._o.onClose.call(this);
}
}
},
/**
* GAME OVER
*/
destroy: function()
{
this.hide();
removeEvent(this.el, 'mousedown', this._onMouseDown, true);
removeEvent(this.el, 'change', this._onChange);
if (this._o.field) {
removeEvent(this._o.field, 'change', this._onInputChange);
if (this._o.bound) {
removeEvent(this._o.trigger, 'click', this._onInputClick);
removeEvent(this._o.trigger, 'focus', this._onInputFocus);
removeEvent(this._o.trigger, 'blur', this._onInputBlur);
}
}
if (this.el.parentNode) {
this.el.parentNode.removeChild(this.el);
}
}
};
return Pikaday;
}));

View File

@@ -1,52 +0,0 @@
/*!
* Pikaday jQuery plugin.
*
* Copyright © 2013 David Bushell | BSD & MIT license | https://github.com/dbushell/Pikaday
*/
(function (root, factory)
{
'use strict';
if (typeof exports === 'object') {
// CommonJS module
factory(require('jquery'), require('../pikaday'));
} else if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['jquery', 'pikaday'], factory);
} else {
// Browser globals
factory(root.jQuery, root.Pikaday);
}
}(this, function ($, Pikaday)
{
'use strict';
$.fn.pikaday = function()
{
var args = arguments;
if (!args || !args.length) {
args = [{ }];
}
return this.each(function()
{
var self = $(this),
plugin = self.data('pikaday');
if (!(plugin instanceof Pikaday)) {
if (typeof args[0] === 'object') {
var options = $.extend({}, args[0]);
options.field = self[0];
self.data('pikaday', new Pikaday(options));
}
} else {
if (typeof args[0] === 'string' && typeof plugin[args[0]] === 'function') {
plugin[args[0]].apply(plugin, Array.prototype.slice.call(args,1));
}
}
});
};
}));

View File

@@ -5,11 +5,6 @@ const $ = require('jquery');
// create global $ and jQuery variables
global.$ = global.jQuery = $;
const moment = require('moment');
global.moment = moment;
const pikaday = require('pikaday-jquery');
const select2 = require('select2');
global.select2 = select2;
@@ -23,7 +18,6 @@ global.chill = chill;
*/
require('./scss/chillmain.scss');
require('./css/chillmain.css');
require('./css/pikaday.css');
require('./js/collection/collections.js');

View File

@@ -17,20 +17,20 @@
// @import "bootstrap/scss/grid";
// @import "bootstrap/scss/tables";
// @import "bootstrap/scss/forms";
// @import "bootstrap/scss/buttons";
// @import "bootstrap/scss/transitions";
@import "bootstrap/scss/buttons";
@import "bootstrap/scss/transitions";
// @import "bootstrap/scss/dropdown";
// @import "bootstrap/scss/button-group";
// @import "bootstrap/scss/input-group";
// @import "bootstrap/scss/custom-forms";
// @import "bootstrap/scss/nav";
@import "bootstrap/scss/nav";
// @import "bootstrap/scss/navbar";
// @import "bootstrap/scss/card";
// @import "bootstrap/scss/breadcrumb";
// @import "bootstrap/scss/pagination";
@import "bootstrap/scss/badge";
// @import "bootstrap/scss/jumbotron";
// @import "bootstrap/scss/alert";
@import "bootstrap/scss/alert";
// @import "bootstrap/scss/progress";
// @import "bootstrap/scss/media";
// @import "bootstrap/scss/list-group";

View File

@@ -4,6 +4,8 @@
// Or compile bootstrap only enabled assets
require('./bootstrap.scss');
// You can specify which plugins you need
//import { Tooltip, Toast, Popover } from 'bootstrap';
import Modal from 'bootstrap/js/dist/modal';
import Collapse from 'bootstrap/js/src/collapse';

View File

@@ -79,6 +79,18 @@ div.flex-table {
h2, h3, h4 {
color: var(--chill-blue);
}
div.item-bloc {
// We use box-shadow instead of border
// to avoid to manage border double-width
// when blocs are resized for small screen !
// Then we can simulate border-collapse: collapse (table)
box-shadow:
1px 0 0 0 #000,
0 1px 0 0 #000,
1px 1px 0 0 #000, /* fix the corner */
1px 0 0 0 #000 inset,
0 1px 0 0 #000 inset;
}
}
/*
@@ -94,11 +106,8 @@ div.flex-bloc {
div.item-bloc {
flex-grow: 0; flex-shrink: 1; flex-basis: 50%;
margin: 0;
border: 1px solid #000;
padding: 1em;
border-top: 0;
&:nth-child(1), &:nth-child(2) {
border-top: 1px solid #000;
@@ -112,7 +121,7 @@ div.flex-bloc {
display: flex;
flex-direction: column;
div.item-row {
& > div.item-row {
flex-grow: 1; flex-shrink: 1; flex-basis: auto;
display: flex;
flex-direction: column;
@@ -167,11 +176,6 @@ div.flex-table {
display: flex;
flex-direction: column;
padding: 1em;
border: 1px solid #000;
border-top: 0;
&:first-child {
border-top: 1px solid #000;
}
&:nth-child(even) {
background-color: #e6e6e6;
}

View File

@@ -0,0 +1,153 @@
<template>
<a class="sc-button" target="_blank"
:class="classAction"
:title="$t(titleAction)"
@click="openModal">
{{ buttonText }}
</a>
<teleport to="body">
<modal v-if="modal.showModal"
:modalDialogClass="modal.modalDialogClass"
@close="modal.showModal = false">
<template v-slot:header>
<h3 class="modal-title">{{ $t(titleModal) }}</h3>
</template>
<template v-slot:body v-if="type === 'person'">
<on-the-fly-person
v-bind:id="id"
v-bind:type="type"
v-bind:action="action"
ref="castPerson">
</on-the-fly-person>
</template>
<template v-slot:body v-else-if="type === 'thirdparty'">
<on-the-fly-thirdparty
v-bind:id="id"
v-bind:type="type"
v-bind:action="action"
ref="castThirdparty">
</on-the-fly-thirdparty>
</template>
<template v-slot:body v-else>
<on-the-fly-create
v-bind:action="action"
ref="castNew">
</on-the-fly-create>
</template>
<template v-slot:footer>
<button v-if="action === 'show'"
@click="changeActionTo('edit')"
class="sc-button bt-update"> <!-- @click.prevent="$emit('..', ..)" -->
</button>
<button v-else
class="sc-button bt-save"
@click="saveAction"
> <!--
-->
{{ $t('action.save')}}
</button>
</template>
</modal>
</teleport>
</template>
<script>
import Modal from 'ChillMainAssets/vuejs/_components/Modal.vue';
import OnTheFlyPerson from 'ChillPersonAssets/vuejs/_components/OnTheFly/Person.vue';
import OnTheFlyThirdparty from './OnTheFly/ThirdParty.vue';
import OnTheFlyCreate from './OnTheFly/Create.vue';
export default {
name: 'OnTheFly',
components: {
Modal,
OnTheFlyPerson,
OnTheFlyThirdparty,
OnTheFlyCreate
},
props: ['type', 'id', 'action', 'buttonText'],
data() {
return {
modal: {
showModal: false,
modalDialogClass: "modal-dialog-scrollable modal-xl"
},
action: this.action
}
},
computed: {
action() {
return this.$data.action;
},
classAction() {
switch (this.action) {
case 'show':
return 'bt-show';
case 'edit':
return 'bt-update';
case 'create':
return 'bt-create';
}
},
titleAction() {
switch (this.action) {
case 'show':
return 'action.show';
case 'edit':
return 'action.edit';
case 'create':
return 'action.create';
}
},
titleModal() {
switch (this.action) {
case 'show':
return 'onthefly.show.' + this.type;
case 'edit':
return 'onthefly.edit.' + this.type;
case 'create':
return 'onthefly.create.title';
}
}
},
methods: {
openModal() {
this.modal.showModal = true;
this.$nextTick(function() {
//this.$refs.search.focus();
})
},
changeActionTo(action) {
// [BUG] clic first on show item button; in modal clic edit button; close modal; clic again on show item button
this.$data.action = action;
},
saveAction() {
console.log('saveAction');
if (this.type === 'person') {
this.$refs.castPerson.postData();
} else if (this.type === 'thirdparty') {
this.$refs.castThirdparty.postData();
} else {
// saveAction() ==cast=to==> child.castByType() ==cast=to==> grand-child.postData()
this.$refs.castNew.castByType();
}
this.modal.showModal = false;
}
}
}
</script>
<style lang="css" scoped>
a {
cursor: pointer;
}
</style>

View File

@@ -0,0 +1,84 @@
<template>
<ul class="nav nav-tabs">
<li class="nav-item">
<a class="nav-link" :class="{ active: isActive('person') }">
<label for="person">
<input type="radio" name="person" v-model="radioType" value="person">
{{ $t('onthefly.create.person') }}
</label>
</a>
</li>
<li class="nav-item">
<a class="nav-link" :class="{ active: isActive('thirdparty') }">
<label for="thirdparty">
<input type="radio" name="thirdparty" v-model="radioType" value="thirdparty">
{{ $t('onthefly.create.thirdparty') }}
</label>
</a>
</li>
</ul>
<div class="my-4">
<on-the-fly-person
v-if="type === 'person'"
v-bind:action="action"
ref="castPerson">
</on-the-fly-person>
<on-the-fly-thirdparty
v-if="type === 'thirdparty'"
v-bind:action="action"
ref="castThirdparty">
</on-the-fly-thirdparty>
</div>
</template>
<script>
import OnTheFlyPerson from 'ChillPersonAssets/vuejs/_components/OnTheFly/Person.vue';
import OnTheFlyThirdparty from './ThirdParty.vue'; // TODO move in ChillThirdpartyAssets
export default {
name: "OnTheFlyCreate",
props: ['action'],
components: {
OnTheFlyPerson,
OnTheFlyThirdparty
},
data() {
return {
type: 'person' //by default
}
},
computed: {
radioType: {
set(type) {
this.type = type;
},
get() {
return this.type;
}
}
},
methods: {
isActive(tab) {
return (this.type === tab) ? true : false;
},
castByType() {
console.log('saveActionByType');
if (this.type === 'person') {
this.$refs.castPerson.postData();
} else if (this.type === 'thirdparty') {
this.$refs.castThirdparty.postData();
} else {
throw Error('Invalid type of entity');
}
}
}
}
</script>
<style lang="css" scoped>
label {
cursor: pointer;
}
</style>

View File

@@ -0,0 +1,23 @@
<template>
<div v-if="action === 'show'">
show
thirdparty
{{ id }}
</div>
<div v-else-if="action === 'edit' || action === 'create'">
{{ action }}
thirdparty
{{ id }}
</div>
</template>
<script>
export default {
name: "OnTheFlyThirdParty",
props: ['id', 'type', 'action']
}
// TODO move in ChillThirdpartyAssets
</script>
<style lang="css" scoped>
</style>

View File

@@ -46,7 +46,23 @@ const messages = {
previous: "Précédent",
top: "Haut",
bottom: "Bas",
}
},
onthefly: {
show: {
person: "Détails de l'usager",
thirdparty: "Détails du tiers"
},
edit: {
person: "Modifier un usager",
thirdparty: "Modifier un tiers"
},
create: {
button: "Créer \"{q}\"",
title: "Créer à la volée…",
person: "un nouvel usager",
thirdparty: "un nouveau tiers"
},
},
}
};