Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a calendar widget #1077

Closed
vvo opened this issue Jun 10, 2016 · 10 comments
Closed

Create a calendar widget #1077

vvo opened this issue Jun 10, 2016 · 10 comments

Comments

@vvo
Copy link
Contributor

vvo commented Jun 10, 2016

No description provided.

@vvo vvo mentioned this issue Jun 10, 2016
@vvo vvo added the new widget label Jun 10, 2016
@vvo vvo changed the title new widget: calendar Create a calendar widget Jun 10, 2016
@florentdestremau
Copy link

florentdestremau commented Jun 10, 2016

My try for now:

search.addWidget({
          getConfiguration: function () {
          },
          init: function (params) {
            var datepicker = $('.bootstrap-datepicker').datepicker({
              autoclose: true,
              format: 'dd/mm/yyyy',
              todayHighlight: true,
              weekStart: 1,
              language: 'fr',
              disableKeyboard: true,
              startDate: 'today'
            });
            var date = new Date();
            datepicker.datepicker('setDate', date);
            datepicker.on('change', function () {
              var date = $(this).datepicker('getDate');
              params.helper.removeNumericRefinement('timeStamp');
              params.helper.addNumericRefinement('timeStamp', '>=', moment(date).unix());
              params.helper.search();
            });

            params.helper.removeNumericRefinement('timeStamp');
            params.helper.addNumericRefinement('timeStamp', '>=', moment(date).unix());
          },
          render: function (params) {}
        });

It's working nicely since yesterday !

@vvo
Copy link
Contributor Author

vvo commented Jun 10, 2016

Awesome, congrats!!

@florentdestremau
Copy link

@vvo I wonder thought if there isn't a better way to handle the filter update in another way than remove + add ?

@chrisvidal
Copy link

@florentdestremau
Did you release a calendar widget ?

@florentdestremau
Copy link

hi @chrisvidal, sorry but I never had the time to finish it properly so it's just the widget above for now.

@chrisvidal
Copy link

Alright, i will try to implement it, thanks
In my scenario, we need to use 2 date pickers, i guess that would work by just adding another datepicker widget

@redox
Copy link
Contributor

redox commented Aug 22, 2016

Hey guys, did you see that Airbnb recently released https://github.com/airbnb/react-dates? Looks like the ideal calendar library to used in instantsearch.js \o/

@FredHasselot
Copy link

Hi,

It's an old issue but...

params.helper.removeNumericRefinement('timeStamp');
params.helper.addNumericRefinement('timeStamp', '>=', moment(date).unix());
params.helper.search();

i'm using something similar with the helper method on a custom date selector widget :

helper.removeNumericRefinement(attr).addNumericRefinement(attr, "=", timestamp).search();

It's fine, it filter the hits but...

How i would createURL like : my_attr=timestamp ?
i can't figure it out

🙏

@Haroenv
Copy link
Contributor

Haroenv commented Feb 9, 2023

there's a calendar widget example now https://github.com/algolia/instantsearch/tree/master/examples/js/calendar-widget which uses connectRange @FredHasselot

@FredHasselot
Copy link

Cool !
Thanks a lot.

After few tests, connectRange may do the trick, but is there a list displaying all connectors natively available ?
When refine hits, i would ideally need somehting like : refine(my_attr = timestamp)

If not, connectRange will be fine.

Thx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants