Skip to content

Commit

Permalink
update col fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pollen8 committed Dec 2, 2013
1 parent 6688248 commit 6e111e9
Show file tree
Hide file tree
Showing 3 changed files with 260 additions and 116 deletions.
2 changes: 1 addition & 1 deletion plugins/fabrik_list/update_col/update_col-min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 34 additions & 24 deletions plugins/fabrik_list/update_col/update_col.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
/**
* List Update Column
*
* @copyright: Copyright (C) 2005-2013, fabrikar.com - All rights reserved.
* @license: GNU/GPL http://www.gnu.org/copyleft/gpl.html
*/

/**
* Simple store for element js objects
* Need to be able to trigger onSave on things like date elements to get correct format
*/
*/
UpdateColSelect = new Class({

initialize: function () {
this.updates = {};
},

/**
* As we are piggybacking on top of the advanced search code addFilter is called when the
* ajax request returns.
Expand All @@ -18,7 +25,7 @@ UpdateColSelect = new Class({
}
this.updates[pluginType].push(filter);
},

/**
* Ensure that date elements set themselves to the correct date format
*/
Expand All @@ -40,15 +47,15 @@ var FbListUpdateCol = new Class({
this.makeUpdateColWindow();
}
},

buttonAction: function () {
if (this.options.userSelect) {
this.win.open();
} else {
this.list.submit('list.doPlugin');
}
},

makeUpdateColWindow: function () {
this.windowopts = {
'id': 'update_col_win_' + this.options.ref,
Expand All @@ -58,9 +65,12 @@ var FbListUpdateCol = new Class({
width: 400,
destroy: false,
height: 300,
onOpen: function () {
this.fitToContent(false);
},
onContentLoaded: function (win) {
var form = document.id('update_col' + this.options.ref);

// Add a row
form.addEvent('click:relay(a.add)', function (e, target) {
e.preventDefault();
Expand All @@ -76,9 +86,9 @@ var FbListUpdateCol = new Class({
} else {
tr.clone().inject(tr, 'after');
}

});

// Delete a row
form.addEvent('click:relay(a.delete)', function (e, target) {
e.preventDefault();
Expand All @@ -89,7 +99,7 @@ var FbListUpdateCol = new Class({
target.getParent('tr').destroy();
}
});

// Select an element plugin and load it
form.addEvent('change:relay(select.key)', function (e, target) {
var opt = target.options[target.selectedIndex];
Expand All @@ -100,44 +110,44 @@ var FbListUpdateCol = new Class({
var plugin = opt.get('data-plugin');
var id = opt.get('data-id');
var counter = 0;

// Piggy backing on the list advanced search code to get an element and its js
var url = "index.php?option=com_fabrik&task=list.elementFilter&format=raw";

// It looks odd - but to get the element js code to load in correct we need to set the context to a visualization
new Request.HTML({'url': url,
'update': update,
new Request.HTML({'url': url,
'update': update,
'data': {
'element': v,
'id': this.options.listid,
'element': v,
'id': this.options.listid,
'elid': id,
'plugin': plugin,
'plugin': plugin,
'counter': counter,
'listref': this.options.ref,
'context': 'visualization',
'listref': this.options.ref,
'context': 'visualization',
'parentView': 'update_col' + this.options.ref,
'fabrikIngoreDefaultFilterVal': 1,
'filterOverride': 'field'
'fabrikIngoreDefaultFilterVal': 1
},
'onComplete': function () {
Fabrik.loader.stop(row);
win.fitToContent(false);
}
}).send();
}.bind(this));

// Submit the update
form.getElement('input[type=button]').addEvent('click', function (e) {
e.stop();
var i;
Fabrik['filter_update_col' + this.options.ref].onSumbit();

var listForm = document.id('listform_' + this.options.ref);

// Grab all the update settings and put them in a hidden field for later extraction within the update_col php code.
i = new Element('input', {'type': 'hidden', 'value': form.toQueryString(), 'name': 'fabrik_update_col'});
i.inject(listForm, 'bottom');
this.list.submit('list.doPlugin');

}.bind(this));
}.bind(this)
};
Expand Down

0 comments on commit 6e111e9

Please sign in to comment.