From b58c083345f16ff3b36a8fcd1c6e199040b6d257 Mon Sep 17 00:00:00 2001 From: senator Date: Wed, 24 Feb 2010 19:36:17 +0000 Subject: [PATCH] Acq: separate LI note creation from LI alert creation; improve notes iface Since adding LI notes or alerts takes place immediately, so does deleting them now, so there's no more need for a Save Changes button on that interface. git-svn-id: svn://svn.open-ils.org/ILS/trunk@15636 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../perlmods/OpenILS/Application/Acq/Lineitem.pm | 8 +++- Open-ILS/web/css/skin/default/acq.css | 4 +- Open-ILS/web/js/dojo/openils/acq/nls/acq.js | 3 +- Open-ILS/web/js/ui/default/acq/common/li_table.js | 54 ++++++++++++++++------ .../web/templates/default/acq/common/li_table.tt2 | 26 +++++++---- 5 files changed, 68 insertions(+), 27 deletions(-) diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Acq/Lineitem.pm b/Open-ILS/src/perlmods/OpenILS/Application/Acq/Lineitem.pm index f0256195e..acb9d65cc 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Acq/Lineitem.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Acq/Lineitem.pm @@ -786,7 +786,7 @@ sub lineitem_note_CUD_batch { if($note->isnew) { $note->creator($e->requestor->id); - $e->create_acq_lineitem_note($note) or return $e->die_event; + $note = $e->create_acq_lineitem_note($note) or return $e->die_event; } elsif($note->isdeleted) { $e->delete_acq_lineitem_note($note) or return $e->die_event; @@ -796,7 +796,11 @@ sub lineitem_note_CUD_batch { } if(!$note->isdeleted) { - $note = $e->retrieve_acq_lineitem_note($note->id); + $note = $e->retrieve_acq_lineitem_note([ + $note->id, { + "flesh" => 1, "flesh_fields" => {"acqlin" => ["alert_text"]} + } + ]); } $conn->respond({maximum => $total, progress => ++$count, note => $note}); diff --git a/Open-ILS/web/css/skin/default/acq.css b/Open-ILS/web/css/skin/default/acq.css index 3cea4fb57..00a61597d 100644 --- a/Open-ILS/web/css/skin/default/acq.css +++ b/Open-ILS/web/css/skin/default/acq.css @@ -140,7 +140,9 @@ label[for="attr_search_type_scalar"] { vertical-align: top; } .acq-lit-note-textarea { border-right: 2px solid #aaa; width:50%;} .acq-lit-note-textarea div { padding: 4px; font-weight: bold; } #acq-lit-notes-tbody td {padding: 20px 10px 20px 10px; border-bottom:2px solid #aaa;} -.acq-lit-note-create-row { margin: 6px 0; } +#acq-lit-alert-value { height: 5em; width: 20em; } +.acq-lit-note-row { margin: 6px 0; } +span[name="alert_code"] {color: #c00;padding-right: 1em;font-weight: bold;} .acq-lit-li-menu-bar {width:99%; text-align:left; border:1px solid #aaa; margin:5px 0px 10px 0px;} .acq-lit-li-menu-left {text-align:left; width:300px;} diff --git a/Open-ILS/web/js/dojo/openils/acq/nls/acq.js b/Open-ILS/web/js/dojo/openils/acq/nls/acq.js index ff1a45712..ed859228d 100644 --- a/Open-ILS/web/js/dojo/openils/acq/nls/acq.js +++ b/Open-ILS/web/js/dojo/openils/acq/nls/acq.js @@ -21,5 +21,6 @@ 'UNRECEIVE_LI': "Are you sure you want to mark this lineitem as UN-received?", 'UNRECEIVE_LID': "Are you sure you want to mark this copy as UN-received?", - 'CONFIRM_LI_ALERT': "An alert has been placed on the lineitem titled,\n\"${0}\":\n\n${1}\n\n${2}\n\nChoose OK if you wish to acknowledge this alert." + 'CONFIRM_LI_ALERT': "An alert has been placed on the lineitem titled,\n\"${0}\":\n\n${1}\n${2}\n${3}\nChoose OK if you wish to acknowledge this alert.", + 'ALERT_UNSELECTED': "You must choose an alert code." } diff --git a/Open-ILS/web/js/ui/default/acq/common/li_table.js b/Open-ILS/web/js/ui/default/acq/common/li_table.js index 6f0416abb..c4bbf289b 100644 --- a/Open-ILS/web/js/ui/default/acq/common/li_table.js +++ b/Open-ILS/web/js/ui/default/acq/common/li_table.js @@ -196,9 +196,10 @@ function AcqLiTable() { dojo.query('[attr=title]', row)[0].onclick = function() {self.drawInfo(li.id())}; dojo.query('[name=copieslink]', row)[0].onclick = function() {self.drawCopies(li.id())}; - dojo.query('[name=notes_count]', row)[0].innerHTML = li.lineitem_notes().length; dojo.query('[name=noteslink]', row)[0].onclick = function() {self.drawLiNotes(li)}; + this.updateLiNotesCount(li, row); + // show which PO this lineitem is a member of if(li.purchase_order() && !this.isPO) { var po = @@ -263,6 +264,12 @@ function AcqLiTable() { } }; + this.updateLiNotesCount = function(li, row) { + if (typeof(row) == "undefined") + row = dojo.query('tr[li="' + li.id() + '"]', "acq-lit-tbody")[0]; + nodeByName("notes_count", row).innerHTML = li.lineitem_notes().length; + }; + this.updateLiReceivedness = function(li, row) { if (typeof(row) == "undefined") row = dojo.query('tr[li="' + li.id() + '"]', "acq-lit-tbody")[0]; @@ -312,7 +319,7 @@ function AcqLiTable() { this._setAlertStore = function() { - acqLitNoteAlertSelector.store = new dojo.data.ItemFileReadStore( + acqLitAlertAlertText.store = new dojo.data.ItemFileReadStore( { "data": acqliat.toStoreData( (new openils.PermaCrud()).search( @@ -321,8 +328,8 @@ function AcqLiTable() { ) } ); - acqLitNoteAlertSelector.setValue(); /* make the store "live" */ - acqLitNoteAlertSelector._store_ready = true; + acqLitAlertAlertText.setValue(); /* make the store "live" */ + acqLitAlertAlertText._store_ready = true; }; /** @@ -331,9 +338,8 @@ function AcqLiTable() { this.drawLiNotes = function(li) { var self = this; - if (!acqLitNoteAlertSelector._store_ready) { + if (!acqLitAlertAlertText._store_ready) this._setAlertStore(); - } li.lineitem_notes( li.lineitem_notes().sort( @@ -355,14 +361,28 @@ function AcqLiTable() { note.isnew(true); note.value(value); note.lineitem(li.id()); - if (acqLitNoteAlertSelector.item) - note.alert_text(Number(acqLitNoteAlertSelector.item.id)); self.updateLiNotes(li, note); } - dojo.byId('acq-lit-notes-save-button').onclick = function() { - self.updateLiNotes(li); + acqLitCreateAlertSubmit.onClick = function() { + if (!acqLitAlertAlertText.item) { + alert(localeStrings.ALERT_UNSELECTED); + return; + } + + var alert_text = new fieldmapper.acqliat().fromStoreItem( + acqLitAlertAlertText.item + ); + var value = acqLitAlertNoteValue.attr("value") || ""; + + var note = new fieldmapper.acqlin(); + note.isnew(true); + note.lineitem(li.id()); + note.value(value); + note.alert_text(alert_text); + + self.updateLiNotes(li, note); } dojo.forEach(li.lineitem_notes(), function(note) { self.addLiNote(li, note) }); @@ -375,15 +395,18 @@ function AcqLiTable() { if(note.isdeleted()) return; var self = this; var row = self.liNotesRow.cloneNode(true); - dojo.query('[name=value]', row)[0].innerHTML = note.value(); + nodeByName("value", row).innerHTML = note.value(); + if (note.alert_text()) + nodeByName("alert_code", row).innerHTML = note.alert_text().code(); - dojo.query('[name=delete]', row)[0].onclick = function() { + nodeByName("delete", row).onclick = function() { note.isdeleted(true); self.liNotesTbody.removeChild(row); + self.updateLiNotes(li); }; if(note.edit_time()) { - dojo.query('[name=edit_time]', row)[0].innerHTML = + nodeByName("edit_time", row).innerHTML = dojo.date.locale.format( dojo.date.stamp.fromISOString(note.edit_time()), {formatLength:'short'}); @@ -434,6 +457,7 @@ function AcqLiTable() { } progressDialog.hide(); + self.updateLiNotesCount(li); self.drawLiNotes(li); return; } @@ -1011,7 +1035,9 @@ function AcqLiTable() { (new openils.acq.Lineitem({"lineitem": li})).findAttr( "title", "lineitem_marc_attr_definition" ), - lin.alert_text().description(), lin.value() + lin.alert_text().code(), + lin.alert_text().description() || "", + lin.value() ] ) ); diff --git a/Open-ILS/web/templates/default/acq/common/li_table.tt2 b/Open-ILS/web/templates/default/acq/common/li_table.tt2 index 96bdd4841..ec3caf827 100644 --- a/Open-ILS/web/templates/default/acq/common/li_table.tt2 +++ b/Open-ILS/web/templates/default/acq/common/li_table.tt2 @@ -142,18 +142,26 @@
New Note
-
- -
-
-
- - +
+
-
Save Changes
+
+ New Alert +
+
+ + +
+
+ +
+
+ +
+
@@ -163,7 +171,7 @@
  • - +
    Delete -- 2.11.0