jQuery-QueryBuilder icon indicating copy to clipboard operation
jQuery-QueryBuilder copied to clipboard

Add support to read only state.

Open ernaniaz opened this issue 4 years ago • 4 comments

Merge request checklist

  • [ x ] I read the guidelines for contributing
  • [ x ] I created my branch from dev and I am issuing the PR to dev
  • [ x ] I didn't pushed the dist directory
  • [ x ] Unit tests are OK
  • [ x ] If it's a new feature, I added the necessary unit tests
  • [ x ] If it's a new language, I filled the __locale and __author fields

Pull request summary

This pull request add "read_only" option support to jQuery QueryBuilder core. This option could be changed with "setOptions" call. When set true, the query will be set read only with a simple overlay. It'll use CSS pointer-events. It's compatible with all browsers except "Opera Mini". If you think it will fit better as a plugin, please let me know on this request, than I'll request another push with a plugin code.

ernaniaz avatar Dec 18 '19 20:12 ernaniaz

Hello, thank you for your PR.

  • Please respect the general code-style (braces on same line)
  • you can simplify the code in "setOptions" by using toggleClass
  • I don't think it's pertinent to change the opacity of the whole builder. Instead buttons and inputs should be disabled and sort handles (from "sortable" plugin) be hidden. It is less straithforward but will be better for the UX/UI.

mistic100 avatar Dec 18 '19 20:12 mistic100

Thanks for your promptly response! I've fixed code-style and changed from CSS overlay to disable any interactive element (also, ignore drag at sortable plugin if readonly).

ernaniaz avatar Dec 18 '19 21:12 ernaniaz

Ok it's quite straithforward actually (didn't know the :input selector) !

I'll test it soon.

mistic100 avatar Dec 18 '19 21:12 mistic100

Added some fixes when read_only:

  • At template, add "disabled" tag if read_only;
  • At reset, make sure elements are read_only;
  • At init, added setTimeout() call to wait DOM refresh, otherwise will not add disable property.

ernaniaz avatar Dec 30 '19 22:12 ernaniaz