Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix period selector on default reminder settings #498

Merged
merged 1 commit into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Changelog
=========

1.6.3 (Unreleased)
---------------------
- Enh #466: Fix period selector on default reminder settings

1.6.2 (July 16, 2024)
---------------------
- Enh #495: Fix column `exdate` to delete more than 16 recurrence event entries
Expand Down
8 changes: 6 additions & 2 deletions models/reminder/forms/ReminderSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ public function init()
protected function initReminders()
{
$this->reminders = $this->loadReminder();
$this->reminders[] = new CalendarReminder();
if (count($this->reminders) < $this->getMaxReminders()) {
$this->reminders[] = new CalendarReminder();
}
}

protected function loadReminder($defaults = true)
Expand Down Expand Up @@ -231,7 +233,9 @@ public function save()
$this->initReminder(1)->save();
}

$this->reminders[] = new CalendarReminder();
if (count($this->reminders) < $this->getMaxReminders()) {
$this->reminders[] = new CalendarReminder();
}

if($this->isGlobalSettings() || $this->isContainerLevelSettings()) {
CalendarReminder::flushDefautlts();
Expand Down
2 changes: 1 addition & 1 deletion module.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.2",
"version": "1.6.3",
"humhub": {
"minVersion": "1.16.1"
},
Expand Down
41 changes: 23 additions & 18 deletions resources/js/humhub.calendar.reminder.Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,38 @@
humhub.module('calendar.reminder.Form', function (module, require, $) {
var Widget = require('ui.widget').Widget;
var client = require('client');
var additions = require('ui.additions');

var SELECTOR_ITEMS = '.calendar-reminder-items';
var SELECTOR_ITEM = '[data-reminder-index]';
var SELECTOR_DEFAULT_ITEMS = '.calendar-reminder-item-defaults';
var SELECTOR_USE_DEFAULT_CHECKBOX = '#remindersettings-usedefaults';
var SELECTOR_REMINDER_TYPE_DROPDOWN = '#remindersettings-remindertype';
var SELECTOR_ADD_BUTTON = '.btn-primary[data-action-click="add"]';
var SELECTOR_BUTTON = '[data-action-click]';

var REMINDER_TYPE_NONE = 0;
var REMINDER_TYPE_DEFAULTS = 1;
var REMINDER_TYPE_CUSTOM = 2;

var Form = Widget.extend();

Form.prototype.init = function(evt) {
Form.prototype.init = function() {
this.checkMaxReminder();
this.checkRemidnerType();
};

Form.prototype.checkMaxReminder = function() {
var count = this.$.find(SELECTOR_ITEMS).find('[data-reminder-index]').length;
if(count >= this.options.maxReminder) {
this.$.find(SELECTOR_ADD_BUTTON).hide();
} else {
this.$.find(SELECTOR_ADD_BUTTON).show();
var rows = this.$.find(SELECTOR_ITEM);

this.$.find(SELECTOR_BUTTON).data('action-click', 'delete')
.removeClass('btn-primary').addClass('btn-danger')
.find('i')
.removeClass('fa-plus').addClass('fa-times');

if (rows.length < this.options.maxReminder) {
rows.last().find(SELECTOR_BUTTON).data('action-click', 'add')
.removeClass('btn-danger').addClass('btn-primary')
.find('i')
.removeClass('fa-times').addClass('fa-plus');
}
};

Expand Down Expand Up @@ -64,19 +72,16 @@ humhub.module('calendar.reminder.Form', function (module, require, $) {
var $newRow = $triggerRow.clone().attr('data-reminder-index', ++$lastIndex);

$newRow.find('[name]').each(function() {
var name = $(this).attr('name').replace(/CalendarReminder\[[0-9]]/, 'CalendarReminder['+$lastIndex+']');
$(this).attr('name', name);
$(this).attr('name', $(this).attr('name').replace(/^CalendarReminder\[\d]/, 'CalendarReminder[' + $lastIndex + ']'));
});
$newRow.find('[id]').each(function() {
$(this).attr('id', $(this).attr('id').replace(/^calendarreminder-\d/, 'calendarreminder-' + $lastIndex));
});
$newRow.find('.select2-container').remove();
additions.applyTo($newRow);

$newRow.insertAfter($triggerRow);

evt.$trigger.data('action-click', 'delete')
.removeClass('btn-primary')
.addClass('btn-danger')
.find('i')
.removeClass('fa-plus')
.addClass('fa-times');

this.checkMaxReminder();
};

Expand All @@ -92,4 +97,4 @@ humhub.module('calendar.reminder.Form', function (module, require, $) {


module.export = Form;
});
});
2 changes: 1 addition & 1 deletion resources/js/humhub.calendar.reminder.Form.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading