Fix review remarks

This commit is contained in:
Mathieu Jaumotte 2022-02-10 17:48:59 +01:00
parent e7a6742964
commit 5a692db30f
5 changed files with 27 additions and 22 deletions

View File

@ -1,4 +1,5 @@
{% import "@ChillDocStore/Macro/macro.html.twig" as m %}
{% import "@ChillDocStore/Macro/macro_mimeicon.html.twig" as mm %}
<div class="flex-table accompanying_course_work-list">
<div class="item-bloc document-item bg-chill-llight-gray">
@ -8,10 +9,11 @@
</div>
<div class="col-8">
<h3>{{ document.title }}</h3>
<small>{{ document.object.type }}</small>
{{ mm.mimeIcon(document.object.type) }}
{% if document.description is not empty %}
<blockquote class="chill-user-quote mt-2">
<blockquote class="chill-user-quote mt-4">
{{ document.description }}
</blockquote>
{% endif %}
@ -36,12 +38,14 @@
{{ m.download_button(document.object, document.title) }}
</li>
<li>
{% if not freezed %}
{{ document.object|chill_document_edit_button({'changeIcon': 'fa-unlock', 'title': document.title|e('html') }) }}
{% else %}
<a class="btn btn-update change-icon disabled" href="#" title="{{ 'workflow.freezed document'|trans }}">
<i class="fa fa-lock me-2"></i>{{ 'Update document'|trans }}
</a>
{% if chill_document_is_editable(document.object) %}
{% if not freezed %}
{{ document.object|chill_document_edit_button({'title': document.title|e('html') }) }}
{% else %}
<a class="btn btn-wopilink disabled" href="#" title="{{ 'workflow.freezed document'|trans }}">
{{ 'Update document'|trans }}
</a>
{% endif %}
{% endif %}
</li>
</ul>

View File

@ -14,7 +14,9 @@
{{ parent() }}
{{ encore_entry_link_tags('mod_async_upload') }}
{{ encore_entry_link_tags('mod_entity_workflow_pick') }}
{#
{{ encore_entry_link_tags('mod_wopi_link') }}
#}
{% endblock %}
{% block content %}
@ -82,5 +84,7 @@
{{ parent() }}
{{ encore_entry_script_tags('mod_async_upload') }}
{{ encore_entry_script_tags('mod_entity_workflow_pick') }}
{#
{{ encore_entry_script_tags('mod_wopi_link') }}
#}
{% endblock %}

View File

@ -36,9 +36,9 @@
mime type and friendly name https://gist.github.com/rosskmurphy/3724501
#}
{% set maptype = {
'fa-file-word-o': 'document/texte',
'fa-file-excel-o': 'document/tableur',
'fa-file-powerpoint-o': 'document/presentation',
'fa-file-word-o': 'office document/texte',
'fa-file-excel-o': 'office document/tableur',
'fa-file-powerpoint-o': 'office document/presentation',
} %}
{% set label = type %}

View File

@ -31,10 +31,7 @@ class WopiEditTwigExtension extends AbstractExtension
public function getFunctions(): array
{
return [
new TwigFunction('chill_document_is_editable', [WopiEditTwigExtensionRuntime::class, 'isEditable'], [
'needs_environment' => true,
'is_safe' => ['html'],
]),
new TwigFunction('chill_document_is_editable', [WopiEditTwigExtensionRuntime::class, 'isEditable']),
];
}

View File

@ -36,18 +36,18 @@ class WopiEditTwigExtensionRuntime implements RuntimeExtensionInterface
]);
}
public function isEditable(Environment $environment, StoredObject $document): bool
public function isEditable(StoredObject $document): bool
{
$mime_type = $this->discovery->discoverMimeType($document->getType());
if (empty($mime_type)) {
if ([] === $mime_type) {
return false;
}
if (array_key_exists('default', $mime_type[0])
&& $mime_type[0]['default'] === 'true'
) {
return true;
foreach ($mime_type as $item) {
if (array_key_exists('default', $item) && $item['default'] === 'true') {
return true;
}
}
return false;