From bbc4353ff05ced313a3596cbb9f2a334dfd1ff39 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 Signed-off-by: Phil Ringnalda --- .../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/editor.tt | 12 ++++ 4 files changed, 133 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 608e3477cc..c2c19155ae 100644 --- a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss +++ b/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss @@ -4082,6 +4082,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 13322d92e1..b8afc900d5 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() { @@ -1223,18 +1238,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 1c1e7db0a3..1d8c4b1b00 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 %] @@ -138,23 +158,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 ); @@ -816,6 +827,16 @@ function PopupMARCFieldDoc(field) {
+ [% IF Koha.Preference('EnableAdvancedCatalogingEditor') %] +
+ + +
+ [% 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 29df5435ea..5b32a023ed 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.40.0