Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(form-builder): allow editing of form meta #2597

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @model={{f.model}} class="uk-flex-last" />
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";
Loading