Avoid code duplication.
Signed-off-by: Jason Stephenson <jstephenson@mvlc.org>
Signed-off-by: Dan Scott <dscott@laurentian.ca>
}
try {
- var bibObj = g.network.request(
- api.FM_BRE_RETRIEVE_VIA_ID.app,
- api.FM_BRE_RETRIEVE_VIA_ID.method,
- [ ses(), [docid] ]
- );
-
- bibObj = bibObj[0];
-
- var cbsObj = g.network.request(
- api.FM_CBS_RETRIEVE_VIA_PCRUD.app,
- api.FM_CBS_RETRIEVE_VIA_PCRUD.method,
- [ ses(), bibObj.source() ]
- );
-
+ JSAN.use('cat.util');
+ var cbsObj = cat.util.get_cbs_for_bre_id(docid);
if (cbsObj.can_have_copies() != get_db_true()) {
alert(document.getElementById('offlineStrings').getFormattedString('staff.cat.bib_source.can_have_copies.false', [cbsObj.source()]));
return;
'source_init' : function() {
var obj = this;
try {
- var bibObj = obj.network.request(
- api.FM_BRE_RETRIEVE_VIA_ID.app,
- api.FM_BRE_RETRIEVE_VIA_ID.method,
- [ ses(), [obj.docid] ]
- );
- bibObj = bibObj[0];
- var cbsObj = obj.network.request(
- api.FM_CBS_RETRIEVE_VIA_PCRUD.app,
- api.FM_CBS_RETRIEVE_VIA_PCRUD.method,
- [ ses(), bibObj.source() ]
- );
+ JSAN.use('cat.util');
+ var cbsObj = cat.util.get_cbs_for_bre_id(obj.docid);
obj.can_have_copies = (cbsObj.can_have_copies() == get_db_true());
obj.source = cbsObj.source();
} catch(E) {
'render_loan_duration', 'mark_item_as_missing_pieces', 'render_callnumbers_for_bib_menu',
'render_cn_prefix_menuitems', 'render_cn_suffix_menuitems', 'render_cn_class_menu',
'render_cn_prefix_menu', 'render_cn_suffix_menu', 'transfer_specific_title_holds',
- 'request_items', 'mark_for_overlay'
+ 'request_items', 'mark_for_overlay', 'get_cbs_for_bre_id'
];
cat.util.EXPORT_TAGS = { ':all' : cat.util.EXPORT_OK };
}
}
+cat.util.get_cbs_for_bre_id = function(doc_id) {
+ try {
+ JSAN.use('util.network'); var network = new util.network();
+ var bibObj = network.simple_request(
+ 'FM_BRE_RETRIEVE_VIA_ID',
+ [ ses(), [ doc_id ] ]
+ );
+ bibObj = bibObj[0];
+ var cbsObj = network.simple_request(
+ 'FM_CBS_RETRIEVE_VIA_PCRUD',
+ [ ses(), bibObj.source() ]
+ );
+ return cbsObj;
+ } catch(E) {
+ alert('Error in cat.util.cbs_can_have_copies(): ' + E);
+ }
+}
dump('exiting cat/util.js\n');