From cd40eb3932bab0be6464ee6839dbb40e7cc0210d Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 6 Feb 2025 12:46:19 +0100 Subject: [PATCH] Turn component into a small vue app and add public private comment logic --- .../ChillActivityBundle/Form/ActivityType.php | 4 +- .../Resources/public/vuejs/Activity/App.vue | 2 +- .../Resources/views/Activity/new.html.twig | 9 +- .../Resources/public/chill/chillmain.scss | 2 + .../public/chill/scss/comment-editor.scss | 14 +++ .../public/vuejs/CommentEditor/App.vue | 36 ++++++++ .../CommentEditor/component/CommentEditor.vue | 89 ++++++++++++++++++ .../public/vuejs/CommentEditor/i18n.js | 14 +++ .../public/vuejs/CommentEditor/index.js | 16 ++++ .../vuejs/_components/CommentEditor.vue | 91 ------------------- .../ChillMainBundle/chill.webpack.config.js | 4 + 11 files changed, 183 insertions(+), 98 deletions(-) create mode 100644 src/Bundle/ChillMainBundle/Resources/public/chill/scss/comment-editor.scss create mode 100644 src/Bundle/ChillMainBundle/Resources/public/vuejs/CommentEditor/App.vue create mode 100644 src/Bundle/ChillMainBundle/Resources/public/vuejs/CommentEditor/component/CommentEditor.vue create mode 100644 src/Bundle/ChillMainBundle/Resources/public/vuejs/CommentEditor/i18n.js create mode 100644 src/Bundle/ChillMainBundle/Resources/public/vuejs/CommentEditor/index.js delete mode 100644 src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/CommentEditor.vue diff --git a/src/Bundle/ChillActivityBundle/Form/ActivityType.php b/src/Bundle/ChillActivityBundle/Form/ActivityType.php index 00570b16f..ae1be5ded 100644 --- a/src/Bundle/ChillActivityBundle/Form/ActivityType.php +++ b/src/Bundle/ChillActivityBundle/Form/ActivityType.php @@ -216,12 +216,12 @@ class ActivityType extends AbstractType ]); }*/ - if ($activityType->isVisible('privateComment')) { +/* if ($activityType->isVisible('privateComment')) { $builder->add('privateComment', PrivateCommentType::class, [ 'label' => '' === $activityType->getLabel('privateComment') ? 'private comment' : $activityType->getPrivateCommentLabel(), 'required' => false, ]); - } + }*/ if ($activityType->isVisible('persons')) { $builder->add('persons', HiddenType::class); diff --git a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/App.vue b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/App.vue index 017f751e0..238065d85 100644 --- a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/App.vue +++ b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/App.vue @@ -9,7 +9,7 @@ import ConcernedGroups from "./components/ConcernedGroups.vue"; import SocialIssuesAcc from "./components/SocialIssuesAcc.vue"; import Location from "./components/Location.vue"; -import CommentEditor from "ChillMainAssets/vuejs/_components/CommentEditor.vue" +import CommentEditor from "ChillMainAssets/vuejs/CommentEditor/component/CommentEditor.vue" export default { name: "App", diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/new.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/new.html.twig index e111c4a50..1f38c7402 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/new.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/new.html.twig @@ -84,11 +84,11 @@ {# {{ form_row(form.comment) }}#} {#{% endif %}#} -
+
-{%- if form.privateComment is defined -%} - {{ form_row(form.privateComment) }} -{% endif %} +{#{%- if form.privateComment is defined -%}#} +{# {{ form_row(form.privateComment) }}#} +{#{% endif %}#} {%- if form.attendee is defined -%} {{ form_row(form.attendee) }} @@ -124,6 +124,7 @@ {% block js %} {{ encore_entry_script_tags('mod_pickentity_type') }} + {{ encore_entry_script_tags('vue_comment_editor') }} {% endblock %} {% block css %} diff --git a/src/Bundle/ChillMainBundle/Resources/public/chill/chillmain.scss b/src/Bundle/ChillMainBundle/Resources/public/chill/chillmain.scss index 1dc56dded..41620a4f1 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/chill/chillmain.scss +++ b/src/Bundle/ChillMainBundle/Resources/public/chill/chillmain.scss @@ -33,6 +33,8 @@ @import './scss/hover.scss'; +@import './scss/comment-editor.scss'; + /* * BASE LAYOUT POSITION */ diff --git a/src/Bundle/ChillMainBundle/Resources/public/chill/scss/comment-editor.scss b/src/Bundle/ChillMainBundle/Resources/public/chill/scss/comment-editor.scss new file mode 100644 index 000000000..05eacd1b1 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Resources/public/chill/scss/comment-editor.scss @@ -0,0 +1,14 @@ +.comment-container { + margin-top: 1.5rem; +} + +.editor-container { + position: relative; + display: flex; + flex-direction: column; + width: 100%; +} + +.editor-wrapper { + position: relative; +} diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/CommentEditor/App.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/CommentEditor/App.vue new file mode 100644 index 000000000..63f659359 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/CommentEditor/App.vue @@ -0,0 +1,36 @@ + + + diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/CommentEditor/component/CommentEditor.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/CommentEditor/component/CommentEditor.vue new file mode 100644 index 000000000..2a3c9d2cd --- /dev/null +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/CommentEditor/component/CommentEditor.vue @@ -0,0 +1,89 @@ + + + + + diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/CommentEditor/i18n.js b/src/Bundle/ChillMainBundle/Resources/public/vuejs/CommentEditor/i18n.js new file mode 100644 index 000000000..6c53020e5 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/CommentEditor/i18n.js @@ -0,0 +1,14 @@ +import {personMessages} from "ChillPersonAssets/vuejs/_js/i18n"; +import {calendarUserSelectorMessages} from "ChillCalendarAssets/vuejs/_components/CalendarUserSelector/js/i18n"; +import {activityMessages} from "ChillActivityAssets/vuejs/Activity/i18n"; + +const appMessages = { + fr: { + comment:{ + label_public: "Note", + label_private: "Note privée", + } + }, +}; + +export { appMessages }; diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/CommentEditor/index.js b/src/Bundle/ChillMainBundle/Resources/public/vuejs/CommentEditor/index.js new file mode 100644 index 000000000..41106ee65 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/CommentEditor/index.js @@ -0,0 +1,16 @@ +import { createApp } from "vue"; +import App from "./App.vue"; +import {_createI18n} from "ChillMainAssets/vuejs/_js/i18n"; +import {appMessages} from "ChillMainAssets/vuejs/CommentEditor/i18n"; + +const i18n = _createI18n(appMessages); +const commentContainer = document.getElementById('comment-widget'); + +const commentMode = commentContainer.dataset.commentMode; + +const app = createApp({ + template: ``, +}, { commentMode }) + .use(i18n) + .component("app", App) + .mount("#comment-widget"); diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/CommentEditor.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/CommentEditor.vue deleted file mode 100644 index 021dcef34..000000000 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/CommentEditor.vue +++ /dev/null @@ -1,91 +0,0 @@ - - - - - diff --git a/src/Bundle/ChillMainBundle/chill.webpack.config.js b/src/Bundle/ChillMainBundle/chill.webpack.config.js index 88b537932..cc8761b25 100644 --- a/src/Bundle/ChillMainBundle/chill.webpack.config.js +++ b/src/Bundle/ChillMainBundle/chill.webpack.config.js @@ -120,4 +120,8 @@ module.exports = function (encore, entries) { "vue_onthefly", __dirname + "/Resources/public/vuejs/OnTheFly/index.js", ); + encore.addEntry( + "vue_comment_editor", + __dirname + "/Resources/public/vuejs/CommentEditor/index.js", + ); };