From e21db94e78d2a64231553c5b9bd13ee4ab3626a3 Mon Sep 17 00:00:00 2001 From: labmecanicatec <58854556+labmecanicatec@users.noreply.github.com> Date: Thu, 29 May 2025 15:16:58 -0500 Subject: [PATCH 1/3] ResourceId is displayed in tpl\Admin\Resources\manage_resources.tpl and tpl\Admin\Resources\view_resources.tpl --- tpl/Admin/Resources/manage_resources.tpl | 39 +++++++++++++----------- tpl/Admin/Resources/view_resources.tpl | 4 +++ 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/tpl/Admin/Resources/manage_resources.tpl b/tpl/Admin/Resources/manage_resources.tpl index 4dcb61056..17a2097b4 100644 --- a/tpl/Admin/Resources/manage_resources.tpl +++ b/tpl/Admin/Resources/manage_resources.tpl @@ -175,7 +175,6 @@ - {*{pagination pageInfo=$PageInfo showCount=true}*}
@@ -298,6 +297,10 @@ +
+ + {$id} +
@@ -2124,31 +2127,31 @@ container: 'body', html: true, placement: 'top', - trigger: 'manual', + trigger: 'manual', content: function() { var popoverId = $(this).data('popover-content'); return $(popoverId).html(); } }); - $('[rel="popover"]').on('click', function(e) { - e.preventDefault(); - e.stopPropagation(); + $('[rel="popover"]').on('click', function(e) { + e.preventDefault(); + e.stopPropagation(); - // Hide other popovers if needed - $('[rel="popover"]').not(this).popover('hide'); + // Hide other popovers if needed + $('[rel="popover"]').not(this).popover('hide'); - // Toggle the clicked one - $(this).popover('toggle'); - }); + // Toggle the clicked one + $(this).popover('toggle'); + }); - $('.descriptionValue').on('shown', function(e, editable) { - $(document).off('click.editable'); - }); + $('.descriptionValue').on('shown', function(e, editable) { + $(document).off('click.editable'); + }); - $('.notesValue').on('shown', function(e, editable) { - $(document).off('click.editable'); - }); + $('.notesValue').on('shown', function(e, editable) { + $(document).off('click.editable'); + }); } function setupCustomAttributesIcon() { @@ -2223,7 +2226,7 @@ }); $('.descriptionValue').editable({ -url: updateUrl + '{ManageResourcesActions::ActionChangeDescription}', + url: updateUrl + '{ManageResourcesActions::ActionChangeDescription}', emptytext: "{translate key='NoDescriptionLabel'|escape:'javascript'}" }); @@ -2402,4 +2405,4 @@ url: updateUrl + '{ManageResourcesActions::ActionChangeDescription}',
-{include file='globalfooter.tpl'} +{include file='globalfooter.tpl'} \ No newline at end of file diff --git a/tpl/Admin/Resources/view_resources.tpl b/tpl/Admin/Resources/view_resources.tpl index 6d830e4a2..5e7b81e33 100644 --- a/tpl/Admin/Resources/view_resources.tpl +++ b/tpl/Admin/Resources/view_resources.tpl @@ -201,6 +201,10 @@
{$resource->GetName()}
+
+ + {$id} +
{if $resource->IsAvailable()} From 77c07d4fbe11665bcbd1a54346ddb697b99e1bd9 Mon Sep 17 00:00:00 2001 From: labmecanicatec <58854556+labmecanicatec@users.noreply.github.com> Date: Thu, 29 May 2025 15:26:19 -0500 Subject: [PATCH 2/3] Trumbowyg is implemented in announcements --- Web/css/librebooking.css | 22 +++++-- Web/scripts/admin/announcement.js | 95 +++++++++++++++++------------- tpl/Admin/manage_announcements.tpl | 55 +++++++++++++---- tpl/Dashboard/announcements.tpl | 8 +-- tpl/javascript-includes.tpl | 2 + tpl/login.tpl | 53 +++++++++++------ 6 files changed, 153 insertions(+), 82 deletions(-) diff --git a/Web/css/librebooking.css b/Web/css/librebooking.css index f80bf04eb..32e68e601 100644 --- a/Web/css/librebooking.css +++ b/Web/css/librebooking.css @@ -86,11 +86,6 @@ img.logo { color: var(--primary-hover) !important; } -/* -.dropdown-toggle.show { - color: var(--primary-hover) !important; -} -*/ .dropdown-menu { --bs-dropdown-link-active-bg: var(--primary); font-size: 12px; @@ -298,7 +293,6 @@ li.ui-timepicker-selected, background: var(--primary); } -.horizontal-list li, .updateCustomAttribute, .reservation-list-dates div { min-width: 240px; @@ -611,6 +605,22 @@ input.mid-number { margin: 0; } +.trumbowyg-modal-submit { + background-color: var(--primary) !important; + color: var(--text-color-btn) !important; +} + +.descriptionValue a, +.descriptionContent a, +.notesValue a, +.noteContent a, +.announcement a, +.announcementText a, +.announcementContent a, +.trumbowyg-editor a { + color: var(--primary); +} + .editable-container.editable-popup { max-width: 50% !important; } diff --git a/Web/scripts/admin/announcement.js b/Web/scripts/admin/announcement.js index d272c54f3..990143eab 100644 --- a/Web/scripts/admin/announcement.js +++ b/Web/scripts/admin/announcement.js @@ -20,20 +20,20 @@ function AnnouncementManagement(opts) { editPriority: $('#editPriority'), editUserGroups: $('#editUserGroups'), editResourceGroups: $('#editResourceGroups'), - editUserGroupsDiv: $('#editUserGroupsDiv'), - editResourceGroupsDiv: $('#editResourceGroupsDiv'), + editUserGroupsDiv: $('#editUserGroupsDiv'), + editResourceGroupsDiv: $('#editResourceGroupsDiv'), emailCount: $('#emailCount'), - displayPage: $('#addPage'), - moreOptions: $('#moreOptions') + displayPage: $('#addPage'), + moreOptions: $('#moreOptions') }; var announcements = new Object(); AnnouncementManagement.prototype.init = function () { - elements.announcementList.on( 'click', 'a.update', function (e) { + elements.announcementList.on('click', 'a.update', function (e) { setActiveId($(this)); e.preventDefault(); }); @@ -48,15 +48,14 @@ function AnnouncementManagement(opts) { deleteAnnouncement(); }); - elements.displayPage.change(function(e){ - if ($(this).val() == '5') - { - elements.moreOptions.hide(); - } - else { - elements.moreOptions.show(); - } - }); + elements.displayPage.change(function (e) { + if ($(this).val() == '5') { + elements.moreOptions.hide(); + } + else { + elements.moreOptions.show(); + } + }); $(".save").click(function () { $(this).closest('form').submit(); @@ -68,9 +67,19 @@ function AnnouncementManagement(opts) { ConfigureAsyncForm(elements.addForm, getSubmitCallback(options.actions.add)); ConfigureAsyncForm(elements.deleteForm, getSubmitCallback(options.actions.deleteAnnouncement)); - ConfigureAsyncForm(elements.form, getSubmitCallback(options.actions.edit)); - ConfigureAsyncForm(elements.emailForm, getSubmitCallback(options.actions.email), function() { - elements.emailDialog.modal('hide');} + ConfigureAsyncForm(elements.form, function () { + // Sanitize the content of the Trumbowyg before sending it + const rawContent = $('#editText').trumbowyg('html'); + const sanitizedHtml = DOMPurify.sanitize(rawContent); + + // Update the textarea with clean content before submitting + $('#editText').val(sanitizedHtml); + + return options.submitUrl + "?aid=" + getActiveId() + "&action=" + options.actions.edit; + }); + ConfigureAsyncForm(elements.emailForm, getSubmitCallback(options.actions.email), function () { + elements.emailDialog.modal('hide'); + } ); }; @@ -91,41 +100,43 @@ function AnnouncementManagement(opts) { var editAnnouncement = function () { var announcement = getActiveAnnouncement(); + // date formatting, temporary? + var startDateFormatted = moment(announcement.start, 'DD/MM/YYYY').format('YYYY-MM-DD'); + var endDateFormatted = moment(announcement.end, 'DD/MM/YYYY').format('YYYY-MM-DD'); + elements.editText.val(HtmlDecode(announcement.text)); - elements.editBegin.val(announcement.start); + elements.editBegin.val(startDateFormatted); elements.editBegin.trigger('change'); - elements.editEnd.val(announcement.end); + elements.editEnd.val(endDateFormatted); elements.editEnd.trigger('change'); elements.editPriority.val(announcement.priority); - if (announcement.displayPage == 5) - { - elements.editUserGroupsDiv.hide(); - elements.editResourceGroupsDiv.hide(); - } - else - { - elements.editUserGroupsDiv.show(); - elements.editResourceGroupsDiv.show(); - - elements.editUserGroups.val($.map(announcement.groupIds, function(i){ - return i + ""; - })); - elements.editUserGroups.trigger('change'); - - elements.editResourceGroups.val($.map(announcement.resourceIds, function(i){ - return i + ""; - })); - elements.editResourceGroups.trigger('change'); - } + if (announcement.displayPage == 5) { + elements.editUserGroupsDiv.hide(); + elements.editResourceGroupsDiv.hide(); + } + else { + elements.editUserGroupsDiv.show(); + elements.editResourceGroupsDiv.show(); + + elements.editUserGroups.val($.map(announcement.groupIds, function (i) { + return i + ""; + })); + elements.editUserGroups.trigger('change'); + + elements.editResourceGroups.val($.map(announcement.resourceIds, function (i) { + return i + ""; + })); + elements.editResourceGroups.trigger('change'); + } elements.editDialog.modal('show'); }; - var emailAnnouncement = function() { + var emailAnnouncement = function () { var announcement = getActiveAnnouncement(); - ajaxGet(options.getEmailCountUrl + '&aid=' +announcement.id, function(){}, function(data) { + ajaxGet(options.getEmailCountUrl + '&aid=' + announcement.id, function () { }, function (data) { elements.emailCount.text(data.users); elements.emailDialog.modal('show'); }); @@ -140,6 +151,6 @@ function AnnouncementManagement(opts) { }; AnnouncementManagement.prototype.addAnnouncement = function (id, text, start, end, priority, groupIds, resourceIds, displayPage) { - announcements[id] = {id: id, text: text, start: start, end: end, priority: priority, groupIds: groupIds, resourceIds: resourceIds, displayPage: displayPage}; + announcements[id] = { id: id, text: text, start: start, end: end, priority: priority, groupIds: groupIds, resourceIds: resourceIds, displayPage: displayPage }; }; } diff --git a/tpl/Admin/manage_announcements.tpl b/tpl/Admin/manage_announcements.tpl index 841267aac..7e13025a1 100644 --- a/tpl/Admin/manage_announcements.tpl +++ b/tpl/Admin/manage_announcements.tpl @@ -1,4 +1,4 @@ -{include file='globalheader.tpl' Select2=true DataTable=true} +{include file='globalheader.tpl' Select2=true DataTable=true Trumbowyg=true}

{translate key=ManageAnnouncements}

@@ -114,8 +114,7 @@ {foreach from=$announcements item=announcement} - {*{cycle values='row0,row1' assign=rowCss}*} - + {$announcement->Text()|unescape:'html'} {$announcement->Priority()} @@ -179,7 +178,7 @@