Skip to content

Commit

Permalink
feat(form-builder): allow editing of form meta (#2597)
Browse files Browse the repository at this point in the history
  • Loading branch information
StephanH90 authored Jan 25, 2024
1 parent 077e7a0 commit e9640b7
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<UkButton
@color="link"
@onClick={{toggle-action "showAdvanced" this}}
class="uk-flex uk-flex-middle uk-margin"
>
{{#if this.showAdvanced}}
<UkIcon @icon="triangle-down" />
{{else}}
<UkIcon @icon="triangle-right" />
{{/if}}
{{t "caluma.form-builder.question.advancedSettings"}}
</UkButton>

{{#if this.showAdvanced}}
{{yield}}
{{/if}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import Component from "@glimmer/component";
import { tracked } from "@glimmer/tracking";

export default class CfbFormEditorCfbAdvancedSettings extends Component {
@tracked showAdvanced = false;
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@
@renderComponent={{component "cfb-toggle-switch" size="small"}}
/>

<CfbFormEditor::CfbAdvancedSettings>
<f.input
@label={{t "caluma.form-builder.question.meta"}}
@name="meta"
@renderComponent={{component "cfb-code-editor" language="json"}}
/>
</CfbFormEditor::CfbAdvancedSettings>

<div class="uk-text-right">
<f.submit
@disabled={{f.loading}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ export default class CfbFormEditorGeneral extends Component {

@dropTask
*submit(changeset) {
const rawMeta = changeset.get("meta");

try {
const form = yield this.apollo.mutate(
{
Expand All @@ -69,6 +71,7 @@ export default class CfbFormEditorGeneral extends Component {
description: changeset.get("description"),
isArchived: changeset.get("isArchived"),
isPublished: changeset.get("isPublished"),
meta: JSON.stringify(rawMeta?.unwrap?.() ?? rawMeta),
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,20 +384,7 @@
@renderComponent={{component "cfb-toggle-switch" size="small"}}
/>

<UkButton
@color="link"
@onClick={{toggle-action "showAdvanced" this}}
class="uk-flex uk-flex-middle uk-margin"
>
{{#if this.showAdvanced}}
<UkIcon @icon="triangle-down" />
{{else}}
<UkIcon @icon="triangle-right" />
{{/if}}
{{t "caluma.form-builder.question.advancedSettings"}}
</UkButton>

{{#if this.showAdvanced}}
<CfbFormEditor::CfbAdvancedSettings>
{{#if (has-question-type f.model "action-button")}}
<f.input
@name="validateOnEnter"
Expand Down Expand Up @@ -438,7 +425,7 @@
@name="meta"
@renderComponent={{component "cfb-code-editor" language="json"}}
/>
{{/if}}
</CfbFormEditor::CfbAdvancedSettings>

<div class="uk-flex uk-flex-between uk-flex-middle uk-flex-row-reverse">
<CfbFormEditor::QuestionUsage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ fragment FormInfo on Form {
description
isArchived
isPublished
meta
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from "@projectcaluma/ember-form-builder/components/cfb-form-editor/cfb-advanced-settings";

0 comments on commit e9640b7

Please sign in to comment.