-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: enable JEXLs for options in choice and multiple choice questions
- Loading branch information
1 parent
194e42d
commit 892b885
Showing
15 changed files
with
190 additions
and
87 deletions.
There are no files selected for viewing
89 changes: 89 additions & 0 deletions
89
packages/form-builder/addon/components/cfb-form-editor/question-option.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
<li class="cfb-option-row" data-test-row={{concat "option-" (add @i 1)}}> | ||
<ValidatedForm @model={{@row}} as |f|> | ||
<div uk-grid class="uk-grid-small uk-flex uk-flex-top" id={{@row.slug}}> | ||
<div class="uk-width-auto uk-flex uk-flex-middle"> | ||
{{#if @canReorder}} | ||
<span | ||
data-test-sort-handle | ||
uk-icon="menu" | ||
class="uk-sortable-handle uk-margin-small-right" | ||
role="button" | ||
></span> | ||
{{/if}} | ||
{{#if (is-empty @row.id)}} | ||
<button | ||
data-test-delete-row | ||
type="button" | ||
class="uk-icon-button" | ||
uk-icon="trash" | ||
title={{t "caluma.form-builder.options.delete"}} | ||
{{on "click" (fn @deleteRow @row)}} | ||
> | ||
</button> | ||
{{else}} | ||
<button | ||
data-test-archive-row | ||
type="button" | ||
class="uk-icon-button" | ||
uk-icon={{if @row.isArchived "refresh" "close"}} | ||
title={{t | ||
(concat | ||
"caluma.form-builder.options." | ||
(if @row.isArchived "restore" "archive") | ||
) | ||
}} | ||
{{on | ||
"click" | ||
(fn (changeset-set @row "isArchived") (not @row.isArchived)) | ||
}} | ||
> | ||
</button> | ||
{{/if}} | ||
</div> | ||
<div class="uk-width-expand"> | ||
<f.input | ||
@name="label" | ||
@inputName={{concat "option-" (add @i 1) "-label"}} | ||
@required={{true}} | ||
@disabled={{@row.isArchived}} | ||
@submitted={{@submitted}} | ||
@on-update={{@updateLabel}} | ||
/> | ||
</div> | ||
<div class="uk-width-1-4"> | ||
<f.input | ||
@name="slug" | ||
@inputName={{concat "option-" (add @i 1) "-slug"}} | ||
@required={{true}} | ||
@disabled={{not (is-empty @row.id)}} | ||
@submitted={{@submitted}} | ||
@renderComponent={{component | ||
"cfb-slug-input" | ||
hidePrefix=true | ||
prefix=@model.slug | ||
onUnlink=(fn (mut @row.slugUnlinked) true) | ||
}} | ||
/> | ||
</div> | ||
<div class="uk-width-auto"> | ||
<button | ||
data-test-toggle-jexl | ||
type="button" | ||
class="uk-icon-button" | ||
uk-icon={{if this.showJexl "triangle-up" "triangle-down"}} | ||
title={{t "caluma.form-builder.options.show-jexl"}} | ||
{{on "click" (fn (mut this.showJexl) (not this.showJexl))}} | ||
/> | ||
</div> | ||
{{#if this.showJexl}} | ||
<div class="uk-width-4-4"> | ||
<f.input | ||
@label={{t "caluma.form-builder.question.isHidden"}} | ||
@name="isHidden" | ||
@renderComponent={{component "cfb-code-editor" language="jexl"}} | ||
/> | ||
</div> | ||
{{/if}} | ||
</div> | ||
</ValidatedForm> | ||
</li> |
6 changes: 6 additions & 0 deletions
6
packages/form-builder/addon/components/cfb-form-editor/question-option.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 CfbFormEditorQuestionOption extends Component { | ||
@tracked showJexl = false; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ mutation SaveOption($input: SaveOptionInput!) { | |
id | ||
label | ||
slug | ||
isHidden | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.