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

Add item at the top if top button is clicked in list field #2055

Merged
merged 3 commits into from
Feb 7, 2021

Conversation

Karmalakas
Copy link
Contributor

@Karmalakas Karmalakas commented Feb 3, 2021

Pretty much title says it all. IMO it makes much more sense, that top button would add item at the top, because if list is long enough, you are not even seeing if something happens when item is added at the bottom. Created this PR because of the question asked in forum. Also created same change PR for Flex Objects plugin

So the solution would be either like this PR suggests, or button actions should be configurable via Admin config somewhere.

Pretty much title says it all. IMO it makes much more sense, that top button would add item at the top, because if list is long enough, you are not even seeing if something happens when item is added at the bottom. Created this PR because of [the question asked in forum](https://discourse.getgrav.org/t/blueprint-type-list-new-data-on-top-of-array/15254).

So the solution would be either like this PR suggests, or button actions should be configurable via Admin config somewhere.
@w00fz
Copy link
Member

w00fz commented Feb 3, 2021

This is a bit of an impactful change to just merge in as is. The expected behavior would change and although I totally see your point I also think it’s a matter of preference and quite definitely contextual. Sometimes I might want it added at the top, sometimes at the bottom.

I think a better solution is to introduce a placement option so that via blueprint, one can decide if for a particular list the new entry should be added at the top or at the bottom.

Something like data-action-add="{{ field.placement|default('bottom') }}" with bottom as default to ensure backward compatibility but now customizable from the blueprint to allow too.

Can you make this change on both PRs? Also I didn’t test this so make sure you do.

// ref trilbymedia/grav-plugin-flex-objects#105

Add field `palecement` property check.

If `top` or `bottom`, both buttons add item to top or bottom.
If `position`, item is added depending on a clicked button position -
  if top button is clicked, item added to top and if bottom button - item added to bottom.

Defaults to bottom
@Karmalakas
Copy link
Contributor Author

Added field placement property check.

If placement value is top or bottom, both buttons add item to top or bottom respectively.
If placement value is position, item is added depending on a clicked button position - if top button is clicked, item added to top and if bottom button, item added to bottom.

Defaults to bottom

@Karmalakas
Copy link
Contributor Author

Also updated Flex Objects plugin PR

@Karmalakas
Copy link
Contributor Author

Created PR for docs

Copy link
Member

@w00fz w00fz left a comment

Choose a reason for hiding this comment

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

I like this thanks, I approve.

@w00fz w00fz merged commit a0b0fa0 into getgrav:develop Feb 7, 2021
w00fz added a commit that referenced this pull request Feb 7, 2021
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