From 99950e1ce132507b6ae4377fbc46966c6bc53510 Mon Sep 17 00:00:00 2001 From: "vishalsingh.qlo325" Date: Fri, 23 Aug 2024 15:58:11 +0530 Subject: [PATCH] Updated design for disabled dates interface in RTL and optmized the code --- .../default/sass/controllers/_products.sass | 36 +++++-------- admin/themes/default/sass/partials/_rtl.sass | 26 ++++++++++ .../products/booked_room_date_ranges_list.tpl | 6 +-- .../controllers/products/configuration.tpl | 44 ++++++++-------- classes/controller/AdminController.php | 3 +- controllers/admin/AdminProductsController.php | 50 +++++++++++++++---- 6 files changed, 105 insertions(+), 60 deletions(-) diff --git a/admin/themes/default/sass/controllers/_products.sass b/admin/themes/default/sass/controllers/_products.sass index 01d961ae1..54adae87e 100644 --- a/admin/themes/default/sass/controllers/_products.sass +++ b/admin/themes/default/sass/controllers/_products.sass @@ -1,24 +1,6 @@ #leave_bprice margin-left: 0px -.margin-lt-5 - margin-left: 5px - -.margin-lt-10 - margin-left: 10px - -.margin-lt-20 - margin-left: 20px - -.margin-rt-5 - margin-right: 5px - -.margin-rt-10 - margin-right: 10px - -.margin-rt-20 - margin-right: 20px - #deactiveDatesModal .fc-daygrid-event box-shadow: 0px 1px 2px 0px rgba(171, 171, 171, 0.3) @@ -48,6 +30,10 @@ padding-right: 0px padding: 10px .modal-title + .add_new_dates, .close + margin-right: 10px + .remove_dates_btn + margin-right: 20px .close line-height: 2 .disabled-dates-modal-title @@ -87,12 +73,13 @@ .tooltip_content_label border: 1px solid #D9D9D9 border-radius: 6px - padding: 5px + padding: 5px 10px .tooltip_content + .tooltip_reason_container, .module_event_id + margin-top: 10px &> div display: inline-block .row - padding-bottom: 15px margin-left: 0 margin-right: 0 ul.disabled_dates_actions @@ -106,8 +93,11 @@ font-size: 14px z-index: 99999 position: absolute - max-width: 400px + min-width: 450px + max-width: 450px background: #fff box-shadow: 0 8px 25px -2px rgba(0,0,0,0.20) - padding: 10px 15px - border-radius: 6px \ No newline at end of file + padding: 15px + border-radius: 6px + .tooltip_action_block + min-width: unset \ No newline at end of file diff --git a/admin/themes/default/sass/partials/_rtl.sass b/admin/themes/default/sass/partials/_rtl.sass index 7fd16f206..067c1a2f9 100644 --- a/admin/themes/default/sass/partials/_rtl.sass +++ b/admin/themes/default/sass/partials/_rtl.sass @@ -124,3 +124,29 @@ html ul#ellipsis_submenu left: 0 right: unset + +#deactiveDatesModal + .tooltip_container + .disabled_dates_actions + .btn + text-align: right !important + padding-inline-start: unset + .display_title + border-left: unset !important + border-right: 2px solid red !important + padding-right: 10px !important + padding-left: unset !important + .fc-event-title-container + direction: rtl !important + .delete_disabled_dates + margin-left: unset + margin-right: 10px + .remove_dates_btn + margin-right: 10px !important + margin-left: 20px + .fc-toolbar > * > :not(:first-child) + margin-right: .75em + .alert.alert-danger + text-align: right !important + .error_message_label + float: right !important diff --git a/admin/themes/default/template/controllers/products/booked_room_date_ranges_list.tpl b/admin/themes/default/template/controllers/products/booked_room_date_ranges_list.tpl index eb6207cd5..2645f8dd8 100644 --- a/admin/themes/default/template/controllers/products/booked_room_date_ranges_list.tpl +++ b/admin/themes/default/template/controllers/products/booked_room_date_ranges_list.tpl @@ -20,13 +20,13 @@ {l s='This room already has a booking for the selected date range.'}
- {l s='Date From:'} {dateFormat date=$orderDetails->date_from} + {l s='Date From'}: {dateFormat date=$orderDetails->date_from}
- {l s='Date To:'} {dateFormat date=$orderDetails->date_to} + {l s='Date To'}: {dateFormat date=$orderDetails->date_to}
diff --git a/admin/themes/default/template/controllers/products/configuration.tpl b/admin/themes/default/template/controllers/products/configuration.tpl index cf572be7c..21f75dec1 100644 --- a/admin/themes/default/template/controllers/products/configuration.tpl +++ b/admin/themes/default/template/controllers/products/configuration.tpl @@ -184,9 +184,9 @@
  {l s='Disable Dates'}
