Bugzilla – Attachment 97325 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.36 KB, created by
Maryse Simard
on 2020-01-13 16:44:42 UTC
(
hide
)
Description:
Bug 8643: Add important constraint to marc subfields
Filename:
MIME Type:
Creator:
Maryse Simard
Created:
2020-01-13 16:44:42 UTC
Size:
38.36 KB
patch
obsolete
>From f67d85cf20027618b75a26c169b7a6ecae5b1ed3 Mon Sep 17 00:00:00 2001 >From: simith <simith@inlibro.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 ) > >Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com> >Tested on update and new install, works as described. >No errors. >--- > C4/Biblio.pm | 12 +- > Koha/Schema/Result/MarcSubfieldStructure.pm | 8 ++ > admin/marc_subfields_structure.pl | 8 +- > 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 + > .../intranet-tmpl/prog/css/right-to-left.css | 4 +- > .../prog/css/src/staff-global.scss | 10 ++ > .../en/includes/str/cataloging_additem.inc | 2 + > .../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 +- > .../prog/js/cataloging_additem.js | 30 ++++- > 17 files changed, 249 insertions(+), 21 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 ce0d4fbdb6..01b5b36f99 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/Koha/Schema/Result/MarcSubfieldStructure.pm b/Koha/Schema/Result/MarcSubfieldStructure.pm >index 94eba864af..dc8ddd7c89 100644 >--- a/Koha/Schema/Result/MarcSubfieldStructure.pm >+++ b/Koha/Schema/Result/MarcSubfieldStructure.pm >@@ -63,6 +63,12 @@ __PACKAGE__->table("marc_subfield_structure"); > default_value: 0 > is_nullable: 0 > >+=head2 important >+ >+ data_type: 'tinyint' >+ default_value: 0 >+ is_nullable: 0 >+ > =head2 kohafield > > data_type: 'varchar' >@@ -149,6 +155,8 @@ __PACKAGE__->add_columns( > { data_type => "tinyint", default_value => 0, is_nullable => 0 }, > "mandatory", > { data_type => "tinyint", default_value => 0, is_nullable => 0 }, >+ "important", >+ { data_type => "tinyint", default_value => 0, is_nullable => 0 }, > "kohafield", > { data_type => "varchar", is_nullable => 1, size => 40 }, > "tab", >diff --git a/admin/marc_subfields_structure.pl b/admin/marc_subfields_structure.pl >index cdefc25884..0dce186c6f 100755 >--- a/admin/marc_subfields_structure.pl >+++ b/admin/marc_subfields_structure.pl >@@ -187,6 +187,7 @@ if ( $op eq 'add_form' ) { > $row_data{authtypecode} = $data->{'authtypecode'}; > $row_data{repeatable} = $data->{repeatable}; > $row_data{mandatory} = $data->{mandatory}; >+ $row_data{important} = $data->{important}; > $row_data{hidden} = $data->{hidden}; > $row_data{isurl} = $data->{isurl}; > $row_data{row} = $i; >@@ -208,6 +209,7 @@ if ( $op eq 'add_form' ) { > $row_data{hidden} = ""; > $row_data{repeatable} = 0; > $row_data{mandatory} = 0; >+ $row_data{important} = 0; > $row_data{isurl} = 0; > $row_data{kohafields} = \@kohafields; > $row_data{authorised_values} = \@authorised_values; >@@ -234,7 +236,7 @@ elsif ( $op eq 'add_validate' ) { > my $dbh = C4::Context->dbh; > $template->param( tagfield => "$input->param('tagfield')" ); > 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'); >@@ -259,6 +261,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]; >@@ -280,6 +283,7 @@ elsif ( $op eq 'add_validate' ) { > $libopac, > $repeatable, > $mandatory, >+ $important, > $kohafield, > $tab, > $seealso, >@@ -312,6 +316,7 @@ elsif ( $op eq 'add_validate' ) { > libopac => $libopac, > repeatable => $repeatable, > mandatory => $mandatory, >+ important => $important, > kohafield => $kohafield, > tab => $tab, > seealso => $seealso, >@@ -394,6 +399,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 e34edd557c..b5d7004069 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,important,authorised_value,ind1_defaultvalue,ind2_defaultvalue from marc_tag_structure where tagfield=? and frameworkcode=?"); > $sth->execute($searchfield,$frameworkcode); > $data=$sth->fetchrow_hashref; > } >@@ -107,6 +107,7 @@ if ($op eq 'add_form') { > libopac => $data->{'libopac'}, > repeatable => $data->{'repeatable'}, > mandatory => $data->{'mandatory'}, >+ important => $data->{'important'}, > authorised_value => $data->{authorised_value}, > ind1_defaultvalue => $data->{'ind1_defaultvalue'}, > ind2_defaultvalue => $data->{'ind2_defaultvalue'} >@@ -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,important,authorised_value,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 a548bab8a6..2a028c5bce 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 babf6d3d4c..67d8d98b60 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 0000000000..8965642bf9 >--- /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 56d5d27d5a..586a01e1d4 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/right-to-left.css b/koha-tmpl/intranet-tmpl/prog/css/right-to-left.css >index 384528ea12..8117fee551 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 5e02ed1d3c..ce935a0f08 100644 >--- a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss >+++ b/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss >@@ -1534,6 +1534,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 >@@ -3435,6 +3439,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 57e389e8a7..52d8f3353a 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 >@@ -13,9 +13,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 09991e99f2..59efee7897 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 >@@ -88,6 +88,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 ) -%] >@@ -283,6 +291,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 aabfe80297..3bfc6cded1 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 2b6caa8034..49267f9f34 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt >@@ -393,6 +393,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 { >@@ -401,6 +408,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 > */ >@@ -770,6 +886,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 %] >@@ -816,6 +934,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 d5320e6949..68052a815c 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 c7a30621c2..1bce295f0f 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/cataloging.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/cataloging.js >@@ -547,7 +547,19 @@ 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'); > $(document).ajaxSuccess(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 8c28e8398d..e3e746764a 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.17.1
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