Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ The available fields to customize an action are:
- `label`: this is the text what will be shown on the button if no icons exist for the name you provided
- `detect`: this is either a `FateType` or a function that takes a `FateNode` as an input and returns either `false` or an object with a `value` field that will be value passed to the dropdown (if any)
- `dropdown`: this is an Angular Component implementing the `FateDropdown` interface. It will be use to show a dialog that allows the user to customize the value of the command
- `closeOnEmit`: this is for determination if close dropdown, when emits a value

### Add the icon to your toolbar
In the template where your ui is included you can simply add the new custom button by it's `name`:
Expand Down
7 changes: 4 additions & 3 deletions src/app/fate-ui/fate-ui.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export class FateUiComponent implements OnChanges, AfterViewInit {
if (!button.classList.contains('fate-ui-button')) {
button = this.legacyBrowser.findParent(button, '.fate-ui-button');
}
if(!button) {
if (!button) {
return
}
const dropdown = this.el.nativeElement.querySelector('.fate-ui-dropdown');
Expand All @@ -106,7 +106,7 @@ export class FateUiComponent implements OnChanges, AfterViewInit {

this.dropdownValue = this.enabled[action];
console.debug('action has value', button, dropdown, this.dropdownValue);
this.initDropdown(this.controller.getAction(action).dropdown, this.dropdownValue);
this.initDropdown(this.controller.getAction(action).dropdown, this.dropdownValue, this.controller.getAction(action).closeOnEmit);

// Postion the dropdown
setTimeout(() => {
Expand Down Expand Up @@ -147,7 +147,7 @@ export class FateUiComponent implements OnChanges, AfterViewInit {
};
}

protected initDropdown(actionComponent, value) {
protected initDropdown(actionComponent, value, closeOnEmit) {
if (this.dropdownComponent) {
this.dropdownComponent.destroy();
}
Expand All @@ -158,6 +158,7 @@ export class FateUiComponent implements OnChanges, AfterViewInit {
component.instance.valueChange.subscribe((newValue) => {
this.dropdownValue = newValue;
this.controller.do(this.uiId, this.dropdownAction, newValue);
this.dropdownAction = closeOnEmit ? false : this.dropdownAction;
});
this.dropdownComponent = this.viewContainerRef.insert(component.hostView);
} else {
Expand Down