[open-ils-commits] r15636 - in trunk/Open-ILS: src/perlmods/OpenILS/Application/Acq web/css/skin/default web/js/dojo/openils/acq/nls web/js/ui/default/acq/common web/templates/default/acq/common (senator)

svn at svn.open-ils.org svn at svn.open-ils.org
Wed Feb 24 14:36:21 EST 2010


Author: senator
Date: 2010-02-24 14:36:17 -0500 (Wed, 24 Feb 2010)
New Revision: 15636

Modified:
   trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Lineitem.pm
   trunk/Open-ILS/web/css/skin/default/acq.css
   trunk/Open-ILS/web/js/dojo/openils/acq/nls/acq.js
   trunk/Open-ILS/web/js/ui/default/acq/common/li_table.js
   trunk/Open-ILS/web/templates/default/acq/common/li_table.tt2
Log:
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.


Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Lineitem.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Lineitem.pm	2010-02-24 19:30:44 UTC (rev 15635)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Lineitem.pm	2010-02-24 19:36:17 UTC (rev 15636)
@@ -786,7 +786,7 @@
 
         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 @@
         }
 
         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});

Modified: trunk/Open-ILS/web/css/skin/default/acq.css
===================================================================
--- trunk/Open-ILS/web/css/skin/default/acq.css	2010-02-24 19:30:44 UTC (rev 15635)
+++ trunk/Open-ILS/web/css/skin/default/acq.css	2010-02-24 19:36:17 UTC (rev 15636)
@@ -140,7 +140,9 @@
 .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;}

Modified: trunk/Open-ILS/web/js/dojo/openils/acq/nls/acq.js
===================================================================
--- trunk/Open-ILS/web/js/dojo/openils/acq/nls/acq.js	2010-02-24 19:30:44 UTC (rev 15635)
+++ trunk/Open-ILS/web/js/dojo/openils/acq/nls/acq.js	2010-02-24 19:36:17 UTC (rev 15636)
@@ -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."
 }

Modified: trunk/Open-ILS/web/js/ui/default/acq/common/li_table.js
===================================================================
--- trunk/Open-ILS/web/js/ui/default/acq/common/li_table.js	2010-02-24 19:30:44 UTC (rev 15635)
+++ trunk/Open-ILS/web/js/ui/default/acq/common/li_table.js	2010-02-24 19:36:17 UTC (rev 15636)
@@ -196,9 +196,10 @@
 
         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 @@
         }
     };
 
+    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 @@
 
 
     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 @@
                 )
             }
         );
-        acqLitNoteAlertSelector.setValue(); /* make the store "live" */
-        acqLitNoteAlertSelector._store_ready = true;
+        acqLitAlertAlertText.setValue(); /* make the store "live" */
+        acqLitAlertAlertText._store_ready = true;
     };
 
     /**
@@ -331,9 +338,8 @@
     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 @@
             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 @@
         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 @@
                         }
 
                         progressDialog.hide();
+                        self.updateLiNotesCount(li);
                         self.drawLiNotes(li);
                         return;
                     }
@@ -1011,7 +1035,9 @@
                     (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()
                 ]
             )
         );

Modified: trunk/Open-ILS/web/templates/default/acq/common/li_table.tt2
===================================================================
--- trunk/Open-ILS/web/templates/default/acq/common/li_table.tt2	2010-02-24 19:30:44 UTC (rev 15635)
+++ trunk/Open-ILS/web/templates/default/acq/common/li_table.tt2	2010-02-24 19:36:17 UTC (rev 15636)
@@ -142,18 +142,26 @@
                         <div dojoType="dijit.form.DropDownButton">
                             <span>New Note</span>
                             <div dojoType="dijit.TooltipDialog">
-                                <div class="acq-lit-note-create-row">
-                                    <label for="acq-lit-create-note-text">Main body of note</label>
-                                    <div jsId='acqLitCreateNoteText' dojoType='dijit.form.Textarea' style='height:5em; width:20em;' name='note' id="acq-lit-create-note-text"></div>
+                                <div class="acq-lit-note-row">
+                                    <div jsId='acqLitCreateNoteText' dojoType='dijit.form.Textarea' style='height:5em; width:25em;' name='note'></div>
                                 </div>
-                                <div class="acq-lit-note-create-row">
-                                    <label for="acq-lit-note-alert-selector">Optional alert text</label>
-                                    <input id="acq-lit-note-alert-selector" jsId="acqLitNoteAlertSelector" dojoType="dijit.form.FilteringSelect" labelAttr="code" searchAttr="code" required="false" />
-                                </div>
                                 <button jsId='acqLitCreateLiNoteSubmit' dojoType='dijit.form.Button' type="submit">Create</button>
                             </div>
                         </div>
-                        <div dojoType='dijit.form.Button' id='acq-lit-notes-save-button'>Save Changes</div>
+                        <div dojoType="dijit.form.DropDownButton">
+                            <span>New Alert</span>
+                            <div dojoType="dijit.TooltipDialog">
+                                <div class="acq-lit-note-row">
+                                    <label for="acq-lit-alert-alert-text">Choose alert code &nbsp;</label>
+                                    <input id="acq-lit-alert-alert-text" jsId="acqLitAlertAlertText" dojoType="dijit.form.FilteringSelect" labelAttr="code" searchAttr="code" required="true" />
+                                </div>
+                                <div class="acq-lit-note-row">
+                                    <label for="acq-lit-alert-value">Optional description</label>
+                                    <div jsId="acqLitAlertNoteValue" id="acq-lit-alert-value" dojoType="dijit.form.Textarea" name="value"></div>
+                                </div>
+                                <button jsId="acqLitCreateAlertSubmit" dojoType="dijit.form.Button" type="submit">Create</button>
+                            </div>
+                        </div>
                     </td>
                 </tr>
             </table>
@@ -163,7 +171,7 @@
             <li id='acq-lit-notes-row'>
                 <table style='width:100%;' class='oils-generic-table'>
                     <tr>
-                        <td width='70%' align='left'><span style='font-size:120%' name='value'></span></td>
+                        <td width='70%' align='left'><span name="alert_code"></span><span style='font-size:120%' name='value'></span></td>
                         <td align='right' style='padding-right:30px;'>
                             <span name='edit_time'></span>
                             <span style='padding-left:4px;'><a name='delete' href='javascript:void(0);' style='color:red;'>Delete</a></span>



More information about the open-ils-commits mailing list