mistic100 / mistic100/jQuery-QueryBuilder

Dynamic plugin. Datepicker and Duration picker value is not coming correctly

Open
#879 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
1.7k
Forks
544
PR merge metrics
No merged PRs in 30d

Description

Hi

I am aware that dynamic plugin based on operator is not supported. So, tried to find a solution. Here is the jsfiddle.

https://jsfiddle.net/fLqc547j/1/

What is working:

  1. It is dynamically enabling the plugins based on operator.
  2. Value is coming correctly if you don't change the operator. See bug 1 and 2 of this approach for more detail.

What is not working and help needed :
Bug1:

  1. Step1: Select date. Don't change the operator. Let it be equal. Select the date. Get rules will give correct selected value. With out changing the operator (mean keep it as equal), keep changing date and check get rules. Will work as expected (value will be latest date selected).
  2. Step2: Change the operator to not equal. Change the date. Now get rules will give old date and not latest date. Custom data.latestValue will have latest selected date. This will continue till you change operator. When you change the operator, that date will start come as value, till you again change the operator. data.latestValue will continue to have correct latest data.
  3. Step3: Select any one of the last 4 operators like before, after... Plugin will change to time duration picker. Set the duration and check get rules. Get rules will have value as old text (like what is mentioned as issue in step2), where as data.latestValue will have latest duration in seconds, which is expected.

Expected behavior: Latest value shall come. Note: Solution shall work for test case where you change operator like datepicker ==> durationpicker ==> datepicker

Bug 2:

When timedurationpicker is the active plugin, get rules shall return value of data.latestValue and for date standard text value. Tried to achieve it using valueGetter, but looks like valueGetter is called only when operator is changed and not during getRules. Unable to find any event for rule value changed.

Note:
First I was trying it using Zebra datepicker and had similar issue.

https://jsfiddle.net/fLqc547j/

So tried using bootstrap-datepicker, which is the link mentioned in the beginning of this message https://jsfiddle.net/fLqc547j/1/

Thanks

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked JSFiddle examples and trace how getRules, valueGetter, and data.latestValue behave when switching between datepicker and duration picker operators. The expected result is for getRules to return the latest value across datepicker-to-durationpicker-to-datepicker transitions, including the duration picker’s latest value.

Written by the indexing model from the issue text.

Assessment

Tech stack
bootstrap, javascript, jquery
Domain
frontend
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
15/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.