Skip to content
Snippets Groups Projects
Commit c9447e18 authored by Moritz Strohm's avatar Moritz Strohm
Browse files

Merge branch 'tic-12' into 'main', re #12

Vor dem tatsächlichen Verschieben einer Buchung im Belegungsplan soll eine Sicherheitsabfrage erscheinen

See merge request studip/studip!4
parents 4b3566e3 b057fbb1
No related branches found
No related tags found
No related merge requests found
......@@ -31,6 +31,12 @@ class Settings_GeneralController extends Settings_SettingsController
PageLayout::setTitle(_('Allgemeine Einstellungen anpassen'));
Navigation::activateItem('/profile/settings/general');
SkipLinks::addIndex(_('Allgemeine Einstellungen anpassen'), 'layout_content', 100);
$this->show_room_management_autor_config = Config::get()->RESOURCES_ENABLE
&& (
ResourceManager::userHasGlobalPermission($this->user, 'autor')
||
RoomManager::userHasRooms($this->user, 'autor')
);
}
/**
......@@ -63,6 +69,9 @@ class Settings_GeneralController extends Settings_SettingsController
$this->config->store('SKIPLINKS_ENABLE', Request::int('skiplinks_enable'));
$this->config->store('TOUR_AUTOSTART_DISABLE', Request::int('tour_autostart_disable'));
$this->config->store('WIKI_COMMENTS_ENABLE', Request::int('wiki_comments_enable'));
if ($this->show_room_management_autor_config) {
$this->config->store('RESOURCES_CONFIRM_PLAN_DRAG_AND_DROP', Request::int('resources_confirm_plan_drag_and_drop'));
}
if (Config::get()->WYSIWYG) {
$this->config->store('WYSIWYG_DISABLED', !Request::int('wysiwyg_enabled'));
......
......@@ -88,7 +88,14 @@
'display_all_requests' => $display_all_requests ? 1 : 0
]
]
]
],
'confirm' => (
UserConfig::get($GLOBALS['user']->id)->RESOURCES_CONFIRM_PLAN_DRAG_AND_DROP
? [
'drop' => _('Wollen Sie die Buchung wirklich ändern?')
]
: []
)
],
['class' => 'resource-plan'],
'resources-fullcalendar'
......
......@@ -70,7 +70,14 @@
'display_all_requests' => $display_all_requests ? 1 : 0
]
]
]
],
'confirm' => (
UserConfig::get($GLOBALS['user']->id)->RESOURCES_CONFIRM_PLAN_DRAG_AND_DROP
? [
'drop' => _('Wollen Sie die Buchung wirklich ändern?')
]
: []
)
],
['class' => 'resource-plan room-group-booking-plan'],
'resources-fullcalendar'
......
......@@ -142,6 +142,21 @@ $start_pages = [
</fieldset>
<? endif; ?>
<? if ($show_room_management_autor_config) : ?>
<fieldset>
<legend><?= _('Raumverwaltung') ?></legend>
<label>
<input type="checkbox" name="resources_confirm_plan_drag_and_drop"
value="1"
<?= $config->RESOURCES_CONFIRM_PLAN_DRAG_AND_DROP ? 'checked' : '' ?>>
<?= _('Nach dem Verschieben einer Buchung per Drag & Drop im Belegungsplan eine Sicherheitsabfrage anzeigen') ?>
<?= tooltipIcon(
_('Wenn diese Einstellung aktiviert ist, wird die Buchung erst dann verschoben, wenn die Sicherheitsabfrage mit „Ja“ beantwortet wurde.')
) ?>
</label>
</fieldset>
<? endif ?>
<footer>
<?= \Studip\Button::create(_("Speichern")) ?>
</footer>
......
<?php
class AddConfigResourcesConfirmPlanDragAndDrop extends Migration
{
public function description()
{
return 'Add configuration RESOURCES_CONFIRM_PLAN_DRAG_AND_DROP';
}
public function up()
{
$db = DBManager::get();
$db->exec(
"INSERT INTO `config`
(`field`, `value`, `type`, `range`,
`section`,
`mkdate`, `chdate`,
`description`)
VALUES
('RESOURCES_CONFIRM_PLAN_DRAG_AND_DROP', '0', 'boolean', 'user',
'resources', UNIX_TIMESTAMP(), UNIX_TIMESTAMP(),
'Soll beim Verschieben von Buchungen im Belegungsplan eine Sicherheitsabfrage erscheinen?')"
);
}
public function down()
{
$db = DBManager::get();
$db->exec(
"DELETE FROM `config_values`
WHERE `field` = 'RESOURCES_CONFIRM_PLAN_DRAG_AND_DROP'"
);
$db->exec(
"DELETE FROM `config`
WHERE `field` = 'RESOURCES_CONFIRM_PLAN_DRAG_AND_DROP'"
);
}
}
......@@ -443,20 +443,38 @@ class Fullcalendar
info.event.source.refetch();
},
eventDrop (info) {
if ($(info.view.context.calendar.el).hasClass('institute-plan')) {
var start = info.event.start;
var cal_start = info.view.activeStart;
if ((start.getHours() - cal_start.getHours()) % 2 === 1) {
info.event.moveDates('-01:00');
let handle_drop = function() {
if ($(info.view.context.calendar.el).hasClass('institute-plan')) {
var start = info.event.start;
var cal_start = info.view.activeStart;
if ((start.getHours() - cal_start.getHours()) % 2 === 1) {
info.event.moveDates('-01:00');
}
STUDIP.Fullcalendar.institutePlanDropEventHandler(info);
} else {
if (info.view.viewSpec.options.studip_functions.drop_event) {
info.view.viewSpec.options.studip_functions.drop_event(info);
} else {
STUDIP.Fullcalendar.defaultDropEventHandler(info);
}
info.event.source.refetch();
}
STUDIP.Fullcalendar.institutePlanDropEventHandler(info);
} else {
if (info.view.viewSpec.options.studip_functions.drop_event) {
info.view.viewSpec.options.studip_functions.drop_event(info);
};
let calendar_config = JSON.parse(info.view.context.calendar.el.dataset.config);
if (calendar_config.confirm) {
if (calendar_config.confirm.drop) {
STUDIP.Dialog.confirm(calendar_config.confirm.drop)
.done(handle_drop)
.fail(function() {
//Revert the dropped element:
info.revert();
});
} else {
STUDIP.Fullcalendar.defaultDropEventHandler(info);
handle_drop();
}
info.event.source.refetch();
} else {
handle_drop();
}
},
eventRender (info) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment