Skip to content

Commit

Permalink
fix: remove jexl logic and hide toggle (#233)
Browse files Browse the repository at this point in the history
  • Loading branch information
fkm authored and czosel committed May 14, 2019
1 parent 2f5a197 commit 9627dec
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
10 changes: 10 additions & 0 deletions addon/components/cfb-form-editor/question.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,16 @@ export default Component.extend(ComponentQueryManager, {
return namespace ? `${namespace}-` : "";
}),

requiredIsVisible: computed("changeset.{__typename,isRequired}", function() {
const isRequired = this.changeset.get("isRequired");
const typename = this.changeset.get("__typename");

return (
(isRequired === "true" || isRequired === "false") &&
typename !== "StaticQuestion"
);
}),

_getIntegerQuestionInput(changeset) {
return {
isRequired: changeset.get("isRequired"),
Expand Down
16 changes: 2 additions & 14 deletions addon/components/cfb-jexl-boolean-toggle-switch.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,16 @@
import RenderComponent from "ember-validated-form/components/validated-input/-themes/uikit/render";
import layout from "../templates/components/cfb-jexl-boolean-toggle-switch";
import jexl from "jexl";
import { reads } from "@ember/object/computed";
import { task } from "ember-concurrency";
import { computed } from "@ember/object";

export default RenderComponent.extend({
layout,

didReceiveAttrs() {
this._super(...arguments);

this.get("_boolValue").perform();
},

boolValue: reads("_boolValue.lastSuccessful.value"),

_boolValue: task(function*() {
return yield jexl.eval(this.get("value"));
}),

disabled: computed("value", function() {
const value = this.get("value");
return !(value === "true" || value === "false");
boolValue: computed("value", function() {
return this.get("value") === "true";
}),

actions: {
Expand Down
2 changes: 1 addition & 1 deletion addon/templates/components/cfb-form-editor/question.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
{{/if}}
</div>

{{#if (not-eq f.model.__typename "StaticQuestion")}}
{{#if requiredIsVisible}}
<div class="uk-width-auto uk-flex">
{{f.input
name="isRequired"
Expand Down

0 comments on commit 9627dec

Please sign in to comment.