@projectcaluma/ember-form-builder 9.0.2 → 9.0.6
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/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/table.js +12 -0
- 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 +21 -30
- package/addon/components/cfb-form-editor/question-list/item.js +2 -4
- package/addon/components/cfb-form-editor/question.hbs +386 -360
- package/addon/components/cfb-form-editor/question.js +136 -145
- 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-navigation.js +1 -1
- package/addon/components/cfb-toggle-switch.hbs +14 -12
- package/addon/controllers/edit/questions/edit.js +4 -1
- package/addon/controllers/edit/questions/new.js +4 -1
- package/addon/controllers/edit.js +4 -4
- package/addon/controllers/index.js +5 -2
- package/addon/controllers/new.js +4 -1
- package/addon/engine.js +1 -8
- package/addon/validators/gt-lt.js +3 -2
- package/app/components/{cfb-float-input/input.js → cfb-form-editor/question/default/table.js} +1 -1
- package/package.json +18 -16
- package/translations/de.yaml +2 -2
- package/translations/en.yaml +2 -2
- package/addon/components/cfb-float-input/input.js +0 -12
- package/addon/components/cfb-label.js +0 -5
|
@@ -1,17 +1,18 @@
|
|
|
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";
|
|
@@ -68,33 +69,17 @@ const TYPES_ANSWER = {
|
|
|
68
69
|
TableAnswer: saveDefaultTableAnswerMutation,
|
|
69
70
|
};
|
|
70
71
|
|
|
71
|
-
export default Component
|
|
72
|
-
|
|
72
|
+
export default class CfbFormEditorQuestion extends Component {
|
|
73
|
+
@service notification;
|
|
74
|
+
@service intl;
|
|
75
|
+
@service calumaOptions;
|
|
76
|
+
@queryManager apollo;
|
|
73
77
|
|
|
74
|
-
|
|
75
|
-
intl: service(),
|
|
76
|
-
calumaOptions: service(),
|
|
78
|
+
@tracked linkSlug = true;
|
|
77
79
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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
|
-
}),
|
|
88
|
-
|
|
89
|
-
async didReceiveAttrs() {
|
|
90
|
-
this._super();
|
|
91
|
-
await this.data.perform();
|
|
92
|
-
await this.availableForms.perform();
|
|
93
|
-
await this.availableDataSources.perform();
|
|
94
|
-
},
|
|
95
|
-
|
|
96
|
-
data: task(function* () {
|
|
97
|
-
if (!this.slug) {
|
|
80
|
+
@restartableTask
|
|
81
|
+
*data() {
|
|
82
|
+
if (!this.args.slug) {
|
|
98
83
|
return A([
|
|
99
84
|
{
|
|
100
85
|
node: {
|
|
@@ -125,14 +110,15 @@ export default Component.extend({
|
|
|
125
110
|
return yield this.apollo.watchQuery(
|
|
126
111
|
{
|
|
127
112
|
query: formEditorQuestionQuery,
|
|
128
|
-
variables: { slug: this.slug },
|
|
113
|
+
variables: { slug: this.args.slug },
|
|
129
114
|
fetchPolicy: "cache-and-network",
|
|
130
115
|
},
|
|
131
116
|
"allQuestions.edges"
|
|
132
117
|
);
|
|
133
|
-
}
|
|
118
|
+
}
|
|
134
119
|
|
|
135
|
-
|
|
120
|
+
@restartableTask
|
|
121
|
+
*availableForms() {
|
|
136
122
|
const forms = yield this.apollo.watchQuery(
|
|
137
123
|
{
|
|
138
124
|
query: formListQuery,
|
|
@@ -147,10 +133,31 @@ export default Component.extend({
|
|
|
147
133
|
if (!forms.map) {
|
|
148
134
|
return [];
|
|
149
135
|
}
|
|
150
|
-
return forms.mapBy("node").filter((form) => form.slug !== this.form);
|
|
151
|
-
}
|
|
136
|
+
return forms.mapBy("node").filter((form) => form.slug !== this.args.form);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
@restartableTask
|
|
140
|
+
*availableDataSources() {
|
|
141
|
+
const dataSources = yield this.apollo.watchQuery(
|
|
142
|
+
{ query: allDataSourcesQuery, fetchPolicy: "cache-and-network" },
|
|
143
|
+
"allDataSources.edges"
|
|
144
|
+
);
|
|
145
|
+
return dataSources.map((edge) => {
|
|
146
|
+
return {
|
|
147
|
+
...edge.node,
|
|
148
|
+
__typename: undefined,
|
|
149
|
+
};
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
get possibleTypes() {
|
|
154
|
+
return Object.keys(TYPES).map((value) => ({
|
|
155
|
+
value,
|
|
156
|
+
label: this.intl.t(`caluma.form-builder.question.types.${value}`),
|
|
157
|
+
}));
|
|
158
|
+
}
|
|
152
159
|
|
|
153
|
-
availableOverrides
|
|
160
|
+
get availableOverrides() {
|
|
154
161
|
const type = this.changeset.get("__typename");
|
|
155
162
|
const overrides = this.calumaOptions
|
|
156
163
|
.getComponentOverrides()
|
|
@@ -162,54 +169,25 @@ export default Component.extend({
|
|
|
162
169
|
{ label: this.intl.t("caluma.form.power-select.null"), component: "" },
|
|
163
170
|
...overrides,
|
|
164
171
|
];
|
|
165
|
-
}
|
|
172
|
+
}
|
|
166
173
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
"allDataSources.edges"
|
|
171
|
-
);
|
|
172
|
-
return dataSources.map((edge) => {
|
|
173
|
-
return {
|
|
174
|
-
...edge.node,
|
|
175
|
-
__typename: undefined,
|
|
176
|
-
};
|
|
177
|
-
});
|
|
178
|
-
}).restartable(),
|
|
179
|
-
|
|
180
|
-
model: reads("data.lastSuccessful.value.firstObject.node"),
|
|
174
|
+
get model() {
|
|
175
|
+
return this.data.lastSuccessful?.value?.firstObject?.node;
|
|
176
|
+
}
|
|
181
177
|
|
|
182
|
-
changeset
|
|
183
|
-
return new Changeset(this.model, lookupValidator(validations));
|
|
184
|
-
}
|
|
178
|
+
get changeset() {
|
|
179
|
+
return new Changeset(this.model, lookupValidator(validations), validations);
|
|
180
|
+
}
|
|
185
181
|
|
|
186
|
-
prefix
|
|
182
|
+
get prefix() {
|
|
187
183
|
return this.calumaOptions.namespace
|
|
188
184
|
? `${this.calumaOptions.namespace}-`
|
|
189
185
|
: "";
|
|
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
|
-
),
|
|
186
|
+
}
|
|
210
187
|
|
|
211
188
|
getInput(changeset) {
|
|
212
|
-
const slug =
|
|
189
|
+
const slug =
|
|
190
|
+
((!this.args.slug && this.prefix) || "") + changeset.get("slug");
|
|
213
191
|
|
|
214
192
|
const input = {
|
|
215
193
|
slug,
|
|
@@ -220,7 +198,7 @@ export default Component.extend({
|
|
|
220
198
|
isArchived: changeset.get("isArchived"),
|
|
221
199
|
};
|
|
222
200
|
|
|
223
|
-
if (!
|
|
201
|
+
if (!hasQuestionType(changeset, "static", "calculated-float")) {
|
|
224
202
|
Object.assign(input, {
|
|
225
203
|
isRequired: changeset.get("isRequired"),
|
|
226
204
|
});
|
|
@@ -232,7 +210,7 @@ export default Component.extend({
|
|
|
232
210
|
}
|
|
233
211
|
|
|
234
212
|
return input;
|
|
235
|
-
}
|
|
213
|
+
}
|
|
236
214
|
|
|
237
215
|
_getIntegerQuestionInput(changeset) {
|
|
238
216
|
return {
|
|
@@ -240,7 +218,7 @@ export default Component.extend({
|
|
|
240
218
|
maxValue: parseInt(changeset.get("integerMaxValue")),
|
|
241
219
|
placeholder: changeset.get("placeholder"),
|
|
242
220
|
};
|
|
243
|
-
}
|
|
221
|
+
}
|
|
244
222
|
|
|
245
223
|
_getFloatQuestionInput(changeset) {
|
|
246
224
|
return {
|
|
@@ -248,7 +226,7 @@ export default Component.extend({
|
|
|
248
226
|
maxValue: parseFloat(changeset.get("floatMaxValue")),
|
|
249
227
|
placeholder: changeset.get("placeholder"),
|
|
250
228
|
};
|
|
251
|
-
}
|
|
229
|
+
}
|
|
252
230
|
|
|
253
231
|
_getTextQuestionInput(changeset) {
|
|
254
232
|
return {
|
|
@@ -256,7 +234,7 @@ export default Component.extend({
|
|
|
256
234
|
maxLength: parseInt(changeset.get("maxLength")),
|
|
257
235
|
placeholder: changeset.get("placeholder"),
|
|
258
236
|
};
|
|
259
|
-
}
|
|
237
|
+
}
|
|
260
238
|
|
|
261
239
|
_getTextareaQuestionInput(changeset) {
|
|
262
240
|
return {
|
|
@@ -264,59 +242,60 @@ export default Component.extend({
|
|
|
264
242
|
maxLength: parseInt(changeset.get("maxLength")),
|
|
265
243
|
placeholder: changeset.get("placeholder"),
|
|
266
244
|
};
|
|
267
|
-
}
|
|
245
|
+
}
|
|
268
246
|
|
|
269
247
|
_getMultipleChoiceQuestionInput(changeset) {
|
|
270
248
|
return {
|
|
271
249
|
options: changeset.get("options.edges").map(({ node: { slug } }) => slug),
|
|
272
250
|
};
|
|
273
|
-
}
|
|
251
|
+
}
|
|
274
252
|
|
|
275
253
|
_getChoiceQuestionInput(changeset) {
|
|
276
254
|
return {
|
|
277
255
|
options: changeset.get("options.edges").map(({ node: { slug } }) => slug),
|
|
278
256
|
};
|
|
279
|
-
}
|
|
257
|
+
}
|
|
280
258
|
|
|
281
259
|
_getDynamicMultipleChoiceQuestionInput(changeset) {
|
|
282
260
|
return {
|
|
283
261
|
dataSource: changeset.get("dataSource"),
|
|
284
262
|
};
|
|
285
|
-
}
|
|
263
|
+
}
|
|
286
264
|
|
|
287
265
|
_getDynamicChoiceQuestionInput(changeset) {
|
|
288
266
|
return {
|
|
289
267
|
dataSource: changeset.get("dataSource"),
|
|
290
268
|
};
|
|
291
|
-
}
|
|
269
|
+
}
|
|
292
270
|
|
|
293
271
|
_getTableQuestionInput(changeset) {
|
|
294
272
|
return {
|
|
295
273
|
rowForm: changeset.get("rowForm.slug"),
|
|
296
274
|
};
|
|
297
|
-
}
|
|
275
|
+
}
|
|
298
276
|
|
|
299
277
|
_getFormQuestionInput(changeset) {
|
|
300
278
|
return {
|
|
301
279
|
subForm: changeset.get("subForm.slug"),
|
|
302
280
|
};
|
|
303
|
-
}
|
|
281
|
+
}
|
|
304
282
|
|
|
305
283
|
_getStaticQuestionInput(changeset) {
|
|
306
284
|
return {
|
|
307
285
|
staticContent: changeset.get("staticContent"),
|
|
308
286
|
};
|
|
309
|
-
}
|
|
287
|
+
}
|
|
310
288
|
|
|
311
289
|
_getCalculatedFloatQuestionInput(changeset) {
|
|
312
290
|
return {
|
|
313
291
|
calcExpression: changeset.get("calcExpression"),
|
|
314
292
|
};
|
|
315
|
-
}
|
|
293
|
+
}
|
|
316
294
|
|
|
317
|
-
|
|
295
|
+
@task
|
|
296
|
+
*saveOptions(changeset) {
|
|
318
297
|
yield all(
|
|
319
|
-
(get(
|
|
298
|
+
(changeset.get("options.edges") || []).map(async ({ node: option }) => {
|
|
320
299
|
const { label, slug, isArchived } = option;
|
|
321
300
|
|
|
322
301
|
await this.apollo.mutate({
|
|
@@ -325,21 +304,21 @@ export default Component.extend({
|
|
|
325
304
|
});
|
|
326
305
|
})
|
|
327
306
|
);
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
saveDefaultAnswer: task(function* (question, changeset) {
|
|
331
|
-
const answer = changeset.get("defaultAnswer");
|
|
307
|
+
}
|
|
332
308
|
|
|
333
|
-
|
|
309
|
+
@task
|
|
310
|
+
*saveDefaultAnswer(question, changeset) {
|
|
311
|
+
if (!changeset.get("defaultAnswer")) {
|
|
334
312
|
return;
|
|
335
313
|
}
|
|
336
314
|
|
|
337
|
-
const
|
|
338
|
-
const
|
|
315
|
+
const typename = changeset.get("defaultAnswer.__typename");
|
|
316
|
+
const valueKey = camelize(typename.replace(/Answer$/, "Value"));
|
|
317
|
+
const value = changeset.get(`defaultAnswer.${valueKey}`);
|
|
339
318
|
|
|
340
319
|
// We need to map the UUIDs of the document's if the user didn't touch
|
|
341
320
|
// the default answer and thus never triggered the onUpdate action.
|
|
342
|
-
if (
|
|
321
|
+
if (typename === "TableAnswer" && typeof value[0] !== "string") {
|
|
343
322
|
return;
|
|
344
323
|
}
|
|
345
324
|
|
|
@@ -348,7 +327,7 @@ export default Component.extend({
|
|
|
348
327
|
// Save or remove depending on the value.
|
|
349
328
|
const mutation = !isAddMutation
|
|
350
329
|
? removeDefaultAnswerMutation
|
|
351
|
-
: TYPES_ANSWER[
|
|
330
|
+
: TYPES_ANSWER[typename];
|
|
352
331
|
|
|
353
332
|
const input = { question: question.slug };
|
|
354
333
|
|
|
@@ -358,9 +337,10 @@ export default Component.extend({
|
|
|
358
337
|
}
|
|
359
338
|
|
|
360
339
|
yield this.apollo.mutate({ mutation, variables: { input } });
|
|
361
|
-
}
|
|
340
|
+
}
|
|
362
341
|
|
|
363
|
-
|
|
342
|
+
@dropTask
|
|
343
|
+
*submit(changeset) {
|
|
364
344
|
try {
|
|
365
345
|
yield this.saveOptions.perform(changeset);
|
|
366
346
|
|
|
@@ -376,14 +356,14 @@ export default Component.extend({
|
|
|
376
356
|
|
|
377
357
|
yield this.saveDefaultAnswer.perform(question, changeset);
|
|
378
358
|
|
|
379
|
-
if (!this.slug) {
|
|
359
|
+
if (!this.args.slug) {
|
|
380
360
|
// This is a new question which must be added to the form after creating it
|
|
381
361
|
yield this.apollo.mutate({
|
|
382
362
|
mutation: addFormQuestionMutation,
|
|
383
363
|
variables: {
|
|
384
364
|
input: {
|
|
385
365
|
question: question.slug,
|
|
386
|
-
form: this.form,
|
|
366
|
+
form: this.args.form,
|
|
387
367
|
},
|
|
388
368
|
search: "",
|
|
389
369
|
},
|
|
@@ -394,7 +374,7 @@ export default Component.extend({
|
|
|
394
374
|
this.intl.t("caluma.form-builder.notification.question.save.success")
|
|
395
375
|
);
|
|
396
376
|
|
|
397
|
-
optional([this.
|
|
377
|
+
optional([this.args["on-after-submit"]])(question);
|
|
398
378
|
} catch (e) {
|
|
399
379
|
// eslint-disable-next-line no-console
|
|
400
380
|
console.error(e);
|
|
@@ -402,9 +382,10 @@ export default Component.extend({
|
|
|
402
382
|
this.intl.t("caluma.form-builder.notification.question.save.error")
|
|
403
383
|
);
|
|
404
384
|
}
|
|
405
|
-
}
|
|
385
|
+
}
|
|
406
386
|
|
|
407
|
-
|
|
387
|
+
@restartableTask
|
|
388
|
+
*validateSlug(slug, changeset) {
|
|
408
389
|
/* istanbul ignore next */
|
|
409
390
|
if (
|
|
410
391
|
getOwner(this).resolveRegistration("config:environment").environment !==
|
|
@@ -427,46 +408,56 @@ export default Component.extend({
|
|
|
427
408
|
this.intl.t("caluma.form-builder.validations.question.slug")
|
|
428
409
|
);
|
|
429
410
|
}
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
actions: {
|
|
433
|
-
updateLabel(value, changeset) {
|
|
434
|
-
changeset.set("label", value);
|
|
435
|
-
|
|
436
|
-
if (!this.slug && this.linkSlug) {
|
|
437
|
-
const slug = slugify(value, { locale: this.intl.primaryLocale });
|
|
438
|
-
|
|
439
|
-
changeset.set("slug", slug);
|
|
440
|
-
|
|
441
|
-
this.validateSlug.perform(this.prefix + slug, changeset);
|
|
442
|
-
}
|
|
443
|
-
},
|
|
411
|
+
}
|
|
444
412
|
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
/*
|
|
453
|
-
* This function adds the selected slugs to the columns to display
|
|
454
|
-
* list if it isnt present, otherwise it will remove the slug.
|
|
455
|
-
*/
|
|
456
|
-
toggleColumnToDisplay(value) {
|
|
457
|
-
const displayed = new Set(this.changeset.get("meta.columnsToDisplay"));
|
|
413
|
+
@action
|
|
414
|
+
async fetchData() {
|
|
415
|
+
await this.data.perform();
|
|
416
|
+
await this.availableForms.perform();
|
|
417
|
+
await this.availableDataSources.perform();
|
|
418
|
+
}
|
|
458
419
|
|
|
459
|
-
|
|
420
|
+
@action
|
|
421
|
+
updateLabel(value, changeset) {
|
|
422
|
+
changeset.set("label", value);
|
|
460
423
|
|
|
461
|
-
|
|
462
|
-
|
|
424
|
+
if (!this.args.slug && this.linkSlug) {
|
|
425
|
+
const slug = slugify(value, { locale: this.intl.primaryLocale });
|
|
463
426
|
|
|
464
|
-
|
|
465
|
-
changeset.set("subForm.slug", value.slug);
|
|
466
|
-
},
|
|
427
|
+
changeset.set("slug", slug);
|
|
467
428
|
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
429
|
+
this.validateSlug.perform(this.prefix + slug, changeset);
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
@action
|
|
434
|
+
updateSlug(value, changeset) {
|
|
435
|
+
changeset.set("slug", value);
|
|
436
|
+
this.linkSlug = false;
|
|
437
|
+
|
|
438
|
+
this.validateSlug.perform(this.prefix + value, changeset);
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
/*
|
|
442
|
+
* This function adds the selected slugs to the columns to display
|
|
443
|
+
* list if it isnt present, otherwise it will remove the slug.
|
|
444
|
+
*/
|
|
445
|
+
@action
|
|
446
|
+
toggleColumnToDisplay(value, changeset) {
|
|
447
|
+
const displayed = new Set(changeset.get("meta.columnsToDisplay"));
|
|
448
|
+
|
|
449
|
+
displayed.delete(value) || displayed.add(value);
|
|
450
|
+
|
|
451
|
+
changeset.set("meta.columnsToDisplay", [...displayed]);
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
@action
|
|
455
|
+
updateSubForm(value, changeset) {
|
|
456
|
+
changeset.set("subForm.slug", value.slug);
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
@action
|
|
460
|
+
updateRowForm(value, changeset) {
|
|
461
|
+
changeset.set("rowForm.slug", value.slug);
|
|
462
|
+
}
|
|
463
|
+
}
|
|
@@ -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>
|
|
@@ -7,7 +7,7 @@ export default class CfbNavigationComponent extends Component {
|
|
|
7
7
|
@service router;
|
|
8
8
|
|
|
9
9
|
get _routes() {
|
|
10
|
-
const currentRoute = this.router.currentRouteName
|
|
10
|
+
const currentRoute = `${this.router._mountPoint}.${this.router.currentRouteName}`;
|
|
11
11
|
if (!currentRoute) return [];
|
|
12
12
|
|
|
13
13
|
const routeParts = currentRoute.split(".");
|
|
@@ -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,9 +1,12 @@
|
|
|
1
1
|
import Controller from "@ember/controller";
|
|
2
2
|
import { action } from "@ember/object";
|
|
3
|
+
import { inject as service } from "@ember/service";
|
|
3
4
|
|
|
4
5
|
export default class EditQuestionsEditController extends Controller {
|
|
6
|
+
@service router;
|
|
7
|
+
|
|
5
8
|
@action
|
|
6
9
|
afterSubmit() {
|
|
7
|
-
this.
|
|
10
|
+
this.router.transitionTo("edit");
|
|
8
11
|
}
|
|
9
12
|
}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import Controller from "@ember/controller";
|
|
2
2
|
import { action } from "@ember/object";
|
|
3
|
+
import { inject as service } from "@ember/service";
|
|
3
4
|
|
|
4
5
|
export default class EditQuestionsNewController extends Controller {
|
|
6
|
+
@service router;
|
|
7
|
+
|
|
5
8
|
@action
|
|
6
9
|
afterSubmit({ slug }) {
|
|
7
|
-
this.
|
|
10
|
+
this.router.transitionTo("edit.questions.edit", slug);
|
|
8
11
|
}
|
|
9
12
|
}
|
|
@@ -7,12 +7,12 @@ export default class EditController extends Controller {
|
|
|
7
7
|
|
|
8
8
|
@action
|
|
9
9
|
createQuestion() {
|
|
10
|
-
this.
|
|
10
|
+
this.router.transitionTo("edit.questions.new");
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
@action
|
|
14
14
|
editQuestion({ slug }) {
|
|
15
|
-
this.
|
|
15
|
+
this.router.transitionTo("edit.questions.edit", slug);
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
@action
|
|
@@ -21,12 +21,12 @@ export default class EditController extends Controller {
|
|
|
21
21
|
/edit\.questions\.edit$/.test(this.router.currentRouteName) &&
|
|
22
22
|
new RegExp(`/${slug}$`).test(this.router.currentURL)
|
|
23
23
|
) {
|
|
24
|
-
this.
|
|
24
|
+
this.router.transitionTo("edit.general");
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
@action
|
|
29
29
|
clickForm({ slug }) {
|
|
30
|
-
this.
|
|
30
|
+
this.router.transitionTo("edit", slug);
|
|
31
31
|
}
|
|
32
32
|
}
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import Controller from "@ember/controller";
|
|
2
2
|
import { action } from "@ember/object";
|
|
3
|
+
import { inject as service } from "@ember/service";
|
|
3
4
|
|
|
4
5
|
export default class IndexController extends Controller {
|
|
6
|
+
@service router;
|
|
7
|
+
|
|
5
8
|
@action
|
|
6
9
|
newForm() {
|
|
7
|
-
this.
|
|
10
|
+
this.router.transitionTo("new");
|
|
8
11
|
}
|
|
9
12
|
|
|
10
13
|
@action
|
|
11
14
|
editForm({ slug }) {
|
|
12
|
-
this.
|
|
15
|
+
this.router.transitionTo("edit", slug);
|
|
13
16
|
}
|
|
14
17
|
}
|