|
Lines 245-251
define( [ '/cgi-bin/koha/svc/cataloguing/framework?frameworkcode=&callback=defin
Link Here
|
| 245 |
} ); |
245 |
} ); |
| 246 |
}, |
246 |
}, |
| 247 |
|
247 |
|
| 248 |
ValidateRecord: function( frameworkcode, record ) { |
248 |
ValidateRecord: function( frameworkcode, record, options ) { |
|
|
249 |
options = options || {}; |
| 250 |
|
| 249 |
var errors = []; |
251 |
var errors = []; |
| 250 |
|
252 |
|
| 251 |
var mandatoryTags = KohaBackend.GetTagsBy( '', 'mandatory', '1' ); |
253 |
var mandatoryTags = KohaBackend.GetTagsBy( '', 'mandatory', '1' ); |
|
Lines 254-260
define( [ '/cgi-bin/koha/svc/cataloguing/framework?frameworkcode=&callback=defin
Link Here
|
| 254 |
var nonRepeatableSubfields = KohaBackend.GetSubfieldsBy( '', 'repeatable', '0' ); |
256 |
var nonRepeatableSubfields = KohaBackend.GetSubfieldsBy( '', 'repeatable', '0' ); |
| 255 |
|
257 |
|
| 256 |
$.each( mandatoryTags, function( tag ) { |
258 |
$.each( mandatoryTags, function( tag ) { |
| 257 |
if ( !record.hasField( tag ) ) errors.push( { type: 'missingTag', tag: tag } ); |
259 |
if ( !record.hasField( tag ) && !options.override_warnings ) errors.push( { type: 'missingTag', tag: tag } ); |
| 258 |
} ); |
260 |
} ); |
| 259 |
|
261 |
|
| 260 |
var seenTags = {}; |
262 |
var seenTags = {}; |
|
Lines 267-273
define( [ '/cgi-bin/koha/svc/cataloguing/framework?frameworkcode=&callback=defin
Link Here
|
| 267 |
} |
269 |
} |
| 268 |
|
270 |
|
| 269 |
if ( seenTags[ field.tagnumber() ] && nonRepeatableTags[ field.tagnumber() ] ) { |
271 |
if ( seenTags[ field.tagnumber() ] && nonRepeatableTags[ field.tagnumber() ] ) { |
| 270 |
errors.push( { type: 'unrepeatableTag', line: field.sourceLine, tag: field.tagnumber() } ); |
272 |
if ( !options.override_warnings ) errors.push( { type: 'unrepeatableTag', line: field.sourceLine, tag: field.tagnumber() } ); |
| 271 |
return; |
273 |
return; |
| 272 |
} |
274 |
} |
| 273 |
|
275 |
|
|
Lines 277-283
define( [ '/cgi-bin/koha/svc/cataloguing/framework?frameworkcode=&callback=defin
Link Here
|
| 277 |
|
279 |
|
| 278 |
$.each( field.subfields(), function( undef, subfield ) { |
280 |
$.each( field.subfields(), function( undef, subfield ) { |
| 279 |
if ( seenSubfields[ subfield[0] ] != null && ( nonRepeatableSubfields[ field.tagnumber() ] || {} )[ subfield[0] ] ) { |
281 |
if ( seenSubfields[ subfield[0] ] != null && ( nonRepeatableSubfields[ field.tagnumber() ] || {} )[ subfield[0] ] ) { |
| 280 |
errors.push( { type: 'unrepeatableSubfield', subfield: subfield[0], line: field.sourceLine } ); |
282 |
if ( !options.override_warnings ) errors.push( { type: 'unrepeatableSubfield', subfield: subfield[0], line: field.sourceLine } ); |
| 281 |
} else { |
283 |
} else { |
| 282 |
seenSubfields[ subfield[0] ] = subfield[1]; |
284 |
seenSubfields[ subfield[0] ] = subfield[1]; |
| 283 |
} |
285 |
} |
|
Lines 285-291
define( [ '/cgi-bin/koha/svc/cataloguing/framework?frameworkcode=&callback=defin
Link Here
|
| 285 |
|
287 |
|
| 286 |
$.each( mandatorySubfields[ field.tagnumber() ] || {}, function( subfield ) { |
288 |
$.each( mandatorySubfields[ field.tagnumber() ] || {}, function( subfield ) { |
| 287 |
if ( !seenSubfields[ subfield ] ) { |
289 |
if ( !seenSubfields[ subfield ] ) { |
| 288 |
errors.push( { type: 'missingSubfield', subfield: subfield[0], line: field.sourceLine } ); |
290 |
if ( !options.override_warnings ) errors.push( { type: 'missingSubfield', subfield: subfield[0], line: field.sourceLine } ); |
| 289 |
} |
291 |
} |
| 290 |
} ); |
292 |
} ); |
| 291 |
} ); |
293 |
} ); |