OpenWopiLink, option title is maintened (replace button by options)

This commit is contained in:
Mathieu Jaumotte 2022-02-09 18:04:12 +01:00
parent 3ffeaf419a
commit e7a6742964
4 changed files with 15 additions and 35 deletions

View File

@ -37,20 +37,7 @@
</li> </li>
<li> <li>
{% if not freezed %} {% if not freezed %}
{% set button = { {{ document.object|chill_document_edit_button({'changeIcon': 'fa-unlock', 'title': document.title|e('html') }) }}
'changeIcon': 'fa-unlock',
} %}{#
'changeClass' string
'noText' boolean
#}
{# vue component #}
<span
data-module="wopi-link"
data-wopi-url="{{ path('chill_wopi_file_edit', {'fileId': document.object.uuid}) }}"
data-doc-title="{{ document.title|e('html_attr') }}"
data-doc-type="{{ document.object.type|e('html_attr') }}"
data-button="{{ button|json_encode }}"
></span>
{% else %} {% else %}
<a class="btn btn-update change-icon disabled" href="#" title="{{ 'workflow.freezed document'|trans }}"> <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 }} <i class="fa fa-lock me-2"></i>{{ 'Update document'|trans }}

View File

@ -2,13 +2,11 @@
<span data-module="wopi-link" <span data-module="wopi-link"
data-wopi-url="{{ path('chill_wopi_file_edit', {'fileId': document.uuid}) }}" data-wopi-url="{{ path('chill_wopi_file_edit', {'fileId': document.uuid}) }}"
data-doc-type="{{ document.type|e('html_attr') }}" data-doc-type="{{ document.type|e('html_attr') }}"
data-button="{{ options|json_encode }}" data-options="{{ options|json_encode }}"
></span> ></span>
{{ chill_path_add_return_path('chill_wopi_file_edit', {'fileId': document.uuid}) }}
#} #}
{# Twig way, {# Twig way
TODO: une route, un template avec un header CHILL et un iframe TODO: une route, un template avec un header CHILL et un iframe
#} #}
<a href="{{ chill_path_add_return_path('chill_wopi_file_edit', {'fileId': document.uuid}) }}" <a href="{{ chill_path_add_return_path('chill_wopi_file_edit', {'fileId': document.uuid}) }}"

View File

@ -8,16 +8,15 @@ window.addEventListener('DOMContentLoaded', function (e) {
document.querySelectorAll('span[data-module="wopi-link"]') document.querySelectorAll('span[data-module="wopi-link"]')
.forEach(function (el) { .forEach(function (el) {
createApp({ createApp({
template: '<open-wopi-link :wopiUrl="wopiUrl" :title="title" :type="type" :button="button"></open-wopi-link>', template: '<open-wopi-link :wopiUrl="wopiUrl" :type="type" :options="options"></open-wopi-link>',
components: { components: {
OpenWopiLink OpenWopiLink
}, },
data() { data() {
return { return {
wopiUrl: el.dataset.wopiUrl, wopiUrl: el.dataset.wopiUrl,
title: el.dataset.docTitle,
type: el.dataset.docType, type: el.dataset.docType,
button: el.dataset.button !== 'null' ? JSON.parse(el.dataset.button) : {} options: el.dataset.options !== 'null' ? JSON.parse(el.dataset.options) : {}
} }
} }
}) })

View File

@ -2,10 +2,10 @@
<a v-if="isOpenDocument" <a v-if="isOpenDocument"
class="btn" :class="[ class="btn" :class="[
isChangeIcon ? 'change-icon' : '', isChangeIcon ? 'change-icon' : '',
isChangeClass ? button.changeClass : 'btn-wopilink' ]" isChangeClass ? options.changeClass : 'btn-wopilink' ]"
@click="openModal"> @click="openModal">
<i v-if="isChangeIcon" class="fa me-2" :class="button.changeIcon"></i> <i v-if="isChangeIcon" class="fa me-2" :class="options.changeIcon"></i>
<span v-if="!noText"> <span v-if="!noText">
{{ $t('online_edit_document') }} {{ $t('online_edit_document') }}
@ -22,7 +22,7 @@
<template v-slot:header> <template v-slot:header>
<img class="logo" :src="logo" height="45"/> <img class="logo" :src="logo" height="45"/>
<span class="ms-auto me-3"> <span class="ms-auto me-3">
<span v-if="title">{{ title }}</span> <span v-if="options.title">{{ options.title }}</span>
</span> </span>
<!-- <!--
<a class="btn btn-outline-light"> <a class="btn btn-outline-light">
@ -75,15 +75,11 @@ export default {
type: String, type: String,
required: true required: true
}, },
title: {
type: String,
required: false
},
type: { type: {
type: String, type: String,
required: true required: true
}, },
button: { options: {
type: Object, type: Object,
required: false required: false
} }
@ -179,20 +175,20 @@ export default {
return false; return false;
}, },
noText() { noText() {
if (typeof this.button.noText !== 'undefined') { if (typeof this.options.noText !== 'undefined') {
return this.button.noText === true; return this.options.noText === true;
} }
return false; return false;
}, },
isChangeIcon() { isChangeIcon() {
if (typeof this.button.changeIcon !== 'undefined') { if (typeof this.options.changeIcon !== 'undefined') {
return (!(this.button.changeIcon === null || this.button.changeIcon === '')) return (!(this.options.changeIcon === null || this.options.changeIcon === ''))
} }
return false; return false;
}, },
isChangeClass() { isChangeClass() {
if (typeof this.button.changeClass !== 'undefined') { if (typeof this.options.changeClass !== 'undefined') {
return (!(this.button.changeClass === null || this.button.changeClass === '')) return (!(this.options.changeClass === null || this.options.changeClass === ''))
} }
return false; return false;
} }