mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-22 16:03:47 +01:00
changed toolbar to have last action.id as value, when submitted to server
This commit is contained in:
parent
94f468095d
commit
7bda46582d
41
etemplate/inc/class.etemplate_widget_toolbar.inc.php
Normal file
41
etemplate/inc/class.etemplate_widget_toolbar.inc.php
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* EGroupware - eTemplate serverside toolbar widget
|
||||||
|
*
|
||||||
|
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||||
|
* @package etemplate
|
||||||
|
* @subpackage api
|
||||||
|
* @link http://www.egroupware.org
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* eTemplate button widget
|
||||||
|
*/
|
||||||
|
class etemplate_widget_toolbar extends etemplate_widget
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Validate toolbar
|
||||||
|
*
|
||||||
|
* Readonly buttons can NOT be pressed!
|
||||||
|
*
|
||||||
|
* @param string $cname current namespace
|
||||||
|
* @param array $expand values for keys 'c', 'row', 'c_', 'row_', 'cont'
|
||||||
|
* @param array $content
|
||||||
|
* @param array &$validated=array() validated content
|
||||||
|
* @return boolean true if no validation error, false otherwise
|
||||||
|
*/
|
||||||
|
public function validate($cname, array $expand, array $content, &$validated=array())
|
||||||
|
{
|
||||||
|
$form_name = self::form_name($cname, $this->id, $expand);
|
||||||
|
error_log(__METHOD__."('$cname', ".array2string($expand).", ...) $this: get_array(\$content, '$form_name')=".array2string(self::get_array($content, $form_name)));
|
||||||
|
|
||||||
|
if (!$this->is_readonly($cname, $form_name))
|
||||||
|
{
|
||||||
|
$value = self::get_array($content, $form_name);
|
||||||
|
$valid =& self::get_array($validated, $form_name, true);
|
||||||
|
if (true) $valid = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
etemplate_widget::registerWidget('etemplate_widget_toolbar', array('toolbar'));
|
@ -23,7 +23,7 @@
|
|||||||
*
|
*
|
||||||
* @augments et2_valueWidget
|
* @augments et2_valueWidget
|
||||||
*/
|
*/
|
||||||
var et2_toolbar = et2_DOMWidget.extend(
|
var et2_toolbar = et2_DOMWidget.extend([et2_IInput],
|
||||||
{
|
{
|
||||||
attributes: {
|
attributes: {
|
||||||
"view_range": {
|
"view_range": {
|
||||||
@ -49,6 +49,11 @@ var et2_toolbar = et2_DOMWidget.extend(
|
|||||||
save: {caption:'Save', group:2, toolbarDefault:true}
|
save: {caption:'Save', group:2, toolbarDefault:true}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* id of last action executed / value of toolbar if submitted
|
||||||
|
*/
|
||||||
|
value: null,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
@ -233,24 +238,20 @@ var et2_toolbar = et2_DOMWidget.extend(
|
|||||||
var action = that._actionManager.getActionById(selected.attr('data-id'));
|
var action = that._actionManager.getActionById(selected.attr('data-id'));
|
||||||
if(action)
|
if(action)
|
||||||
{
|
{
|
||||||
if(action)
|
this.value = action.id;
|
||||||
{
|
action.execute([]);
|
||||||
action.onExecute.exec(action);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
console.debug(selected, this, action);
|
//console.debug(selected, this, action);
|
||||||
},action);
|
},action);
|
||||||
dropdown.onclick = jQuery.proxy(function(selected, dropdown)
|
dropdown.onclick = jQuery.proxy(function(selected, dropdown)
|
||||||
{
|
{
|
||||||
var action = that._actionManager.getActionById(this.getValue());
|
var action = that._actionManager.getActionById(this.getValue());
|
||||||
if(action)
|
if(action)
|
||||||
{
|
{
|
||||||
if(action)
|
this.value = action.id;
|
||||||
{
|
action.execute([]);
|
||||||
action.onExecute.exec(action);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
console.debug(selected, this, action);
|
//console.debug(selected, this, action);
|
||||||
},dropdown);
|
},dropdown);
|
||||||
$j(dropdown.getDOMNode())
|
$j(dropdown.getDOMNode())
|
||||||
.attr('id',this.id + '-' + dropdown.id)
|
.attr('id',this.id + '-' + dropdown.id)
|
||||||
@ -395,10 +396,12 @@ var et2_toolbar = et2_DOMWidget.extend(
|
|||||||
button.button(button_options);
|
button.button(button_options);
|
||||||
}
|
}
|
||||||
// Set up the click action
|
// Set up the click action
|
||||||
var click = function(e) {
|
var click = function(e)
|
||||||
|
{
|
||||||
var action = this._actionManager.getActionById(e.data);
|
var action = this._actionManager.getActionById(e.data);
|
||||||
if(action)
|
if(action)
|
||||||
{
|
{
|
||||||
|
this.value = action.id;
|
||||||
action.data.event = e;
|
action.data.event = e;
|
||||||
action.execute([]);
|
action.execute([]);
|
||||||
}
|
}
|
||||||
@ -420,6 +423,50 @@ var et2_toolbar = et2_DOMWidget.extend(
|
|||||||
getDOMNode: function(asker)
|
getDOMNode: function(asker)
|
||||||
{
|
{
|
||||||
return this.div[0];
|
return this.div[0];
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* getValue has to return the value of the input widget
|
||||||
|
*/
|
||||||
|
getValue: function()
|
||||||
|
{
|
||||||
|
return this.value;
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is dirty returns true if the value of the widget has changed since it
|
||||||
|
* was loaded.
|
||||||
|
*/
|
||||||
|
isDirty: function()
|
||||||
|
{
|
||||||
|
return this.value != null;
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Causes the dirty flag to be reseted.
|
||||||
|
*/
|
||||||
|
resetDirty: function()
|
||||||
|
{
|
||||||
|
this.value = null;
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks the data to see if it is valid, as far as the client side can tell.
|
||||||
|
* Return true if it's not possible to tell on the client side, because the server
|
||||||
|
* will have the chance to validate also.
|
||||||
|
*
|
||||||
|
* The messages array is to be populated with everything wrong with the data,
|
||||||
|
* so don't stop checking after the first problem unless it really makes sense
|
||||||
|
* to ignore other problems.
|
||||||
|
*
|
||||||
|
* @param {String[]} messages List of messages explaining the failure(s).
|
||||||
|
* messages should be fairly short, and already translated.
|
||||||
|
*
|
||||||
|
* @return {boolean} True if the value is valid (enough), false to fail
|
||||||
|
*/
|
||||||
|
isValid: function(messages)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
et2_register_widget(et2_toolbar, ["toolbar"]);
|
et2_register_widget(et2_toolbar, ["toolbar"]);
|
||||||
|
Loading…
Reference in New Issue
Block a user