Commit 1b6c5878 authored by MARCO Jonathan's avatar MARCO Jonathan
Browse files

Add an option hasPreviewButton in the plugin install to hide the

preview button

📝 Add this option in the doc
parent 72116449
......@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: formbuilder plugin 0.1\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-09-21 16:34+0200\n"
"POT-Creation-Date: 2021-10-12 09:47+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
......@@ -33,17 +33,17 @@ msgid "If you customize the color in Vuetify, you can define if your primary col
msgstr ""
#: ../../configuration/options.rst:27
#: ../../configuration/options.rst:55
#: ../../configuration/options.rst:56
msgid "option"
msgstr ""
#: ../../configuration/options.rst:27
#: ../../configuration/options.rst:55
#: ../../configuration/options.rst:56
msgid "type"
msgstr ""
#: ../../configuration/options.rst:27
#: ../../configuration/options.rst:55
#: ../../configuration/options.rst:56
msgid "default"
msgstr ""
......@@ -53,7 +53,7 @@ msgstr ""
#: ../../configuration/options.rst:29
#: ../../configuration/options.rst:31
#: ../../configuration/options.rst:57
#: ../../configuration/options.rst:58
msgid "boolean"
msgstr ""
......@@ -75,13 +75,17 @@ msgid "In the builder component you have a \"preview button\". This button displ
msgstr ""
#: ../../configuration/options.rst:38
msgid "The option ``previewIsSave`` set if this button save the form before the displaying or not."
msgid "The option ``previewIsSave`` set if this button saves the form before the displaying or not."
msgstr ""
#: ../../configuration/options.rst:57
#: ../../configuration/options.rst:39
msgid "The option ``hasPreviewButton`` defines if the button is displayed or not."
msgstr ""
#: ../../configuration/options.rst:58
msgid "previewIsSave"
msgstr ""
#: ../../configuration/options.rst:57
#: ../../configuration/options.rst:58
msgid "true"
msgstr ""
......@@ -35,7 +35,8 @@ Preview button action
---------------------
| In the builder component you have a "preview button". This button displays the form as if the user where using it.
| The option ``previewIsSave`` set if this button save the form before the displaying or not.
| The option ``previewIsSave`` set if this button saves the form before the displaying or not.
| The option ``hasPreviewButton`` defines if the button is displayed or not.
.. code-block:: javascript
......
......@@ -9,7 +9,7 @@ msgid ""
msgstr ""
"Project-Id-Version: formbuilder plugin 0.1\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-09-21 16:34+0200\n"
"POT-Creation-Date: 2021-10-12 09:47+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
......@@ -37,65 +37,70 @@ msgid ""
"the font color is the white, or if the color is light, the font color is "
"the black."
msgstr ""
"Si vous personnalisez les couleurs de Vuetify, vous pouvez définir si la couleur primaire "
"ou la couleur secondaire sont claire ou foncée. Si la couleur est foncée, "
"le text sera en blanc, et si la couleur est claire, le text sera "
"en noir."
"Si vous personnalisez les couleurs de Vuetify, vous pouvez définir si la "
"couleur primaire ou la couleur secondaire sont claire ou foncée. Si la "
"couleur est foncée, le text sera en blanc, et si la couleur est claire, "
"le text sera en noir."
#: ../../configuration/options.rst:26 ../../configuration/options.rst:53
#: ../../configuration/options.rst:27 ../../configuration/options.rst:56
msgid "option"
msgstr ""
#: ../../configuration/options.rst:26 ../../configuration/options.rst:53
#: ../../configuration/options.rst:27 ../../configuration/options.rst:56
msgid "type"
msgstr ""
#: ../../configuration/options.rst:26 ../../configuration/options.rst:53
#: ../../configuration/options.rst:27 ../../configuration/options.rst:56
msgid "default"
msgstr "défaut"
#: ../../configuration/options.rst:28
#: ../../configuration/options.rst:29
msgid "primaryIsDark"
msgstr ""
#: ../../configuration/options.rst:28 ../../configuration/options.rst:30
#: ../../configuration/options.rst:55
#: ../../configuration/options.rst:29 ../../configuration/options.rst:31
#: ../../configuration/options.rst:58
msgid "boolean"
msgstr ""
#: ../../configuration/options.rst:28 ../../configuration/options.rst:30
#: ../../configuration/options.rst:29 ../../configuration/options.rst:31
msgid "false"
msgstr ""
#: ../../configuration/options.rst:30
#: ../../configuration/options.rst:31
msgid "secondaryIsDark"
msgstr ""
#: ../../configuration/options.rst:34
#: ../../configuration/options.rst:35
msgid "Preview button action"
msgstr "Bouton \"Prévisualisation\""
#: ../../configuration/options.rst:36
#: ../../configuration/options.rst:37
msgid ""
"In the builder component you have a \"preview button\". This button "
"displays the form as if the user where using it."
msgstr ""
"Dans l'interface de construction on retrouve un bouton de prévisualisation. Ce bouton "
"affiche le formulaire quand on clique dessus."
"Dans l'interface de construction on retrouve un bouton de "
"prévisualisation. Ce bouton affiche le formulaire quand on clique dessus."
#: ../../configuration/options.rst:37
#: ../../configuration/options.rst:38
msgid ""
"The option ``previewIsSave`` set if this button save the form before the "
"displaying or not."
"The option ``previewIsSave`` set if this button saves the form before the"
" displaying or not."
msgstr ""
"L'option ``previewIsSave`` modifie si ce bouton sauvegarde le formulaire "
"avant de l'afficher ou non."
#: ../../configuration/options.rst:39
msgid "The option ``hasPreviewButton`` defines if the button is displayed or not."
msgstr ""
"L'option ``previewIsSave`` modifie si ce bouton sauvegarde le formulaire avant "
"de l'afficher ou non."
"L'option ``hasPreviewButton`` modifie si ce bouton est affiché ou non."
#: ../../configuration/options.rst:55
#: ../../configuration/options.rst:58
msgid "previewIsSave"
msgstr ""
#: ../../configuration/options.rst:55
#: ../../configuration/options.rst:58
msgid "true"
msgstr ""
<template>
<div id="UsfActionButtonsContainer">
<v-tooltip bottom v-if="previewIsSave || !hasFields">
<template v-slot:activator="{on, attrs}">
<div v-on="on" :class="{save_disabled: !hasFields}">
<v-btn
v-bind="attrs"
outlined
block
small
tile
color="primary"
:disabled="!hasFields"
>
{{ _uct('builder.actionButtons.preview') }}
<v-icon right>mdi-tooltip-image</v-icon>
</v-btn>
</div>
</template>
<span v-if="hasFields">{{ _uct('builder.actionButtons.previewInfo') }}</span>
<span v-else>{{ _uct('builder.actionButtons.previewDisabled') }}</span>
</v-tooltip>
<div v-if="hasPreviewButton">
<v-tooltip bottom v-if="previewIsSave || !hasFields">
<template v-slot:activator="{on, attrs}">
<div v-on="on" :class="{save_disabled: !hasFields}">
<v-btn
v-bind="attrs"
outlined
block
small
tile
color="primary"
:disabled="!hasFields"
>
{{ _uct('builder.actionButtons.preview') }}
<v-icon right>mdi-tooltip-image</v-icon>
</v-btn>
</div>
</template>
<span v-if="hasFields">{{ _uct('builder.actionButtons.previewInfo') }}</span>
<span v-else>{{ _uct('builder.actionButtons.previewDisabled') }}</span>
</v-tooltip>
<v-btn
v-else
outlined
block
small
tile
color="primary"
@click.stop="$emit('preview', { fields: denormalizedFields, messages })"
>
{{ _uct('builder.actionButtons.preview') }}{{ !hasFields }}
<v-icon right>mdi-tooltip-image</v-icon>
</v-btn>
</div>
<v-btn
v-else
outlined
block
small
tile
color="primary"
@click.stop="$emit('preview', { fields: denormalizedFields, messages })"
>
{{ _uct('builder.actionButtons.preview') }}{{ !hasFields }}
<v-icon right>mdi-tooltip-image</v-icon>
</v-btn>
<v-btn
outlined
block
......
import {UsfBuilder, UsfRenderer} from './components';
import pluginStore, {modules} from './store';
import {fr} from './locales/fr';
import {PluginFunction} from 'vue';
import {AppMessages, installOptions} from '#form-plugin/index';
import { UsfBuilder, UsfRenderer } from './components';
import pluginStore, { modules } from './store';
import { fr } from './locales/fr';
import { PluginFunction } from 'vue';
import { AppMessages, installOptions } from '#form-plugin/index';
const components = {UsfBuilder, UsfRenderer};
const components = { UsfBuilder, UsfRenderer };
let messages: AppMessages = {fr};
let messages: AppMessages = { fr };
let locale = 'fr';
let installed: boolean = false;
// TODO: la langue ne change pas automatiquement voir pour le faire évoluer.
const install: PluginFunction<installOptions> = (
Vue,
{store, internationalization, options, customFields},
{ store, internationalization, options, customFields },
) => {
if (installed) return;
if (!store) throw new Error('You must provide a vuex store.');
......@@ -64,14 +64,17 @@ const install: PluginFunction<installOptions> = (
Vue.mixin({
computed: {
hasPreviewButton(): boolean {
return options && options.hasPreviewButton ? options.hasPreviewButton : true;
},
previewIsSave(): boolean {
return options ? options.previewIsSave : true;
return options && options.previewIsSave ? options.previewIsSave : true;
},
primaryIsDark(): boolean {
return options ? options.primaryIsDark : false;
return options && options.primaryIsDark ? options.primaryIsDark : false;
},
secondaryIsDark(): boolean {
return options ? options.secondaryIsDark : false;
return options && options.secondaryIsDark ? options.secondaryIsDark : false;
},
},
......
......@@ -16,9 +16,10 @@ interface installOptions {
messages?: AppMessages;
};
options?: {
hasPreviewButton?: boolean;
previewIsSave?: boolean;
primaryIsDark?: boolean;
secondaryIsDark?: boolean;
previewIsSave?: boolean;
};
customFields?: {
components?: Record<string, VueConstructor<Vue>>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment