Lines 287-293
define( [ '/cgi-bin/koha/svc/cataloguing/framework?frameworkcode=&callback=defin
Link Here
|
287 |
} ); |
287 |
} ); |
288 |
}, |
288 |
}, |
289 |
|
289 |
|
290 |
ValidateRecord: function( frameworkcode, record ) { |
290 |
ValidateRecord: function( frameworkcode, record, options ) { |
|
|
291 |
options = options || {}; |
292 |
|
291 |
var errors = []; |
293 |
var errors = []; |
292 |
|
294 |
|
293 |
var mandatoryTags = KohaBackend.GetTagsBy( record.frameworkcode, 'mandatory', '1' ); |
295 |
var mandatoryTags = KohaBackend.GetTagsBy( record.frameworkcode, 'mandatory', '1' ); |
Lines 296-302
define( [ '/cgi-bin/koha/svc/cataloguing/framework?frameworkcode=&callback=defin
Link Here
|
296 |
var nonRepeatableSubfields = KohaBackend.GetSubfieldsBy( record.frameworkcode, 'repeatable', '0' ); |
298 |
var nonRepeatableSubfields = KohaBackend.GetSubfieldsBy( record.frameworkcode, 'repeatable', '0' ); |
297 |
|
299 |
|
298 |
$.each( mandatoryTags, function( tag ) { |
300 |
$.each( mandatoryTags, function( tag ) { |
299 |
if ( !record.hasField( tag ) ) errors.push( { type: 'missingTag', tag: tag } ); |
301 |
if ( !record.hasField( tag ) && !options.override_warnings ) errors.push( { type: 'missingTag', tag: tag } ); |
300 |
} ); |
302 |
} ); |
301 |
|
303 |
|
302 |
var seenTags = {}; |
304 |
var seenTags = {}; |
Lines 309-315
define( [ '/cgi-bin/koha/svc/cataloguing/framework?frameworkcode=&callback=defin
Link Here
|
309 |
} |
311 |
} |
310 |
|
312 |
|
311 |
if ( seenTags[ field.tagnumber() ] && nonRepeatableTags[ field.tagnumber() ] ) { |
313 |
if ( seenTags[ field.tagnumber() ] && nonRepeatableTags[ field.tagnumber() ] ) { |
312 |
errors.push( { type: 'unrepeatableTag', line: field.sourceLine, tag: field.tagnumber() } ); |
314 |
if ( !options.override_warnings ) errors.push( { type: 'unrepeatableTag', line: field.sourceLine, tag: field.tagnumber() } ); |
313 |
return; |
315 |
return; |
314 |
} |
316 |
} |
315 |
|
317 |
|
Lines 319-325
define( [ '/cgi-bin/koha/svc/cataloguing/framework?frameworkcode=&callback=defin
Link Here
|
319 |
|
321 |
|
320 |
$.each( field.subfields(), function( undef, subfield ) { |
322 |
$.each( field.subfields(), function( undef, subfield ) { |
321 |
if ( seenSubfields[ subfield[0] ] != null && ( nonRepeatableSubfields[ field.tagnumber() ] || {} )[ subfield[0] ] ) { |
323 |
if ( seenSubfields[ subfield[0] ] != null && ( nonRepeatableSubfields[ field.tagnumber() ] || {} )[ subfield[0] ] ) { |
322 |
errors.push( { type: 'unrepeatableSubfield', subfield: subfield[0], line: field.sourceLine } ); |
324 |
if ( !options.override_warnings ) errors.push( { type: 'unrepeatableSubfield', subfield: subfield[0], line: field.sourceLine } ); |
323 |
} else { |
325 |
} else { |
324 |
seenSubfields[ subfield[0] ] = subfield[1]; |
326 |
seenSubfields[ subfield[0] ] = subfield[1]; |
325 |
} |
327 |
} |
Lines 327-333
define( [ '/cgi-bin/koha/svc/cataloguing/framework?frameworkcode=&callback=defin
Link Here
|
327 |
|
329 |
|
328 |
$.each( mandatorySubfields[ field.tagnumber() ] || {}, function( subfield ) { |
330 |
$.each( mandatorySubfields[ field.tagnumber() ] || {}, function( subfield ) { |
329 |
if ( !seenSubfields[ subfield ] ) { |
331 |
if ( !seenSubfields[ subfield ] ) { |
330 |
errors.push( { type: 'missingSubfield', subfield: subfield[0], line: field.sourceLine } ); |
332 |
if ( !options.override_warnings ) errors.push( { type: 'missingSubfield', subfield: subfield[0], line: field.sourceLine } ); |
331 |
} |
333 |
} |
332 |
} ); |
334 |
} ); |
333 |
} ); |
335 |
} ); |