@projectcaluma/ember-form-builder 11.0.0-beta.4 → 11.0.0-beta.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +131 -0
- package/addon/components/cfb-code-editor.hbs +26 -9
- package/addon/components/cfb-code-editor.js +60 -11
- package/addon/components/cfb-form-editor/general.hbs +1 -3
- package/addon/components/cfb-form-editor/general.js +6 -7
- package/addon/components/cfb-form-editor/question/default.hbs +11 -9
- package/addon/components/cfb-form-editor/question/default.js +9 -4
- package/addon/components/cfb-form-editor/question/options.hbs +3 -3
- package/addon/components/cfb-form-editor/question/validation.hbs +16 -14
- package/addon/components/cfb-form-editor/question/validation.js +17 -13
- package/addon/components/cfb-form-editor/question-list/item.hbs +44 -38
- package/addon/components/cfb-form-editor/question-list.hbs +2 -2
- package/addon/components/cfb-form-editor/question-list.js +9 -3
- package/addon/components/cfb-form-editor/question.hbs +55 -96
- package/addon/components/cfb-form-editor/question.js +53 -34
- package/addon/components/cfb-form-list.hbs +7 -7
- package/addon/components/cfb-form-list.js +44 -11
- package/addon/controllers/index.js +6 -0
- package/addon/engine.js +1 -1
- package/addon/gql/mutations/add-form-question.graphql +1 -1
- package/addon/gql/mutations/remove-form-question.graphql +1 -1
- package/addon/gql/mutations/reorder-form-questions.graphql +1 -1
- package/addon/gql/mutations/save-calculated-float-question.graphql +1 -0
- package/addon/gql/mutations/save-choice-question.graphql +1 -0
- package/addon/gql/mutations/save-date-question.graphql +3 -0
- package/addon/gql/mutations/save-dynamic-choice-question.graphql +1 -0
- package/addon/gql/mutations/save-dynamic-multiple-choice-question.graphql +1 -0
- package/addon/gql/mutations/save-files-question.graphql +14 -0
- package/addon/gql/mutations/save-float-question.graphql +1 -0
- package/addon/gql/mutations/save-integer-question.graphql +1 -0
- package/addon/gql/mutations/save-multiple-choice-question.graphql +1 -0
- package/addon/gql/mutations/save-table-question.graphql +1 -0
- package/addon/gql/mutations/save-text-question.graphql +1 -0
- package/addon/gql/mutations/save-textarea-question.graphql +1 -0
- package/addon/gql/queries/all-format-validators.graphql +10 -0
- package/addon/gql/queries/check-form-slug.graphql +1 -1
- package/addon/gql/queries/check-question-slug.graphql +1 -1
- package/addon/gql/queries/form-editor-general.graphql +1 -1
- package/addon/gql/queries/form-editor-question.graphql +30 -2
- package/addon/gql/queries/search-form-question.graphql +3 -3
- package/addon/instance-initializers/form-builder-widget-overrides.js +15 -0
- package/addon/routes/edit/questions/edit.js +2 -1
- package/addon/routes/edit.js +1 -1
- package/addon/templates/index.hbs +8 -1
- package/addon/validations/question.js +13 -4
- package/addon/validators/gt-lt.js +17 -38
- package/addon/validators/jexl.js +49 -0
- package/app/instance-initializers/form-builder-widget-overrides.js +4 -0
- package/app/styles/@projectcaluma/ember-form-builder.scss +2 -2
- package/app/styles/_cfb-uikit-powerselect.scss +2 -0
- package/blueprints/@projectcaluma/ember-form-builder/index.js +1 -1
- package/config/environment.js +0 -7
- package/index.js +4 -2
- package/package.json +57 -46
- package/translations/de.yaml +7 -6
- package/translations/en.yaml +4 -3
- package/translations/fr.yaml +154 -1
- package/addon/components/cfb-float-input.hbs +0 -14
- package/addon/components/cfb-label.hbs +0 -12
- package/addon/gql/fragments/field.graphql +0 -247
- package/addon/gql/mutations/save-file-question.graphql +0 -11
- package/app/components/cfb-float-input.js +0 -1
- package/app/components/cfb-label.js +0 -1
- package/app/styles/_cfb-powerselect.scss +0 -31
|
@@ -113,26 +113,11 @@
|
|
|
113
113
|
{{/if}}
|
|
114
114
|
|
|
115
115
|
{{#if (has-question-type f.model "static")}}
|
|
116
|
-
<
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
"cfb-code-editor"
|
|
122
|
-
language="markdown"
|
|
123
|
-
className="uk-margin-remove-bottom"
|
|
124
|
-
}}
|
|
125
|
-
class="uk-margin-remove-bottom"
|
|
126
|
-
/>
|
|
127
|
-
<small class="uk-text-muted">
|
|
128
|
-
{{t "caluma.form-builder.question.supportsMarkdownPrefix"}}
|
|
129
|
-
<a
|
|
130
|
-
target="_blank"
|
|
131
|
-
rel="noopener noreferrer"
|
|
132
|
-
href="https://www.markdownguide.org/basic-syntax"
|
|
133
|
-
>{{t "caluma.form-builder.question.markdown"}}</a>
|
|
134
|
-
</small>
|
|
135
|
-
</div>
|
|
116
|
+
<f.input
|
|
117
|
+
@label={{t "caluma.form-builder.question.staticContent"}}
|
|
118
|
+
@name="staticContent"
|
|
119
|
+
@renderComponent={{component "cfb-code-editor" language="markdown"}}
|
|
120
|
+
/>
|
|
136
121
|
{{/if}}
|
|
137
122
|
|
|
138
123
|
{{#if (has-question-type f.model "action-button")}}
|
|
@@ -140,27 +125,21 @@
|
|
|
140
125
|
@label={{t "caluma.form-builder.question.confirmationText"}}
|
|
141
126
|
@name="infoText"
|
|
142
127
|
@type="textarea"
|
|
128
|
+
{{autoresize mode="height"}}
|
|
143
129
|
/>
|
|
144
130
|
{{else}}
|
|
145
|
-
<
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
<a
|
|
158
|
-
target="_blank"
|
|
159
|
-
rel="noopener noreferrer"
|
|
160
|
-
href="https://www.markdownguide.org/basic-syntax"
|
|
161
|
-
>{{t "caluma.form-builder.question.markdown"}}</a>
|
|
162
|
-
</small>
|
|
163
|
-
</div>
|
|
131
|
+
<f.input
|
|
132
|
+
@label={{t "caluma.form-builder.question.infoText"}}
|
|
133
|
+
@name="infoText"
|
|
134
|
+
@renderComponent={{component "cfb-code-editor" language="markdown"}}
|
|
135
|
+
/>
|
|
136
|
+
{{/if}}
|
|
137
|
+
|
|
138
|
+
{{#if (not (has-question-type f.model "action-button" "static" "form"))}}
|
|
139
|
+
<f.input
|
|
140
|
+
@name="hintText"
|
|
141
|
+
@label={{t "caluma.form-builder.question.hintText"}}
|
|
142
|
+
/>
|
|
164
143
|
{{/if}}
|
|
165
144
|
|
|
166
145
|
{{#if (has-question-type f.model "text" "textarea" "integer" "float")}}
|
|
@@ -207,13 +186,13 @@
|
|
|
207
186
|
/>
|
|
208
187
|
|
|
209
188
|
<f.input
|
|
210
|
-
@name="
|
|
189
|
+
@name="formatValidators"
|
|
211
190
|
@label={{t "caluma.form-builder.question.formatValidators"}}
|
|
212
|
-
@placeholder={{t "caluma.form-builder.question.
|
|
191
|
+
@placeholder={{t "caluma.form-builder.question.no-selection"}}
|
|
213
192
|
@required={{false}}
|
|
214
193
|
@renderComponent={{component "cfb-form-editor/question/validation"}}
|
|
215
|
-
@on-update={{changeset-set f.model "
|
|
216
|
-
@value={{changeset-get f.model "
|
|
194
|
+
@on-update={{changeset-set f.model "formatValidators"}}
|
|
195
|
+
@value={{changeset-get f.model "formatValidators"}}
|
|
217
196
|
/>
|
|
218
197
|
{{/if}}
|
|
219
198
|
|
|
@@ -242,17 +221,18 @@
|
|
|
242
221
|
<div uk-grid class="uk-grid-small uk-child-width-1-2 uk-margin">
|
|
243
222
|
<div>
|
|
244
223
|
<f.input
|
|
224
|
+
@type="number"
|
|
245
225
|
@name="floatMinValue"
|
|
246
226
|
@label={{t "caluma.form-builder.question.min-value"}}
|
|
247
|
-
|
|
227
|
+
step="any"
|
|
248
228
|
/>
|
|
249
229
|
</div>
|
|
250
|
-
|
|
251
230
|
<div>
|
|
252
231
|
<f.input
|
|
232
|
+
@type="number"
|
|
253
233
|
@name="floatMaxValue"
|
|
254
234
|
@label={{t "caluma.form-builder.question.max-value"}}
|
|
255
|
-
|
|
235
|
+
step="any"
|
|
256
236
|
/>
|
|
257
237
|
</div>
|
|
258
238
|
</div>
|
|
@@ -295,10 +275,10 @@
|
|
|
295
275
|
@type="select"
|
|
296
276
|
@required={{true}}
|
|
297
277
|
@label={{t "caluma.form-builder.question.dataSource"}}
|
|
298
|
-
@options={{or this.availableDataSources.lastSuccessful.value array}}
|
|
278
|
+
@options={{or this.availableDataSources.lastSuccessful.value (array)}}
|
|
299
279
|
@optionTargetPath="name"
|
|
300
280
|
@optionLabelPath="info"
|
|
301
|
-
@
|
|
281
|
+
@prompt={{t "caluma.form-builder.question.no-selection"}}
|
|
302
282
|
/>
|
|
303
283
|
{{/if}}
|
|
304
284
|
|
|
@@ -328,9 +308,9 @@
|
|
|
328
308
|
as |fi|
|
|
329
309
|
>
|
|
330
310
|
<PowerSelect
|
|
331
|
-
@options={{or this.availableForms.lastSuccessful.value array}}
|
|
311
|
+
@options={{or this.availableForms.lastSuccessful.value (array)}}
|
|
332
312
|
@selected={{fi.value}}
|
|
333
|
-
@placeholder={{t "caluma.form-builder.question.
|
|
313
|
+
@placeholder={{t "caluma.form-builder.question.no-selection"}}
|
|
334
314
|
@onBlur={{fi.setDirty}}
|
|
335
315
|
@onChange={{fi.update}}
|
|
336
316
|
@searchField="slug"
|
|
@@ -359,33 +339,12 @@
|
|
|
359
339
|
</div>
|
|
360
340
|
|
|
361
341
|
{{#if @slug}}
|
|
362
|
-
<
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
{{#let rowEdge.node as |row|}}
|
|
369
|
-
<label class="cf-checkbox_label">
|
|
370
|
-
<input
|
|
371
|
-
type="checkbox"
|
|
372
|
-
value={{row.slug}}
|
|
373
|
-
checked={{includes
|
|
374
|
-
row.slug
|
|
375
|
-
this.model.meta.columnsToDisplay
|
|
376
|
-
}}
|
|
377
|
-
class="uk-checkbox uk-margin-small-right"
|
|
378
|
-
{{on
|
|
379
|
-
"change"
|
|
380
|
-
(fn this.toggleColumnToDisplay row.slug f.model)
|
|
381
|
-
}}
|
|
382
|
-
/>
|
|
383
|
-
{{row.label}}
|
|
384
|
-
</label>
|
|
385
|
-
{{/let}}
|
|
386
|
-
{{/each}}
|
|
387
|
-
</f.input>
|
|
388
|
-
</div>
|
|
342
|
+
<f.input
|
|
343
|
+
@type="checkbox-group"
|
|
344
|
+
@name="meta.columnsToDisplay"
|
|
345
|
+
@label={{t "caluma.form-builder.question.columnsToDisplay"}}
|
|
346
|
+
@options={{this.columnsToDisplayOptions}}
|
|
347
|
+
/>
|
|
389
348
|
{{/if}}
|
|
390
349
|
{{/if}}
|
|
391
350
|
|
|
@@ -403,9 +362,9 @@
|
|
|
403
362
|
as |fi|
|
|
404
363
|
>
|
|
405
364
|
<PowerSelect
|
|
406
|
-
@options={{or this.availableForms.lastSuccessful.value array}}
|
|
365
|
+
@options={{or this.availableForms.lastSuccessful.value (array)}}
|
|
407
366
|
@selected={{fi.value}}
|
|
408
|
-
@placeholder={{t "caluma.form-builder.question.
|
|
367
|
+
@placeholder={{t "caluma.form-builder.question.no-selection"}}
|
|
409
368
|
@onBlur={{fi.setDirty}}
|
|
410
369
|
@onChange={{fi.update}}
|
|
411
370
|
@searchField="slug"
|
|
@@ -437,7 +396,7 @@
|
|
|
437
396
|
@optionTargetPath="component"
|
|
438
397
|
@optionLabelPath="label"
|
|
439
398
|
@options={{this.availableOverrides}}
|
|
440
|
-
|
|
399
|
+
@prompt={{t "caluma.form-builder.question.no-selection"}}
|
|
441
400
|
/>
|
|
442
401
|
|
|
443
402
|
<f.input
|
|
@@ -445,7 +404,6 @@
|
|
|
445
404
|
@label={{t "caluma.form-builder.question.isArchived"}}
|
|
446
405
|
@required={{true}}
|
|
447
406
|
@renderComponent={{component "cfb-toggle-switch" size="small"}}
|
|
448
|
-
class="uk-flex uk-flex-between uk-flex-column"
|
|
449
407
|
/>
|
|
450
408
|
|
|
451
409
|
<UkButton
|
|
@@ -468,17 +426,14 @@
|
|
|
468
426
|
@required={{true}}
|
|
469
427
|
@label={{t "caluma.form-builder.question.validateOnEnter"}}
|
|
470
428
|
@renderComponent={{component "cfb-toggle-switch" size="small"}}
|
|
471
|
-
class="uk-flex uk-flex-between uk-flex-column"
|
|
472
429
|
/>
|
|
473
430
|
{{/if}}
|
|
474
431
|
|
|
475
|
-
<
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
/>
|
|
481
|
-
</div>
|
|
432
|
+
<f.input
|
|
433
|
+
@label={{t "caluma.form-builder.question.isHidden"}}
|
|
434
|
+
@name="isHidden"
|
|
435
|
+
@renderComponent={{component "cfb-code-editor" language="jexl"}}
|
|
436
|
+
/>
|
|
482
437
|
|
|
483
438
|
{{#if
|
|
484
439
|
(not
|
|
@@ -487,14 +442,18 @@
|
|
|
487
442
|
)
|
|
488
443
|
)
|
|
489
444
|
}}
|
|
490
|
-
<
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
/>
|
|
496
|
-
</div>
|
|
445
|
+
<f.input
|
|
446
|
+
@label={{t "caluma.form-builder.question.isRequired"}}
|
|
447
|
+
@name="isRequired"
|
|
448
|
+
@renderComponent={{component "cfb-code-editor" language="jexl"}}
|
|
449
|
+
/>
|
|
497
450
|
{{/if}}
|
|
451
|
+
|
|
452
|
+
<f.input
|
|
453
|
+
@label={{t "caluma.form-builder.question.meta"}}
|
|
454
|
+
@name="meta"
|
|
455
|
+
@renderComponent={{component "cfb-code-editor" language="json"}}
|
|
456
|
+
/>
|
|
498
457
|
{{/if}}
|
|
499
458
|
|
|
500
459
|
<div class="uk-text-right">
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import { getOwner } from "@ember/application";
|
|
2
1
|
import { A } from "@ember/array";
|
|
3
2
|
import { action } from "@ember/object";
|
|
4
3
|
import { inject as service } from "@ember/service";
|
|
5
4
|
import { camelize } from "@ember/string";
|
|
5
|
+
import { macroCondition, isTesting } from "@embroider/macros";
|
|
6
6
|
import Component from "@glimmer/component";
|
|
7
7
|
import { tracked } from "@glimmer/tracking";
|
|
8
8
|
import { queryManager } from "ember-apollo-client";
|
|
9
9
|
import Changeset from "ember-changeset";
|
|
10
10
|
import lookupValidator from "ember-changeset-validations";
|
|
11
11
|
import { dropTask, restartableTask, task, timeout } from "ember-concurrency";
|
|
12
|
-
import { all } from "rsvp";
|
|
13
12
|
|
|
14
13
|
import { hasQuestionType } from "@projectcaluma/ember-core/helpers/has-question-type";
|
|
15
14
|
import slugify from "@projectcaluma/ember-core/utils/slugify";
|
|
@@ -27,7 +26,7 @@ import saveDefaultStringAnswerMutation from "@projectcaluma/ember-form-builder/g
|
|
|
27
26
|
import saveDefaultTableAnswerMutation from "@projectcaluma/ember-form-builder/gql/mutations/save-default-table-answer.graphql";
|
|
28
27
|
import saveDynamicChoiceQuestionMutation from "@projectcaluma/ember-form-builder/gql/mutations/save-dynamic-choice-question.graphql";
|
|
29
28
|
import saveDynamicMultipleChoiceQuestionMutation from "@projectcaluma/ember-form-builder/gql/mutations/save-dynamic-multiple-choice-question.graphql";
|
|
30
|
-
import
|
|
29
|
+
import saveFilesQuestionMutation from "@projectcaluma/ember-form-builder/gql/mutations/save-files-question.graphql";
|
|
31
30
|
import saveFloatQuestionMutation from "@projectcaluma/ember-form-builder/gql/mutations/save-float-question.graphql";
|
|
32
31
|
import saveFormQuestionMutation from "@projectcaluma/ember-form-builder/gql/mutations/save-form-question.graphql";
|
|
33
32
|
import saveIntegerQuestionMutation from "@projectcaluma/ember-form-builder/gql/mutations/save-integer-question.graphql";
|
|
@@ -54,7 +53,7 @@ export const TYPES = {
|
|
|
54
53
|
DynamicChoiceQuestion: saveDynamicChoiceQuestionMutation,
|
|
55
54
|
TableQuestion: saveTableQuestionMutation,
|
|
56
55
|
FormQuestion: saveFormQuestionMutation,
|
|
57
|
-
|
|
56
|
+
FilesQuestion: saveFilesQuestionMutation,
|
|
58
57
|
StaticQuestion: saveStaticQuestionMutation,
|
|
59
58
|
DateQuestion: saveDateQuestionMutation,
|
|
60
59
|
CalculatedFloatQuestion: saveCalculatedFloatQuestionMutation,
|
|
@@ -106,6 +105,7 @@ export default class CfbFormEditorQuestion extends Component {
|
|
|
106
105
|
subForm: {},
|
|
107
106
|
meta: {},
|
|
108
107
|
dataSource: "",
|
|
108
|
+
formatValidators: null,
|
|
109
109
|
// action button
|
|
110
110
|
action: ACTIONS[0],
|
|
111
111
|
color: COLORS[0],
|
|
@@ -142,7 +142,9 @@ export default class CfbFormEditorQuestion extends Component {
|
|
|
142
142
|
if (!forms.map) {
|
|
143
143
|
return [];
|
|
144
144
|
}
|
|
145
|
-
return forms
|
|
145
|
+
return forms
|
|
146
|
+
.filter((edge) => edge.node.slug !== this.args.form)
|
|
147
|
+
.map((edge) => edge.node);
|
|
146
148
|
}
|
|
147
149
|
|
|
148
150
|
@restartableTask
|
|
@@ -182,20 +184,14 @@ export default class CfbFormEditorQuestion extends Component {
|
|
|
182
184
|
|
|
183
185
|
get availableOverrides() {
|
|
184
186
|
const type = this.changeset.get("__typename");
|
|
185
|
-
const overrides = this.calumaOptions
|
|
186
|
-
.getComponentOverrides()
|
|
187
|
-
.filter((override) => {
|
|
188
|
-
return !override.types || override.types.includes(type);
|
|
189
|
-
});
|
|
190
187
|
|
|
191
|
-
return
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
];
|
|
188
|
+
return this.calumaOptions.getComponentOverrides().filter((override) => {
|
|
189
|
+
return !override.types || override.types.includes(type);
|
|
190
|
+
});
|
|
195
191
|
}
|
|
196
192
|
|
|
197
193
|
get model() {
|
|
198
|
-
return this.data.lastSuccessful?.value?.
|
|
194
|
+
return this.data.lastSuccessful?.value?.[0]?.node;
|
|
199
195
|
}
|
|
200
196
|
|
|
201
197
|
get changeset() {
|
|
@@ -208,16 +204,25 @@ export default class CfbFormEditorQuestion extends Component {
|
|
|
208
204
|
: "";
|
|
209
205
|
}
|
|
210
206
|
|
|
207
|
+
get columnsToDisplayOptions() {
|
|
208
|
+
return this.model.rowForm?.questions.edges.map((edge) => ({
|
|
209
|
+
key: edge.node.slug,
|
|
210
|
+
label: edge.node.label,
|
|
211
|
+
}));
|
|
212
|
+
}
|
|
213
|
+
|
|
211
214
|
getInput(changeset) {
|
|
212
215
|
const slug =
|
|
213
216
|
((!this.args.slug && this.prefix) || "") + changeset.get("slug");
|
|
214
217
|
|
|
218
|
+
const rawMeta = changeset.get("meta");
|
|
219
|
+
|
|
215
220
|
const input = {
|
|
216
221
|
slug,
|
|
217
222
|
label: changeset.get("label"),
|
|
218
223
|
isHidden: changeset.get("isHidden"),
|
|
219
224
|
infoText: changeset.get("infoText"),
|
|
220
|
-
meta: JSON.stringify(
|
|
225
|
+
meta: JSON.stringify(rawMeta?.unwrap?.() ?? rawMeta),
|
|
221
226
|
isArchived: changeset.get("isArchived"),
|
|
222
227
|
};
|
|
223
228
|
|
|
@@ -242,6 +247,7 @@ export default class CfbFormEditorQuestion extends Component {
|
|
|
242
247
|
minValue: parseInt(changeset.get("integerMinValue")),
|
|
243
248
|
maxValue: parseInt(changeset.get("integerMaxValue")),
|
|
244
249
|
placeholder: changeset.get("placeholder"),
|
|
250
|
+
hintText: changeset.get("hintText"),
|
|
245
251
|
};
|
|
246
252
|
}
|
|
247
253
|
|
|
@@ -250,6 +256,7 @@ export default class CfbFormEditorQuestion extends Component {
|
|
|
250
256
|
minValue: parseFloat(changeset.get("floatMinValue")),
|
|
251
257
|
maxValue: parseFloat(changeset.get("floatMaxValue")),
|
|
252
258
|
placeholder: changeset.get("placeholder"),
|
|
259
|
+
hintText: changeset.get("hintText"),
|
|
253
260
|
};
|
|
254
261
|
}
|
|
255
262
|
|
|
@@ -258,6 +265,10 @@ export default class CfbFormEditorQuestion extends Component {
|
|
|
258
265
|
minLength: parseInt(changeset.get("minLength")),
|
|
259
266
|
maxLength: parseInt(changeset.get("maxLength")),
|
|
260
267
|
placeholder: changeset.get("placeholder"),
|
|
268
|
+
formatValidators: changeset
|
|
269
|
+
.get("formatValidators")
|
|
270
|
+
?.edges.map((edge) => edge.node.slug),
|
|
271
|
+
hintText: changeset.get("hintText"),
|
|
261
272
|
};
|
|
262
273
|
}
|
|
263
274
|
|
|
@@ -266,36 +277,51 @@ export default class CfbFormEditorQuestion extends Component {
|
|
|
266
277
|
minLength: parseInt(changeset.get("minLength")),
|
|
267
278
|
maxLength: parseInt(changeset.get("maxLength")),
|
|
268
279
|
placeholder: changeset.get("placeholder"),
|
|
280
|
+
formatValidators: changeset
|
|
281
|
+
.get("formatValidators")
|
|
282
|
+
?.edges.map((edge) => edge.node.slug),
|
|
283
|
+
hintText: changeset.get("hintText"),
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
_getDateQuestionInput(changeset) {
|
|
288
|
+
return {
|
|
289
|
+
hintText: changeset.get("hintText"),
|
|
269
290
|
};
|
|
270
291
|
}
|
|
271
292
|
|
|
272
293
|
_getMultipleChoiceQuestionInput(changeset) {
|
|
273
294
|
return {
|
|
274
295
|
options: changeset.get("options.edges").map(({ node: { slug } }) => slug),
|
|
296
|
+
hintText: changeset.get("hintText"),
|
|
275
297
|
};
|
|
276
298
|
}
|
|
277
299
|
|
|
278
300
|
_getChoiceQuestionInput(changeset) {
|
|
279
301
|
return {
|
|
280
302
|
options: changeset.get("options.edges").map(({ node: { slug } }) => slug),
|
|
303
|
+
hintText: changeset.get("hintText"),
|
|
281
304
|
};
|
|
282
305
|
}
|
|
283
306
|
|
|
284
307
|
_getDynamicMultipleChoiceQuestionInput(changeset) {
|
|
285
308
|
return {
|
|
286
309
|
dataSource: changeset.get("dataSource"),
|
|
310
|
+
hintText: changeset.get("hintText"),
|
|
287
311
|
};
|
|
288
312
|
}
|
|
289
313
|
|
|
290
314
|
_getDynamicChoiceQuestionInput(changeset) {
|
|
291
315
|
return {
|
|
292
316
|
dataSource: changeset.get("dataSource"),
|
|
317
|
+
hintText: changeset.get("hintText"),
|
|
293
318
|
};
|
|
294
319
|
}
|
|
295
320
|
|
|
296
321
|
_getTableQuestionInput(changeset) {
|
|
297
322
|
return {
|
|
298
323
|
rowForm: changeset.get("rowForm.slug"),
|
|
324
|
+
hintText: changeset.get("hintText"),
|
|
299
325
|
};
|
|
300
326
|
}
|
|
301
327
|
|
|
@@ -314,6 +340,13 @@ export default class CfbFormEditorQuestion extends Component {
|
|
|
314
340
|
_getCalculatedFloatQuestionInput(changeset) {
|
|
315
341
|
return {
|
|
316
342
|
calcExpression: changeset.get("calcExpression"),
|
|
343
|
+
hintText: changeset.get("hintText"),
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
_getFilesQuestionInput(changeset) {
|
|
348
|
+
return {
|
|
349
|
+
hintText: changeset.get("hintText"),
|
|
317
350
|
};
|
|
318
351
|
}
|
|
319
352
|
|
|
@@ -327,7 +360,7 @@ export default class CfbFormEditorQuestion extends Component {
|
|
|
327
360
|
|
|
328
361
|
@task
|
|
329
362
|
*saveOptions(changeset) {
|
|
330
|
-
yield all(
|
|
363
|
+
yield Promise.all(
|
|
331
364
|
(changeset.get("options.edges") || []).map(async ({ node: option }) => {
|
|
332
365
|
const { label, slug, isArchived } = option;
|
|
333
366
|
|
|
@@ -420,10 +453,9 @@ export default class CfbFormEditorQuestion extends Component {
|
|
|
420
453
|
@restartableTask
|
|
421
454
|
*validateSlug(slug, changeset) {
|
|
422
455
|
/* istanbul ignore next */
|
|
423
|
-
if (
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
) {
|
|
456
|
+
if (macroCondition(isTesting())) {
|
|
457
|
+
// no timeout
|
|
458
|
+
} else {
|
|
427
459
|
yield timeout(500);
|
|
428
460
|
}
|
|
429
461
|
|
|
@@ -471,19 +503,6 @@ export default class CfbFormEditorQuestion extends Component {
|
|
|
471
503
|
this.validateSlug.perform(this.prefix + value, changeset);
|
|
472
504
|
}
|
|
473
505
|
|
|
474
|
-
/*
|
|
475
|
-
* This function adds the selected slugs to the columns to display
|
|
476
|
-
* list if it isnt present, otherwise it will remove the slug.
|
|
477
|
-
*/
|
|
478
|
-
@action
|
|
479
|
-
toggleColumnToDisplay(value, changeset) {
|
|
480
|
-
const displayed = new Set(changeset.get("meta.columnsToDisplay"));
|
|
481
|
-
|
|
482
|
-
displayed.delete(value) || displayed.add(value);
|
|
483
|
-
|
|
484
|
-
changeset.set("meta.columnsToDisplay", [...displayed]);
|
|
485
|
-
}
|
|
486
|
-
|
|
487
506
|
@action
|
|
488
507
|
updateSubForm(value, changeset) {
|
|
489
508
|
changeset.set("subForm.slug", value.slug);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
<div class="uk-flex uk-flex-between">
|
|
2
2
|
<div class="uk-button-group">
|
|
3
|
-
{{#each
|
|
3
|
+
{{#each this.categories as |category|}}
|
|
4
4
|
<UkButton
|
|
5
|
-
data-test-filter={{category}}
|
|
6
|
-
@onClick={{fn
|
|
7
|
-
@label={{
|
|
8
|
-
@
|
|
5
|
+
data-test-filter={{category.value}}
|
|
6
|
+
@onClick={{fn @onUpdateCategory category.value}}
|
|
7
|
+
@label={{category.label}}
|
|
8
|
+
@color={{if (eq @category category.value) "primary"}}
|
|
9
9
|
/>
|
|
10
10
|
{{/each}}
|
|
11
11
|
</div>
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
type="search"
|
|
27
27
|
placeholder="{{t 'caluma.form-builder.global.search'}}..."
|
|
28
28
|
aria-label="{{t 'caluma.form-builder.global.search'}}"
|
|
29
|
-
value={{
|
|
30
|
-
{{on "input" (
|
|
29
|
+
value={{@search}}
|
|
30
|
+
{{on "input" (perform this.search)}}
|
|
31
31
|
/>
|
|
32
32
|
</div>
|
|
33
33
|
|
|
@@ -1,38 +1,71 @@
|
|
|
1
|
+
import { inject as service } from "@ember/service";
|
|
2
|
+
import { macroCondition, isTesting } from "@embroider/macros";
|
|
1
3
|
import Component from "@glimmer/component";
|
|
2
|
-
import { tracked } from "@glimmer/tracking";
|
|
3
4
|
import { timeout, restartableTask } from "ember-concurrency";
|
|
4
5
|
|
|
5
6
|
import { useCalumaQuery } from "@projectcaluma/ember-core/caluma-query";
|
|
6
7
|
import { allForms } from "@projectcaluma/ember-core/caluma-query/queries";
|
|
7
8
|
|
|
8
9
|
export default class ComponentsCfbFormListComponent extends Component {
|
|
10
|
+
@service intl;
|
|
11
|
+
|
|
9
12
|
formsQuery = useCalumaQuery(this, allForms, () => ({
|
|
10
13
|
options: { pageSize: 20 },
|
|
11
14
|
filter: this.filter,
|
|
12
15
|
order: [{ attribute: "NAME", direction: "ASC" }],
|
|
13
16
|
}));
|
|
14
17
|
|
|
15
|
-
|
|
16
|
-
|
|
18
|
+
get categories() {
|
|
19
|
+
return [
|
|
20
|
+
{
|
|
21
|
+
value: "active",
|
|
22
|
+
label: this.intl.t("caluma.form-builder.form.active"),
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
value: "archived",
|
|
26
|
+
label: this.intl.t("caluma.form-builder.form.isArchived"),
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
value: "published",
|
|
30
|
+
label: this.intl.t("caluma.form-builder.form.isPublished"),
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
value: "unpublished",
|
|
34
|
+
label: this.intl.t("caluma.form-builder.form.draft"),
|
|
35
|
+
},
|
|
36
|
+
{ value: "all", label: this.intl.t("caluma.form-builder.form.all") },
|
|
37
|
+
];
|
|
38
|
+
}
|
|
17
39
|
|
|
18
40
|
get filter() {
|
|
19
41
|
const isArchived =
|
|
20
|
-
this.category === "active"
|
|
42
|
+
this.args.category === "active"
|
|
21
43
|
? { isArchived: false }
|
|
22
|
-
: this.category === "archived"
|
|
44
|
+
: this.args.category === "archived"
|
|
23
45
|
? { isArchived: true }
|
|
24
46
|
: null;
|
|
25
47
|
|
|
26
|
-
const search = this.search ? { search: this.search } : null;
|
|
48
|
+
const search = this.args.search ? { search: this.args.search } : null;
|
|
49
|
+
|
|
50
|
+
const isPublished =
|
|
51
|
+
this.args.category === "unpublished"
|
|
52
|
+
? { isPublished: false }
|
|
53
|
+
: this.args.category === "published"
|
|
54
|
+
? { isPublished: true }
|
|
55
|
+
: null;
|
|
27
56
|
|
|
28
|
-
return [isArchived, search].filter(Boolean) || null;
|
|
57
|
+
return [isArchived, isPublished, search].filter(Boolean) || null;
|
|
29
58
|
}
|
|
30
59
|
|
|
31
60
|
@restartableTask
|
|
32
|
-
*
|
|
33
|
-
|
|
61
|
+
*search(event) {
|
|
62
|
+
/* istanbul ignore next */
|
|
63
|
+
if (macroCondition(isTesting())) {
|
|
64
|
+
// no timeout
|
|
65
|
+
} else {
|
|
66
|
+
yield timeout(500);
|
|
67
|
+
}
|
|
34
68
|
|
|
35
|
-
this
|
|
36
|
-
eventOrValue instanceof Event ? eventOrValue.target.value : eventOrValue;
|
|
69
|
+
this.args.onUpdateSearch(event.target.value);
|
|
37
70
|
}
|
|
38
71
|
}
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import Controller from "@ember/controller";
|
|
2
2
|
import { action } from "@ember/object";
|
|
3
3
|
import { inject as service } from "@ember/service";
|
|
4
|
+
import { tracked } from "@glimmer/tracking";
|
|
4
5
|
|
|
5
6
|
export default class IndexController extends Controller {
|
|
6
7
|
@service router;
|
|
7
8
|
|
|
9
|
+
queryParams = ["search", "category"];
|
|
10
|
+
|
|
11
|
+
@tracked search = "";
|
|
12
|
+
@tracked category = "active";
|
|
13
|
+
|
|
8
14
|
@action
|
|
9
15
|
newForm() {
|
|
10
16
|
this.router.transitionTo("new");
|
package/addon/engine.js
CHANGED
|
@@ -11,7 +11,7 @@ export default class FormBuilderEngine extends Engine {
|
|
|
11
11
|
Resolver = Resolver;
|
|
12
12
|
|
|
13
13
|
dependencies = {
|
|
14
|
-
services: ["apollo", "notification", "intl", "caluma-options"
|
|
14
|
+
services: ["apollo", "notification", "intl", "caluma-options"],
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
17
|
|