Bugzilla – Attachment 16878 Details for
Bug 9894
'hidden' value is hard to understand in frameworks
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 9894 - (3.12) de-serialize the 'hidden' value for subfields in frameworks
Bug-9894---312-de-serialize-the-hidden-value-for-s.patch (text/plain), 9.39 KB, created by
Liz Rea
on 2013-03-26 03:05:52 UTC
(
hide
)
Description:
Bug 9894 - (3.12) de-serialize the 'hidden' value for subfields in frameworks
Filename:
MIME Type:
Creator:
Liz Rea
Created:
2013-03-26 03:05:52 UTC
Size:
9.39 KB
patch
obsolete
>From 4b230c1b4f3831ce9072f1b7bab5d5b7acc35720 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@gmail.com> >Date: Mon, 25 Mar 2013 22:55:11 -0300 >Subject: [PATCH] Bug 9894 - (3.12) de-serialize the 'hidden' value for > subfields in frameworks >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >This patch aims to provide a non-intrusive way (with respect to Koha's code, so >it could have got into 3.12) for the users to easily choose the visibility settings >for each subfield. > >This patch is also known to have arrived late for 3.12. I've been struggling with >other stuff at work, but I just wanted to put this somewhere just in case it can >be reused or something else. > >The patch adds two JavaScript functions that deal with (de)serialization of the 'hidden' >value for subfields. One each way. Listeners are added to the checkboxes so the (actually, heh) >'hidden' value gets correctly updated on each checkbox change. > >There's a costly function to update all checkboxes on every tab to match the 'hidden' value on page load. > >To test: >- open the docs to have at hand the list of codes/visibility options combinations and >try changing several subfields from a single tagfield. Save, and reopen the "Edit subfields" page. >- I had a MySQL shell opened to repeatedly run this query (i tested against field 886 > on the default framework): >> SELECT tagfield,tagsubfield,hidden FROM marc_subfield_structure WHERE frameworkcode='' AND tagfield=886; >- Compare what was saved on the DB with the docs for that visibility selection. > >Regards >To+ > >PS: I promise I'll work on the proper patch for 3.14, which would involve DB structure changes and >(more than I expected) rewriten code. > >Sponsored-by: Universidad Nacional de Córdoba >Signed-off-by: Liz Rea <liz@catalyst.net.nz> >I promise to hug you the next time we meet. This works, and is a reasonable work around for a very longstanding awkward interface. >--- > .../en/modules/admin/marc_subfields_structure.tt | 123 +++++++++++++++++++- > 1 file changed, 122 insertions(+), 1 deletion(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marc_subfields_structure.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marc_subfields_structure.tt >index a0177db..c9ba8e7 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marc_subfields_structure.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marc_subfields_structure.tt >@@ -17,6 +17,10 @@ $(document).ready(function() { > link.html(_("Display more constraints")); > } > }); >+ $("input[id^='hidden_']").click(setHiddenValue); >+ $("input[id^='hidden-']").each(function() { >+ populateHiddenCheckboxes($(this).attr('id').split('-')[1]); >+ }); > }); > > /*function displayMoreConstraint(numlayer){ >@@ -30,6 +34,117 @@ $(document).ready(function() { > } > }*/ > >+/* Function to serialize and set the 'hidden' field */ >+function setHiddenValue() { >+ >+ var tab = $(this).attr('id').split('_')[2]; >+ var opac_checked = $("#hidden_opac_" + tab).is(':checked'); >+ var intranet_checked = $("#hidden_intranet_" + tab).is(':checked'); >+ var editor_checked = $("#hidden_editor_" + tab).is(':checked'); >+ var collapsed_checked = $("#hidden_collapsed_" + tab).is(':checked'); >+ var hidden_value = ""; >+ >+ if ( opac_checked && ! intranet_checked && ! editor_checked && collapsed_checked ) { >+ hidden_value='-7'; >+ } else if ( opac_checked && intranet_checked && ! editor_checked && ! collapsed_checked) { >+ hidden_value='-6'; >+ } else if ( opac_checked && intranet_checked && ! editor_checked && collapsed_checked) { >+ hidden_value='-5'; >+ } else if ( opac_checked && ! intranet_checked && ! editor_checked && ! collapsed_checked) { >+ hidden_value='-4'; >+ } else if ( opac_checked && ! intranet_checked && editor_checked && collapsed_checked) { >+ hidden_value='-3'; >+ } else if ( opac_checked && ! intranet_checked && editor_checked && ! collapsed_checked) { >+ hidden_value='-2'; >+ } else if ( opac_checked && intranet_checked && editor_checked && collapsed_checked) { >+ hidden_value='-1'; >+ } else if ( opac_checked && intranet_checked && editor_checked && ! collapsed_checked) { >+ hidden_value='0'; >+ } else if ( ! opac_checked && intranet_checked && editor_checked && collapsed_checked) { >+ hidden_value='1'; >+ } else if ( ! opac_checked && ! intranet_checked && editor_checked && ! collapsed_checked) { >+ hidden_value='2'; >+ } else if ( ! opac_checked && ! intranet_checked && editor_checked && collapsed_checked) { >+ hidden_value='3'; >+ } else if ( ! opac_checked && intranet_checked && editor_checked && ! collapsed_checked) { >+ hidden_value='4'; >+ } else if ( ! opac_checked && ! intranet_checked && ! editor_checked && collapsed_checked) { >+ hidden_value='5'; >+ } else if ( ! opac_checked && intranet_checked && ! editor_checked && ! collapsed_checked) { >+ hidden_value='6'; >+ } else if ( ! opac_checked && intranet_checked && ! editor_checked && collapsed_checked) { >+ hidden_value='7'; >+ } else if ( ! opac_checked && ! intranet_checked && ! editor_checked && ! collapsed_checked) { >+ hidden_value='8'; >+ } >+ >+ $('#hidden-' + tab).val(hidden_value); >+} >+ >+function populateHiddenCheckboxes(tab) { >+ // read the serialized value >+ var hidden_value = $('#hidden-' + tab).val(); >+ // deafult to false >+ var opac_checked = false; >+ var intranet_checked = false; >+ var editor_checked = false; >+ var collapsed_checked = false; >+ >+ if ( hidden_value == '-7') { >+ opac_checked = true; >+ collapsed_checked = true; >+ } else if ( hidden_value == '-6' ) { >+ opac_checked = true; >+ intranet_checked = true; >+ } else if ( hidden_value == '-5') { >+ opac_checked = true; >+ intranet_checked = true; >+ collapsed_checked = true; >+ } else if ( hidden_value == '-4' ) { >+ opac_checked = true; >+ } else if ( hidden_value == '-3') { >+ opac_checked = true; >+ editor_checked = true; >+ collapsed_checked = true; >+ } else if ( hidden_value == '-2' ) { >+ opac_checked = true; >+ editor_checked = true; >+ } else if ( hidden_value == '-1' ) { >+ opac_checked = true; >+ intranet_checked = true; >+ editor_checked = true; >+ collapsed_checked = true; >+ } else if ( hidden_value == '0' ) { >+ opac_checked = true; >+ intranet_checked = true; >+ editor_checked = true; >+ } else if ( hidden_value == '1' ) { >+ intranet_checked = true; >+ editor_checked = true; >+ collapsed_checked = true; >+ } else if ( hidden_value == '2' ) { >+ editor_checked = true; >+ } else if ( hidden_value == '3' ) { >+ editor_checked = true; >+ collapsed_checked = true; >+ } else if ( hidden_value == '4' ) { >+ intranet_checked = true; >+ editor_checked = true; >+ } else if ( hidden_value == '5' ) { >+ collapsed_checked = true; >+ } else if ( hidden_value == '6' ) { >+ intranet_checked = true; >+ } else if ( hidden_value == '7' ) { >+ intranet_checked = true; >+ collapsed_checked = true; >+ } // else if ( hidden_value == '8') { skip } >+ >+ $("#hidden_opac_" + tab).attr('checked',opac_checked); >+ $("#hidden_intranet_" + tab).attr('checked',intranet_checked); >+ $("#hidden_editor_" + tab).attr('checked',editor_checked); >+ $("#hidden_collapsed_" + tab).attr('checked',collapsed_checked); >+} >+ > //]]> > </script> > </head> >@@ -111,7 +226,13 @@ $(document).ready(function() { > <ol><li><label for="defaultvalue[% loo.row %]">Default value:</label> > <input type="text" name="defaultvalue" id="defaultvalue[% loo.row %]" value="[% loo.defaultvalue %]" /></li> > <li><label for="maxlength[% loo.row %]">Max length:</label><input type="text" id="maxlength[% loo.row %]" name="maxlength" value="[% loo.maxlength %]" size="4" /> (see online help)</li> >- <li><label for="hidden[% loo.row %]">hidden</label><input type="text" id="hidden[% loo.row %]" name="hidden" value="[% loo.hidden %]" size="2" /> (see online help)</li> >+ <li><input type="hidden" id="hidden-[% loo.row %]" name="hidden" value="[% loo.hidden %]" /> >+ <label for="hidden[% loo.row %]">Visibility: </label> >+ <input class="radio" type="checkbox" id="hidden_opac_[% loo.row %]" name="hidden_opac_[% loo.row %]"/> OPAC >+ <input type="checkbox" id="hidden_intranet_[% loo.row %]" name="hidden_intranet_[% loo.row %]"/> Intranet >+ <input type="checkbox" id="hidden_editor_[% loo.row %]" name="hidden_editor_[% loo.row %]"/> Editor >+ <input type="checkbox" id="hidden_collapsed_[% loo.row %]" name="hidden_collapsed_[% loo.row %]"/> Collapsed >+ </li> > <li><label for="isurl[% loo.row %]">Is a URL:</label>[% loo.isurl %] (if checked, it means that the subfield is a URL and can be clicked)</li> > <li><label for="link[% loo.row %]">Link:</label><input type="text" id="link[% loo.row %]" name="link" value="[% loo.link %]" size="10" maxlength="80" /> (e.g., Title or Local-Number) <span class="error"><em>NOTE: If you change this value you must ask your administrator to run misc/batchRebuildBiblioTables.pl.</em></span></li> > <li><label for="kohafield[% loo.row %]">Koha link:</label>[% loo.kohafield %]</li> >-- >1.7.9.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 9894
:
16876
|
16877
|
16878
|
17019
|
17176
|
17177
|
17181
|
17259
|
17260
|
17278
|
17279
|
17280
|
17281