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

View File

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

View File

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

View File

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

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()); $mime_type = $this->discovery->discoverMimeType($document->getType());
if (empty($mime_type)) { if ([] === $mime_type) {
return false; return false;
} }
if (array_key_exists('default', $mime_type[0]) foreach ($mime_type as $item) {
&& $mime_type[0]['default'] === 'true' if (array_key_exists('default', $item) && $item['default'] === 'true') {
) { return true;
return true; }
} }
return false; return false;