From 17db3a3a11e3ba249b4547245088c2e63f390d22 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Fri, 23 Aug 2019 14:43:00 +0000 Subject: [PATCH] Bug 23501: Drag-and-drop hold reordering in the staff client This patch adds drag-and-drop priority reordering to the table of existing holds on a title. To test, apply the patch and regenerate the staff client CSS (https://wiki.koha-community.org/wiki/Working_with_SCSS_in_the_OPAC_and_staff_client). - Log in to Koha as a user who has permission to modify holds priority - Test on a record that has multiple holds, including one which is waiting and one which is in transit. - Holds which can be re-ordered should have a "drag handle" styled table cell in the first column. - Your mouse should show the "move" cursor when you hover over it. - Clicking and dragging from this table cell should reorder the table rows. - The priority numbers should be automatically updated when you "drop" the row. - It should not be possible to move a hold which is waiting or in transit. - It should not be possible to move a hold before a waiting or in transit hold. - Toggle lowest priority on a hold. The row should become unsortable, and it should be impossible to sort a hold below that hold. - Test again as a user who doesn't have permission to modify holds priority. Signed-off-by: Maryse Simard --- .../intranet-tmpl/prog/css/src/staff-global.scss | 36 +++++++++++++++++++++- .../intranet-tmpl/prog/en/includes/holds_table.inc | 29 ++++++++++++++--- .../prog/en/modules/reserve/request.tt | 13 ++++++++ 3 files changed, 72 insertions(+), 6 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss b/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss index 09dc82b..caa4857 100644 --- a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss +++ b/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss @@ -4078,10 +4078,44 @@ div#makechart ol li { list-style: none; } -@media (min-width: 200px) { +/* Sortable table styling */ +.handle { + background: #FCFCFC url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAMAQMAAABoTh6ZAAAABlBMVEVMaXHExMQ/ZYtiAAAAAXRSTlMAQObYZgAAABNJREFUeNpjYGBgMDYAIQjAxgYAKfECU0ml038AAAAASUVORK5CYII=") repeat-y; + cursor: move; + padding: 0 1em; } +tr { + &.ui-sortable-helper { + td { + border-bottom: 2px solid #85CA11; + border-top: 2px solid #85CA11; + + &:first-child { + border-left: 2px solid #85CA11; + } + + &:last-child { + border-right: 2px solid #85CA11; + } + } + } +} + +.table-sort-placeholder { + height: 2.5em; + width: 100%; + + td { + background-color: #FFC; + border-color: #85CA11; + min-width: 3em; + } +} + +/* End sortable table styling */ + @media (max-width: 767px) { .header-menu-link { display: inline-block; diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc index 0e0462d..f4f3680 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc @@ -1,7 +1,9 @@ [% USE Koha %] - +
+ [% IF ( CAN_user_reserveforothers_modify_holds_priority ) %] + [% ELSE %] @@ -19,22 +21,38 @@ [% IF SuspendHoldsIntranet %][% END %] - + + [% SET first_priority = 0 %] [% SET last_priority = holds.last.priority %] [% FOREACH hold IN holds %] [% IF !hold.found && first_priority == 0 %][% first_priority = hold.priority %][% END %] - + [% IF ( CAN_user_reserveforothers_modify_holds_priority ) %] + [% IF ( hold.found ) %] + + + [% ELSE %] + [% IF ( hold.lowestPriority ) %] + + + [% ELSE %] + + + [% END %] + [% END %] + [% ELSE %] + + [% END %] [% END %] +
  Priority    
 
 
 
[% IF Koha.Preference('HoldsSplitQueue') == "nothing" && !hold.found %] - [% ELSE %] - [% END %] [% IF ( hold.found ) %] [% IF ( hold.intransit ) %] @@ -210,4 +228,5 @@
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt index 91e4ebb..3408ef2 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt @@ -967,6 +967,19 @@ [% END %] [% END %] + // Sortable table of existing holds + // #existing_holdst is found in holds_table.inc + $("#existing_holdst tbody").sortable({ + cursor: "move", // Cursor style + handle: ".handle", // Elements with this class will serve as "handle" for dragging + items: "tr:not(.no-sort)", // Only these elements will be draggable + placeholder: "table-sort-placeholder", + update: function( event, ui ){ + $(".rank-request:enabled").each(function( index ){ + $(this).val( index + 1 ); // Update the priority of the sortable holds based on the order + }); + } + }); }); [% END %] -- 2.7.4