forked from extern/egroupware
- returning checked state of all checkboxes, not only select_all, in $content[nm][checkboxes]
- $content[nm][select_all] is now only reference to $content[nm][checkboxes][select_all] - checkboxes need no default onExecute, therefore removed nm_select_all method - improved documentation for action stuff in nextmatch widget - added egwAction.getActionsByAttr(_attr, _val) method returning all actions with a given attribute and value
This commit is contained in:
parent
9786f03980
commit
fb5ea143be
@ -408,7 +408,6 @@ class addressbook_ui extends addressbook_bo
|
||||
$actions['select_all'] = array(
|
||||
'caption' => 'Whole query',
|
||||
'checkbox' => true,
|
||||
'onExecute' => 'javaScript:nm_select_all', // uses hint to confirm all nm_action='submit'
|
||||
'hint' => 'Apply the action on the whole query, NOT only the shown contacts!!!',
|
||||
'group' => ++$group,
|
||||
);
|
||||
|
@ -56,10 +56,13 @@
|
||||
* 'csv_fields' => // I false=disable csv export, true or unset=enable it with auto-detected fieldnames or preferred importexport definition,
|
||||
* array with name=>label or name=>array('label'=>label,'type'=>type) pairs (type is a eT widget-type)
|
||||
* or name of import/export definition
|
||||
* 'row_id' => // I key into row content to set it's value as tr id, eg. 'id'
|
||||
* 'actions' => // I array with actions, see nextmatch_widget::egw_actions
|
||||
* 'action_links' => // I array with enabled actions or ones which should be checked if they are enabled
|
||||
* optional, default id of all first level actions plus the ones with enabled='javaScript:...'
|
||||
* 'row_id' => // I key into row content to set it's value as tr id, eg. 'id'
|
||||
* 'actions' => // I array with actions, see nextmatch_widget::egw_actions
|
||||
* 'action_links' => // I array with enabled actions or ones which should be checked if they are enabled
|
||||
* optional, default id of all first level actions plus the ones with enabled='javaScript:...'
|
||||
* 'selected' => // O array with selected id's
|
||||
* 'checkboxes' => // 0 array with checkbox id as key and boolean checked value
|
||||
* 'select_all' => // 0 boolean value of select_all checkbox, reference to above value for key 'select_all'
|
||||
* );
|
||||
*/
|
||||
class nextmatch_widget
|
||||
@ -1173,7 +1176,14 @@ class nextmatch_widget
|
||||
|
||||
// allows return selected as array
|
||||
$value['selected'] = $value['selected'] === '' ? array() : boetemplate::csv_split($value['selected']);
|
||||
$value['select_all'] = (boolean)$value['select_all'];
|
||||
$checkboxes = $value['checkboxes'];
|
||||
$value['checkboxes'] = array();
|
||||
foreach(explode(';',$checkboxes) as $data)
|
||||
{
|
||||
list($name,$checked) = explode(':',$data);
|
||||
if ($name) $value['checkboxes'][$name] = (boolean)$checked;
|
||||
}
|
||||
$value['select_all'] =& $value['checkboxes']['select_all'];
|
||||
|
||||
return True;
|
||||
}
|
||||
|
@ -91,6 +91,9 @@ function nextmatchRowAOI(_node)
|
||||
*/
|
||||
function nm_action(_action, _senders)
|
||||
{
|
||||
// ignore checkboxes, unless they have an explicit defined nm_action
|
||||
if (_action.checkbox && (!_action.data || typeof _action.data.nm_action == 'undefined')) return;
|
||||
|
||||
if (typeof _action.data == 'undefined' || !_action.data) _action.data = {};
|
||||
if (typeof _action.data.nm_action == 'undefined') _action.data.nm_action = 'submit';
|
||||
|
||||
@ -102,13 +105,13 @@ function nm_action(_action, _senders)
|
||||
}
|
||||
//console.log(_action); console.log(_senders);
|
||||
|
||||
var select_all = document.getElementById('exec[nm][select_all]');
|
||||
var confirm_msg = (_senders.length > 1 || select_all && select_all.value) &&
|
||||
var select_all = egw_actionManager.getActionById("select_all");
|
||||
var confirm_msg = (_senders.length > 1 || select_all && select_all.checked) &&
|
||||
typeof _action.data.confirm_multiple != 'undefined' ?
|
||||
_action.data.confirm_multiple : _action.data.confirm;
|
||||
|
||||
// let user confirm the action first (if not select_all set and nm_action == 'submit' --> confirmed later)
|
||||
if (!(select_all && select_all.value && _action.data.nm_action == 'submit') &&
|
||||
if (!(select_all && select_all.checked && _action.data.nm_action == 'submit') &&
|
||||
typeof _action.data.confirm != 'undefined')
|
||||
{
|
||||
if (!confirm(confirm_msg)) return;
|
||||
@ -142,10 +145,16 @@ function nm_action(_action, _senders)
|
||||
|
||||
case 'submit':
|
||||
// let user confirm select-all
|
||||
if (select_all && select_all.value)
|
||||
if (select_all && select_all.checked)
|
||||
{
|
||||
if (!confirm(confirm_msg+"\n\n"+select_all.value)) return;
|
||||
if (!confirm(confirm_msg+"\n\n"+select_all.hint)) return;
|
||||
}
|
||||
var checkboxes = egw_actionManager.getActionsByAttr("checkbox", true);
|
||||
var checkboxes_elem = document.getElementById('exec[nm][checkboxes]');
|
||||
if (checkboxes && checkboxes_elem)
|
||||
for (var i in checkboxes)
|
||||
checkboxes_elem.value += checkboxes[i].id + ":" + (checkboxes[i].checked ? "1" : "0") + ";";
|
||||
|
||||
var form = document.getElementsByName("eTemplate")[0];
|
||||
document.getElementById('exec[nm][action]').value = _action.id;
|
||||
document.getElementById('exec[nm][selected]').value = ids;
|
||||
@ -161,17 +170,6 @@ function nm_action(_action, _senders)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback for select_all checkbox, use hint to confirm all nm_action='submit' before submitting in nm_action()
|
||||
*
|
||||
* @param _action
|
||||
* @param _senders
|
||||
*/
|
||||
function nm_select_all(_action, _senders)
|
||||
{
|
||||
document.getElementById('exec[nm][select_all]').value = _action.checked ? _action.hint : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to check if none of _senders rows has disableClass set
|
||||
*
|
||||
|
@ -2,7 +2,7 @@
|
||||
/**
|
||||
* eGroupWare - eTemplates for Application etemplate
|
||||
* http://www.egroupware.org
|
||||
* generated by soetemplate::dump4setup() 2011-04-16 22:25
|
||||
* generated by soetemplate::dump4setup() 2011-04-27 09:40
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
@ -143,7 +143,7 @@ $templ_data[] = array('name' => 'etemplate.link_widget.to','template' => '','lan
|
||||
.type_hide { display: none; }
|
||||
.hide_comment input { display: none; width: 99%; }','modified' => '1260292296',);
|
||||
|
||||
$templ_data[] = array('name' => 'etemplate.nextmatch_widget','template' => '','lang' => '','group' => '0','version' => '1.9.001','data' => 'a:4:{i:0;a:2:{s:4:"type";s:6:"hidden";s:4:"name";s:6:"action";}i:1;a:2:{s:4:"type";s:6:"hidden";s:4:"name";s:8:"selected";}i:2;a:2:{s:4:"type";s:6:"hidden";s:4:"name";s:10:"select_all";}i:3;a:5:{s:4:"type";s:4:"grid";s:4:"data";a:6:{i:0;a:8:{s:1:"A";s:3:"35%";s:1:"C";s:3:"35%";s:2:"c1";s:7:"noPrint";s:2:"c2";s:7:"noPrint";s:2:"c5";s:7:"noPrint";s:2:"h5";s:13:",!@bottom_too";s:2:"h3";s:15:",!@lettersearch";s:2:"c3";s:7:"noPrint";}i:1;a:3:{s:1:"A";a:2:{s:4:"type";s:8:"template";s:4:"name";s:12:"@header_left";}s:1:"B";a:6:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"2";s:5:"align";s:6:"center";i:1;a:4:{s:4:"type";s:5:"label";s:5:"label";s:7:"showing";s:7:"no_lang";s:1:"1";s:4:"name";s:5:"range";}i:2;a:4:{s:4:"type";s:5:"label";s:5:"label";s:2:"of";s:7:"no_lang";s:1:"1";s:4:"name";s:5:"total";}s:4:"span";s:16:",nextmatch-range";}s:1:"C";a:3:{s:4:"type";s:8:"template";s:5:"align";s:5:"right";s:4:"name";s:13:"@header_right";}}i:2;a:3:{s:1:"A";a:4:{s:4:"type";s:8:"template";s:4:"span";s:3:"all";s:5:"align";s:6:"center";s:4:"name";s:33:"etemplate.nextmatch_widget.nm_row";}s:1:"B";a:2:{s:4:"type";s:5:"label";s:8:"onchange";s:1:"1";}s:1:"C";a:1:{s:4:"type";s:5:"label";}}i:3;a:3:{s:1:"A";a:5:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"1";s:4:"span";s:3:"all";s:4:"name";s:12:"lettersearch";i:1;a:6:{s:4:"type";s:5:"label";s:5:"label";s:3:"All";s:5:"align";s:5:"right";s:4:"name";s:3:"all";s:6:"needed";s:1:"1";s:4:"span";s:20:",lettersearch_active";}}s:1:"B";a:1:{s:4:"type";s:5:"label";}s:1:"C";a:1:{s:4:"type";s:5:"label";}}i:4;a:3:{s:1:"A";a:5:{s:4:"type";s:8:"template";s:4:"size";s:4:"rows";s:4:"span";s:20:"all,egwGridView_grid";s:5:"align";s:6:"center";s:4:"name";s:9:"@template";}s:1:"B";a:1:{s:4:"type";s:5:"label";}s:1:"C";a:1:{s:4:"type";s:5:"label";}}i:5;a:3:{s:1:"A";a:5:{s:4:"type";s:8:"template";s:4:"size";s:6:"bottom";s:4:"span";s:3:"all";s:5:"align";s:6:"center";s:4:"name";s:33:"etemplate.nextmatch_widget.nm_row";}s:1:"B";a:1:{s:4:"type";s:5:"label";}s:1:"C";a:1:{s:4:"type";s:5:"label";}}}s:4:"rows";i:5;s:4:"cols";i:3;s:4:"size";s:4:"100%";}}','size' => '100%','style' => '','modified' => '1155978375',);
|
||||
$templ_data[] = array('name' => 'etemplate.nextmatch_widget','template' => '','lang' => '','group' => '0','version' => '1.9.001','data' => 'a:4:{i:0;a:2:{s:4:"type";s:6:"hidden";s:4:"name";s:6:"action";}i:1;a:2:{s:4:"type";s:6:"hidden";s:4:"name";s:8:"selected";}i:2;a:2:{s:4:"type";s:6:"hidden";s:4:"name";s:10:"checkboxes";}i:3;a:5:{s:4:"type";s:4:"grid";s:4:"data";a:6:{i:0;a:8:{s:1:"A";s:3:"35%";s:1:"C";s:3:"35%";s:2:"c1";s:7:"noPrint";s:2:"c2";s:7:"noPrint";s:2:"c5";s:7:"noPrint";s:2:"h5";s:13:",!@bottom_too";s:2:"h3";s:15:",!@lettersearch";s:2:"c3";s:7:"noPrint";}i:1;a:3:{s:1:"A";a:2:{s:4:"type";s:8:"template";s:4:"name";s:12:"@header_left";}s:1:"B";a:6:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"2";s:5:"align";s:6:"center";i:1;a:4:{s:4:"type";s:5:"label";s:5:"label";s:7:"showing";s:7:"no_lang";s:1:"1";s:4:"name";s:5:"range";}i:2;a:4:{s:4:"type";s:5:"label";s:5:"label";s:2:"of";s:7:"no_lang";s:1:"1";s:4:"name";s:5:"total";}s:4:"span";s:16:",nextmatch-range";}s:1:"C";a:3:{s:4:"type";s:8:"template";s:5:"align";s:5:"right";s:4:"name";s:13:"@header_right";}}i:2;a:3:{s:1:"A";a:4:{s:4:"type";s:8:"template";s:4:"span";s:3:"all";s:5:"align";s:6:"center";s:4:"name";s:33:"etemplate.nextmatch_widget.nm_row";}s:1:"B";a:2:{s:4:"type";s:5:"label";s:8:"onchange";s:1:"1";}s:1:"C";a:1:{s:4:"type";s:5:"label";}}i:3;a:3:{s:1:"A";a:5:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"1";s:4:"span";s:3:"all";s:4:"name";s:12:"lettersearch";i:1;a:6:{s:4:"type";s:5:"label";s:5:"label";s:3:"All";s:5:"align";s:5:"right";s:4:"name";s:3:"all";s:6:"needed";s:1:"1";s:4:"span";s:20:",lettersearch_active";}}s:1:"B";a:1:{s:4:"type";s:5:"label";}s:1:"C";a:1:{s:4:"type";s:5:"label";}}i:4;a:3:{s:1:"A";a:5:{s:4:"type";s:8:"template";s:4:"size";s:4:"rows";s:4:"span";s:20:"all,egwGridView_grid";s:5:"align";s:6:"center";s:4:"name";s:9:"@template";}s:1:"B";a:1:{s:4:"type";s:5:"label";}s:1:"C";a:1:{s:4:"type";s:5:"label";}}i:5;a:3:{s:1:"A";a:5:{s:4:"type";s:8:"template";s:4:"size";s:6:"bottom";s:4:"span";s:3:"all";s:5:"align";s:6:"center";s:4:"name";s:33:"etemplate.nextmatch_widget.nm_row";}s:1:"B";a:1:{s:4:"type";s:5:"label";}s:1:"C";a:1:{s:4:"type";s:5:"label";}}}s:4:"rows";i:5;s:4:"cols";i:3;s:4:"size";s:4:"100%";}}','size' => '100%','style' => '','modified' => '1155978375',);
|
||||
|
||||
$templ_data[] = array('name' => 'etemplate.nextmatch_widget.header_only','template' => '','lang' => '','group' => '0','version' => '0.9.15.002','data' => 'a:1:{i:0;a:5:{s:4:"type";s:4:"grid";s:4:"data";a:3:{i:0;a:2:{s:1:"A";s:3:"50%";s:1:"B";s:3:"50%";}i:1;a:2:{s:1:"A";a:2:{s:4:"type";s:8:"template";s:4:"name";s:12:"@header_left";}s:1:"B";a:3:{s:4:"type";s:8:"template";s:5:"align";s:5:"right";s:4:"name";s:13:"@header_right";}}i:2;a:2:{s:1:"A";a:5:{s:4:"type";s:8:"template";s:4:"size";s:4:"rows";s:4:"span";s:3:"all";s:5:"align";s:6:"center";s:4:"name";s:9:"@template";}s:1:"B";a:1:{s:4:"type";s:5:"label";}}}s:4:"rows";i:2;s:4:"cols";i:2;s:4:"size";s:4:"100%";}}','size' => '100%','style' => '.activ_sortcolumn { color: red; font-weight: bold; }
|
||||
.inactiv_sortcolumn { color: green; font-weight: normal; }','modified' => '1075985789',);
|
||||
|
@ -57,7 +57,7 @@
|
||||
<template id="etemplate.nextmatch_widget" template="" lang="" group="0" version="1.9.001">
|
||||
<hidden id="action"/>
|
||||
<hidden id="selected"/>
|
||||
<hidden id="select_all"/>
|
||||
<hidden id="checkboxes"/>
|
||||
<grid width="100%">
|
||||
<columns>
|
||||
<column width="35%"/>
|
||||
|
@ -93,6 +93,37 @@ egwAction.prototype.getActionById = function(_id)
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches for actions having an attribute with a certain value
|
||||
*
|
||||
* Example: actionManager.getActionsByAttr("checkbox", true) returns all checkbox actions
|
||||
*
|
||||
* @param string _attr attribute name
|
||||
* @param mixed _val attribute value
|
||||
* @return array
|
||||
*/
|
||||
egwAction.prototype.getActionsByAttr = function(_attr, _val)
|
||||
{
|
||||
var _actions = [];
|
||||
|
||||
// If the current action object has the given attr AND value, return it
|
||||
if (typeof this[_attr] != "undefined" && this[_attr] === _val)
|
||||
{
|
||||
_actions.push(this);
|
||||
}
|
||||
|
||||
// If this element is capable of having children, search those too
|
||||
if (this.canHaveChildren)
|
||||
{
|
||||
for (var i = 0; i < this.children.length; i++)
|
||||
{
|
||||
_actions = _actions.concat(this.children[i].getActionsByAttr(_attr, _val));
|
||||
}
|
||||
}
|
||||
|
||||
return _actions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new action to the child elements.
|
||||
*/
|
||||
|
@ -908,7 +908,6 @@ class timesheet_ui extends timesheet_bo
|
||||
'select_all' => array(
|
||||
'caption' => 'Whole query',
|
||||
'checkbox' => true,
|
||||
'onExecute' => 'javaScript:nm_select_all', // uses hint to confirm all nm_action='submit'
|
||||
'hint' => 'Apply the action on the whole query, NOT only the shown timesheets!!!',
|
||||
'group' => ++$group,
|
||||
),
|
||||
|
Loading…
Reference in New Issue
Block a user