to cache or not to cache... don't cache if you just changed data
authorpines <pines@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Sun, 6 May 2007 09:04:29 +0000 (09:04 +0000)
committerpines <pines@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Sun, 6 May 2007 09:04:29 +0000 (09:04 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@7208 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/xul/staff_client/server/patron/info_notes.xul

index 285f218..ccf9c12 100644 (file)
@@ -51,6 +51,8 @@
                                g.cgi = new CGI();
                                g.patron_id = g.cgi.param('patron_id');
 
+                               g.new_note = false;
+
                                refresh();
 
                        } catch(E) {
                }
 
                function retrieve_notes() {
-                       g.notes = g.network.simple_request('FM_AUN_RETRIEVE_ALL',[ ses(), { 'patronid' : g.patron_id } ]).reverse();
+                       if (g.new_note) {
+                               g.notes = g.network.simple_request('FM_AUN_RETRIEVE_ALL',[ ses(), { 'patronid' : g.patron_id } ]).reverse();
+                               g.new_note = false;
+                       } else {
+                               g.notes = g.network.cached_request('FM_AUN_RETRIEVE_ALL',[ ses(), { 'patronid' : g.patron_id } ]).reverse();
+                       }
                }
 
                function apply(node,field,value) {
                                                                var r = g.error.yns_alert('Delete the note titled "' + g.notes[id].title() + '" created on ' + g.notes[id].create_date().toString().substr(0,10) + '?','Delete Note','Yes','No',null,'Check here to confirm this action'); 
                                                                if (r == 0) {
                                                                        g.network.simple_request('FM_AUN_DELETE',[ses(),g.notes[id].id()]);
-                                                                       setTimeout(function(){ alert('Note deleted.'); refresh();},0);
+                                                                       setTimeout(function(){ g.new_note = true; alert('Note deleted.'); refresh();},0);
                                                                }
                                                        } }(i),
                                                        false
                                        note.usr( g.patron_id );
                                        var r = g.network.simple_request('FM_AUN_CREATE',[ ses(), note ]);
                                        if (typeof r.ilsevent != 'undefined') throw(r);
-                                       setTimeout(function(){ alert('Note added.'); refresh();},0);
+                                       setTimeout(function(){ g.new_note = true; alert('Note added.'); refresh();},0);
                                }
                        } catch(E) {
                                g.error.standard_unexpected_error_alert('The note was not likely created.',E);