@projectcaluma/ember-form-builder 11.0.0-beta.9 → 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 +82 -0
- package/addon/components/cfb-code-editor.hbs +26 -10
- package/addon/components/cfb-code-editor.js +60 -11
- 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 +51 -90
- 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 +1 -1
- 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 -48
- package/translations/de.yaml +5 -4
- package/translations/en.yaml +4 -3
- package/translations/fr.yaml +4 -4
- 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")}}
|
|
@@ -143,25 +128,18 @@
|
|
|
143
128
|
{{autoresize mode="height"}}
|
|
144
129
|
/>
|
|
145
130
|
{{else}}
|
|
146
|
-
<
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
<a
|
|
159
|
-
target="_blank"
|
|
160
|
-
rel="noopener noreferrer"
|
|
161
|
-
href="https://www.markdownguide.org/basic-syntax"
|
|
162
|
-
>{{t "caluma.form-builder.question.markdown"}}</a>
|
|
163
|
-
</small>
|
|
164
|
-
</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
|
+
/>
|
|
165
143
|
{{/if}}
|
|
166
144
|
|
|
167
145
|
{{#if (has-question-type f.model "text" "textarea" "integer" "float")}}
|
|
@@ -210,7 +188,7 @@
|
|
|
210
188
|
<f.input
|
|
211
189
|
@name="formatValidators"
|
|
212
190
|
@label={{t "caluma.form-builder.question.formatValidators"}}
|
|
213
|
-
@placeholder={{t "caluma.form-builder.question.
|
|
191
|
+
@placeholder={{t "caluma.form-builder.question.no-selection"}}
|
|
214
192
|
@required={{false}}
|
|
215
193
|
@renderComponent={{component "cfb-form-editor/question/validation"}}
|
|
216
194
|
@on-update={{changeset-set f.model "formatValidators"}}
|
|
@@ -243,17 +221,18 @@
|
|
|
243
221
|
<div uk-grid class="uk-grid-small uk-child-width-1-2 uk-margin">
|
|
244
222
|
<div>
|
|
245
223
|
<f.input
|
|
224
|
+
@type="number"
|
|
246
225
|
@name="floatMinValue"
|
|
247
226
|
@label={{t "caluma.form-builder.question.min-value"}}
|
|
248
|
-
|
|
227
|
+
step="any"
|
|
249
228
|
/>
|
|
250
229
|
</div>
|
|
251
|
-
|
|
252
230
|
<div>
|
|
253
231
|
<f.input
|
|
232
|
+
@type="number"
|
|
254
233
|
@name="floatMaxValue"
|
|
255
234
|
@label={{t "caluma.form-builder.question.max-value"}}
|
|
256
|
-
|
|
235
|
+
step="any"
|
|
257
236
|
/>
|
|
258
237
|
</div>
|
|
259
238
|
</div>
|
|
@@ -296,10 +275,10 @@
|
|
|
296
275
|
@type="select"
|
|
297
276
|
@required={{true}}
|
|
298
277
|
@label={{t "caluma.form-builder.question.dataSource"}}
|
|
299
|
-
@options={{or this.availableDataSources.lastSuccessful.value array}}
|
|
278
|
+
@options={{or this.availableDataSources.lastSuccessful.value (array)}}
|
|
300
279
|
@optionTargetPath="name"
|
|
301
280
|
@optionLabelPath="info"
|
|
302
|
-
@
|
|
281
|
+
@prompt={{t "caluma.form-builder.question.no-selection"}}
|
|
303
282
|
/>
|
|
304
283
|
{{/if}}
|
|
305
284
|
|
|
@@ -329,9 +308,9 @@
|
|
|
329
308
|
as |fi|
|
|
330
309
|
>
|
|
331
310
|
<PowerSelect
|
|
332
|
-
@options={{or this.availableForms.lastSuccessful.value array}}
|
|
311
|
+
@options={{or this.availableForms.lastSuccessful.value (array)}}
|
|
333
312
|
@selected={{fi.value}}
|
|
334
|
-
@placeholder={{t "caluma.form-builder.question.
|
|
313
|
+
@placeholder={{t "caluma.form-builder.question.no-selection"}}
|
|
335
314
|
@onBlur={{fi.setDirty}}
|
|
336
315
|
@onChange={{fi.update}}
|
|
337
316
|
@searchField="slug"
|
|
@@ -360,33 +339,12 @@
|
|
|
360
339
|
</div>
|
|
361
340
|
|
|
362
341
|
{{#if @slug}}
|
|
363
|
-
<
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
{{#let rowEdge.node as |row|}}
|
|
370
|
-
<label class="cf-checkbox_label">
|
|
371
|
-
<input
|
|
372
|
-
type="checkbox"
|
|
373
|
-
value={{row.slug}}
|
|
374
|
-
checked={{includes
|
|
375
|
-
row.slug
|
|
376
|
-
this.model.meta.columnsToDisplay
|
|
377
|
-
}}
|
|
378
|
-
class="uk-checkbox uk-margin-small-right"
|
|
379
|
-
{{on
|
|
380
|
-
"change"
|
|
381
|
-
(fn this.toggleColumnToDisplay row.slug f.model)
|
|
382
|
-
}}
|
|
383
|
-
/>
|
|
384
|
-
{{row.label}}
|
|
385
|
-
</label>
|
|
386
|
-
{{/let}}
|
|
387
|
-
{{/each}}
|
|
388
|
-
</f.input>
|
|
389
|
-
</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
|
+
/>
|
|
390
348
|
{{/if}}
|
|
391
349
|
{{/if}}
|
|
392
350
|
|
|
@@ -404,9 +362,9 @@
|
|
|
404
362
|
as |fi|
|
|
405
363
|
>
|
|
406
364
|
<PowerSelect
|
|
407
|
-
@options={{or this.availableForms.lastSuccessful.value array}}
|
|
365
|
+
@options={{or this.availableForms.lastSuccessful.value (array)}}
|
|
408
366
|
@selected={{fi.value}}
|
|
409
|
-
@placeholder={{t "caluma.form-builder.question.
|
|
367
|
+
@placeholder={{t "caluma.form-builder.question.no-selection"}}
|
|
410
368
|
@onBlur={{fi.setDirty}}
|
|
411
369
|
@onChange={{fi.update}}
|
|
412
370
|
@searchField="slug"
|
|
@@ -438,6 +396,7 @@
|
|
|
438
396
|
@optionTargetPath="component"
|
|
439
397
|
@optionLabelPath="label"
|
|
440
398
|
@options={{this.availableOverrides}}
|
|
399
|
+
@prompt={{t "caluma.form-builder.question.no-selection"}}
|
|
441
400
|
/>
|
|
442
401
|
|
|
443
402
|
<f.input
|
|
@@ -470,13 +429,11 @@
|
|
|
470
429
|
/>
|
|
471
430
|
{{/if}}
|
|
472
431
|
|
|
473
|
-
<
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
/>
|
|
479
|
-
</div>
|
|
432
|
+
<f.input
|
|
433
|
+
@label={{t "caluma.form-builder.question.isHidden"}}
|
|
434
|
+
@name="isHidden"
|
|
435
|
+
@renderComponent={{component "cfb-code-editor" language="jexl"}}
|
|
436
|
+
/>
|
|
480
437
|
|
|
481
438
|
{{#if
|
|
482
439
|
(not
|
|
@@ -485,14 +442,18 @@
|
|
|
485
442
|
)
|
|
486
443
|
)
|
|
487
444
|
}}
|
|
488
|
-
<
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
/>
|
|
494
|
-
</div>
|
|
445
|
+
<f.input
|
|
446
|
+
@label={{t "caluma.form-builder.question.isRequired"}}
|
|
447
|
+
@name="isRequired"
|
|
448
|
+
@renderComponent={{component "cfb-code-editor" language="jexl"}}
|
|
449
|
+
/>
|
|
495
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
|
+
/>
|
|
496
457
|
{{/if}}
|
|
497
458
|
|
|
498
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");
|