Skip to content

Commit

Permalink
Improve auto-save active status to remove red flag
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaun McCormick committed Mar 7, 2011
1 parent 1ed847b commit 662f552
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 24 deletions.
2 changes: 1 addition & 1 deletion _build/build.transport.php
Expand Up @@ -14,7 +14,7 @@
/* define package names */
define('PKG_NAME','Redirector');
define('PKG_NAME_LOWER','redirector');
define('PKG_VERSION','1.0.1');
define('PKG_VERSION','1.0.2');
define('PKG_RELEASE','pl');

/* define build paths */
Expand Down
52 changes: 30 additions & 22 deletions assets/components/redirector/js/mgr/widgets/redirects.grid.js
Expand Up @@ -5,28 +5,7 @@ Redi.grid.Redirects = function(config) {
,dataIndex: 'active'
,width: 40
,sortable: true
,onMouseDown: function(e, t){

var rowData = "";
//checks/unchecks
if(t.className && t.className.indexOf('x-grid3-cc-'+this.id) != -1){
e.stopEvent();
var index = this.grid.getView().findRowIndex(t);
var record = this.grid.store.getAt(index);
record.set(this.dataIndex, !record.data[this.dataIndex]);
rowData = record.data;//save row records. will be used in the ajax request
}

//don't send the ajax request if the rowData is empty. rowData is empty if the row is clicked.
if(rowData){
//send ajax request to update the data
Ext.Ajax.request({
url : Redi.config.connector_url,
params : { action : 'mgr/redirect/updateFromGrid', data: Ext.util.JSON.encode(rowData)},
method: 'POST'
});
}
}
,onMouseDown: this.saveCheckbox
});
Ext.applyIf(config,{
id: 'redirector-grid-redirects'
Expand Down Expand Up @@ -84,6 +63,35 @@ Ext.extend(Redi.grid.Redirects,MODx.grid.Grid,{
this.getBottomToolbar().changePage(1);
this.refresh();
}
,saveCheckbox: function(e, t){
var rowData = false;
/* checks/unchecks */
if(t.className && t.className.indexOf('x-grid3-cc-'+this.id) != -1){
e.stopEvent();
var index = this.grid.getView().findRowIndex(t);
var record = this.grid.store.getAt(index);
record.set(this.dataIndex, !record.data[this.dataIndex]);
rowData = record.data; /*save row records. will be used in the ajax request */
}

/*don't send the ajax request if the rowData is empty. rowData is empty if the row is clicked. */
if (!rowData) return;

/* send ajax request to update the data */
MODx.Ajax.request({
url: Redi.config.connector_url
,params: {
action : 'mgr/redirect/updateFromGrid'
,data: Ext.util.JSON.encode(rowData)
}
,method: 'POST'
,listeners: {
'success': {fn: function(r) {
Ext.getCmp('redirector-grid-redirects').getStore().commitChanges();
},scope: this}
}
});
}
,updateRedirect: function(btn,e) {
if (!this.updateRedirectWindow) {
this.updateRedirectWindow = MODx.load({
Expand Down
3 changes: 2 additions & 1 deletion core/components/redirector/docs/changelog.txt
Expand Up @@ -2,7 +2,8 @@ Changelog file for Redirector component.

Redirector 1.0.1
====================================
- Added Dutch translation
- Add improvement to auto-save active checkbox on grid
- Add Dutch translation

Redirector 1.0.0
====================================
Expand Down

0 comments on commit 662f552

Please sign in to comment.