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 next/prev/up buttons to the resource panel #15464

Open
wants to merge 5 commits into
base: 3.x
Choose a base branch
from

Conversation

wax100
Copy link
Contributor

@wax100 wax100 commented Mar 5, 2021

What does it do?

Add buttons next \ prev \ up to resources

Why is it needed?

Enhancement #12

Related issue(s)/PR(s)

Enhancement #12 modxorg/DocsApp#12

@wax100 wax100 requested review from Mark-H and opengeek as code owners March 5, 2021 11:28
@cla-bot cla-bot bot added the cla-signed CLA confirmed for contributors to this PR. label Mar 5, 2021
@Mark-H
Copy link
Collaborator

Mark-H commented Mar 5, 2021

That issue was about adding prev/next links to the documentation, not to MODX 😆

This looks cool as well though!

@wax100
Copy link
Contributor Author

wax100 commented Mar 5, 2021

That issue was about adding prev/next links to the documentation, not to MODX 😆

this is feature, not bug =) Sorry, don't know how to work with Docs

core/src/Revolution/modResource.php Outdated Show resolved Hide resolved
core/src/Revolution/modResource.php Outdated Show resolved Hide resolved
core/src/Revolution/modResource.php Outdated Show resolved Hide resolved
core/src/Revolution/modResource.php Outdated Show resolved Hide resolved
@Mark-H Mark-H changed the title Enhancement #12 https://github.com/modxorg/DocsApp/issues/12 Add next/prev/up buttons to the resource panel Mar 8, 2021
{
$arr = [];

$q = $this->xpdo->newQuery(modResource::class, ['parent' => $this->parent]);
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure I like this approach. On large sites, this basically means that everytime you open resource to edit you'll fetch all resources under the same parent, which could be hundreds or even thousands of records in some cases, just to get 2 specific IDs.

Wouldn't be better to query directly for the resource under and above the current one?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was idea for modx docs, not for modx CMS) my mistake

Copy link
Collaborator

Choose a reason for hiding this comment

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

Here's one way to get the prev/next without having to get all resources: add a where that matches the sortby.

For the next:

$qNext->where([
     'id:!=' => $this->get('id'),
     'AND:menuindex:<=' => $this->get('menuindex'),
]);
$qNext->limit(1);
$qNext->sortby('menuindex', 'ASC');

For the previous:

$qPrevious->where([
     'id:!=' => $this->get('id'),
     'AND:menuindex:>=' => $this->get('menuindex'),
]);
$qPrevious->limit(1);
$qPrevious->sortby('menuindex', 'ASC');

The "equals or larger/smaller" makes sure that items with the same menuindex still appear.

It means two queries, but will be much more optimized than loading all siblings, especially on large sites.

Copy link
Collaborator

@Ruslan-Aleev Ruslan-Aleev left a comment

Choose a reason for hiding this comment

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

An interesting option, convenient for a news list, for example :)

res_nav

@Ruslan-Aleev Ruslan-Aleev added pr/review-needed Pull request requires review and testing. type-frontend Issues related to UI/UX issues, mostly about styles and frontend implementations on JavaScript. labels Sep 22, 2021
@Mark-H Mark-H added this to the v3.1.0 milestone Jan 19, 2022
Copy link
Collaborator

@Mark-H Mark-H left a comment

Choose a reason for hiding this comment

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

Needs to use more optimized queries.

@Mark-H
Copy link
Collaborator

Mark-H commented Jan 30, 2023

Even if the initial request wasn't meant for the core, this could be a nifty feature to add to 3.1.

Maybe there's something to be said for optimising the UI a bit more, to make it take up less space in an already busy toolbar? Perhaps a buttongroup instead of multiple buttons? Not, sure, just ideas.

@Mark-H Mark-H added blocked Active participation around the pull request or issue required. Consensus is not reached. and removed pr/review-needed Pull request requires review and testing. labels Jan 30, 2023
@smg6511
Copy link
Collaborator

smg6511 commented Sep 19, 2023

Even if just the keyboard actions were implemented and there were no buttons added this would be a handy feature. That said, the suggestion of a button group would make sense to keep the UI as simple as possible in this area.

@wax100 - Would you like someone else to pick up where you left off on this PR?

@theboxer
Copy link
Member

theboxer commented Nov 7, 2024

Is moving to the next/prev resource really something that's used that much on all resources, that it deserves the spot in the already packed action bar?

I can see this useful in some specific scenarios for resources under specific parent, where it may be handy to quickly move to the next/prev one. But in general space, I don't think this is needed.

@opengeek opengeek modified the milestones: v3.1.0, v3.1.1 Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked Active participation around the pull request or issue required. Consensus is not reached. cla-signed CLA confirmed for contributors to this PR. type-frontend Issues related to UI/UX issues, mostly about styles and frontend implementations on JavaScript.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants