Skip to content

Commit

Permalink
fixed: issues with autocomplete dbjoin and select in front end not
Browse files Browse the repository at this point in the history
working. Also add record from popup window would possibly display "could
not find row" error message, as the URL to load the form was not correct
(back ported change I had already made in 3.1 into 3.0 for this one)'
  • Loading branch information
pollen8 committed May 21, 2013
1 parent 046fa3d commit 02f09a8
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 17 deletions.
2 changes: 1 addition & 1 deletion media/com_fabrik/js/form-min.js

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions media/com_fabrik/js/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -1182,13 +1182,16 @@ var FbForm = new Class({
return h;
},

watchGroupButtons : function () {
watchGroupButtons: function () {
/*this.form.getElements('.deleteGroup').each(function (g, i) {
g.addEvent('click', function (e) {
this.deleteGroup(e);
}.bind(this));
}.bind(this));*/

if (typeOf(this.form) === 'null') {
fconsole('form: watchgroup buttons - didnt find form');
return;
}
this.form.addEvent('click:relay(.deleteGroup)', function (e, target) {
e.preventDefault();
this.deleteGroup(e);
Expand Down
2 changes: 1 addition & 1 deletion plugins/fabrik_element/databasejoin/databasejoin-min.js

Large diffs are not rendered by default.

21 changes: 11 additions & 10 deletions plugins/fabrik_element/databasejoin/databasejoin.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,10 @@ var FbDatabasejoin = new Class({
if (this.options.popupform === 0 || this.options.allowadd === false) {
return;
}

var url = "index.php?option=com_fabrik&task=form.view&tmpl=component&ajax=1&formid=" + this.options.popupform;
c = this.getContainer();
var a = c.getElement('.toggle-addoption');
var url = typeOf(a) === 'null' ? e.target.get('href') : a.get('href');

if (typeOf(this.element) === 'null') {
return;
}
Expand Down Expand Up @@ -264,18 +266,16 @@ var FbDatabasejoin = new Class({
method: 'post',
'data': data,
onSuccess: function (json) {
var existingValues = this.getOptionValues();
var sel, existingValues = this.getOptionValues();

// If duplicating an element in a repeat group when its auto-complete we dont want to update its value
if (this.options.displayType === 'auto-complete' && v === '' && existingValues.length === 0) {
return;
}
json.each(function (o) {
if (!existingValues.contains(o.value) && typeOf(o.value) !== 'null') {
if (this.activePopUp) {
this.options.value = o.value;
}
this.addOption(o.value, o.text, this.activePopUp);
sel = this.options.value === o.value;
this.addOption(o.value, o.text, sel);
this.element.fireEvent('change', new Event.Mock(this.element, 'change'));
this.element.fireEvent('blur', new Event.Mock(this.element, 'blur'));
}
Expand Down Expand Up @@ -384,7 +384,6 @@ var FbDatabasejoin = new Class({
if (Fabrik.Windows[winid]) {
Fabrik.Windows[winid].close();
}
this.updateFromServer(json.rowid);
}
}.bind(this));

Expand Down Expand Up @@ -665,19 +664,21 @@ var FbDatabasejoin = new Class({

// Fired when form submitted - enables element to update itself with any new submitted data
if (this.options.popupform === form.id) {
this.options.value = json.rowid;

// rob previously we we doing appendInfo() but that didnt get the concat labels for the database join
if (this.options.displayType === 'auto-complete') {

// Need to get v if autocomplete and updating from posted popup form as we only want to get ONE
// option back inside updateFromServer;
// option back inside update();
var myajax = new Request.JSON({
'url': Fabrik.liveSite + 'index.php?option=com_fabrik&view=form&format=raw',
'data': {
'formid': this.options.popupform,
'rowid': json.rowid
},
'onSuccess': function (json) {
this.updateFromServer(json.data[this.options.key]);
this.update(json.data[this.options.key]);
}.bind(this)
}).send();
} else {
Expand Down
10 changes: 7 additions & 3 deletions plugins/fabrik_element/databasejoin/databasejoin.php
Original file line number Diff line number Diff line change
Expand Up @@ -1112,14 +1112,18 @@ public function render($data, $repeatCounter = 0)
{
$chooseUrl = 'index.php?option=com_' . $package . '&view=list&listid=' . $popuplistid . '&tmpl=component&ajax=1';
}
$html[] = '<a href="' . ($chooseUrl) . '" class="toggle-selectoption" title="' . JText::_('COM_FABRIK_SELECT') . '">'
. FabrikHelperHTML::image('search.png', 'form', @$this->tmpl, array('alt' => JText::_('COM_FABRIK_SELECT'))) . '</a>';
$html[] = '<a href="' . ($chooseUrl) . '" class="toggle-selectoption btn" title="' . JText::_('COM_FABRIK_SELECT') . '">'
. FabrikHelperHTML::image('search.png', 'form', @$this->tmpl, array('alt' => JText::_('COM_FABRIK_SELECT'))) . '</a>';
}

if ($params->get('fabrikdatabasejoin_frontend_add') && $this->isEditable())
{
JText::script('PLG_ELEMENT_DBJOIN_ADD');
$html[] = '<a href="#" title="' . JText::_('COM_FABRIK_ADD') . '" class="toggle-addoption">';
$popupform = (int) $params->get('databasejoin_popupform');
$addURL = 'index.php?option=com_fabrik';
$addURL .= $app->isAdmin() ? '&task=form.view' : '&view=form';
$addURL .= '&tmpl=component&ajax=1&formid=' . $popupform;
$html[] = '<a href="' . $addURL . '" title="' . JText::_('COM_FABRIK_ADD') . '" class="toggle-addoption btn">';
$html[] = FabrikHelperHTML::image('action_add.png', 'form', @$this->tmpl, array('alt' => JText::_('COM_FABRIK_SELECT'))) . '</a>';
}

Expand Down

0 comments on commit 02f09a8

Please sign in to comment.