Merge pull request #3073 from jygaulier/PHRAS-2628_toolbar-plugin_4.1

PHRAS-2628 #comment merge toolbar-plugin_4.1
This commit is contained in:
Nicolas Maillat
2019-06-13 17:10:04 +02:00
committed by GitHub
2 changed files with 31 additions and 13 deletions

View File

@@ -20,6 +20,8 @@ use Alchemy\Phrasea\Model\Repositories\FeedRepository;
use Symfony\Component\Finder\Finder; use Symfony\Component\Finder\Finder;
use Symfony\Component\Finder\SplFileInfo; use Symfony\Component\Finder\SplFileInfo;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
// use Alchemy\Phrasea\Plugin\ActionBarPluginInterface;
class RootController extends Controller class RootController extends Controller
{ {
@@ -85,6 +87,22 @@ class RootController extends Controller
/** @var \Closure $filter */ /** @var \Closure $filter */
$filter = $this->app['plugin.filter_by_authorization']; $filter = $this->app['plugin.filter_by_authorization'];
/* prepare work to extend whole taskbar... later
$menus = [
'push' => ['native'=>true, 'n'=>0],
'tools' => ['native'=>true, 'n'=>0],
];
/ ** @var ActionBarPluginInterface $plugin * /
foreach($filter('actionbar') as $kplugin=>$plugin) {
foreach($plugin->getActionBar() as $kmenu=>$menu) {
if(!array_key_exists($kmenu, $menus)) {
$menus[$kmenu] = ['native'=>false, 'n'=>0];
}
$menus[$kmenu]['n']++;
}
}
*/
$plugins = [ $plugins = [
'workzone' => $filter('workzone'), 'workzone' => $filter('workzone'),
'actionbar' => $filter('actionbar'), 'actionbar' => $filter('actionbar'),

View File

@@ -166,9 +166,7 @@
{% if action.icon %} {% if action.icon %}
<img src="{{ plugin_asset(plugin.PluginName, action.icon) }}" height="16" width="16" class="btn-image"/> <img src="{{ plugin_asset(plugin.PluginName, action.icon) }}" height="16" width="16" class="btn-image"/>
{% endif %} {% endif %}
{{ action.label|trans({}, plugin.PluginLocale) }}
{% set label = action.label %}
{% trans from plugin.PluginLocale %}label{% endtrans %}
</a> </a>
</li> </li>
{% endfor %} {% endfor %}
@@ -201,9 +199,7 @@
{% if action.icon %} {% if action.icon %}
<img src="{{ plugin_asset(plugin.PluginName, action.icon) }}" height="16" width="16" class="btn-image"/> <img src="{{ plugin_asset(plugin.PluginName, action.icon) }}" height="16" width="16" class="btn-image"/>
{% endif %} {% endif %}
{{ action.label|trans({}, plugin.PluginLocale) }}
{% set label = action.label %}
{% trans from plugin.PluginLocale %}label{% endtrans %}
</a> </a>
</li> </li>
{% endfor %} {% endfor %}
@@ -237,9 +233,7 @@
<img src="{{ plugin_asset(plugin.PluginName, action.icon) }}" <img src="{{ plugin_asset(plugin.PluginName, action.icon) }}"
height="16" width="16" class="btn-image"/> height="16" width="16" class="btn-image"/>
{% endif %} {% endif %}
{{ action.label|trans({}, plugin.PluginLocale) }}
{% set label = action.label %}
{% trans from plugin.PluginLocale %}label{% endtrans %}
</a> </a>
</li> </li>
{% endfor %} {% endfor %}
@@ -260,8 +254,7 @@
{% if action.icon %} {% if action.icon %}
<img src="{{ plugin_asset(plugin.PluginName, action.icon) }}" height="16" width="16"/> <img src="{{ plugin_asset(plugin.PluginName, action.icon) }}" height="16" width="16"/>
{% endif %} {% endif %}
{% set label = action.label %} {{ action.label|trans({}, plugin.PluginLocale) }}
{% trans from plugin.PluginLocale %}label{% endtrans %}
</a> </a>
</button> </button>
{% if not (loop.last and loop.parent.loop.last) %} {% if not (loop.last and loop.parent.loop.last) %}
@@ -275,8 +268,7 @@
{% if action.icon %} {% if action.icon %}
<img src="{{ plugin_asset(plugin.PluginName, action.icon) }}" height="16" width="16" class="btn-image"/> <img src="{{ plugin_asset(plugin.PluginName, action.icon) }}" height="16" width="16" class="btn-image"/>
{% endif %} {% endif %}
{% set label = action.label %} {{ action.label|trans({}, plugin.PluginLocale) }}
{% trans from plugin.PluginLocale %}label{% endtrans %}
</a> </a>
</li> </li>
{% else %} {% else %}
@@ -311,3 +303,11 @@
</span> </span>
{% endif %} {% endif %}
{% endblock %} {% endblock %}
{% block toolbarJS %}
{% if plugins.actionbar is not empty %}
{% for plugin in plugins.actionbar %}
{{ (plugin.JS|default(''))|raw }}
{% endfor %}
{% endif %}
{% endblock %}