fix: [UI] Fix add object menu item

- make the scaffolding system aware of the possibility that "this" might get passed along to javascript
pull/4438/head
iglocska 2019-02-23 18:39:56 +01:00
parent ad8eb0ed47
commit e931b6b80a
2 changed files with 18 additions and 7 deletions

View File

@ -57,9 +57,14 @@
'url' => '/attributes/add/' . $event['Event']['id'],
'text' => __('Add Attribute')
));
echo '<li>';
echo '<a href="#" onclick="popoverPopup(this, ' . h($event['Event']['id']) . ', \'objectTemplates\', \'objectMetaChoice\')"> ' . __('Add Object') . '</a>';
echo '</li>';
echo $this->element('/genericElements/SideMenu/side_menu_link', array(
'element_id' => 'addObject',
'text' => __('Add Object'),
'onClick' => array(
'function' => 'popoverPopup',
'params' => array('this', h($event['Event']['id']), 'objectTemplates', 'objectMetaChoice')
),
));
echo $this->element('/genericElements/SideMenu/side_menu_link', array(
'element_id' => 'addAttachment',
'url' => '/attributes/add_attachment/' . $event['Event']['id'],

View File

@ -23,12 +23,18 @@
$class = '';
}
if (!empty($onClick)) {
$params = array();
$params = '';
foreach ($onClick['params'] as $param) {
$params[] = h($param);
if (!empty($params)) {
$params .= ', ';
}
if ($param === 'this') {
$params .= $param;
} else {
$params .= "'" . h($param) . "'";
}
}
$params = implode('\', \'', $params);
$a .= sprintf(' onClick="%s(\'%s\')"', $onClick['function'], $params);
$a .= sprintf(' onClick="%s(%s)"', $onClick['function'], $params);
}
if (!empty($download)) {
$download = 'download="' . h($download) . '"';