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

Smart Fields not load on custom Related Data (with smart relationships) #82

Open
GautierT opened this issue Sep 6, 2017 · 5 comments
Open

Comments

@GautierT
Copy link

GautierT commented Sep 6, 2017

Hi,

I have created multiple smart fields for a model.
I then created a smart relationships to display this model on related data for an other model but here, i can see the columns for the smart fields but it's empty. The data are not loaded for this custom fields.

Thanks

@arnaudbesnier
Copy link
Member

arnaudbesnier commented Sep 6, 2017

Hi @GautierT,

Please add a piece of code that represents you Smart Relationship getter implementation.
Without it we cannot help you here.

@GautierT
Copy link
Author

GautierT commented Sep 6, 2017

UPDATED

router.get('/forest/users/:userId/relationships/XX', Liana.ensureAuthenticated, async (req, res, next) => {
    debug('req.body : %O', req.body)
    debug('req.params : %O', req.params)
    debug('req.query : %O', req.query)

    try {

      const results = await Letters.paginate({
        user: req.params.userId,
        mode: 'test'
      }, {
        page: parseInt(req.query.page.number),
        limit: parseInt(req.query.page.size),
        sort: req.query.sort,
        populate: [{
          path: 'XX',
          select: '-__v'
        }, {
          path: 'XX',
          select: '-__v'
        }, {
          path: 'XX'
        }]
      })

      console.log('results.total : ', results.total)

      const serialized = await new Serializer(Liana, Letters, results.docs, {}, {
        count: results.total
        // Don't seem to work
      }).perform()

      debug('serialized : %O', serialized)

      return res.send({...serialized, meta : {count : results.total}})
    }
    catch (ex) {
      return next(ex)
    }

  })

@GautierT
Copy link
Author

GautierT commented Sep 6, 2017

Sometimes (one over 10) the smart fields are fetch and visible.
I think it's a problem in Ember. But i have no error in the console.

@arnaudbesnier
Copy link
Member

The Smart Field values injection is not made here (it is not the Serializer that does that job in the current liana).

To make the magic happen we should do improve this and it would make your code work perfectly.

By the way, is it a special relationship you have between users and letters? I don't get why Forest does not detect this relationship automatically.

@GautierT
Copy link
Author

GautierT commented Sep 6, 2017

Yes, it's a special one. Users does'n't contain an array of letters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants