Sha256: 04be6bbce3c71eb5c564f2d1f4e04d9f666a1bff46c64331cc7c2b91c24aba89

Contents?: true

Size: 830 Bytes

Versions: 4

Compression:

Stored size: 830 Bytes

Contents

import { queryStringToParams, hasTurbolinks, turbolinksVisit, toQueryString } from './utils';

class PerPage {
  constructor(element) {
    this.element = element;
  }

  update() {
    const params = queryStringToParams()
      .filter(({name}) => name != 'per_page' || name != 'page')

    params.push({ name: 'per_page', value: this.element.value });

    if (hasTurbolinks()) {
      turbolinksVisit(params);
    } else {
      window.location.search = toQueryString(params);
    }
  }

  static _jQueryInterface(config) {
    return this.each(function () {
      const $this = $(this)
      let data = $this.data('perPage')

      if (!data) {
        data = new PerPage(this)
        $this.data('perPage', data)
      }

      if (config === 'update') {
        data[config]()
      }
    })
  }
};

export default PerPage;

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
activeadmin-2.7.0 app/javascript/active_admin/lib/per-page.js
activeadmin-2.6.1 app/javascript/active_admin/lib/per-page.js
activeadmin-2.6.0 app/javascript/active_admin/lib/per-page.js
activeadmin-2.5.0 app/javascript/active_admin/lib/per-page.js