From b1399ceac10cacc58f1623cce2514a4eaff9938d Mon Sep 17 00:00:00 2001 From: Lucas Gass Date: Thu, 13 Jul 2023 17:51:13 +0000 Subject: [PATCH] Bug 34275: Add toggle switch for basic/advanced cataloging editors To test: 1. Apply patch and regenerate CSS. (https://wiki.koha-community.org/wiki/Working_with_SCSS_in_the_OPAC_and_staff_interface) 2. Turn on EnableAdvancedCatalogingEditor. 3. Go to cataloging > 'New record' 4. In the upper left notice a new toggle switch labeled 'Editor:'. 5. Try toggling the switch back and forth to move between editors. Verify it works correecly. 6. Try editing an existing record and make sure the toggle works well when editing records. 7. Try the other method of switch editors, Settings > Switch to basic/advanced editor. Make sure it works the same as always 8. Turn off EnableAdvancedCatalogingEditor, make sure the toggle button is no longer present. Signed-off-by: Barbara Johnson --- .../prog/css/src/staff-global.scss | 65 +++++++++++++++++++ .../prog/en/includes/cateditor-ui.inc | 31 +++++---- .../prog/en/modules/cataloguing/addbiblio.tt | 51 ++++++++++----- .../prog/en/modules/cataloguing/addbooks.tt | 31 +++++++++ .../prog/en/modules/cataloguing/editor.tt | 12 ++++ 5 files changed, 164 insertions(+), 26 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 ab0a8f9e3e..56c0769b05 100644 --- a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss +++ b/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss @@ -4101,6 +4101,71 @@ input.renew { } } +#toggle-editor { + display: flex; + align-items: center; + float: right; + + label { + margin-left: 2px; + margin-bottom: 0; + } + + .switch { + position: relative; + display: inline-block; + width: 105px; + height: 24px; + + input { + opacity: 0; + width: 0; + height: 0; + + &:checked { + + .slider { + background-color: #408540; + } + + .slider:before { + -webkit-transform: translateX(26px); + -ms-transform: translateX(26px); + transform: translateX(26px); + } + } + } + + } + + .slider { + position: absolute; + cursor: pointer; + top: 0; + left: 0; + right: 0; + bottom: 0; + background-color: #ccc; + -webkit-transition: .4s; + transition: .4s; + border-radius: 34px; + + &::before { + position: absolute; + content: ""; + height: 16px; + width: 68px; + left: 4px; + bottom: 4px; + background-color: white; + -webkit-transition: .4s; + transition: .4s; + content: attr(data-editor); + border-radius: 34px; + text-align: center; + font-weight: bold; + } + } +} + /* Permissions */ #permissionstree { diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc index a167314729..77a22a360c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc @@ -976,6 +976,20 @@ require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr }); } + function changeEditor() { + if ( !confirm( _("Any changes will not be saved. Continue?") ) ) return; + + Cookies.set( "catalogue_editor_[% logged_in_user.borrowernumber | html %]", "basic", { expires: 365, path: '/', sameSite: 'Lax'} ); + + if ( state.backend == 'catalog' ) { + window.location = '/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=' + state.recordID; + } else if ( state.backend == 'new' ) { + window.location = '/cgi-bin/koha/cataloguing/addbiblio.pl'; + } else { + humanMsg.displayAlert( _("Cannot open this record in the basic editor"), { className: 'humanError' } ); + } + } + $(".macro_shared").change(function(){ if(this.checked){ saveMacro(true); @@ -987,6 +1001,7 @@ require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr // END Macro functions $(document).ready( function() { + // Editor setup editor = new MARCEditor( { onCursorActivity: function() { @@ -1222,18 +1237,12 @@ require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr return false; } ); - $( '#switch-editor' ).click( function() { - if ( !confirm( _("Any changes will not be saved. Continue?") ) ) return; - - Cookies.set( "catalogue_editor_[% logged_in_user.borrowernumber | html %]", "basic", { expires: 365, path: '/', sameSite: 'Lax'} ); + $( '#toggleEditor' ).change( function() { + changeEditor(); + }); - if ( state.backend == 'catalog' ) { - window.location = '/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=' + state.recordID; - } else if ( state.backend == 'new' ) { - window.location = '/cgi-bin/koha/cataloguing/addbiblio.pl'; - } else { - humanMsg.displayAlert( _("Cannot open this record in the basic editor"), { className: 'humanError' } ); - } + $( '#switch-editor' ).click( function() { + changeEditor(); } ); $( '#show-advanced-search' ).click( function() { diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt index 7e33f115d4..b774794a21 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt @@ -26,6 +26,26 @@ $("#loading").hide(); }); var Sticky; + + function changeEditor() { + + var breedingid = [% breedingid || "null" | html %]; + + if ( !confirm( breedingid ? _("This record cannot be transferred to the advanced editor. Continue?") : _("Any changes will not be saved. Continue?") ) ) return false; + + Cookies.set( 'catalogue_editor_[% logged_in_user.borrowernumber | html %]', 'advanced', { expires: 365, path: '/', sameSite: 'Lax' } ); + + var biblionumber = [% biblionumber || "null" | html %]; + + if ( biblionumber ) { + window.location = '/cgi-bin/koha/cataloguing/editor.pl#catalog/' + biblionumber; + } else { + window.location = '/cgi-bin/koha/cataloguing/editor.pl'; + } + + return false; + } + $(document).ready(function() { [% IF bib_doesnt_exist %] @@ -136,23 +156,14 @@ return false; }); - $( '#switcheditor' ).click( function() { - var breedingid = [% breedingid || "null" | html %]; - - if ( !confirm( breedingid ? _("This record cannot be transferred to the advanced editor. Continue?") : _("Any changes will not be saved. Continue?") ) ) return false; - - Cookies.set( 'catalogue_editor_[% logged_in_user.borrowernumber | html %]', 'advanced', { expires: 365, path: '/', sameSite: 'Lax' } ); - - var biblionumber = [% biblionumber || "null" | html %]; - - if ( biblionumber ) { - window.location = '/cgi-bin/koha/cataloguing/editor.pl#catalog/' + biblionumber; - } else { - window.location = '/cgi-bin/koha/cataloguing/editor.pl'; - } + $( '#toggleEditor' ).change( function() { + changeEditor(); + } ); - return false; + $( '#switcheditor' ).click( function() { + changeEditor(); } ); + $(".change-framework").on("click", function(){ var frameworkcode = $(this).data("frameworkcode"); $("#frameworkcode").val( frameworkcode ); @@ -823,6 +834,16 @@ function PopupMARCFieldDoc(field) {
+ [% IF Koha.Preference('EnableAdvancedCatalogingEditor') %] +
+ + +
+ [% END %] +

diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbooks.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbooks.tt index 09289a375f..606b7a7a1c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbooks.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbooks.tt @@ -130,6 +130,36 @@ [% END %] + [% IF (resultsloo.availablecount ) %] +
+ [% FOREACH items_loo IN resultsloo.available_items_loop %] + [% items_loo.branchname | html %] + [% IF ( items_loo.location ) %][% items_loo.location | html %][% END %] + [% IF ( items_loo.itemcallnumber ) %][% items_loo.itemcallnumber | html %][% END %] + [% IF ( items_loo.classification ) %] + + [% items_loo.classification | html %] + + [% END %] + [% END %] +
+ [% END %] + [% IF ( resultsloo.onloancount ) %] +
+
[% resultsloo.onloancount | html %] checked out:
+ [% FOREACH items_loo IN resultsloo.onloan_items_loop %] + [% items_loo.branchname | html %] + [% IF ( items_loo.location ) %][% items_loo.location | html %][% END %] + [% IF ( items_loo.itemcallnumber ) %][% items_loo.itemcallnumber | html %][% END %] + [% IF ( items_loo.classification ) %] + + [% items_loo.classification | html %] + + [% END %] + [% END %] +
+ [% END %] +
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/editor.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/editor.tt index 6519def77b..74a857dd60 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/editor.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/editor.tt @@ -1,5 +1,6 @@ [% USE raw %] [% USE Asset %] +[% USE Koha %] [% INCLUDE 'doc-head-open.inc' %] Editor › Cataloging › Koha [% INCLUDE 'doc-head-close.inc' %] @@ -36,8 +37,19 @@
+[% IF Koha.Preference('EnableAdvancedCatalogingEditor') %] +
+ + +
+[% END %] +

Cataloging editor

+
-- 2.30.2