Initial dev repository
[kcls-web.git] / opac / extras / mobile / js / opac / edit_hold.js
diff --git a/opac/extras/mobile/js/opac/edit_hold.js b/opac/extras/mobile/js/opac/edit_hold.js
new file mode 100644 (file)
index 0000000..7dca4f8
--- /dev/null
@@ -0,0 +1,14 @@
+var __hasProp=Object.prototype.hasOwnProperty,__bind=function(A,n){return function(){return A.apply(n,arguments)}};
+module("opac.edit_hold",imports("eg.fieldmapper","eg.eg_api","template","plugin","opac.ou_tree"),function(A,n,z){$.fn.title_details=function(){var b,a,h,c,i;i=z.template('<div>Title:                <span class="value"><%= b.title            %></span></div>\n<div>Author:               <span class="value"><%= b.author           %></span></div>\n<div>Publisher:            <span class="value"><%= b.publisher        %></span></div>\n<div>Call Number:          <span class="value"><%= b.callnumber       %></span></div>\n<div>ISBN:                 <span class="value"><%= b.isbn             %></span></div>\n<div>ISSN:                 <span class="value"><%= b.issn             %></span></div>\n<div>UPC:                  <span class="value"><%= b.upc              %></span></div>\n<div>Publisher Number:     <span class="value"><%= b.publisher_number %></span></div>\n<div>Physical Description: <span class="value"><%= b.phy_descr        %></span></div>\n<div>Edition:              <span class="value"><%= b.edition          %></span></div>\n<div>Frequency:            <span class="value"><%= b.frequency        %></span></div>');c=
+{title:{"245":"abchp"},author:{"100":"","110":"","111":"","130":"","700":"","710":"","711":""},publisher:{"260":""},callnumber:{"092":"","099":""},isbn:{"020":""},issn:{"022":""},upc:{"024":""},publisher_number:{"028":""},phy_descr:{"300":""},edition:{"250":""},frequency:{"310":""}};h=function(d){return $.trim(d.text().replace(/\s+/g," "))};a=function(d){var j,o,p,q,e,f,k,m,g,r,w,l,s,x,t,u,v;l=[];$(".marc_tag_row",d).each(function(){return l.push(h($(this)).replace(/^(.....)\. /,"$1").replace(/^(...) \. /,
+"$1"))});for(s in c)if(__hasProp.call(c,s)){j=c[s];d="";j=j;for(t in j)if(__hasProp.call(j,t)){x=j[t];p=l;o=0;for(q=p.length;o<q;o++){u=p[o];if(u.match(RegExp("^"+t))){e=x.split("");f=e.length?e:["."];e=0;for(k=f.length;e<k;e++){m=f[e];m="\\u2021"+m+"(.+?)(?= \\u2021|$)";if(g=u.match(RegExp(m,"g"))){m=[];r=g;g=0;for(w=r.length;g<w;g++){v=r[g];m.push(v.replace(/^../,""))}m=m.join(" ");d=!d?m:""+d+" "+m}}}}if(d.length)break}if(d.length)c[s]=d;else delete c[s]}return c};b=this.parent().data("hold");
+return this.openils("title details","search.biblio.record.html",b.target,function(d){return this.html(i({b:a(d),target_id:b.target,hold_id:b.id||0})).find(".value").each(function(){if(!$(this).text())return $(this).parent().empty()})})};$.fn.holding_details=function(){var b,a,h,c,i,d,j,o,p,q,e;b=this.parent();a=b.data("hold");d=b.data("search_ou");i=b.data("search_depth");h=b.data("ou_tree");c=b.data("ou_types");p=b.data("status_names");e=z.template('<div class="holding" id="<%= holding_id %>">\n\t<span>   <span title="Circulating branch or library" class="value"><%= h.org_name %></span></span>\n\t<span> / <span title="Name of collection" class="value"><%= h.copylocation %></span></span>\n\t<span> / <span title="Call number" class="value"><%= h.callnumber %></span></span>\n\n\t<span title="Copy status" class="copy_status">\n\t\t/ <span class="value"><%= h.Available %></span> available</span>\n\t<span title="Copy status" class="copy_status">\n\t\t/ <span class="value"><%= h.Lost %></span> lost</span>\n\t<span title="Copy status" class="copy_status">\n\t\t/ <span class="value"><%= h.Missing %></span> missing</span>\n\t<span title="Copy status" class="copy_status">\n\t\t/ <span class="value"><%= h.Cleaning %></span> cleaning</span>\n\t<span title="Copy status" class="copy_status">\n\t\t/ <span class="value"><%= h.Mending %></span> mending</span>\n\t<span title="Copy status" class="copy_status">\n\t\t/ <span class="value"><%= h.Reshelving %></span> reshelving</span>\n\t<span title="Copy status" class="copy_status">\n\t\t/ <span class="value"><%= in_process %></span> in process</span>\n\t<span title="Copy status" class="copy_status">\n\t\t/ <span class="value"><%= in_transit %></span> in transit</span>\n\t<span title="Copy status" class="copy_status">\n\t\t/ <span class="value"><%= on_holds_shelf %></span> on holds shelf</span>\n\t<span title="Copy status" class="copy_status">\n\t\t/ <span class="value"><%= on_order %></span> on order</span>\n\t<span title="Copy status" class="copy_status">\n\t\t/ <span class="value"><%= checked_out %></span> checked out</span>\n</div>');
+o=function(f,k){return this.append(e({holding_id:f,h:k,checked_out:k["Checked out"],in_process:k["In process"],in_transit:k["In transit"],on_holds_shelf:k["On holds shelf"],on_order:k["On order"]})).find(".value").each(function(){if(!$(this).text())return $(this).parent().empty()})};q=z.template('<span id="<%= barcode %>"> / Due date <%= duedate %></span>');j=function(f){return this.append(q({barcode:f.barcode,duedate:f.circulations==null?undefined:f.circulations[0].due_date.slice(0,10)}))};this.loading("holding details");
+n.openils("search.biblio.copy_location_counts.summary.retrieve",{id:a.target,org_id:d,depth:i},__bind(function(f){var k,m,g,r,w;if(f instanceof Error)return this.failed("holding details");else this.succeeded();k=0;for(m=f.length;k<m;k++){var l=f[k];g=c[h[l.org_id].ou_type].depth;if(i<=g){l.org_name=h[l.org_id].name;g=l.available;for(r in g)if(__hasProp.call(g,r)){w=g[r];l[p[r].name]=w}g=(""+l.org_id+" "+a.target+" "+l.callnumber).replace(/\s+/g,"_");o.call(this,g,l);l["Checked out"]&&function(s,x){var t;
+return t=$("#"+s).openils("due dates","search.asset.copy.retrieve_by_cn_label",{id:a.target,cn:x.callnumber,org_id:x.org_id},function(u){var v,y,B,C;v=[];y=0;for(B=u.length;y<B;y++){C=u[y];v.push(t.openils("due dates","search.asset.copy.fleshed2.retrieve",C,j))}return v})}(g,l)}}return[]},this));return this};$.fn.hold_details=function(){var b,a,h;a=this.parent().data("hold");b=function(){$.unblockUI({onUnblock:__bind(function(){return this.empty()},this)});return false};h=function(){var c,i,d,j,o,
+p,q;o=this.parent().data("ou_tree");p=this.parent().data("ou_types");j={};i=$("form.place_hold",this).serializeArray();c=0;for(d=i.length;c<d;c++){q=i[c];j[q.name]=q.value}$.extend(a,j,{selection_depth:p[o[Number(j.pickup_lib)].ou_type].depth});a.id?n.openils("circ.hold.update",a,__bind(function(e){if(typeof e!=="object"){this.publish("notice",["Hold updated"]);this.publish("holds_summary",[a.id])}else this.publish("prompt",["Hold update failed",""+e[0].desc]);return b.call(this)},this)):n.openils("circ.title_hold.is_possible",
+a,__bind(function(e){if(typeof e==="undefined"||e===null?undefined:e.success)return n.openils("circ.holds.create",a,__bind(function(f){if(typeof f!=="object"){b.call(this);this.publish("notice",["Hold created"]);return this.publish("holds_summary",[a])}else{b.call(this);return this.publish("prompt",["Hold request failed",""+f[0].desc])}},this));else{b.call(this);return this.publish("prompt",["The hold is not possible","The server doesn't say why.\nIt could be because the library you wanted to pick the item up from\nis not part of the same system the item is from.\nIt could also be a number of other reasons."])}},
+this));return false};this.append('<form class="place_hold">\n\t<div>\n\t\t<label>Hold a copy of this title at</label>\n\t\t<span class="org_unit_selector" />\n\t</div> <div>\n\t\t<button type="submit">Place Hold</button>\n\t\t<button type="reset">Cancel</button>\n\t</div>\n</form>').delegate("[type=submit]","click",__bind(function(){return h.call(this)},this)).delegate("[type=reset]","click",__bind(function(){return b.call(this)},this)).delegate("form","keypress",__bind(function(c){if((c=c.keyCode)===
+13)h.call(this);else c===27&&b.call(this);return false},this));$(".org_unit_selector",this).ou_tree({name:"pickup_lib",all:false,selected:Number(a.pickup_lib),indent:". ",focus:true});return this};return $.fn.edit_hold=function(){var b;b=function(a,h,c){this.data("hold",a).html('<div class="title_details" />\n<hr />\n<div class="hold_details" />\n<hr />\n<div>Copies available for this title</div>\n<div class="holding_details" />');parallel({ouTypes:n.openils("actor.org_types.retrieve"),ouTree:n.openils("actor.org_tree.retrieve"),
+copy_status_map:n.openils("search.config.copy_status.retrieve.all")}).next(__bind(function(i){$.blockUI({message:this});this.data("hold",a).data("search_ou",h).data("search_depth",c).data("ou_tree",i.ouTree).data("ou_types",i.ouTypes).data("status_names",i.copy_status_map);$(".title_details",this).title_details();$(".holding_details",this).holding_details();$(".hold_details",this).hold_details();return null},this));return false};if(this.plugin())return this.empty().hide();return this.plugin("edit_hold").empty().hide().subscribe("hold_create",
+__bind(function(a,h,c){a={target:a,titleid:a,hold_type:"T",pickup_lib:Number(n.auth.session.user.home_ou)};b.call(this,a,h,c);return false},this)).subscribe("hold_update",__bind(function(a){b.call(this,a);return false},this))}});