diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/new.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/new.html.twig index 1f38c7402..8117ec0ce 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/new.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/new.html.twig @@ -84,8 +84,15 @@ {# {{ form_row(form.comment) }}#} {#{% endif %}#} -
+
+ +
+
+
+ +
+
{#{%- if form.privateComment is defined -%}#} {# {{ form_row(form.privateComment) }}#} {#{% endif %}#} diff --git a/src/Bundle/ChillMainBundle/Resources/public/chill/scss/comment-editor.scss b/src/Bundle/ChillMainBundle/Resources/public/chill/scss/comment-editor.scss index 05eacd1b1..e30326e48 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/chill/scss/comment-editor.scss +++ b/src/Bundle/ChillMainBundle/Resources/public/chill/scss/comment-editor.scss @@ -2,6 +2,20 @@ margin-top: 1.5rem; } +.toggle-button { + position: absolute; + bottom: -10px; + left: 10px; + padding: 2px 6px; + cursor: pointer; + z-index: 10; +} + +.editor-wrapper textarea { + resize: vertical; + min-height: 100px; +} + .editor-container { position: relative; display: flex; diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/CommentEditor/App.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/CommentEditor/App.vue index 63f659359..dfec5af1b 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/CommentEditor/App.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/CommentEditor/App.vue @@ -1,36 +1,29 @@ diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/CommentEditor/component/CommentEditor.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/CommentEditor/component/CommentEditor.vue index 2a3c9d2cd..9e6b3400f 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/CommentEditor/component/CommentEditor.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/CommentEditor/component/CommentEditor.vue @@ -16,74 +16,46 @@ class="form-control" > - {{ buttonText }} + {{ isSimple ? $t("mode.rich") : $t("mode.simple") }} diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/CommentEditor/i18n.js b/src/Bundle/ChillMainBundle/Resources/public/vuejs/CommentEditor/i18n.js index 6c53020e5..93a03a665 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/CommentEditor/i18n.js +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/CommentEditor/i18n.js @@ -4,9 +4,9 @@ import {activityMessages} from "ChillActivityAssets/vuejs/Activity/i18n"; const appMessages = { fr: { - comment:{ - label_public: "Note", - label_private: "Note privée", + mode: { + simple: "Editeur simple", + rich: "Editeur riche" } }, }; diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/CommentEditor/index.js b/src/Bundle/ChillMainBundle/Resources/public/vuejs/CommentEditor/index.js index 41106ee65..033d3cd41 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/CommentEditor/index.js +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/CommentEditor/index.js @@ -1,16 +1,29 @@ -import { createApp } from "vue"; +import { createApp, reactive } from "vue"; import App from "./App.vue"; import {_createI18n} from "ChillMainAssets/vuejs/_js/i18n"; -import {appMessages} from "ChillMainAssets/vuejs/CommentEditor/i18n"; +import { appMessages } from "ChillMainAssets/vuejs/CommentEditor/i18n"; const i18n = _createI18n(appMessages); -const commentContainer = document.getElementById('comment-widget'); -const commentMode = commentContainer.dataset.commentMode; +// Global reactive state to handle editorMode +const globalState = reactive({ + isSimple: localStorage.getItem('editorMode') === 'simple' +}); -const app = createApp({ - template: ``, -}, { commentMode }) - .use(i18n) - .component("app", App) - .mount("#comment-widget"); +// Watch for changes to `localStorage` and update the state +window.addEventListener('storage', () => { + globalState.isSimple = localStorage.getItem('editorMode') === 'simple'; +}); + +const commentWidgets = document.querySelectorAll('[id^="comment-widget"]'); +commentWidgets.forEach((commentContainer) => { + const app = createApp({ + template: `` + }); + + // Pass the global state to each app instance + app.use(i18n) + .provide('globalState', globalState) // Provide global state to components + .component("app", App) + .mount(commentContainer); +}); diff --git a/src/Bundle/ChillMainBundle/translations/messages.fr.yml b/src/Bundle/ChillMainBundle/translations/messages.fr.yml index 26631b3ed..428948a26 100644 --- a/src/Bundle/ChillMainBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillMainBundle/translations/messages.fr.yml @@ -109,6 +109,8 @@ Any comment: Aucun commentaire # comment embeddable No comment associated: Aucun commentaire private comment: Notes privées +comment_public: Note +comment_private: Note privée #pagination Previous: Précédent