- - - + +
@@ -293,18 +293,18 @@
-
-
{l s='Disabled Duration'}
+
+
{l s='Duration'}
-
-
+
{l s='Disabled on'}
-
{l s='Event Id'}
-
{l s='Reason'}
+
{l s='Event Id'}
+
{l s='Reason'}
@@ -356,6 +356,7 @@ initialDate: '{date('Y-m-d', time())}', dayMaxEventRows: true, selectable: true, + direction:{if isset($language_is_rtl) && $language_is_rtl}'rlt'{else}'ltr'{/if}, unselectAuto: true, eventTextColor: '#333333', selectAllow: function(info) { @@ -386,8 +387,6 @@ if (is_editable) { $(info.el).find('.fc-event-title-container').append(''); } - - } var dateFrom = info.event.extendedProps.date_from_formatted; @@ -416,7 +415,7 @@ } if (id_module_event) { - var event_html = '(#'+id_module_event+')'; + var event_html = '#'+id_module_event; if (module_event_url != '') { event_html = ''+ event_html + ''; } else { @@ -437,7 +436,7 @@ container: $('#disabled_dates_full_calendar').closest('div'), delay: { show: 600, - hide: 300 + hide: 500 }, placement: 'auto' } @@ -478,9 +477,9 @@ container: $('#disabled_dates_full_calendar').closest('div'), delay: { show: 600, - hide: 400 + hide: 500 }, - placement: 'auto|bottom', + placement: {if isset($language_is_rtl) && $language_is_rtl}'left'{else}'right'{/if}, } $(selectedElement).tooltip(options); // since we are hiding the form after 200, if we show before hiding the position get wrong for the tooltip @@ -495,6 +494,7 @@ }, 1); } }); + function updateEventDates(event, add) { if (event.start && event.end) { let dateFrom = new Date(event.start); @@ -579,8 +579,8 @@ 'is_deleteable' : v['is_deleteable'], 'date_to_formatted': v['date_to'], 'date_from_formatted': v['date_from'], - 'id_module_event' : v['id_module_event'], - 'module_event_url' : v['module_event_url'], + 'id_module_event' : v['id_event'], + 'module_event_url' : v['event_url'], 'backgroundColor': '#FFFFFF', 'borderColor': '#FFFFFF' }); @@ -662,7 +662,7 @@ $('#disabled_dates_form').show(200); $('#deactiveDatesModal').animate({ scrollTop: 0 }, 'slow'); }, - submitValidateDisableDates: function(cb) { + submitDisableDates: function(cb) { let idRoom = parseInt($('#deactiveDatesModal').attr('data-id-room')); idRoom = idRoom == isNaN(idRoom) ? 0 : idRoom; var formElem = $('#disabled_dates_form'); @@ -681,7 +681,7 @@ type: 'POST', data: { ajax: true, - action: 'submitValidateDisableDates', + action: 'submitDisableDates', id_disabled_date : id_disabled_date, id_product: idProduct, id_room: idRoom, @@ -1062,7 +1062,7 @@ const dateTo = $.datepicker.formatDate('yy-mm-dd', dateToFormatted); var data = { ajax: true, - action: 'enableSelectedDate', + action: 'removeSelectedDate', id_room: idRoom, date_from: dateFrom, date_to: dateTo @@ -1092,8 +1092,8 @@ 'date_to_formatted': value['date_to'], 'date_from_formatted': value['date_from'], 'is_deleteable' : value['is_deleteable'], - 'id_module_event' : value['id_module_event'], - 'module_event_url' : value['module_event_url'], + 'id_module_event' : value['module_event'], + 'module_event_url' : value['event_url'], 'backgroundColor': '#FFFFFF', 'borderColor': '#FFFFFF' }); @@ -1144,7 +1144,7 @@ if (confirm("{l s='Are you sure?'}")) { $('.add_new_dates').removeClass('triggred'); $('.room_disable_reason').closest('.form-group').show(); - DisableDatesModal.submitValidateDisableDates(); + DisableDatesModal.submitDisableDates(); } }); $(document).on('click', '.close_action_tooltip', function(){ diff --git a/classes/controller/AdminController.php b/classes/controller/AdminController.php index 876652420..affc8e54c 100644 --- a/classes/controller/AdminController.php +++ b/classes/controller/AdminController.php @@ -2917,7 +2917,8 @@ class AdminControllerCore extends Controller 'current' => self::$currentIndex, 'token' => $this->token, 'host_mode' => defined('_PS_HOST_MODE_') ? 1 : 0, - 'stock_management' => (int)Configuration::get('PS_STOCK_MANAGEMENT') + 'stock_management' => (int)Configuration::get('PS_STOCK_MANAGEMENT'), + 'language_is_rtl' => $this->context->language->is_rtl )); if ($this->display_header) { diff --git a/controllers/admin/AdminProductsController.php b/controllers/admin/AdminProductsController.php index 02f35cca2..549a24498 100644 --- a/controllers/admin/AdminProductsController.php +++ b/controllers/admin/AdminProductsController.php @@ -2980,12 +2980,24 @@ class AdminProductsControllerCore extends AdminController // To display the disabled dates events with date_to as inclusive in the full calendar $disabledDates[$disabledDatesKey]['date_to'] = date('Y-m-d', strtotime($dates['date_to'])); $disabledDates[$disabledDatesKey]['date_add'] = date('Y-m-d', strtotime($dates['date_add'])); - if (!isset($dates['id_module_event'])) { - $disabledDates[$disabledDatesKey]['is_deleteable'] = 1; + if (!isset($dates['id_event'])) { + $disabledDates[$disabledDatesKey]['id_event'] = 0; + } + + if (!isset($dates['is_editable'])) { $disabledDates[$disabledDatesKey]['is_editable'] = 1; + } + + if (!isset($dates['is_deleteable'])) { + $disabledDates[$disabledDatesKey]['is_deleteable'] = 1; + } + + if (!isset($dates['event_title'])) { $disabledDates[$disabledDatesKey]['event_title'] = 0; - $disabledDates[$disabledDatesKey]['id_module_event'] = 0; - $disabledDates[$disabledDatesKey]['module_event_url'] = 0; + } + + if (!isset($dates['event_url'])) { + $disabledDates[$disabledDatesKey]['event_url'] = 0; } } } @@ -4997,7 +5009,7 @@ class AdminProductsControllerCore extends AdminController )); } - public function ajaxProcessSubmitValidateDisableDates() + public function ajaxProcessSubmitDisableDates() { $response = array('status' => false); $idRoom = (int) Tools::getValue('id_room'); @@ -5034,7 +5046,11 @@ class AdminProductsControllerCore extends AdminController && $objHotelRoomDisableDates->save() ) { $response['id_disabled_date'] = $objHotelRoomDisableDates->id; - $this->confirmations[] = $this->l('Room successfully disabled for the specified date range.'); + if (Tools::getValue('id_disabled_date')) { + $this->confirmations[] = $this->l('Successfully updated.'); + } else { + $this->confirmations[] = $this->l('Room disabled successfully for the specified date range.'); + } } else { $this->errors[] = Tools::displayError('An error occurred while trying to save the disable dates.'); } @@ -5056,7 +5072,7 @@ class AdminProductsControllerCore extends AdminController $this->ajaxDie(json_encode($response)); } - public function ajaxProcessEnableSelectedDate() + public function ajaxProcessRemoveSelectedDate() { $response = array('status' => false); $idRoom = (int) Tools::getValue('id_room'); @@ -5117,12 +5133,24 @@ class AdminProductsControllerCore extends AdminController if ($disabledDates = $objRoomDisableDates->getRoomDisableDates($idRoom)) { foreach ($disabledDates as $disabledDatesKey => $dates) { $disabledDates[$disabledDatesKey]['date_add'] = date('Y-m-d', strtotime($dates['date_add'])); - if (!isset($dates['id_module_event'])) { - $disabledDates[$disabledDatesKey]['is_deleteable'] = 1; + if (!isset($dates['id_event'])) { + $disabledDates[$disabledDatesKey]['id_event'] = 0; + } + + if (!isset($dates['is_editable'])) { $disabledDates[$disabledDatesKey]['is_editable'] = 1; + } + + if (!isset($dates['is_deleteable'])) { + $disabledDates[$disabledDatesKey]['is_deleteable'] = 1; + } + + if (!isset($dates['event_title'])) { $disabledDates[$disabledDatesKey]['event_title'] = 0; - $disabledDates[$disabledDatesKey]['id_module_event'] = 0; - $disabledDates[$disabledDatesKey]['module_event_url'] = 0; + } + + if (!isset($dates['event_url'])) { + $disabledDates[$disabledDatesKey]['event_url'] = 0; } } } else {