Skip to content

Commit

Permalink
feat(cf-form): allow passing context information to cf-form, cf-navig…
Browse files Browse the repository at this point in the history
…ation (#218)

feat(cf-form): allow passing context information to cf-form, cf-navigation
  • Loading branch information
Jonas Metzener committed May 9, 2019
2 parents 2d7d6fe + 149e92e commit 2955dc6
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 4 deletions.
8 changes: 8 additions & 0 deletions addon/components/cf-form.js
Expand Up @@ -54,6 +54,14 @@ export default Component.extend(ComponentQueryManager, {
*/ */
overrides: null, overrides: null,


/**
* Can be used to pass "context" information from the outside through
* to custom overrides.
*
* @argument {*} overrides
*/
context: null,

didReceiveAttrs() { didReceiveAttrs() {
this._super(...arguments); this._super(...arguments);
if (this.documentId) { if (this.documentId) {
Expand Down
36 changes: 35 additions & 1 deletion addon/components/cf-navigation.js
Expand Up @@ -6,12 +6,46 @@ import { ComponentQueryManager } from "ember-apollo-client";
import { task } from "ember-concurrency"; import { task } from "ember-concurrency";
import getNavigationQuery from "ember-caluma/gql/queries/get-navigation"; import getNavigationQuery from "ember-caluma/gql/queries/get-navigation";


/**
* Component to display a nested form including navigation.
*
* ```hbs
* {{cf-navigation documentId="myDocId" section=section subSection=subSection}}
* ```
*
* @class CfFormComponent
*/
export default Component.extend(ComponentQueryManager, { export default Component.extend(ComponentQueryManager, {
layout, layout,
documentStore: service(), documentStore: service(),


/**
* The ID of the nested document to display the navigation for
* @argument {String} documentId
*/
documentId: null, documentId: null,
activeDocumentId: null,
/**
* Can be used to pass "context" information from the outside through
* to custom overrides.
*
* @argument {*} context
*/
context: null,

/**
* Form slug of currently visible section
*
* @argument {String} section
*/
section: null,

/**
* Form slug of currently visible sub-section
*
* @argument {String} subSection
*/
subSection: null,


_currentDocumentId: null, _currentDocumentId: null,


Expand Down
2 changes: 1 addition & 1 deletion addon/templates/components/cf-field.hbs
Expand Up @@ -5,7 +5,7 @@
<div class="uk-flex"> <div class="uk-flex">
<div class="uk-width-expand"> <div class="uk-width-expand">
{{#if componentOverride}} {{#if componentOverride}}
{{component componentOverride field=field disabled=disabled onSave=(perform save)}} {{component componentOverride field=field disabled=disabled context=context onSave=(perform save)}}
{{else}} {{else}}
{{cf-field/input field=field disabled=disabled onSave=(perform save)}} {{cf-field/input field=field disabled=disabled onSave=(perform save)}}
{{/if}} {{/if}}
Expand Down
2 changes: 1 addition & 1 deletion addon/templates/components/cf-form.hbs
@@ -1,3 +1,3 @@
{{#each _document.fields as |field|}} {{#each _document.fields as |field|}}
{{cf-field field=field disabled=disabled}} {{cf-field field=field disabled=disabled context=context}}
{{/each}} {{/each}}
2 changes: 1 addition & 1 deletion addon/templates/components/cf-navigation.hbs
Expand Up @@ -33,7 +33,7 @@
</div> </div>


<div class="uk-width-1-1 uk-width-2-3@m"> <div class="uk-width-1-1 uk-width-2-3@m">
{{cf-form document=displayedDocument}} {{cf-form document=displayedDocument context=context}}
</div> </div>
{{/if}} {{/if}}
</div> </div>

0 comments on commit 2955dc6

Please sign in to comment.