From c7144dd61902906142fce26b1861244627b82884 Mon Sep 17 00:00:00 2001 From: Afan Ajdari Date: Tue, 28 May 2024 10:49:30 +0200 Subject: [PATCH 1/3] Laravel to v11 & Statamic to v5 --- resources/sites.yaml | 4 ++++ starter-kit.yaml | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 resources/sites.yaml diff --git a/resources/sites.yaml b/resources/sites.yaml new file mode 100644 index 0000000..1c40c4a --- /dev/null +++ b/resources/sites.yaml @@ -0,0 +1,4 @@ +default: + name: '{{ config:app:name }}' + locale: en_US + url: / diff --git a/starter-kit.yaml b/starter-kit.yaml index 47be1c5..1605978 100644 --- a/starter-kit.yaml +++ b/starter-kit.yaml @@ -9,6 +9,7 @@ export_paths: - content/collections/pages/employment-application.md - config/statamic/assets.php - config/statamic/protect.php + - resources/sites.yaml - resources/forms/employment_application.yaml - resources/fieldsets - resources/blueprints/globals/formatic.yaml @@ -29,4 +30,4 @@ export_paths: - README.md dependencies: marcorieser/tailwind-merge-statamic: ^1.1.0 - stillat/antlers-components: ^2.0 + stillat/antlers-components: ^2.2.0 From 615f9b597c360ed86f2631c815473f68a16a1fb7 Mon Sep 17 00:00:00 2001 From: Afan Ajdari Date: Tue, 28 May 2024 10:51:56 +0200 Subject: [PATCH 2/3] Made the success message duration dynamic and configurable from CP --- .../collections/pages/formatic.yaml | 139 ++---------------- resources/js/form/Formatic.js | 12 +- .../views/partials/sets/formatic.antlers.html | 18 +-- 3 files changed, 30 insertions(+), 139 deletions(-) diff --git a/resources/blueprints/collections/pages/formatic.yaml b/resources/blueprints/collections/pages/formatic.yaml index ee4cb55..b59691d 100644 --- a/resources/blueprints/collections/pages/formatic.yaml +++ b/resources/blueprints/collections/pages/formatic.yaml @@ -13,24 +13,12 @@ tabs: validate: - required display: 'Page Header' - instructions_position: above - listable: hidden - visibility: visible - input_type: text - antlers: false - hide_display: false - handle: page_description field: - antlers: false type: textarea display: 'Page Description' - icon: textarea instructions: 'Displayed under the title' - listable: hidden - instructions_position: above - visibility: visible - hide_display: false - display: 'Form Builder' fields: @@ -46,44 +34,24 @@ tabs: handle: logo field: max_files: 1 - mode: list container: assets - restrict: false - allow_uploads: true - show_filename: true - show_set_alt: true type: assets display: 'Logo Light' - icon: assets instructions: |- The light version of the Logo. It is displayed above the title. width: 50 - listable: hidden - instructions_position: above - visibility: visible - hide_display: false - handle: logo_dark field: max_files: 1 - mode: list container: assets - restrict: false - allow_uploads: true - show_filename: true - show_set_alt: true type: assets display: 'Logo Dark' - icon: assets instructions: |- The dark version of the Logo. It is displayed above the title. width: 50 - listable: hidden - instructions_position: above - visibility: visible - hide_display: false - handle: logo_size field: @@ -94,11 +62,6 @@ tabs: default: medium type: button_group display: 'Logo Size' - icon: button_group - listable: hidden - instructions_position: above - visibility: visible - hide_display: false - handle: theme_color field: @@ -119,12 +82,7 @@ tabs: default: '#e11d48' type: color display: 'Theme Color' - icon: color width: 25 - listable: hidden - instructions_position: above - visibility: visible - hide_display: false - handle: theme_radius field: @@ -137,13 +95,8 @@ tabs: default: 0.5rem type: button_group display: Radius - icon: button_group instructions: 'The border radius of the elements.' width: 75 - listable: hidden - instructions_position: above - visibility: visible - hide_display: false - display: Settings fields: @@ -153,13 +106,8 @@ tabs: default: true type: toggle display: 'Darkmode Toggle' - icon: toggle instructions: 'Enable or Disable the Darkmode Toggle.' width: 50 - listable: hidden - instructions_position: above - visibility: visible - hide_display: false - handle: theme_mode field: @@ -169,12 +117,7 @@ tabs: auto: Auto type: button_group display: 'Theme Mode' - icon: button_group instructions: 'Auto will respect the users preference.' - listable: hidden - instructions_position: above - visibility: visible - hide_display: false if: darkmode_toggle: 'equals false' - @@ -187,62 +130,33 @@ tabs: default: medium type: button_group display: 'Form Size' - icon: button_group width: 50 - listable: hidden - instructions_position: above - visibility: visible - hide_display: false - handle: required_fields_text field: - input_type: text default: '* Required fields' - antlers: false type: text display: 'Required Fields Text' - icon: text width: 50 - listable: hidden - instructions_position: above - visibility: visible - hide_display: false - handle: protect_spacer field: type: spacer display: 'Protect Spacer' - icon: width - listable: hidden - instructions_position: above - visibility: visible - hide_display: false - handle: protected_page field: - default: false type: toggle display: 'Protected Page' - icon: toggle width: 33 - listable: hidden - instructions_position: above - visibility: visible - hide_display: false - handle: protect field: - input_type: text default: password - antlers: false type: text display: Protect - icon: text width: 66 - listable: hidden - instructions_position: above visibility: read_only - hide_display: false if: protected_page: 'equals true' - @@ -257,25 +171,26 @@ tabs: default: thankyou_page type: button_group display: 'Submit Options' - icon: button_group instructions: 'Choose what to do after the Form is submitted.' - listable: hidden - instructions_position: above - visibility: visible - hide_display: false + width: 50 + - + handle: success_message_duration + field: + min: 1 + default: 4 + type: range + display: 'Success Message Duration' + instructions: 'The duration (in seconds) for which the success message remains visible after form submission.' + width: 50 + if: + submit_options: 'equals thankyou_page' + max: 10 - handle: submit_title field: - input_type: text default: 'Thank you. Your form is submitted.' - antlers: false type: text display: 'Submit Title' - icon: text - listable: hidden - instructions_position: above - visibility: visible - hide_display: false validate: - 'required_if:submit_options,thankyou_page' if: @@ -291,46 +206,19 @@ tabs: - removeformat - quote - anchor - smart_typography: false - save_html: false - inline: false - toolbar_mode: fixed - reading_time: false - word_count: false - fullscreen: true allow_source: false - enable_input_rules: true - enable_paste_rules: true remove_empty_nodes: false - antlers: false - link_noopener: false - link_noreferrer: false - target_blank: false - always_show_set_button: false - collapse: false - previews: true type: bard display: 'Submit Description' - icon: bard - listable: hidden - instructions_position: above - visibility: visible - hide_display: false if: submit_options: 'equals thankyou_page' - handle: page_redirect_url field: input_type: url - antlers: false type: text display: 'Redirect URL' - icon: text - listable: hidden - instructions_position: above - visibility: visible duplicate: false - hide_display: false if: submit_options: 'equals page_redirect' validate: @@ -345,6 +233,7 @@ tabs: field: type: slug localizable: true + validate: 'max:200' - handle: parent field: diff --git a/resources/js/form/Formatic.js b/resources/js/form/Formatic.js index eae2055..b2dc078 100644 --- a/resources/js/form/Formatic.js +++ b/resources/js/form/Formatic.js @@ -2,6 +2,7 @@ export const Formatic = () => ({ steps: [], currentStep: 1, redirect_url: null, + success_message_duration: 4, submit_url: null, success: false, form: "", @@ -57,17 +58,18 @@ export const Formatic = () => ({ this.form.errors = {}; this.success = true; - setTimeout(() => { + if (this.redirect_url) { this.success = false; + return (window.location.href = this.redirect_url); + } - if (this.redirect_url) { - window.location.href = this.redirect_url; - } + setTimeout(() => { + this.success = false; if (this.isMultiStep()) { location.reload(); } - }, 1000); + }, this.success_message_duration * 1000); } } catch (error) { if (error.response && error.response.data.errors) { diff --git a/resources/views/partials/sets/formatic.antlers.html b/resources/views/partials/sets/formatic.antlers.html index 61c166e..9d8b2e7 100644 --- a/resources/views/partials/sets/formatic.antlers.html +++ b/resources/views/partials/sets/formatic.antlers.html @@ -1,8 +1,8 @@ {{ form:create :in="selected_form:handle" js="alpine:form" attr:x-ref="form" files="true" }} -
- + {{ else }} + + {{ /if }}
{{ /form:create }} -
+ \ No newline at end of file From 79adfdc007cc98ff6585b8c2d81ff637d842e350 Mon Sep 17 00:00:00 2001 From: Afan Ajdari Date: Tue, 28 May 2024 10:52:26 +0200 Subject: [PATCH 3/3] Update forms --- .../pages/employment-application.md | 1 + public/build/assets/site-77a4b0d4.js | 26 +++++++++++++++++++ public/build/manifest.json | 2 +- 3 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 public/build/assets/site-77a4b0d4.js diff --git a/content/collections/pages/employment-application.md b/content/collections/pages/employment-application.md index e5db729..000e2bc 100644 --- a/content/collections/pages/employment-application.md +++ b/content/collections/pages/employment-application.md @@ -19,6 +19,7 @@ required_fields_text: '* Required fields' protected_page: false submit_options: thankyou_page submit_title: 'Thank you. Your form is submitted.' +success_message_duration: 4 updated_by: c4788818-bedf-422a-ad20-bc93b90731e8 updated_at: 1695393851 --- diff --git a/public/build/assets/site-77a4b0d4.js b/public/build/assets/site-77a4b0d4.js new file mode 100644 index 0000000..e9231d0 --- /dev/null +++ b/public/build/assets/site-77a4b0d4.js @@ -0,0 +1,26 @@ +var ga=!1,ma=!1,Dn=[],ba=-1;function Zc(e){Qc(e)}function Qc(e){Dn.includes(e)||Dn.push(e),el()}function Ms(e){let n=Dn.indexOf(e);n!==-1&&n>ba&&Dn.splice(n,1)}function el(){!ma&&!ga&&(ga=!0,queueMicrotask(tl))}function tl(){ga=!1,ma=!0;for(let e=0;ee.effect(n,{scheduler:t=>{va?Zc(t):t()}}),Is=e.raw}function Io(e){Qn=e}function il(e){let n=()=>{};return[r=>{let i=Qn(r);return e._x_effects||(e._x_effects=new Set,e._x_runEffects=()=>{e._x_effects.forEach(a=>a())}),e._x_effects.add(i),n=()=>{i!==void 0&&(e._x_effects.delete(i),Ur(i))},i},()=>{n()}]}function Dr(e,n,t={}){e.dispatchEvent(new CustomEvent(n,{detail:t,bubbles:!0,composed:!0,cancelable:!0}))}function rn(e,n){if(typeof ShadowRoot=="function"&&e instanceof ShadowRoot){Array.from(e.children).forEach(i=>rn(i,n));return}let t=!1;if(n(e,()=>t=!0),t)return;let r=e.firstElementChild;for(;r;)rn(r,n),r=r.nextElementSibling}function an(e,...n){console.warn(`Alpine Warning: ${e}`,...n)}var Po=!1;function al(){Po&&an("Alpine has already been initialized on this page. Calling Alpine.start() more than once can cause problems."),Po=!0,document.body||an("Unable to initialize. Trying to load Alpine before `` is available. Did you forget to add `defer` in Alpine's `