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

datagridfield pattern #106

Merged
merged 16 commits into from
Mar 15, 2021
Merged

datagridfield pattern #106

merged 16 commits into from
Mar 15, 2021

Conversation

thet
Copy link
Member

@thet thet commented Mar 2, 2021

To improve the current unstable javascript situation this PR rebuilds the JS functionality within a pattern.
This provides a defined scope to operate on and should give automatic initialization within modals, mosaic and so on.

..Upgrade notice::
In this version a pattern handles all the JavaScript functionality to ensure best possible encapsulation between different instances of the datagridfield widget.
If you have customized templates, make sure you do the following:

  • Add the class pat-datagridfield to the datagridwidget-table-view nodes (files: datagridfield_input.pt, datagridfield_input_block.pt).

  • Add the following classes instead of ids to the ui buttons as shown in this map (files: datagridfieldobject_input.pt, datagridfieldobject_input_block.pt_):

    • #btn-addrow -> .dgf--row-add
    • #btn-deleterow -> .dgf--row-delete
    • #btn-moveup -> .dgf--row-moveup
    • #btn-movedown -> .dgf--row-movedown
  • Clean up upgrade profile definitions and align to Plone standards.

  • Remove non-unique id attributes from UI buttons and add classes instead.
    Let the button functionality be initialized by the pattern.

  • Remove extra parameter for datagridfield widget as it was unused and untested.

  • Use pat-datagridfield in templates.

  • Rework JavaScript as a Pattern for better initialization.

This targets Plone 5.1 and Plone 5.2, as master does.
A quick screenshot with some rows and enabled/disabled buttons. The last row have all buttons disabled as this is a auto-append row - it will automatically add another row if a input-focusout event happens in one of the auto append row fields. Here the buttons do not make any sense.
Screenshot from 2021-03-05 14-08-57

@thet thet force-pushed the thet-fixes branch 2 times, most recently from 3bd0467 to 9f98380 Compare March 3, 2021 10:52
thet added 2 commits March 3, 2021 12:09
Remove non-unique id attributes from UI buttons and add classes instead.
Let the button functionality be initialized by the pattern.

Breaking change:
In this version a pattern handles all the JavaScript functionality to ensure best possible encapsulation between different instances of the datagridfield widget.
If you have customized templates, make sure you do the following:
- Add the class ``pat-datagridfield`` to the ``datagridwidget-table-view`` nodes (files: datagridfield_input.pt, datagridfield_input_block.pt).
- Add the following classes instead of ids to the ui buttons as shown in this map (files: datagridfieldobject_input.pt, datagridfieldobject_input_block.pt_):
    - #btn-addrow -> .dgf--row-add
    - #btn-deleterow -> .dgf--row-delete
    - #btn-moveup -> .dgf--row-moveup
    - #btn-movedown -> .dgf--row-movedown
@thet thet force-pushed the thet-fixes branch 5 times, most recently from 3e02bd8 to 86c2408 Compare March 3, 2021 14:29
thet added 3 commits March 4, 2021 10:45
Change row UI elements from anchor to buttons for better semantics.
Fix Boostrap classes, remove unused attributes, add a title to buttons.
@thet thet force-pushed the thet-fixes branch 3 times, most recently from 38c85a1 to 607102b Compare March 4, 2021 11:07
@thet thet marked this pull request as ready for review March 5, 2021 12:56
@thet thet requested a review from pbauer March 5, 2021 12:56
Copy link
Member

@jensens jensens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, I would release a beta of 2.0 first and let more people use it in the wild.
For Plone 6 this would need other classes applied to the HTML, right?

CHANGES.rst Outdated Show resolved Hide resolved
Breaking change:
The JavaScript resources have changed a lot.
Please run the provided upgrade steps!

If you were customizing templates which loaded these JavaScript resources
or customized the JavaScript functionality itself, take special care.
The bundle is loaded only for logged-in users.
@thet
Copy link
Member Author

thet commented Mar 15, 2021

@jensens tnx for the review! will merge.

@thet thet merged commit a6b26e3 into master Mar 15, 2021
@thet thet deleted the thet-fixes branch March 15, 2021 11:31
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

Successfully merging this pull request may close these issues.

2 participants