-
Notifications
You must be signed in to change notification settings - Fork 2
WIP alternative hierarchic config #255
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,13 +2,14 @@ import {JsonPipe} from '@angular/common'; | |
| import {Component} from '@angular/core'; | ||
| import {FormsModule, ReactiveFormsModule} from '@angular/forms'; | ||
| import {MatButton} from '@angular/material/button'; | ||
| import {MatFormField, MatLabel, MatHint} from '@angular/material/form-field'; | ||
| import {MatFormField, MatHint, MatLabel} from '@angular/material/form-field'; | ||
| import {MatInput} from '@angular/material/input'; | ||
| import {NaturalHierarchicConfiguration} from '@ecodev/natural'; | ||
| import {hierarchicConfig, nodeConfig} from '@ecodev/natural'; | ||
| import {NaturalSelectHierarchicComponent} from '../../../projects/natural/src/lib/modules/select/select-hierarchic/select-hierarchic.component'; | ||
| import {ItemService} from '../../../projects/natural/src/lib/testing/item.service'; | ||
| import {AbstractSelect} from '../AbstractSelect'; | ||
| import {DebugControlComponent} from '../debug-form.component'; | ||
| import {FileService} from '../file/file.service'; | ||
|
|
||
| @Component({ | ||
| imports: [ | ||
|
|
@@ -27,12 +28,57 @@ import {DebugControlComponent} from '../debug-form.component'; | |
| styleUrl: './select-hierarchic.component.scss', | ||
| }) | ||
| export class SelectHierarchicComponent extends AbstractSelect { | ||
| public hierarchicConfig: NaturalHierarchicConfiguration[] = [ | ||
| { | ||
| service: ItemService, | ||
| parentsRelationNames: ['parent'], | ||
| childrenRelationNames: ['parent'], | ||
| selectableAtKey: 'any', | ||
| public readonly itemNode = nodeConfig({ | ||
| service: ItemService, | ||
| root: true, | ||
| selectableAtKey: 'any', | ||
| }); | ||
|
Comment on lines
+31
to
+35
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. D'abord on définit les noeuds de l'arbre. La nouvelle propriété |
||
|
|
||
| public readonly fileNode = nodeConfig({ | ||
| service: FileService, | ||
| selectableAtKey: 'any', | ||
| }); | ||
|
|
||
| public hierarchicConfig = hierarchicConfig( | ||
| [this.itemNode], | ||
| [ | ||
| { | ||
| parent: this.itemNode, | ||
| child: this.itemNode, | ||
| field: 'parent', | ||
| }, | ||
| ], | ||
| ); | ||
|
Comment on lines
+42
to
+51
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Puis on définit les relations entre les noeuds de l'arbre. Une relation est un |
||
|
|
||
| public readonly itemForRootNode = nodeConfig({ | ||
| service: ItemService, | ||
| root: true, | ||
| selectableAtKey: 'any', | ||
| }); | ||
|
|
||
| public readonly itemForChildNode = nodeConfig({ | ||
| service: ItemService, | ||
| selectableAtKey: 'any', | ||
| filter: { | ||
| conditions: [ | ||
| // ... | ||
| ], | ||
| }, | ||
| ]; | ||
| }); | ||
|
|
||
| public hierarchicConfig2 = hierarchicConfig( | ||
| [this.itemForRootNode, this.itemForChildNode], | ||
| [ | ||
| { | ||
| parent: this.itemForRootNode, | ||
| child: this.itemForChildNode, | ||
| field: 'parent', | ||
| }, | ||
| { | ||
| parent: this.itemForChildNode, | ||
| child: this.itemForChildNode, | ||
| field: 'parent', | ||
| }, | ||
| ], | ||
| ); | ||
|
Comment on lines
+69
to
+83
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On utilise 2 fonctions pour construire la config pour permettre à TypeScript de nous garantir que les noeuds utilisés dans les relations, sont bien déclarés dans la liste de noeuds.