Coder Social home page Coder Social logo

Comments (6)

markshust avatar markshust commented on September 27, 2024

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.

sachinbhutani avatar sachinbhutani commented on September 27, 2024

That's the idea!
Updated to autoform version 5.7.1 - might help.
Please let me know.

from flow-db-admin.

markshust avatar markshust commented on September 27, 2024

No dice -- here's how it shows:

screen shot 2015-11-07 at 7 38 30 am

I'm assuming "Phase ID" should show as a select dropdown menu with the options of id:name of phases?

from flow-db-admin.

markshust avatar markshust commented on September 27, 2024

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.

markshust avatar markshust commented on September 27, 2024

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.

otech-nl avatar otech-nl commented on September 27, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.