@projectcaluma/ember-form-builder 9.0.5 → 10.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 +16 -0
- package/addon/components/cfb-float-input.hbs +14 -0
- package/addon/components/cfb-float-input.js +10 -4
- package/addon/components/cfb-form-editor/general.hbs +90 -86
- package/addon/components/cfb-form-editor/general.js +43 -45
- package/addon/components/cfb-form-editor/question/default.hbs +11 -9
- package/addon/components/cfb-form-editor/question/default.js +19 -29
- package/addon/components/cfb-form-editor/question/options.hbs +80 -82
- package/addon/components/cfb-form-editor/question/options.js +116 -105
- package/addon/components/cfb-form-editor/question/validation.hbs +14 -12
- package/addon/components/cfb-form-editor/question/validation.js +22 -31
- package/addon/components/cfb-form-editor/question-list/item.js +2 -4
- package/addon/components/cfb-form-editor/question.hbs +455 -380
- package/addon/components/cfb-form-editor/question.js +162 -138
- package/addon/components/cfb-form-list.hbs +1 -1
- package/addon/components/cfb-jexl-boolean-toggle-switch.hbs +12 -10
- package/addon/components/cfb-jexl-boolean-toggle-switch.js +11 -10
- package/addon/components/cfb-label.hbs +12 -4
- package/addon/components/cfb-toggle-switch.hbs +14 -12
- package/addon/gql/mutations/add-form-question.graphql +2 -2
- package/addon/gql/mutations/remove-form-question.graphql +2 -2
- package/addon/gql/mutations/reorder-form-questions.graphql +2 -2
- package/addon/gql/mutations/save-action-button-question.graphql +15 -0
- package/addon/gql/mutations/save-calculated-float-question.graphql +1 -1
- package/addon/gql/mutations/save-choice-question.graphql +1 -1
- package/addon/gql/mutations/save-date-question.graphql +1 -1
- package/addon/gql/mutations/save-default-date-answer.graphql +2 -6
- package/addon/gql/mutations/save-default-float-answer.graphql +2 -6
- package/addon/gql/mutations/save-default-integer-answer.graphql +2 -6
- package/addon/gql/mutations/save-default-list-answer.graphql +2 -6
- package/addon/gql/mutations/save-default-string-answer.graphql +2 -6
- package/addon/gql/mutations/save-default-table-answer.graphql +2 -6
- package/addon/gql/mutations/save-dynamic-choice-question.graphql +1 -1
- package/addon/gql/mutations/save-dynamic-multiple-choice-question.graphql +1 -1
- package/addon/gql/mutations/save-file-question.graphql +1 -1
- package/addon/gql/mutations/save-float-question.graphql +1 -1
- package/addon/gql/mutations/save-form-question.graphql +1 -1
- package/addon/gql/mutations/save-form.graphql +1 -1
- package/addon/gql/mutations/save-integer-question.graphql +1 -1
- package/addon/gql/mutations/save-multiple-choice-question.graphql +1 -1
- package/addon/gql/mutations/save-static-question.graphql +1 -1
- package/addon/gql/mutations/save-table-question.graphql +1 -1
- package/addon/gql/mutations/save-text-question.graphql +1 -1
- package/addon/gql/mutations/save-textarea-question.graphql +1 -1
- package/addon/gql/queries/form-editor-general.graphql +1 -1
- package/addon/gql/queries/form-editor-question.graphql +7 -3
- package/addon/gql/queries/form-list.graphql +1 -1
- package/addon/gql/queries/search-form-question.graphql +1 -1
- package/addon/gql/queries/search-question.graphql +1 -1
- package/addon/routes/edit/questions/edit.js +1 -1
- package/addon/routes/edit.js +1 -1
- package/package.json +21 -21
- package/translations/de.yaml +18 -4
- package/translations/en.yaml +18 -4
- package/addon/components/cfb-float-input/input.js +0 -12
- package/addon/components/cfb-label.js +0 -5
- package/addon/gql/fragments/field-answer.graphql +0 -57
- package/addon/gql/fragments/field-question.graphql +0 -159
- package/addon/gql/mutations/archive-form.graphql +0 -5
- package/addon/gql/mutations/remove-document.graphql +0 -5
- package/addon/gql/queries/all-format-validators.graphql +0 -12
- package/addon/gql/queries/all-work-items.graphql +0 -9
- package/addon/gql/queries/data-source.graphql +0 -10
- package/addon/gql/queries/get-document-answers.graphql +0 -21
- package/addon/gql/queries/get-document-forms.graphql +0 -20
- package/addon/gql/queries/get-document-used-dynamic-options.graphql +0 -12
- package/addon/gql/queries/get-dynamic-options.graphql +0 -29
- package/addon/gql/queries/get-fileanswer-info.graphql +0 -13
- package/app/components/cfb-float-input/input.js +0 -1
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
import { getOwner } from "@ember/application";
|
|
2
2
|
import { A } from "@ember/array";
|
|
3
|
-
import
|
|
4
|
-
import { computed, get } from "@ember/object";
|
|
5
|
-
import { reads } from "@ember/object/computed";
|
|
3
|
+
import { action } from "@ember/object";
|
|
6
4
|
import { inject as service } from "@ember/service";
|
|
7
5
|
import { camelize } from "@ember/string";
|
|
6
|
+
import Component from "@glimmer/component";
|
|
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 { optional } from "ember-composable-helpers/helpers/optional";
|
|
12
|
-
import { task, timeout } from "ember-concurrency";
|
|
12
|
+
import { dropTask, restartableTask, task, timeout } from "ember-concurrency";
|
|
13
13
|
import { all } from "rsvp";
|
|
14
14
|
|
|
15
|
+
import { hasQuestionType } from "@projectcaluma/ember-core/helpers/has-question-type";
|
|
15
16
|
import slugify from "@projectcaluma/ember-core/utils/slugify";
|
|
16
17
|
import addFormQuestionMutation from "@projectcaluma/ember-form-builder/gql/mutations/add-form-question.graphql";
|
|
17
18
|
import removeDefaultAnswerMutation from "@projectcaluma/ember-form-builder/gql/mutations/remove-default-answer.graphql";
|
|
19
|
+
import saveActionButtonQuestionMutation from "@projectcaluma/ember-form-builder/gql/mutations/save-action-button-question.graphql";
|
|
18
20
|
import saveCalculatedFloatQuestionMutation from "@projectcaluma/ember-form-builder/gql/mutations/save-calculated-float-question.graphql";
|
|
19
21
|
import saveChoiceQuestionMutation from "@projectcaluma/ember-form-builder/gql/mutations/save-choice-question.graphql";
|
|
20
22
|
import saveDateQuestionMutation from "@projectcaluma/ember-form-builder/gql/mutations/save-date-question.graphql";
|
|
@@ -57,8 +59,13 @@ export const TYPES = {
|
|
|
57
59
|
StaticQuestion: saveStaticQuestionMutation,
|
|
58
60
|
DateQuestion: saveDateQuestionMutation,
|
|
59
61
|
CalculatedFloatQuestion: saveCalculatedFloatQuestionMutation,
|
|
62
|
+
ActionButtonQuestion: saveActionButtonQuestionMutation,
|
|
60
63
|
};
|
|
61
64
|
|
|
65
|
+
const ACTIONS = ["COMPLETE", "SKIP"];
|
|
66
|
+
|
|
67
|
+
const COLORS = ["PRIMARY", "SECONDARY", "DEFAULT"];
|
|
68
|
+
|
|
62
69
|
const TYPES_ANSWER = {
|
|
63
70
|
StringAnswer: saveDefaultStringAnswerMutation,
|
|
64
71
|
IntegerAnswer: saveDefaultIntegerAnswerMutation,
|
|
@@ -68,33 +75,17 @@ const TYPES_ANSWER = {
|
|
|
68
75
|
TableAnswer: saveDefaultTableAnswerMutation,
|
|
69
76
|
};
|
|
70
77
|
|
|
71
|
-
export default Component
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
calumaOptions: service(),
|
|
77
|
-
|
|
78
|
-
apollo: queryManager(),
|
|
79
|
-
|
|
80
|
-
linkSlug: true,
|
|
81
|
-
|
|
82
|
-
possibleTypes: computed(function () {
|
|
83
|
-
return Object.keys(TYPES).map((value) => ({
|
|
84
|
-
value,
|
|
85
|
-
label: this.intl.t(`caluma.form-builder.question.types.${value}`),
|
|
86
|
-
}));
|
|
87
|
-
}),
|
|
78
|
+
export default class CfbFormEditorQuestion extends Component {
|
|
79
|
+
@service notification;
|
|
80
|
+
@service intl;
|
|
81
|
+
@service calumaOptions;
|
|
82
|
+
@queryManager apollo;
|
|
88
83
|
|
|
89
|
-
|
|
90
|
-
this._super();
|
|
91
|
-
await this.data.perform();
|
|
92
|
-
await this.availableForms.perform();
|
|
93
|
-
await this.availableDataSources.perform();
|
|
94
|
-
},
|
|
84
|
+
@tracked linkSlug = true;
|
|
95
85
|
|
|
96
|
-
|
|
97
|
-
|
|
86
|
+
@restartableTask
|
|
87
|
+
*data() {
|
|
88
|
+
if (!this.args.slug) {
|
|
98
89
|
return A([
|
|
99
90
|
{
|
|
100
91
|
node: {
|
|
@@ -116,6 +107,10 @@ export default Component.extend({
|
|
|
116
107
|
subForm: {},
|
|
117
108
|
meta: {},
|
|
118
109
|
dataSource: "",
|
|
110
|
+
// action button
|
|
111
|
+
action: ACTIONS[0],
|
|
112
|
+
color: COLORS[0],
|
|
113
|
+
validateOnEnter: false,
|
|
119
114
|
__typename: Object.keys(TYPES)[0],
|
|
120
115
|
},
|
|
121
116
|
},
|
|
@@ -125,14 +120,15 @@ export default Component.extend({
|
|
|
125
120
|
return yield this.apollo.watchQuery(
|
|
126
121
|
{
|
|
127
122
|
query: formEditorQuestionQuery,
|
|
128
|
-
variables: { slug: this.slug },
|
|
123
|
+
variables: { slug: this.args.slug },
|
|
129
124
|
fetchPolicy: "cache-and-network",
|
|
130
125
|
},
|
|
131
126
|
"allQuestions.edges"
|
|
132
127
|
);
|
|
133
|
-
}
|
|
128
|
+
}
|
|
134
129
|
|
|
135
|
-
|
|
130
|
+
@restartableTask
|
|
131
|
+
*availableForms() {
|
|
136
132
|
const forms = yield this.apollo.watchQuery(
|
|
137
133
|
{
|
|
138
134
|
query: formListQuery,
|
|
@@ -147,10 +143,45 @@ export default Component.extend({
|
|
|
147
143
|
if (!forms.map) {
|
|
148
144
|
return [];
|
|
149
145
|
}
|
|
150
|
-
return forms.mapBy("node").filter((form) => form.slug !== this.form);
|
|
151
|
-
}
|
|
146
|
+
return forms.mapBy("node").filter((form) => form.slug !== this.args.form);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
@restartableTask
|
|
150
|
+
*availableDataSources() {
|
|
151
|
+
const dataSources = yield this.apollo.watchQuery(
|
|
152
|
+
{ query: allDataSourcesQuery, fetchPolicy: "cache-and-network" },
|
|
153
|
+
"allDataSources.edges"
|
|
154
|
+
);
|
|
155
|
+
return dataSources.map((edge) => {
|
|
156
|
+
return {
|
|
157
|
+
...edge.node,
|
|
158
|
+
__typename: undefined,
|
|
159
|
+
};
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
get possibleTypes() {
|
|
164
|
+
return Object.keys(TYPES).map((value) => ({
|
|
165
|
+
value,
|
|
166
|
+
label: this.intl.t(`caluma.form-builder.question.types.${value}`),
|
|
167
|
+
}));
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
get possibleActions() {
|
|
171
|
+
return ACTIONS.map((value) => ({
|
|
172
|
+
value,
|
|
173
|
+
label: this.intl.t(`caluma.form-builder.question.actions.${value}`),
|
|
174
|
+
}));
|
|
175
|
+
}
|
|
152
176
|
|
|
153
|
-
|
|
177
|
+
get possibleColors() {
|
|
178
|
+
return COLORS.map((value) => ({
|
|
179
|
+
value,
|
|
180
|
+
label: this.intl.t(`caluma.form-builder.question.colors.${value}`),
|
|
181
|
+
}));
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
get availableOverrides() {
|
|
154
185
|
const type = this.changeset.get("__typename");
|
|
155
186
|
const overrides = this.calumaOptions
|
|
156
187
|
.getComponentOverrides()
|
|
@@ -162,54 +193,25 @@ export default Component.extend({
|
|
|
162
193
|
{ label: this.intl.t("caluma.form.power-select.null"), component: "" },
|
|
163
194
|
...overrides,
|
|
164
195
|
];
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
availableDataSources: task(function* () {
|
|
168
|
-
const dataSources = yield this.apollo.watchQuery(
|
|
169
|
-
{ query: allDataSourcesQuery, fetchPolicy: "cache-and-network" },
|
|
170
|
-
"allDataSources.edges"
|
|
171
|
-
);
|
|
172
|
-
return dataSources.map((edge) => {
|
|
173
|
-
return {
|
|
174
|
-
...edge.node,
|
|
175
|
-
__typename: undefined,
|
|
176
|
-
};
|
|
177
|
-
});
|
|
178
|
-
}).restartable(),
|
|
196
|
+
}
|
|
179
197
|
|
|
180
|
-
model
|
|
198
|
+
get model() {
|
|
199
|
+
return this.data.lastSuccessful?.value?.firstObject?.node;
|
|
200
|
+
}
|
|
181
201
|
|
|
182
|
-
changeset
|
|
183
|
-
return new Changeset(this.model, lookupValidator(validations));
|
|
184
|
-
}
|
|
202
|
+
get changeset() {
|
|
203
|
+
return new Changeset(this.model, lookupValidator(validations), validations);
|
|
204
|
+
}
|
|
185
205
|
|
|
186
|
-
prefix
|
|
206
|
+
get prefix() {
|
|
187
207
|
return this.calumaOptions.namespace
|
|
188
208
|
? `${this.calumaOptions.namespace}-`
|
|
189
209
|
: "";
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
requiredIrrelevant: computed("changeset.__typename", function () {
|
|
193
|
-
return ["StaticQuestion", "CalculatedFloatQuestion"].includes(
|
|
194
|
-
this.changeset.__typename
|
|
195
|
-
);
|
|
196
|
-
}),
|
|
197
|
-
|
|
198
|
-
requiredToggleVisible: computed(
|
|
199
|
-
"changeset.isRequired",
|
|
200
|
-
"requiredIrrelevant",
|
|
201
|
-
function () {
|
|
202
|
-
// the required toggle is only shown if the JEXL is a simple boolean and
|
|
203
|
-
// it's not irrelevant since it's not a question that takes any input
|
|
204
|
-
return (
|
|
205
|
-
["true", "false"].includes(this.changeset.isRequired) &&
|
|
206
|
-
!this.requiredIrrelevant
|
|
207
|
-
);
|
|
208
|
-
}
|
|
209
|
-
),
|
|
210
|
+
}
|
|
210
211
|
|
|
211
212
|
getInput(changeset) {
|
|
212
|
-
const slug =
|
|
213
|
+
const slug =
|
|
214
|
+
((!this.args.slug && this.prefix) || "") + changeset.get("slug");
|
|
213
215
|
|
|
214
216
|
const input = {
|
|
215
217
|
slug,
|
|
@@ -220,7 +222,7 @@ export default Component.extend({
|
|
|
220
222
|
isArchived: changeset.get("isArchived"),
|
|
221
223
|
};
|
|
222
224
|
|
|
223
|
-
if (!
|
|
225
|
+
if (!hasQuestionType(changeset, "static", "calculated-float")) {
|
|
224
226
|
Object.assign(input, {
|
|
225
227
|
isRequired: changeset.get("isRequired"),
|
|
226
228
|
});
|
|
@@ -232,7 +234,7 @@ export default Component.extend({
|
|
|
232
234
|
}
|
|
233
235
|
|
|
234
236
|
return input;
|
|
235
|
-
}
|
|
237
|
+
}
|
|
236
238
|
|
|
237
239
|
_getIntegerQuestionInput(changeset) {
|
|
238
240
|
return {
|
|
@@ -240,7 +242,7 @@ export default Component.extend({
|
|
|
240
242
|
maxValue: parseInt(changeset.get("integerMaxValue")),
|
|
241
243
|
placeholder: changeset.get("placeholder"),
|
|
242
244
|
};
|
|
243
|
-
}
|
|
245
|
+
}
|
|
244
246
|
|
|
245
247
|
_getFloatQuestionInput(changeset) {
|
|
246
248
|
return {
|
|
@@ -248,7 +250,7 @@ export default Component.extend({
|
|
|
248
250
|
maxValue: parseFloat(changeset.get("floatMaxValue")),
|
|
249
251
|
placeholder: changeset.get("placeholder"),
|
|
250
252
|
};
|
|
251
|
-
}
|
|
253
|
+
}
|
|
252
254
|
|
|
253
255
|
_getTextQuestionInput(changeset) {
|
|
254
256
|
return {
|
|
@@ -256,7 +258,7 @@ export default Component.extend({
|
|
|
256
258
|
maxLength: parseInt(changeset.get("maxLength")),
|
|
257
259
|
placeholder: changeset.get("placeholder"),
|
|
258
260
|
};
|
|
259
|
-
}
|
|
261
|
+
}
|
|
260
262
|
|
|
261
263
|
_getTextareaQuestionInput(changeset) {
|
|
262
264
|
return {
|
|
@@ -264,59 +266,68 @@ export default Component.extend({
|
|
|
264
266
|
maxLength: parseInt(changeset.get("maxLength")),
|
|
265
267
|
placeholder: changeset.get("placeholder"),
|
|
266
268
|
};
|
|
267
|
-
}
|
|
269
|
+
}
|
|
268
270
|
|
|
269
271
|
_getMultipleChoiceQuestionInput(changeset) {
|
|
270
272
|
return {
|
|
271
273
|
options: changeset.get("options.edges").map(({ node: { slug } }) => slug),
|
|
272
274
|
};
|
|
273
|
-
}
|
|
275
|
+
}
|
|
274
276
|
|
|
275
277
|
_getChoiceQuestionInput(changeset) {
|
|
276
278
|
return {
|
|
277
279
|
options: changeset.get("options.edges").map(({ node: { slug } }) => slug),
|
|
278
280
|
};
|
|
279
|
-
}
|
|
281
|
+
}
|
|
280
282
|
|
|
281
283
|
_getDynamicMultipleChoiceQuestionInput(changeset) {
|
|
282
284
|
return {
|
|
283
285
|
dataSource: changeset.get("dataSource"),
|
|
284
286
|
};
|
|
285
|
-
}
|
|
287
|
+
}
|
|
286
288
|
|
|
287
289
|
_getDynamicChoiceQuestionInput(changeset) {
|
|
288
290
|
return {
|
|
289
291
|
dataSource: changeset.get("dataSource"),
|
|
290
292
|
};
|
|
291
|
-
}
|
|
293
|
+
}
|
|
292
294
|
|
|
293
295
|
_getTableQuestionInput(changeset) {
|
|
294
296
|
return {
|
|
295
297
|
rowForm: changeset.get("rowForm.slug"),
|
|
296
298
|
};
|
|
297
|
-
}
|
|
299
|
+
}
|
|
298
300
|
|
|
299
301
|
_getFormQuestionInput(changeset) {
|
|
300
302
|
return {
|
|
301
303
|
subForm: changeset.get("subForm.slug"),
|
|
302
304
|
};
|
|
303
|
-
}
|
|
305
|
+
}
|
|
304
306
|
|
|
305
307
|
_getStaticQuestionInput(changeset) {
|
|
306
308
|
return {
|
|
307
309
|
staticContent: changeset.get("staticContent"),
|
|
308
310
|
};
|
|
309
|
-
}
|
|
311
|
+
}
|
|
310
312
|
|
|
311
313
|
_getCalculatedFloatQuestionInput(changeset) {
|
|
312
314
|
return {
|
|
313
315
|
calcExpression: changeset.get("calcExpression"),
|
|
314
316
|
};
|
|
315
|
-
}
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
_getActionButtonQuestionInput(changeset) {
|
|
320
|
+
return {
|
|
321
|
+
action: changeset.get("action"),
|
|
322
|
+
color: changeset.get("color"),
|
|
323
|
+
validateOnEnter: Boolean(changeset.get("validateOnEnter")),
|
|
324
|
+
};
|
|
325
|
+
}
|
|
316
326
|
|
|
317
|
-
|
|
327
|
+
@task
|
|
328
|
+
*saveOptions(changeset) {
|
|
318
329
|
yield all(
|
|
319
|
-
(get(
|
|
330
|
+
(changeset.get("options.edges") || []).map(async ({ node: option }) => {
|
|
320
331
|
const { label, slug, isArchived } = option;
|
|
321
332
|
|
|
322
333
|
await this.apollo.mutate({
|
|
@@ -325,9 +336,10 @@ export default Component.extend({
|
|
|
325
336
|
});
|
|
326
337
|
})
|
|
327
338
|
);
|
|
328
|
-
}
|
|
339
|
+
}
|
|
329
340
|
|
|
330
|
-
|
|
341
|
+
@task
|
|
342
|
+
*saveDefaultAnswer(question, changeset) {
|
|
331
343
|
if (!changeset.get("defaultAnswer")) {
|
|
332
344
|
return;
|
|
333
345
|
}
|
|
@@ -357,9 +369,10 @@ export default Component.extend({
|
|
|
357
369
|
}
|
|
358
370
|
|
|
359
371
|
yield this.apollo.mutate({ mutation, variables: { input } });
|
|
360
|
-
}
|
|
372
|
+
}
|
|
361
373
|
|
|
362
|
-
|
|
374
|
+
@dropTask
|
|
375
|
+
*submit(changeset) {
|
|
363
376
|
try {
|
|
364
377
|
yield this.saveOptions.perform(changeset);
|
|
365
378
|
|
|
@@ -375,14 +388,14 @@ export default Component.extend({
|
|
|
375
388
|
|
|
376
389
|
yield this.saveDefaultAnswer.perform(question, changeset);
|
|
377
390
|
|
|
378
|
-
if (!this.slug) {
|
|
391
|
+
if (!this.args.slug) {
|
|
379
392
|
// This is a new question which must be added to the form after creating it
|
|
380
393
|
yield this.apollo.mutate({
|
|
381
394
|
mutation: addFormQuestionMutation,
|
|
382
395
|
variables: {
|
|
383
396
|
input: {
|
|
384
397
|
question: question.slug,
|
|
385
|
-
form: this.form,
|
|
398
|
+
form: this.args.form,
|
|
386
399
|
},
|
|
387
400
|
search: "",
|
|
388
401
|
},
|
|
@@ -393,7 +406,7 @@ export default Component.extend({
|
|
|
393
406
|
this.intl.t("caluma.form-builder.notification.question.save.success")
|
|
394
407
|
);
|
|
395
408
|
|
|
396
|
-
optional([this.
|
|
409
|
+
optional([this.args["on-after-submit"]])(question);
|
|
397
410
|
} catch (e) {
|
|
398
411
|
// eslint-disable-next-line no-console
|
|
399
412
|
console.error(e);
|
|
@@ -401,9 +414,10 @@ export default Component.extend({
|
|
|
401
414
|
this.intl.t("caluma.form-builder.notification.question.save.error")
|
|
402
415
|
);
|
|
403
416
|
}
|
|
404
|
-
}
|
|
417
|
+
}
|
|
405
418
|
|
|
406
|
-
|
|
419
|
+
@restartableTask
|
|
420
|
+
*validateSlug(slug, changeset) {
|
|
407
421
|
/* istanbul ignore next */
|
|
408
422
|
if (
|
|
409
423
|
getOwner(this).resolveRegistration("config:environment").environment !==
|
|
@@ -426,46 +440,56 @@ export default Component.extend({
|
|
|
426
440
|
this.intl.t("caluma.form-builder.validations.question.slug")
|
|
427
441
|
);
|
|
428
442
|
}
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
actions: {
|
|
432
|
-
updateLabel(value, changeset) {
|
|
433
|
-
changeset.set("label", value);
|
|
434
|
-
|
|
435
|
-
if (!this.slug && this.linkSlug) {
|
|
436
|
-
const slug = slugify(value, { locale: this.intl.primaryLocale });
|
|
437
|
-
|
|
438
|
-
changeset.set("slug", slug);
|
|
443
|
+
}
|
|
439
444
|
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
this.set("linkSlug", false);
|
|
447
|
-
|
|
448
|
-
this.validateSlug.perform(this.prefix + value, changeset);
|
|
449
|
-
},
|
|
450
|
-
|
|
451
|
-
/*
|
|
452
|
-
* This function adds the selected slugs to the columns to display
|
|
453
|
-
* list if it isnt present, otherwise it will remove the slug.
|
|
454
|
-
*/
|
|
455
|
-
toggleColumnToDisplay(value) {
|
|
456
|
-
const displayed = new Set(this.changeset.get("meta.columnsToDisplay"));
|
|
445
|
+
@action
|
|
446
|
+
async fetchData() {
|
|
447
|
+
await this.data.perform();
|
|
448
|
+
await this.availableForms.perform();
|
|
449
|
+
await this.availableDataSources.perform();
|
|
450
|
+
}
|
|
457
451
|
|
|
458
|
-
|
|
452
|
+
@action
|
|
453
|
+
updateLabel(value, changeset) {
|
|
454
|
+
changeset.set("label", value);
|
|
459
455
|
|
|
460
|
-
|
|
461
|
-
|
|
456
|
+
if (!this.args.slug && this.linkSlug) {
|
|
457
|
+
const slug = slugify(value, { locale: this.intl.primaryLocale });
|
|
462
458
|
|
|
463
|
-
|
|
464
|
-
changeset.set("subForm.slug", value.slug);
|
|
465
|
-
},
|
|
459
|
+
changeset.set("slug", slug);
|
|
466
460
|
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
461
|
+
this.validateSlug.perform(this.prefix + slug, changeset);
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
@action
|
|
466
|
+
updateSlug(value, changeset) {
|
|
467
|
+
changeset.set("slug", value);
|
|
468
|
+
this.linkSlug = false;
|
|
469
|
+
|
|
470
|
+
this.validateSlug.perform(this.prefix + value, changeset);
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
/*
|
|
474
|
+
* This function adds the selected slugs to the columns to display
|
|
475
|
+
* list if it isnt present, otherwise it will remove the slug.
|
|
476
|
+
*/
|
|
477
|
+
@action
|
|
478
|
+
toggleColumnToDisplay(value, changeset) {
|
|
479
|
+
const displayed = new Set(changeset.get("meta.columnsToDisplay"));
|
|
480
|
+
|
|
481
|
+
displayed.delete(value) || displayed.add(value);
|
|
482
|
+
|
|
483
|
+
changeset.set("meta.columnsToDisplay", [...displayed]);
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
@action
|
|
487
|
+
updateSubForm(value, changeset) {
|
|
488
|
+
changeset.set("subForm.slug", value.slug);
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
@action
|
|
492
|
+
updateRowForm(value, changeset) {
|
|
493
|
+
changeset.set("rowForm.slug", value.slug);
|
|
494
|
+
}
|
|
495
|
+
}
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
</form>
|
|
40
40
|
{{#if this.formsQuery.isLoading}}
|
|
41
41
|
<div class="uk-height-small uk-flex uk-flex-center uk-flex-middle">
|
|
42
|
-
|
|
42
|
+
<UkSpinner ratio="2" />
|
|
43
43
|
</div>
|
|
44
44
|
{{else if this.formsQuery.value.length}}
|
|
45
45
|
<ul data-test-form-list class="uk-list uk-list-divider uk-list-large">
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
labelComponent=labelComponent
|
|
3
|
-
hintComponent=hintComponent
|
|
4
|
-
errorComponent=errorComponent
|
|
5
|
-
|
|
6
|
-
size=size
|
|
7
|
-
name=name
|
|
8
|
-
|
|
9
|
-
update=
|
|
10
|
-
}}
|
|
1
|
+
<CfbToggleSwitch
|
|
2
|
+
@labelComponent={{@labelComponent}}
|
|
3
|
+
@hintComponent={{@hintComponent}}
|
|
4
|
+
@errorComponent={{@errorComponent}}
|
|
5
|
+
@disabled={{@disabled}}
|
|
6
|
+
@size={{@size}}
|
|
7
|
+
@name={{@name}}
|
|
8
|
+
@value={{this.boolValue}}
|
|
9
|
+
@update={{this.toggle}}
|
|
10
|
+
@noMargin={{true}}
|
|
11
|
+
class="uk-flex uk-flex-middle uk-height-1-1"
|
|
12
|
+
/>
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { action } from "@ember/object";
|
|
2
|
+
import Component from "@glimmer/component";
|
|
3
3
|
|
|
4
|
-
export default
|
|
5
|
-
boolValue
|
|
4
|
+
export default class CfbJexlBooleanToggleSwitch extends Component {
|
|
5
|
+
get boolValue() {
|
|
6
|
+
return this.args.value === "true";
|
|
7
|
+
}
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
});
|
|
9
|
+
@action
|
|
10
|
+
toggle(boolValue) {
|
|
11
|
+
this.args.update(String(boolValue));
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
<label
|
|
2
|
+
class="uk-form-label uk-flex uk-flex-between"
|
|
3
|
+
for={{@inputId}}
|
|
4
|
+
...attributes
|
|
5
|
+
>
|
|
6
|
+
{{yield}}{{@label}}
|
|
7
|
+
{{#unless @required}}
|
|
8
|
+
<span class="uk-text-muted uk-text-lowercase">
|
|
9
|
+
({{t "caluma.form-builder.global.optional"}})
|
|
10
|
+
</span>
|
|
11
|
+
{{/unless}}
|
|
12
|
+
</label>
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
<div class="uk-flex uk-flex-column {{unless @noMargin "uk-margin"}}">
|
|
2
|
+
<@labelComponent />
|
|
2
3
|
|
|
3
|
-
<div class="uk-form-controls">
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
</div>
|
|
4
|
+
<div class="uk-form-controls" ...attributes>
|
|
5
|
+
<UkToggleSwitch
|
|
6
|
+
@value={{@value}}
|
|
7
|
+
@size={{@size}}
|
|
8
|
+
@name={{@name}}
|
|
9
|
+
@disabled={{@disabled}}
|
|
10
|
+
@on-toggle={{@update}}
|
|
11
|
+
/>
|
|
12
|
+
</div>
|
|
12
13
|
|
|
13
|
-
<@hintComponent />
|
|
14
|
-
<@errorComponent />
|
|
14
|
+
<@hintComponent />
|
|
15
|
+
<@errorComponent />
|
|
16
|
+
</div>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
#
|
|
2
|
-
#
|
|
1
|
+
#import FormInfo from '../fragments/form-info.graphql'
|
|
2
|
+
#import QuestionInfo from '../fragments/question-info.graphql'
|
|
3
3
|
|
|
4
4
|
mutation AddFormQuestion($input: AddFormQuestionInput!, $search: String) {
|
|
5
5
|
addFormQuestion(input: $input) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
#
|
|
2
|
-
#
|
|
1
|
+
#import FormInfo from '../fragments/form-info.graphql'
|
|
2
|
+
#import QuestionInfo from '../fragments/question-info.graphql'
|
|
3
3
|
|
|
4
4
|
mutation RemoveFormQuestion($input: RemoveFormQuestionInput!, $search: String) {
|
|
5
5
|
removeFormQuestion(input: $input) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
#
|
|
2
|
-
#
|
|
1
|
+
#import FormInfo from '../fragments/form-info.graphql'
|
|
2
|
+
#import QuestionInfo from '../fragments/question-info.graphql'
|
|
3
3
|
|
|
4
4
|
mutation ReorderFormQuestions(
|
|
5
5
|
$input: ReorderFormQuestionsInput!
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#import QuestionInfo from '../fragments/question-info.graphql'
|
|
2
|
+
|
|
3
|
+
mutation SaveActionButtonQuestion($input: SaveActionButtonQuestionInput!) {
|
|
4
|
+
saveActionButtonQuestion(input: $input) {
|
|
5
|
+
question {
|
|
6
|
+
...QuestionInfo
|
|
7
|
+
... on ActionButtonQuestion {
|
|
8
|
+
action
|
|
9
|
+
color
|
|
10
|
+
validateOnEnter
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
clientMutationId
|
|
14
|
+
}
|
|
15
|
+
}
|