0.1.0 • Published 7 years ago

avalara-paginater v0.1.0

Weekly downloads
1
License
MIT
Repository
-
Last release
7 years ago

avalara-paginater

This README outlines the details of collaborating on this Ember addon.

Route for the model data of the paginater component

import Ember from 'ember';
import AvPaginaterRoute from 'avalara-paginater/mixins/av-paginater-route';

export default Ember.Route.extend(AvPaginaterRoute, {
  //in case of multiple inheritance, make sure that AvPaginaterRoute is the last one in the list of multiple super classes,
  // to ensure that the appropriate hooks from the other super classes also get called
  
  model() {
    this._super(...arguments); //very imp! for the av-paginater magic to kick in
    const { skip } = this.get('paginaterParams');
    const max = 3;

    //call backend service using orderBy and skip parameters to get the model data
    //skip,  the skip parameter used for the pagination results
    return callDataService(skip, max)
  },
});

Controller for the corresponding route of the paginater component

import Ember from 'ember';
import AvPaginaterController from 'avalara-paginater/mixins/av-paginater-controller';

export default Ember.Controller.extend(AvPaginaterController, {
});

Template for the corresponding route of the paginater component

{{av-paginater-ctrl
  numItems=model.total {{!-- the count of the total records that exist --}}
  paginaterParams=paginaterParams {{!-- pass as it is for all the magic --}}
  itemsPerPage=3 {{!-- how many records per page --}}
 }}