|
| 1 | +// eslint-disable-next-line @stylistic/max-len |
| 2 | +/* eslint-disable @typescript-eslint/explicit-module-boundary-types,@typescript-eslint/no-unused-vars */ |
| 3 | +import { getDiagram } from '@ts/ui/diagram/diagram.importer'; |
| 4 | + |
| 5 | +class DiagramBar { |
| 6 | + // eslint-disable-next-line @typescript-eslint/no-explicit-any |
| 7 | + onChanged: any; |
| 8 | + |
| 9 | + // eslint-disable-next-line @typescript-eslint/no-explicit-any |
| 10 | + _owner: any; |
| 11 | + |
| 12 | + // eslint-disable-next-line @typescript-eslint/no-explicit-any |
| 13 | + constructor(owner: any) { |
| 14 | + const { EventDispatcher } = getDiagram(); |
| 15 | + this.onChanged = new EventDispatcher(); // IBar.onChanged: EventDispatcher<IBarListener> |
| 16 | + this._owner = owner; |
| 17 | + } |
| 18 | + |
| 19 | + raiseBarCommandExecuted(key, parameter): void { |
| 20 | + this.onChanged.raise('notifyBarCommandExecuted', parseInt(key, 10), parameter); |
| 21 | + } |
| 22 | + |
| 23 | + getCommandKeys(): void { |
| 24 | + // IBar.getCommandKeys(): DiagramCommand[] |
| 25 | + throw 'Not Implemented'; |
| 26 | + } |
| 27 | + |
| 28 | + setItemValue(key, value): void { |
| 29 | + // IBar.setItemValue(key: DiagramCommand, value: any) |
| 30 | + } |
| 31 | + |
| 32 | + setItemEnabled(key, enabled): void { |
| 33 | + // IBar.setItemEnabled(key: DiagramCommand, enabled: boolean) |
| 34 | + } |
| 35 | + |
| 36 | + setItemVisible(key, enabled): void { |
| 37 | + // IBar.setItemVisible(key: DiagramCommand, visible: boolean) |
| 38 | + } |
| 39 | + |
| 40 | + setEnabled(enabled): void { |
| 41 | + // IBar.setEnabled(enabled: boolean) |
| 42 | + } |
| 43 | + |
| 44 | + setItemSubItems(key, items): void { |
| 45 | + // IBar.setItemSubItems(key: DiagramCommand, items: any[]) |
| 46 | + } |
| 47 | + |
| 48 | + isVisible(): boolean { |
| 49 | + // IBar.isVisible(): boolean |
| 50 | + return true; |
| 51 | + } |
| 52 | + |
| 53 | + // eslint-disable-next-line @typescript-eslint/explicit-function-return-type |
| 54 | + _getKeys(items) { |
| 55 | + const keys = items.reduce((commands, item) => { |
| 56 | + if (item.command !== undefined) { |
| 57 | + commands.push(item.command); |
| 58 | + } |
| 59 | + if (item.items) { |
| 60 | + // eslint-disable-next-line no-param-reassign |
| 61 | + commands = commands.concat(this._getKeys(item.items)); |
| 62 | + } |
| 63 | + // eslint-disable-next-line @typescript-eslint/no-unsafe-return |
| 64 | + return commands; |
| 65 | + }, []); |
| 66 | + // eslint-disable-next-line @typescript-eslint/no-unsafe-return |
| 67 | + return keys; |
| 68 | + } |
| 69 | +} |
| 70 | + |
| 71 | +export default DiagramBar; |
0 commit comments