Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Entity index table structure does not change when navigating between different entities #11

Closed
desertjinn opened this issue Jan 16, 2015 · 11 comments
Assignees

Comments

@desertjinn
Copy link

I have a few entities defined and each has its own individual structure for its index table.
This is an entity named 'sports' -
screenshot from 2015-01-16 20 09 32

This is another entity named 'events' -
screenshot from 2015-01-16 20 10 07

If I select 'sports' first and then switch to 'events' the index table ends up looking like this -
screenshot from 2015-01-16 20 12 27

No console error messages are shown.
screenshot from 2015-01-16 20 15 18

This only happens when navigating between entities.
Any idea why?

@desertjinn desertjinn changed the title Entity index table structure does not change when selecting different entities Entity index table structure does not change when navigating between different entities Jan 16, 2015
@nicolaslopezj
Copy link
Member

Maybe it's an issue with autopublish. Can you try updating all dependencies and removing autopublish before dig in into this problem

@desertjinn
Copy link
Author

I updated the dependencies and removed autopublish but index table structure is still behaving the same. The table structure of the first entity selected seems to persist while navigating between other entities.

@nicolaslopezj
Copy link
Member

Ok. I will fix this tonight

@nicolaslopezj
Copy link
Member

Sorry, aldeed:tabular is too buggy. I'm thinking in changing it.

@desertjinn
Copy link
Author

Hope you find something suitable soon, your package is truly an awesome addition to meteor.

nicolaslopezj added a commit that referenced this issue Jan 18, 2015
@nicolaslopezj
Copy link
Member

Didn't fix aldeed:tabular but I did a trick to make it work.
PD: aldeed:tabular it's not entirely buggy, but in the tracker topic yes it is

@desertjinn
Copy link
Author

Updated the package, the edit/delete buttons are gone from the table but I am able to edit and delete by selecting the table element 👍 . Nice fix.

New issue :
I had a select option specified using the format

{value:'labelvalue',label:'labelname'} 

and this worked before the update. After updating, no values are available for the select box.
screenshot from 2015-01-20 20 01 49

nicolaslopezj added a commit that referenced this issue Jan 20, 2015
@nicolaslopezj
Copy link
Member

Sorry, I was using the submit button the wrong way.

@desertjinn
Copy link
Author

It works!! 👍

P.S - I have a doubt.
When setting up select box, supplying values in the format {value:'labelvalue',label:'labelname'}, everything works perfectly. 👍

But I am setting the select box options by calling function getVenues() and returning all the values in the prescribed format. This just shows an empty select box now. This used to work fine before the update to 0.4.6.

function getVenues() {
    var venues = orion.entities.venues.collection.find().fetch();
    var venuesmin = [];
    _.each(venues,function(item){
        venuesmin.push({value:item._id,label:""+item.title+""});
    });
    if(venuesmin)
        return venuesmin;
    return [];
}

I configured the select box like this -

orion.addEntity('sports', {
    title: {
        type: String,
        label: "Sport Title",
    },
    venue: {
        type: String,
        label: "Venue",
        optional: true,
        autoform: {
            type: 'select',
            options :getVenues(),
        }
    },

},  {
    icon: 'cubes',
    sidebarName: 'Sports',
    pluralName: 'Sports',
    singularName: 'Sport',

    tableColumns: [
        { data:'title', title: 'Sport' },
        { 
            data:'venue', 
            title: 'Venue', 
            render: function(val, type, doc) {
                var venuename = orion.entities.venues.collection.findOne({_id:doc.venue},{fields:{title:1}});
                if(venuename) return venuename.title;               
            }, 
        },
    ]
});

Specifically retrieving the venues entity collection gives me an empty array.

var venues = orion.entities.venues.collection.find().fetch();
console.log(venues)  //=> Array[0]

Any ideas as to what I'm messing up?

@nicolaslopezj
Copy link
Member

It's because you are not subscribed.
Add this line of code in the client

orion.admin.addAdminSubscription(orion.subs.subscribe('entity', 'venues'));

This will subscribe to that entity on every route of the admin

@desertjinn
Copy link
Author

Yes, that worked. I also had to tweak calling the function to populate options like this

autoform: {
            type: 'select',
            options : function(){
                var venues = orion.entities.venues.collection.find().fetch();
                var venuesmin = [];
                _.each(venues,function(item){
                    venuesmin.push({value:item._id,label:item.title});
                });

                if(venuesmin)
                    return venuesmin;
                return [];
            },
        }

prior to v0.4.6 I got the values by calling a function defined outside the entity.

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

No branches or pull requests

2 participants