{"_id":"@activeadmin-plugins/active_admin_date_range_preset","_rev":"2-a48873199803ffd2b445e81f7a3309c2","name":"@activeadmin-plugins/active_admin_date_range_preset","dist-tags":{"latest":"0.3.1"},"versions":{"0.3.1":{"name":"@activeadmin-plugins/active_admin_date_range_preset","version":"0.3.1","keywords":["active","admin","date","range","preset"],"author":{"name":"Gena M.","email":"workgena@gmail.com"},"license":"MIT","_id":"@activeadmin-plugins/active_admin_date_range_preset@0.3.1","maintainers":[{"name":"gigorok","email":"igor.g@didww.com"},{"name":"skumring","email":"denys.m@didww.com"}],"homepage":"https://github.com/activeadmin-plugins/active_admin_date_range_preset#readme","bugs":{"url":"https://github.com/activeadmin-plugins/active_admin_date_range_preset/issues"},"dist":{"shasum":"50068bd436546e18cc2b14443025af917bae66fd","tarball":"https://registry.npmjs.org/@activeadmin-plugins/active_admin_date_range_preset/-/active_admin_date_range_preset-0.3.1.tgz","fileCount":5,"integrity":"sha512-a1eF6lKvPiUuz8WMbES9Nr20RglzqVADEG9NHOh/SVFiAkGBtYmcxZ/+0aa5TVvx/RleLLohUk4EibAylnlYiQ==","signatures":[{"sig":"MEYCIQCcN9DxwR+Kphiu0SO13FmYlYm/GrLRfwOtofQxQ0UktAIhAPMSCz87QbS1ObcMsugZxDC41Cck+ZjP7ExJwHI9GFb9","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16800,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJijfSNACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpQKA/7BJvGoa1S5X1L4VC0b3jxd14JYO3zApnDR07hbOjZSUb+vxk5\r\npsEwpGmWFtiJQdCGOz7+v9qVOS6DiNjXT1Faa3CGdavUxTcYhJubNvg5neO5\r\ntHruAEwBda4F3xxkvaSzLjKimwI756KLbJMZ37WzrDudpcrnHFrdTxcF4sNn\r\nEiQNWoXn88nGxrqlRPbYC2EWpY3+EOw4gTFG2UK+NQzBIk9w5FZriVDhC3/j\r\nfCvqBNo667Uz/hVKZDYoxBEUr+tjo2qncJvfRQhhMi3xX+SxOLhRxdsDULmV\r\n75O2qjMw/GddGIOIGEGCDOn8G4v6GQer839wroDEDXhrxkL76XdYLyp5ewX5\r\nr27s0up6+QofLovYl94OGP6Kin9Et79Ew+E+5HdmdiFnSeSXzjetsR9Lio0Z\r\n6PTUyaxri85W8b2KHhQ68Fa/T1+s2t+BETikAl3WbNCZX2y81uaRXaQMwc/W\r\nwSgysvZwHDa8IxLwvbTSb5Fo13kC28qLaYmL8QC+hM3KWJtD1jm0zulabbUa\r\nWl2z489qwZFZsix2GUwLmoSa7PX8P3W8DSa9t21XakvfNmB/LXjkcCHLQvfx\r\ng3NsnNVEke2kMtwVdI1+NriWBlPBsVh2WoZr3Kgh+OjzfgR1Oa8ug2dbWVOr\r\n6upsjtuOgbjTqaAWvQ2Ttelc2Wfc5Z/pEa8=\r\n=Of5w\r\n-----END PGP SIGNATURE-----\r\n"},"main":"src/active_admin_date_range_preset.js","style":"src/active_admin_date_range_preset.scss","gitHead":"dfcf8f65c2173b631169f371cc436c58a0c29287","private":false,"scripts":{"prepublishOnly":"rm -rf src && cp -R vendor/assets/javascripts/ src && cp -R vendor/assets/stylesheets/ src"},"_npmUser":{"name":"skumring","email":"denys.m@didww.com"},"repository":{"url":"git+https://github.com/activeadmin-plugins/active_admin_date_range_preset.git","type":"git"},"_npmVersion":"8.10.0","description":"Integrate useful fast links to set date ranges in to ActiveAdmin, for example today range, week range, month range","directories":{},"_nodeVersion":"16.13.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/active_admin_date_range_preset_0.3.1_1653470348942_0.0003203123445798539","host":"s3://npm-registry-packages"}}},"time":{"created":"2022-05-25T09:19:08.856Z","modified":"2026-04-07T16:54:43.956Z","0.3.1":"2022-05-25T09:19:09.189Z"},"bugs":{"url":"https://github.com/activeadmin-plugins/active_admin_date_range_preset/issues"},"author":{"name":"Gena M.","email":"workgena@gmail.com"},"license":"MIT","homepage":"https://github.com/activeadmin-plugins/active_admin_date_range_preset#readme","keywords":["active","admin","date","range","preset"],"repository":{"url":"git+https://github.com/activeadmin-plugins/active_admin_date_range_preset.git","type":"git"},"description":"Integrate useful fast links to set date ranges in to ActiveAdmin, for example today range, week range, month range","maintainers":[{"email":"denys.m@didww.com","name":"skumring"},{"email":"igor.g@didww.com","name":"gigorok"},{"email":"fedoronchuk@gmail.com","name":"igor_fedoronchuk"}],"readme":"[![Gem Version](https://badge.fury.io/rb/active_admin_date_range_preset.svg)](https://badge.fury.io/rb/active_admin_date_range_preset)\n[![NPM Version](https://badge.fury.io/js/@activeadmin-plugins%2Factive_admin_date_range_preset.svg)](https://badge.fury.io/js/@activeadmin-plugins%2Factive_admin_date_range_preset)\n![npm](https://img.shields.io/npm/dm/@activeadmin-plugins/active_admin_date_range_preset)\n\n# active_admin_date_range_preset\n\nPreset links for ActiveAdmin date_range inputs in sidebar filters in forms\n\nThis is how it looks like\n\n![Step 1](/screen/step_1.jpg)\n\n![Step 2](/screen/step_2.jpg)\n\n![Form 1](/screen/step_2_1.png)\n\n![Form 2](/screen/step_2_2.png)\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'active_admin_date_range_preset'\n```\n\nAnd then execute:\n\n    $ bundle install\n\nOr install it yourself as:\n\n    $ gem install active_admin_date_range_preset\n\n##### Using assets via Sprockets\n\n JS asset\n ```//= require active_admin_date_range_preset```\n\n CSS\n ```@import \"active_admin_date_range_preset\";```\n\n##### Using assets via Webpacker (or any other assets bundler) as a NPM module (Yarn package)\n\nExecute:\n\n    $ npm i @activeadmin-plugins/active_admin_date_range_preset\n\nOr\n\n    $ yarn add @activeadmin-plugins/active_admin_date_range_preset\n\nOr add manually to `package.json`:\n\n```json\n\"dependencies\": {\n  \"@activeadmin-plugins/active_admin_date_range_preset\": \"0.3.1\"\n}\n```\nand execute:\n\n    $ yarn\n\nAdd the following line into `app/assets/javascripts/active_admin.js`:\n\n```javascript\nimport '@activeadmin-plugins/active_admin_date_range_preset';\n```\n\nAdd the following line into `app/assets/stylesheets/active_admin.scss`:\n\n```css\n@import '@activeadmin-plugins/active_admin_date_range_preset';\n```\n\nYour sidebar filters should now have link \"Set Range\"\n\n## Usage\n\nin New/Edit formtastic forms:\n\n```ruby\nf.input :date_from, as: :date_time_picker, wrapper_html: { class: 'datetime_preset_pair', data: { show_time: 'true' } }\nf.input :date_to, as: :date_time_picker\n```\n\nInput can be \"as :string\" or any other type compatible with \"input type=text\"\nMain point is to set for first input-pair wrapper-class\n\n```wrapper_html: { class: 'datetime_preset_pair' }```\n\ninput name('date_from' and 'date_to') can be named whatever your need\n\nBy default inputs are filled with date(\"yyyy-mm-dd\"). If you need time add\n\n```data: { show_time: 'true' }```\n\n\n## Using with ActiveAdminDatetimepicker\n\nIf you use GEM https://github.com/activeadmin-plugins/active_admin_datetimepicker\nand want apply this plugin to filter-inputs for this gem you need:\n\nFirst apply ActiveAdminDatetimepicker to any filters your need\n\n```ruby\nfilter :time_start, as: :date_time_range\n```\n\nIn active_admin.js\n\nAdd following lines to JavaScript\n\n```javascript\n$(document).on('ready', function(){\n    $('form.filter_form div.filter_date_time_range').date_range_ext_preset();\n});\n```\n\nNow all you \"date_time_range\" inputs has button \"Set range\"\n\n\n## Custom usage\n\nYou can assign \"Set range\" almost to any input-text-pair filters/forms.\nFor example, you have complex form where input-pairs are not close to each other and not standard.\n\n```javascript\n$(document).on('ready', function(){\n  $('.any_jquery_selector').date_range_ext_preset({\n    lteq_input: '.jquery_selector_to_first_input',\n    gteq_input: '.jquery_selector_to_second_input'\n  });\n});\n```\n\".any_jquery_selector\" is pointed to place where button \"Set range\" will appear.\nSet lteq_input and gteq_input to point to inputs if they not near main selector.\n\n\n## Global and local settings\n\nThere are several settings, which can be set globally or locally.\n\nExample how to set settings for only specific inputs\n\n```javascript\n$('.any_jquery_selector').date_range_ext_preset({\n setting_name: \"setting_value\"\n});\n```\nExample how to set global settings. Write it before $(document).on('ready')\n\n```javascript\n$.fn.date_range_ext_preset.defaults.setting_name = \"setting_value\"\n```\n\nYou can set global defaults in your active_admin.js like this:\n\n```javascript\n# End date will be full-day, not next.\n# Today true : 2015-06-12 - 2015-06-12\n# Today false: 2015-06-12 - 2015-06-13\n$.fn.date_range_ext_preset.defaults.date_to_human_readable = true\n\n# Display time\n# Today: 2015-06-12 00:00:00 - 2015-06-13 00:00:00\n# Today with human_readable=true: 2015-06-12 00:00:00 - 2015-16-12 23:59:59\n$.fn.date_range_ext_preset.defaults.show_time = true\n```\n\n### date_to_human_readable\n\nvalue: true/false\n\ndefault: false\n\nThis options changes second date to include full date-time of the day, like normal human thinks about time ranges.\nToday true : 2015-06-12 - 2015-06-12\nToday false: 2015-06-12 - 2015-06-13\n\nWhen normal human say \"2015-06-12\" hi means \"2015-06-12 23:59:59\"\nBut default behavior in programming is \"2015-06-12\" = \"2015-06-12 00:00:00\"\nBe careful with this options. Cause if you change it to \"true\" you will also need to change your server-side scripts to search \"humanize-way\".\n\n### show_time\n\nvalue: true/false\n\ndefault: false\n\nIf true then will show date and time, usually it will be 00:00:00\n\n### hours_offset\n\nvalues: positive or negative integer\n\ndefault: 0\n\nTo work correctly this plugin needs to detect current date-time. And it uses UTC. But if you need your local timezone or some other time-shift, your can set this option:\n\nExample:\n```javascript\n$.fn.date_range_ext_preset.defaults.hours_offset = +3\n// or\n$.fn.date_range_ext_preset.defaults.hours_offset = -3\n```\n\n### Addition ranges\n\n```javascript\n$(document).on('ready', function(){\n\n    $('.filter_form .filter_date_range').date_range_ext_preset({\n        date_to_human_readable: true, # affects last day\n        add_range: [\n            {\n                title: 'Last 30 days',\n                // date_to_human_readable affects end-date, sow must do this:\n                start: new Date(new Date().setDate(new Date().getDate() - 29)),\n                end: new Date(new Date().setDate(new Date().getDate() + 1))\n            }\n        ]\n    });\n\n});\n```\n","readmeFilename":"README.md"}