All files / addon/components/freestyle/bootstrap/tables table-with-pagination.js

42.86% Statements 3/7
100% Branches 0/0
28.57% Functions 2/7
42.86% Lines 3/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100                1x 1x     10x                                                                                                                                                                              
import Component from '@ember/component';
import layout from '../../../../templates/components/freestyle/bootstrap/tables/table-with-pagination';
import { BuilderForPropDefaults } from 'ember-bootstrap-controls/utils/prop-definition-tools';
import { propDefinitions } from '../../../bootstrap/tables/table-with-pagination';
import faker from 'faker';
import ArrayProxy from '@ember/array/proxy';
 
 
var createFakeModels = function() {
  return Array.from(
    { length:10 },
    ()=> (
      {
        number: faker.random.number(),
        first: faker.name.firstName(),
        last: faker.name.lastName(),
        handle: `@${faker.internet.userName()}`,
        email: faker.internet.email(),
        phone: faker.phone.phoneNumber(),
      }
    )
  );
};
 
export default Component.extend({
  layout,
  propDefinitions,
  data: Object.assign(BuilderForPropDefaults(propDefinitions), {
    value: '',
    noRowsMessage: 'No Recent Tasks',
    columns: [
      {
        headerLabel: '#',
        cellValueKey: 'number',
        columnKey: 'number',
        sortingCriteriaValue: 'number',
      },
      {
        headerLabel: 'First',
        cellValueKey: 'first',
        columnKey: 'first',
        sortingCriteriaValue: 'first',
      },
      {
        headerLabel: 'Last',
        cellValueKey: 'last',
        columnKey: 'last',
        sortingCriteriaValue: 'last',
      },
      {
        headerLabel: 'Handle',
        cellValueKey: 'handle',
        columnKey: 'handle',
        sortingCriteriaValue: 'handle',
      },
      {
        headerLabel: 'Email',
        cellValueKey: 'email',
        columnKey: 'email',
        sortingCriteriaValue: 'email',
      }
    ],
    models: ArrayProxy.create({
      content: createFakeModels(),
      meta: {
          page: {
            current_iteration_count: -24,
            iteration_count_end: 25,
            iteration_count_start: 1,
            offset: "1",
            record_count: 25,
            size: "25",
            total_pages: 2,
            total_records: 49,
        }
      }
    }),
  }),
 
  basicValue: '',
 
  actions: {
    simpleAction() {
 
    },
    clickAction(text){
      window.alert(`You clikced on item ${text}`);
    },
    sortAction(sortCriteria){
      window.alert(`The table will be sorted by ${sortCriteria}`);
    },
    onEdit(){
      window.alert(`Edit table row`);
    },
    onDelete(){
      window.alert(`Delete table row`);
    },
  },
});