Comments (6)
This could be because there is no code for this 😆
https://github.com/sachinbhutani/flow-db-admin/search?utf8=%E2%9C%93&q=options
Is this supposed to be automatically handled by autoform?
from flow-db-admin.
That's the idea!
Updated to autoform version 5.7.1 - might help.
Please let me know.
from flow-db-admin.
No dice -- here's how it shows:
I'm assuming "Phase ID" should show as a select dropdown menu with the options of id:name of phases?
from flow-db-admin.
Ok, so I just submitted a PR to fix the documentation. The autoform.options
object should be a function.... that returns something ;) The original yogiben:admin
documentation was missing this.
Onto the second issue. If I setup my new phase_id
object like this:
phase_id: {
type: String,
regEx: SimpleSchema.RegEx.Id,
label: "Phase ID",
index: 1,
autoform: {
options: function() {
return _.map([
{_id: 1, name: "Phase 1"},
{_id: 2, name: "Phase 2"}
], function(phase) {
return {
label: phase.name,
value: phase._id
}
});
}
}
}
I now get a select dropdown with options. However, if I change it to the cursor fetch:
phase_id: {
type: String,
regEx: SimpleSchema.RegEx.Id,
label: "Phase ID",
index: 1,
autoform: {
options: function() {
return _.map(phase.find().fetch(), function(phase) {
return {
label: phase.name,
value: phase._id
}
});
}
}
}
I get a select menu, but without any options. If I turn on autopublish
, I get the options with phase names/vals (yay, at least that works now 👍 )
I would assume adding autoform options would auto-subscribe to these requests, but this doesn't happen, so we have three choices: autosubscribe to these requests, make another object where we can define publications to subscribe to, or have a manual subscribe process. I think option 1 or 2 would be better, as it would make things a lot easier for the end-user.
from flow-db-admin.
Here is the suggested way to do this with yogiben:admin
: https://github.com/yogiben/meteor-admin/#custom-route-options - This was ported to Flow Router, but I'm assuming this feature wasn't setup.
This would make AdminConfig.collections.lesson
use something like:
lesson: {
tableColumns: [
{ label: 'Name', name: 'name' },
{ label: 'Description', name: 'description' },
{ label: 'Rank', name: 'rank' },
{ label: 'Phase ID', name: 'phase_id' }
],
routes: {
new: {
waitOn: function () { return Meteor.subscribe('lesson') && Meteor.subscribe('phase'); }
},
view: {
waitOn: function () { return Meteor.subscribe('lesson') && Meteor.subscribe('phase'); }
},
edit: {
waitOn: function () { return Meteor.subscribe('lesson') && Meteor.subscribe('phase'); }
}
}
}
However, this doesn't follow DRY principle, and waitOn is iron router specific. Since the collection is automatically subscribed to, something like this would be more ideal:
lesson: {
tableColumns: [
{ label: 'Name', name: 'name' },
{ label: 'Description', name: 'description' },
{ label: 'Rank', name: 'rank' },
{ label: 'Phase ID', name: 'phase_id' }
],
depSubs: [
{ name: 'phase', params: []}
]
}
The idea being depSubs
are dependent subscriptions that would automatically be subscribed to, and depSubs
> params
will define the optional/additional parameters passed into the sub, in the situation where you need to filter the additional subscription data.
In the interim, something like this would also work and is simpler:
lesson: {
tableColumns: [
{ label: 'Name', name: 'name' },
{ label: 'Description', name: 'description' },
{ label: 'Rank', name: 'rank' },
{ label: 'Phase ID', name: 'phase_id' }
],
depSubs: ['phase']
}
from flow-db-admin.
This is an old issue, but for future reference:
I got this to work by adding a 'extraSubscriptions' option to the column definition and than add:
Template.AdminDashboard.rendered = function() {
var template = this;
var collectionName = FlowRouter.getParam('collectionName');
var collectionConfig = AdminConfig.collections[collectionName];
if( 'extraSubscriptions' in collectionConfig) {
template.autorun((computation) => {
collectionConfig.extraSubscriptions.forEach((sub) => {
template.subscribe(sub);
});
});
}
};
from flow-db-admin.
Related Issues (20)
- Question about CSS frameworks HOT 1
- Populate Users 'edit' with existing data from collection? HOT 2
- Custom edit template not working HOT 2
- userSchema have compile error. HOT 1
- View tables not appearing, Meteor 1.3+ HOT 1
- jquery.dataTables drop an error
- Support for Meteor 1.3 HOT 3
- Summernote editor does not works on edit page.
- Router is still in use - cannot redirect if not admin
- how to filter collections
- callback of 'You need to be an admin to view this page'
- extraFields expamle HOT 1
- addSidebarItem: "-->"
- collection2-core, autoform6 and simpl-schema support HOT 2
- Error: No such template: AdminLTE
- Only use admin for users
- flow-db-admin version 1.2
- simpl-schema not working with autoform
- flow-db-admin wont install HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flow-db-admin.