From: phasefx Date: Tue, 22 Sep 2009 22:40:01 +0000 (+0000) Subject: This completes the morphing of the Hold Notifications interface into a dual Notes... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=e64aa382a491d33e7084f878ff93a73f4343c72f;p=contrib%2FConifer.git This completes the morphing of the Hold Notifications interface into a dual Notes/Notifications interface, and embeds it into the Holds list with a Detail View/List View toggle. git-svn-id: svn://svn.open-ils.org/ILS/trunk@14106 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/web/opac/locale/en-US/lang.dtd b/Open-ILS/web/opac/locale/en-US/lang.dtd index d05473735e..2e03a8c3ea 100644 --- a/Open-ILS/web/opac/locale/en-US/lang.dtd +++ b/Open-ILS/web/opac/locale/en-US/lang.dtd @@ -2009,8 +2009,6 @@ - - @@ -2516,9 +2514,13 @@ - - + + + + + + diff --git a/Open-ILS/xul/staff_client/server/locale/en-US/circ.properties b/Open-ILS/xul/staff_client/server/locale/en-US/circ.properties index efcdaa22cf..88a91e13fc 100644 --- a/Open-ILS/xul/staff_client/server/locale/en-US/circ.properties +++ b/Open-ILS/xul/staff_client/server/locale/en-US/circ.properties @@ -371,3 +371,7 @@ staff.circ.holds.unexpected_error.not_likely_modified=Holds not likely modified. staff.circ.holds.unexpected_error.not_likely_activated=Holds not likely activated. staff.circ.holds.unexpected_error.not_likely_suspended=Holds not likely suspended. staff.circ.holds.error.may_not_edit_pickup_lib_for_hold_intransit=You may not edit the pickup library for holds that are in-transit or ready for pickup. +staff.circ.holds.alt_view.label=Detail View +staff.circ.holds.alt_view.accesskey=V +staff.circ.holds.list_view.label=List View +staff.circ.holds.list_view.accesskey=V diff --git a/Open-ILS/xul/staff_client/server/locale/en-US/patron.properties b/Open-ILS/xul/staff_client/server/locale/en-US/patron.properties index 542ab207bc..0956b8601f 100644 --- a/Open-ILS/xul/staff_client/server/locale/en-US/patron.properties +++ b/Open-ILS/xul/staff_client/server/locale/en-US/patron.properties @@ -87,6 +87,25 @@ staff.patron.hold_notices.cancel_accesskey=C staff.patron.hold_notices.add_notif_record=Add Notification Record staff.patron.hold_notices.add_notif_record_accesskey=A staff.patron.hold_notices.new_notification.not_created=The notification was not likely created. + +staff.patron.hold_notes.tooltiptext=ID: %1$s Hold ID: %2$s Staff ID: %3$s +staff.patron.hold_notes.new_note=New Note +staff.patron.hold_notes.title=Title +staff.patron.hold_notes.body=Note +staff.patron.hold_notes.public=Public +staff.patron.hold_notes.private=Private +staff.patron.hold_notes.print_on_slip=Print on Slip +staff.patron.hold_notes.no_print_on_slip=No print on Slip +staff.patron.hold_notes.by_staff=By Staff +staff.patron.hold_notes.by_patron=By Patron +staff.patron.hold_notes.new_note.public=Public? +staff.patron.hold_notes.new_note.slip=Print on slip? +staff.patron.hold_notes.cancel=Cancel +staff.patron.hold_notes.cancel_accesskey=C +staff.patron.hold_notes.add_note=Add Note +staff.patron.hold_notes.add_note.accesskey=A +staff.patron.hold_notes.new_note.not_created=The note was not likely created. + staff.patron.holds.init.hold_num_error=Error retrieving details for hold #%1$s staff.patron.holds.show_notifications.error_rendering_notifs=Error rendering or retrieving hold notifications. staff.patron.holds.holds_edit_selection_depth.choose_hold_range=Please choose a Hold Range: diff --git a/Open-ILS/xul/staff_client/server/patron/hold_details.js b/Open-ILS/xul/staff_client/server/patron/hold_details.js index b5eab04a55..2620cb4821 100644 --- a/Open-ILS/xul/staff_client/server/patron/hold_details.js +++ b/Open-ILS/xul/staff_client/server/patron/hold_details.js @@ -1,4 +1,3 @@ - function $(id) { return document.getElementById(id); } function my_init() { @@ -8,7 +7,6 @@ function my_init() { JSAN.errorLevel = "die"; // none, warn, or die JSAN.addRepository('/xul/server/'); - dojo.require('openils.PermaCrud'); JSAN.use('util.error'); g.error = new util.error(); JSAN.use('util.network'); g.network = new util.network(); @@ -17,107 +15,135 @@ function my_init() { g.error.sdump('D_TRACE','my_init() for hold_notices.xul'); - g.ahr_id = xul_param('ahr_id'); + g.pcrud = new openils.PermaCrud({authtoken :ses()}); - g.ahr = g.network.simple_request('FM_AHR_RETRIEVE',[ ses(), g.ahr_id ]); - if (typeof g.ahr.ilsevent != 'undefined') { throw(g.ahr); } - g.ahr = g.ahr[0]; + init_list(); + + if (xulG.ahr_id) fetch_and_render_all(); - render_patron(); + } catch(E) { + try { g.error.standard_unexpected_error_alert('/xul/server/patron/hold_notices.xul',E); } catch(E) { alert('FIXME: ' + js2JSON(E)); } + } +} + +function fetch_and_render_all() { + try { + if (!xulG.ahr_id) { alert('boo'); return; } + + fetch_hold(); + + if (xulG.patron_rendered_elsewhere) { + // Hide patron line + } else { + render_patron(); + } a_list_of_one(); var x = document.getElementById('bib_brief_box'); while (x.firstChild) x.removeChild(x.lastChild); var bib_brief = document.createElement('iframe'); x.appendChild(bib_brief); bib_brief.setAttribute('flex',1); - bib_brief.setAttribute('src',urls.XUL_BIB_BRIEF); + bib_brief.setAttribute('src',urls.XUL_BIB_BRIEF); get_contentWindow(bib_brief).xulG = { 'docid' : g.ahr.target() }; - refresh(); + retrieve_notes(); render_notes(); + + retrieve_notifications(); render_notifications(); } catch(E) { - try { g.error.standard_unexpected_error_alert('/xul/server/patron/hold_notices.xul',E); } catch(E) { alert('FIXME: ' + js2JSON(E)); } + alert('Error in hold_details.js, fetch_and_render_all(): ' + E); + } +} + +function fetch_hold(id) { + try { + g.ahr_id = xulG.ahr_id; + g.ahr = g.network.simple_request('FM_AHR_RETRIEVE',[ ses(), g.ahr_id ]); + if (typeof g.ahr.ilsevent != 'undefined') { throw(g.ahr); } + g.ahr = g.ahr[0]; + } catch(E) { + alert('Error in hold_details.js, fetch_hold(): ' + E); } } function render_patron() { if (g.ahr.usr()) { - JSAN.use('patron.util'); + JSAN.use('patron.util'); var au_obj = patron.util.retrieve_fleshed_au_via_id( ses(), g.ahr.usr() ); - - $('patron_name').setAttribute('value', - ( au_obj.prefix() ? au_obj.prefix() + ' ' : '') + - au_obj.family_name() + ', ' + - au_obj.first_given_name() + ' ' + - ( au_obj.second_given_name() ? au_obj.second_given_name() + ' ' : '' ) + - ( au_obj.suffix() ? au_obj.suffix() : '') - + ' : ' + au_obj.card().barcode() - ); + + $('patron_name').setAttribute('value', + ( au_obj.prefix() ? au_obj.prefix() + ' ' : '') + + au_obj.family_name() + ', ' + + au_obj.first_given_name() + ' ' + + ( au_obj.second_given_name() ? au_obj.second_given_name() + ' ' : '' ) + + ( au_obj.suffix() ? au_obj.suffix() : '') + + ' : ' + au_obj.card().barcode() + ); } } -function a_list_of_one() { +function init_list() { JSAN.use('circ.util'); - var columns = circ.util.hold_columns( - { - 'status' : { 'hidden' : true }, - 'request_time' : { 'hidden' : false }, - 'pickup_lib_shortname' : { 'hidden' : false }, - 'current_copy' : { 'hidden' : false }, - 'phone_notify' : { 'hidden' : false }, - 'email_notify' : { 'hidden' : false }, - } - ); + var columns = circ.util.hold_columns( + { + 'status' : { 'hidden' : true }, + 'request_time' : { 'hidden' : false }, + 'pickup_lib_shortname' : { 'hidden' : false }, + 'current_copy' : { 'hidden' : false }, + 'phone_notify' : { 'hidden' : false }, + 'email_notify' : { 'hidden' : false }, + } + ); JSAN.use('util.list'); g.list = new util.list('holds_list'); g.list.init( - { - 'columns' : columns, - 'map_row_to_columns' : circ.util.std_map_row_to_columns(), - 'retrieve_row' : function(params) { - var row = params.row; - try { - switch(row.my.ahr.hold_type()) { - case 'M' : - row.my.mvr = g.network.request( - api.MODS_SLIM_METARECORD_RETRIEVE.app, - api.MODS_SLIM_METARECORD_RETRIEVE.method, - [ row.my.ahr.target() ] - ); - break; - default: - row.my.mvr = g.network.simple_request( - 'MODS_SLIM_RECORD_RETRIEVE.authoritative', - [ row.my.ahr.target() ] - ); - if (row.my.ahr.current_copy()) { - row.my.acp = g.network.simple_request( 'FM_ACP_RETRIEVE', [ row.my.ahr.current_copy() ]); - } - break; + { + 'columns' : columns, + 'map_row_to_columns' : circ.util.std_map_row_to_columns(), + 'retrieve_row' : function(params) { + var row = params.row; + try { + switch(row.my.ahr.hold_type()) { + case 'M' : + row.my.mvr = g.network.request( + api.MODS_SLIM_METARECORD_RETRIEVE.app, + api.MODS_SLIM_METARECORD_RETRIEVE.method, + [ row.my.ahr.target() ] + ); + break; + default: + row.my.mvr = g.network.simple_request( + 'MODS_SLIM_RECORD_RETRIEVE.authoritative', + [ row.my.ahr.target() ] + ); + if (row.my.ahr.current_copy()) { + row.my.acp = g.network.simple_request( 'FM_ACP_RETRIEVE', [ row.my.ahr.current_copy() ]); } - } catch(E) { - g.error.sdump('D_ERROR','retrieve_row: ' + E ); - } - if (typeof params.on_retrieve == 'function') { - params.on_retrieve(row); - } - return row; - }, - } - ); - g.list.append( - { - 'row' : { - 'my' : { - 'ahr' : g.ahr, - } - }, - 'no_auto_select' : true, - } - ); + break; + } + } catch(E) { + g.error.sdump('D_ERROR','retrieve_row: ' + E ); + } + if (typeof params.on_retrieve == 'function') { + params.on_retrieve(row); + } + return row; + }, + } + ); } -function refresh() { - retrieve_notifications(); render_notifications(); retrieve_notes(); render_notes(); +function a_list_of_one() { + g.list.clear(); + g.list.append( + { + 'row' : { + 'my' : { + 'ahr' : g.ahr, + } + }, + 'no_auto_select' : true, + } + ); } function retrieve_notifications() { @@ -125,30 +151,21 @@ function retrieve_notifications() { } function retrieve_notes() { - try{ - g.ahr_id = xul_param('ahr_id'); - - g.notes = new openils.PermaCrud( - { - authtoken :ses() - } - ).search('ahrn', {hold:g.ahr_id}); - } - catch(E){alert(E);} - + g.notes = g.pcrud.search('ahrn',{'hold':g.ahr_id}); + g.notes = g.notes.reverse(); } function apply(node,field,value) { util.widgets.apply( - node,'name',field, - function(n) { - switch(n.nodeName) { - case 'description' : n.appendChild( document.createTextNode( value ) ); break; - case 'label' : n.value = value; break; - default : n.value = value; break; - } - } - ); + node,'name',field, + function(n) { + switch(n.nodeName) { + case 'description' : n.appendChild( document.createTextNode( value ) ); break; + case 'label' : n.value = value; break; + default : n.value = value; break; + } + } + ); } function render_notifications() { @@ -160,13 +177,13 @@ function render_notifications() { /* template */ var node = $('notification_template').cloneNode(true); np.appendChild(node); node.hidden = false; util.widgets.apply(node,'name','notify_time', - function(n){ - n.setAttribute( - "tooltiptext", - $("patronStrings").getFormattedString('staff.patron.hold_notices.tooltiptext',[g.notifications[i].id(), g.notifications[i].hold(), g.notifications[i].notify_staff()]) - ); - } - ); + function(n){ + n.setAttribute( + "tooltiptext", + $("patronStrings").getFormattedString('staff.patron.hold_notices.tooltiptext',[g.notifications[i].id(), g.notifications[i].hold(), g.notifications[i].notify_staff()]) + ); + } + ); apply(node,'method',g.notifications[i].method() ? g.notifications[i].method() : ''); apply(node,'note',g.notifications[i].note() ? g.notifications[i].note() : ''); apply(node,'notify_time',g.notifications[i].notify_time() ? g.notifications[i].notify_time().toString().substr(0,10) : ''); @@ -175,26 +192,32 @@ function render_notifications() { } function render_notes() { - JSAN.use('util.widgets'); util.widgets.remove_children('notes_panel'); - var notep = $('notes_panel'); + var np = $('notes_panel'); for (var i = 0; i < g.notes.length; i++) { - // template - var notenode = $('note_template').cloneNode(true); notep.appendChild(notenode); notenode.hidden = false; - - /* alert('notenode = ' - + notenode + ' title = ' + g.notes[i].title() + ' note = ' + - g.notes[i].body() + ' pub = ' + g.notes[i].pub() + ' slip = ' + - g.notes[i].slip() );*/ - - apply(notenode,'title',g.notes[i].title() ? g.notes[i].title() : ''); - apply(notenode,'note',g.notes[i].body() ? g.notes[i].body() : ''); - apply(notenode,'pub',g.notes[i].pub() ? g.notes[i].pub() : ''); - apply(notenode,'slip',g.notes[i].slip() ? g.notes[i].slip() : ''); + /* template */ + var node = $('note_template').cloneNode(true); np.appendChild(node); node.hidden = false; + util.widgets.apply(node,'name','create_date', + function(n){ + n.setAttribute( + "tooltiptext", + $("patronStrings").getFormattedString('staff.patron.hold_notes.tooltiptext',[g.notes[i].id(), g.notes[i].hold(), g.notes[i].staff()]) + ); + } + ); + apply(node,'title',g.notes[i].title() ? g.notes[i].title() : ''); + apply(node,'note',g.notes[i].body() ? g.notes[i].body() : ''); + //apply(node,'create_date',g.notes[i].create_date() ? g.notes[i].create_date().toString().substr(0,10) : ''); // FIXME -- need to rework date display more intelligently + apply(node,'pub',get_bool( g.notes[i].pub() ) ? $("patronStrings").getString('staff.patron.hold_notes.public') : $("patronStrings").getString('staff.patron.hold_notes.private') ) + apply(node,'slip',get_bool( g.notes[i].slip() ) ? $("patronStrings").getString('staff.patron.hold_notes.print_on_slip') : $("patronStrings").getString('staff.patron.hold_notes.no_print_on_slip') ) + apply(node,'staff',get_bool( g.notes[i].staff() ) ? $("patronStrings").getString('staff.patron.hold_notes.by_staff') : $("patronStrings").getString('staff.patron.hold_notes.by_patron') ) } + } + + function new_notification() { try { netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect UniversalBrowserWrite"); @@ -208,10 +231,10 @@ function new_notification() { xml += 'accesskey="' + $("patronStrings").getString('staff.patron.hold_notices.add_notif_record_accesskey') + '" name="fancy_submit"/>'; JSAN.use('util.window'); var win = new util.window(); var fancy_prompt_data = win.open( - urls.XUL_FANCY_PROMPT, - 'fancy_prompt', 'chrome,resizable,modal,width=700,height=500', - { 'xml' : xml, 'focus' : 'method', 'title' : $("patronStrings").getString('staff.patron.hold_notices.add_notif_record') } - ); + urls.XUL_FANCY_PROMPT, + 'fancy_prompt', 'chrome,resizable,modal,width=700,height=500', + { 'xml' : xml, 'focus' : 'method', 'title' : $("patronStrings").getString('staff.patron.hold_notices.add_notif_record') } + ); if (fancy_prompt_data.fancy_status == 'complete') { var notification = new ahn(); notification.isnew(1); @@ -219,39 +242,50 @@ function new_notification() { notification.method( fancy_prompt_data.method ); notification.note( fancy_prompt_data.note ); var r = g.network.simple_request('FM_AHN_CREATE',[ ses(), notification ]); if (typeof r.ilsevent != 'undefined') throw(r); - setTimeout(function(){refresh();},0); + setTimeout(function(){fetch_and_render_all();},0); } } catch(E) { g.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.hold_notices.new_notification.not_created'),E); - setTimeout(function(){refresh();},0); + setTimeout(function(){fetch_and_render_all();},0); } } function new_note() { - try{ - var newNote = new fieldmapper.ahrn(); - newNote.isnew("t"); - newNote.body(document.getElementById('hold_note_text').value); - newNote.hold(g.ahr_id); - newNote.title(document.getElementById('hold_note_title').value); - - if($('pub_bool').checked){ - newNote.pub("t"); - }else { - newNote.pub("f"); - } - if($('print_bool').checked){ - newNote.slip("t"); - }else{ - newNote.slip("f"); - } - newNote.staff("t"); - - new openils.PermaCrud({authtoken :ses()}).create(newNote); - - } - catch(E) { - alert('new_note FAILED'); - } - refresh(); -} \ No newline at end of file + try { + netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect UniversalBrowserWrite"); + var xml = ''; + xml += ''; + xml += ''; + xml += ''; + xml += ''; + xml += ''; + xml += '