Skip to content

Commit

Permalink
fix(navigation): fix navigation to show base form questions (#565)
Browse files Browse the repository at this point in the history
Fixes #460
  • Loading branch information
Yelinz committed Oct 11, 2019
1 parent e5cd5ef commit 5f38df0
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 17 deletions.
43 changes: 27 additions & 16 deletions addon/lib/navigation.js
Expand Up @@ -59,15 +59,28 @@ export const NavigationItem = Base.extend({
* @property {String} label
* @accessor
*/
label: reads("fieldset.field.question.label"),
label: computed("fieldset.{field.question.label,form.name}", function() {
return this.getWithDefault(
"fieldset.field.question.label",
this.get("fieldset.form.name")
);
}),

/**
* The slug of the items form
*
* @property {String} slug
* @accessor
*/
slug: reads("fieldset.field.question.subForm.slug"),
slug: computed(
"fieldset.{field.question.subForm.slug,form.slug}",
function() {
return this.getWithDefault(
"fieldset.field.question.subForm.slug",
this.get("fieldset.form.slug")
);
}
),

/**
* The slug of the parent items form
Expand Down Expand Up @@ -101,7 +114,7 @@ export const NavigationItem = Base.extend({
"fieldset.fields.@each.{hidden,questionType}",
function() {
return (
!this.fieldset.field.hidden &&
(this.fieldset.field === undefined || !this.fieldset.field.hidden) &&
this.fieldset.fields.some(
field => field.questionType !== "FormQuestion" && !field.hidden
)
Expand Down Expand Up @@ -227,19 +240,17 @@ export const Navigation = Base.extend({
},

_createItems() {
const items = this.document.fieldsets
.filter(fieldset => fieldset.field)
.map(fieldset => {
const pk = `NavigationItem:${fieldset.pk}`;

return (
this.calumaStore.find(pk) ||
NavigationItem.create(getOwner(this).ownerInjection(), {
fieldset,
navigation: this
})
);
});
const items = this.document.fieldsets.map(fieldset => {
const pk = `NavigationItem:${fieldset.pk}`;

return (
this.calumaStore.find(pk) ||
NavigationItem.create(getOwner(this).ownerInjection(), {
fieldset,
navigation: this
})
);
});

this.set("items", items);
},
Expand Down
5 changes: 4 additions & 1 deletion addon/templates/components/cf-navigation.hbs
Expand Up @@ -2,6 +2,9 @@
{{#each (reject-by "parent" navigation.items) as |item|}}
{{#if item.visible}}
{{cf-navigation-item item=item}}
{{#unless item.fieldset.field}}
<hr class="uk-divider-small uk-margin-small">
{{/unless}}
{{/if}}
{{/each}}
</ul>
</ul>

0 comments on commit 5f38df0

Please sign in to comment.