mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-11-18 08:19:05 +01:00
LSldapObject / Custom actions : Added ajax validation feature
This commit is contained in:
parent
5d6ac6956c
commit
97a2713ea0
4 changed files with 59 additions and 7 deletions
|
@ -83,7 +83,7 @@ class LSform {
|
||||||
*/
|
*/
|
||||||
function display(){
|
function display(){
|
||||||
if ($this -> idForm == 'view') {
|
if ($this -> idForm == 'view') {
|
||||||
self :: loadDependenciesDisplayView();
|
self :: loadDependenciesDisplayView($this -> $ldapObject);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LSsession :: addJSscript('LSformElement_field.js');
|
LSsession :: addJSscript('LSformElement_field.js');
|
||||||
|
@ -188,14 +188,35 @@ class LSform {
|
||||||
*
|
*
|
||||||
* @retval void
|
* @retval void
|
||||||
*/
|
*/
|
||||||
public static function loadDependenciesDisplayView() {
|
public static function loadDependenciesDisplayView($ldapObject=false) {
|
||||||
LSsession :: addCssFile('LSform.css');
|
LSsession :: addCssFile('LSform.css');
|
||||||
LSsession :: addJSscript('LSform.js');
|
LSsession :: addJSscript('LSform.js');
|
||||||
LSsession :: addJSconfigParam('LSview_labels', array(
|
$customActionLabels = array ();
|
||||||
|
if (is_a($ldapObject,'LSldapObject')) {
|
||||||
|
$objectname=$ldapObject -> getDisplayName();
|
||||||
|
$customActionsConfig = LSconfig :: get('LSobjects.'.$ldapObject->type_name.'.customActions');
|
||||||
|
if (is_array($customActionsConfig)) {
|
||||||
|
foreach($customActionsConfig as $name => $config) {
|
||||||
|
if (isset($config['question_format'])) {
|
||||||
|
$customActionLabels['custom_action_'.$name.'_confirm_text'] = getFData(__($config['question_format']),$objectname);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$customActionLabels['custom_action_'.$name.'_confirm_text'] = getFData(
|
||||||
|
_('Do you really want to execute custom action %{customAction} on %{objectname} ?'),
|
||||||
|
array(
|
||||||
|
'objectname' => $objectname,
|
||||||
|
'customAction' => $name
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
LSsession :: addJSconfigParam('LSview_labels', array_merge(array(
|
||||||
'delete_confirm_text' => _("Do you really want to delete"),
|
'delete_confirm_text' => _("Do you really want to delete"),
|
||||||
'delete_confirm_title' => _("Caution"),
|
'delete_confirm_title' => _("Caution"),
|
||||||
'delete_confirm_validate' => _("Delete")
|
'delete_confirm_validate' => _("Delete")
|
||||||
));
|
),$customActionLabels));
|
||||||
if (LSsession :: loadLSclass('LSconfirmBox')) {
|
if (LSsession :: loadLSclass('LSconfirmBox')) {
|
||||||
LSconfirmBox :: loadDependenciesDisplay();
|
LSconfirmBox :: loadDependenciesDisplay();
|
||||||
}
|
}
|
||||||
|
@ -210,7 +231,7 @@ class LSform {
|
||||||
* @retval void
|
* @retval void
|
||||||
*/
|
*/
|
||||||
function displayView(){
|
function displayView(){
|
||||||
self :: loadDependenciesDisplayView();
|
self :: loadDependenciesDisplayView($this -> ldapObject);
|
||||||
|
|
||||||
$LSform_object = array(
|
$LSform_object = array(
|
||||||
'type' => $this -> ldapObject -> getType(),
|
'type' => $this -> ldapObject -> getType(),
|
||||||
|
|
|
@ -95,6 +95,36 @@ var LSview = new Class({
|
||||||
|
|
||||||
removeFromA: function(a) {
|
removeFromA: function(a) {
|
||||||
document.location = a.href+'&valid';
|
document.location = a.href+'&valid';
|
||||||
|
},
|
||||||
|
|
||||||
|
onCustomActionBtnClick: function(event,a) {
|
||||||
|
Event(event).stop();
|
||||||
|
if (!this._confirmBoxOpen) {
|
||||||
|
this._confirmBoxOpen = 1;
|
||||||
|
var getName = new RegExp('customAction=([^&]*)');
|
||||||
|
var name = getName.exec(a.href)[1];
|
||||||
|
if (name) {
|
||||||
|
var title = a.innerHTML;
|
||||||
|
if ($type(this.labels['custom_action_'+name+'_confirm_text'])) {
|
||||||
|
var text = this.labels['custom_action_'+name+'_confirm_text']
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
var objectname = $('LSview_title').innerHTML;
|
||||||
|
var text = getFData('Do you really want to execute custom action %{customAction} on %{objectname} ?',{customAction: name, objectname: objectname });
|
||||||
|
}
|
||||||
|
this.confirmBox = new LSconfirmBox({
|
||||||
|
text: text,
|
||||||
|
title: title,
|
||||||
|
startElement: a,
|
||||||
|
onConfirm: this.executeCustomActionFromA.bind(this,a),
|
||||||
|
onClose: this.onConfirmBoxClose.bind(this)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
executeCustomActionFromA: function(a) {
|
||||||
|
document.location = a.href+'&valid';
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<ul class='LSview-actions'>
|
<ul class='LSview-actions'>
|
||||||
{foreach from=$LSview_actions item=item}
|
{foreach from=$LSview_actions item=item}
|
||||||
{if is_array($item)}
|
{if is_array($item)}
|
||||||
<li class='LSview-actions'><a href='{$item.url}' class='LSview-actions' ><img src='{$LS_IMAGES_DIR}/{$item.action}.png' alt='{$item.label}' title='{$item.label}' /> {$item.label}</a></li>
|
<li class='LSview-actions'><a href='{$item.url}' class='LSview-actions{if $item.class} {$item.class}{/if}' ><img src='{$LS_IMAGES_DIR}/{$item.action}.png' alt='{$item.label}' title='{$item.label}' /> {$item.label}</a></li>
|
||||||
{/if}
|
{/if}
|
||||||
{/foreach}
|
{/foreach}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -70,7 +70,8 @@ if(LSsession :: startLSsession()) {
|
||||||
$LSview_actions[] = array (
|
$LSview_actions[] = array (
|
||||||
'label' => ((isset($config['label']))?__($config['label']):__($name)),
|
'label' => ((isset($config['label']))?__($config['label']):__($name)),
|
||||||
'url' => 'custom_action.php?LSobject='.$LSobject.'&dn='.$dn.'&customAction='.$name,
|
'url' => 'custom_action.php?LSobject='.$LSobject.'&dn='.$dn.'&customAction='.$name,
|
||||||
'action' => ((isset($config['icon']))?$config['icon']:'generate')
|
'action' => ((isset($config['icon']))?$config['icon']:'generate'),
|
||||||
|
'class' => 'LScustomActions'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue