-
-
-
+
-
-
+
\ No newline at end of file
diff --git a/resources/js/components/forms/index.js b/resources/js/components/forms/index.js
index bbb854e..70fad78 100644
--- a/resources/js/components/forms/index.js
+++ b/resources/js/components/forms/index.js
@@ -16,6 +16,7 @@ import ImageInput from './ImageInput'
import DateInput from './DateInput';
import RatingInput from './RatingInput';
import FlatSelectInput from './FlatSelectInput';
+import ToggleSwitchInput from './ToggleSwitchInput';
// Components that are registered globaly.
[
@@ -34,7 +35,8 @@ import FlatSelectInput from './FlatSelectInput';
RichTextAreaInput,
DateInput,
RatingInput,
- FlatSelectInput
+ FlatSelectInput,
+ ToggleSwitchInput
].forEach(Component => {
Vue.component(Component.name, Component)
})
diff --git a/resources/js/components/open/forms/OpenForm.vue b/resources/js/components/open/forms/OpenForm.vue
index 427acb0..7cdba83 100644
--- a/resources/js/components/open/forms/OpenForm.vue
+++ b/resources/js/components/open/forms/OpenForm.vue
@@ -317,6 +317,9 @@ export default {
if (['select', 'multi_select'].includes(field.type) && field.without_dropdown) {
return 'FlatSelectInput'
}
+ if (field.type === 'checkbox' && field.use_toggle_switch) {
+ return 'ToggleSwitchInput'
+ }
return this.fieldComponents[field.type]
},
getFieldClasses (field) {
diff --git a/resources/js/components/open/forms/components/FormSubmissions.vue b/resources/js/components/open/forms/components/FormSubmissions.vue
index 5bb97ef..1d6bff0 100644
--- a/resources/js/components/open/forms/components/FormSubmissions.vue
+++ b/resources/js/components/open/forms/components/FormSubmissions.vue
@@ -2,11 +2,41 @@
+
+
+
+
+
+
+ Display columns
+
+
+
+
+ Form Fields
+
+ {{ field.name }}
+
+
+
+
+ Removed Fields
+
+ {{ field.name }}
+
+
+
+
+
+ Close
+
+
+
+
!property.hasOwnProperty('hidden') || !property.hidden)
- tmp.push({
- "name": "Create Date",
- "id": "create_date",
- "type": "date"
- });
- return tmp
- },
exportUrl() {
if (!this.form) {
return ''
@@ -104,6 +127,20 @@ export default {
})
this.$set(this.form, 'properties', columns)
this.formInitDone = true
+
+ this.properties = clonedeep(this.form.properties)
+ this.removed_properties = clonedeep(this.form.removed_properties)
+
+ // Get display columns from local storage
+ const tmpColumns = window.localStorage.getItem('display-columns-formid-'+this.form.id)
+ if(tmpColumns !== null && tmpColumns){
+ this.displayColumns = JSON.parse(tmpColumns)
+ this.onChangeDisplayColumns()
+ }else{
+ this.form.properties.forEach((field) => {
+ this.displayColumns[field.id] = true
+ })
+ }
},
getSubmissionsData() {
if (!this.form || this.fullyLoaded) {
@@ -131,6 +168,13 @@ export default {
this.$refs.shadows.toggleShadow()
this.$refs.shadows.calcDimensions()
},
+ onChangeDisplayColumns(){
+ window.localStorage.setItem('display-columns-formid-'+this.form.id, JSON.stringify(this.displayColumns))
+ const final_properties = this.properties.concat(this.removed_properties).filter((field) => {
+ return this.displayColumns[field.id] === true
+ })
+ this.$set(this.form, 'properties', final_properties)
+ }
},
}
diff --git a/resources/js/components/open/forms/components/form-components/FormEditorPreview.vue b/resources/js/components/open/forms/components/form-components/FormEditorPreview.vue
index 51fa584..00839ae 100644
--- a/resources/js/components/open/forms/components/form-components/FormEditorPreview.vue
+++ b/resources/js/components/open/forms/components/form-components/FormEditorPreview.vue
@@ -46,7 +46,7 @@
>
diff --git a/resources/js/components/open/forms/components/form-components/FormInformation.vue b/resources/js/components/open/forms/components/form-components/FormInformation.vue
index 62631d4..f94bd12 100644
--- a/resources/js/components/open/forms/components/form-components/FormInformation.vue
+++ b/resources/js/components/open/forms/components/form-components/FormInformation.vue
@@ -27,6 +27,11 @@
placeholder="Select Tag(s)" :multiple="true" :allowCreation="true"
:options="allTagsOptions"
/>
+
+
+
{{ form.title }}
+ Draft (not public)
@@ -305,7 +306,7 @@ import FormSubmissions from '../../components/open/forms/components/FormSubmissi
const loadForms = function () {
store.commit('open/forms/startLoading')
store.dispatch('open/workspaces/loadIfEmpty').then(() => {
- store.dispatch('open/forms/load', store.state['open/workspaces'].currentId)
+ store.dispatch('open/forms/loadIfEmpty', store.state['open/workspaces'].currentId)
})
}
diff --git a/resources/js/pages/home.vue b/resources/js/pages/home.vue
index 01ad098..5cb84af 100644
--- a/resources/js/pages/home.vue
+++ b/resources/js/pages/home.vue
@@ -10,13 +10,11 @@
Create a new form
-
+
@@ -31,7 +29,8 @@
@@ -82,7 +84,7 @@ import OpenFormFooter from '../components/pages/OpenFormFooter'
const loadForms = function () {
store.commit('open/forms/startLoading')
store.dispatch('open/workspaces/loadIfEmpty').then(() => {
- store.dispatch('open/forms/load', store.state['open/workspaces'].currentId)
+ store.dispatch('open/forms/loadIfEmpty', store.state['open/workspaces'].currentId)
})
}
diff --git a/resources/js/store/modules/open/forms.js b/resources/js/store/modules/open/forms.js
index f8af0c1..ae9b237 100644
--- a/resources/js/store/modules/open/forms.js
+++ b/resources/js/store/modules/open/forms.js
@@ -2,6 +2,7 @@ import axios from 'axios'
export const formsEndpoint = '/api/open/workspaces/{workspaceId}/forms'
export const namespaced = true
+export let currentPage = 1
// state
export const state = {
@@ -36,6 +37,9 @@ export const mutations = {
set (state, items) {
state.content = items
},
+ append (state, items) {
+ state.content = state.content.concat(items)
+ },
addOrUpdate (state, item) {
state.content = state.content.filter((val) => val.id !== item.id)
state.content.push(item)
@@ -56,12 +60,26 @@ export const actions = {
resetState (context) {
context.commit('set', [])
context.commit('stopLoading')
+ currentPage = 1
},
load (context, workspaceId) {
context.commit('startLoading')
- return axios.get(formsEndpoint.replace('{workspaceId}', workspaceId)).then((response) => {
- context.commit('set', response.data)
- context.commit('stopLoading')
+ return axios.get(formsEndpoint.replace('{workspaceId}', workspaceId)+'?page='+currentPage).then((response) => {
+ context.commit((currentPage == 1) ? 'set' : 'append', response.data.data)
+ if (currentPage < response.data.meta.last_page) {
+ currentPage += 1
+ context.dispatch('load', workspaceId)
+ } else {
+ context.commit('stopLoading')
+ currentPage = 1
+ }
})
+ },
+ loadIfEmpty (context, workspaceId) {
+ if (context.state.content.length === 0) {
+ return context.dispatch('load', workspaceId)
+ }
+ context.commit('stopLoading')
+ return Promise.resolve()
}
}
diff --git a/tailwind.config.js b/tailwind.config.js
index 8718719..c41ecdf 100644
--- a/tailwind.config.js
+++ b/tailwind.config.js
@@ -37,6 +37,9 @@ module.exports = {
10: '10rem',
8: '2rem'
},
+ translate: {
+ 5.5: '1.4rem'
+ },
boxShadow: {
'inner-notion': '#0f0f0f1a 0px 0px 0px 1px inset',
'focus-notion': '#2eaadcb3 0px 0px 0px 1px inset, #2eaadc66 0px 0px 0px 2px !important'
diff --git a/tests/Feature/Forms/AnswerFormTest.php b/tests/Feature/Forms/AnswerFormTest.php
index e76de0f..b89c820 100644
--- a/tests/Feature/Forms/AnswerFormTest.php
+++ b/tests/Feature/Forms/AnswerFormTest.php
@@ -58,6 +58,29 @@ it('can submit form till max submissions count is not reached at limit', functio
}
// Now, can not submit form, Because it's reached at submission limit
+ $this->postJson(route('forms.answer', $form->slug), $formData)
+ ->assertStatus(403);
+});
+
+it('can not open draft form', function () {
+ $user = $this->actingAsUser();
+ $workspace = $this->createUserWorkspace($user);
+ $form = $this->createForm($user, $workspace, [
+ 'visibility' => 'draft'
+ ]);
+
+ $this->getJson(route('forms.show', $form->slug))
+ ->assertStatus(404);
+});
+
+it('can not submit draft form', function () {
+ $user = $this->actingAsUser();
+ $workspace = $this->createUserWorkspace($user);
+ $form = $this->createForm($user, $workspace, [
+ 'visibility' => 'draft'
+ ]);
+ $formData = FormSubmissionDataFactory::generateSubmissionData($form);
+
$this->postJson(route('forms.answer', $form->slug), $formData)
->assertStatus(403);
});
\ No newline at end of file
diff --git a/tests/Feature/Forms/FormTest.php b/tests/Feature/Forms/FormTest.php
index be124eb..d0c08d0 100644
--- a/tests/Feature/Forms/FormTest.php
+++ b/tests/Feature/Forms/FormTest.php
@@ -28,12 +28,10 @@ it('can fetch forms', function () {
$this->getJson(route('open.workspaces.forms.index', $workspace->id))
->assertSuccessful()
- ->assertJsonCount(1)
- ->assertJson(function (AssertableJson $json) use ($form) {
- return $json->where('0.id', $form->id)
- ->whereType('0.title', 'string')
- ->whereType('0.properties', 'array');
- });
+ ->assertJsonCount(3)
+ ->assertSuccessful()
+ ->assertJsonPath('data.0.id', $form->id)
+ ->assertJsonPath('data.0.title', $form->title);
});
it('can update a form', function () {
@@ -152,4 +150,4 @@ it('can create form with dark mode', function () {
->where('dark_mode', 'dark')
->etc();
});
-});
\ No newline at end of file
+});