From dae446755984124f0562de6d8d7a7d51001d36a2 Mon Sep 17 00:00:00 2001 From: Jesse Weaver Date: Tue, 10 Nov 2015 12:00:41 -0700 Subject: [PATCH] Bug 18823: Rancor - Save overriding warnings Allow saving of record even if invalid To test: Open/create a record with missing mandatory fields Click save Record is not saved and errors are listed Choose the dropdown under the save button and select 'Save overriding warnings' Note record is saved --- koha-tmpl/intranet-tmpl/lib/koha/cateditor/koha-backend.js | 12 +++++++----- koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc | 8 +++++--- .../intranet-tmpl/prog/en/modules/cataloguing/editor.tt | 9 ++++----- 3 files changed, 16 insertions(+), 13 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 4f36be8..e010c80 100644 --- a/koha-tmpl/intranet-tmpl/lib/koha/cateditor/koha-backend.js +++ b/koha-tmpl/intranet-tmpl/lib/koha/cateditor/koha-backend.js @@ -245,7 +245,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( '', 'mandatory', '1' ); @@ -254,7 +256,7 @@ define( [ '/cgi-bin/koha/svc/cataloguing/framework?frameworkcode=&callback=defin var nonRepeatableSubfields = KohaBackend.GetSubfieldsBy( '', '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 = {}; @@ -267,7 +269,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; } @@ -277,7 +279,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]; } @@ -285,7 +287,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 44571ef..9c4aacd 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc @@ -386,7 +386,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; @@ -401,7 +401,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 } ); @@ -434,7 +434,7 @@ require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr } if (callback) callback( data ); - } ); + }, options ); } function loadRecord( recid, editor, callback ) { @@ -1142,6 +1142,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 ); } ); 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 d3e8e3d..a324842 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/editor.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/editor.tt @@ -32,11 +32,10 @@
- - -
-- 2.7.4