Skip to content
Permalink
Browse files

fix(cf-navigation): auto-link empty form sections to first subsection (

…#185)

Also remove top-level question because it provided no real value and
broke the styling
  • Loading branch information...
czosel committed May 1, 2019
1 parent abdf659 commit a50a44275e1021dc32b23ef131c4532017782cbb
@@ -1,10 +1,27 @@
import Component from "@ember/component";
import layout from "../templates/components/cf-navigation-item";
import { computed } from "@ember/object";

export default Component.extend({
tagName: "",
layout,

section: null,
subSection: null
subSection: null,

_subSection: computed(
"subSection",
"field.childDocument.fields.[]",
function() {
if (
!this.get("subSection") &&
!(this.get("field.childDocument.fields") || []).some(
f => f.get("question.__typename") !== "FormQuestion"
)
) {
return this.get("field.childDocument.fields.firstObject.question.slug");
}
return this.get("subSection");
}
)
});
@@ -1,5 +1,5 @@
{{#if (not field.question.hidden)}}
{{#link-to (query-params section=section subSection=subSection)}}
{{#link-to (query-params section=section subSection=_subSection)}}
<div class="uk-flex uk-flex-between uk-flex-middle">
<div>{{label}}</div>
<span
@@ -5,39 +5,30 @@
</div>
{{else}}
<div class="uk-width-1-1 uk-width-1-3@m">
<ul class="uk-tab uk-tab-left">
<li>
{{cf-navigation-item
field=field
label=rootDocument.raw.form.name
state=rootDocument.state
}}
<ul class="uk-tab uk-tab-left uk-margin-left uk-margin-remove-vertical">
{{#each fields as |field|}}
<li>
{{cf-navigation-item
field=field
section=field.question.slug
label=field.question.label
state=field.childDocument.state
<ul class="uk-tab uk-tab-left uk-margin-left uk-margin-remove-vertical">
{{#each fields as |field|}}
<li>
{{cf-navigation-item
field=field
section=field.question.slug
label=field.question.label
state=field.childDocument.state
}}
<ul class="uk-tab uk-tab-left uk-margin-left uk-margin-remove-vertical">
{{#each field.navSubFields as |subField|}}
<li>
{{cf-navigation-item
field=subField
section=field.question.slug
subSection=subField.question.slug
label=subField.question.label
state=subField.childDocument.state
}}
<ul class="uk-tab uk-tab-left uk-margin-left uk-margin-remove-vertical">
{{#each field.navSubFields as |subField|}}
<li>
{{cf-navigation-item
field=subField
section=field.question.slug
subSection=subField.question.slug
label=subField.question.label
state=subField.childDocument.state
}}
</li>
{{/each}}
</ul>
</li>
{{/each}}
</ul>
</li>
</li>
{{/each}}
</ul>
</li>
{{/each}}
</ul>
</div>

0 comments on commit a50a442

Please sign in to comment.
You can’t perform that action at this time.