design-comuni-plone-theme 11.23.1 → 11.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/main.yml +1 -1
- package/.github/workflows/prs.yml +1 -1
- package/.github/workflows/release.yml +1 -1
- package/.yarn/cache/{volto-form-block-npm-3.9.2-cb78fb6cd0-a47c5241be.zip → volto-form-block-npm-3.10.0-8cd1c7a976-8ddce2c624.zip} +0 -0
- package/.yarn/install-state.gz +0 -0
- package/CHANGELOG.md +34 -0
- package/Makefile +1 -1
- package/RELEASE.md +25 -0
- package/locales/de/LC_MESSAGES/volto.po +5 -0
- package/locales/en/LC_MESSAGES/volto.po +5 -0
- package/locales/es/LC_MESSAGES/volto.po +5 -0
- package/locales/fr/LC_MESSAGES/volto.po +5 -0
- package/locales/it/LC_MESSAGES/volto.po +5 -0
- package/locales/volto.pot +6 -1
- package/package.json +3 -3
- package/publiccode.yml +2 -2
- package/src/components/ItaliaTheme/Blocks/Listing/SimpleCard/Card/SimpleCardDefault.jsx +5 -1
- package/src/components/ItaliaTheme/View/PersonaView/PersonaRuolo.jsx +11 -5
- package/src/config/italiaConfig.js +1 -0
- package/src/customizations/volto/components/manage/Controlpanels/Groups/GroupsControlpanel.jsx +709 -0
- package/src/customizations/volto/components/manage/Controlpanels/Groups/RenderGroups.jsx +122 -0
- package/src/customizations/volto/components/manage/Diff/DiffField.jsx +2 -3
- package/src/customizations/volto/components/manage/Widgets/RecurrenceWidget/EndField.jsx +18 -11
- package/src/customizations/volto/components/manage/Widgets/RecurrenceWidget/RecurrenceWidget.jsx +233 -116
- package/src/customizations/volto/components/theme/View/LinkView.jsx +75 -0
- package/src/customizations/volto-form-block/components/FormView.jsx +44 -40
- package/src/customizations/volto-form-block/components/Sidebar.jsx +4 -1
- package/src/customizations/volto-form-block/components/View.jsx +9 -2
- package/src/customizations/volto-form-block/formSchema.js +18 -0
package/src/customizations/volto/components/manage/Widgets/RecurrenceWidget/RecurrenceWidget.jsx
CHANGED
|
@@ -1,19 +1,30 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* RecurrenceWidget component.
|
|
3
3
|
* @module components/manage/Widgets/RecurrenceWidget
|
|
4
|
-
*
|
|
5
|
-
* - add date field open calendar on top
|
|
6
|
-
* - fix all imports and rrulei18n use
|
|
7
|
-
* - added customization to have this changes https://github.com/plone/volto/pull/5555/files
|
|
4
|
+
* See https://github.com/RedTurtle/design-comuni-plone-theme/pull/741 for notable changes and reasons
|
|
8
5
|
*/
|
|
9
6
|
|
|
10
7
|
import React, { Component } from 'react';
|
|
8
|
+
import { compose } from 'redux';
|
|
9
|
+
import { connect } from 'react-redux';
|
|
11
10
|
import PropTypes from 'prop-types';
|
|
12
|
-
import moment from 'moment';
|
|
13
|
-
import { RRule, RRuleSet, rrulestr } from 'rrule';
|
|
14
11
|
|
|
15
12
|
import cx from 'classnames';
|
|
16
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
isEqual,
|
|
15
|
+
map,
|
|
16
|
+
find,
|
|
17
|
+
concat,
|
|
18
|
+
remove,
|
|
19
|
+
isNil,
|
|
20
|
+
isBoolean,
|
|
21
|
+
isArray,
|
|
22
|
+
isString,
|
|
23
|
+
isObject,
|
|
24
|
+
isEmpty,
|
|
25
|
+
isNumber,
|
|
26
|
+
omitBy,
|
|
27
|
+
} from 'lodash';
|
|
17
28
|
import { defineMessages, injectIntl } from 'react-intl';
|
|
18
29
|
import {
|
|
19
30
|
Form,
|
|
@@ -24,8 +35,9 @@ import {
|
|
|
24
35
|
Modal,
|
|
25
36
|
Header,
|
|
26
37
|
} from 'semantic-ui-react';
|
|
27
|
-
|
|
28
38
|
import { SelectWidget, Icon, DatetimeWidget } from '@plone/volto/components';
|
|
39
|
+
import { toBackendLang } from '@plone/volto/helpers';
|
|
40
|
+
import { injectLazyLibs } from '@plone/volto/helpers/Loadable/Loadable';
|
|
29
41
|
|
|
30
42
|
import saveSVG from '@plone/volto/icons/save.svg';
|
|
31
43
|
import editingSVG from '@plone/volto/icons/editing.svg';
|
|
@@ -181,8 +193,10 @@ class RecurrenceWidget extends Component {
|
|
|
181
193
|
*/
|
|
182
194
|
constructor(props, intl) {
|
|
183
195
|
super(props);
|
|
196
|
+
const { RRuleSet, rrulestr } = props.rrule;
|
|
184
197
|
|
|
185
|
-
moment
|
|
198
|
+
this.moment = this.props.moment.default;
|
|
199
|
+
this.moment.locale(toBackendLang(this.props.lang));
|
|
186
200
|
|
|
187
201
|
let rruleSet = this.props.value
|
|
188
202
|
? rrulestr(props.value, {
|
|
@@ -199,11 +213,12 @@ class RecurrenceWidget extends Component {
|
|
|
199
213
|
this.state = {
|
|
200
214
|
open: false,
|
|
201
215
|
rruleSet: rruleSet,
|
|
216
|
+
editRruleSet: rruleSet,
|
|
202
217
|
formValues: this.getFormValues(rruleSet),
|
|
203
218
|
RRULE_LANGUAGE: rrulei18n(
|
|
204
219
|
this.props.intl,
|
|
205
|
-
moment,
|
|
206
|
-
this.props.
|
|
220
|
+
this.moment,
|
|
221
|
+
toBackendLang(this.props.lang),
|
|
207
222
|
),
|
|
208
223
|
};
|
|
209
224
|
}
|
|
@@ -222,7 +237,6 @@ class RecurrenceWidget extends Component {
|
|
|
222
237
|
|
|
223
238
|
if (changedStart || changedEnd) {
|
|
224
239
|
let start = this.getUTCDate(this.props.formData?.start).toDate();
|
|
225
|
-
// let end = this.getUTCDate(this.props.formData?.end).toDate();
|
|
226
240
|
|
|
227
241
|
let changeFormValues = {};
|
|
228
242
|
if (changedEnd) {
|
|
@@ -240,7 +254,6 @@ class RecurrenceWidget extends Component {
|
|
|
240
254
|
'dtstart',
|
|
241
255
|
start,
|
|
242
256
|
);
|
|
243
|
-
|
|
244
257
|
return {
|
|
245
258
|
...prevState,
|
|
246
259
|
rruleSet,
|
|
@@ -255,6 +268,29 @@ class RecurrenceWidget extends Component {
|
|
|
255
268
|
}
|
|
256
269
|
}
|
|
257
270
|
|
|
271
|
+
cleanRRuleObject(rruleObj) {
|
|
272
|
+
// Recursive function for rrule options object cleanup
|
|
273
|
+
function cleanObject(obj) {
|
|
274
|
+
// Use _.omitBy to remove all objectlike falsish and falsish values, preserve dates/string dates/strings/booleans
|
|
275
|
+
return omitBy(obj, (value) => {
|
|
276
|
+
if (
|
|
277
|
+
(isString(value) && !isNaN(Date.parse(value))) ||
|
|
278
|
+
(value instanceof Date && !isNaN(value.getTime()))
|
|
279
|
+
)
|
|
280
|
+
return false;
|
|
281
|
+
if (isString(value) || isBoolean(value) || isNumber(value))
|
|
282
|
+
return false;
|
|
283
|
+
// Everything else goes
|
|
284
|
+
return (
|
|
285
|
+
isNil(value) ||
|
|
286
|
+
(isArray(value) && isEmpty(value)) ||
|
|
287
|
+
(isObject(value) && isEmpty(value))
|
|
288
|
+
);
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
return cleanObject(rruleObj);
|
|
292
|
+
}
|
|
293
|
+
|
|
258
294
|
editRecurrence = () => {
|
|
259
295
|
this.setRecurrenceStartEnd();
|
|
260
296
|
};
|
|
@@ -262,25 +298,31 @@ class RecurrenceWidget extends Component {
|
|
|
262
298
|
setRecurrenceStartEnd = () => {
|
|
263
299
|
const start = this.props.formData?.start;
|
|
264
300
|
|
|
265
|
-
|
|
301
|
+
// The `start` date from Plone is in UTC
|
|
302
|
+
const _start = new Date(start);
|
|
266
303
|
|
|
267
304
|
this.setState((prevState) => {
|
|
268
|
-
let
|
|
269
|
-
const formValues = this.getFormValues(
|
|
305
|
+
let editRruleSet = prevState.rruleSet;
|
|
306
|
+
const formValues = this.getFormValues(editRruleSet); //to set default values, included end
|
|
270
307
|
|
|
271
|
-
|
|
308
|
+
editRruleSet = this.updateRruleSet(
|
|
309
|
+
editRruleSet,
|
|
310
|
+
formValues,
|
|
311
|
+
'dtstart',
|
|
312
|
+
_start,
|
|
313
|
+
);
|
|
272
314
|
return {
|
|
273
315
|
...prevState,
|
|
274
|
-
|
|
316
|
+
editRruleSet,
|
|
275
317
|
formValues,
|
|
276
318
|
};
|
|
277
319
|
});
|
|
278
320
|
};
|
|
279
321
|
|
|
280
322
|
getUTCDate = (date) => {
|
|
281
|
-
return date
|
|
282
|
-
? moment(date).utc()
|
|
283
|
-
: moment(`${date}Z`).utc();
|
|
323
|
+
return date?.match(/T(.)*(-|\+|Z)/g)
|
|
324
|
+
? this.moment(date).utc()
|
|
325
|
+
: this.moment(`${date}Z`).utc();
|
|
284
326
|
};
|
|
285
327
|
|
|
286
328
|
show = (dimmer) => () => {
|
|
@@ -320,24 +362,23 @@ class RecurrenceWidget extends Component {
|
|
|
320
362
|
* */
|
|
321
363
|
getFormValues = (rruleSet) => {
|
|
322
364
|
//default
|
|
323
|
-
let formValues = {
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
);
|
|
365
|
+
let formValues = {};
|
|
366
|
+
if (!formValues.recurrenceEnds)
|
|
367
|
+
formValues = this.changeField(
|
|
368
|
+
formValues,
|
|
369
|
+
'recurrenceEnds',
|
|
370
|
+
this.props.formData?.end && !this.props?.formData?.open_end
|
|
371
|
+
? 'until'
|
|
372
|
+
: 'count',
|
|
373
|
+
);
|
|
333
374
|
|
|
334
375
|
const rrule = rruleSet.rrules()[0];
|
|
335
376
|
|
|
336
|
-
if (rrule) {
|
|
337
|
-
|
|
338
|
-
|
|
377
|
+
if (rrule?.options) {
|
|
378
|
+
const rruleOptions = this.cleanRRuleObject(rrule.options);
|
|
379
|
+
var freq = this.getFreq(rruleOptions?.freq, rruleOptions?.byweekday);
|
|
339
380
|
//init with rruleOptions
|
|
340
|
-
Object.entries(
|
|
381
|
+
Object.entries(rruleOptions).forEach(([option, value]) => {
|
|
341
382
|
switch (option) {
|
|
342
383
|
case 'freq':
|
|
343
384
|
formValues[option] = freq;
|
|
@@ -346,28 +387,31 @@ class RecurrenceWidget extends Component {
|
|
|
346
387
|
if (value != null) {
|
|
347
388
|
formValues['recurrenceEnds'] = option;
|
|
348
389
|
formValues[option] = value;
|
|
390
|
+
formValues['until'] = null;
|
|
349
391
|
}
|
|
350
392
|
break;
|
|
351
393
|
case 'until':
|
|
352
|
-
|
|
353
|
-
|
|
394
|
+
// Handle open ended events
|
|
395
|
+
if (
|
|
396
|
+
(value !== null && this.props.formData.end) ||
|
|
397
|
+
this.props.formData.open_end
|
|
398
|
+
) {
|
|
399
|
+
if (value !== null) formValues['recurrenceEnds'] = option;
|
|
354
400
|
formValues[option] = value;
|
|
355
401
|
}
|
|
356
402
|
break;
|
|
357
403
|
case 'byweekday':
|
|
404
|
+
// Correct handling of freq
|
|
358
405
|
if (value && value.length > 0) {
|
|
359
406
|
if (isEqual(value, WEEKLY_DAYS)) {
|
|
360
407
|
formValues['freq'] = FREQUENCES.WEEKDAYS;
|
|
361
|
-
}
|
|
362
|
-
if (isEqual(value, MONDAYFRIDAY_DAYS)) {
|
|
408
|
+
} else if (isEqual(value, MONDAYFRIDAY_DAYS)) {
|
|
363
409
|
formValues['freq'] = FREQUENCES.MONDAYFRIDAY;
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
formValues[option] = value
|
|
367
|
-
? value.map((d) => {
|
|
410
|
+
} else
|
|
411
|
+
formValues[option] = value.map((d) => {
|
|
368
412
|
return this.getWeekday(d);
|
|
369
|
-
})
|
|
370
|
-
|
|
413
|
+
});
|
|
414
|
+
}
|
|
371
415
|
break;
|
|
372
416
|
case 'bymonthday':
|
|
373
417
|
if (value && value.length > 0) {
|
|
@@ -391,7 +435,7 @@ class RecurrenceWidget extends Component {
|
|
|
391
435
|
if (value && value.length > 0) {
|
|
392
436
|
//[weekDayNumber,orinal_number] -> translated is for example: [sunday, third] -> the third sunday of the month
|
|
393
437
|
|
|
394
|
-
if (freq === FREQUENCES.
|
|
438
|
+
if (freq === FREQUENCES.MONTHLY) {
|
|
395
439
|
formValues['monthly'] = 'byweekday';
|
|
396
440
|
}
|
|
397
441
|
if (freq === FREQUENCES.YEARLY) {
|
|
@@ -406,13 +450,19 @@ class RecurrenceWidget extends Component {
|
|
|
406
450
|
formValues['yearly'] = 'byday';
|
|
407
451
|
}
|
|
408
452
|
formValues['monthOfTheYear'] = value ? value[0] : null;
|
|
453
|
+
// Fix bymonth handling
|
|
454
|
+
formValues[option] = value ? value : null;
|
|
409
455
|
break;
|
|
410
|
-
|
|
411
456
|
default:
|
|
412
457
|
formValues[option] = value;
|
|
413
458
|
}
|
|
414
459
|
});
|
|
415
|
-
}
|
|
460
|
+
} else
|
|
461
|
+
formValues = {
|
|
462
|
+
...formValues,
|
|
463
|
+
freq: FREQUENCES.DAILY,
|
|
464
|
+
interval: 1,
|
|
465
|
+
};
|
|
416
466
|
return formValues;
|
|
417
467
|
};
|
|
418
468
|
|
|
@@ -423,7 +473,6 @@ class RecurrenceWidget extends Component {
|
|
|
423
473
|
NoRRuleOptions.forEach((opt) => {
|
|
424
474
|
delete values[opt];
|
|
425
475
|
});
|
|
426
|
-
|
|
427
476
|
//transform values for rrule
|
|
428
477
|
Object.keys(values).forEach((field) => {
|
|
429
478
|
var value = values[field];
|
|
@@ -436,17 +485,17 @@ class RecurrenceWidget extends Component {
|
|
|
436
485
|
case 'until':
|
|
437
486
|
let mDate = null;
|
|
438
487
|
if (value) {
|
|
439
|
-
mDate = moment(new Date(value));
|
|
488
|
+
mDate = this.moment(new Date(value));
|
|
440
489
|
if (typeof value === 'string') {
|
|
441
|
-
mDate = moment(new Date(value));
|
|
490
|
+
mDate = this.moment(new Date(value));
|
|
442
491
|
} else {
|
|
443
492
|
//object-->Date()
|
|
444
|
-
mDate = moment(value);
|
|
493
|
+
mDate = this.moment(value);
|
|
445
494
|
}
|
|
446
495
|
|
|
447
496
|
if (this.props.formData.end) {
|
|
448
497
|
//set time from formData.end
|
|
449
|
-
const mEnd = moment(new Date(this.props.formData.end));
|
|
498
|
+
const mEnd = this.moment(new Date(this.props.formData.end));
|
|
450
499
|
mDate.set('hour', mEnd.get('hour'));
|
|
451
500
|
mDate.set('minute', mEnd.get('minute'));
|
|
452
501
|
}
|
|
@@ -456,8 +505,7 @@ class RecurrenceWidget extends Component {
|
|
|
456
505
|
default:
|
|
457
506
|
break;
|
|
458
507
|
}
|
|
459
|
-
|
|
460
|
-
if (value) {
|
|
508
|
+
if (value === 0 || value) {
|
|
461
509
|
//set value
|
|
462
510
|
values[field] = value;
|
|
463
511
|
} else {
|
|
@@ -470,41 +518,67 @@ class RecurrenceWidget extends Component {
|
|
|
470
518
|
};
|
|
471
519
|
|
|
472
520
|
updateRruleSet = (rruleSet, formValues, field, value) => {
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
521
|
+
let rruleOptions = this.formValuesToRRuleOptions(formValues);
|
|
522
|
+
let dstart = undefined;
|
|
523
|
+
if (rruleSet.dtstart()) {
|
|
524
|
+
// Se hai una ricorrenza usala
|
|
525
|
+
dstart = rruleSet.dtstart();
|
|
526
|
+
} else {
|
|
527
|
+
if (this.props.formData.start) {
|
|
528
|
+
// Verifica chi tra start e end vuoi usare in base al contronto tra le date e al flag fine aperta
|
|
529
|
+
const mstart = this.moment(new Date(this.props.formData.start));
|
|
530
|
+
const mend = this.moment(new Date(this.props.formData.end));
|
|
531
|
+
if (mstart.isSame(mend, 'day')) {
|
|
532
|
+
dstart = mstart.toDate();
|
|
533
|
+
} else {
|
|
534
|
+
if (this.props.formData.open_end) dstart = mstart.toDate();
|
|
535
|
+
else dstart = mend.toDate();
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
let exdates = Object.assign([], rruleSet.exdates());
|
|
540
|
+
let rdates = Object.assign([], rruleSet.rdates());
|
|
541
|
+
if (field === 'dstart') dstart = value;
|
|
542
|
+
else if (field === 'exdates') exdates = value;
|
|
543
|
+
else if (field === 'rdates') rdates = value;
|
|
544
|
+
else if (field === 'freq') {
|
|
545
|
+
// reset ex and rdates
|
|
546
|
+
exdates = [];
|
|
547
|
+
rdates = [];
|
|
548
|
+
}
|
|
485
549
|
|
|
486
550
|
rruleOptions.dtstart = dstart;
|
|
551
|
+
let sanitizedRruleOptions = this.cleanRRuleObject(rruleOptions);
|
|
552
|
+
|
|
553
|
+
const { RRule, RRuleSet } = this.props.rrule;
|
|
487
554
|
|
|
488
555
|
let set = new RRuleSet();
|
|
489
556
|
//set.dtstart(dstart);
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
557
|
+
if (!sanitizedRruleOptions.count && !sanitizedRruleOptions.until) {
|
|
558
|
+
// Limit to 100, otherwise you can get up tp 500k recurrences, blocking browser
|
|
559
|
+
// 100 is an arbitrary value
|
|
560
|
+
sanitizedRruleOptions = { ...sanitizedRruleOptions, count: 100 };
|
|
561
|
+
}
|
|
562
|
+
set.rrule(new RRule(sanitizedRruleOptions));
|
|
563
|
+
for (const ex of exdates) set.exdate(ex);
|
|
564
|
+
for (const r of rdates) set.rdate(r);
|
|
495
565
|
return set;
|
|
496
566
|
};
|
|
497
567
|
|
|
498
568
|
getDefaultUntil = (freq) => {
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
569
|
+
// No clue why this opinionated set of rules
|
|
570
|
+
// Let's handle open end events
|
|
571
|
+
const moment = this.moment;
|
|
572
|
+
let end =
|
|
573
|
+
this.props.formData?.end && !this.props.formData?.open_end
|
|
574
|
+
? moment(new Date(this.props.formData.end))
|
|
575
|
+
: null;
|
|
502
576
|
var tomorrow = moment().add(1, 'days');
|
|
503
577
|
var nextWeek = moment().add(7, 'days');
|
|
504
578
|
var nextMonth = moment().add(1, 'months');
|
|
505
579
|
var nextYear = moment().add(1, 'years');
|
|
506
580
|
|
|
507
|
-
|
|
581
|
+
let until = end;
|
|
508
582
|
switch (freq) {
|
|
509
583
|
case FREQUENCES.DAILY:
|
|
510
584
|
until = end ? end : tomorrow;
|
|
@@ -527,38 +601,39 @@ class RecurrenceWidget extends Component {
|
|
|
527
601
|
default:
|
|
528
602
|
break;
|
|
529
603
|
}
|
|
530
|
-
if (this.props.formData.end) {
|
|
531
|
-
//set default end time
|
|
532
|
-
until.set('hour', end.get('hour'));
|
|
533
|
-
until.set('minute', end.get('minute'));
|
|
534
|
-
}
|
|
535
604
|
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
605
|
+
// if (this.props.formData.end) {
|
|
606
|
+
// //set default end time
|
|
607
|
+
// until.set('hour', end.get('hour'));
|
|
608
|
+
// until.set('minute', end.get('minute'));
|
|
609
|
+
// }
|
|
610
|
+
if (until)
|
|
611
|
+
until = new Date(
|
|
612
|
+
until.get('year'),
|
|
613
|
+
until.get('month'),
|
|
614
|
+
until.get('date'),
|
|
615
|
+
until.get('hour'),
|
|
616
|
+
until.get('minute'),
|
|
617
|
+
);
|
|
543
618
|
|
|
544
619
|
return until;
|
|
545
620
|
};
|
|
546
621
|
|
|
547
622
|
changeField = (formValues, field, value) => {
|
|
548
|
-
// git p.log('field', field, 'value', value);
|
|
549
623
|
//get weekday from state.
|
|
550
|
-
|
|
624
|
+
const moment = this.moment;
|
|
625
|
+
const byweekday =
|
|
551
626
|
this.state?.rruleSet?.rrules().length > 0
|
|
552
627
|
? this.state.rruleSet.rrules()[0].origOptions.byweekday
|
|
553
628
|
: null;
|
|
554
|
-
|
|
555
|
-
|
|
629
|
+
const currWeekday = this.getWeekday(moment().day() - 1);
|
|
630
|
+
const currMonth = moment().month() + 1;
|
|
556
631
|
|
|
557
|
-
|
|
632
|
+
const startMonth = this.props.formData?.start
|
|
558
633
|
? moment(this.props.formData.start).month() + 1
|
|
559
634
|
: currMonth;
|
|
560
635
|
|
|
561
|
-
|
|
636
|
+
const startWeekday = this.props.formData?.start
|
|
562
637
|
? this.getWeekday(moment(this.props.formData.start).day() - 1)
|
|
563
638
|
: currWeekday;
|
|
564
639
|
formValues[field] = value;
|
|
@@ -583,7 +658,11 @@ class RecurrenceWidget extends Component {
|
|
|
583
658
|
formValues = this.changeField(formValues, 'byweekday', null);
|
|
584
659
|
formValues = this.changeField(formValues, 'monthOfTheYear', null);
|
|
585
660
|
|
|
586
|
-
if (
|
|
661
|
+
if (
|
|
662
|
+
!formValues.count &&
|
|
663
|
+
!formValues.until &&
|
|
664
|
+
!this.props.formData.open_end
|
|
665
|
+
) {
|
|
587
666
|
formValues.until = this.getDefaultUntil(value);
|
|
588
667
|
}
|
|
589
668
|
|
|
@@ -656,7 +735,8 @@ class RecurrenceWidget extends Component {
|
|
|
656
735
|
break;
|
|
657
736
|
|
|
658
737
|
case 'monthOfTheYear':
|
|
659
|
-
|
|
738
|
+
// Fix check, null and undefined are falsish
|
|
739
|
+
if (!value) {
|
|
660
740
|
delete formValues.bymonth;
|
|
661
741
|
} else {
|
|
662
742
|
formValues.bymonth = [value];
|
|
@@ -706,6 +786,10 @@ class RecurrenceWidget extends Component {
|
|
|
706
786
|
default:
|
|
707
787
|
break;
|
|
708
788
|
}
|
|
789
|
+
// Somehow it goes missing sometimes, no clue where anymore, force add it
|
|
790
|
+
if (formValues?.weekdayOfTheMonth && !formValues.monthly) {
|
|
791
|
+
formValues = { ...formValues, monthly: 'byweekday' };
|
|
792
|
+
}
|
|
709
793
|
return formValues;
|
|
710
794
|
};
|
|
711
795
|
|
|
@@ -714,24 +798,41 @@ class RecurrenceWidget extends Component {
|
|
|
714
798
|
formValues = this.changeField(formValues, field, value);
|
|
715
799
|
|
|
716
800
|
this.setState((prevState) => {
|
|
717
|
-
var
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
...prevState,
|
|
721
|
-
rruleSet,
|
|
801
|
+
var editRruleSet = prevState.editRruleSet;
|
|
802
|
+
editRruleSet = this.updateRruleSet(
|
|
803
|
+
editRruleSet,
|
|
722
804
|
formValues,
|
|
723
|
-
|
|
805
|
+
field,
|
|
806
|
+
value,
|
|
807
|
+
);
|
|
808
|
+
return editRruleSet
|
|
809
|
+
? {
|
|
810
|
+
...prevState,
|
|
811
|
+
editRruleSet,
|
|
812
|
+
formValues,
|
|
813
|
+
}
|
|
814
|
+
: { ...prevState, formValues };
|
|
724
815
|
});
|
|
725
816
|
};
|
|
726
817
|
|
|
818
|
+
// Handle rdates too, they were left behind :(
|
|
727
819
|
exclude = (date) => {
|
|
728
|
-
let
|
|
729
|
-
|
|
730
|
-
|
|
820
|
+
let additionalDates = this.state.editRruleSet.rdates();
|
|
821
|
+
let exDates = this.state.editRruleSet.exdates();
|
|
822
|
+
|
|
823
|
+
if (additionalDates.some((ad) => ad.getTime() === date.getTime())) {
|
|
824
|
+
remove(additionalDates, (ad) => {
|
|
825
|
+
return ad.getTime() === date.getTime();
|
|
826
|
+
});
|
|
827
|
+
this.onChangeRule('rdates', additionalDates);
|
|
828
|
+
} else {
|
|
829
|
+
exDates.push(date);
|
|
830
|
+
this.onChangeRule('exdates', exDates);
|
|
831
|
+
}
|
|
731
832
|
};
|
|
732
833
|
|
|
733
834
|
undoExclude = (date) => {
|
|
734
|
-
let list = this.state.
|
|
835
|
+
let list = this.state.editRruleSet.exdates().slice(0);
|
|
735
836
|
remove(list, (e) => {
|
|
736
837
|
return e.getTime() === date.getTime();
|
|
737
838
|
});
|
|
@@ -739,7 +840,11 @@ class RecurrenceWidget extends Component {
|
|
|
739
840
|
};
|
|
740
841
|
|
|
741
842
|
addDate = (date) => {
|
|
742
|
-
|
|
843
|
+
const moment = this.moment;
|
|
844
|
+
let all = concat(
|
|
845
|
+
this.state.editRruleSet.all(),
|
|
846
|
+
this.state.editRruleSet.exdates(),
|
|
847
|
+
);
|
|
743
848
|
|
|
744
849
|
var simpleDate = moment(new Date(date)).startOf('day').toDate().getTime();
|
|
745
850
|
var exists = find(all, (e) => {
|
|
@@ -747,14 +852,18 @@ class RecurrenceWidget extends Component {
|
|
|
747
852
|
return d === simpleDate;
|
|
748
853
|
});
|
|
749
854
|
if (!exists) {
|
|
750
|
-
let list = this.state.
|
|
855
|
+
let list = this.state.editRruleSet.rdates().slice(0);
|
|
751
856
|
list.push(new Date(date));
|
|
752
857
|
this.onChangeRule('rdates', list);
|
|
753
858
|
}
|
|
754
859
|
};
|
|
755
860
|
|
|
756
861
|
saveRrule = () => {
|
|
757
|
-
var value = this.state.
|
|
862
|
+
var value = this.state.editRruleSet.toString();
|
|
863
|
+
this.setState((prev) => ({
|
|
864
|
+
...prev,
|
|
865
|
+
rruleSet: prev.editRruleSet,
|
|
866
|
+
}));
|
|
758
867
|
this.props.onChange(this.props.id, value);
|
|
759
868
|
};
|
|
760
869
|
|
|
@@ -764,17 +873,19 @@ class RecurrenceWidget extends Component {
|
|
|
764
873
|
};
|
|
765
874
|
|
|
766
875
|
remove = () => {
|
|
876
|
+
const { RRuleSet } = this.props.rrule;
|
|
767
877
|
this.props.onChange(this.props.id, null);
|
|
768
878
|
let rruleSet = new RRuleSet();
|
|
769
879
|
this.setState({
|
|
880
|
+
editRruleSet: rruleSet,
|
|
770
881
|
rruleSet: rruleSet,
|
|
771
882
|
formValues: this.getFormValues(rruleSet),
|
|
772
883
|
});
|
|
773
884
|
};
|
|
774
885
|
|
|
775
886
|
render() {
|
|
776
|
-
const { open, dimmer, rruleSet, formValues, RRULE_LANGUAGE } =
|
|
777
|
-
|
|
887
|
+
const { open, dimmer, rruleSet, editRruleSet, formValues, RRULE_LANGUAGE } =
|
|
888
|
+
this.state;
|
|
778
889
|
const { id, title, required, description, error, fieldSet, intl } =
|
|
779
890
|
this.props;
|
|
780
891
|
|
|
@@ -787,7 +898,7 @@ class RecurrenceWidget extends Component {
|
|
|
787
898
|
id={`${fieldSet || 'field'}-${id}`}
|
|
788
899
|
>
|
|
789
900
|
<Grid>
|
|
790
|
-
<Grid.Row stretched>
|
|
901
|
+
<Grid.Row stretched verticalAlign="middle">
|
|
791
902
|
<Grid.Column width="4">
|
|
792
903
|
<div className="wrapper">
|
|
793
904
|
<label htmlFor={`field-${id}`}>{title}</label>
|
|
@@ -797,7 +908,7 @@ class RecurrenceWidget extends Component {
|
|
|
797
908
|
{rruleSet.rrules()[0] && (
|
|
798
909
|
<>
|
|
799
910
|
<Label>
|
|
800
|
-
{rruleSet.rrules()[0]?.toText(
|
|
911
|
+
{rruleSet.rrules()?.[0]?.toText(
|
|
801
912
|
(t) => {
|
|
802
913
|
return RRULE_LANGUAGE.strings[t];
|
|
803
914
|
},
|
|
@@ -863,7 +974,7 @@ class RecurrenceWidget extends Component {
|
|
|
863
974
|
{intl.formatMessage(messages.editRecurrence)}{' '}
|
|
864
975
|
</Modal.Header>
|
|
865
976
|
<Modal.Content scrolling>
|
|
866
|
-
{
|
|
977
|
+
{editRruleSet?.rrules()?.length > 0 && (
|
|
867
978
|
<Modal.Description>
|
|
868
979
|
<Segment>
|
|
869
980
|
<Form>
|
|
@@ -943,7 +1054,7 @@ class RecurrenceWidget extends Component {
|
|
|
943
1054
|
</Segment>
|
|
944
1055
|
<Segment>
|
|
945
1056
|
<Occurences
|
|
946
|
-
rruleSet={
|
|
1057
|
+
rruleSet={editRruleSet}
|
|
947
1058
|
exclude={this.exclude}
|
|
948
1059
|
undoExclude={this.undoExclude}
|
|
949
1060
|
/>
|
|
@@ -1007,4 +1118,10 @@ class RecurrenceWidget extends Component {
|
|
|
1007
1118
|
}
|
|
1008
1119
|
}
|
|
1009
1120
|
|
|
1010
|
-
export default
|
|
1121
|
+
export default compose(
|
|
1122
|
+
injectLazyLibs(['moment', 'rrule']),
|
|
1123
|
+
connect((state) => ({
|
|
1124
|
+
lang: state.intl.locale,
|
|
1125
|
+
})),
|
|
1126
|
+
injectIntl,
|
|
1127
|
+
)(RecurrenceWidget);
|