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

Relationship Field: Allow Choosing Content According to the Relationship #30928

Closed
Tracked by #30495
nicobytes opened this issue Dec 11, 2024 · 2 comments · Fixed by #30976
Closed
Tracked by #30495

Relationship Field: Allow Choosing Content According to the Relationship #30928

nicobytes opened this issue Dec 11, 2024 · 2 comments · Fixed by #30976

Comments

@nicobytes
Copy link
Contributor

nicobytes commented Dec 11, 2024

Parent Issue

#30495

User Story

As a user, I want to select content based on its relationship to other items, so that I can establish meaningful connections between content pieces without confusion.

Screenshot 2024-12-11 at 3 53 18 PM

Acceptance Criteria

1. Button Behavior Based on Relationship Type

  • For 1-to-1 relationships:

    • The "Existing Content" button should be disabled if the user has selected exactly one content item.
    • For 1-1 relationships, should the table allow the selection of a single content item using a radio button
  • For 1-to-n or n-to-n relationships:

    • The "Relate" button should always be enabled, allowing multiple selections.
    • Ensure proper validation and handling for multiple content selections.
@nicobytes
Copy link
Contributor Author

nicobytes commented Dec 27, 2024

QA Notes:

Steps to reproduce:

  1. Enable the new editor content by setting DOT_FEATURE_FLAG_NEW_EDIT_PAGE and DOT_CONTENT_EDITOR2_ENABLED to true.
  2. Create a new content type: navigate to Content Model > Content Type > Create Content.
  3. Enable the Edit Content Beta feature.
  4. Open the content created previously.
  5. Add a Relationships field with a 1-1 relationship.
  6. Add a Relationships field with a 1-n relationship.
  7. Add a Relationships field with an n-n relationship.
  8. Add a Relationships field with an n-1 relationship.

Behavior

radio.mp4

Dialog height

Screenshot 2024-12-27 at 11 24 22 AM

@nicobytes nicobytes moved this from In Progress to In Review in dotCMS - Product Planning Dec 27, 2024
github-merge-queue bot pushed a commit that referenced this issue Dec 27, 2024
)

### Parent Issue

#30928 

### Proposed Changes

This pull request includes several changes to improve the functionality
and maintainability of the `dot-select-existing-content` component and
its associated files. The most important changes include enhancements to
the selection mode, updates to the dialog behavior, and improvements to
the component's initialization and testing.

### Enhancements to selection mode:

* Added support for dynamic selection mode in the
`dot-select-existing-content.component.html` file, allowing for both
multiple and single selection modes.
[[1]](diffhunk://#diff-ba794904cc95635d9efca07b7e2bfeb948b5b0bb0c8e1e97c777c615398ba011R4-R7)
[[2]](diffhunk://#diff-ba794904cc95635d9efca07b7e2bfeb948b5b0bb0c8e1e97c777c615398ba011L41-R24)
[[3]](diffhunk://#diff-ba794904cc95635d9efca07b7e2bfeb948b5b0bb0c8e1e97c777c615398ba011L54-R37)
[[4]](diffhunk://#diff-ba794904cc95635d9efca07b7e2bfeb948b5b0bb0c8e1e97c777c615398ba011R66-R71)
[[5]](diffhunk://#diff-ba794904cc95635d9efca07b7e2bfeb948b5b0bb0c8e1e97c777c615398ba011R84-R88)
[[6]](diffhunk://#diff-ba794904cc95635d9efca07b7e2bfeb948b5b0bb0c8e1e97c777c615398ba011L117-R121)

### Updates to dialog behavior:

* Modified the `dot-select-existing-content.component.ts` to include the
`DynamicDialogConfig` and `DynamicDialogRef` services for better dialog
management.
[[1]](diffhunk://#diff-14d3d666b0a074fe26436013ebf4abe96e518e28e9799b85b393d14b82ac528bL1-R13)
[[2]](diffhunk://#diff-14d3d666b0a074fe26436013ebf4abe96e518e28e9799b85b393d14b82ac528bL28-R35)
[[3]](diffhunk://#diff-14d3d666b0a074fe26436013ebf4abe96e518e28e9799b85b393d14b82ac528bL43)
[[4]](diffhunk://#diff-14d3d666b0a074fe26436013ebf4abe96e518e28e9799b85b393d14b82ac528bL54-R58)
* Updated the `dot-select-existing-content.component.spec.ts` to include
tests for dialog initialization, closing behavior, and selection mode
validation.
[[1]](diffhunk://#diff-c67ee6b7f401324d58934e1bbad99e6b1d0c2e462d5471caa5a9df58eac71767L4-R4)
[[2]](diffhunk://#diff-c67ee6b7f401324d58934e1bbad99e6b1d0c2e462d5471caa5a9df58eac71767R18)
[[3]](diffhunk://#diff-c67ee6b7f401324d58934e1bbad99e6b1d0c2e462d5471caa5a9df58eac71767R34-R58)
[[4]](diffhunk://#diff-c67ee6b7f401324d58934e1bbad99e6b1d0c2e462d5471caa5a9df58eac71767L58-R143)
[[5]](diffhunk://#diff-c67ee6b7f401324d58934e1bbad99e6b1d0c2e462d5471caa5a9df58eac71767R163-R207)

### Improvements to initialization and testing:

* Added initialization logic in the
`dot-select-existing-content.component.ts` to ensure the component
starts with the correct configuration.
* Enhanced the test suite in
`dot-select-existing-content.component.spec.ts` to cover various
scenarios, including initialization, dialog behavior, and item
selection.
[[1]](diffhunk://#diff-c67ee6b7f401324d58934e1bbad99e6b1d0c2e462d5471caa5a9df58eac71767L4-R4)
[[2]](diffhunk://#diff-c67ee6b7f401324d58934e1bbad99e6b1d0c2e462d5471caa5a9df58eac71767R18)
[[3]](diffhunk://#diff-c67ee6b7f401324d58934e1bbad99e6b1d0c2e462d5471caa5a9df58eac71767R34-R58)
[[4]](diffhunk://#diff-c67ee6b7f401324d58934e1bbad99e6b1d0c2e462d5471caa5a9df58eac71767L58-R143)
[[5]](diffhunk://#diff-c67ee6b7f401324d58934e1bbad99e6b1d0c2e462d5471caa5a9df58eac71767R163-R207)

### Minor adjustments:

* Updated the SCSS file `_radiobutton.scss` to include a new class for
styling radio buttons.
* Added readonly properties for injected services in the
`dot-select-existing-file.component.ts` to improve code readability and
maintainability.
[[1]](diffhunk://#diff-18bf6e06cc08560259db33d84f324194172c43e47220f07b1de0990cf71077acR46-R49)
[[2]](diffhunk://#diff-18bf6e06cc08560259db33d84f324194172c43e47220f07b1de0990cf71077acR66-R69)

### Checklist
- [x] Tests
- [x] Translations
- [x] Security Implications Contemplated (add notes if applicable)
@github-project-automation github-project-automation bot moved this from In Review to Done in dotCMS - Product Planning Dec 27, 2024
@nicobytes nicobytes moved this from Done to Internal QA in dotCMS - Product Planning Dec 27, 2024
@freddyDOTCMS freddyDOTCMS self-assigned this Dec 27, 2024
@freddyDOTCMS
Copy link
Contributor

Pass Internal QA: Work as expected

Note: The "New Content" option is not working but it is going to be work in another issue. also we need to disabled the "New Content" option when the relationship is one to one and you already have a item selected

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