|
|
|
@ -37,7 +37,7 @@ import { Direction, SortOrder } from '@shared/models/page/sort-order'; |
|
|
|
import { MatPaginator } from '@angular/material/paginator'; |
|
|
|
import { MatSort } from '@angular/material/sort'; |
|
|
|
import { fromEvent, merge } from 'rxjs'; |
|
|
|
import { debounceTime, distinctUntilChanged, tap } from 'rxjs/operators'; |
|
|
|
import { debounceTime, distinctUntilChanged, first, tap } from 'rxjs/operators'; |
|
|
|
import { |
|
|
|
toWidgetActionDescriptor, |
|
|
|
WidgetActionCallbacks, |
|
|
|
@ -54,6 +54,7 @@ import { |
|
|
|
import { deepClone } from '@core/utils'; |
|
|
|
import { ResizeObserver } from '@juggle/resize-observer'; |
|
|
|
import { hidePageSizePixelValue } from '@shared/models/constants'; |
|
|
|
import { CdkDragDrop, moveItemInArray } from '@angular/cdk/drag-drop'; |
|
|
|
|
|
|
|
@Component({ |
|
|
|
selector: 'tb-manage-widget-actions', |
|
|
|
@ -85,6 +86,7 @@ export class ManageWidgetActionsComponent extends PageComponent implements OnIni |
|
|
|
|
|
|
|
viewsInited = false; |
|
|
|
dirtyValue = false; |
|
|
|
dragDisabled = true; |
|
|
|
|
|
|
|
private widgetResize$: ResizeObserver; |
|
|
|
|
|
|
|
@ -106,7 +108,7 @@ export class ManageWidgetActionsComponent extends PageComponent implements OnIni |
|
|
|
const sortOrder: SortOrder = { property: 'actionSourceName', direction: Direction.ASC }; |
|
|
|
this.pageLink = new PageLink(10, 0, null, sortOrder); |
|
|
|
this.dataSource = new WidgetActionsDatasource(this.translate, this.utils); |
|
|
|
this.displayedColumns = ['actionSourceName', 'name', 'icon', 'typeName', 'actions']; |
|
|
|
this.displayedColumns = ['actionSourceId', 'actionSourceName', 'name', 'icon', 'typeName', 'actions']; |
|
|
|
} |
|
|
|
|
|
|
|
ngOnInit(): void { |
|
|
|
@ -163,6 +165,23 @@ export class ManageWidgetActionsComponent extends PageComponent implements OnIni |
|
|
|
this.dataSource.loadActions(this.pageLink, reload); |
|
|
|
} |
|
|
|
|
|
|
|
dropAction(event: CdkDragDrop<WidgetActionsDatasource>) { |
|
|
|
this.dragDisabled = true; |
|
|
|
const droppedAction: WidgetActionDescriptorInfo = event.item.data; |
|
|
|
this.dataSource.pageData$.pipe( |
|
|
|
first() |
|
|
|
).subscribe((actions) => { |
|
|
|
const action = actions.data; |
|
|
|
let startActionSourceIndex = action.findIndex(element => element.actionSourceId === droppedAction.actionSourceId); |
|
|
|
const targetActions = this.getOrCreateTargetActions(droppedAction.actionSourceId); |
|
|
|
if (startActionSourceIndex === 0) { |
|
|
|
startActionSourceIndex -= targetActions.findIndex(element => element.id === action[0].id); |
|
|
|
} |
|
|
|
moveItemInArray(targetActions, event.previousIndex - startActionSourceIndex, event.currentIndex - startActionSourceIndex); |
|
|
|
this.onActionsUpdated(); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
addAction($event: Event) { |
|
|
|
this.openWidgetActionDialog($event); |
|
|
|
} |
|
|
|
|