@projectcaluma/ember-form-builder 11.0.0-beta.2 → 11.0.0-beta.26
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 +154 -0
- package/addon/components/cfb-code-editor.hbs +2 -1
- package/addon/components/cfb-code-editor.js +59 -11
- package/addon/components/cfb-form-editor/general.hbs +2 -4
- package/addon/components/cfb-form-editor/general.js +7 -9
- package/addon/components/cfb-form-editor/question/options.hbs +1 -1
- package/addon/components/cfb-form-editor/question/validation.hbs +2 -2
- package/addon/components/cfb-form-editor/question/validation.js +17 -13
- package/addon/components/cfb-form-editor/question-list/item.hbs +21 -13
- package/addon/components/cfb-form-editor/question-list/item.js +2 -2
- package/addon/components/cfb-form-editor/question-list.hbs +6 -6
- package/addon/components/cfb-form-editor/question-list.js +12 -7
- package/addon/components/cfb-form-editor/question.hbs +29 -15
- package/addon/components/cfb-form-editor/question.js +50 -24
- package/addon/components/cfb-form-editor.hbs +5 -5
- package/addon/components/cfb-form-list/item.hbs +1 -1
- package/addon/components/cfb-form-list.hbs +9 -9
- package/addon/components/cfb-form-list.js +44 -11
- package/addon/components/cfb-toggle-switch.hbs +1 -1
- package/addon/controllers/index.js +6 -0
- package/addon/engine.js +1 -1
- package/addon/gql/fragments/field.graphql +14 -2
- 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 +29 -1
- package/addon/gql/queries/search-form-question.graphql +3 -3
- package/addon/instance-initializers/form-builder-widget-overrides.js +15 -0
- package/addon/modifiers/pikaday.js +2 -0
- package/addon/routes/edit/questions/edit.js +2 -1
- package/addon/routes/edit.js +1 -1
- package/addon/templates/edit/questions/edit.hbs +1 -1
- package/addon/templates/edit/questions/new.hbs +1 -4
- package/addon/templates/edit.hbs +5 -5
- package/addon/templates/index.hbs +8 -1
- package/addon/templates/new.hbs +1 -1
- package/addon/validations/question.js +6 -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/index.js +0 -6
- package/package.json +45 -34
- package/translations/de.yaml +7 -6
- package/translations/en.yaml +4 -3
- package/translations/fr.yaml +154 -1
- package/addon/gql/mutations/save-file-question.graphql +0 -11
- package/app/styles/_cfb-powerselect.scss +0 -31
|
@@ -140,6 +140,7 @@
|
|
|
140
140
|
@label={{t "caluma.form-builder.question.confirmationText"}}
|
|
141
141
|
@name="infoText"
|
|
142
142
|
@type="textarea"
|
|
143
|
+
{{autoresize mode="height"}}
|
|
143
144
|
/>
|
|
144
145
|
{{else}}
|
|
145
146
|
<div class="uk-margin">
|
|
@@ -163,6 +164,13 @@
|
|
|
163
164
|
</div>
|
|
164
165
|
{{/if}}
|
|
165
166
|
|
|
167
|
+
{{#if (not (has-question-type f.model "action-button" "static" "form"))}}
|
|
168
|
+
<f.input
|
|
169
|
+
@name="hintText"
|
|
170
|
+
@label={{t "caluma.form-builder.question.hintText"}}
|
|
171
|
+
/>
|
|
172
|
+
{{/if}}
|
|
173
|
+
|
|
166
174
|
{{#if (has-question-type f.model "text" "textarea" "integer" "float")}}
|
|
167
175
|
<f.input
|
|
168
176
|
@name="placeholder"
|
|
@@ -207,13 +215,13 @@
|
|
|
207
215
|
/>
|
|
208
216
|
|
|
209
217
|
<f.input
|
|
210
|
-
@name="
|
|
218
|
+
@name="formatValidators"
|
|
211
219
|
@label={{t "caluma.form-builder.question.formatValidators"}}
|
|
212
|
-
@placeholder={{t "caluma.form-builder.question.
|
|
220
|
+
@placeholder={{t "caluma.form-builder.question.no-selection"}}
|
|
213
221
|
@required={{false}}
|
|
214
222
|
@renderComponent={{component "cfb-form-editor/question/validation"}}
|
|
215
|
-
@on-update={{changeset-set f.model "
|
|
216
|
-
@value={{changeset-get f.model "
|
|
223
|
+
@on-update={{changeset-set f.model "formatValidators"}}
|
|
224
|
+
@value={{changeset-get f.model "formatValidators"}}
|
|
217
225
|
/>
|
|
218
226
|
{{/if}}
|
|
219
227
|
|
|
@@ -295,10 +303,10 @@
|
|
|
295
303
|
@type="select"
|
|
296
304
|
@required={{true}}
|
|
297
305
|
@label={{t "caluma.form-builder.question.dataSource"}}
|
|
298
|
-
@options={{or this.availableDataSources.lastSuccessful.value array}}
|
|
306
|
+
@options={{or this.availableDataSources.lastSuccessful.value (array)}}
|
|
299
307
|
@optionTargetPath="name"
|
|
300
308
|
@optionLabelPath="info"
|
|
301
|
-
@
|
|
309
|
+
@prompt={{t "caluma.form-builder.question.no-selection"}}
|
|
302
310
|
/>
|
|
303
311
|
{{/if}}
|
|
304
312
|
|
|
@@ -328,9 +336,9 @@
|
|
|
328
336
|
as |fi|
|
|
329
337
|
>
|
|
330
338
|
<PowerSelect
|
|
331
|
-
@options={{or this.availableForms.lastSuccessful.value array}}
|
|
339
|
+
@options={{or this.availableForms.lastSuccessful.value (array)}}
|
|
332
340
|
@selected={{fi.value}}
|
|
333
|
-
@placeholder={{t "caluma.form-builder.question.
|
|
341
|
+
@placeholder={{t "caluma.form-builder.question.no-selection"}}
|
|
334
342
|
@onBlur={{fi.setDirty}}
|
|
335
343
|
@onChange={{fi.update}}
|
|
336
344
|
@searchField="slug"
|
|
@@ -366,7 +374,7 @@
|
|
|
366
374
|
>
|
|
367
375
|
{{#each this.model.rowForm.questions.edges as |rowEdge|}}
|
|
368
376
|
{{#let rowEdge.node as |row|}}
|
|
369
|
-
<label
|
|
377
|
+
<label>
|
|
370
378
|
<input
|
|
371
379
|
type="checkbox"
|
|
372
380
|
value={{row.slug}}
|
|
@@ -403,9 +411,9 @@
|
|
|
403
411
|
as |fi|
|
|
404
412
|
>
|
|
405
413
|
<PowerSelect
|
|
406
|
-
@options={{or this.availableForms.lastSuccessful.value array}}
|
|
414
|
+
@options={{or this.availableForms.lastSuccessful.value (array)}}
|
|
407
415
|
@selected={{fi.value}}
|
|
408
|
-
@placeholder={{t "caluma.form-builder.question.
|
|
416
|
+
@placeholder={{t "caluma.form-builder.question.no-selection"}}
|
|
409
417
|
@onBlur={{fi.setDirty}}
|
|
410
418
|
@onChange={{fi.update}}
|
|
411
419
|
@searchField="slug"
|
|
@@ -437,7 +445,7 @@
|
|
|
437
445
|
@optionTargetPath="component"
|
|
438
446
|
@optionLabelPath="label"
|
|
439
447
|
@options={{this.availableOverrides}}
|
|
440
|
-
|
|
448
|
+
@prompt={{t "caluma.form-builder.question.no-selection"}}
|
|
441
449
|
/>
|
|
442
450
|
|
|
443
451
|
<f.input
|
|
@@ -445,12 +453,11 @@
|
|
|
445
453
|
@label={{t "caluma.form-builder.question.isArchived"}}
|
|
446
454
|
@required={{true}}
|
|
447
455
|
@renderComponent={{component "cfb-toggle-switch" size="small"}}
|
|
448
|
-
class="uk-flex uk-flex-between uk-flex-column"
|
|
449
456
|
/>
|
|
450
457
|
|
|
451
458
|
<UkButton
|
|
452
459
|
@color="link"
|
|
453
|
-
@
|
|
460
|
+
@onClick={{toggle-action "showAdvanced" this}}
|
|
454
461
|
class="uk-flex uk-flex-middle uk-margin"
|
|
455
462
|
>
|
|
456
463
|
{{#if this.showAdvanced}}
|
|
@@ -468,7 +475,6 @@
|
|
|
468
475
|
@required={{true}}
|
|
469
476
|
@label={{t "caluma.form-builder.question.validateOnEnter"}}
|
|
470
477
|
@renderComponent={{component "cfb-toggle-switch" size="small"}}
|
|
471
|
-
class="uk-flex uk-flex-between uk-flex-column"
|
|
472
478
|
/>
|
|
473
479
|
{{/if}}
|
|
474
480
|
|
|
@@ -495,6 +501,14 @@
|
|
|
495
501
|
/>
|
|
496
502
|
</div>
|
|
497
503
|
{{/if}}
|
|
504
|
+
|
|
505
|
+
<div class="uk-margin">
|
|
506
|
+
<f.input
|
|
507
|
+
@label={{t "caluma.form-builder.question.meta"}}
|
|
508
|
+
@name="meta"
|
|
509
|
+
@renderComponent={{component "cfb-code-editor" language="json"}}
|
|
510
|
+
/>
|
|
511
|
+
</div>
|
|
498
512
|
{{/if}}
|
|
499
513
|
|
|
500
514
|
<div class="uk-text-right">
|
|
@@ -1,16 +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
|
-
import { optional } from "ember-composable-helpers/helpers/optional";
|
|
12
11
|
import { dropTask, restartableTask, task, timeout } from "ember-concurrency";
|
|
13
|
-
import { all } from "rsvp";
|
|
14
12
|
|
|
15
13
|
import { hasQuestionType } from "@projectcaluma/ember-core/helpers/has-question-type";
|
|
16
14
|
import slugify from "@projectcaluma/ember-core/utils/slugify";
|
|
@@ -28,7 +26,7 @@ import saveDefaultStringAnswerMutation from "@projectcaluma/ember-form-builder/g
|
|
|
28
26
|
import saveDefaultTableAnswerMutation from "@projectcaluma/ember-form-builder/gql/mutations/save-default-table-answer.graphql";
|
|
29
27
|
import saveDynamicChoiceQuestionMutation from "@projectcaluma/ember-form-builder/gql/mutations/save-dynamic-choice-question.graphql";
|
|
30
28
|
import saveDynamicMultipleChoiceQuestionMutation from "@projectcaluma/ember-form-builder/gql/mutations/save-dynamic-multiple-choice-question.graphql";
|
|
31
|
-
import
|
|
29
|
+
import saveFilesQuestionMutation from "@projectcaluma/ember-form-builder/gql/mutations/save-files-question.graphql";
|
|
32
30
|
import saveFloatQuestionMutation from "@projectcaluma/ember-form-builder/gql/mutations/save-float-question.graphql";
|
|
33
31
|
import saveFormQuestionMutation from "@projectcaluma/ember-form-builder/gql/mutations/save-form-question.graphql";
|
|
34
32
|
import saveIntegerQuestionMutation from "@projectcaluma/ember-form-builder/gql/mutations/save-integer-question.graphql";
|
|
@@ -55,7 +53,7 @@ export const TYPES = {
|
|
|
55
53
|
DynamicChoiceQuestion: saveDynamicChoiceQuestionMutation,
|
|
56
54
|
TableQuestion: saveTableQuestionMutation,
|
|
57
55
|
FormQuestion: saveFormQuestionMutation,
|
|
58
|
-
|
|
56
|
+
FilesQuestion: saveFilesQuestionMutation,
|
|
59
57
|
StaticQuestion: saveStaticQuestionMutation,
|
|
60
58
|
DateQuestion: saveDateQuestionMutation,
|
|
61
59
|
CalculatedFloatQuestion: saveCalculatedFloatQuestionMutation,
|
|
@@ -107,6 +105,7 @@ export default class CfbFormEditorQuestion extends Component {
|
|
|
107
105
|
subForm: {},
|
|
108
106
|
meta: {},
|
|
109
107
|
dataSource: "",
|
|
108
|
+
formatValidators: null,
|
|
110
109
|
// action button
|
|
111
110
|
action: ACTIONS[0],
|
|
112
111
|
color: COLORS[0],
|
|
@@ -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() {
|
|
@@ -213,16 +208,20 @@ export default class CfbFormEditorQuestion extends Component {
|
|
|
213
208
|
const slug =
|
|
214
209
|
((!this.args.slug && this.prefix) || "") + changeset.get("slug");
|
|
215
210
|
|
|
211
|
+
const rawMeta = changeset.get("meta");
|
|
212
|
+
|
|
216
213
|
const input = {
|
|
217
214
|
slug,
|
|
218
215
|
label: changeset.get("label"),
|
|
219
216
|
isHidden: changeset.get("isHidden"),
|
|
220
217
|
infoText: changeset.get("infoText"),
|
|
221
|
-
meta: JSON.stringify(
|
|
218
|
+
meta: JSON.stringify(rawMeta?.unwrap?.() ?? rawMeta),
|
|
222
219
|
isArchived: changeset.get("isArchived"),
|
|
223
220
|
};
|
|
224
221
|
|
|
225
|
-
if (
|
|
222
|
+
if (
|
|
223
|
+
!hasQuestionType(changeset, "static", "calculated-float", "action-button")
|
|
224
|
+
) {
|
|
226
225
|
Object.assign(input, {
|
|
227
226
|
isRequired: changeset.get("isRequired"),
|
|
228
227
|
});
|
|
@@ -241,6 +240,7 @@ export default class CfbFormEditorQuestion extends Component {
|
|
|
241
240
|
minValue: parseInt(changeset.get("integerMinValue")),
|
|
242
241
|
maxValue: parseInt(changeset.get("integerMaxValue")),
|
|
243
242
|
placeholder: changeset.get("placeholder"),
|
|
243
|
+
hintText: changeset.get("hintText"),
|
|
244
244
|
};
|
|
245
245
|
}
|
|
246
246
|
|
|
@@ -249,6 +249,7 @@ export default class CfbFormEditorQuestion extends Component {
|
|
|
249
249
|
minValue: parseFloat(changeset.get("floatMinValue")),
|
|
250
250
|
maxValue: parseFloat(changeset.get("floatMaxValue")),
|
|
251
251
|
placeholder: changeset.get("placeholder"),
|
|
252
|
+
hintText: changeset.get("hintText"),
|
|
252
253
|
};
|
|
253
254
|
}
|
|
254
255
|
|
|
@@ -257,6 +258,10 @@ export default class CfbFormEditorQuestion extends Component {
|
|
|
257
258
|
minLength: parseInt(changeset.get("minLength")),
|
|
258
259
|
maxLength: parseInt(changeset.get("maxLength")),
|
|
259
260
|
placeholder: changeset.get("placeholder"),
|
|
261
|
+
formatValidators: changeset
|
|
262
|
+
.get("formatValidators")
|
|
263
|
+
?.edges.map((edge) => edge.node.slug),
|
|
264
|
+
hintText: changeset.get("hintText"),
|
|
260
265
|
};
|
|
261
266
|
}
|
|
262
267
|
|
|
@@ -265,36 +270,51 @@ export default class CfbFormEditorQuestion extends Component {
|
|
|
265
270
|
minLength: parseInt(changeset.get("minLength")),
|
|
266
271
|
maxLength: parseInt(changeset.get("maxLength")),
|
|
267
272
|
placeholder: changeset.get("placeholder"),
|
|
273
|
+
formatValidators: changeset
|
|
274
|
+
.get("formatValidators")
|
|
275
|
+
?.edges.map((edge) => edge.node.slug),
|
|
276
|
+
hintText: changeset.get("hintText"),
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
_getDateQuestionInput(changeset) {
|
|
281
|
+
return {
|
|
282
|
+
hintText: changeset.get("hintText"),
|
|
268
283
|
};
|
|
269
284
|
}
|
|
270
285
|
|
|
271
286
|
_getMultipleChoiceQuestionInput(changeset) {
|
|
272
287
|
return {
|
|
273
288
|
options: changeset.get("options.edges").map(({ node: { slug } }) => slug),
|
|
289
|
+
hintText: changeset.get("hintText"),
|
|
274
290
|
};
|
|
275
291
|
}
|
|
276
292
|
|
|
277
293
|
_getChoiceQuestionInput(changeset) {
|
|
278
294
|
return {
|
|
279
295
|
options: changeset.get("options.edges").map(({ node: { slug } }) => slug),
|
|
296
|
+
hintText: changeset.get("hintText"),
|
|
280
297
|
};
|
|
281
298
|
}
|
|
282
299
|
|
|
283
300
|
_getDynamicMultipleChoiceQuestionInput(changeset) {
|
|
284
301
|
return {
|
|
285
302
|
dataSource: changeset.get("dataSource"),
|
|
303
|
+
hintText: changeset.get("hintText"),
|
|
286
304
|
};
|
|
287
305
|
}
|
|
288
306
|
|
|
289
307
|
_getDynamicChoiceQuestionInput(changeset) {
|
|
290
308
|
return {
|
|
291
309
|
dataSource: changeset.get("dataSource"),
|
|
310
|
+
hintText: changeset.get("hintText"),
|
|
292
311
|
};
|
|
293
312
|
}
|
|
294
313
|
|
|
295
314
|
_getTableQuestionInput(changeset) {
|
|
296
315
|
return {
|
|
297
316
|
rowForm: changeset.get("rowForm.slug"),
|
|
317
|
+
hintText: changeset.get("hintText"),
|
|
298
318
|
};
|
|
299
319
|
}
|
|
300
320
|
|
|
@@ -313,6 +333,13 @@ export default class CfbFormEditorQuestion extends Component {
|
|
|
313
333
|
_getCalculatedFloatQuestionInput(changeset) {
|
|
314
334
|
return {
|
|
315
335
|
calcExpression: changeset.get("calcExpression"),
|
|
336
|
+
hintText: changeset.get("hintText"),
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
_getFilesQuestionInput(changeset) {
|
|
341
|
+
return {
|
|
342
|
+
hintText: changeset.get("hintText"),
|
|
316
343
|
};
|
|
317
344
|
}
|
|
318
345
|
|
|
@@ -326,7 +353,7 @@ export default class CfbFormEditorQuestion extends Component {
|
|
|
326
353
|
|
|
327
354
|
@task
|
|
328
355
|
*saveOptions(changeset) {
|
|
329
|
-
yield all(
|
|
356
|
+
yield Promise.all(
|
|
330
357
|
(changeset.get("options.edges") || []).map(async ({ node: option }) => {
|
|
331
358
|
const { label, slug, isArchived } = option;
|
|
332
359
|
|
|
@@ -406,7 +433,7 @@ export default class CfbFormEditorQuestion extends Component {
|
|
|
406
433
|
this.intl.t("caluma.form-builder.notification.question.save.success")
|
|
407
434
|
);
|
|
408
435
|
|
|
409
|
-
|
|
436
|
+
this.args.onAfterSubmit?.(question);
|
|
410
437
|
} catch (e) {
|
|
411
438
|
// eslint-disable-next-line no-console
|
|
412
439
|
console.error(e);
|
|
@@ -419,10 +446,9 @@ export default class CfbFormEditorQuestion extends Component {
|
|
|
419
446
|
@restartableTask
|
|
420
447
|
*validateSlug(slug, changeset) {
|
|
421
448
|
/* istanbul ignore next */
|
|
422
|
-
if (
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
) {
|
|
449
|
+
if (macroCondition(isTesting())) {
|
|
450
|
+
// no timeout
|
|
451
|
+
} else {
|
|
426
452
|
yield timeout(500);
|
|
427
453
|
}
|
|
428
454
|
|
|
@@ -12,11 +12,11 @@
|
|
|
12
12
|
{{else}}
|
|
13
13
|
<CfbFormEditor::QuestionList
|
|
14
14
|
@form={{@slug}}
|
|
15
|
-
@
|
|
16
|
-
@
|
|
17
|
-
@
|
|
18
|
-
@
|
|
19
|
-
@
|
|
15
|
+
@onEditQuestion={{@onEditQuestion}}
|
|
16
|
+
@onCreateQuestion={{@onCreateQuestion}}
|
|
17
|
+
@onAfterAddQuestion={{@onAfterAddQuestion}}
|
|
18
|
+
@onAfterRemoveQuestion={{@onAfterRemoveQuestion}}
|
|
19
|
+
@onClickForm={{@onClickForm}}
|
|
20
20
|
/>
|
|
21
21
|
{{/if}}
|
|
22
22
|
</div>
|
|
@@ -1,18 +1,18 @@
|
|
|
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
|
-
@
|
|
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>
|
|
12
12
|
<div>
|
|
13
13
|
<UkButton
|
|
14
14
|
data-test-new-form
|
|
15
|
-
@
|
|
15
|
+
@onClick={{optional @onNewForm}}
|
|
16
16
|
@label={{t "caluma.form-builder.form.new"}}
|
|
17
17
|
/>
|
|
18
18
|
</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
|
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
<CfbFormList::Item
|
|
38
38
|
data-test-form-list-item={{item.slug}}
|
|
39
39
|
@item={{item}}
|
|
40
|
-
@
|
|
40
|
+
@onEditForm={{@onEditForm}}
|
|
41
41
|
/>
|
|
42
42
|
{{/each}}
|
|
43
43
|
{{#if this.formsQuery.isLoading}}
|
|
@@ -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
|
|
|
@@ -19,6 +19,7 @@ fragment SimpleQuestion on Question {
|
|
|
19
19
|
value
|
|
20
20
|
}
|
|
21
21
|
placeholder
|
|
22
|
+
hintText
|
|
22
23
|
}
|
|
23
24
|
... on TextareaQuestion {
|
|
24
25
|
textareaMinLength: minLength
|
|
@@ -28,6 +29,7 @@ fragment SimpleQuestion on Question {
|
|
|
28
29
|
value
|
|
29
30
|
}
|
|
30
31
|
placeholder
|
|
32
|
+
hintText
|
|
31
33
|
}
|
|
32
34
|
... on IntegerQuestion {
|
|
33
35
|
integerMinValue: minValue
|
|
@@ -37,6 +39,7 @@ fragment SimpleQuestion on Question {
|
|
|
37
39
|
value
|
|
38
40
|
}
|
|
39
41
|
placeholder
|
|
42
|
+
hintText
|
|
40
43
|
}
|
|
41
44
|
... on FloatQuestion {
|
|
42
45
|
floatMinValue: minValue
|
|
@@ -46,6 +49,7 @@ fragment SimpleQuestion on Question {
|
|
|
46
49
|
value
|
|
47
50
|
}
|
|
48
51
|
placeholder
|
|
52
|
+
hintText
|
|
49
53
|
}
|
|
50
54
|
... on ChoiceQuestion {
|
|
51
55
|
choiceOptions: options {
|
|
@@ -62,6 +66,7 @@ fragment SimpleQuestion on Question {
|
|
|
62
66
|
id
|
|
63
67
|
value
|
|
64
68
|
}
|
|
69
|
+
hintText
|
|
65
70
|
}
|
|
66
71
|
... on MultipleChoiceQuestion {
|
|
67
72
|
multipleChoiceOptions: options {
|
|
@@ -78,18 +83,24 @@ fragment SimpleQuestion on Question {
|
|
|
78
83
|
id
|
|
79
84
|
value
|
|
80
85
|
}
|
|
86
|
+
hintText
|
|
81
87
|
}
|
|
82
88
|
... on DateQuestion {
|
|
83
89
|
dateDefaultAnswer: defaultAnswer {
|
|
84
90
|
id
|
|
85
91
|
value
|
|
86
92
|
}
|
|
93
|
+
hintText
|
|
87
94
|
}
|
|
88
95
|
... on StaticQuestion {
|
|
89
96
|
staticContent
|
|
90
97
|
}
|
|
91
98
|
... on CalculatedFloatQuestion {
|
|
92
99
|
calcExpression
|
|
100
|
+
hintText
|
|
101
|
+
}
|
|
102
|
+
... on FilesQuestion {
|
|
103
|
+
hintText
|
|
93
104
|
}
|
|
94
105
|
... on ActionButtonQuestion {
|
|
95
106
|
action
|
|
@@ -112,6 +123,7 @@ fragment FieldTableQuestion on Question {
|
|
|
112
123
|
}
|
|
113
124
|
}
|
|
114
125
|
}
|
|
126
|
+
hintText
|
|
115
127
|
tableDefaultAnswer: defaultAnswer {
|
|
116
128
|
id
|
|
117
129
|
value {
|
|
@@ -204,8 +216,8 @@ fragment SimpleAnswer on Answer {
|
|
|
204
216
|
... on ListAnswer {
|
|
205
217
|
listValue: value
|
|
206
218
|
}
|
|
207
|
-
... on
|
|
208
|
-
|
|
219
|
+
... on FilesAnswer {
|
|
220
|
+
filesValue: value {
|
|
209
221
|
id
|
|
210
222
|
uploadUrl
|
|
211
223
|
downloadUrl
|