Bugzilla – Attachment 79503 Details for
Bug 16424
Advanced editor reverts records back to Default framework
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 16424: Update default values in advanced editor when changing frameworks.
Bug-16424-Update-default-values-in-advanced-editor.patch (text/plain), 5.32 KB, created by
Katrin Fischer
on 2018-09-27 13:15:47 UTC
(
hide
)
Description:
Bug 16424: Update default values in advanced editor when changing frameworks.
Filename:
MIME Type:
Creator:
Katrin Fischer
Created:
2018-09-27 13:15:47 UTC
Size:
5.32 KB
patch
obsolete
>From 42c2554880bf1a5d2aff299f798ecfaf77f8d70d Mon Sep 17 00:00:00 2001 >From: Ere Maijala <ere.maijala@helsinki.fi> >Date: Fri, 10 Nov 2017 08:28:01 +0200 >Subject: [PATCH] Bug 16424: Update default values in advanced editor when > changing frameworks. > >Signed-off-by: Michal Denar <black23@gmail.com> > >Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> >--- > .../lib/koha/cateditor/koha-backend.js | 8 ++++++-- > .../lib/koha/cateditor/marc-editor.js | 24 ++++++++++++++-------- > .../prog/en/includes/cateditor-ui.inc | 1 + > 3 files changed, 23 insertions(+), 10 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 10e9337..eeca779 100644 >--- a/koha-tmpl/intranet-tmpl/lib/koha/cateditor/koha-backend.js >+++ b/koha-tmpl/intranet-tmpl/lib/koha/cateditor/koha-backend.js >@@ -222,10 +222,14 @@ define( [ '/cgi-bin/koha/svc/cataloguing/framework?frameworkcode=&callback=defin > $.each( taginfo.subfields, function( undef, subfield ) { > var subfieldcode = subfield[0], subfieldinfo = subfield[1]; > >- if ( subfieldinfo.mandatory != "1" && !allTags ) return; >+ if ( subfieldinfo.mandatory != "1" && !subfieldinfo.defaultvalue && !allTags ) return; > > $.each( fields, function( undef, field ) { >- if ( !field.hasSubfield(subfieldcode) ) field.addSubfieldGrouped( [ subfieldcode, subfieldinfo.defaultvalue || '' ] ); >+ if ( !field.hasSubfield(subfieldcode) ) { >+ field.addSubfieldGrouped( [ subfieldcode, subfieldinfo.defaultvalue || '' ] ); >+ } else if ( subfieldinfo.defaultvalue && field.subfield( subfieldcode ) === '' ) { >+ field.subfield( subfieldcode, subfieldinfo.defaultvalue ); >+ } > } ); > } ); > } ); >diff --git a/koha-tmpl/intranet-tmpl/lib/koha/cateditor/marc-editor.js b/koha-tmpl/intranet-tmpl/lib/koha/cateditor/marc-editor.js >index 046ff71..7fe7062 100644 >--- a/koha-tmpl/intranet-tmpl/lib/koha/cateditor/marc-editor.js >+++ b/koha-tmpl/intranet-tmpl/lib/koha/cateditor/marc-editor.js >@@ -537,30 +537,38 @@ define( [ 'marc-record', 'koha-backend', 'preferences', 'text-marc', 'widget' ], > this.cm.refresh(); > }, > >- setFrameworkCode: function( code, callback ) { >+ setFrameworkCode: function( code, updateFields, callback ) { > this.frameworkcode = code; > $( 'a.change-framework i.selected' ).addClass( 'hidden' ); > $( 'a.change-framework i.unselected' ).removeClass( 'hidden' ); > $( 'a.change-framework[data-frameworkcode="' + code + '"] i.unselected' ).addClass( 'hidden' ); > $( 'a.change-framework[data-frameworkcode="' + code + '"] i.selected' ).removeClass( 'hidden '); >- KohaBackend.InitFramework( code, callback ); >+ var cm = this.cm; >+ KohaBackend.InitFramework( code, function ( error ) { >+ cm.setOption( 'mode', { >+ name: 'marc', >+ nonRepeatableTags: KohaBackend.GetTagsBy( code, 'repeatable', '0' ), >+ nonRepeatableSubfields: KohaBackend.GetSubfieldsBy( code, 'repeatable', '0' ) >+ }); >+ if ( updateFields ) { >+ var record = TextMARC.TextToRecord( cm.getValue() ); >+ KohaBackend.FillRecord( code, record ); >+ cm.setValue( TextMARC.RecordToText(record) ); >+ } >+ callback( error ); >+ } ); > }, > > displayRecord: function( record ) { > this.cm.setValue( TextMARC.RecordToText(record) ); > this.modified = false; >- var cm = this.cm; > this.setFrameworkCode( > typeof record.frameworkcode !== 'undefined' ? record.frameworkcode : '', >+ false, > function ( error ) { > if ( typeof error !== 'undefined' ) { > humanMsg.displayAlert( _(error), { className: 'humanError' } ); > } >- cm.setOption( 'mode', { >- name: 'marc', >- nonRepeatableTags: KohaBackend.GetTagsBy( this.frameworkcode, 'repeatable', '0' ), >- nonRepeatableSubfields: KohaBackend.GetSubfieldsBy( this.frameworkcode, 'repeatable', '0' ) >- }); > } > ); > }, >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 a20bbe6..82d200f 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc >@@ -1098,6 +1098,7 @@ require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr > $("#loading").show(); > editor.setFrameworkCode( > $(this).data( 'frameworkcode' ), >+ true, > function ( error ) { > if ( typeof error !== 'undefined' ) { > humanMsg.displayAlert( _("Failed to change framework"), { className: 'humanError' } ); >-- >2.1.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 16424
:
78977
|
78978
|
79009
|
79010
|
79011
|
79017
|
79022
|
79294
|
79295
|
79296
|
79297
|
79298
|
79499
|
79500
|
79501
|
79502
| 79503 |
79504
|
79621