npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

trk_datatables

v1.1.2

Published

Javascript package that works nicely with trk_datatables gem

Downloads

989

Readme

Trk Datatables

This is javascript package that depends on datatables and works with trk_datatables gem

Here is example demo Rails application https://github.com/trkin/trk_datatables_demo

This package is using following npm packages:

  • datarangepicker https://github.com/dangrossman/daterangepicker
  • multiple-select https://github.com/wenzhixin/multiple-select
  • tristate https://github.com/vanderlee/tristate

Installation on Ruby on Rails with webpack

Find on https://github.com/trkin/trk_datatables#installation

Somehow it needs provided jquery plugin even it does not load another instance of jquery (note that when you use yarn link trk_datatables it loads two jqueries so do not assume that yarn link is the same as node_modules).

config/webpack/environment.js
const { environment } = require('@rails/webpacker')
const webpack = require('webpack');
environment.plugins.append('Provide', new webpack.ProvidePlugin({
  $: 'jquery',
  jQuery: 'jquery',
  Popper: ['popper.js', 'default']
}));

module.exports = environment

Installation with script tag

Look for example test/support/server_side.html and run yarn build to generate dist/index.js.

<!-- test/support/server_side.html -->
    <script type="text/javascript" src="./../../dist/index.js"></script>
    <table data-datatable='true' data-datatable-ajax-url='http://localhost:3004/clubs/search.json' id='myTable'>
    </table>
    <script>
      trkDatatables(window, $).initialise()
    </script>

Options

You can search for passedOptions to see which parameters you can change:

  • language
  • dateRangePickerDateFormat and dateRangePickerDateTimeFormat

Development

To run test you can

# run all test files
yarn test

# run single
node node_modules/.bin/jest --runInBand test/initialise.test.js

You can open sample with

yarn start
# open examples in dist
gnome-open http://localhost:8081/dist/client_side.html
gnome-open http://localhost:8081/dist/server_side.html

To test on a project locally use file: protocol since yarn link gives error that

Module not found: Error: Can't resolve 'jquery' in ...

When you update the package, to trigger recompile you need to run on rails project

yarn upgrade trk_datatables
# edit some js file to trigger webpack

Here is a link usage just for reference

# in this folder (trk_datatables package folder)
yarn link

# to see links
ls -la ~/.config/yarn/link

# in usage folder (rails folder)
rm -rf node_modules/trk_datatables
yarn link trk_datatables
# this will create link node_modules/trk_datatables ->
# ../../../.config/yarn/link/trk_datatables which points to
# ~/javascript/trk_datatables

# when you are done, you should use npm version, not local
yarn unlink trk_datatables
yarn add trk_datatables

Also to debug on Rails app, you can put debugger here in src/index.js and change (simply add new line) app/javascript/packs/application.js to triger webpack rebuild.

For icons we used http://fontello.com/ npm install fontello-cli -g and open a page:

fontello-cli --config fontello/config.json open

You can download package and extract to /fontello or you can download config.json and copy and install (in this case it will not update demo.html)

cp ~/Downloads/config.json fontello/
fontello-cli --config fontello/config.json install

To see local previews you can also

gnome-open fontello/demo.html

Deploy

Release new version by updating version in package.json and push

npm publish