@projectcaluma/ember-form-builder 11.0.0-beta.8 → 11.0.0
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 +89 -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 +15 -13
- package/addon/components/cfb-form-editor/question/validation.js +2 -2
- 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 -7
- package/addon/components/cfb-form-editor/question.hbs +52 -93
- package/addon/components/cfb-form-editor/question.js +46 -34
- package/addon/components/cfb-form-list.hbs +7 -7
- package/addon/components/cfb-form-list.js +42 -15
- package/addon/controllers/index.js +6 -0
- 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/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 +16 -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 +58 -47
- 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/addon/modifiers/pikaday.js +0 -2
- 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")}}
|
|
@@ -209,7 +188,7 @@
|
|
|
209
188
|
<f.input
|
|
210
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
194
|
@on-update={{changeset-set f.model "formatValidators"}}
|
|
@@ -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,
|
|
@@ -143,7 +142,9 @@ export default class CfbFormEditorQuestion extends Component {
|
|
|
143
142
|
if (!forms.map) {
|
|
144
143
|
return [];
|
|
145
144
|
}
|
|
146
|
-
return forms
|
|
145
|
+
return forms
|
|
146
|
+
.filter((edge) => edge.node.slug !== this.args.form)
|
|
147
|
+
.map((edge) => edge.node);
|
|
147
148
|
}
|
|
148
149
|
|
|
149
150
|
@restartableTask
|
|
@@ -183,20 +184,14 @@ export default class CfbFormEditorQuestion extends Component {
|
|
|
183
184
|
|
|
184
185
|
get availableOverrides() {
|
|
185
186
|
const type = this.changeset.get("__typename");
|
|
186
|
-
const overrides = this.calumaOptions
|
|
187
|
-
.getComponentOverrides()
|
|
188
|
-
.filter((override) => {
|
|
189
|
-
return !override.types || override.types.includes(type);
|
|
190
|
-
});
|
|
191
187
|
|
|
192
|
-
return
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
];
|
|
188
|
+
return this.calumaOptions.getComponentOverrides().filter((override) => {
|
|
189
|
+
return !override.types || override.types.includes(type);
|
|
190
|
+
});
|
|
196
191
|
}
|
|
197
192
|
|
|
198
193
|
get model() {
|
|
199
|
-
return this.data.lastSuccessful?.value?.
|
|
194
|
+
return this.data.lastSuccessful?.value?.[0]?.node;
|
|
200
195
|
}
|
|
201
196
|
|
|
202
197
|
get changeset() {
|
|
@@ -209,16 +204,25 @@ export default class CfbFormEditorQuestion extends Component {
|
|
|
209
204
|
: "";
|
|
210
205
|
}
|
|
211
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
|
+
|
|
212
214
|
getInput(changeset) {
|
|
213
215
|
const slug =
|
|
214
216
|
((!this.args.slug && this.prefix) || "") + changeset.get("slug");
|
|
215
217
|
|
|
218
|
+
const rawMeta = changeset.get("meta");
|
|
219
|
+
|
|
216
220
|
const input = {
|
|
217
221
|
slug,
|
|
218
222
|
label: changeset.get("label"),
|
|
219
223
|
isHidden: changeset.get("isHidden"),
|
|
220
224
|
infoText: changeset.get("infoText"),
|
|
221
|
-
meta: JSON.stringify(
|
|
225
|
+
meta: JSON.stringify(rawMeta?.unwrap?.() ?? rawMeta),
|
|
222
226
|
isArchived: changeset.get("isArchived"),
|
|
223
227
|
};
|
|
224
228
|
|
|
@@ -243,6 +247,7 @@ export default class CfbFormEditorQuestion extends Component {
|
|
|
243
247
|
minValue: parseInt(changeset.get("integerMinValue")),
|
|
244
248
|
maxValue: parseInt(changeset.get("integerMaxValue")),
|
|
245
249
|
placeholder: changeset.get("placeholder"),
|
|
250
|
+
hintText: changeset.get("hintText"),
|
|
246
251
|
};
|
|
247
252
|
}
|
|
248
253
|
|
|
@@ -251,6 +256,7 @@ export default class CfbFormEditorQuestion extends Component {
|
|
|
251
256
|
minValue: parseFloat(changeset.get("floatMinValue")),
|
|
252
257
|
maxValue: parseFloat(changeset.get("floatMaxValue")),
|
|
253
258
|
placeholder: changeset.get("placeholder"),
|
|
259
|
+
hintText: changeset.get("hintText"),
|
|
254
260
|
};
|
|
255
261
|
}
|
|
256
262
|
|
|
@@ -262,6 +268,7 @@ export default class CfbFormEditorQuestion extends Component {
|
|
|
262
268
|
formatValidators: changeset
|
|
263
269
|
.get("formatValidators")
|
|
264
270
|
?.edges.map((edge) => edge.node.slug),
|
|
271
|
+
hintText: changeset.get("hintText"),
|
|
265
272
|
};
|
|
266
273
|
}
|
|
267
274
|
|
|
@@ -273,36 +280,48 @@ export default class CfbFormEditorQuestion extends Component {
|
|
|
273
280
|
formatValidators: changeset
|
|
274
281
|
.get("formatValidators")
|
|
275
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"),
|
|
276
290
|
};
|
|
277
291
|
}
|
|
278
292
|
|
|
279
293
|
_getMultipleChoiceQuestionInput(changeset) {
|
|
280
294
|
return {
|
|
281
295
|
options: changeset.get("options.edges").map(({ node: { slug } }) => slug),
|
|
296
|
+
hintText: changeset.get("hintText"),
|
|
282
297
|
};
|
|
283
298
|
}
|
|
284
299
|
|
|
285
300
|
_getChoiceQuestionInput(changeset) {
|
|
286
301
|
return {
|
|
287
302
|
options: changeset.get("options.edges").map(({ node: { slug } }) => slug),
|
|
303
|
+
hintText: changeset.get("hintText"),
|
|
288
304
|
};
|
|
289
305
|
}
|
|
290
306
|
|
|
291
307
|
_getDynamicMultipleChoiceQuestionInput(changeset) {
|
|
292
308
|
return {
|
|
293
309
|
dataSource: changeset.get("dataSource"),
|
|
310
|
+
hintText: changeset.get("hintText"),
|
|
294
311
|
};
|
|
295
312
|
}
|
|
296
313
|
|
|
297
314
|
_getDynamicChoiceQuestionInput(changeset) {
|
|
298
315
|
return {
|
|
299
316
|
dataSource: changeset.get("dataSource"),
|
|
317
|
+
hintText: changeset.get("hintText"),
|
|
300
318
|
};
|
|
301
319
|
}
|
|
302
320
|
|
|
303
321
|
_getTableQuestionInput(changeset) {
|
|
304
322
|
return {
|
|
305
323
|
rowForm: changeset.get("rowForm.slug"),
|
|
324
|
+
hintText: changeset.get("hintText"),
|
|
306
325
|
};
|
|
307
326
|
}
|
|
308
327
|
|
|
@@ -321,6 +340,13 @@ export default class CfbFormEditorQuestion extends Component {
|
|
|
321
340
|
_getCalculatedFloatQuestionInput(changeset) {
|
|
322
341
|
return {
|
|
323
342
|
calcExpression: changeset.get("calcExpression"),
|
|
343
|
+
hintText: changeset.get("hintText"),
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
_getFilesQuestionInput(changeset) {
|
|
348
|
+
return {
|
|
349
|
+
hintText: changeset.get("hintText"),
|
|
324
350
|
};
|
|
325
351
|
}
|
|
326
352
|
|
|
@@ -334,7 +360,7 @@ export default class CfbFormEditorQuestion extends Component {
|
|
|
334
360
|
|
|
335
361
|
@task
|
|
336
362
|
*saveOptions(changeset) {
|
|
337
|
-
yield all(
|
|
363
|
+
yield Promise.all(
|
|
338
364
|
(changeset.get("options.edges") || []).map(async ({ node: option }) => {
|
|
339
365
|
const { label, slug, isArchived } = option;
|
|
340
366
|
|
|
@@ -426,11 +452,10 @@ export default class CfbFormEditorQuestion extends Component {
|
|
|
426
452
|
|
|
427
453
|
@restartableTask
|
|
428
454
|
*validateSlug(slug, changeset) {
|
|
429
|
-
const { environment } =
|
|
430
|
-
getOwner(this).resolveRegistration("config:environment");
|
|
431
|
-
|
|
432
455
|
/* istanbul ignore next */
|
|
433
|
-
if (
|
|
456
|
+
if (macroCondition(isTesting())) {
|
|
457
|
+
// no timeout
|
|
458
|
+
} else {
|
|
434
459
|
yield timeout(500);
|
|
435
460
|
}
|
|
436
461
|
|
|
@@ -478,19 +503,6 @@ export default class CfbFormEditorQuestion extends Component {
|
|
|
478
503
|
this.validateSlug.perform(this.prefix + value, changeset);
|
|
479
504
|
}
|
|
480
505
|
|
|
481
|
-
/*
|
|
482
|
-
* This function adds the selected slugs to the columns to display
|
|
483
|
-
* list if it isnt present, otherwise it will remove the slug.
|
|
484
|
-
*/
|
|
485
|
-
@action
|
|
486
|
-
toggleColumnToDisplay(value, changeset) {
|
|
487
|
-
const displayed = new Set(changeset.get("meta.columnsToDisplay"));
|
|
488
|
-
|
|
489
|
-
displayed.delete(value) || displayed.add(value);
|
|
490
|
-
|
|
491
|
-
changeset.set("meta.columnsToDisplay", [...displayed]);
|
|
492
|
-
}
|
|
493
|
-
|
|
494
506
|
@action
|
|
495
507
|
updateSubForm(value, changeset) {
|
|
496
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
|
-
@color={{if (eq
|
|
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,44 +1,71 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { inject as service } from "@ember/service";
|
|
2
|
+
import { macroCondition, isTesting } from "@embroider/macros";
|
|
2
3
|
import Component from "@glimmer/component";
|
|
3
|
-
import { tracked } from "@glimmer/tracking";
|
|
4
4
|
import { timeout, restartableTask } from "ember-concurrency";
|
|
5
5
|
|
|
6
6
|
import { useCalumaQuery } from "@projectcaluma/ember-core/caluma-query";
|
|
7
7
|
import { allForms } from "@projectcaluma/ember-core/caluma-query/queries";
|
|
8
8
|
|
|
9
9
|
export default class ComponentsCfbFormListComponent extends Component {
|
|
10
|
+
@service intl;
|
|
11
|
+
|
|
10
12
|
formsQuery = useCalumaQuery(this, allForms, () => ({
|
|
11
13
|
options: { pageSize: 20 },
|
|
12
14
|
filter: this.filter,
|
|
13
15
|
order: [{ attribute: "NAME", direction: "ASC" }],
|
|
14
16
|
}));
|
|
15
17
|
|
|
16
|
-
|
|
17
|
-
|
|
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
|
+
}
|
|
18
39
|
|
|
19
40
|
get filter() {
|
|
20
41
|
const isArchived =
|
|
21
|
-
this.category === "active"
|
|
42
|
+
this.args.category === "active"
|
|
22
43
|
? { isArchived: false }
|
|
23
|
-
: this.category === "archived"
|
|
44
|
+
: this.args.category === "archived"
|
|
24
45
|
? { isArchived: true }
|
|
25
46
|
: null;
|
|
26
47
|
|
|
27
|
-
const search = this.search ? { search: this.search } : null;
|
|
48
|
+
const search = this.args.search ? { search: this.args.search } : null;
|
|
28
49
|
|
|
29
|
-
|
|
50
|
+
const isPublished =
|
|
51
|
+
this.args.category === "unpublished"
|
|
52
|
+
? { isPublished: false }
|
|
53
|
+
: this.args.category === "published"
|
|
54
|
+
? { isPublished: true }
|
|
55
|
+
: null;
|
|
56
|
+
|
|
57
|
+
return [isArchived, isPublished, search].filter(Boolean) || null;
|
|
30
58
|
}
|
|
31
59
|
|
|
32
60
|
@restartableTask
|
|
33
|
-
*
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
61
|
+
*search(event) {
|
|
62
|
+
/* istanbul ignore next */
|
|
63
|
+
if (macroCondition(isTesting())) {
|
|
64
|
+
// no timeout
|
|
65
|
+
} else {
|
|
38
66
|
yield timeout(500);
|
|
39
67
|
}
|
|
40
68
|
|
|
41
|
-
this
|
|
42
|
-
eventOrValue instanceof Event ? eventOrValue.target.value : eventOrValue;
|
|
69
|
+
this.args.onUpdateSearch(event.target.value);
|
|
43
70
|
}
|
|
44
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");
|