From 8271b0534bc45c195ba72505f070bb548597cb44 Mon Sep 17 00:00:00 2001 From: Vladyslav_Prykhodko Date: Wed, 2 Nov 2022 16:55:33 +0200 Subject: [PATCH] UI: Clear code and change style --- .../home/components/home-components.module.ts | 5 +-- .../manage-widget-actions.component.html | 35 +++++++++++++------ .../manage-widget-actions.component.scss | 13 +++++++ .../action/manage-widget-actions.component.ts | 8 +++-- .../assets/locale/locale.constant-en_US.json | 1 - 5 files changed, 43 insertions(+), 19 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/home-components.module.ts b/ui-ngx/src/app/modules/home/components/home-components.module.ts index c7ee635dae..7cfcf269de 100644 --- a/ui-ngx/src/app/modules/home/components/home-components.module.ts +++ b/ui-ngx/src/app/modules/home/components/home-components.module.ts @@ -173,7 +173,6 @@ import { RateLimitsDetailsDialogComponent } from '@home/components/profile/tenan import { AssetProfileComponent } from '@home/components/profile/asset-profile.component'; import { AssetProfileDialogComponent } from '@home/components/profile/asset-profile-dialog.component'; import { AssetProfileAutocompleteComponent } from '@home/components/profile/asset-profile-autocomplete.component'; -import { DragDropModule } from '@angular/cdk/drag-drop'; @NgModule({ declarations: @@ -322,7 +321,6 @@ import { DragDropModule } from '@angular/cdk/drag-drop'; imports: [ CommonModule, SharedModule, - DragDropModule, SharedHomeComponentsModule, WidgetSettingsModule, Lwm2mProfileComponentsModule, @@ -455,8 +453,7 @@ import { DragDropModule } from '@angular/cdk/drag-drop'; RateLimitsListComponent, RateLimitsComponent, RateLimitsTextComponent, - RateLimitsDetailsDialogComponent, - DragDropModule + RateLimitsDetailsDialogComponent ], providers: [ WidgetComponentService, diff --git a/ui-ngx/src/app/modules/home/components/widget/action/manage-widget-actions.component.html b/ui-ngx/src/app/modules/home/components/widget/action/manage-widget-actions.component.html index 81ccd42da0..be94218f4a 100644 --- a/ui-ngx/src/app/modules/home/components/widget/action/manage-widget-actions.component.html +++ b/ui-ngx/src/app/modules/home/components/widget/action/manage-widget-actions.component.html @@ -59,36 +59,49 @@
- + cdkDropList cdkDropListOrientation="vertical" + [cdkDropListData]="dataSource" + (cdkDropListDropped)="dropAction($event)" + [cdkDropListDisabled]="dragDisabled" + class="tb-drop-list"> - {{ 'widget-config.action-source-order' | translate }} + - reorder +
+ drag_handle +
{{ 'widget-config.action-source' | translate }} - + {{ action.actionSourceName }} {{ 'widget-config.action-name' | translate }} - + {{ action.name }} - {{ 'widget-config.action-icon' | translate }} - + {{ 'widget-config.action-icon' | translate }} + {{ action.icon }} {{ 'widget-config.action-type' | translate }} - + {{ action.typeName }} @@ -114,8 +127,8 @@ - - +
diff --git a/ui-ngx/src/app/modules/home/components/widget/action/manage-widget-actions.component.scss b/ui-ngx/src/app/modules/home/components/widget/action/manage-widget-actions.component.scss index 0a4e22cea0..53c881df72 100644 --- a/ui-ngx/src/app/modules/home/components/widget/action/manage-widget-actions.component.scss +++ b/ui-ngx/src/app/modules/home/components/widget/action/manage-widget-actions.component.scss @@ -41,4 +41,17 @@ .mat-sort-header-sorted .mat-sort-header-arrow { opacity: 1 !important; } + + .tb-draggable { + &.cdk-drag-placeholder { + opacity: 0; + } + &.cdk-drag-preview { + box-sizing: border-box; + border-radius: 4px; + box-shadow: 0 5px 5px -3px rgba(0, 0, 0, 0.2), + 0 8px 10px 1px rgba(0, 0, 0, 0.14), + 0 3px 14px 2px rgba(0, 0, 0, 0.12); + } + } } diff --git a/ui-ngx/src/app/modules/home/components/widget/action/manage-widget-actions.component.ts b/ui-ngx/src/app/modules/home/components/widget/action/manage-widget-actions.component.ts index df9cdb4a04..8c329df938 100644 --- a/ui-ngx/src/app/modules/home/components/widget/action/manage-widget-actions.component.ts +++ b/ui-ngx/src/app/modules/home/components/widget/action/manage-widget-actions.component.ts @@ -54,7 +54,7 @@ import { import { deepClone } from '@core/utils'; import { ResizeObserver } from '@juggle/resize-observer'; import { hidePageSizePixelValue } from '@shared/models/constants'; -import {CdkDragDrop, moveItemInArray, CdkDragHandle} from '@angular/cdk/drag-drop'; +import { CdkDragDrop, moveItemInArray } from '@angular/cdk/drag-drop'; @Component({ selector: 'tb-manage-widget-actions', @@ -86,6 +86,7 @@ export class ManageWidgetActionsComponent extends PageComponent implements OnIni viewsInited = false; dirtyValue = false; + dragDisabled = true; private widgetResize$: ResizeObserver; @@ -164,7 +165,8 @@ export class ManageWidgetActionsComponent extends PageComponent implements OnIni this.dataSource.loadActions(this.pageLink, reload); } - dropAction(event: CdkDragDrop) { + dropAction(event: CdkDragDrop) { + this.dragDisabled = true; const droppedAction = event.item.data; this.dataSource.getAllActions().subscribe( (actions) => { @@ -183,7 +185,7 @@ export class ManageWidgetActionsComponent extends PageComponent implements OnIni } const targetActions = this.getOrCreateTargetActions(droppedAction.actionSourceId); - let oldIndex: number = -1; + let oldIndex = -1; let newIndex: number = nearestNeighbourAction ? -1 : (isBackward ? targetActions.length - 1 : 0); for (let i: number = isBackward ? targetActions.length - 1 : 0; diff --git a/ui-ngx/src/assets/locale/locale.constant-en_US.json b/ui-ngx/src/assets/locale/locale.constant-en_US.json index 878ee53d3b..061f042e44 100644 --- a/ui-ngx/src/assets/locale/locale.constant-en_US.json +++ b/ui-ngx/src/assets/locale/locale.constant-en_US.json @@ -3686,7 +3686,6 @@ "add-action": "Add action", "search-actions": "Search actions", "no-actions-text": "No actions found", - "action-source-order": "Order", "action-source": "Action source", "action-source-required": "Action source is required.", "action-name": "Name",