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

Prev, Next and Create buttons on detail GridField forms #436

Closed
16 tasks done
chillu opened this issue Feb 15, 2018 · 26 comments
Closed
16 tasks done

Prev, Next and Create buttons on detail GridField forms #436

chillu opened this issue Feb 15, 2018 · 26 comments

Comments

@chillu
Copy link
Member

chillu commented Feb 15, 2018

Overview

It's often cumbersome to move through a list of items by clicking into the detail view, hitting the "back" button, and clicking into the next item. The betterbuttons module solved this for 3.x, and there's a good case for making it a core feature. @sachajudd and @clarkepaul have designed a solution as part of a Save and add new button design.

Acceptance Criteria

  • I can add a new record from a record detail form
  • If choosing to add a new record or navigate to the previous/next record on a record detail form with unsaved edits, I get a prompt and stay on the same screen until I've saved the record explicitly.
  • I can navigate to the previous and next records of a list when viewing a record detail form
  • If there is no more previous or next records, the button is disabled
  • The new buttons don't compromise more important buttons on small screens
  • The functionality works in ModelAdmin and any other GridField
  • Sorting and filtering is retained
  • Does not double up when betterbuttons is installed (might need a patch to that module?) (UPDATE: BetterButtons already takes priority and overrides all the actions)
  • Should work in default configurations, but can be opted out of
  • Behat Tests written
  • Update documentation
  • Excludes choosing the type of record to create (that's a thing in some GridField modules)
  • Excludes any "save and close" or "publish and close" logic

Designs

Styleguide

Notes

Pull Requests

@bummzack
Copy link

Yes, this would be an awesome addition!

Please also consider the case where different classes can be added to a relation. Meaning that the "add new" button should turn into a flyout where you can select the class to create (the gridfield equivalent of this is the GridFieldAddNewMultiClass component added via gridfieldextensions). The elemental-module makes use of this to add the different block-types to a page.

It doesn't have to be in core, but it should be possible to add this via extensions or similar.

@Rhym
Copy link

Rhym commented Mar 16, 2018

4.1.1 here we gooooo!

@chillu
Copy link
Member Author

chillu commented Apr 15, 2018

Separated out one AC to #486

@chillu
Copy link
Member Author

chillu commented Jul 31, 2018

@sachajudd commented on the duplicate card:

We should have a warning indicating to the user that they have unsaved changes before they navigate away. We thought the "save/publish and create new" action was better suited in the drop-down area.

I've changed the AC accordingly. So the "plus" button would only create a new record, not also save the existing one.

@patricknelson
Copy link
Contributor

Excludes any "save and close" or "publish and close" logic

So, I think this means that the extra imputed functionality necessary for maintaining Version'ed DataObject's managed in GridField instances will still reside entirely in the betterbuttons module, is this correct? That is, the special BetterButton_SaveDraft and BetterButton_Publish buttons incorporated by the module right now ("Saved" and "Save & publish") and the associated "stage" level DB persistence abstraction interfacing with the Versioned:: API.

If that's not the case, could someone point me in the direction where this will eventually live long term for SS 4+ and onward (if not in betterbuttons module or in silverstripe-admin)?

@bergice
Copy link
Contributor

bergice commented Nov 6, 2018

@patricknelson that's correct. This is only porting the Previous, Next and Add buttons on the edit form.

@unclecheese
Copy link

@patricknelson It's an MVP at this point. We need to satisfy the squeakiest wheel, and that's prev/next and add. That's most of the reason why users are installing betterbuttons. Further down the track, I see this API expanding to support additional prebaked and custom actions, and may even do so in 4.4, as this PR isn't going to make it into 4.3 anyway.

@Rhym
Copy link

Rhym commented Nov 6, 2018

@unclecheese I'll give you $5 if it goes into 4.3. rubs hands

@normann
Copy link

normann commented Feb 25, 2019

Just wondering when this bit can be released to a stable?

@chillu
Copy link
Member Author

chillu commented Feb 25, 2019

It's already in the latest 4.x stable

@Rhym
Copy link

Rhym commented Feb 25, 2019

@chillu As in the current stable release? How would we activate/view this?

@chillu
Copy link
Member Author

chillu commented Feb 25, 2019 via email

@ScopeyNZ
Copy link
Contributor

ScopeyNZ commented Feb 25, 2019

It will be released in 4.4. Not yet tagged.

@Rhym
Copy link

Rhym commented Mar 11, 2019

@ScopeyNZ Do we have a rough estimate for 4.4? this button would help a lot with a client's data entry.

@ScopeyNZ
Copy link
Contributor

4.4 should be within the next couple of months. I think there's a tentative schedule to have an RC on the week beginning 6th of May.

@Rhym
Copy link

Rhym commented Mar 24, 2019

Excellent, looking forward to this addition :)

@Rhym
Copy link

Rhym commented Jun 4, 2019

It may have taken half a decade, but it's finally here! I used the buttons today, and they made me very happy. Thanks for all your work, team! 🎉🎉🎉

@ssimo3lsuhsc
Copy link

Where do I leave a comment to say that it doesn't work the way it should? Sometimes the Next button is greyed out on a non-final record, and sometimes the Previous button is inactive on a non-first record. I should add that the affected records are ALMOST NEVER page-initial or page-final in the current page of the query.

@andreaslindahl
Copy link

I have the same problem. The buttons are often disabled, when they shouldn't be.

@ScopeyNZ
Copy link
Contributor

Please feel free to raise an issue with the problem. Preferably with some accurate steps to reproduce.

@chillu
Copy link
Member Author

chillu commented Aug 27, 2019

Note that I don't think prev/next takes filtered/ordered GridFields into account - @unclecheese you're working on persisting search parameters in the GridField URL state, do you think this might be overlapping?

@unclecheese
Copy link

My guess is that the issue here is non-deterministic sort. Make sure your dataobject has a default_sort defined, or explicitly sort the datalist you’re passing to the grid.

The fact that it happens unpredictably is a good indication that your result set isn’t predictable itself.

@ssimo3lsuhsc
Copy link

I have set a default_sort on my DataObject. The problem still occurs. It does not occur predictably with any given record, but it occurs in one of every five GridFieldDetailForm views I make.

@unclecheese
Copy link

It’s exactly one out of every five?

So the steps to reproduce are:

  • Edit record
  • Go back to grid
  • Repeat five times
  • On the fifth time, the prev/next buttons are incorrect

@ssimo3lsuhsc
Copy link

ssimo3lsuhsc commented Aug 27, 2019 via email

@ssimo3lsuhsc
Copy link

ssimo3lsuhsc commented Aug 27, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants