|
Lines 23-32
define( [ '/cgi-bin/koha/svc/cataloguing/framework?frameworkcode=&callback=defin
Link Here
|
| 23 |
var _framework_mappings = {}; |
23 |
var _framework_mappings = {}; |
| 24 |
var _framework_kohafields = {}; |
24 |
var _framework_kohafields = {}; |
| 25 |
|
25 |
|
|
|
26 |
async function _readStream(stream){ |
| 27 |
let xml_response = new Response(stream); |
| 28 |
let the_xml = await xml_response.text(); |
| 29 |
return the_xml; |
| 30 |
} |
| 31 |
|
| 26 |
function _fromXMLStruct( data ) { |
32 |
function _fromXMLStruct( data ) { |
| 27 |
result = {}; |
33 |
result = {}; |
| 28 |
|
34 |
|
| 29 |
$(data).children().eq(0).children().each( function() { |
35 |
$(data).children().each( function() { |
| 30 |
var $contents = $(this).contents(); |
36 |
var $contents = $(this).contents(); |
| 31 |
if ( $contents.length == 1 && $contents[0].nodeType == Node.TEXT_NODE ) { |
37 |
if ( $contents.length == 1 && $contents[0].nodeType == Node.TEXT_NODE ) { |
| 32 |
result[ this.localName ] = $contents[0].data; |
38 |
result[ this.localName ] = $contents[0].data; |
|
Lines 137-150
define( [ '/cgi-bin/koha/svc/cataloguing/framework?frameworkcode=&callback=defin
Link Here
|
| 137 |
_removeBiblionumberFields( record ); |
143 |
_removeBiblionumberFields( record ); |
| 138 |
|
144 |
|
| 139 |
const client = APIClient.cataloguing; |
145 |
const client = APIClient.cataloguing; |
| 140 |
client.catalog_bib.create({ frameworkcode, record }).then( |
146 |
client.catalog_bib.create({ frameworkcode: frameworkcode, record: record }).then( |
| 141 |
success => { |
147 |
success => { |
| 142 |
var record = _fromXMLStruct( success ); |
148 |
_readStream( success.body ).then( |
| 143 |
if ( record.marcxml ) { |
149 |
success=> { |
| 144 |
record.marcxml[0].frameworkcode = frameworkcode; |
150 |
var xml_response = success; |
|
|
151 |
var record =_fromXMLStruct( xml_response ); |
| 152 |
if ( record.marcxml ) { |
| 153 |
record.marcxml[0].frameworkcode = frameworkcode; |
| 154 |
} |
| 155 |
callback( record ); |
| 156 |
}, |
| 157 |
error => { |
| 158 |
callback( { error: _('Could not parse response') } ); |
| 145 |
} |
159 |
} |
| 146 |
callback( record ); |
160 |
);}, |
| 147 |
}, |
|
|
| 148 |
error => { |
161 |
error => { |
| 149 |
callback( { error: _('Could not save record') } ); |
162 |
callback( { error: _('Could not save record') } ); |
| 150 |
} |
163 |
} |
|
Lines 156-175
define( [ '/cgi-bin/koha/svc/cataloguing/framework?frameworkcode=&callback=defin
Link Here
|
| 156 |
record = record.clone(); |
169 |
record = record.clone(); |
| 157 |
_removeBiblionumberFields( record ); |
170 |
_removeBiblionumberFields( record ); |
| 158 |
|
171 |
|
| 159 |
$.ajax( { |
172 |
const client = APIClient.cataloguing; |
| 160 |
type: 'POST', |
173 |
client.catalog_bib.update({ frameworkcode: frameworkcode, record: record, id: id }).then( |
| 161 |
url: '/cgi-bin/koha/svc/bib/' + id + '?frameworkcode=' + encodeURIComponent(frameworkcode), |
174 |
success => { |
| 162 |
data: record.toXML(), |
175 |
_readStream( success.body ).then( |
| 163 |
contentType: 'text/xml' |
176 |
success=> { |
| 164 |
} ).done( function( data ) { |
177 |
var xml_response = success; |
| 165 |
var record = _fromXMLStruct( data ); |
178 |
var record =_fromXMLStruct( xml_response ); |
| 166 |
if ( record.marcxml ) { |
179 |
if ( record.marcxml ) { |
| 167 |
record.marcxml[0].frameworkcode = frameworkcode; |
180 |
record.marcxml[0].frameworkcode = frameworkcode; |
|
|
181 |
} |
| 182 |
callback( record ); |
| 183 |
}, |
| 184 |
error => { |
| 185 |
callback( { error: _('Could not parse response') } ); |
| 186 |
} |
| 187 |
);}, |
| 188 |
error => { |
| 189 |
callback( { error: _('Could not save record') } ); |
| 168 |
} |
190 |
} |
| 169 |
callback( record ); |
191 |
); |
| 170 |
} ).fail( function( data ) { |
|
|
| 171 |
callback( { error: _('Could not save record') } ); |
| 172 |
} ); |
| 173 |
}, |
192 |
}, |
| 174 |
|
193 |
|
| 175 |
GetTagsBy: function( frameworkcode, field, value ) { |
194 |
GetTagsBy: function( frameworkcode, field, value ) { |