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

Non editable list groups #85

Merged
merged 2 commits into from
Jul 16, 2021
Merged

Non editable list groups #85

merged 2 commits into from
Jul 16, 2021

Conversation

pinussilvestrus
Copy link
Contributor

This makes it possible to have lists non-editable, which includes

  • no adding of items
  • no removal of items
  • disable default alphanumeric sorting

Required by bpmn-io/bpmn-properties-panel#25

@pinussilvestrus pinussilvestrus requested review from a team, marstamm and barmac and removed request for a team July 16, 2021 12:06
@bpmn-io-tasks bpmn-io-tasks bot added the needs review Review pending label Jul 16, 2021
@pinussilvestrus pinussilvestrus requested review from MaxTru, nikku and philippfromme and removed request for marstamm and barmac July 16, 2021 12:06
Copy link
Contributor

@MaxTru MaxTru left a comment

Choose a reason for hiding this comment

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

👋

@fake-join fake-join bot merged commit a13ad4a into main Jul 16, 2021
@fake-join fake-join bot deleted the non-editable-list-groups branch July 16, 2021 12:31
@bpmn-io-tasks bpmn-io-tasks bot removed the needs review Review pending label Jul 16, 2021
Copy link
Member

@nikku nikku left a comment

Choose a reason for hiding this comment

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

Two small comments for understanding.

@@ -39,7 +39,8 @@ const DEFAULT_LAYOUT = {
* component: import('preact').Component,
* id: String,
Copy link
Member

Choose a reason for hiding this comment

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

Meta comment, just because I came across it: Plain types are supposed to be lower case, i.e. string, number, boolean. Otherwise we refer to actual instances of String (new String("FOO")) which is not desired for type hints.

@@ -87,14 +88,14 @@ export default function ListGroup(props) {
useEffect(() => {

// we already sorted as items were added
if (open && !newItemAdded) {
if (shouldSort && open && !newItemAdded) {
Copy link
Member

Choose a reason for hiding this comment

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

Can shouldSort change? If so we'd need to make it part of the effect, right?

setOrdering(createOrdering(sortItems(items)));
}
}, [ open ]);

// (3) items were deleted
useEffect(() => {
if (prevItems && items.length < prevItems.length) {
if (shouldSort && prevItems && items.length < prevItems.length) {
Copy link
Member

Choose a reason for hiding this comment

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

See above: Can shouldSort change?

@@ -39,7 +39,8 @@ const DEFAULT_LAYOUT = {
* component: import('preact').Component,
* id: String,
* items: Array<ListItemDefinition>,
* label: String
* label: String,
* shouldSort?: Boolean
Copy link
Member

Choose a reason for hiding this comment

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

Any reason to not simply call it sort?

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.

3 participants