Lines 537-566
define( [ 'marc-record', 'koha-backend', 'preferences', 'text-marc', 'widget' ],
Link Here
|
537 |
this.cm.refresh(); |
537 |
this.cm.refresh(); |
538 |
}, |
538 |
}, |
539 |
|
539 |
|
540 |
setFrameworkCode: function( code, callback ) { |
540 |
setFrameworkCode: function( code, updateFields, callback ) { |
541 |
this.frameworkcode = code; |
541 |
this.frameworkcode = code; |
542 |
$( 'a.change-framework i.selected' ).addClass( 'hidden' ); |
542 |
$( 'a.change-framework i.selected' ).addClass( 'hidden' ); |
543 |
$( 'a.change-framework i.unselected' ).removeClass( 'hidden' ); |
543 |
$( 'a.change-framework i.unselected' ).removeClass( 'hidden' ); |
544 |
$( 'a.change-framework[data-frameworkcode="' + code + '"] i.unselected' ).addClass( 'hidden' ); |
544 |
$( 'a.change-framework[data-frameworkcode="' + code + '"] i.unselected' ).addClass( 'hidden' ); |
545 |
$( 'a.change-framework[data-frameworkcode="' + code + '"] i.selected' ).removeClass( 'hidden '); |
545 |
$( 'a.change-framework[data-frameworkcode="' + code + '"] i.selected' ).removeClass( 'hidden '); |
546 |
KohaBackend.InitFramework( code, callback ); |
546 |
var cm = this.cm; |
|
|
547 |
KohaBackend.InitFramework( code, function ( error ) { |
548 |
cm.setOption( 'mode', { |
549 |
name: 'marc', |
550 |
nonRepeatableTags: KohaBackend.GetTagsBy( code, 'repeatable', '0' ), |
551 |
nonRepeatableSubfields: KohaBackend.GetSubfieldsBy( code, 'repeatable', '0' ) |
552 |
}); |
553 |
if ( updateFields ) { |
554 |
var record = TextMARC.TextToRecord( cm.getValue() ); |
555 |
KohaBackend.FillRecord( code, record ); |
556 |
cm.setValue( TextMARC.RecordToText(record) ); |
557 |
} |
558 |
callback( error ); |
559 |
} ); |
547 |
}, |
560 |
}, |
548 |
|
561 |
|
549 |
displayRecord: function( record ) { |
562 |
displayRecord: function( record ) { |
550 |
this.cm.setValue( TextMARC.RecordToText(record) ); |
563 |
this.cm.setValue( TextMARC.RecordToText(record) ); |
551 |
this.modified = false; |
564 |
this.modified = false; |
552 |
var cm = this.cm; |
|
|
553 |
this.setFrameworkCode( |
565 |
this.setFrameworkCode( |
554 |
typeof record.frameworkcode !== 'undefined' ? record.frameworkcode : '', |
566 |
typeof record.frameworkcode !== 'undefined' ? record.frameworkcode : '', |
|
|
567 |
false, |
555 |
function ( error ) { |
568 |
function ( error ) { |
556 |
if ( typeof error !== 'undefined' ) { |
569 |
if ( typeof error !== 'undefined' ) { |
557 |
humanMsg.displayAlert( _(error), { className: 'humanError' } ); |
570 |
humanMsg.displayAlert( _(error), { className: 'humanError' } ); |
558 |
} |
571 |
} |
559 |
cm.setOption( 'mode', { |
|
|
560 |
name: 'marc', |
561 |
nonRepeatableTags: KohaBackend.GetTagsBy( this.frameworkcode, 'repeatable', '0' ), |
562 |
nonRepeatableSubfields: KohaBackend.GetSubfieldsBy( this.frameworkcode, 'repeatable', '0' ) |
563 |
}); |
564 |
} |
572 |
} |
565 |
); |
573 |
); |
566 |
}, |
574 |
}, |