Skip to content

[RFR] Introduce new way to define dashboard datasources#509

Merged
jpetitcolas merged 10 commits intomasterfrom
new_dashboard
Jun 19, 2015
Merged

[RFR] Introduce new way to define dashboard datasources#509
jpetitcolas merged 10 commits intomasterfrom
new_dashboard

Conversation

@fzaninotto
Copy link
Copy Markdown
Member

Depends on marmelab/admin-config#14

// customize dashboard
admin.dashboard(nga.dashboard()
    .addCollection('posts', nga.collection(post)
        .title('Recent posts')
        .perPage(5) // limit the panel to the 5 latest posts
        .fields([
            nga.field('title').isDetailLink(true).map(truncate)
        ])
        .order(1)
    )
    .addCollection('comments', nga.collection(comment)
        .title('Last comments')
        .perPage(5)
        .fields([
            nga.field('id'),
            nga.field('body', 'wysiwyg')
                .label('Comment')
                .stripTags(true)
                .map(truncate),
            nga.field(null, 'template') // template fields don't need a name in dashboard view
                .label('')
                .template('<post-link entry="entry"></post-link>') // you can use custom directives, too
        ])
        .order(2)
    )
    .addCollection('tags', nga.collection(tag)
        .title('Recent tags')
        .perPage(10)
        .fields([
            nga.field('id'),
            nga.field('name'),
            nga.field('published', 'boolean').label('Is published ?')
        ])
        .order(3)
    )
);
  • add support for new nga.dashboard() syntax
  • Add compatibility layer to make old dashboardView() work
  • clean up dashboard view
  • rename PanelBuilder
  • document new syntax
  • Add example of custom dashboard
  • Fix tests

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would also add a few words about Restangular element transformers.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I refer to the extensive documentation chapter about API Mapping two lines down, I think it's enough.

@jpetitcolas
Copy link
Copy Markdown
Contributor

Fine for me, even if there may be a confusion between the collection name, which is sometimes used as a listView in the ReadQueries.getAll method for instance. We should consider (probably in another PR) to homogenize these names.

@fzaninotto
Copy link
Copy Markdown
Member Author

I'm also not very happy about the addition of a new concept, but this one goes in the right direction (separating data from presentation). listView mixes three concepts: the definition of the collection to fetch (fields, per page, etc.), the presentation (title, filters, etc), and the features (filters, actions). As it's all-or-nothing, I preferred to introduce this collection concept, which is what should be used in every ReadQuery instead of view. But that's, as you said, for another refactoring.

@fzaninotto
Copy link
Copy Markdown
Member Author

Green!

@fzaninotto fzaninotto changed the title [WIP] Introduce new way to define dashboard datasources [RFR] Introduce new way to define dashboard datasources Jun 19, 2015
@fzaninotto fzaninotto changed the title [RFR] Introduce new way to define dashboard datasources [WIP] Introduce new way to define dashboard datasources Jun 19, 2015
@fzaninotto
Copy link
Copy Markdown
Member Author

Back to WIP, I discovered a regression in dashboard panels title

@fzaninotto fzaninotto changed the title [WIP] Introduce new way to define dashboard datasources [RFR] Introduce new way to define dashboard datasources Jun 19, 2015
@fzaninotto
Copy link
Copy Markdown
Member Author

And we're back to RFR.

jpetitcolas added a commit that referenced this pull request Jun 19, 2015
[RFR] Introduce new way to define dashboard datasources
@jpetitcolas jpetitcolas merged commit e4b33a5 into master Jun 19, 2015
@jpetitcolas jpetitcolas deleted the new_dashboard branch June 19, 2015 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants