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

feat: child and related listings UI #58

Merged
merged 18 commits into from
Jun 21, 2021
Merged

Conversation

dkoo
Copy link
Contributor

@dkoo dkoo commented May 25, 2021

All Submissions:

Changes proposed in this Pull Request:

  • Removes the placeholder front-end display of parent listings (to be designed and handled in a separate PR, perhaps using a block-based UI)
  • Replaces the sidebar UI for managing parent and child listings with a modal UI using the new AutocompleteWithSuggestions component from newspack-components (note: requires feat: add multi-select capabillity to AutocompleteWithSuggestions newspack-plugin#975 to be published to NPM)
  • As discussed with @thomasguillot, we no longer show parent listings UI in listings (to avoid showing both parent and child UIs in the same editor instance). Parent/child relationships for listings are now solely managed as child listings from the parent's editor instance.

How to test the changes in this Pull Request:

  1. Until feat: add multi-select capabillity to AutocompleteWithSuggestions newspack-plugin#975 is published to NPM, spoof the change by checking out that branch in newspack-plugin, going to assets/components, and running npm run prepublishOnly, then copying the components folder to newspack-listings/node_modules/newspack-components This is no longer required as the updated component has been published to NPM. You should be able to run npm ci from this branch to get it, now.
  2. Edit a post or page. Confirm the new sidebar panel:

Screen Shot 2021-05-25 at 5 11 21 PM

  1. Click "Manage Related Listings" and confirm the new modal UI:

Screen Shot 2021-05-25 at 5 12 18 PM

  1. Select different post types in the dropdown, add some listings, remove others, and save. Confirm that all functionality works as expected.
  2. After saving, edit one of the listings you added in WP admin.
  3. In the editor page for the listing, confirm the new sidebar panel:

Screen Shot 2021-05-25 at 5 13 51 PM

  1. Click "Manage Child Listings" and confirm the new modal UI. Confirm that the post where you selected this listing as a related listing is shown as selected here:

Screen Shot 2021-05-25 at 5 14 14 PM

  1. Select different post types in the dropdown, add some listings, remove others, and save. Confirm that all functionality works as expected.
  2. Remove the post or page where you added the listing as a related listing in step 4. Save.
  3. Go back to that post in the editor, open the "Manage Related Listings" modal and confirm that the listing is no longer shown as selected.
  4. Test with different combinations of listings owning other listings, pages, and posts. Confirm that for all listing types, listings can no longer be assigned as a parent to other listings of the same type (they can on the back-end, but only so we can programmatically manage orphaned or missing shadow terms—e.g. every Place listing is assigned its own shadow term, so we can easily query them)

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully ran tests with your changes locally?

@dkoo dkoo changed the base branch from master to epic/phase-2 May 25, 2021 22:59
@dkoo dkoo self-assigned this May 25, 2021
@dkoo dkoo marked this pull request as ready for review May 25, 2021 23:20
@dkoo dkoo changed the title Feat/parent child UI feat: child and related listings UI May 25, 2021
} )
.then( response => {
if ( response ) {
const mappedResponse = response.map( post => ( {
Copy link
Member

Choose a reason for hiding this comment

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

I've received and object instead of an array here, which resulted in a response.map is not a function error.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This puzzled me, but I found that it's because Newspack_Listings_Taxonomies::get_child_posts filters the array of results before returning it, so it sometimes ends up as an array with non-consecutive indexes, which JS converts to an object keyed with those non-consecutive indexes instead of a proper array. Using array_values to re-key the array in PHP before returning it as a response fixes the issue. 1902d9d

@dkoo dkoo requested a review from adekbadek June 17, 2021 16:31
Copy link
Member

@adekbadek adekbadek left a comment

Choose a reason for hiding this comment

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

Nit, but since the design was approved I assume it's ok. In the editor panel the button says "Manage Child Listings" even though related posts are managed in the modal, too. Maybe it could be more generic, like "Manage Related Content"?

image

@dkoo
Copy link
Contributor Author

dkoo commented Jun 18, 2021

Nit, but since the design was approved I assume it's ok. In the editor panel the button says "Manage Child Listings" even though related posts are managed in the modal, too. Maybe it could be more generic, like "Manage Related Content"?

I thought about that, too, but I was worried that "related content" is a phrase used by other products and might be confused with those other uses. In 2d6c6b1 I replaced all instances of "child listings" in the UI with "related content" so we can test how it feels. What do you think? cc @thomasguillot

@dkoo
Copy link
Contributor Author

dkoo commented Jun 21, 2021

Discussed with Thomas in Slack and he is okay with "related content" for now. Since this functionality is only half the equation (with front-end features coming in a future PR) we have some latitude to rename things again in the future.

@dkoo dkoo merged commit 06aff81 into epic/phase-2 Jun 21, 2021
@dkoo dkoo deleted the feat/parent-child-ui branch June 21, 2021 21:18
matticbot pushed a commit that referenced this pull request Jun 21, 2021
# [2.0.0-alpha.1](v1.2.1...v2.0.0-alpha.1) (2021-06-21)

### Bug Fixes

* activation PHP warning ([#70](#70)) ([29b0a34](29b0a34))
* failing npm ci command ([f509f36](f509f36))
* guard against nonexistent meta object ([#66](#66)) ([c821a09](c821a09))
* missing condition for block appender in list container ([#74](#74)) ([2c49896](2c49896))
* newspack_blocks support slug ([a2bda56](a2bda56))
* remove material packages ([b489015](b489015))
* use synced attributes for ListContainer directly ([#73](#73)) ([f8641a7](f8641a7))
* use value property of selection from AutocompleteWithSuggestions ([#61](#61)) ([c7c4cea](c7c4cea))
* util for checking post type on new posts ([fb61530](fb61530))
* warning about default meta value ([16af17b](16af17b))
* wp_insert_post filter name and theme_mod filter ([5befca7](5befca7))

### Features

* add a new global setting and post option to hide date ([#57](#57)) ([896f68f](896f68f))
* add revisions support for listings ([42d04d2](42d04d2))
* add settings for individual listing type URL slugs ([d78a3f7](d78a3f7)), closes [#41](#41)
* better integration with Newspack Theme features ([823f66a](823f66a))
* child and related listings UI ([#58](#58)) ([06aff81](06aff81))
* convert legacy custom terms to regular post terms ([#67](#67)) ([a2fcf84](a2fcf84))
* CSV importer script ([#51](#51)) ([ffbea00](ffbea00))
* flush permalinks automatically if updating slug option ([988521e](988521e))
* support Newspack Sponsors for listings ([#65](#65)) ([7d2ef64](7d2ef64))
* update cpt icon and block icons ([7b59032](7b59032)), closes [#49](#49)
* update price block to use placeholder and large font size ([#71](#71)) ([710f34c](710f34c))
* use post categories and tags for all listing post types ([#39](#39)) ([f223053](f223053)), closes [#32](#32)

### BREAKING CHANGES

* This feature will deprecate existing custom taxonomies, so any existing terms for those taxonomies will be lost.

To fix, we can convert terms from the deprecated taxonomies to standard post categories/tags via a migration script.
@matticbot
Copy link
Contributor

🎉 This PR is included in version 2.0.0-alpha.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

dkoo added a commit that referenced this pull request Jul 6, 2021
* chore: replace AutocompleteTokenfield with Newspack Components version (#40)

* feat: use post categories and tags for all listing post types (#39)

* feat: use post categories and tags for all listing post types

* fix: undo patterns post type changes (for another PR)

* chore: remove unneeded admin page highlighting filter

BREAKING CHANGE: This feature will deprecate existing custom taxonomies, so any existing terms for those taxonomies will be lost.

To fix, we can convert terms from the deprecated taxonomies to standard post categories/tags via a migration script.


Fixes #32.

* feat: better integration with Newspack Theme features

* feat: add settings for individual listing type URL slugs

Closes #41.

* fix: wp_insert_post filter name and theme_mod filter

* fix: newspack_blocks support slug

* feat: add revisions support for listings

* chore: update outdated docblock

* refactor: use material icons with Newspack color

* fix: warning about default meta value

* fix: util for checking post type on new posts

* chore: update label of "hide author" setting

* feat: flush permalinks automatically if updating slug option

* feat: update cpt icon and block icons

See #49

* fix: remove material packages

* fix: failing npm ci command

* [WIP] feat: harden post type usage and establish relationships between listings and posts/pages (#43)

* feat: make Business patterns applicable only to places

* feat: create shadow taxonomy for places

* feat: add ability to associate Places with regular posts and pages

* fix: remove default map markers from patterns

* feat: new Price block for Marketplace listings

Also create a proof-of-concept Marketplace listing pattern to test block implementation.

* feat: add meta field with data synced from Price block

* feat: second test pattern

* fix: incorrect conditional for updating shadow terms (whoops)

* feat: abstract shadow tax functions to make it easier to add more

* refactor: simplify setting formattedPrice attribute via useEffect

* chore: fix PHP warning about passing variables

* feat: shadow taxonomies for all CPTs; test automated related listings

* fix: avoid showing post on itself

* fix: incorrect var assignment

* fix: decode HTML entities before rendering currency options

* chore: fix function/class docs

* fix: formatting an empty string results in NaN

* fix: wrong post type being returned by util

* fix: handle all listing post types for shadow taxonomies

* fix: don't show the shadow taxonomy for the post being edited

* feat: add new post button for shadow taxonomies

* chore: instantiate var as empty array, just in case

* fix: updating of terms, and delete orphan terms

* fix: replace Material icon with WordPress icon

* feat: custom UI for parent/child listings instead of WP taxonomy UI

* chore: update function comment

* chore: remove commented-out code

* fix: posts/pages child search fields; only show child UI if published

* fix: logical errors in validation method 🤦

* chore: update function name and comments for clarity

* refactor: use AutocompleteWithSuggestions from newspack-components (#56)

* feat: CSV importer script (#51)

* feat: init CSV importer via CLI command

* refactor: move importer files to subdir

* feat: take field mappings from config file instead of hard-coding them

* feat: add (currently unused) image_ids meta field for future use

* feat: process meta fields and content into block patterns

* fix: mismatch between data types in term handling

* feat: support multiple post types for importing

* docs: add README and sample config

* fix: do not apply content filters to legacy content upon importing

* chore: description

* fix: check if default post type constant is a listing

* feat: update block template; handle social media links

* feat: importer edits for GDG

* feat: add a new global setting and post option to hide date (#57)

* fix: use value property of selection from AutocompleteWithSuggestions (#61)

* fix: use value property of selection from AutocompleteWithSuggestions

* fix: cast listing ID value as an integer

* fix: cast listing IDs as strings to avoid breaking existing listings

* feat: convert legacy custom terms to regular post terms (#67)

* test: init test suite (#60)

* test: init test suite

* chore: fix function comment

* chore: remove redundant lint-php NPM script

* feat: if no view.php, register blocks with default attributes

* fix: activation PHP warning (#70)

* feat: support Newspack Sponsors for listings (#65)

* feat: support Newspack Sponsors

* refactor: response object with author and sponsors

* fix: sponsors for queried listings

* feat: update price block to use placeholder and large font size (#71)

* fix: guard against nonexistent meta object (#66)

* feat: child and related listings UI (#58)

* feat: initial exploration of UI in a modal

* fix: filter out parent post from child listings response

* feat: child and related listings UI

* chore: clear messages when closing modals

* chore: hide shadow terms from menu

* chore: handle errors from fetching suggestions

* chore: more context-sensitive labels for child/parent UI

* chore: update empty message

* refactor: make parent/child UI components more self-contained, reusable

* chore: update newspack-components

* fix: parent/child listings UI bugs

* chore: rename "Child Listings" to "Related Content"

* fix: default listings to one-column-wide.php post template (#77)

* chore: gate legacy taxonomy term deletion behind an environment constant

* fix: memory leaks from legacy term utilities (#81)

* feat: gate custom tax migration behind env flag to avoid expensive ops

* feat: move legacy taxonomy migrator script to a CLI command

* chore: rename CLI command and use ::log instead of ::line

* refactor: move missing/orphan shadow term handling to WP CLI

Co-authored-by: Thomas Guillot <info@thomasguillot.com>
Co-authored-by: Thomas Guillot <thomasguillot@users.noreply.github.com>
matticbot pushed a commit that referenced this pull request Jul 6, 2021
# [2.0.0-alpha.3](v2.0.0-alpha.2...v2.0.0-alpha.3) (2021-07-06)

* v2 release (#85) ([748810d](748810d)), closes [#85](#85) [#40](#40) [#39](#39) [#32](#32) [#41](#41) [#49](#49) [#43](#43) [#56](#56) [#51](#51) [#57](#57) [#61](#61) [#67](#67) [#60](#60) [#70](#70) [#65](#65) [#71](#71) [#66](#66) [#58](#58) [#77](#77) [#81](#81)

### Bug Fixes

* errors and bugs related to WP 5.8 ([#83](#83)) ([90da6c5](90da6c5))

### BREAKING CHANGES

* This feature will deprecate existing custom taxonomies, so any existing terms for those taxonomies will be lost.

To fix, we can convert terms from the deprecated taxonomies to standard post categories/tags via a migration script.
matticbot pushed a commit that referenced this pull request Jul 6, 2021
# [2.0.0](v1.2.2...v2.0.0) (2021-07-06)

* v2 release (#85) ([748810d](748810d)), closes [#85](#85) [#40](#40) [#39](#39) [#32](#32) [#41](#41) [#49](#49) [#43](#43) [#56](#56) [#51](#51) [#57](#57) [#61](#61) [#67](#67) [#60](#60) [#70](#70) [#65](#65) [#71](#71) [#66](#66) [#58](#58) [#77](#77) [#81](#81)

### Bug Fixes

* errors and bugs related to WP 5.8 ([#83](#83)) ([90da6c5](90da6c5))

### BREAKING CHANGES

* This feature will deprecate existing custom taxonomies, so any existing terms for those taxonomies will be lost.

To fix, we can convert terms from the deprecated taxonomies to standard post categories/tags via a migration script.
dkoo added a commit that referenced this pull request Jul 19, 2021
* chore: replace AutocompleteTokenfield with Newspack Components version (#40)

* feat: use post categories and tags for all listing post types (#39)

* feat: use post categories and tags for all listing post types

* fix: undo patterns post type changes (for another PR)

* chore: remove unneeded admin page highlighting filter

BREAKING CHANGE: This feature will deprecate existing custom taxonomies, so any existing terms for those taxonomies will be lost.

To fix, we can convert terms from the deprecated taxonomies to standard post categories/tags via a migration script.


Fixes #32.

* feat: better integration with Newspack Theme features

* feat: add settings for individual listing type URL slugs

Closes #41.

* fix: wp_insert_post filter name and theme_mod filter

* fix: newspack_blocks support slug

* feat: add revisions support for listings

* chore: update outdated docblock

* refactor: use material icons with Newspack color

* fix: warning about default meta value

* fix: util for checking post type on new posts

* chore: update label of "hide author" setting

* feat: flush permalinks automatically if updating slug option

* feat: update cpt icon and block icons

See #49

* fix: remove material packages

* fix: failing npm ci command

* [WIP] feat: harden post type usage and establish relationships between listings and posts/pages (#43)

* feat: make Business patterns applicable only to places

* feat: create shadow taxonomy for places

* feat: add ability to associate Places with regular posts and pages

* fix: remove default map markers from patterns

* feat: new Price block for Marketplace listings

Also create a proof-of-concept Marketplace listing pattern to test block implementation.

* feat: add meta field with data synced from Price block

* feat: second test pattern

* fix: incorrect conditional for updating shadow terms (whoops)

* feat: abstract shadow tax functions to make it easier to add more

* refactor: simplify setting formattedPrice attribute via useEffect

* chore: fix PHP warning about passing variables

* feat: shadow taxonomies for all CPTs; test automated related listings

* fix: avoid showing post on itself

* fix: incorrect var assignment

* fix: decode HTML entities before rendering currency options

* chore: fix function/class docs

* fix: formatting an empty string results in NaN

* fix: wrong post type being returned by util

* fix: handle all listing post types for shadow taxonomies

* fix: don't show the shadow taxonomy for the post being edited

* feat: add new post button for shadow taxonomies

* chore: instantiate var as empty array, just in case

* fix: updating of terms, and delete orphan terms

* fix: replace Material icon with WordPress icon

* feat: custom UI for parent/child listings instead of WP taxonomy UI

* chore: update function comment

* chore: remove commented-out code

* fix: posts/pages child search fields; only show child UI if published

* fix: logical errors in validation method 🤦

* chore: update function name and comments for clarity

* refactor: use AutocompleteWithSuggestions from newspack-components (#56)

* feat: CSV importer script (#51)

* feat: init CSV importer via CLI command

* refactor: move importer files to subdir

* feat: take field mappings from config file instead of hard-coding them

* feat: add (currently unused) image_ids meta field for future use

* feat: process meta fields and content into block patterns

* fix: mismatch between data types in term handling

* feat: support multiple post types for importing

* docs: add README and sample config

* fix: do not apply content filters to legacy content upon importing

* chore: description

* fix: check if default post type constant is a listing

* feat: update block template; handle social media links

* feat: importer edits for GDG

* feat: add a new global setting and post option to hide date (#57)

* fix: use value property of selection from AutocompleteWithSuggestions (#61)

* fix: use value property of selection from AutocompleteWithSuggestions

* fix: cast listing ID value as an integer

* fix: cast listing IDs as strings to avoid breaking existing listings

* feat: convert legacy custom terms to regular post terms (#67)

* test: init test suite (#60)

* test: init test suite

* chore: fix function comment

* chore: remove redundant lint-php NPM script

* feat: if no view.php, register blocks with default attributes

* fix: activation PHP warning (#70)

* feat: support Newspack Sponsors for listings (#65)

* feat: support Newspack Sponsors

* refactor: response object with author and sponsors

* fix: sponsors for queried listings

* feat: update price block to use placeholder and large font size (#71)

* fix: guard against nonexistent meta object (#66)

* feat: child and related listings UI (#58)

* feat: initial exploration of UI in a modal

* fix: filter out parent post from child listings response

* feat: child and related listings UI

* chore: clear messages when closing modals

* chore: hide shadow terms from menu

* chore: handle errors from fetching suggestions

* chore: more context-sensitive labels for child/parent UI

* chore: update empty message

* refactor: make parent/child UI components more self-contained, reusable

* chore: update newspack-components

* fix: parent/child listings UI bugs

* chore: rename "Child Listings" to "Related Content"

* fix: default listings to one-column-wide.php post template (#77)

* chore: gate legacy taxonomy term deletion behind an environment constant

* fix: memory leaks from legacy term utilities (#81)

* feat: gate custom tax migration behind env flag to avoid expensive ops

* feat: move legacy taxonomy migrator script to a CLI command

* chore: rename CLI command and use ::log instead of ::line

* refactor: move missing/orphan shadow term handling to WP CLI

* feat: block patterns for real estate and classifieds

* fix: import pattern styles into editor SCSS

* fix: restore patterns after merge

* refactor: remove placeholder image URLs from patterns

Co-authored-by: Thomas Guillot <info@thomasguillot.com>
Co-authored-by: Thomas Guillot <thomasguillot@users.noreply.github.com>
matticbot pushed a commit that referenced this pull request Jul 19, 2021
# [3.0.0-alpha.1](v2.0.1...v3.0.0-alpha.1) (2021-07-19)

### Bug Fixes

* avoid meta sync update error ([#95](#95)) ([cab16aa](cab16aa))
* do not register post-specific sidebars in widgets page ([#93](#93)) ([7716775](7716775))

### Features

* bump max number of items per list from 20 to 50 ([#97](#97)) ([009deab](009deab))
* more block patterns (real estate, classified ads) ([#84](#84)) ([e76acc3](e76acc3)), closes [#40](#40) [#39](#39) [#32](#32) [#41](#41) [#49](#49) [#43](#43) [#56](#56) [#51](#51) [#57](#57) [#61](#61) [#67](#67) [#60](#60) [#70](#70) [#65](#65) [#71](#71) [#66](#66) [#58](#58) [#77](#77) [#81](#81)

### BREAKING CHANGES

* This feature will deprecate existing custom taxonomies, so any existing terms for those taxonomies will be lost.

To fix, we can convert terms from the deprecated taxonomies to standard post categories/tags via a migration script.
matticbot pushed a commit that referenced this pull request Jul 19, 2021
# [3.0.0-alpha.1](v2.0.1...v3.0.0-alpha.1) (2021-07-19)

### Bug Fixes

* avoid meta sync update error ([#95](#95)) ([cab16aa](cab16aa))
* do not register post-specific sidebars in widgets page ([#93](#93)) ([7716775](7716775))

### Features

* bump max number of items per list from 20 to 50 ([#97](#97)) ([009deab](009deab))
* more block patterns (real estate, classified ads) ([#84](#84)) ([a51f5af](a51f5af))
* more block patterns (real estate, classified ads) ([#84](#84)) ([e76acc3](e76acc3)), closes [#40](#40) [#39](#39) [#32](#32) [#41](#41) [#49](#49) [#43](#43) [#56](#56) [#51](#51) [#57](#57) [#61](#61) [#67](#67) [#60](#60) [#70](#70) [#65](#65) [#71](#71) [#66](#66) [#58](#58) [#77](#77) [#81](#81)

### BREAKING CHANGES

* This feature will deprecate existing custom taxonomies, so any existing terms for those taxonomies will be lost.

To fix, we can convert terms from the deprecated taxonomies to standard post categories/tags via a migration script.
matticbot pushed a commit that referenced this pull request Jul 19, 2021
# 1.0.0-alpha.1 (2021-07-19)

### Bug Fixes

* avoid meta sync update error ([#95](#95)) ([cab16aa](cab16aa))
* do not register post-specific sidebars in widgets page ([#93](#93)) ([7716775](7716775))
* editor errors with reusable blocks ([#89](#89)) ([fdc46d3](fdc46d3))
* errors and bugs related to WP 5.8 ([#83](#83)) ([90da6c5](90da6c5))
* force alpha rebuild ([acc2075](acc2075))
* minor bug fixes ([#21](#21)) ([5f90bc7](5f90bc7))
* missing condition for block appender in list container ([#74](#74)) ([2c49896](2c49896))
* syncing attributes from curated list block to inner blocks ([#64](#64)) ([cdbc0bb](cdbc0bb))
* use synced attributes for ListContainer directly ([#73](#73)) ([f8641a7](f8641a7))

### Features

* add block patterns ([#23](#23)) ([a273a40](a273a40))
* bump max number of items per list from 20 to 50 ([#97](#97)) ([009deab](009deab))
* initial post type and block setup ([#1](#1)) ([47dc0c1](47dc0c1))
* listing taxonomies and query mode ([#6](#6)) ([528e1e5](528e1e5))
* more block patterns (real estate, classified ads) ([#84](#84)) ([a51f5af](a51f5af))
* new Curated List block, block pattern, and map functionality ([#3](#3)) ([9be6e7e](9be6e7e))
* remove borders and padding in editor to match front-end styles ([#14](#14)) ([6c47a17](6c47a17))

* v2 release (#85) ([748810d](748810d)), closes [#85](#85) [#40](#40) [#39](#39) [#32](#32) [#41](#41) [#49](#49) [#43](#43) [#56](#56) [#51](#51) [#57](#57) [#61](#61) [#67](#67) [#60](#60) [#70](#70) [#65](#65) [#71](#71) [#66](#66) [#58](#58) [#77](#77) [#81](#81)

### BREAKING CHANGES

* This feature will deprecate existing custom taxonomies, so any existing terms for those taxonomies will be lost.

To fix, we can convert terms from the deprecated taxonomies to standard post categories/tags via a migration script.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants