From 0556c4a242fe4a0914db22c19816238d64c58eac Mon Sep 17 00:00:00 2001 From: Cori Lynn Arnold Date: Mon, 15 Oct 2018 18:16:26 +0000 Subject: [PATCH] Bug 18823: Rancor - save override warnings Rebase. Signed-off-by: cori Rebased-on: 2019-03-20 Alex Arnaud --- koha-tmpl/intranet-tmpl/lib/koha/cateditor/koha-backend.js | 12 +++++++----- koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc | 8 +++++--- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/lib/koha/cateditor/koha-backend.js b/koha-tmpl/intranet-tmpl/lib/koha/cateditor/koha-backend.js index 373f385..7cc1e64 100644 --- a/koha-tmpl/intranet-tmpl/lib/koha/cateditor/koha-backend.js +++ b/koha-tmpl/intranet-tmpl/lib/koha/cateditor/koha-backend.js @@ -287,7 +287,9 @@ define( [ '/cgi-bin/koha/svc/cataloguing/framework?frameworkcode=&callback=defin } ); }, - ValidateRecord: function( frameworkcode, record ) { + ValidateRecord: function( frameworkcode, record, options ) { + options = options || {}; + var errors = []; var mandatoryTags = KohaBackend.GetTagsBy( record.frameworkcode, 'mandatory', '1' ); @@ -296,7 +298,7 @@ define( [ '/cgi-bin/koha/svc/cataloguing/framework?frameworkcode=&callback=defin var nonRepeatableSubfields = KohaBackend.GetSubfieldsBy( record.frameworkcode, 'repeatable', '0' ); $.each( mandatoryTags, function( tag ) { - if ( !record.hasField( tag ) ) errors.push( { type: 'missingTag', tag: tag } ); + if ( !record.hasField( tag ) && !options.override_warnings ) errors.push( { type: 'missingTag', tag: tag } ); } ); var seenTags = {}; @@ -309,7 +311,7 @@ define( [ '/cgi-bin/koha/svc/cataloguing/framework?frameworkcode=&callback=defin } if ( seenTags[ field.tagnumber() ] && nonRepeatableTags[ field.tagnumber() ] ) { - errors.push( { type: 'unrepeatableTag', line: field.sourceLine, tag: field.tagnumber() } ); + if ( !options.override_warnings ) errors.push( { type: 'unrepeatableTag', line: field.sourceLine, tag: field.tagnumber() } ); return; } @@ -319,7 +321,7 @@ define( [ '/cgi-bin/koha/svc/cataloguing/framework?frameworkcode=&callback=defin $.each( field.subfields(), function( undef, subfield ) { if ( seenSubfields[ subfield[0] ] != null && ( nonRepeatableSubfields[ field.tagnumber() ] || {} )[ subfield[0] ] ) { - errors.push( { type: 'unrepeatableSubfield', subfield: subfield[0], line: field.sourceLine } ); + if ( !options.override_warnings ) errors.push( { type: 'unrepeatableSubfield', subfield: subfield[0], line: field.sourceLine } ); } else { seenSubfields[ subfield[0] ] = subfield[1]; } @@ -327,7 +329,7 @@ define( [ '/cgi-bin/koha/svc/cataloguing/framework?frameworkcode=&callback=defin $.each( mandatorySubfields[ field.tagnumber() ] || {}, function( subfield ) { if ( !seenSubfields[ subfield ] ) { - errors.push( { type: 'missingSubfield', subfield: subfield[0], line: field.sourceLine } ); + if ( !options.override_warnings ) errors.push( { type: 'missingSubfield', subfield: subfield[0], line: field.sourceLine } ); } } ); } ); 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 07e67d5..ffe8c33 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc @@ -424,7 +424,7 @@ require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr $( 'title', document.head ).html( _("Koha › Cataloging › ") + backend.titleForRecord.format( parts[1] ) ); } - function saveRecord( recid, editor, callback ) { + function saveRecord( recid, editor, callback, options ) { var parts = recid.split('/'); if ( parts.length != 2 ) return false; @@ -439,7 +439,7 @@ require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr return; } - var errors = KohaBackend.ValidateRecord( '', record ); + var errors = KohaBackend.ValidateRecord( '', record, options ); if ( errors.length ) { state.saving = false; callback( { error: 'invalid', errors: errors } ); @@ -473,7 +473,7 @@ require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr } if (callback) callback( data ); - } ); + }, options ); } function loadRecord( recid, editor, callback ) { @@ -1182,6 +1182,8 @@ require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr } } + var options = { override_warnings: $(this).is('#save-with-override') } + $.each( enabledTargets, function() { saveRecord( this.id, editor, finishCb, options ); } ); -- 2.7.4