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

Add functionality for updating sections dynamically #542

Open
wants to merge 20 commits into
base: main
Choose a base branch
from

Conversation

vitPinchuk
Copy link
Contributor

Resolves: #523

@vitPinchuk vitPinchuk self-assigned this Nov 6, 2024
Copy link

codecov bot commented Nov 6, 2024

Codecov Report

Attention: Patch coverage is 98.27586% with 2 lines in your changes missing coverage. Please review.

Project coverage is 99.18%. Comparing base (9c1ff1b) to head (5c4d12a).

Files with missing lines Patch % Lines
src/migration.ts 91.66% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #542      +/-   ##
==========================================
- Coverage   99.19%   99.18%   -0.02%     
==========================================
  Files         115      115              
  Lines        1986     2076      +90     
  Branches      519      511       -8     
==========================================
+ Hits         1970     2059      +89     
- Misses         14       15       +1     
  Partials        2        2              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mikhail-vl mikhail-vl added the enhancement New feature or request label Nov 6, 2024
@mikhail-vl mikhail-vl added this to the Forms 4.9.0 milestone Nov 6, 2024
@vitPinchuk vitPinchuk marked this pull request as draft November 6, 2024 13:44
@vitPinchuk vitPinchuk marked this pull request as ready for review November 7, 2024 15:47
onChangeSections([...sections, ...currentSectionsToAdd]);
}
},
[onChangeSections, options, sections]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please don't use state values as hook dependency which is used in custom code. It might cause infinity loops.
Options and sections should be removed from dependency list.
Use ref value or setState callback instead.

*/
const addSections = useCallback(
(newSections: LayoutSection[]) => {
if (options) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

do we need to check options here?

@@ -172,6 +188,22 @@ export const elementValueChangedCodeParameters = new CodeParametersBuilder({
CodeEditorSuggestionItemKind.Method
),
sectionsExpandedState: new CodeParameterItem<Record<string, boolean>>('Sections Expanded State'),
addSections: new CodeParameterItem<(sections: LayoutSection[]) => void>(
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would change sections helpers to simplify working with them for end users.

  1. Add Section and already assign elements for it
const elements = []; // create and save elements;

.addSection({ name: '1', elements: [element1.id] });
.addSection({ name: '2', elements: [element2.id] });
  1. Get Section By Name - returns section object with elements
  2. Remove From section
removeFromSection(section.id, [element1.id]);
  1. Remove section
  2. Add to section
addToSection(section.id, [element1.id])

In addition, I would create an object with all helpers for sections like sectionsHelper: { add, get, getAll, update, assign, unassign, remove }

@mikhail-vl mikhail-vl changed the title Add and remove sections dynamically Add functionality for updating sections dynamically Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Ready
Development

Successfully merging this pull request may close these issues.

Dynamic panel layout
3 participants