Bugzilla – Attachment 92081 Details for
Bug 8643
Add ability to mark some MARC tags and subfields as important and alert on saving the record if they are found to be empty
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 8643: Add important constraint to marc subfields
Bug-8643-Add-important-constraint-to-marc-subfield.patch (text/plain), 38.15 KB, created by
Maryse Simard
on 2019-08-08 15:01:46 UTC
(
hide
)
Description:
Bug 8643: Add important constraint to marc subfields
Filename:
MIME Type:
Creator:
Maryse Simard
Created:
2019-08-08 15:01:46 UTC
Size:
38.15 KB
patch
obsolete
>From 95118c325f4b95362a73f7d30e8c18dd256a3901 Mon Sep 17 00:00:00 2001 >From: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com> >Date: Fri, 18 Dec 2015 11:40:02 -0300 >Subject: [PATCH] Bug 8643: Add important constraint to marc subfields >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >This fix permits to add an "Important" option to the marc structure pages. > >Testing: > >1) Apply the patch >2) Run updatedatabase.pl >3) Regenerate CSS >4) Define 100 as an "important" field ( Administration » MARC bibliographic framework » MARC structure ( Default Frameword) » Edit ) >5) Define 100$a as an "important" subfield (Administration » MARC bibliographic framework » MARC structure (Default Frameword) » Subfield » Onglet a) >6) Edit a record to clear the field 100 (subfields are all blank) >7) Save the record. >8) Validate the following message: > >A few important fields are not filled: > > * tag 100 subfield a Nom de personne in tab > * Field 100 is important, at least one of its subfields should be filled. > >Are you sure you want to save? > >Sponsored by the CCSR ( http://www.ccsr.qc.ca ) >--- > C4/Biblio.pm | 12 ++- > admin/marc_subfields_structure.pl | 12 ++- > admin/marctagstructure.pl | 16 ++- > cataloguing/addbiblio.pl | 9 +- > cataloguing/additem.pl | 1 + > .../bug-8643-add_important_constraint.perl | 11 ++ > installer/data/mysql/kohastructure.sql | 2 + > koha-tmpl/intranet-tmpl/prog/css/addbiblio.css | 1 + > koha-tmpl/intranet-tmpl/prog/css/right-to-left.css | 4 +- > .../intranet-tmpl/prog/css/src/staff-global.scss | 10 ++ > .../prog/en/includes/str/cataloging_additem.inc | 2 + > .../en/modules/admin/marc_subfields_structure.tt | 9 ++ > .../prog/en/modules/admin/marctagstructure.tt | 9 ++ > .../prog/en/modules/cataloguing/addbiblio.tt | 120 +++++++++++++++++++++ > .../prog/en/modules/cataloguing/additem.tt | 5 +- > koha-tmpl/intranet-tmpl/prog/js/cataloging.js | 14 ++- > .../intranet-tmpl/prog/js/cataloging_additem.js | 30 ++++-- > 17 files changed, 244 insertions(+), 23 deletions(-) > create mode 100644 installer/data/mysql/atomicupdate/bug-8643-add_important_constraint.perl > >diff --git a/C4/Biblio.pm b/C4/Biblio.pm >index 55a2c01..a038cd7 100644 >--- a/C4/Biblio.pm >+++ b/C4/Biblio.pm >@@ -863,25 +863,26 @@ sub GetMarcStructure { > > my $dbh = C4::Context->dbh; > my $sth = $dbh->prepare( >- "SELECT tagfield,liblibrarian,libopac,mandatory,repeatable,ind1_defaultvalue,ind2_defaultvalue >+ "SELECT tagfield,liblibrarian,libopac,mandatory,repeatable,important,ind1_defaultvalue,ind2_defaultvalue > FROM marc_tag_structure > WHERE frameworkcode=? > ORDER BY tagfield" > ); > $sth->execute($frameworkcode); >- my ( $liblibrarian, $libopac, $tag, $res, $tab, $mandatory, $repeatable, $ind1_defaultvalue, $ind2_defaultvalue ); >+ my ( $liblibrarian, $libopac, $tag, $res, $tab, $mandatory, $repeatable, $important, $ind1_defaultvalue, $ind2_defaultvalue ); > >- while ( ( $tag, $liblibrarian, $libopac, $mandatory, $repeatable, $ind1_defaultvalue, $ind2_defaultvalue ) = $sth->fetchrow ) { >+ while ( ( $tag, $liblibrarian, $libopac, $mandatory, $repeatable, $important, $ind1_defaultvalue, $ind2_defaultvalue ) = $sth->fetchrow ) { > $res->{$tag}->{lib} = ( $forlibrarian or !$libopac ) ? $liblibrarian : $libopac; > $res->{$tag}->{tab} = ""; > $res->{$tag}->{mandatory} = $mandatory; >+ $res->{$tag}->{important} = $important; > $res->{$tag}->{repeatable} = $repeatable; > $res->{$tag}->{ind1_defaultvalue} = $ind1_defaultvalue; > $res->{$tag}->{ind2_defaultvalue} = $ind2_defaultvalue; > } > > $sth = $dbh->prepare( >- "SELECT tagfield,tagsubfield,liblibrarian,libopac,tab,mandatory,repeatable,authorised_value,authtypecode,value_builder,kohafield,seealso,hidden,isurl,link,defaultvalue,maxlength >+ "SELECT tagfield,tagsubfield,liblibrarian,libopac,tab,mandatory,repeatable,authorised_value,authtypecode,value_builder,kohafield,seealso,hidden,isurl,link,defaultvalue,maxlength,important > FROM marc_subfield_structure > WHERE frameworkcode=? > ORDER BY tagfield,tagsubfield >@@ -905,13 +906,14 @@ sub GetMarcStructure { > while ( > ( $tag, $subfield, $liblibrarian, $libopac, $tab, $mandatory, $repeatable, $authorised_value, > $authtypecode, $value_builder, $kohafield, $seealso, $hidden, $isurl, $link, $defaultvalue, >- $maxlength >+ $maxlength, $important > ) > = $sth->fetchrow > ) { > $res->{$tag}->{$subfield}->{lib} = ( $forlibrarian or !$libopac ) ? $liblibrarian : $libopac; > $res->{$tag}->{$subfield}->{tab} = $tab; > $res->{$tag}->{$subfield}->{mandatory} = $mandatory; >+ $res->{$tag}->{$subfield}->{important} = $important; > $res->{$tag}->{$subfield}->{repeatable} = $repeatable; > $res->{$tag}->{$subfield}->{authorised_value} = $authorised_value; > $res->{$tag}->{$subfield}->{authtypecode} = $authtypecode; >diff --git a/admin/marc_subfields_structure.pl b/admin/marc_subfields_structure.pl >index 2519649..594233b 100755 >--- a/admin/marc_subfields_structure.pl >+++ b/admin/marc_subfields_structure.pl >@@ -191,6 +191,7 @@ if ( $op eq 'add_form' ) { > $row_data{isurl} = $data->{isurl}; > $row_data{row} = $i; > $row_data{link} = $data->{'link'}; >+ $row_data{important} = $data->{important}; > push( @loop_data, \%row_data ); > $i++; > } >@@ -215,6 +216,7 @@ if ( $op eq 'add_form' ) { > $row_data{authtypes} = \@authtypes; > $row_data{link} = ""; > $row_data{row} = $i; >+ $row_data{important} = ""; > push( @loop_data, \%row_data ); > > $template->param( 'use_heading_flags_p' => 1 ); >@@ -238,11 +240,11 @@ elsif ( $op eq 'add_validate' ) { > # values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)" > # ); > my $sth_insert = $dbh->prepare(qq{ >- insert into marc_subfield_structure (tagfield,tagsubfield,liblibrarian,libopac,repeatable,mandatory,kohafield,tab,seealso,authorised_value,authtypecode,value_builder,hidden,isurl,frameworkcode, link,defaultvalue,maxlength) >- values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) >+ insert into marc_subfield_structure (tagfield,tagsubfield,liblibrarian,libopac,repeatable,mandatory,important,kohafield,tab,seealso,authorised_value,authtypecode,value_builder,hidden,isurl,frameworkcode, link,defaultvalue,maxlength) >+ values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) > }); > my $sth_update = $dbh->prepare(qq{ >- update marc_subfield_structure set tagfield=?, tagsubfield=?, liblibrarian=?, libopac=?, repeatable=?, mandatory=?, kohafield=?, tab=?, seealso=?, authorised_value=?, authtypecode=?, value_builder=?, hidden=?, isurl=?, frameworkcode=?, link=?, defaultvalue=?, maxlength=? >+ update marc_subfield_structure set tagfield=?, tagsubfield=?, liblibrarian=?, libopac=?, repeatable=?, mandatory=?, important=?, kohafield=?, tab=?, seealso=?, authorised_value=?, authtypecode=?, value_builder=?, hidden=?, isurl=?, frameworkcode=?, link=?, defaultvalue=?, maxlength=? > where tagfield=? and tagsubfield=? and frameworkcode=? > }); > my @tagsubfield = $input->multi_param('tagsubfield'); >@@ -267,6 +269,7 @@ elsif ( $op eq 'add_validate' ) { > my $libopac = $libopac[$i]; > my $repeatable = $input->param("repeatable$i") ? 1 : 0; > my $mandatory = $input->param("mandatory$i") ? 1 : 0; >+ my $important = $input->param("important$i") ? 1 : 0; > my $kohafield = $kohafield[$i]; > my $tab = $tab[$i]; > my $seealso = $seealso[$i]; >@@ -288,6 +291,7 @@ elsif ( $op eq 'add_validate' ) { > $libopac, > $repeatable, > $mandatory, >+ $important, > $kohafield, > $tab, > $seealso, >@@ -319,6 +323,7 @@ elsif ( $op eq 'add_validate' ) { > $libopac, > $repeatable, > $mandatory, >+ $important, > $kohafield, > $tab, > $seealso, >@@ -401,6 +406,7 @@ else { # DEFAULT > $row_data{kohafield} = $results->[$i]{'kohafield'}; > $row_data{repeatable} = $results->[$i]{'repeatable'}; > $row_data{mandatory} = $results->[$i]{'mandatory'}; >+ $row_data{important} = $results->[$i]{'important'}; > $row_data{tab} = $results->[$i]{'tab'}; > $row_data{seealso} = $results->[$i]{'seealso'}; > $row_data{authorised_value} = $results->[$i]{'authorised_value'}; >diff --git a/admin/marctagstructure.pl b/admin/marctagstructure.pl >index e34edd5..c19d1e8 100755 >--- a/admin/marctagstructure.pl >+++ b/admin/marctagstructure.pl >@@ -89,7 +89,7 @@ if ($op eq 'add_form') { > #---- if primkey exists, it's a modify action, so read values to modify... > my $data; > if ($searchfield) { >- $sth=$dbh->prepare("select tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value,ind1_defaultvalue,ind2_defaultvalue from marc_tag_structure where tagfield=? and frameworkcode=?"); >+ $sth=$dbh->prepare("select tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value,important,ind1_defaultvalue,ind2_defaultvalue from marc_tag_structure where tagfield=? and frameworkcode=?"); > $sth->execute($searchfield,$frameworkcode); > $data=$sth->fetchrow_hashref; > } >@@ -108,6 +108,7 @@ if ($op eq 'add_form') { > repeatable => $data->{'repeatable'}, > mandatory => $data->{'mandatory'}, > authorised_value => $data->{authorised_value}, >+ important => $data->{'important'}, > ind1_defaultvalue => $data->{'ind1_defaultvalue'}, > ind2_defaultvalue => $data->{'ind2_defaultvalue'} > ); # FIXME: move checkboxes to presentation layer >@@ -120,17 +121,19 @@ if ($op eq 'add_form') { > my $libopac = $input->param('libopac'); > my $repeatable = $input->param('repeatable') ? 1 : 0; > my $mandatory = $input->param('mandatory') ? 1 : 0; >+ my $important = $input->param('important') ? 1 : 0; > my $authorised_value = $input->param('authorised_value'); > my $ind1_defaultvalue = $input->param('ind1_defaultvalue'); > my $ind2_defaultvalue = $input->param('ind2_defaultvalue'); > if ($input->param('modif')) { > $sth = $dbh->prepare( >- "UPDATE marc_tag_structure SET liblibrarian=? ,libopac=? ,repeatable=? ,mandatory=? ,authorised_value=?, ind1_defaultvalue=?, ind2_defaultvalue=? WHERE frameworkcode=? AND tagfield=?" >+ "UPDATE marc_tag_structure SET liblibrarian=? ,libopac=? ,repeatable=? ,mandatory=? ,important=? ,authorised_value=?, ind1_defaultvalue=?, ind2_defaultvalue=? WHERE frameworkcode=? AND tagfield=?" > ); > $sth->execute( $liblibrarian, > $libopac, > $repeatable, > $mandatory, >+ $important, > $authorised_value, > $ind1_defaultvalue, > $ind2_defaultvalue, >@@ -139,13 +142,14 @@ if ($op eq 'add_form') { > ); > } else { > $sth = $dbh->prepare( >- "INSERT INTO marc_tag_structure (tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value,ind1_defaultvalue,ind2_defaultvalue,frameworkcode) values (?,?,?,?,?,?,?,?,?)" >+ "INSERT INTO marc_tag_structure (tagfield,liblibrarian,libopac,repeatable,mandatory,important,authorised_value,ind1_defaultvalue,ind2_defaultvalue,frameworkcode) values (?,?,?,?,?,?,?,?,?,?)" > ); > $sth->execute($tagfield, > $liblibrarian, > $libopac, > $repeatable, > $mandatory, >+ $important, > $authorised_value, > $ind1_defaultvalue, > $ind2_defaultvalue, >@@ -216,6 +220,7 @@ if ($op eq 'add_form') { > marc_tag_structure.libopac as mts_libopac, > marc_tag_structure.repeatable as mts_repeatable, > marc_tag_structure.mandatory as mts_mandatory, >+ marc_tag_structure.important as mts_important, > marc_tag_structure.authorised_value as mts_authorized_value, > marc_tag_structure.ind1_defaultvalue as mts_ind1_defaultvalue, > marc_tag_structure.ind1_defaultvalue as mts_ind2_defaultvalue, >@@ -239,6 +244,7 @@ if ($op eq 'add_form') { > $row_data{liblibrarian} = $results[$i]->{'mts_liblibrarian'}; > $row_data{repeatable} = $results[$i]->{'mts_repeatable'}; > $row_data{mandatory} = $results[$i]->{'mts_mandatory'}; >+ $row_data{important} = $results[$i]->{'mts_important'}; > $row_data{authorised_value} = $results[$i]->{'mts_authorised_value'}; > $row_data{ind1_defaultvalue} = $results[$i]->{'mts_ind1_defaultvalue'}; > $row_data{ind2_defaultvalue} = $results[$i]->{'mts_ind2_defaultvalue'}; >@@ -251,6 +257,7 @@ if ($op eq 'add_form') { > $subfield_data{kohafield} = $results[$j]->{'kohafield'}; > $subfield_data{repeatable} = $results[$j]->{'repeatable'}; > $subfield_data{mandatory} = $results[$j]->{'mandatory'}; >+ $subfield_data{important} = $results[$j]->{'important'}; > $subfield_data{tab} = $results[$j]->{'tab'}; > $subfield_data{seealso} = $results[$j]->{'seealso'}; > $subfield_data{authorised_value} = $results[$j]->{'authorised_value'}; >@@ -283,6 +290,7 @@ if ($op eq 'add_form') { > $row_data{liblibrarian} = $results->[$i]{'liblibrarian'}; > $row_data{repeatable} = $results->[$i]{'repeatable'}; > $row_data{mandatory} = $results->[$i]{'mandatory'}; >+ $row_data{important} = $results->[$i]{'important'}; > $row_data{authorised_value} = $results->[$i]{'authorised_value'}; > $row_data{ind1_defaultvalue} = $results->[$i]{'ind1_defaultvalue'}; > $row_data{ind2_defaultvalue} = $results->[$i]{'ind2_defaultvalue'}; >@@ -313,7 +321,7 @@ output_html_with_http_headers $input, $cookie, $template->output; > sub StringSearch { > my ($searchstring,$frameworkcode)=@_; > my $sth = C4::Context->dbh->prepare(" >- SELECT tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value,ind1_defaultvalue,ind2_defaultvalue >+ SELECT tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value,important,ind1_defaultvalue,ind2_defaultvalue > FROM marc_tag_structure > WHERE (tagfield >= ? and frameworkcode=?) > ORDER BY tagfield >diff --git a/cataloguing/addbiblio.pl b/cataloguing/addbiblio.pl >index 00b2501..30a547a 100755 >--- a/cataloguing/addbiblio.pl >+++ b/cataloguing/addbiblio.pl >@@ -305,6 +305,7 @@ sub create_input { > marc_lib => $tagslib->{$tag}->{$subfield}->{lib}, > tag_mandatory => $tagslib->{$tag}->{mandatory}, > mandatory => $tagslib->{$tag}->{$subfield}->{mandatory}, >+ important => $tagslib->{$tag}->{$subfield}->{important}, > repeatable => $tagslib->{$tag}->{$subfield}->{repeatable}, > kohafield => $tagslib->{$tag}->{$subfield}->{kohafield}, > index => $index_tag, >@@ -318,13 +319,15 @@ sub create_input { > $subfield_data{z3950_mandatory} = $mandatory_z3950->{$tag.$subfield}; > } > # Subfield is hidden depending of hidden and mandatory flag, and is always >- # shown if it contains anything or if its field is mandatory. >+ # shown if it contains anything or if its field is mandatory or important. > my $tdef = $tagslib->{$tag}; > $subfield_data{visibility} = "display:none;" > if $tdef->{$subfield}->{hidden} % 2 == 1 && > $value eq '' && > !$tdef->{$subfield}->{mandatory} && >- !$tdef->{mandatory}; >+ !$tdef->{mandatory} && >+ !$tdef->{$subfield}->{important} && >+ !$tdef->{important}; > # expand all subfields of 773 if there is a host item provided in the input > $subfield_data{visibility} ="" if ($tag eq 773 and $cgi->param('hostitemnumber')); > >@@ -607,6 +610,7 @@ sub build_tabs { > tag_lib => $tagslib->{$tag}->{lib}, > repeatable => $tagslib->{$tag}->{repeatable}, > mandatory => $tagslib->{$tag}->{mandatory}, >+ important => $tagslib->{$tag}->{important}, > subfield_loop => \@subfields_data, > fixedfield => $tag < 10?1:0, > random => CreateKey, >@@ -653,6 +657,7 @@ sub build_tabs { > tag_lib => $tagslib->{$tag}->{lib}, > repeatable => $tagslib->{$tag}->{repeatable}, > mandatory => $tagslib->{$tag}->{mandatory}, >+ important => $tagslib->{$tag}->{important}, > indicator1 => ( $indicator1 || $tagslib->{$tag}->{ind1_defaultvalue} ), #if not set, try to load the default value > indicator2 => ( $indicator2 || $tagslib->{$tag}->{ind2_defaultvalue} ), #use short-circuit operator for efficiency > subfield_loop => \@subfields_data, >diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl >index ce12b0a..b906aff 100755 >--- a/cataloguing/additem.pl >+++ b/cataloguing/additem.pl >@@ -130,6 +130,7 @@ sub generate_subfield_form { > $subfield_data{subfield} = $subfieldtag; > $subfield_data{marc_lib} ="<span id=\"error$i\" title=\"".$subfieldlib->{lib}."\">".$subfieldlib->{lib}."</span>"; > $subfield_data{mandatory} = $subfieldlib->{mandatory}; >+ $subfield_data{important} = $subfieldlib->{important}; > $subfield_data{repeatable} = $subfieldlib->{repeatable}; > $subfield_data{maxlength} = $subfieldlib->{maxlength}; > >diff --git a/installer/data/mysql/atomicupdate/bug-8643-add_important_constraint.perl b/installer/data/mysql/atomicupdate/bug-8643-add_important_constraint.perl >new file mode 100644 >index 0000000..8965642 >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug-8643-add_important_constraint.perl >@@ -0,0 +1,11 @@ >+$DBversion = "XXX"; >+if ( CheckVersion($DBversion) ) { >+ if ( !column_exists( 'marc_subfield_structure', 'important') ){ >+ $dbh->do("ALTER TABLE marc_subfield_structure ADD COLUMN important TINYINT(4) NOT NULL DEFAULT 0 AFTER mandatory"); >+ } >+ if ( !column_exists( 'marc_tag_structure', 'important') ){ >+ $dbh->do("ALTER TABLE marc_tag_structure ADD COLUMN important TINYINT(4) NOT NULL DEFAULT 0 AFTER mandatory"); >+ } >+ SetVersion($DBversion); >+ print "Upgrade to $DBversion done (Bug 8643 - Add important constraint to marc subfields)\n"; >+} >diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql >index 5016b68..550590f 100644 >--- a/installer/data/mysql/kohastructure.sql >+++ b/installer/data/mysql/kohastructure.sql >@@ -1043,6 +1043,7 @@ CREATE TABLE `marc_subfield_structure` ( > `libopac` varchar(255) NOT NULL default '', > `repeatable` tinyint(4) NOT NULL default 0, > `mandatory` tinyint(4) NOT NULL default 0, >+ `important` tinyint(4) NOT NULL DEFAULT '0', > `kohafield` varchar(40) default NULL, > `tab` tinyint(1) default NULL, > `authorised_value` varchar(32) default NULL, >@@ -1073,6 +1074,7 @@ CREATE TABLE `marc_tag_structure` ( > `libopac` varchar(255) NOT NULL default '', > `repeatable` tinyint(4) NOT NULL default 0, > `mandatory` tinyint(4) NOT NULL default 0, >+ `important` tinyint(4) NOT NULL DEFAULT '0', > `authorised_value` varchar(10) default NULL, > `ind1_defaultvalue` varchar(1) NOT NULL default '', > `ind2_defaultvalue` varchar(1) NOT NULL default '', >diff --git a/koha-tmpl/intranet-tmpl/prog/css/addbiblio.css b/koha-tmpl/intranet-tmpl/prog/css/addbiblio.css >index c31b7aa..e3551b2 100644 >--- a/koha-tmpl/intranet-tmpl/prog/css/addbiblio.css >+++ b/koha-tmpl/intranet-tmpl/prog/css/addbiblio.css >@@ -129,6 +129,7 @@ a.tagnum { > .mandatory_marker { > color: red; > } >+ > .linktools { display: block; white-space: nowrap; } > .linktools a { font-size : 75%; display:block;text-decoration:none;} > .linktools a {margin:0 2px;padding:2px;background-color:#FFF;text-align:center; } >diff --git a/koha-tmpl/intranet-tmpl/prog/css/right-to-left.css b/koha-tmpl/intranet-tmpl/prog/css/right-to-left.css >index 043c65d..06ccea8 100644 >--- a/koha-tmpl/intranet-tmpl/prog/css/right-to-left.css >+++ b/koha-tmpl/intranet-tmpl/prog/css/right-to-left.css >@@ -68,6 +68,7 @@ fieldset.rows textarea, > ol.bibliodetails, > ol.bibliodetails span.label, > span.required, >+span.important, > #marcDocsSelect, > #toplevelnav, > .ui-tabs-nav li, >@@ -140,7 +141,8 @@ div.patroninfo h5, > margin-left: 0.5em; > } > fieldset.rows img, >-span.required >+span.required, >+span.important > { > margin-right: 0.5em; > } >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 0c8a375..c80cd53 100644 >--- a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss >+++ b/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss >@@ -1777,6 +1777,10 @@ input[type='text']:read-only:focus { > background-color: #FFFF99; > } > >+.important_subfield_not_filled { >+ background-color : #FFFFCC; >+} >+ > .content_hidden { > display: none; > visibility: hidden; // you propably don't need to change this one >@@ -3654,6 +3658,12 @@ span { > margin-left: .5em; > } > >+ &.important { >+ color: #EAC117; >+ font-style: italic; >+ margin-left: .5em; >+ } >+ > &[class*=" label-"] { > color: #FFF; > display: inline; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/str/cataloging_additem.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/str/cataloging_additem.inc >index 97cadb9..22355bc 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/str/cataloging_additem.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/str/cataloging_additem.inc >@@ -9,9 +9,11 @@ > var LABEL_DELETE_ITEM = _("Delete item"); > var MSG_FORM_NOT_SUBMITTED = _("Form not submitted because of the following problem(s)"); > var MSG_MANDATORY_FIELDS_EMPTY = _("%s mandatory fields empty (highlighted)"); >+ var MSG_IMPORTANT_FIELDS_EMPTY = _("%s important fields empty (highlighted)"); > var MSG_ADD_MULTIPLE_ITEMS = _("You are about to add %s items. Continue?"); > var MSG_ENTER_NUM_ITEMS = _("Please enter a number of items to create."); > var MSG_CONFIRM_DELETE_ITEM = _("Are you sure you want to delete this item?"); > var MSG_CONFIRM_ADD_ITEM = _("Are you sure you want to add a new item? Any changes made on this page will be lost."); >+ var MSG_CONFIRM_SAVE = _("Are you sure you want to save?"); > var columns_settings = [% ColumnsSettings.GetColumns( 'cataloguing', 'additem', 'itemst', 'json' ) | $raw %]; > </script> >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 f4d0fef..8edb20b 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 >@@ -87,6 +87,14 @@ > <input type="checkbox" id="mandatory[% loo.row | html %]" name="mandatory[% loo.row | html %]" value="1" /> > [% END %] > </li> >+ <li> >+ <label for="important[% loo.row | html %]">Important: </label> >+ [% IF loo.important %] >+ <input type="checkbox" id="important[% loo.row | html %]" name="important[% loo.row | html %]" checked="checked" value="1" /> >+ [% ELSE %] >+ <input type="checkbox" id="important[% loo.row | html %]" name="important[% loo.row | html %]" value="1" /> >+ [% END %] >+ </li> > <li><label for="tab[% loo.row | html %]">Managed in tab: </label> > <select name="tab" tabindex="" size="1" id="tab[% loo.row | html %]"> > [%- IF ( loo.tab == -1 ) -%] >@@ -281,6 +289,7 @@ > [% IF ( loo.kohafield ) %] | Koha field: [% loo.kohafield | html %], [% END %] > [% IF ( loo.repeatable ) %]Repeatable, [% ELSE %]Not repeatable,[% END %] > [% IF ( loo.mandatory ) %]Mandatory, [% ELSE %]Not mandatory,[% END %] >+ [% IF ( loo.important ) %]Important, [% ELSE %]Not important,[% END %] > [% IF ( loo.seealso ) %] | See Also: [% loo.seealso | html %],[% END %] > [% IF ( loo.hidden ) %]hidden,[% END %] > [% IF ( loo.isurl ) %]is a URL,[% END %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marctagstructure.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marctagstructure.tt >index 1e9c54a..b9a1863 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marctagstructure.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marctagstructure.tt >@@ -80,6 +80,13 @@ > <input type="checkbox" name="mandatory" id="mandatory" value="1" /> > [% END %] > </li> >+ <li><label for="important">Important: </label> >+ [% IF ( important ) %] >+ <input type="checkbox" name="important" id="important" value="1" checked="checked" /> >+ [% ELSE %] >+ <input type="checkbox" name="important" id="important" value="1" /> >+ [% END %] >+ </li> > <li><label for="ind1_defaultvalue">First indicator default value: </label> > <input id="ind1_defaultvalue" type="text" name="ind1_defaultvalue" value="[% ind1_defaultvalue | html %]" maxlength="1" size="1" /> > </li> >@@ -176,6 +183,7 @@ > <th>Lib</th> > <th>Repeatable</th> > <th>Mandatory</th> >+ <th>Important</th> > <th>Auth value</th> > <th>Indicator 1</th> > <th>Indicator 2</th> >@@ -199,6 +207,7 @@ > </td> > <td>[% IF ( loo.repeatable ) %]Yes[% ELSE %]No[% END %]</td> > <td>[% IF ( loo.mandatory ) %]Yes[% ELSE %]No[% END %]</td> >+ <td>[% IF ( loo.important ) %]Yes[% ELSE %]No[% END %]</td> > <td>[% loo.authorised_value | html %]</td> > <td>[% loo.ind1_defaultvalue | html %]</td> > <td>[% loo.ind2_defaultvalue | html %]</td> >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 635b6cc..693b3c4 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt >@@ -385,6 +385,13 @@ > function Check(){ > var StrAlert = AreMandatoriesNotOk(); > if( ! StrAlert ){ >+ var StrWarning = AreImportantsNotOk(); >+ if (StrWarning){ >+ var r=confirm(StrWarning); >+ if (! r){ >+ return false; >+ } >+ } > document.f.submit(); > return true; > } else { >@@ -394,6 +401,115 @@ > } > > /** >+ * check if important subfields are written >+ */ >+ function AreImportantsNotOk(){ >+ var importants = new Array(); >+ var importantsfields = new Array(); >+ var tab = new Array(); >+ var label = new Array(); >+ var flag=0; >+ var tabflag= new Array(); >+ [% FOREACH BIG_LOO IN BIG_LOOP %] >+ [% FOREACH innerloo IN BIG_LOO.innerloop %] >+ [% IF ( innerloo.important ) %] >+ importantsfields.push(new Array("[% innerloo.tag | html %]","[% innerloo.index | html %][% innerloo.random | html %]","[% innerloo.index | html %]")); >+ [% END %] >+ [% FOREACH subfield_loo IN innerloo.subfield_loop %] >+ [% IF ( subfield_loo.important ) %]importants.push("[% subfield_loo.id | html %]"); >+ tab.push("[% BIG_LOO.number | html %]"); >+ label.push("[% subfield_loo.marc_lib | $raw %]"); >+ [% END %] >+ [% END %] >+ [% END %] >+ [% END %] >+ var StrWarning = _("A few important fields are not filled:"); >+ StrWarning += "\n\n"; >+ for(var i=0,len=importants.length; i<len ; i++){ >+ var tag=importants[i].substr(4,3); >+ var subfield=importants[i].substr(17,1); >+ var tagnumber=importants[i].substr(19,importants[i].lastIndexOf("_")-19); >+ if (tabflag[tag+subfield+tagnumber] == null) { >+ tabflag[tag+subfield+tagnumber]=new Array(); >+ tabflag[tag+subfield+tagnumber][0]=0; >+ } >+ if( tabflag[tag+subfield+tagnumber][0] != 1 && (document.getElementById(importants[i]) != null && ! document.getElementById(importants[i]).value || document.getElementById(importants[i]) == null)){ >+ tabflag[tag+subfield+tagnumber][0] = 0 + tabflag[tag+subfield+tagnumber] ; >+ document.getElementById(importants[i]).setAttribute('class','input_marceditor noEnterSubmit important_subfield_not_filled'); >+ $('#' + importants[i]).focus(); >+ tabflag[tag+subfield+tagnumber][1]=label[i]; >+ tabflag[tag+subfield+tagnumber][2]=tab[i]; >+ } else { >+ tabflag[tag+subfield+tagnumber][0] = 1; >+ } >+ } >+ for (var tagsubfieldid in tabflag){ >+ if (tabflag[tagsubfieldid][0]==0){ >+ var tag=tagsubfieldid.substr(0,3); >+ var subfield=tagsubfieldid.substr(3,1); >+ StrWarning += "\t* "+_("tag %s subfield %s %s in tab %s").format(tag, subfield, tabflag[tagsubfieldid][1], tabflag[tagsubfieldid][2]) + "\n"; >+ //StrAlert += "\t* "+label[i]+_(" in tab ")+tab[i]+"\n"; >+ flag=1; >+ } >+ } >+ >+ /* Check for importants field(not subfields) */ >+ for(var i=0,len=importantsfields.length; i<len; i++){ >+ isempty = true; >+ arr = importantsfields[i]; >+ divid = "tag_" + arr[0] + "_" + arr[1]; >+ varegexp = new RegExp("^tag_" + arr[0] + "_code_"); >+ >+ if(parseInt(arr[0]) >= 10){ >+ elem = document.getElementById(divid); >+ eleminputs = elem.getElementsByTagName('input'); >+ for(var j=0,len2=eleminputs.length; j<len2; j++){ >+ >+ if(eleminputs[j].name.match(varegexp) && eleminputs[j].value){ >+ inputregexp = new RegExp("^tag_" + arr[0] + "_subfield_" + eleminputs[j].value + "_" + arr[2]); >+ >+ for( var k=0; k<len2; k++){ >+ if(eleminputs[k].id.match(inputregexp) && eleminputs[k].value){ >+ isempty = false >+ } >+ } >+ >+ elemselect = elem.getElementsByTagName('select'); >+ for( var k=0; k<elemselect.length; k++){ >+ if(elemselect[k].id.match(inputregexp) && elemselect[k].value){ >+ isempty = false >+ } >+ } >+ } >+ } >+ >+ elemtextareas = elem.getElementsByTagName('textarea'); >+ for(var j=0,len2=elemtextareas.length; j<len2; j++){ >+ // this bit assumes that the only textareas in this context would be for subfields >+ if (elemtextareas[j].value) { >+ isempty = false; >+ } >+ } >+ } else { >+ isempty = false; >+ } >+ >+ if(isempty){ >+ flag = 1; >+ StrWarning += "\t* " + _("Field %s is important, at least one of its subfields must be filled.").format(arr[0]) + "\n"; >+ } >+ } >+ >+ StrWarning += "\n" + _("Are you sure you want to save?"); >+ >+ if(flag){ >+ return StrWarning; >+ } else { >+ return flag; >+ } >+ } >+ >+ /** > * check if z3950 mandatories are set or not > */ > function GetZ3950Terms(){ >@@ -751,6 +867,8 @@ > [% UNLESS advancedMARCEditor %] > [% IF ( subfield_loo.mandatory ) %] > <span class="subfield subfield_mandatory"> >+ [% ELSIF ( subfield_loo.important ) %] >+ <span class="subfield subfield_important"> > [% ELSE %] > <span class="subfield"> > [% END %] >@@ -797,6 +915,8 @@ > [% END # /IF (mv.type...) %] > [% IF ( subfield_loo.mandatory ) %] > <span class="required">Required</span> >+ [% ELSIF ( subfield_loo.important ) %] >+ <span class="important">Important</span> > [% END %] > <span class="subfield_controls"> > [% IF ( subfield_loo.repeatable ) %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt >index 25fcf73..edfaaf4 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt >@@ -196,12 +196,15 @@ > <input type="hidden" name="tag" value="[% ite.tag | html %]" /> > <input type="hidden" name="subfield" value="[% ite.subfield | html %]" /> > <input type="hidden" name="mandatory" value="[% ite.mandatory | html %]" /> >+ <input type="hidden" name="important" value="[% ite.important | html %]" /> > [% IF ( ite.repeatable ) %] > <a href="#" class="buttonPlus" onclick="CloneItemSubfield(this.parentNode); return false;"> > <img src="[% interface | html %]/[% theme | html %]/img/clone-subfield.png" alt="Clone" title="Clone this subfield" /> > </a> > [% END %] >- [% IF ( ite.mandatory ) %] <span class="required">Required</span>[% END %] >+ [% IF ( ite.mandatory ) %] <span class="required">Required</span> >+ [% ELSIF ( ite.important ) %] <span class="important">Important</span> >+ [% END %] > </div></li> > [% END %] > </ol> >diff --git a/koha-tmpl/intranet-tmpl/prog/js/cataloging.js b/koha-tmpl/intranet-tmpl/prog/js/cataloging.js >index b26c45b..89571d8 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/cataloging.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/cataloging.js >@@ -557,6 +557,18 @@ function CheckMandatorySubfields(p){ > return total; > } > >-$(document).ready(function() { >+function CheckImportantSubfields(p){ >+ var total = 0; >+ $(p).find(".subfield_line input[name='important'][value='1']").each(function(i){ >+ var editor = $(this).siblings("[name='field_value']"); >+ if (!editor.val()) { >+ editor.addClass("missing"); >+ total++; >+ } >+ }); >+ return total; >+} >+ >+ $(document).ready(function() { > $("input.input_marceditor, input.indicator").addClass('noEnterSubmit'); > }); >diff --git a/koha-tmpl/intranet-tmpl/prog/js/cataloging_additem.js b/koha-tmpl/intranet-tmpl/prog/js/cataloging_additem.js >index 8c28e83..e3e7467 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/cataloging_additem.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/cataloging_additem.js >@@ -76,8 +76,10 @@ $(document).ready(function(){ > }); > > function Check(f) { >- var total_errors = CheckMandatorySubfields(f); >- if (total_errors==0) { >+ var total_mandatory = CheckMandatorySubfields(f); >+ var total_important = CheckImportantSubfields(f); >+ var alertString2; >+ if (total_mandatory==0) { > // Explanation about this line: > // In case of limited edition permission, we have to prevent user from modifying some fields. > // But there is no such thing as readonly attribute for select elements. >@@ -85,14 +87,30 @@ function Check(f) { > // So we "un-disable" the elements just before submitting. > // That's a bit clumsy, and if someone comes up with a better solution, feel free to improve that. > $("select[name=field_value]").prop('disabled', false); >- return true; > } else { >- var alertString2 = MSG_FORM_NOT_SUBMITTED; >+ alertString2 = MSG_FORM_NOT_SUBMITTED; > alertString2 += "\n------------------------------------------------------------------------------------\n"; >- alertString2 += "\n- " + "%s " + MSG_MANDATORY_FIELDS_EMPTY.format(total_errors); >- alert(alertString2); >+ alertString2 += "\n- " + "%s " + MSG_MANDATORY_FIELDS_EMPTY.format(total_mandatory); >+ } >+ if(total_important > 0){ >+ if( !alertString2 ){ >+ alertString2 = ""; >+ } >+ alertString2 += "\n\n " + MSG_IMPORTANT_FIELDS_EMPTY.format(total_important); >+ alertString2 += "\n\n " + MSG_CONFIRM_SAVE; >+ } >+ if(alertString2){ >+ if(total_mandatory){ >+ alert(alertString2); >+ }else{ >+ var a = confirm(alertString2); >+ if( a ){ >+ return true; >+ } >+ } > return false; > } >+ return true; > } > > function CheckMultipleAdd(f) { >-- >2.7.4
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 8643
:
11621
|
11622
|
30640
|
31032
|
40232
|
40237
|
41259
|
41261
|
41264
|
41265
|
45834
|
45835
|
45836
|
45837
|
60554
|
60555
|
65148
|
65149
|
65682
|
72154
|
72155
|
72156
|
72157
|
73591
|
73808
|
73809
|
73810
|
73811
|
73812
|
73813
|
73814
|
73815
|
73816
|
73817
|
73818
|
74267
|
74268
|
74269
|
74270
|
74271
|
74272
|
74273
|
81032
|
85982
|
91537
|
92081
|
92384
|
96625
|
96627
|
97325
|
97326
|
98607
|
98608
|
98702
|
98703
|
98712