Invert submitOnce on UI

Signed-off-by: Jonas Rittershofer <jotoeri@users.noreply.github.com>
This commit is contained in:
Jonas Rittershofer 2020-06-11 22:49:28 +02:00
parent 8779ded0dc
commit 3ed4fef4fa
2 changed files with 16 additions and 2 deletions

View file

@ -174,6 +174,7 @@ class ApiController extends Controller {
$form->setAccess([
'type' => 'public'
]);
$form->setSubmitOnce(true);
$this->formMapper->insert($form);

View file

@ -48,13 +48,13 @@
</li>
<li>
<input id="submitOnce"
v-model="form.submitOnce"
v-model="submitMultiple"
:disabled="isPublic || form.isAnonymous"
type="checkbox"
class="checkbox"
@change="onSubmitOnceChange">
<label for="submitOnce">
{{ t('forms', 'Only allow one response per user') }}
{{ t('forms', 'Allow multiple responses per person') }}
</label>
</li>
<li>
@ -177,6 +177,19 @@ export default {
return window.location.protocol + '//' + window.location.host + generateUrl(`/apps/forms/${this.form.hash}`)
},
// Inverting submitOnce for UI here. Adapt downto Db for V3, if this imposes for longterm.
submitMultiple: {
get() {
if (this.form.access.type === 'public' || this.form.isAnonymous) {
return true
}
return !this.form.submitOnce
},
set(submitMultiple) {
this.form.submitOnce = !submitMultiple
},
},
formExpires: {
get() {
return this.form.expires !== 0