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

Single project view #140

Merged
merged 9 commits into from
Jun 1, 2020
Merged

Single project view #140

merged 9 commits into from
Jun 1, 2020

Conversation

joshdarby
Copy link

@joshdarby joshdarby commented May 29, 2020

Changes

This pull request makes the following changes:

  • Adds a way to link to single post by using a project_id=ID query param
  • Pulls in single project data via AJAX and displays it in the single project holder partial

screencapture-currentorg-test-local-projects-2020-05-29-12_35_40

Why

For #125

Testing/Questions

Features that this PR affects:

  • Single project view
  • Functionality for linking to a specific project

Questions that need to be answered before merging:

  • Is this PR targeting the correct branch in this repository?
  • Does anything need to be sanitized better?
  • Any safety check conditionals missing?
  • Is there a better way to do any of this?
  • When do we get to style this?
  • What issue pertains to the mobile version?

Steps to test this PR:

  1. Create a project with all possible meta fields filled out
  2. View the project on the frontend and make sure everything displays without issue
  3. Make sure the unique project link works and isn't broken

@joshdarby joshdarby added this to the INOV-001 milestone May 29, 2020
@joshdarby joshdarby requested a review from benlk May 29, 2020 16:39
@joshdarby joshdarby self-assigned this May 29, 2020
Copy link
Collaborator

@benlk benlk left a comment

Choose a reason for hiding this comment

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

There's a duplication of divs when loading a post via AJAX

</h2>

<?php
// we may need to redo these links as search query params instead
$status = get_the_terms( get_the_ID(), 'project-status' );
$categories = get_the_terms( get_the_ID(), 'project-category' );
// @todo this throws errors when no terms are found for this type of post
if ( is_array( $status) && is_array( $status ) ) {
if ( is_array( $status) && is_array( $categories ) ) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks for the catch. 👍

$(".projects-single-holder").html("Loading project...");

// actually load the single project
$(".projects-single-holder").load(ajax_object.ajax_url+"?action=load_more_post&post_id="+post_id);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Consider https://current.test/ltw-test-page/ and the per-project page https://current.test/ltw-test-page/?project_id=3251741:

On page load, https://current.test/ltw-test-page/ displays in the single-project area the final post from the queue, which is the last item in the post list.

The DOM looks like this:

<div class="projects-single-holder">
	<h1 class="projects-single-title">Youth Reporting Institute</h1>
	....
</div>

Styles on .projects-single-holder give the project a single black outline.

Clicking on the last item in the list loads the post:

<div class="projects-single-holder">
	<div class="projects-single-holder">
		<h1 class="projects-single-title">Youth Reporting Institute</h1>
		....
	</div>
</div>

The post now has a double black outline.

Loading the project-specific URL https://current.test/ltw-test-page/?project_id=3251741 means that that project is, upon page load, queried for by JS and then loaded by JS:

<div class="projects-single-holder">
	<div class="projects-single-holder">
		<h1 class="projects-single-title">Youth Reporting Institute</h1>
		....
	</div>
</div>

The post now has a double black outline.

In conclusion: loading the project via JS means that we get an extra div.projects-single-holder.

  • should we have separate divs for inner and outer, so that the AJAX response can reply with only the inner div to be appended to the outer? This might require splitting partials/project-single-holder.php into two files: the holder and the held.

Copy link
Author

Choose a reason for hiding this comment

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

@benlk I noticed that too and wanted to hear your opinion on what you think would be best. I think splitting up the "holder" and the "held" sounds like a viable solution.

Copy link
Collaborator

@benlk benlk Jun 1, 2020

Choose a reason for hiding this comment

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

#140 (comment) explores a little more the holder/held distinction; I think what we'd end up with is:

div.project-single-layout
    button.project-single-close
    div.project-single-holder
         article.project-single-held

Copy link
Author

Choose a reason for hiding this comment

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

@benlk 8a616c2 starts the implementation of that structure

// set up basic args for our query to grab the post
$single_project_args = array(
'post_type' => 'projects',
'p' => $post_id
Copy link
Collaborator

Choose a reason for hiding this comment

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

This needs to be sanitized; since post IDs are always integers we could do abs(intval( $post_id ))

Copy link
Author

Choose a reason for hiding this comment

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

Updated in 554eded

@benlk
Copy link
Collaborator

benlk commented Jun 1, 2020

When do we get to style this?

Not sure, but we should plan for attempted content overflow. Right now, iframes come in with width="771px", and that's distorting the grid:

Screen Shot 2020-06-01 at 13 18 53

max-width: 100% on iframes and pictures would fix this.

What issue pertains to the mobile version?

I don't think there's a separate item for this. At 770px and below, we could:

  • add a "close" button to the held partial
  • in partials/project-base.php, move the holder before the list, so that on slow connections the loaded project displays first, before the list
  • on mobile with html:not(.no-js), hide the holder
  • when a new held partial is rendered, add a CSS open class or jQuery .show() to unhide the holder and reveal both the held and the "close" button

Copy link
Collaborator

@benlk benlk left a comment

Choose a reason for hiding this comment

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

Hold/held looks good 👍

We can do the mobile styles and other work in a later pass, I guess?

@joshdarby joshdarby merged commit ae1179c into staging Jun 1, 2020
@benlk benlk deleted the 125-single-project-view branch June 1, 2020 20:06
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