@projectcaluma/ember-form-builder 12.9.0 → 12.10.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.
@@ -0,0 +1,50 @@
1
+ <UkModal
2
+ @visible={{this.visible}}
3
+ @onHide={{fn (mut this.visible) false}}
4
+ data-test-copy-form-modal
5
+ as |modal|
6
+ >
7
+ {{#if this.visible}}
8
+ <ValidatedForm
9
+ @model={{this.changeset}}
10
+ @on-submit={{perform this.submit}}
11
+ as |f|
12
+ >
13
+ <modal.header>
14
+ <h2 class="uk-modal-title">
15
+ {{t "caluma.form-builder.copy-modal.title" form=@item.name}}
16
+ </h2>
17
+ </modal.header>
18
+ <modal.body>
19
+ <f.input
20
+ @name="name"
21
+ @label={{t "caluma.form-builder.copy-modal.name.label"}}
22
+ @hint={{t "caluma.form-builder.copy-modal.name.hint" name=@item.name}}
23
+ data-test-copy-modal-input-name
24
+ />
25
+ <f.input
26
+ @name="slug"
27
+ @label={{t "caluma.form-builder.copy-modal.slug.label"}}
28
+ @hint={{t "caluma.form-builder.copy-modal.slug.hint" slug=@item.slug}}
29
+ @renderComponent={{component "cfb-slug-input" hidePrefix=false}}
30
+ data-test-copy-modal-input-slug
31
+ />
32
+ </modal.body>
33
+ <modal.footer class="uk-text-right">
34
+ <f.submit
35
+ @loading={{this.submit.isRunning}}
36
+ @disabled={{or
37
+ this.submit.isRunning
38
+ (not this.changeset.isValid)
39
+ (eq @item.slug this.changeset.slug)
40
+ }}
41
+ data-test-copy-form-submit
42
+ >
43
+ {{t "caluma.form-builder.copy-modal.submit"}}
44
+ </f.submit>
45
+ </modal.footer>
46
+ </ValidatedForm>
47
+ {{/if}}
48
+ </UkModal>
49
+
50
+ {{yield (hash toggle=this.toggle)}}
@@ -0,0 +1,63 @@
1
+ import { action } from "@ember/object";
2
+ import { inject as service } from "@ember/service";
3
+ import Component from "@glimmer/component";
4
+ import { tracked } from "@glimmer/tracking";
5
+ import { queryManager } from "ember-apollo-client";
6
+ import { Changeset } from "ember-changeset";
7
+ import lookupValidator from "ember-changeset-validations";
8
+ import { dropTask } from "ember-concurrency";
9
+
10
+ import copyFormMutation from "@projectcaluma/ember-form-builder/gql/mutations/copy-form.graphql";
11
+ import validations from "@projectcaluma/ember-form-builder/validations/form";
12
+
13
+ export default class CfbFormEditorCopyModal extends Component {
14
+ @queryManager apollo;
15
+ @service notification;
16
+ @service router;
17
+ @service intl;
18
+ @tracked visible = false;
19
+
20
+ constructor(owner, args) {
21
+ super(owner, args);
22
+
23
+ this.changeset = Changeset(
24
+ { ...this.args.item, id: undefined },
25
+ lookupValidator(validations),
26
+ validations,
27
+ );
28
+ }
29
+
30
+ @action
31
+ toggle() {
32
+ this.visible = !this.visible;
33
+ }
34
+
35
+ @dropTask
36
+ *submit(changeset) {
37
+ try {
38
+ yield this.apollo.mutate(
39
+ {
40
+ mutation: copyFormMutation,
41
+ variables: {
42
+ input: {
43
+ source: this.args.item.slug,
44
+ name: changeset.name,
45
+ slug: changeset.slug,
46
+ },
47
+ },
48
+ },
49
+ "copyForm.form",
50
+ );
51
+
52
+ this.notification.success(
53
+ this.intl.t("caluma.form-builder.notification.form.create.success"),
54
+ );
55
+
56
+ this.router.transitionTo("edit", changeset.slug);
57
+ } catch (e) {
58
+ this.notification.danger(
59
+ this.intl.t("caluma.form-builder.notification.form.create.error"),
60
+ );
61
+ }
62
+ }
63
+ }
@@ -58,6 +58,15 @@
58
58
  </CfbFormEditor::CfbAdvancedSettings>
59
59
 
60
60
  <div class="uk-text-right">
61
+ <CfbFormEditor::CopyModal @item={{this.data}} as |modal|>
62
+ <f.button
63
+ @disabled={{f.loading}}
64
+ @label={{t "caluma.form-builder.copy-modal.submit"}}
65
+ {{on "click" modal.toggle}}
66
+ data-test-copy-form-button={{@slug}}
67
+ />
68
+ </CfbFormEditor::CopyModal>
69
+
61
70
  <f.submit
62
71
  @disabled={{f.loading}}
63
72
  @label={{t "caluma.form-builder.global.save"}}
@@ -10,7 +10,7 @@
10
10
  type="button"
11
11
  class="uk-icon-button uk-animation-slide-top"
12
12
  uk-icon="close"
13
- title={{t "caluma.form-builder.global.ca ncel"}}
13
+ title={{t "caluma.form-builder.global.cancel"}}
14
14
  {{on "click" (fn this.setMode "reorder")}}
15
15
  >
16
16
  </button>
@@ -14,6 +14,7 @@
14
14
  </span>
15
15
  {{/if}}
16
16
  <input
17
+ ...attributes
17
18
  id={{@inputId}}
18
19
  name={{or @inputName @name}}
19
20
  type="text"
@@ -1,4 +1,5 @@
1
1
  import { action } from "@ember/object";
2
+ import { scheduleOnce } from "@ember/runloop";
2
3
  import { inject as service } from "@ember/service";
3
4
  import { htmlSafe } from "@ember/template";
4
5
  import Component from "@glimmer/component";
@@ -30,6 +31,12 @@ export default class CfbSlugInputComponent extends Component {
30
31
 
31
32
  @action
32
33
  calculatePadding(element) {
34
+ // Ensures that the element is already visible in combined use
35
+ // with modal dialogs.
36
+ scheduleOnce("afterRender", this, "_calculatePadding", element);
37
+ }
38
+
39
+ _calculatePadding(element) {
33
40
  const prefixWidth = element.clientWidth;
34
41
  const prefixMargin = window.getComputedStyle(element).marginLeft;
35
42
 
@@ -0,0 +1,8 @@
1
+ mutation CopyForm($input: CopyFormInput!) {
2
+ copyForm(input: $input) {
3
+ form {
4
+ id
5
+ }
6
+ clientMutationId
7
+ }
8
+ }
@@ -0,0 +1 @@
1
+ export { default } from "@projectcaluma/ember-form-builder/components/cfb-form-editor/copy-modal";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@projectcaluma/ember-form-builder",
3
- "version": "12.9.0",
3
+ "version": "12.10.0",
4
4
  "description": "Ember engine for building Caluma forms.",
5
5
  "keywords": [
6
6
  "ember-addon",
@@ -10,7 +10,7 @@
10
10
  "homepage": "https://docs.caluma.io/ember-caluma",
11
11
  "repository": "github:projectcaluma/ember-caluma",
12
12
  "dependencies": {
13
- "@babel/core": "^7.23.7",
13
+ "@babel/core": "^7.23.9",
14
14
  "@ember/legacy-built-in-components": "^0.5.0",
15
15
  "@ember/render-modifiers": "^2.1.0",
16
16
  "@ember/string": "^3.1.1",
@@ -44,8 +44,8 @@
44
44
  "jexl": "^2.3.0",
45
45
  "lodash.isequal": "^4.5.0",
46
46
  "uikit": "^3.17.11",
47
- "@projectcaluma/ember-core": "^12.9.0",
48
- "@projectcaluma/ember-form": "^12.9.0"
47
+ "@projectcaluma/ember-core": "^12.10.0",
48
+ "@projectcaluma/ember-form": "^12.10.0"
49
49
  },
50
50
  "//": [
51
51
  "TODO: remove obsolete dependency to `ember-data` which is only necessary",
@@ -54,10 +54,10 @@
54
54
  "docs app) but not as direct dependency of the package."
55
55
  ],
56
56
  "devDependencies": {
57
- "@ember/optional-features": "2.0.0",
57
+ "@ember/optional-features": "2.1.0",
58
58
  "@ember/test-helpers": "3.2.1",
59
59
  "@embroider/test-setup": "3.0.3",
60
- "@faker-js/faker": "8.3.1",
60
+ "@faker-js/faker": "8.4.1",
61
61
  "broccoli-asset-rev": "3.0.0",
62
62
  "ember-autoresize-modifier": "0.7.0",
63
63
  "ember-cli": "5.5.0",
@@ -80,8 +80,8 @@
80
80
  "miragejs": "0.1.48",
81
81
  "qunit": "2.20.0",
82
82
  "qunit-dom": "3.0.0",
83
- "webpack": "5.89.0",
84
- "@projectcaluma/ember-testing": "12.9.0"
83
+ "webpack": "5.90.0",
84
+ "@projectcaluma/ember-testing": "12.10.0"
85
85
  },
86
86
  "peerDependencies": {
87
87
  "ember-engines": "^0.9.0",
@@ -129,6 +129,7 @@ caluma:
129
129
  widgetOverrides:
130
130
  powerselect: "Power Select"
131
131
  hidden: "Versteckt"
132
+ number-separator: "Zahlentrennzeichen"
132
133
 
133
134
  not-found: "Keine Frage mit dem Slug '{slug}' gefunden"
134
135
 
@@ -175,6 +176,16 @@ caluma:
175
176
  success: "Ihre Frage wurde erfolgreich gespeichert!"
176
177
  error: "Hoppla, beim Speichern der Frage ist etwas schief gelaufen..."
177
178
 
179
+ copy-modal:
180
+ title: '"{form}" kopieren'
181
+ name:
182
+ label: "Name"
183
+ hint: "Original: {name}"
184
+ slug:
185
+ label: "Slug"
186
+ hint: "Original: {slug}"
187
+ submit: "Kopieren"
188
+
178
189
  validations:
179
190
  form:
180
191
  slug: "Ein Formular mit diesem Slug existiert bereits"
@@ -129,6 +129,7 @@ caluma:
129
129
  widgetOverrides:
130
130
  powerselect: "Power Select"
131
131
  hidden: "Hidden"
132
+ number-separator: "Number separator"
132
133
 
133
134
  not-found: "No question with slug '{slug}' found"
134
135
 
@@ -175,6 +176,16 @@ caluma:
175
176
  success: "Your question was successfully saved!"
176
177
  error: "Ooops, something went wrong while saving the question..."
177
178
 
179
+ copy-modal:
180
+ title: 'Copy "{form}"'
181
+ name:
182
+ label: "Name"
183
+ hint: "Original: {name}"
184
+ slug:
185
+ label: "Slug"
186
+ hint: "Original: {slug}"
187
+ submit: "Copy"
188
+
178
189
  validations:
179
190
  form:
180
191
  slug: "A form with this slug already exists"
@@ -129,6 +129,7 @@ caluma:
129
129
  widgetOverrides:
130
130
  powerselect: "Power Select"
131
131
  hidden: "Caché"
132
+ number-separator: "Séparateur de chiffres"
132
133
 
133
134
  not-found: "Aucune question trouvée avec le slug '{slug}'"
134
135
 
@@ -175,6 +176,16 @@ caluma:
175
176
  success: "Votre question a été enregistrée avec succès !"
176
177
  error: "Oups, quelque chose s'est mal passé lors de l'enregistrement de la question..."
177
178
 
179
+ copy-modal:
180
+ title: 'Copier "{form}"'
181
+ name:
182
+ label: "Nom"
183
+ hint: "Original : {name}"
184
+ slug:
185
+ label: "Slug"
186
+ hint: "Original : {slug}"
187
+ submit: "Copier"
188
+
178
189
  validations:
179
190
  form:
180
191
  slug: "Un formulaire avec ce slug existe déjà"