packages/data/src/lib/resource-actionbar/api-actionbar.component.ts
selector | ec-api-actionbar |
template |
|
Properties |
|
Methods |
|
Inputs |
Outputs |
constructor(notificationService: NotificationsService, sdk: SdkService, resourceConfig: ResourceConfig, elementRef: ElementRef, cdr: ChangeDetectorRef)
|
||||||||||||||||||
Parameters :
|
actions | |
Type : Action[]
|
|
Default value : [
{
id: 'data',
title: 'Datamanager',
action: (item, actionbar) =>
this.loadResourceListActions({
api: this.sdk.datamanager,
relation: 'dataManager',
actionbar,
action: (dm) => {
this.sdk.useDatamanager(dm.shortID);
actionbar.loadActions([
this.resourceAction({
actionbar,
title: 'Models',
relation: 'model',
api: dm,
action: (model) =>
actionbar.loadActions([
{
id: 'entry',
title: 'Entries',
action: () => {
this.sdk.api.entryList(model.title).then((entryList) => {
const actions = entryList.getAllItems().map((listEntry) => {
return {
title: listEntry._entryTitle,
id: listEntry.id,
data: listEntry,
action: (entryItem) => {
const path = this.getPath().join('/');
this.openInEditor(path);
},
};
});
actionbar.loadActions(actions);
});
},
},
{
id: 'edit',
title: 'Edit Model',
action: () => {
const path = this.getPath().join('/');
this.openInEditor(path);
},
},
]),
}),
this.resourceAction({
actionbar,
title: 'Asset Group',
relation: 'assetGroup',
path: 'asset-group',
api: dm,
action: () => this.openCurrentPath(),
}),
this.resourceAction({
actionbar,
title: 'Datamanager Accounts',
relation: 'dmAccount',
api: dm,
action: () => this.openCurrentPath(),
}),
{
title: 'Edit',
id: 'edit',
action: () => this.openCurrentPath(),
},
]);
},
}),
},
{
id: 'accounts',
title: 'Account Server',
action: (item, actionbar) =>
this.loadApiRelationActions(this.sdk.accounts, actionbar, () => this.openCurrentPath()),
},
]
|
|
actions | |
Type : Action[]
|
|
Inherited from
ResourceActionbarComponent
|
|
Defined in
ResourceActionbarComponent:27
|
actions | |
Type : Action[]
|
|
Inherited from
ActionbarComponent
|
|
Defined in
ActionbarComponent:33
|
config | |
Type : ActionbarConfig
|
|
Default value : {
label: 'title',
identifier: 'id',
fields: {
title: {},
},
}
|
|
Inherited from
ActionbarComponent
|
|
Defined in
ActionbarComponent:26
|
root | |
Default value : 'ROOT'
|
|
Inherited from
ActionbarComponent
|
|
Defined in
ActionbarComponent:25
|
config | |
Type : ListConfig<T>
|
|
Inherited from
SelectComponent
|
|
Defined in
SelectComponent:48
|
|
Configuration Object for List |
disabled | |
Type : ListConfig<T>
|
|
Inherited from
SelectComponent
|
|
Defined in
SelectComponent:50
|
|
If true, the input will be disabled |
focusEvent | |
Type : EventEmitter<boolean>
|
|
Default value : new EventEmitter()
|
|
Inherited from
SelectComponent
|
|
Defined in
SelectComponent:76
|
|
Event emitter to focus input |
formControl | |
Type : FormControl
|
|
Inherited from
SelectComponent
|
|
Defined in
SelectComponent:88
|
|
The formControl that is used. |
list | |
Type : List<T>
|
|
Inherited from
SelectComponent
|
|
Defined in
SelectComponent:70
|
|
The Instance of the List |
placeholder | |
Type : string
|
|
Inherited from
SelectComponent
|
|
Defined in
SelectComponent:56
|
|
Input placeholder |
selection | |
Type : Selection<T>
|
|
Inherited from
SelectComponent
|
|
Defined in
SelectComponent:54
|
|
The used selection |
solo | |
Type : boolean
|
|
Inherited from
SelectComponent
|
|
Defined in
SelectComponent:74
|
|
Wether or not the selection should be solo |
value | |
Type : Array<T> | T
|
|
Inherited from
SelectComponent
|
|
Defined in
SelectComponent:52
|
|
The visible items |
values | |
Type : Array<T>
|
|
Inherited from
SelectComponent
|
|
Defined in
SelectComponent:72
|
|
Available Items |
create | |
Type : EventEmitter<string>
|
|
Inherited from
ResourceActionbarComponent
|
|
Defined in
ResourceActionbarComponent:24
|
select | |
Type : EventEmitter<Item<Action>>
|
|
Inherited from
ResourceActionbarComponent
|
|
Defined in
ResourceActionbarComponent:25
|
add | |
Type : EventEmitter<Item<T>>
|
|
Inherited from
SelectComponent
|
|
Defined in
SelectComponent:64
|
|
Emits when an item is being added |
changed | |
Type : EventEmitter<Selection<T>>
|
|
Inherited from
SelectComponent
|
|
Defined in
SelectComponent:58
|
|
Event emitter on item selection |
enter | |
Type : EventEmitter<SelectComponent<T>>
|
|
Inherited from
SelectComponent
|
|
Defined in
SelectComponent:66
|
|
Emits the query when enter is pressed |
enterPressed | |
Type : Subject<string>
|
|
Inherited from
SelectComponent
|
|
Defined in
SelectComponent:68
|
|
Subject that is nexted when enter is pressed |
itemClick | |
Type : EventEmitter<Item<T>>
|
|
Inherited from
SelectComponent
|
|
Defined in
SelectComponent:60
|
|
Event emitter on selected item click |
remove | |
Type : EventEmitter<Item<T>>
|
|
Inherited from
SelectComponent
|
|
Defined in
SelectComponent:62
|
|
Emits when an item is being removed |
loadApiRelationActions | ||||||||||||||||
loadApiRelationActions(api: Core, actionbar: ActionbarComponent, action?: ActionFunction)
|
||||||||||||||||
Parameters :
Returns :
void
|
ngOnInit |
ngOnInit()
|
Returns :
void
|
openCurrentPath |
openCurrentPath()
|
Returns :
void
|
openInEditor | ||||||||||||
openInEditor(path, env: string)
|
||||||||||||
Parameters :
Returns :
void
|
filterDropdownList | |||||||||
filterDropdownList(listComponent: ListComponent
|
|||||||||
Inherited from
ResourceActionbarComponent
|
|||||||||
Defined in
ResourceActionbarComponent:152
|
|||||||||
Parameters :
Returns :
any
|
getResourceListActions | ||||||||||||
getResourceListActions(listResource: ListResource, relation: string, action?: ActionFunction)
|
||||||||||||
Inherited from
ResourceActionbarComponent
|
||||||||||||
Defined in
ResourceActionbarComponent:54
|
||||||||||||
Parameters :
Returns :
Action[]
|
loadResourceListActions | ||||||||||||
loadResourceListActions(state: ResourceActionbarState, stack)
|
||||||||||||
Inherited from
ResourceActionbarComponent
|
||||||||||||
Defined in
ResourceActionbarComponent:97
|
||||||||||||
Parameters :
Returns :
Promise<Action[]>
|
ngOnInit |
ngOnInit()
|
Inherited from
ResourceActionbarComponent
|
Defined in
ResourceActionbarComponent:39
|
Returns :
void
|
reload |
reload()
|
Inherited from
ResourceActionbarComponent
|
Defined in
ResourceActionbarComponent:90
|
Returns :
void
|
resourceAction | |||||
resourceAction(undefined: literal type)
|
|||||
Inherited from
ResourceActionbarComponent
|
|||||
Defined in
ResourceActionbarComponent:127
|
|||||
Parameters :
Returns :
{ id: string; title: string; add: boolean; action: () => any; }
|
currentActions |
currentActions()
|
Inherited from
ActionbarComponent
|
Defined in
ActionbarComponent:79
|
Returns :
{}
|
currentID |
currentID()
|
Inherited from
ActionbarComponent
|
Defined in
ActionbarComponent:67
|
Returns :
any
|
getPath |
getPath()
|
Inherited from
ActionbarComponent
|
Defined in
ActionbarComponent:107
|
Returns :
any
|
Async loadActions | |||||||||
loadActions(actions, addToStack)
|
|||||||||
Inherited from
ActionbarComponent
|
|||||||||
Defined in
ActionbarComponent:83
|
|||||||||
Parameters :
Returns :
any
|
loadActionsBefore |
loadActionsBefore()
|
Inherited from
ActionbarComponent
|
Defined in
ActionbarComponent:56
|
Returns :
void
|
ngOnInit |
ngOnInit()
|
Inherited from
ActionbarComponent
|
Defined in
ActionbarComponent:63
|
Returns :
void
|
reset |
reset()
|
Inherited from
ActionbarComponent
|
Defined in
ActionbarComponent:74
|
Returns :
void
|
activate | ||||
activate(e)
|
||||
Inherited from
SelectComponent
|
||||
Defined in
SelectComponent:283
|
||||
Parameters :
Returns :
void
|
addItem | ||||||
addItem(item: Item
|
||||||
Inherited from
SelectComponent
|
||||||
Defined in
SelectComponent:166
|
||||||
Adds the given ite, emits add output if observed
Parameters :
Returns :
void
|
cancelDrag | ||||||||||||
cancelDrag(item, e, target)
|
||||||||||||
Inherited from
SelectComponent
|
||||||||||||
Defined in
SelectComponent:276
|
||||||||||||
is called when the drag stops in any kind of way.
Parameters :
Returns :
void
|
canRemove |
canRemove()
|
Inherited from
SelectComponent
|
Defined in
SelectComponent:298
|
Returns :
boolean
|
Public clickItem | ||||||
clickItem(item, e?)
|
||||||
Inherited from
SelectComponent
|
||||||
Defined in
SelectComponent:203
|
||||||
Is called when a selected item is clicked
Parameters :
Returns :
void
|
filterDropdownList | |||||||||
filterDropdownList(listComponent: ListComponent
|
|||||||||
Inherited from
SelectComponent
|
|||||||||
Defined in
SelectComponent:360
|
|||||||||
Parameters :
Returns :
void
|
focus | ||||
focus(e)
|
||||
Inherited from
SelectComponent
|
||||
Defined in
SelectComponent:219
|
||||
Parameters :
Returns :
void
|
focusSearchbar |
focusSearchbar()
|
Inherited from
SelectComponent
|
Defined in
SelectComponent:229
|
Returns :
void
|
getArray | ||||
getArray(value)
|
||||
Inherited from
SelectComponent
|
||||
Defined in
SelectComponent:175
|
||||
Parameters :
Returns :
any
|
getParentTree | ||||||||||||
getParentTree(el, tree: [])
|
||||||||||||
Inherited from
SelectComponent
|
||||||||||||
Defined in
SelectComponent:103
|
||||||||||||
Parameters :
Returns :
any
|
handleKey | ||||||
handleKey(e, list)
|
||||||
Inherited from
SelectComponent
|
||||||
Defined in
SelectComponent:302
|
||||||
Parameters :
Returns :
void
|
hasSoloSelection |
hasSoloSelection()
|
Inherited from
SelectComponent
|
Defined in
SelectComponent:225
|
Returns :
boolean
|
initSelection |
initSelection()
|
Inherited from
SelectComponent
|
Defined in
SelectComponent:119
|
creates the collection from the config
Returns :
void
|
Public listItemClicked | ||||||
listItemClicked(item, list?)
|
||||||
Inherited from
SelectComponent
|
||||||
Defined in
SelectComponent:210
|
||||||
Select handler. Toggles selection.
Parameters :
Returns :
void
|
ngOnChanges |
ngOnChanges()
|
Inherited from
SelectComponent
|
Defined in
SelectComponent:114
|
Returns :
void
|
ngOnInit |
ngOnInit()
|
Inherited from
SelectComponent
|
Defined in
SelectComponent:110
|
Returns :
void
|
onChange |
onChange()
|
Inherited from
SelectComponent
|
Defined in
SelectComponent:236
|
Fires on selection change. Hides dropdown if solo
Returns :
void
|
onDragStart | ||||||||||||
onDragStart(item, e, target)
|
||||||||||||
Inherited from
SelectComponent
|
||||||||||||
Defined in
SelectComponent:257
|
||||||||||||
is called when an element is dragged by the user. hides element in selection
Parameters :
Returns :
void
|
onDrop | ||||
onDrop(e)
|
||||
Inherited from
SelectComponent
|
||||
Defined in
SelectComponent:264
|
||||
called when the element is dropped. moves item in selection.
Parameters :
Returns :
void
|
preventDefault | ||||
preventDefault(e)
|
||||
Inherited from
SelectComponent
|
||||
Defined in
SelectComponent:292
|
||||
Parameters :
Returns :
void
|
registerOnChange | ||||
registerOnChange(fn)
|
||||
Inherited from
SelectComponent
|
||||
Defined in
SelectComponent:250
|
||||
registers change method. (handled by angular)
Parameters :
Returns :
void
|
registerOnTouched |
registerOnTouched()
|
Inherited from
SelectComponent
|
Defined in
SelectComponent:254
|
Returns :
void
|
removeItem | |||||||||
removeItem(item: Item
|
|||||||||
Inherited from
SelectComponent
|
|||||||||
Defined in
SelectComponent:153
|
|||||||||
Removes the given item from selection
Parameters :
Returns :
void
|
setDisabledState | ||||
setDisabledState(isDisabled)
|
||||
Inherited from
SelectComponent
|
||||
Defined in
SelectComponent:371
|
||||
Parameters :
Returns :
void
|
use | |||||||||
use(value, event)
|
|||||||||
Inherited from
SelectComponent
|
|||||||||
Defined in
SelectComponent:180
|
|||||||||
Uses the given value as selection items
Parameters :
Returns :
void
|
useConfig | ||||||||
useConfig(config: ListConfig
|
||||||||
Inherited from
SelectComponent
|
||||||||
Defined in
SelectComponent:196
|
||||||||
Initializes either with values, collection or list. Creates Selection with config.
Parameters :
Returns :
void
|
writeValue | ||||||
writeValue(value: any)
|
||||||
Inherited from
SelectComponent
|
||||||
Defined in
SelectComponent:148
|
||||||
Called when the model changes
Parameters :
Returns :
void
|
Public cdr |
Type : ChangeDetectorRef
|
Public elementRef |
Type : ElementRef
|
Public notificationService |
Type : NotificationsService
|
Public resourceConfig |
Type : ResourceConfig
|
Public sdk |
Type : SdkService
|
Public cdr |
Type : ChangeDetectorRef
|
Inherited from
ResourceActionbarComponent
|
Defined in
ResourceActionbarComponent:34
|
Public elementRef |
Type : ElementRef
|
Inherited from
ResourceActionbarComponent
|
Defined in
ResourceActionbarComponent:33
|
Public notificationService |
Type : NotificationsService
|
Inherited from
ResourceActionbarComponent
|
Defined in
ResourceActionbarComponent:30
|
Public resourceConfig |
Type : ResourceConfig
|
Inherited from
ResourceActionbarComponent
|
Defined in
ResourceActionbarComponent:32
|
Public sdk |
Type : SdkService
|
Inherited from
ResourceActionbarComponent
|
Defined in
ResourceActionbarComponent:31
|
state |
Type : ResourceActionbarState
|
Inherited from
ResourceActionbarComponent
|
Defined in
ResourceActionbarComponent:22
|
actionStack |
Type : literal type
|
Default value : {}
|
Inherited from
ActionbarComponent
|
Defined in
ActionbarComponent:34
|
Public cdr |
Type : ChangeDetectorRef
|
Inherited from
ActionbarComponent
|
Defined in
ActionbarComponent:36
|
Public elementRef |
Type : ElementRef
|
Inherited from
ActionbarComponent
|
Defined in
ActionbarComponent:36
|
Public cdr |
Type : ChangeDetectorRef
|
Inherited from
SelectComponent
|
Defined in
SelectComponent:90
|
dragged |
Type : Item<T>
|
Inherited from
SelectComponent
|
Defined in
SelectComponent:46
|
the current dragged element |
dropdown |
Type : PopComponent
|
Decorators :
@ViewChild('dropdown', {static: true})
|
Inherited from
SelectComponent
|
Defined in
SelectComponent:78
|
The selection dropdown |
dropdownList |
Type : ListComponent<any>
|
Decorators :
@ViewChild(ListComponent, {static: true})
|
Inherited from
SelectComponent
|
Defined in
SelectComponent:82
|
The list in the dropdown |
dropdownLoader |
Type : LoaderComponent
|
Decorators :
@ViewChild('dropdownLoader', {static: true})
|
Inherited from
SelectComponent
|
Defined in
SelectComponent:80
|
The loader inside the dropdown |
Public elementRef |
Type : ElementRef
|
Inherited from
SelectComponent
|
Defined in
SelectComponent:90
|
propagateChange |
Default value : () => {...}
|
Inherited from
SelectComponent
|
Defined in
SelectComponent:248
|
Propagates formControl/ngModel changes |
searchbar |
Type : SearchbarComponent
|
Decorators :
@ViewChild(SearchbarComponent)
|
Inherited from
SelectComponent
|
Defined in
SelectComponent:84
|
The nested searchbar |
toggleItem |
Type : Subject<Item<T>>
|
Default value : new Subject()
|
Inherited from
SelectComponent
|
Defined in
SelectComponent:86
|
Subject that is nexted when an item is being selected (clicked or entered on) |
import { ChangeDetectorRef, Component, ElementRef, Input, OnInit } from '@angular/core';
import { Action, ActionbarComponent, ActionFunction, NotificationsService, selectTemplate } from '@ec.components/ui';
import Core from 'ec.sdk/lib/Core';
import { ResourceConfig } from '../resource-config/resource-config.service';
import { SdkService } from '../sdk/sdk.service';
import { ResourceActionbarComponent } from './resource-actionbar.component';
@Component({
selector: 'ec-api-actionbar',
template: selectTemplate,
})
export class ApiActionbarComponent extends ResourceActionbarComponent implements OnInit {
@Input() actions: Action[] = [
{
id: 'data',
title: 'Datamanager',
action: (item, actionbar) =>
this.loadResourceListActions({
api: this.sdk.datamanager,
relation: 'dataManager',
actionbar,
action: (dm) => {
this.sdk.useDatamanager(dm.shortID);
actionbar.loadActions([
this.resourceAction({
actionbar,
title: 'Models',
relation: 'model',
api: dm,
action: (model) =>
actionbar.loadActions([
{
id: 'entry',
title: 'Entries',
action: () => {
this.sdk.api.entryList(model.title).then((entryList) => {
const actions = entryList.getAllItems().map((listEntry) => {
return {
title: listEntry._entryTitle,
id: listEntry.id,
data: listEntry,
action: (entryItem) => {
const path = this.getPath().join('/');
this.openInEditor(path);
},
};
});
actionbar.loadActions(actions);
});
},
},
{
id: 'edit',
title: 'Edit Model',
action: () => {
const path = this.getPath().join('/');
this.openInEditor(path);
},
},
]),
}),
this.resourceAction({
actionbar,
title: 'Asset Group',
relation: 'assetGroup',
path: 'asset-group',
api: dm,
action: () => this.openCurrentPath(),
}),
this.resourceAction({
actionbar,
title: 'Datamanager Accounts',
relation: 'dmAccount',
api: dm,
action: () => this.openCurrentPath(),
}),
{
title: 'Edit',
id: 'edit',
action: () => this.openCurrentPath(),
},
]);
},
}),
},
{
id: 'accounts',
title: 'Account Server',
action: (item, actionbar) =>
this.loadApiRelationActions(this.sdk.accounts, actionbar, () => this.openCurrentPath()),
},
];
constructor(
public notificationService: NotificationsService,
public sdk: SdkService,
public resourceConfig: ResourceConfig,
public elementRef: ElementRef,
public cdr: ChangeDetectorRef,
) {
super(notificationService, sdk, resourceConfig, elementRef, cdr);
}
loadApiRelationActions(api: Core, actionbar: ActionbarComponent = this, action?: ActionFunction) {
const actions = Object.keys(api.getAvailableRelations()).map((relationName) => ({
id: relationName,
title: relationName,
relation: relationName,
action: (item) => {
this.loadResourceListActions({ api, relation: relationName, actionbar, action });
},
}));
actionbar.loadActions(actions);
}
openCurrentPath() {
const path = this.getPath().join('/');
this.openInEditor(path);
}
openInEditor(path, env = 'stage') {
window.open(`https://localhost:4200/${env}/${path}`, '_blank');
}
ngOnInit() {
this.loadActions(this.actions);
}
}