-
Notifications
You must be signed in to change notification settings - Fork 329
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Form focused mode #640
base: main
Are you sure you want to change the base?
Form focused mode #640
Changes from 9 commits
dabef40
72264ae
440125a
b1febab
a791916
62d86f3
a1ad9fd
61143fc
9a19502
459dcf7
0db1fc0
f24cab9
cd60d43
1b93185
228df27
838bf34
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class () extends Migration { | ||
/** | ||
* Run the migrations. | ||
*/ | ||
public function up(): void | ||
{ | ||
Schema::table('forms', function (Blueprint $table) { | ||
$table->string('format')->default('regular'); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
*/ | ||
public function down(): void | ||
{ | ||
Schema::table('forms', function (Blueprint $table) { | ||
$table->dropColumn('format'); | ||
}); | ||
} | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<template> | ||
<modal | ||
:show="show && form.format === 'focused' && removeBlocks.length > 0" | ||
:compact-header="true" | ||
:closeable="false" | ||
@close="onCancel" | ||
> | ||
<template #icon> | ||
<Icon | ||
name="heroicons:document-text" | ||
class="w-10 h-10 text-blue" | ||
/> | ||
</template> | ||
<template #title> | ||
Format Change | ||
</template> | ||
|
||
<div class="p-4"> | ||
If you change the format, below block(s) will be removed from the form: | ||
<ul | ||
v-if="removeBlocks.length > 0" | ||
class="list-disc ml-4 mt-2" | ||
> | ||
<li | ||
v-for="block in removeBlocks" | ||
:key="block.id" | ||
> | ||
{{ block.name }} | ||
</li> | ||
</ul> | ||
|
||
<div class="flex justify-end mt-4 px-6"> | ||
<v-button | ||
class="mr-2" | ||
@click.prevent="changeFormat" | ||
> | ||
It's ok | ||
</v-button> | ||
<v-button | ||
color="white" | ||
@click.prevent="onCancel" | ||
> | ||
Cancel | ||
</v-button> | ||
</div> | ||
</div> | ||
</modal> | ||
</template> | ||
|
||
<script setup> | ||
const props = defineProps({ | ||
show: { | ||
type: Boolean, | ||
default: false, | ||
} | ||
}) | ||
|
||
const emit = defineEmits(['close']) | ||
const removeTypes = ['nf-page-break','nf-divider','nf-image','nf-code'] | ||
const formStore = useWorkingFormStore() | ||
const form = computed(() => formStore.content) | ||
|
||
const removeBlocks = computed(() => form.value.properties.filter(field => removeTypes.includes(field.type))) | ||
|
||
const changeFormat = () => { | ||
form.value.properties = form.value.properties.filter(property => !removeTypes.includes(property.type)) | ||
form.value.format = 'focused' | ||
emit('close') | ||
} | ||
|
||
const onCancel = () => { | ||
form.value.format = 'regular' | ||
emit('close') | ||
} | ||
</script> |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -108,7 +108,7 @@ | |||||
key="form" | ||||||
> | ||||||
<open-form | ||||||
v-if="form && !form.is_closed" | ||||||
v-if="form && !form.is_closed && form.format === 'regular'" | ||||||
:form="form" | ||||||
:loading="loading" | ||||||
:fields="form.properties" | ||||||
|
@@ -130,6 +130,29 @@ | |||||
</open-form-button> | ||||||
</template> | ||||||
</open-form> | ||||||
<open-form-focused | ||||||
v-else-if="form && !form.is_closed && form.format === 'focused'" | ||||||
:form="form" | ||||||
:loading="loading" | ||||||
:fields="form.properties" | ||||||
:theme="theme" | ||||||
:dark-mode="darkMode" | ||||||
:admin-preview="adminPreview" | ||||||
@submit="submitForm" | ||||||
> | ||||||
<template #submit-btn="{submitForm}"> | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix variable shadowing in submit button template. The -<template #submit-btn="{submitForm}">
+<template #submit-btn="{submitForm: handleFocusedSubmit}"> 📝 Committable suggestion
Suggested change
🧰 Tools🪛 GitHub Check: Run client linters[warning] 161-161: 🪛 GitHub Actions: laravel[warning] 161-161: Variable 'submitForm' is already declared in the upper scope |
||||||
<open-form-button | ||||||
:loading="loading" | ||||||
:theme="theme" | ||||||
:color="form.color" | ||||||
class="mt-2 px-8 mx-1" | ||||||
:class="submitButtonClass" | ||||||
@click.prevent="submitForm" | ||||||
> | ||||||
{{ form.submit_button_text }} | ||||||
</open-form-button> | ||||||
</template> | ||||||
</open-form-focused> | ||||||
<p | ||||||
v-if="!form.no_branding" | ||||||
class="text-center w-full mt-2" | ||||||
|
@@ -202,6 +225,8 @@ | |||||
<script> | ||||||
import OpenForm from './OpenForm.vue' | ||||||
import OpenFormButton from './OpenFormButton.vue' | ||||||
import OpenFormFocused from './OpenFormFocused.vue' | ||||||
import FormTimer from './FormTimer.vue' | ||||||
Comment on lines
+246
to
+247
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove unused FormTimer component. The FormTimer component is imported and registered but not used in the template. -import FormTimer from './FormTimer.vue'
import FormCleanings from '../../pages/forms/show/FormCleanings.vue'
export default {
- components: { VTransition, OpenFormButton, OpenForm, OpenFormFocused, FormCleanings, FormTimer, FirstSubmissionModal },
+ components: { VTransition, OpenFormButton, OpenForm, OpenFormFocused, FormCleanings, FirstSubmissionModal }, Also applies to: 256-256 |
||||||
import FormCleanings from '../../pages/forms/show/FormCleanings.vue' | ||||||
import VTransition from '~/components/global/transitions/VTransition.vue' | ||||||
import {pendingSubmission} from "~/composables/forms/pendingSubmission.js" | ||||||
|
@@ -210,7 +235,7 @@ import ThemeBuilder from "~/lib/forms/themes/ThemeBuilder.js" | |||||
import FirstSubmissionModal from '~/components/open/forms/components/FirstSubmissionModal.vue' | ||||||
|
||||||
export default { | ||||||
components: { VTransition, OpenFormButton, OpenForm, FormCleanings, FirstSubmissionModal }, | ||||||
components: { VTransition, OpenFormButton, OpenForm, OpenFormFocused, FormCleanings, FormTimer, FirstSubmissionModal }, | ||||||
|
||||||
props: { | ||||||
form: { type: Object, required: true }, | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Move removeTypes to a constants file
The
removeTypes
array should be moved to a constants file for better maintainability and reusability.Create a new constant in a shared location: