From 46a1a0097890c01793556dff39d9ff1a7521dc3b Mon Sep 17 00:00:00 2001 From: Johannes Raggam Date: Wed, 14 Jan 2026 11:34:58 +0100 Subject: [PATCH 1/2] fix(pat-recurrence): In an error case when loading the occurrences preview, show a inline warning instead of a window alert. --- src/pat/recurrence/recurrence.js | 11 ++++++----- src/pat/recurrence/recurrence.test.js | 26 ++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/src/pat/recurrence/recurrence.js b/src/pat/recurrence/recurrence.js index 80b883ebc..c44e9d15c 100644 --- a/src/pat/recurrence/recurrence.js +++ b/src/pat/recurrence/recurrence.js @@ -739,7 +739,6 @@ const RecurrenceInput = function (conf, textarea) { } occurrenceDiv = element.find(".rioccurrences"); - occurrenceDiv.hide(); const year = startdate.getFullYear(); const month = startdate.getMonth() + 1; @@ -811,11 +810,11 @@ const RecurrenceInput = function (conf, textarea) { .find(".rioccurrences .action a.rdate") .on("click", occurrenceDelete); } - // Show the new div - occurrenceDiv.show(); }, - error: function (jqXHR, textStatus) { - alert(textStatus); + error: function () { + occurrenceDiv[0].innerHTML = ` +
${conf.localization.error_load_occurrences}
+ `; }, }); } @@ -1377,6 +1376,8 @@ export default Base.extend({ monthly: "Monthly", yearly: "Yearly", }, + + error_load_occurrences: "Cannot load the occurrences preview.", }, readOnly: false, diff --git a/src/pat/recurrence/recurrence.test.js b/src/pat/recurrence/recurrence.test.js index 521807dea..8c26c39ff 100644 --- a/src/pat/recurrence/recurrence.test.js +++ b/src/pat/recurrence/recurrence.test.js @@ -28,4 +28,30 @@ describe("Recurrence", function () { ).toEqual("none"); expect(document.querySelector("div.riform").style.display).toEqual("none"); }); + + it("Adds a warning, if the occurrences preview cannot be loaded.", async function () { + // Without any test mock server, the occurrences preview cannot be loaded. + document.body.innerHTML = ` + + + `; + + registry.scan(document.body); + await utils.timeout(1); + + const edit_btn = document.querySelector("[name=riedit]"); + edit_btn.click(); + + const occurrences_preview = document.querySelector( + ".rioccurrences .alert-warning", + ); + expect(occurrences_preview).toBeTruthy(); + expect(occurrences_preview.textContent.trim()).toBe( + "Cannot load the occurrences preview.", + ); + }); }); From 4193b9b6529aa1d2f56d0bda968752516cdf7dde Mon Sep 17 00:00:00 2001 From: Johannes Raggam Date: Tue, 13 Jan 2026 23:21:35 +0100 Subject: [PATCH 2/2] feat(pat-recurrence): Allow to enable/disable the feature to add additional dates. Ref: https://github.com/plone/plone.formwidget.recurrence/pull/66 Fixes: https://github.com/plone/plone.formwidget.recurrence/issues/49 --- src/pat/recurrence/README.md | 50 +++++++++++++++++++++++++-- src/pat/recurrence/recurrence.js | 1 + src/pat/recurrence/recurrence.test.js | 41 ++++++++++++++++++++++ src/pat/recurrence/templates/form.xml | 2 ++ 4 files changed, 92 insertions(+), 2 deletions(-) diff --git a/src/pat/recurrence/README.md b/src/pat/recurrence/README.md index c926ec4f3..5bc964ae5 100644 --- a/src/pat/recurrence/README.md +++ b/src/pat/recurrence/README.md @@ -16,8 +16,54 @@ Show the recurrence widget. ## Example - +### Recurrence without additional start feature + + + + +```html + +``` + +### Recurrence with additional start feature + +Note: adding additional start dates is a feature of the specification but is +not supported by a number of external tools, like Google Calendar, Microsoft +Outlook or Gnome Calendar. +Therefore, this feature is disabled by default. +However, you can enable it with the `hasAdditionalDates` feature. + + + ```html - + ``` diff --git a/src/pat/recurrence/recurrence.js b/src/pat/recurrence/recurrence.js index c44e9d15c..6fe02ae21 100644 --- a/src/pat/recurrence/recurrence.js +++ b/src/pat/recurrence/recurrence.js @@ -1393,6 +1393,7 @@ export default Base.extend({ ributtonExtraClass: "", // INPUT CONFIGURATION + hasAdditionalDates: false, hasRepeatForeverButton: true, // JQUERY TEMPLATE NAMES diff --git a/src/pat/recurrence/recurrence.test.js b/src/pat/recurrence/recurrence.test.js index 8c26c39ff..c227979ec 100644 --- a/src/pat/recurrence/recurrence.test.js +++ b/src/pat/recurrence/recurrence.test.js @@ -54,4 +54,45 @@ describe("Recurrence", function () { "Cannot load the occurrences preview.", ); }); + + it("Initializes without the additional dates feature.", async function () { + document.body.innerHTML = ` + + + `; + + registry.scan(document.body); + await utils.timeout(1); + + const edit_btn = document.querySelector("[name=riedit]"); + edit_btn.click(); + + const add_occurrence = document.querySelector(".modal .riaddoccurrence"); + expect(add_occurrence).toBeFalsy(); + }); + + it("Initializes with the additional dates feature.", async function () { + document.body.innerHTML = ` + + + `; + + registry.scan(document.body); + await utils.timeout(1); + + const edit_btn = document.querySelector("[name=riedit]"); + edit_btn.click(); + + const add_occurrence = document.querySelector(".modal .riaddoccurrence"); + expect(add_occurrence).toBeTruthy(); + }); }); diff --git a/src/pat/recurrence/templates/form.xml b/src/pat/recurrence/templates/form.xml index d3db8cf9c..fe55aba56 100644 --- a/src/pat/recurrence/templates/form.xml +++ b/src/pat/recurrence/templates/form.xml @@ -291,6 +291,7 @@
+ <% if (hasAdditionalDates === true) { %>
<%= localization.addDate %>
@@ -299,6 +300,7 @@
+ <% } %>