Browse Source

Move quickaccess to header

experimental
Paweł Jedwabny 3 years ago
parent
commit
3aacc4fd6c
7 changed files with 39 additions and 53 deletions
  1. +0
    -3
      modules/Base/ActionBar/ActionBarCommon_0.php
  2. +23
    -35
      modules/Base/ActionBar/ActionBar_0.php
  3. +1
    -14
      modules/Base/ActionBar/theme/default.tpl
  4. +12
    -0
      modules/Base/ActionBar/theme/quickaccess.twig
  5. +2
    -0
      modules/Base/Box/Box_0.php
  6. +1
    -0
      modules/Base/Box/theme/default.tpl
  7. +0
    -1
      modules/Base/Dashboard/Dashboard_0.php

+ 0
- 3
modules/Base/ActionBar/ActionBarCommon_0.php View File

@@ -92,9 +92,6 @@ class Base_ActionBarCommon extends ModuleCommon {
self::$icons = array();
}
public static function show_quick_access_shortcuts($value = true) {
self::$quick_access_shortcuts = $value;
}
}
on_exit(array('Base_ActionBarCommon','clean'));
?>

+ 23
- 35
modules/Base/ActionBar/ActionBar_0.php View File

@@ -90,43 +90,9 @@ class Base_ActionBar extends Module
'close' => ''
);

$launcher_right = [];
if (Base_AclCommon::is_user() && $opts = Base_Menu_QuickAccessCommon::get_options()) {
self::$launchpad = array();
foreach ($opts as $k => $v) {
if (Base_ActionBarCommon::$quick_access_shortcuts
&& Base_User_SettingsCommon::get(Base_Menu_QuickAccessCommon::module_name(), $v['name'] . '_d')
) {
$ii = array();
$trimmed_label = trim(substr(strrchr($v['label'], ':'), 1));
$ii['label'] = $trimmed_label ? $trimmed_label : $v['label'];
$ii['description'] = $v['label'];
$arr = $v['link'];
$icon = null;
$icon_url = null;
if (isset($v['link']['__icon__'])) {
if (array_key_exists('fa-' . $v['link']['__icon__'], $fa_icons))
$icon = $v['link']['__icon__'];
else
$icon_url = Base_ThemeCommon::get_template_file($v['module'], $v['link']['__icon__']);
} else
$icon_url = Base_ThemeCommon::get_template_file($v['module'], 'icon.png');
if (!$icon && !$icon_url) $icon_url = 'cog';
$ii['icon'] = $icon;
$ii['icon_url'] = $icon_url;

if (isset($arr['__url__']))
$ii['open'] = '<a href="' . $arr['__url__'] . '" target="_blank" class="icon-' . ($icon ? $icon : md5($icon_url)) . '">';
else
$ii['open'] = '<a ' . Base_MenuCommon::create_href($this, $arr) . ' class="icon-' . ($icon ? $icon : md5($icon_url)) . '">';
$ii['close'] = '</a>';

if ($ii['label'] == 'Launchpad') {
$launcher_left[] = $ii;
} else {
$launcher_right[] = $ii;
}
}
if (Base_User_SettingsCommon::get(Base_Menu_QuickAccessCommon::module_name(), $v['name'] . '_l')) {
$ii = array();
$trimmed_label = trim(substr(strrchr($v['label'], ':'), 1));
@@ -220,11 +186,33 @@ class Base_ActionBar extends Module
//display
$th = $this->pack_module(Base_Theme::module_name());
$th->assign('icons', $icons);
$th->assign('launcher_right', array_reverse($launcher_right));
$th->assign('launcher_left', array_reverse($launcher_left));
$th->display();
}


public function quickaccess()
{
if(!Base_AclCommon::is_user()) {
return [];
}

$items = array_filter(Base_Menu_QuickAccessCommon::get_options(), function($item) {
return Base_User_SettingsCommon::get(Base_Menu_QuickAccessCommon::module_name(), $item['name'] . '_d');
});

$items = array_map(function($item) {
return [
'href' => Base_MenuCommon::create_href($this, $item['link']),
'icon' => (array_key_exists('fa-' . $item['link']['__icon__'], FontAwesome::get())) ? $item['link']['__icon__'] : null,
'label' => trim(substr(strrchr($item['label'], ':'), 1))?:$item['label'],
'description' => $item['label']
];
}, $items);
return $this->twig_render('quickaccess.twig', ['items' => $items]);

}

}

?>

+ 1
- 14
modules/Base/ActionBar/theme/default.tpl View File

@@ -27,19 +27,6 @@
{/foreach}
</div>

<div class="pull-right">
{foreach item=i from=$launcher_right}
{$i.open}
<div class="btn btn-default">
{if $i.icon_url}
<img src="{$i.icon_url}" style="height:3em">
{else}
<i class="fa fa-{$i.icon} fa-3x"></i>
{/if}
<div>{$i.label}</div>
</div>
{$i.close}
{/foreach}
</div>

</div>


+ 12
- 0
modules/Base/ActionBar/theme/quickaccess.twig View File

@@ -0,0 +1,12 @@
<div class="dropdown d-none d-md-flex">
<a class="nav-link icon" data-toggle="dropdown">
<i class="fa fa-paper-plane"></i>
</a>
<div class="dropdown-menu dropdown-menu-right dropdown-menu-arrow">
{% for item in items %}
<a {{ item.href | raw }} title="{{ item.description }}" class="dropdown-item d-flex">
<span class="mr-3 align-self-center"><span class="fa fa-{{ item.icon|default('home') }}"></span></span>{{ item.label }}
</a>
{% endfor %}
</div>
</div>

+ 2
- 0
modules/Base/Box/Box_0.php View File

@@ -165,6 +165,8 @@ class Base_Box extends Module {
$theme->assign('indicator', $this->init_module(Base_User_Login::module_name())->indicator());
$theme->assign('watchdog', $this->init_module(Utils_Watchdog::module_name())->indicator());
$theme->assign('filter', $this->init_module(CRM_Filters::module_name())->button());
$theme->assign('quickaccess', $this->init_module(Base_ActionBar::module_name())->quickaccess());


$theme->assign('help',Base_MainModuleIndicatorCommon::get_href());
$theme->display();


+ 1
- 0
modules/Base/Box/theme/default.tpl View File

@@ -18,6 +18,7 @@
{/if}
</div>
{$watchdog}
{$quickaccess}
{$filter}
{$indicator}
</div>


+ 0
- 1
modules/Base/Dashboard/Dashboard_0.php View File

@@ -27,7 +27,6 @@ class Base_Dashboard extends Module {
if(Utils_RecordBrowserCommon::check_for_jump()) return;

$this->dashboard();
Base_ActionBarCommon::show_quick_access_shortcuts(true);
}

private function dashboard() {


Loading…
Cancel
Save