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

TreeCollection & RuleCollection (Conditional Tree Builder) #456

Draft
wants to merge 23 commits into
base: dev
Choose a base branch
from

Conversation

edarroudi
Copy link

Q A
New feature? [X]
Related issues? mentioned in #451

What's in this Pull Request?

Added a common TreeCollection control that features:

  • Row dependend Fields: e.g. show field x,y in root, and z on level 1
  • Row Fields are based on the collectionData component
  • MultiRoot Trees

Added a RuleTree (Condition Builder Tree) based on the TreeCollection component above, featuring:

  • Building complex conditions
  • Will feature "Autocomplete" Tokens in the future
  • Will feature "Evaluation" of the current Context when property pane is opened
  • Will feature custom condtions

What are the next todos for this feature branch:

  • Discuss interface
  • Discuss layout
  • Implement Evaluation of the current Context for RuleTree
  • Implement custom conditions for RuleTree
  • Finish localisation / Replace const labels
  • Refactoring
  • Documentation
  • Full Tests

What are the optional todos for the next feature branch:

  • Maybe Autocomplete

Any comment is appreciated. I think the trees don't need to support a lot of items so I didn't optimize it for speed.
The RuleBuilder might look a bit confusing at first but I think users will be able to work with that.

Below are some screenshots...

image

image

image
image
image
image
image
image

@edarroudi edarroudi mentioned this pull request May 30, 2022
1 task
Copy link
Collaborator

@AJIXuMuK AJIXuMuK left a comment

Choose a reason for hiding this comment

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

@edarroudi - thank you very much for this PR.
And I'm really sorry for the long delay.
I left some comments.
Promise to be more responsive :)

@@ -29,6 +29,7 @@
"@pnp/sp": "1.3.11",
"@pnp/sp-clientsvc": "1.3.11",
"@pnp/sp-taxonomy": "1.3.11",
"@pnp/spfx-controls-react": "3.8.0",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Did you check what is the size increase for the library?
Maybe it makes sense (if needed) to incorporate dynamic import?

@@ -0,0 +1,15 @@
import { IPropertyFieldRuleTreeProps as IPropertyFieldRuleTreeProps } from '.';
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's better to import from the file instead of ..
When importing from . you may complicate tree shaking.

}


private readonly standardFields: ICustomCollectionField[] = [{
Copy link
Collaborator

Choose a reason for hiding this comment

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

Definitely needs to be localized.

names.push(<li>{objName} {this.getTokens(tokenObject[objName])}</li>);
}

if(names)
Copy link
Collaborator

Choose a reason for hiding this comment

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

this will be always true.
You should probably check names.length

import { ICustomCollectionField } from "../collectionData/ICustomCollectionField";
import { ICustomTreeData, ICustomTreeItem } from "./ICustomTreeItem";

export interface IPropertyFieldTreeCollectionDataProps {
Copy link
Collaborator

Choose a reason for hiding this comment

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

this interface seems pretty similar to IPropertyFieldRuleTreeProps.
Maybe it makes sense to extend one from another or make some basic interface that will be extended by both?


import { clone, findIndex, sortBy } from '@microsoft/sp-lodash-subset';
import { CollectionDropdownField } from '../../collectionData/collectionDropdownField/CollectionDropdownField';
import { isEqual } from 'lodash';
Copy link
Collaborator

Choose a reason for hiding this comment

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

import isEqual from 'lodash/isEqual'

import { CollectionColorField } from '../../collectionData/collectionColorField/CollectionColorField';
import { CollectionIconField } from '../../collectionData/collectionIconField/CollectionIconField';

export class TreeCollectionDataItem extends React.Component<ITreeCollectionDataItemProps, ITreeCollectionDataItemState> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't like duplicating of the code between this component and CollectionDataItem.
Maybe implement some helper that will contain common logic?
Or have a base component that will have props like render, etc. And both TreeCollectionDataItem and CollectionDataItem will render this base component with appropriate props overrides?

@edarroudi
Copy link
Author

@edarroudi - thank you very much for this PR. And I'm really sorry for the long delay. I left some comments. Promise to be more responsive :)

@AJIXuMuK - no worries! Thank your for your reply and your comments. I tend to optimize and refactor the code once the overall "Architecture", Layout and Features are discussed and approved. I believe now that you don't have any problems with the overall approach and will a) change the code according to your commets and b) add the Evaluation and Custom conditions code.

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.

None yet

2 participants