Skip to content

Commit

Permalink
list filters now applied only to each admin module
Browse files Browse the repository at this point in the history
added option to show filters for chart viz
autocomplete filter js objects now only observe their exact field (was duplicating events if 2 list modules contained the same list
added hover trigger event to inliine edit plugin
  • Loading branch information
pollen8 committed Oct 28, 2011
1 parent 7bdf603 commit 4910ac7
Show file tree
Hide file tree
Showing 40 changed files with 330 additions and 155 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,4 @@ transfer/*
/tests
/cache
fabrik_build/output/
/build_config_private.ini
2 changes: 1 addition & 1 deletion administrator/components/com_fabrik/controllers/form.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function view()
$viewLayout = JRequest::getCmd('layout', 'default');
$view = $this->getView('form', $viewType, '');
$view->setModel($model, true);

$view->isMambot = $this->isMambot;
// Set the layout
$view->setLayout($viewLayout);

Expand Down
4 changes: 1 addition & 3 deletions administrator/components/com_fabrik/controllers/form.raw.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,8 @@ function process()
$this->_isMambot = JRequest::getVar('_isMambot', 0);
$model->getForm();
$model->_rowId = JRequest::getVar('rowid', '');

// Check for request forgeries
$fbConfig = JComponentHelper::getParams('com_fabrik');
if ($model->getParams()->get('spoof_check', $fbConfig->get('spoofcheck_on_formsubmission', true)) == true) {
if ($model->spoofCheck()) {
JRequest::checkToken() or die('Invalid Token');
}
if (!$model->validate()) {
Expand Down
3 changes: 1 addition & 2 deletions administrator/components/com_fabrik/controllers/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public function view()
$this->setPath('view', COM_FABRIK_FRONTEND.DS.'views');

$viewLayout = JRequest::getCmd('layout', 'default');
$view = & $this->getView($this->view_item, $viewType, '');
$view = $this->getView($this->view_item, $viewType, '');
$view->setModel($model, true);
// Set the layout
$view->setLayout($viewLayout);
Expand Down Expand Up @@ -147,7 +147,6 @@ public function filter()
{
// Check for request forgeries
JRequest::checkToken() or die('Invalid Token');
//JModel::addIncludePath(JPATH_SITE.DS.'components'.DS.'com_fabrik'.DS.'models');
$model = JModel::getInstance('List', 'FabrikFEModel');
$id = JRequest::getInt('listid');
$model->setId($id);
Expand Down
41 changes: 41 additions & 0 deletions administrator/components/com_fabrik/controllers/list.raw.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,45 @@ public function ajax_loadTableDropDown()
$fieldDropDown = JHTML::_('select.genericlist', $fieldNames, $name, "class=\"inputbox\" size=\"1\" ", 'value', 'text', '');
echo $fieldDropDown;
}

public function filter()
{
// Check for request forgeries
//JRequest::checkToken() or die('Invalid Token');
$model = JModel::getInstance('List', 'FabrikFEModel');
$id = JRequest::getInt('listid');
$model->setId($id);
JRequest::setvar('cid', $id);
$request = $model->getRequestData();
$model->storeRequestData($request);
$this->view();
}

/**
* show the lists data in the admin
*/

public function view()
{
$cid = JRequest::getVar('cid', array(0), 'method', 'array');
if(is_array($cid)){
$cid = $cid[0];
}
$cid = JRequest::getInt('listid', $cid);
// grab the model and set its id
$model = JModel::getInstance('List', 'FabrikFEModel');
$model->setState('list.id', $cid);
$viewType = JFactory::getDocument()->getType();
//use the front end renderer to show the table
$this->setPath('view', COM_FABRIK_FRONTEND.DS.'views');

$viewLayout = JRequest::getCmd('layout', 'default');
$view = $this->getView($this->view_item, $viewType, '');
$view->setModel($model, true);
// Set the layout
$view->setLayout($viewLayout);
JToolBarHelper::title(JText::_('COM_FABRIK_MANAGER_LISTS'), 'lists.png');
$view->display();
FabrikHelper::addSubmenu(JRequest::getWord('view', 'lists'));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,9 @@ COM_FABRIK_FIELD="Field"
COM_FABRIK_FIELD_ACTION_METHOD_LABEL="Render buttons as"
COM_FABRIK_FIELD_ACTION_METHOD_DESC="Determines how the edit/view/delete and plugin buttons are rendered"
COM_FABRIK_FIELD_ACTION_METHOD_INLINE="Inline"
COM_FABRIK_FIELD_ACTION_METHOD_FLOATING="Floating"
COM_FABRIK_FIELD_ACTION_METHOD_FLOATING="Floating"
COM_FABRIK_FIELD_ADD_BUTTON_LABEL_LABEL="Add button label"
COM_FABRIK_FIELD_ADD_BUTTON_LABEL_DESC="Custom text for the add button, leave blank to default to 'add'"
COM_FABRIK_FIELD_ADD_RECORDS_DESC="The group the user must belong to to be able to add records"
COM_FABRIK_FIELD_ADD_RECORDS_LABEL="Add records"
COM_FABRIK_FIELD_ADD_TO_PAGE_TITLE_DESC="When set to yes the element's value is appended to the document's page title."
Expand Down
9 changes: 6 additions & 3 deletions administrator/components/com_fabrik/models/fields/element.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,13 @@ function getInput()
if (!isset($fabrikelements)) {
$fabrikelements = array();
}

$c = $this->form->repeatCounter;
JDEBUG ? JHtml::_('script', 'media/com_fabrik/js/lib/head/head.js'): JHtml::_('script', 'media/com_fabrik/js/lib/head/head.min.js');
FabrikHelperHTML::script('administrator/components/com_fabrik/views/namespace.js');
$c = (int)@$this->form->repeatCounter;
$table = $this->element['table'];

if ($table == '') {
$table = $this->form->getValue('params.list_id');
}
$include_calculations = (int)$this->element['include_calculations'];
$published = (int)$this->element['published'];
$showintable = (int)$this->element['showintable'];
Expand Down
1 change: 1 addition & 0 deletions components/com_fabrik/controllers/form.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ function display()
if (!JError::isError($model) && is_object($model)) {
$view->setModel($model, true);
}
echo $this->isMambot ? 'controller is mambot ': 'controller NOT a ambot';
$view->isMambot = $this->isMambot;
// Display the view
$view->assign('error', $this->getError());
Expand Down
4 changes: 2 additions & 2 deletions components/com_fabrik/helpers/html.php
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ function emailIcon($formModel, $params)

/**
* get a list of condition options - used in advanced search
* @param int table id
* @param string table ref
* @param string selected value
* @return string html select list
*/
Expand Down Expand Up @@ -701,7 +701,7 @@ function script($file, $onLoad = '')

function slimbox()
{
return;
//return;
$fbConfig = JComponentHelper::getParams('com_fabrik');
if ($fbConfig->get('include_lightbox_js', 1) == 0) {
return;
Expand Down
40 changes: 20 additions & 20 deletions components/com_fabrik/models/element.php
Original file line number Diff line number Diff line change
Expand Up @@ -1780,8 +1780,8 @@ public function getFilter($counter = 0, $normal = true)
$element = $this->getElement();

$elName = $this->getFullName(false, true, false);
$id = $this->getHTMLId() . 'value';
$v = 'fabrik___filter[list_'.$table->id.'][value]';
$id = $this->getHTMLId().'value';
$v = 'fabrik___filter[list_'.$listModel->getRenderContext().'][value]';
$v .= ($normal) ? '['.$counter.']' : '[]';

//corect default got
Expand Down Expand Up @@ -1822,12 +1822,11 @@ public function getFilter($counter = 0, $normal = true)
case "auto-complete":
$default = stripslashes($default);
$default = htmlspecialchars($default);
$return = '<input type="hidden" name="'.$v.'" class="inputbox fabrik_filter" value="'.$default.'" id="'.$id.'" />';
$return .= '<input type="text" name="'.$v.'-auto-complete" class="inputbox fabrik_filter autocomplete-trigger" size="'.$size.'" value="'.$default.'" id="'.$id.'-auto-complete" />';
// $$$ rob 29/04/2011 - for this to work you would need to update the autocompleter class as it does $(id) not document.getELement();
// think its safer to not alter the class as noneof the element pugin implementations work like this!
//FabrikHelperHTML::autoComplete('#tableform_'.$table->id . ' #'.$id, $this->getElement()->id);
FabrikHelperHTML::autoComplete($id, $this->getElement()->id);
// $$$ rob 28/10/2011 using selector rather than element id so we can have n modules with the same filters showing and not produce invald html & duplicate js calls
$return = '<input type="hidden" name="'.$v.'" class="inputbox fabrik_filter '.$id.'" value="'.$default.'" />';
$return .= '<input type="text" name="'.$v.'-auto-complete" class="inputbox fabrik_filter autocomplete-trigger '.$id.'-auto-complete" size="'.$size.'" value="'.$default.'" />';
$selector = '#list_'.$listModel->getRenderContext().' .'.$id;
FabrikHelperHTML::autoComplete($selector, $this->getElement()->id);
break;
}
if ($normal) {
Expand Down Expand Up @@ -2119,16 +2118,17 @@ function getFilterHiddenFields($counter, $elName, $hidden = false)
$match = $this->isExactMatch(array('match' => $element->filter_exact_match));
$cond = $this->getFilterCondition();
$return = array();
$return[] = '<input type="hidden" name="fabrik___filter[list_'.$table->id.'][condition]['.$counter.']" value="'.$cond.'" />';
$return[] = '<input type="hidden" name="fabrik___filter[list_'.$table->id.'][join]['.$counter.']" value="AND" />';
$return[] = '<input type="hidden" name="fabrik___filter[list_'.$table->id.'][key]['.$counter.']" value="'.$elName.'" />';
$return[] = '<input type="hidden" name="fabrik___filter[list_'.$table->id.'][search_type]['.$counter.']" value="normal" />';
$return[] = '<input type="hidden" name="fabrik___filter[list_'.$table->id.'][match]['.$counter.']" value="'.$match.'" />';
$return[] = '<input type="hidden" name="fabrik___filter[list_'.$table->id.'][full_words_only]['.$counter.']" value="'.$params->get('full_words_only', '0').'" />';
$return[] = '<input type="hidden" name="fabrik___filter[list_'.$table->id.'][eval]['.$counter.']" value="'.FABRIKFILTER_TEXT.'" />';
$return[] = '<input type="hidden" name="fabrik___filter[list_'.$table->id.'][grouped_to_previous]['.$counter.']" value="0" />';
$return[] = '<input type="hidden" name="fabrik___filter[list_'.$table->id.'][hidden]['.$counter.']" value="'.$hidden.'" />';
$return[] = '<input type="hidden" name="fabrik___filter[list_'.$table->id.'][elementid]['.$counter.']" value="'.$element->id.'" />';
$prefix = '<input type="hidden" name="fabrik___filter[list_'.$this->getListModel()->getRenderContext().']';
$return[] = $prefix.'[condition]['.$counter.']" value="'.$cond.'" />';
$return[] = $prefix.'[join]['.$counter.']" value="AND" />';
$return[] = $prefix.'[key]['.$counter.']" value="'.$elName.'" />';
$return[] = $prefix.'[search_type]['.$counter.']" value="normal" />';
$return[] = $prefix.'[match]['.$counter.']" value="'.$match.'" />';
$return[] = $prefix.'[full_words_only]['.$counter.']" value="'.$params->get('full_words_only', '0').'" />';
$return[] = $prefix.'[eval]['.$counter.']" value="'.FABRIKFILTER_TEXT.'" />';
$return[] = $prefix.'[grouped_to_previous]['.$counter.']" value="0" />';
$return[] = $prefix.'[hidden]['.$counter.']" value="'.$hidden.'" />';
$return[] = $prefix.'[elementid]['.$counter.']" value="'.$element->id.'" />';
return implode("\n", $return);
}

Expand Down Expand Up @@ -2156,9 +2156,9 @@ protected function getFilterCondition()

function getAdvancedFilterHiddenFields()
{
$table = $this->getListModel()->getTable();
$listModel = $this->getListModel();
$element = $this->getElement();
return "\n".'<input type="hidden" name="fabrik___filter[list_'.$table->id.'][elementid][]" value="'.$element->id.'" />';
return "\n".'<input type="hidden" name="fabrik___filter[list_'.$listModel->getRenderContext().'][elementid][]" value="'.$element->id.'" />';
}

/**
Expand Down
12 changes: 7 additions & 5 deletions components/com_fabrik/models/elementlist.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ function getFilter($counter = 0, $normal = true)
$default = $this->getDefaultFilterVal($normal, $counter);
$elName = $this->getFullName(false, true, false);
$htmlid = $this->getHTMLId() . 'value';
$table = $this->getlistModel()->getTable();
$listModel = $this->getListModel();
$params = $this->getParams();
$v = 'fabrik___filter[list_'.$table->id.'][value]';
$v = 'fabrik___filter[list_'.$listModel->getRenderContext().'][value]';
$v .= $normal ? '['.$counter.']' : '[]';

if (in_array($element->filter_type, array('range', 'dropdown', ''))) {
Expand Down Expand Up @@ -157,9 +157,11 @@ function getFilter($counter = 0, $normal = true)
$default = stripslashes($default);
}
$default = htmlspecialchars($default);
$return[] = '<input type="hidden" name="'.$v.'" class="inputbox fabrik_filter" value="'.$default.'" id="'.$htmlid.'" />';
$return[] = '<input type="text" name="'.$v.'-auto-complete" class="inputbox fabrik_filter autocomplete-trigger" size="'.$size.'" value="'.$default.'" id="'.$htmlid.'-auto-complete" />';
FabrikHelperHTML::autoComplete($htmlid, $this->getElement()->id, $element->plugin);
$return = '<input type="hidden" name="'.$v.'" class="inputbox fabrik_filter '.$htmlid.'" value="'.$default.'" />';
$return .= '<input type="text" name="'.$v.'-auto-complete" class="inputbox fabrik_filter autocomplete-trigger '.$htmlid.'-auto-complete" size="'.$size.'" value="'.$default.'" />';
$selector = '#list_'.$listModel->getRenderContext().' .'.$htmlid;
FabrikHelperHTML::autoComplete($selector, $this->getElement()->id);

break;
}
if ($normal) {
Expand Down
Loading

0 comments on commit 4910ac7

Please sign in to comment.