Skip to content

Commit

Permalink
feat: Moved external item drag and drop functionality to component di…
Browse files Browse the repository at this point in the history
…rectory
  • Loading branch information
siarheihuzarevich committed Aug 23, 2024
1 parent 55a4070 commit 8b9dbb1
Show file tree
Hide file tree
Showing 19 changed files with 21 additions and 16 deletions.
2 changes: 1 addition & 1 deletion projects/f-flow/src/f-draggable/f-draggable-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import {
PointExtensions
} from '@foblex/core';
import { Directive, EventEmitter, InjectionToken, } from '@angular/core';
import { FCreateNodeEvent } from './external-item';
import { FCreateConnectionEvent, FReassignConnectionEvent } from './connections';
import { FSelectionChangeEvent } from './f-selection-change-event';
import { ICanRunOutsideAngular } from './i-can-run-outside-angular';
import { FCreateNodeEvent } from '../f-external-item';

export const F_DRAGGABLE = new InjectionToken<FDraggableBase>('F_DRAGGABLE');

Expand Down
8 changes: 6 additions & 2 deletions projects/f-flow/src/f-draggable/f-draggable.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { F_DRAGGABLE, FDraggableBase } from './f-draggable-base';
import { FComponentsStore } from '../f-storage';
import { FDraggableDataContext } from './f-draggable-data-context';
import { Subscription } from 'rxjs';
import { FCreateNodeEvent, ExternalItemPreparationRequest, ExternalItemFinalizeRequest } from './external-item';
import { IPointerEvent, Point } from '@foblex/core';
import { NodeMoveFinalizeRequest, NodeMovePreparationRequest } from './node';
import { CanvasMoveFinalizeRequest, CanvasMovePreparationRequest } from './canvas';
Expand All @@ -28,7 +27,12 @@ import {
import { FSelectionChangeEvent } from './f-selection-change-event';
import { FFlowMediator } from '../infrastructure';
import { EmitTransformChangesRequest, GetSelectionRequest } from '../domain';
import { isExternalItem } from '../f-external-item';
import {
ExternalItemFinalizeRequest,
ExternalItemPreparationRequest,
FCreateNodeEvent,
isExternalItem
} from '../f-external-item';
import { SingleSelectRequest } from './single-select';
import { NodeResizeFinalizeRequest, NodeResizePreparationRequest } from './node-resize';
import { SelectionAreaFinalizeRequest, SelectionAreaPreparationRequest } from './selection-area';
Expand Down
2 changes: 0 additions & 2 deletions projects/f-flow/src/f-draggable/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ export * from './canvas';

export * from './connections';

export * from './external-item';

export * from './node';

export * from './node-resize';
Expand Down
4 changes: 2 additions & 2 deletions projects/f-flow/src/f-draggable/providers.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { CANVAS_PROVIDERS } from './canvas';
import { CONNECTIONS_PROVIDERS } from './connections';
import { SINGLE_SELECT_PROVIDERS } from './single-select';
import { EXTERNAL_ITEM_PROVIDERS } from './external-item';
import { NODE_PROVIDERS } from './node';
import { NODE_RESIZE_PROVIDERS } from './node-resize';
import { SELECTION_AREA_PROVIDERS } from './selection-area';
import { F_MINIMAP_DRAG_AND_DROP_PROVIDERS } from '../f-minimap/domain/providers';
import { F_EXTERNAL_ITEM_DRAG_AND_DROP_PROVIDERS } from '../f-external-item/domain/providers';

export const F_DRAGGABLE_PROVIDERS = [

Expand All @@ -15,7 +15,7 @@ export const F_DRAGGABLE_PROVIDERS = [

...SINGLE_SELECT_PROVIDERS,

...EXTERNAL_ITEM_PROVIDERS,
...F_EXTERNAL_ITEM_DRAG_AND_DROP_PROVIDERS,

...NODE_PROVIDERS,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { ExternalItemFinalizeRequest } from './external-item-finalize.request';
import { IPoint, IRect } from '@foblex/core';
import { FExecutionRegister, FFlowMediator, IExecution } from '../../../infrastructure';
import { FComponentsStore } from '../../../f-storage';
import { FDraggableDataContext } from '../../f-draggable-data-context';
import { ExternalItemDragHandler } from '../external-item.drag-handler';
import { FCreateNodeEvent } from '../f-create-node.event';
import { GetElementRectInFlowRequest } from '../../../domain';
import { FDraggableDataContext } from '../../../f-draggable';

@Injectable()
@FExecutionRegister(ExternalItemFinalizeRequest)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Injectable } from '@angular/core';
import { ExternalItemFinalizeRequest } from './external-item-finalize.request';
import { FValidatorRegister, IValidator } from '../../../infrastructure';
import { EFDraggableType } from '../../e-f-draggable-type';
import { FDraggableDataContext } from '../../f-draggable-data-context';
import { FDraggableDataContext } from '../../../f-draggable';
import { ExternalItemDragHandler } from '../external-item.drag-handler';


@Injectable()
@FValidatorRegister(ExternalItemFinalizeRequest)
Expand All @@ -14,7 +15,8 @@ export class ExternalItemFinalizeValidator implements IValidator<ExternalItemFin
}

public handle(request: ExternalItemFinalizeRequest): boolean {
return this.fDraggableDataContext.draggableItems.some((x) =>
x.type === EFDraggableType.PALETTE_ITEM);
return this.fDraggableDataContext.draggableItems.some(
(x) => x.constructor.name === ExternalItemDragHandler.name
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { ExternalItemPreparationRequest } from './external-item-preparation.requ
import { Point } from '@foblex/core';
import { FExecutionRegister, IExecution } from '../../../infrastructure';
import { FComponentsStore } from '../../../f-storage';
import { FDraggableDataContext } from '../../f-draggable-data-context';
import { FExternalItemBase, FExternalItemService, getExternalItem } from '../../../f-external-item';
import { ExternalItemDragHandler } from '../external-item.drag-handler';
import { FDraggableDataContext } from '../../../f-draggable';

@Injectable()
@FExecutionRegister(ExternalItemPreparationRequest)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { DomElementExtensions, IPoint, IRect, Point, PointExtensions, RectExtensions } from '@foblex/core';
import { IDraggableItem } from '../i-draggable-item';
import { EFDraggableType } from '../e-f-draggable-type';
import { FExternalItemBase } from '../../f-external-item';
import { EFDraggableType, IDraggableItem } from '../../f-draggable';

export class ExternalItemDragHandler implements IDraggableItem {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { EXTERNAL_ITEM_PREPARATION_PROVIDERS } from './external-item-preparation';
import { EXTERNAL_ITEM_FINALIZE_PROVIDERS } from './external-item-finalize';

export const EXTERNAL_ITEM_PROVIDERS = [
export const F_EXTERNAL_ITEM_DRAG_AND_DROP_PROVIDERS = [

...EXTERNAL_ITEM_FINALIZE_PROVIDERS,

Expand Down
2 changes: 2 additions & 0 deletions projects/f-flow/src/f-external-item/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export * from './domain';

export * from './f-external-item-base';

export * from './is-external-item';
Expand Down

0 comments on commit 8b9dbb1

Please sign in to comment.