← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6890: (patient) Add Rename and Delete function for favorite.

 

------------------------------------------------------------
revno: 6890
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-05-09 16:50:16 +0700
message:
  (patient) Add Rename and Delete function for favorite.
modified:
  dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties	2012-05-09 08:30:28 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties	2012-05-09 09:50:16 +0000
@@ -335,4 +335,8 @@
 manage_favorites = Manage favorites
 update = Update
 et_no_programs = Please select an program.
-last_updated = Last updated
\ No newline at end of file
+last_updated = Last updated
+rename_favorite=Rename favorite
+delete_object=Delete
+delete_favorite=Delete favorite
+are_you_sure=Are you sure?
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js	2012-05-09 08:30:28 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js	2012-05-09 09:50:16 +0000
@@ -111,7 +111,9 @@
         east_gridcolumn_height: 30,
         form_label_width: 90,
 		grid_favorite_width: 420,
-		grid_favorite_height: 250
+		grid_favorite_height: 250,
+        window_favorite_ypos: 100,
+        window_confirm_width: 250,
     }
 };
 
@@ -456,9 +458,30 @@
                 update: function(fn) {
                     TR.util.crud.favorite.create(fn, true);
                 },
+				updateName: function(name) {
+                    if (TR.store.favorite.findExact('name', name) != -1) {
+                        return;
+                    }
+                    TR.util.mask.showMask(TR.cmp.favorite.window, TR.i18n.renaming + '...');
+                    var r = TR.cmp.favorite.grid.getSelectionModel().getSelection()[0];
+                    Ext.Ajax.request({
+                        url: TR.conf.finals.ajax.path_root + TR.conf.finals.ajax.favorite_rename,
+                        method: 'POST',
+                        params: {id: r.data.id, name: name},
+                        success: function() {
+                            TR.store.favorite.load({callback: function() {
+                                TR.cmp.favorite.rename.window.close();
+                                TR.util.mask.hideMask();
+                                TR.cmp.favorite.grid.getSelectionModel().select(TR.store.favorite.getAt(TR.store.favorite.findExact('name', name)));
+                                TR.cmp.favorite.name.setValue(name);
+                            }});
+                        }
+                    });
+                },
                 del: function(fn) {
                     TR.util.mask.showMask(TR.cmp.favorite.window, TR.i18n.deleting + '...');
-                    var baseurl = TR.conf.finals.ajax.path_root + TR.conf.finals.ajax.favorite_delete,
+					var id = TR.cmp.favorite.grid.getSelectionModel().getSelection()[0].data.id;
+                    var baseurl = TR.conf.finals.ajax.path_root + TR.conf.finals.ajax.favorite_delete + "?id=" + id,
                         selection = TR.cmp.favorite.grid.getSelectionModel().getSelection();
                     Ext.Array.each(selection, function(item) {
                         baseurl = Ext.String.urlAppend(baseurl, 'uids=' + item.data.id);
@@ -579,6 +602,7 @@
 								}
 							}
 							
+							TR.cmp.params.organisationunit.treepanel.getSelectionModel().deselectAll();
 							TR.exe.execute();
 						}
 					});
@@ -938,7 +962,7 @@
 					return false;
 				}
 				
-				if (!TR.cmp.params.organisationunit.treepanel.getSelectionModel().getSelection().length) {
+				if (TR.state.orgunitId == '') {
 					TR.util.notification.error(TR.i18n.et_no_orgunits, TR.i18n.em_no_orgunits);
 					return false;
 				}
@@ -2375,6 +2399,7 @@
 														title: TR.i18n.manage_favorites,
 														iconCls: 'tr-window-title-favorite',
 														bodyStyle: 'padding:8px; background-color:#fff',
+														region: 'center',
 														width: TR.conf.layout.grid_favorite_width,
 														height: TR.conf.layout.grid_favorite_height,
 														closeAction: 'hide',