From a981c66730255e73234854ddab88cce73e3e11ab Mon Sep 17 00:00:00 2001 From: Yuriy Bakhtin Date: Fri, 12 Jul 2024 18:49:55 +0200 Subject: [PATCH 1/2] Display info after delete event entry --- controllers/EntryController.php | 14 ++++++++++++-- docs/CHANGELOG.md | 3 +++ module.json | 2 +- resources/js/humhub.calendar.js | 13 +++++++++++-- resources/js/humhub.calendar.min.js | 2 +- 5 files changed, 28 insertions(+), 6 deletions(-) diff --git a/controllers/EntryController.php b/controllers/EntryController.php index 5ffd61db..fecbca49 100644 --- a/controllers/EntryController.php +++ b/controllers/EntryController.php @@ -544,10 +544,20 @@ public function actionDelete($id) throw new HttpException('403', Yii::t('CalendarModule.base', "You don't have permission to delete this event!")); } - $calendarEntry->delete(); + if (!$calendarEntry->delete()) { + return Yii::$app->request->isAjax + ? $this->asJson([ + 'success' => false, + 'message' => Yii::t('CalendarModule.base', 'Event could not be deleted!'), + ]) + : $this->redirect(Url::toEntry($calendarEntry)); + } return Yii::$app->request->isAjax - ? $this->asJson(['success' => true]) + ? $this->asJson([ + 'success' => true, + 'message' => Yii::t('CalendarModule.base', 'Event has been be deleted!'), + ]) : $this->redirect(Url::toCalendar($this->contentContainer)); } diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 77009fa9..479d4d14 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,6 +1,9 @@ Changelog ========= +1.6.2 (Unreleased) +-------------------- +- Enh #495: Display info after delete event entry 1.6.1 (July 3, 2024) -------------------- diff --git a/module.json b/module.json index eb447bd4..2aebfb22 100644 --- a/module.json +++ b/module.json @@ -3,7 +3,7 @@ "name": "Calendar", "description": "Create one-time or recurring events, invite and manage attendees, and keep track of all your events with the Calendar module.", "keywords": ["calendar"], - "version": "1.6.1", + "version": "1.6.2", "humhub": { "minVersion": "1.16.1" }, diff --git a/resources/js/humhub.calendar.js b/resources/js/humhub.calendar.js index b20e0ee6..3eff8179 100644 --- a/resources/js/humhub.calendar.js +++ b/resources/js/humhub.calendar.js @@ -12,6 +12,7 @@ humhub.module('calendar', function (module, require, $) { var Content = require('content').Content; var event = require('event'); var StreamEntry = require('stream').StreamEntry; + var status = require('ui.status'); var Calendar = Widget.extend(); var Form = Widget.extend(); @@ -325,10 +326,18 @@ humhub.module('calendar', function (module, require, $) { streamEntry.loader(); modal.confirm().then(function (confirm) { if (confirm) { - client.post(evt).then(function () { - modal.global.close(); + client.post(evt).then(function (response) { + if (response.success) { + status.success(response.message); + modal.global.close(); + } else if (response.message) { + status.error(response.message); + } }).catch(function (e) { module.log.error(e, true); + if (e.message) { + status.error(e.message); + } }); } else { var streamEntry = Widget.closest(evt.$trigger); diff --git a/resources/js/humhub.calendar.min.js b/resources/js/humhub.calendar.min.js index 935f1cb8..ec82b8c8 100644 --- a/resources/js/humhub.calendar.min.js +++ b/resources/js/humhub.calendar.min.js @@ -1 +1 @@ -humhub.module("calendar",function(o,t,l){var i=t("ui.widget").Widget,r=t("client"),a=t("ui.modal"),d=t("action"),n=t("content").Content,c=t("event"),s=t("stream").StreamEntry,u=i.extend(),f=i.extend();f.RECUR_EDIT_MODE_CREATE=0,f.RECUR_EDIT_MODE_THIS=1,f.RECUR_EDIT_MODE_FOLLOWING=2,f.RECUR_EDIT_MODE_ALL=3,f.prototype.init=function(){a.global.$.find(".tab-basic").on("shown.bs.tab",function(t){l("#calendarentry-title").focus()}),a.global.$.find(".tab-participation").on("shown.bs.tab",function(t){l("#calendarentry-participation_mode").focus()}),this.initDateTimeCorrector(),this.initTimeInput(),this.initSubmitAction()},f.prototype.initDateTimeCorrector=function(){function n(t){t=t.split(":");var e=parseInt(t[0]);return 12===e&&t[1].includes("AM")?e=0:e+=t[1].includes("PM")&&e<12?12:0,60*e+parseInt(t[1])}function o(){return{start:l(r+"date").datepicker("getDate").getTime(),end:l(a+"date").datepicker("getDate").getTime()}}function e(t,e,n){var o,i,r,a,d=1440;if(e<0||d<=e){var c=new Date(l(t+"date").datepicker("getDate"));c.setDate(c.getDate()+(e<0?-1:1)),l(t+"date").datepicker("setDate",c),e+=e<0?d:-d}l(t+"time").val((r=((o=e)-(i=o%60))/60,a="","12h"===n&&(a=r<12?" AM":" PM",0===r?r=12:12 Date: Tue, 16 Jul 2024 10:05:12 +0200 Subject: [PATCH 2/2] Fix column `exdate` to delete more than 16 recurrence event entries --- docs/CHANGELOG.md | 2 +- migrations/m240716_075328_fix_exdate.php | 27 ++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 migrations/m240716_075328_fix_exdate.php diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 479d4d14..62aa6579 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -3,7 +3,7 @@ Changelog 1.6.2 (Unreleased) -------------------- -- Enh #495: Display info after delete event entry +- Enh #495: Fix column `exdate` to delete more than 16 recurrence event entries 1.6.1 (July 3, 2024) -------------------- diff --git a/migrations/m240716_075328_fix_exdate.php b/migrations/m240716_075328_fix_exdate.php new file mode 100644 index 00000000..6b63f9fa --- /dev/null +++ b/migrations/m240716_075328_fix_exdate.php @@ -0,0 +1,27 @@ +alterColumn('calendar_entry', 'exdate', $this->text()->null()); + } + + /** + * {@inheritdoc} + */ + public function safeDown() + { + echo "m240716_075328_fix_exdate cannot be reverted.\n"; + + return false; + } +}