jeudi 22 mars 2018

Filtering using dropdown based on the uniq event name

i would like to add a filtering for my records of my table based on the value that I selected on my dropdown.Btw, I am using power-select. This is how my template looks like

  <table>
    <tr>
      <th>
        Event Name
        
          
        
      </th>
    </tr>

    <tr>
      
        <td></td>
        <td></td>
      
    </tr>
  </table>

And on my route.js this is how it looks like

 model() {
  const { date } = this.paramsFor('dashboard.route-name');
  return this.queryModel(date);
 },

 setupController(controller) {
   this._super(...arguments);

   const { date } = this.paramsFor('dashboard.route-name');
   controller.set('selectedDate', date);
 },

 queryModel(date) {
   date = date || moment().format('YYYY-MM-DD');

   return this.store.query('modelName', {
    filter: {
      'created-at:between': `${date} 00:00:00,${date} 23:59:59`
    },
      sort:    'updated-at'
   });
  }

and on my controller.js I have the following below

 import Ember from 'ember';

 export default Ember.Controller.extend({
   modelNames:    Ember.computed.alias('model'),
   eventNames:    Ember.computed.mapBy('modelNames', 'eventName'),
   uniqEventName: Ember.computed.uniq('eventNames'),

   actions: {
    selectDate(date) {
      this.transitionToRoute({ queryParams: { date }});
    },

    selectEventName(eventName) {
      console.log(eventName);
    }
  }
 });

My question is How would I filter my records based on the eventName that I selected on my dropdown? Any suggestions and approach is much appreciated, hoping someone could help as I am still noob on ember. Thank you

This is my power-select

 
   
 




Aucun commentaire:

Enregistrer un commentaire