-
Notifications
You must be signed in to change notification settings - Fork 20
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
[WIP] Move specialist document pages #4600
Draft
leenagupte
wants to merge
19
commits into
main
Choose a base branch
from
move-specialist-document-pages
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The view will updated to match the new data structure in a later commit Audit trail: specialist_document.html.erb: https://github.com/alphagov/government-frontend/blob/a7e99cf556dbc5d8b8fab5a317157136cadeb8a0/app/views/content_items/specialist_document.html.erb
Copies the component as-is from government-frontend. The test has been updated to use RSpec. Audit trail: css: https://github.com/alphagov/government-frontend/blob/a7e99cf556dbc5d8b8fab5a317157136cadeb8a0/app/assets/stylesheets/components/_back-to-top.scss docs: https://github.com/alphagov/government-frontend/blob/a7e99cf556dbc5d8b8fab5a317157136cadeb8a0/app/views/components/docs/back_to_top.yml test: https://github.com/alphagov/government-frontend/blob/a7e99cf556dbc5d8b8fab5a317157136cadeb8a0/test/components/back_to_top_test.rb view: https://github.com/alphagov/government-frontend/blob/a7e99cf556dbc5d8b8fab5a317157136cadeb8a0/app/views/components/_back_to_top.html.erb dartsass.rb:https://github.com/alphagov/government-frontend/blob/a7e99cf556dbc5d8b8fab5a317157136cadeb8a0/config/initializers/dartsass.rb
Copies the component as-is from government-frontend. The test has been updated to use RSpec. Audit trail: css: https://github.com/alphagov/government-frontend/blob/a7e99cf556dbc5d8b8fab5a317157136cadeb8a0/app/assets/stylesheets/components/_contents-list-with-body.scss docs: https://github.com/alphagov/government-frontend/blob/a7e99cf556dbc5d8b8fab5a317157136cadeb8a0/app/views/components/docs/contents_list_with_body.yml test: https://github.com/alphagov/government-frontend/blob/a7e99cf556dbc5d8b8fab5a317157136cadeb8a0/test/components/contents_list_with_body_test.rb view: https://github.com/alphagov/government-frontend/blob/a7e99cf556dbc5d8b8fab5a317157136cadeb8a0/app/views/components/_contents_list_with_body.html.erb dartsass.rb:https://github.com/alphagov/government-frontend/blob/a7e99cf556dbc5d8b8fab5a317157136cadeb8a0/config/initializers/dartsass.rb
Changes the view to call the title component directly, rather than via a presenter method.
The list of headers is used to generate the contents list if there are more than 3 headers in the list. Confusingly this list of headers is generated in multiple places. [specialist-publisher] uses the govspeak gem to parse the body content and look for `h2` and `h3` tags and generate the `headers` list in `details` from them. If there are no `h2` or `h3` tags the entire `headers` element is removed from `details. government-frontend deals with `headers` in two different ways. It uses the `headers` element in details to [create the contents list], but then somewhat replicates the code from the govspeak gem by [parsing the `h2` tags] in the body content to determine whether or not so show the contents list. Those it's not being used to render the contents list in government-frontend the `headers` element does have a `level` attribute that indicates whether the header is a `h2` or `h3`. Therefore it should not be possible to greatly simplify the code from its current form in government-frontend. The first step is to just extract the headers list in the SpecialistPublisher model. The code to determine whether or not to display the contents list will be added to a presenter in a later commit. An example from content schemas is being used to initialise the SpecialistDocument model object, however the ["details"]["headers"] have been copied from the example into the test as unlike other model tests the values in the array are being modified and the test is easier to follow if you can see exactly what's changed. Audit trail: specialist_document_presenter: https://github.com/alphagov/government-frontend/blob/c6eead39b29192e692c802c9b5e8bc234e16692c/app/presenters/specialist_document_presenter.rb#L86-L100 [specialist-publisher](https://github.com/alphagov/specialist-publisher/blob/efadf3c4df33d045c0067e095f958d4b12638f29/app/presenters/document_presenter.rb#L50) [create the contents list]: https://github.com/alphagov/government-frontend/blob/c6eead39b29192e692c802c9b5e8bc234e16692c/app/presenters/specialist_document_presenter.rb#L86-L100 [parsing the `h2` tags]: https://github.com/alphagov/government-frontend/blob/main/app/presenters/content_item/contents_list.rb#L43
This adds a `show_contents_list?` method. The method needs to know if there are any level two headers. Rather than parsing the html in the body attribute, the `level` is just being preserved in the `headers` list in the model. There is a lot of code in the original government-frontend code relating to images, and the character count and the number of table rows. This seems to be more related to document collections, rather specialist documents, so for now it has been omitted and rather than creating a shared presenter, a specialist specific one has been created to minimise the code. Audit trail: contents_list_presenter.rb: https://github.com/alphagov/government-frontend/blob/main/app/presenters/content_item/contents_list.rb#L21
This updates the view to use the new `show_contents_list?` method from SpecialistDocumentPresenter.
leenagupte
force-pushed
the
move-specialist-document-pages
branch
from
January 17, 2025 17:29
b259d63
to
35c7372
Compare
leenagupte
force-pushed
the
move-specialist-document-pages
branch
from
January 17, 2025 17:31
35c7372
to
6f7fd4c
Compare
This updates the view to use the new `show_finder_link?` method from SpecialistDocumentPresenter.
leenagupte
force-pushed
the
move-specialist-document-pages
branch
from
January 17, 2025 17:43
6f7fd4c
to
66bf67d
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What
Why
Trello card
How
Screenshots?