From 1ba7805e3572df09e4a44fc39115d3b7714084ac Mon Sep 17 00:00:00 2001 From: JhumanJ Date: Fri, 16 May 2025 19:58:53 +0200 Subject: [PATCH] Enhance Form Visibility Logic and UI Components - Updated the `getIsClosedAttribute` method in `Form.php` to include a check for the form's visibility status, ensuring that forms marked as 'closed' are accurately reflected in their state. - Modified `QuillyEditor.vue` to import additional Quill patches for improved functionality. - Changed the alert color from yellow to amber in `OpenCompleteForm.vue` for better visual consistency. - Refactored the form status display in `OpenCompleteForm.vue` and `show.vue` to utilize the new `FormStatusBadges` component, streamlining the UI and improving maintainability. - Enhanced the `FormEditorNavbar.vue` to include icons for better user experience and clarity. These changes aim to improve the accuracy of form visibility handling and enhance the overall user interface across various components. --- api/app/Models/Forms/Form.php | 2 +- .../forms/components/QuillyEditor.vue | 1 + .../open/forms/OpenCompleteForm.vue | 32 ++--- .../forms/components/FormEditorNavbar.vue | 4 +- .../forms/components/FormStatusBadges.vue | 110 ++++++++++++++++++ client/lib/quill/quillPatches.js | 22 ++++ client/pages/forms/[slug]/show.vue | 77 +----------- client/pages/home.vue | 32 ++--- 8 files changed, 170 insertions(+), 110 deletions(-) create mode 100644 client/components/open/forms/components/FormStatusBadges.vue create mode 100644 client/lib/quill/quillPatches.js diff --git a/api/app/Models/Forms/Form.php b/api/app/Models/Forms/Form.php index 42b6f2ec..afecd4b2 100644 --- a/api/app/Models/Forms/Form.php +++ b/api/app/Models/Forms/Form.php @@ -223,7 +223,7 @@ class Form extends Model implements CachableAttributes public function getIsClosedAttribute() { - return $this->closes_at && now()->gt($this->closes_at); + return $this->visibility === 'closed' || ($this->closes_at && now()->gt($this->closes_at)); } public function getFormPendingSubmissionKeyAttribute() diff --git a/client/components/forms/components/QuillyEditor.vue b/client/components/forms/components/QuillyEditor.vue index 94978277..1d0a43f7 100644 --- a/client/components/forms/components/QuillyEditor.vue +++ b/client/components/forms/components/QuillyEditor.vue @@ -8,6 +8,7 @@ \ No newline at end of file diff --git a/client/lib/quill/quillPatches.js b/client/lib/quill/quillPatches.js new file mode 100644 index 00000000..3811237b --- /dev/null +++ b/client/lib/quill/quillPatches.js @@ -0,0 +1,22 @@ +import Quill from 'quill' + +// Self-executing function to patch Quill's prototype +;(function installQuillFixes() { + // Store the original method + const originalGetSemanticHTML = Quill.prototype.getSemanticHTML + + // Override the getSemanticHTML method + Quill.prototype.getSemanticHTML = function(index = 0, length) { + // Call the original method + const html = originalGetSemanticHTML.call(this, index, length || this.getLength()) + + // Apply fixes: + return html + // 1. Replace   with regular spaces + .replace(/ /g, ' ') + // 2. Fix line breaks by replacing empty paragraphs with paragraphs containing
+ .replace(/

<\/p>/g, '


') + } +})() + +export default {} \ No newline at end of file diff --git a/client/pages/forms/[slug]/show.vue b/client/pages/forms/[slug]/show.vue index 3d4d6c24..fc44bdf9 100644 --- a/client/pages/forms/[slug]/show.vue +++ b/client/pages/forms/[slug]/show.vue @@ -78,60 +78,11 @@ - Edited {{ form.last_edited_human }}

-
- - Draft - not publicly accessible - - - Closed - won't accept new submissions - - - {{ tag }} - -
- -

- - This form stopped accepting submissions on the - {{ displayClosesDate }} - - - This form will stop accepting submissions on the - {{ displayClosesDate }} - -

-

- - The form is now closed because it reached its limit of - {{ form.max_submissions_count }} submissions. - - - This form will stop accepting submissions after - {{ form.max_submissions_count }} submissions. - -

+ + formsStore.getByKey(slug)) const workspace = computed(() => workspacesStore.getCurrent) const loading = computed(() => formsStore.loading || workspacesStore.loading) -const displayClosesDate = computed(() => { - if (form.value && form.value.closes_at) { - const dateObj = new Date(form.value.closes_at) - return ( - dateObj.getFullYear() + - "-" + - String(dateObj.getMonth() + 1).padStart(2, "0") + - "-" + - String(dateObj.getDate()).padStart(2, "0") + - " " + - String(dateObj.getHours()).padStart(2, "0") + - ":" + - String(dateObj.getMinutes()).padStart(2, "0") - ) - } - return "" -}) const tabsList = [ { diff --git a/client/pages/home.vue b/client/pages/home.vue index 5d155aae..d3e148f9 100644 --- a/client/pages/home.vue +++ b/client/pages/home.vue @@ -153,30 +153,13 @@ {{ form?.creator?.name }} -
- - Draft - - - Closed - - - {{ tag }} - -
+ + +