forked from Fliplet/fliplet-widget-form-builder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
interface.html
399 lines (383 loc) · 22.3 KB
/
interface.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
<div id="app" class="is-loading" :data-device-type="deviceType">
<div class="col-sm-12 loading-message">
<!-- Show loading animation -->
<div class="spinner-holder animated">
<div class="spinner-overlay">Loading...</div>
<p>Loading the form builder... Please wait!</p>
</div>
</div>
<main v-bind:class="{ 'select-template': chooseTemplate }">
<header>
<p>
<template v-if="chooseTemplate">Template gallery</template>
<template v-else>Configure form</template>
<a href="https://help.fliplet.com/form-component/" class="help-icon" target="_blank">
<i class="fa fa-question-circle-o"></i>
</a>
</p>
</header>
<section v-if="chooseTemplate" class="col-sm-12 choose-template" ref="templateGallery">
<p class="templates-sub-title">Choose a form template to get started.</p>
<template v-if="organizationTemplates.length">
<div class="gallery-heading">Templates by \{{ organizationName }}</div>
<div class="templates-holder">
<div class="template-wrapper" v-for="template in organizationTemplates">
<div class="template-info">
<h4 class="template-title">\{{ template.settings.displayName }} <span type="button" class="template-created-info" data-toggle="tooltip" data-placement="left" :title="template.createdDescription"><i class="fa fa-info" aria-hidden="true"></i></span></h4>
<div v-if="readMore.indexOf(template.id) > -1" class="template-desc">
<span v-html="template.settings.description"></span>
<a href="#" class="readless" v-on:click.prevent="toggleReadMore(false, template.id)">Close</a>
</div>
<div v-else class="template-desc">
<span v-html="truncate(template.settings.description, 100)"></span>
<a v-if="template.settings.description.length > 100" href="#" class="readmore" v-on:click.prevent="toggleReadMore(true, template.id)">Read more <i class="fa fa-angle-down"></i></a>
</div>
<div class="template-controls">
<div class="btn btn-secondary" v-on:click.prevent="previewTemplate(template.id)">
<template v-if="settings.previewingTemplate === template.id">Previewing</template>
<template v-else>Preview</template>
</div>
<div class="btn btn-primary" v-on:click.prevent="useTemplate(template.id)">Use</div>
</div>
</div>
</div>
</div>
</template>
<div class="gallery-heading">Fliplet templates</div>
<div class="templates-holder">
<div class="template-wrapper" v-for="template in systemTemplates">
<div class="template-info">
<h4 class="template-title">\{{ template.settings.displayName }} <span type="button" class="template-created-info" data-toggle="tooltip" data-placement="left" title="Created by Fliplet"><i class="fa fa-info" aria-hidden="true"></i></span></h4>
<div v-if="readMore.indexOf(template.id) > -1" class="template-desc">
<span v-html="template.settings.description"></span>
<a href="#" class="readless" v-on:click.prevent="toggleReadMore(false, template.id)">Close</a>
</div>
<div v-else class="template-desc">
<span v-html="truncate(template.settings.description, 100)"></span>
<a v-if="template.settings.description.length > 100" href="#" class="readmore" v-on:click.prevent="toggleReadMore(true, template.id)">Read more <i class="fa fa-angle-down"></i></a>
</div>
<div class="template-controls">
<div class="btn btn-secondary" v-on:click.prevent="previewTemplate(template.id)">
<template v-if="settings.previewingTemplate === template.id">Previewing</template>
<template v-else>Preview</template>
</div>
<div class="btn btn-primary" v-on:click.prevent="useTemplate(template.id)">Use</div>
</div>
</div>
</div>
</div>
</section>
<section v-if="toChangeTemplate" class="col-sm-12 change-template">
<div class="back-btn">
<a href="#" v-on:click.prevent="goBack"><i class="fa fa-angle-left"></i> Back</a>
</div>
<label class="control-label">Change your form template</label>
<p>Select another template to load a new form.</p>
<label for="select-new-template" class="select-proxy-display">
<select class="form-control hidden-select" id="select-new-template" v-model="newTemplate">
<option value="" disabled>-- Select a template</option>
<option v-for="template in templates" :value="template.id">\{{ template.settings.displayName }}</option>
</select>
<span class="icon fa fa-chevron-down"></span>
<span class="select-value-proxy">-- Select a template</span>
</label>
<div class="panel panel-warning">
<div class="panel-heading">
<h3 class="panel-title">Are you sure you want to load a new form?</h3>
</div>
<div class="panel-body">
<p>Your existing form fields and settings will be lost. Previously collected data will NOT be deleted.</p>
<div class="form-group clearfix" style="margin-bottom:0">
<div class="checkbox checkbox-icon">
<input type="checkbox" id="reviewCheckbox" v-model="permissionToChange">
<label for="reviewCheckbox" class="bolder">
<span class="check"><i class="fa fa-check"></i></span> Yup, I'm sure.
</label>
</div>
</div>
</div>
</div>
</section>
<div class="builder" v-show="!chooseTemplate && !toChangeTemplate">
<nav>
<ul class="nav nav-tabs">
<li v-bind:class="{ active: section === 'form' }">
<a href="#" v-on:click.prevent="section = 'form'">Edit form</a>
</li>
<li v-bind:class="{ active: section === 'settings' }">
<a href="#" v-on:click.prevent="section = 'settings'">Settings</a>
</li>
<li v-bind:class="{ active: section === 'org-template' }">
<a href="#" v-on:click.prevent="section = 'org-template'">Form template</a>
</li>
</ul>
<a href="#" class="btn btn-xs btn-primary hidden" v-on:click.prevent="changeTemplate()">Change template</a>
</nav>
<div class="content">
<section class="col-sm-12" v-show="section === 'settings'">
<form class="form-settings" ref="formSettings">
<h3>General</h3>
<div class="form-group">
<label for="formName" class="control-label">Form name</label>
<input id="formName" type="text" v-model="settings.displayName" class="form-control" />
</div>
<div class="form-group" id="data-source-provider">
</div>
<div v-if="missingColumnsMessage && settings.dataSourceId" class="columns-notification alert alert-warning">
<p><b>\{{ missingColumnsMessage }}</b></p>
<p>\{{ missingColumns }}</p>
<button type="button" class="btn btn-primary btn-block btn-generate-columns" @click="generateColumns">\{{ newColumns.length > 1 ? 'Add columns to data source' : 'Add column to data source' }}</button>
</div>
<div class="form-group">
<div class="control-label">
<label>Save users' progress on the form</label>
</div>
<div>
<div class="radio radio-icon">
<input type="radio" id="progress_save" name="progress" v-model="settings.saveProgress" :value="true">
<label for="progress_save">
<span class="check"><i class="fa fa-circle"></i></span> Always <small>- Form entries will be saved in the device if the user abandons the form without submitting</small>
</label>
</div>
<div class="radio radio-icon">
<input type="radio" id="progress_dont_save" name="progress" v-model="settings.saveProgress" :value="false">
<label for="progress_dont_save">
<span class="check"><i class="fa fa-circle"></i></span> Never <small>- Form entries will be discarded if the user abandons the form without submitting</small>
</label>
</div>
</div>
</div>
<h3>Submission</h3>
<div v-if="!settings.dataStore.length" class="form-group">
<div class="control-label">
<label>When the form is loaded...</label>
</div>
<div class="checkbox checkbox-icon">
<input type="checkbox" id="autobindProfileEditing" v-model="settings.autobindProfileEditing" :value="true">
<label for="autobindProfileEditing">
<span class="check"><i class="fa fa-check"></i></span> Load the data from user's profile
<p class="help-block"><small>If the user is signed in to the app, they will be able to edit their user profile using this form.</small></p>
</label>
</div>
</div>
<div class="form-group" v-if="showDataSourceSettings">
<div class="control-label">
<label>When the form is submitted...</label>
</div>
<div>
<div v-if="!settings.autobindProfileEditing" class="checkbox checkbox-icon">
<input type="checkbox" id="save_datasource" name="dataStore" v-model="settings.dataStore" value="dataSource">
<label for="save_datasource">
<span class="check"><i class="fa fa-check"></i></span> Add new submissions to a data source
</label>
</div>
<div v-if="settings.autobindProfileEditing">
<p class="help-block">
<small>If the form loads data from user’s profile, it can only be used to update the user’s profile.</small>
</p>
</div>
<div class="hidden-settings" v-bind:class="{ 'active': showExtraAdd, 'hidden': !showExtraAdd }">
<div class="form-group">
<div class="control-label">
<label>Submit form when the device is...</label>
</div>
<div>
<div class="radio radio-icon">
<input type="radio" id="online_offline" name="connectivityStatus" v-model="settings.offline" :value="true">
<label for="online_offline">
<span class="check"><i class="fa fa-circle"></i></span> Online & Offline <small>- The user can submit their form even when they don't have an internet connection, and the entry will be sent to the data source as soon as a connection is available</small>
</label>
</div>
<div class="radio radio-icon">
<input type="radio" id="online_only" name="connectivityStatus" v-model="settings.offline" :value="false">
<label for="online_only">
<span class="check"><i class="fa fa-circle"></i></span> Online only <small>- The user can only submit the form when connected to the internet</small>
</label>
</div>
</div>
</div>
<div class="form-group">
<div class="control-label">
<label>Send an email notification whenever a form is submitted</label>
</div>
<div>
<div v-if="settings.dataSourceId" class="checkbox checkbox-icon">
<input type="checkbox" id="templated_email_add" name="whenSubmitted" v-model="settings.onSubmit" value="templatedEmailAdd">
<label for="templated_email_add">
<span class="check"><i class="fa fa-check"></i></span> Yes, please <span v-show="toggleTemplatedEmailAdd">[<a href="#" v-on:click.prevent="configureEmailTemplateAdd">Configure email template</a>]</span>
</label>
</div>
<div v-else>
<p>To configure the email template, please select a data source first.</p>
</div>
</div>
</div>
</div>
<div class="checkbox checkbox-icon">
<input type="checkbox" id="edit_datasource" name="dataStore" v-model="settings.dataStore" value="editDataSource">
<label for="edit_datasource">
<span class="check"><i class="fa fa-check"></i></span> Update existing entries in a data source
<p class="help-block"><small>Selecting this option will make your form unavailable if the user doesn't have an internet connection.</small></p>
</label>
</div>
<div class="hidden-settings" v-bind:class="{ 'active': showExtraEdit, 'hidden': !showExtraEdit }">
<div class="form-group">
<div class="control-label">
<label>Send an email notification whenever the data is updated</label>
</div>
<div>
<div v-if="settings.dataSourceId" class="checkbox checkbox-icon">
<input type="checkbox" id="templated_email_edit" name="whenSubmitted" v-model="settings.onSubmit" value="templatedEmailEdit">
<label for="templated_email_edit">
<span class="check"><i class="fa fa-check"></i></span> Yes, please <span v-show="toggleTemplatedEmailEdit">[<a href="#" v-on:click.prevent="configureEmailTemplateEdit">Configure email template</a>]</span>
</label>
</div>
<div v-else>
<p>To configure the email template, please select a data source first.</p>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="form-group">
<div class="control-label">
<label>When the form is submitted do you want to generate an email on the device?</label>
</div>
<div>
<div class="checkbox checkbox-icon">
<input type="checkbox" id="generate_email" name="whenSubmitted" v-model="settings.onSubmit" value="generateEmail">
<label for="generate_email">
<span class="check"><i class="fa fa-check"></i></span> Yes, please! <span v-show="toggleGenerateEmail">[<a href="#" v-on:click.prevent="configureEmailTemplateForCompose">Configure email template</a>]</span>
</label>
</div>
</div>
</div>
<div class="form-group">
<div class="control-label">
<label>After the form has been submitted...</label>
</div>
<div>
<div class="radio radio-icon">
<input type="radio" id="redirect_yes" name="redirectOptions" v-model="settings.redirect" :value="true">
<label for="redirect_yes">
<span class="check"><i class="fa fa-circle"></i></span> Take the user to another screen
</label>
<div class="hidden-settings" v-show="settings.redirect">
<div class="form-group">
<div id="linkAction"></div>
</div>
</div>
</div>
<div class="radio radio-icon">
<input type="radio" id="redirect_no" name="redirectOptions" v-model="settings.redirect" :value="false">
<label for="redirect_no">
<span class="check"><i class="fa fa-circle"></i></span> Show a confirmation message
</label>
<div class="hidden-settings" v-show="!settings.redirect">
<div class="form-group">
<textarea id="formResult" ref="resulthtml" v-model="settings.resultHtml" class="form-control" rows="4"></textarea>
</div>
</div>
</div>
</div>
</div>
</form>
</section>
<div v-show="section === 'form'" class="section-holder clearfix">
<section class="form-preview" v-bind:class="{ 'col-sm-6': isAddingFields, 'col-sm-12': !isAddingFields }">
<a href="#" v-if="!isAddingFields" v-on:click.prevent="isAddingFields = true" class="btn btn-primary btn-xs add-field pull-right">Add fields <i class="fa fa-plus"></i></a>
<h2><small>Your form</small> <span class="required-info-label" v-bind:class="{'isRequired': hasRequiredFields}">* Required fields</span></h2>
<form class="form-html" v-sortable="{ group: { name: 'fields', pull: false }, scrollSensitivity: 116, scrollSpeed: 10, onAdd: onAdd, onUpdate: onSort }">
<template v-if="fields.length">
<div class="component" :key="field.name" v-for="(field, index) in fields" v-on:click="onFieldClick(field)" v-bind:class="{ editing: activeField && field.name === activeField.name }">
<div class="delete-field" href="#" v-on:click.prevent.stop="deleteField(field.label, index)"><i class="fa fa-trash"></i></div>
<div class="overlay-screen">
<div class="edit-label">
Click to edit and drag to reorder
</div>
</div>
<component :is="field._type" v-bind="field"></component>
</div>
</template>
<div v-else class="empty-state">
<p>Add fields by dragging from the right side and dropping them here.</p>
</div>
</form>
</section>
<transition name="fade">
<section v-if="isAddingFields" class="components-list col-sm-6">
<a href="#" v-on:click.prevent="isAddingFields = false" class="btn btn-secondary btn-xs hide-fields">Hide</a>
<h2><small>Drag and drop to add a field</small></h2>
<form class="form-html">
<div class="panel-group" id="componentsAccordion" role="tablist" aria-multiselectable="true">
<div class="panel panel-default" v-for="(category, idx) in categories">
<div class="panel-heading" role="tab">
<h4 class="panel-title" v-bind:class="{ collapsed: idx !== 0}" role="button" data-toggle="collapse" data-parent="#componentsAccordion" :href="'#category' + idx" :aria-expanded="idx === 0" :aria-controls="'category' + idx">
\{{ category.name }}
</h4>
<div class="chevron-icon">
<i class="fa fa-angle-up"></i>
</div>
</div>
<div :id="'category' + idx" class="panel-collapse collapse" v-bind:class="{ in: idx === 0}" role="tabpanel">
<div class="panel-body" v-sortable="{ sort: false, group: { name: 'fields', pull: 'clone', put: false, revertClone: true } }">
<div :key="field" :data-field="field" class="component" v-for="(field, index) in category.fields">
<div class="overlay-screen">
<div class="edit-label">
Drag field to the left
</div>
</div>
<component :is="field"></component>
</div>
</div>
</div>
</div>
</div>
</form>
</section>
</transition>
</div>
<div v-show="section === 'org-template'" class="section-holder clearfix">
<section class="col-sm-12">
<div class="form-group">
<div class="checkbox checkbox-icon">
<input id="templateCheckbox" type="checkbox" v-model="settings.template" />
<label for="templateCheckbox">
<span class="check"><i class="fa fa-check"></i></span> Set this form as a template for \{{ organizationName }}
</label>
</div>
</div>
<p class="help-block">Your colleagues can use this form as a template when they create new forms.</p>
<p class="help-block"><strong>Note:</strong> Changes to your form will be applied to the template after this app is published, but won't affect forms already using the template.</p>
<div v-show="settings.template">
<div class="form-group">
<label class="control-label">Form name</label>
<input placeholder="Form name" class="form-control" type="text" v-model="settings.displayName" />
</div>
<div class="form-group">
<label class="control-label">Template description</label>
<textarea ref="templateDescription" v-model="settings.description" class="form-control" rows="4"></textarea>
</div>
</div>
</section>
</div>
<div class="modal" tabindex="-1" role="dialog" v-bind:class="{ active: !!activeFieldConfigType }">
<transition name="slide-in">
<div v-show="!!activeFieldConfigType" class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h2 class="modal-title"><small>\{{ activeFieldName }}</small></h2>
</div>
<div class="modal-body">
<a href="#" class="btn btn-default close-btn" data-dismiss="modal" aria-label="Close" v-on:click.prevent="closeEdit">Cancel</a>
<component :is="activeFieldConfigType" v-bind="activeField" :_fields="fields" :_idx="activeFieldIdx"></component>
</div>
</div>
</div>
</transition>
</div>
</div>
</div>
</main>
</div>