Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export class UmbBlockGridAreaConfigEntryElement extends UmbLitElement implements
<uui-icon name="icon-remove"></uui-icon>
</uui-button>
</uui-action-bar>
<umb-block-scale-handler @mousedown=${(e: MouseEvent) => this.#context.scaleManager.onScaleMouseDown(e)}>
<umb-block-scale-handler @mouseup=${(e: MouseEvent) => this.#context.scaleManager.onScaleMouseDown(e)}>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would make sense to rename onScaleMouseDown function, eventually something independant of event type.

I wounder if is can use the similar feature on image cropper focalpoint, which handle both mouse and touch event.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably in another PR, onScaleMouseDown already existed, but it seems it still has problems. Thanks for reviewing

${this._columnSpan}x${this._rowSpan}
</umb-block-scale-handler>
`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ import { UMB_BLOCK_GRID_DEFAULT_LAYOUT_STYLESHEET, type UmbBlockGridTypeAreaType
import { UMB_BLOCK_GRID_AREA_TYPE_WORKSPACE_MODAL } from '../../components/block-grid-area-config-entry/constants.js';
import { UmbBlockGridAreaTypeEntriesContext } from './block-grid-area-type-entries.context.js';
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
import { html, customElement, property, state, repeat } from '@umbraco-cms/backoffice/external/lit';
import { html, customElement, property, state, repeat,css } from '@umbraco-cms/backoffice/external/lit';
import type {
UmbPropertyEditorUiElement,
UmbPropertyEditorConfigCollection,
} from '@umbraco-cms/backoffice/property-editor';
import { UMB_PROPERTY_DATASET_CONTEXT } from '@umbraco-cms/backoffice/property';
import { UmbModalRouteRegistrationController } from '@umbraco-cms/backoffice/router';
import { incrementString } from '@umbraco-cms/backoffice/utils';
import { UmbTextStyles } from '@umbraco-cms/backoffice/style';

import '../../components/block-grid-area-config-entry/block-grid-area-config-entry.element.js';
@customElement('umb-property-editor-ui-block-grid-areas-config')
Expand Down Expand Up @@ -53,6 +54,9 @@ export class UmbPropertyEditorUIBlockGridAreasConfigElement
@state()
private _areaGridColumns?: number;

@state()
private _draggedIndex?: number = undefined;

constructor() {
super();

Expand Down Expand Up @@ -112,7 +116,19 @@ export class UmbPropertyEditorUIBlockGridAreasConfigElement
return alias;
}

#handleDrop(targetIndex: number) {
if (!this._draggedIndex || this._draggedIndex === targetIndex) return;

const newValue = [...this.value];
const [movedItem] = newValue.splice(this._draggedIndex, 1);
newValue.splice(targetIndex, 0, movedItem);

this.value = newValue;
this._draggedIndex = undefined;
}

override render() {

return this._areaGridColumns
? html`${this._styleElement}
<div
Expand All @@ -122,17 +138,33 @@ export class UmbPropertyEditorUIBlockGridAreasConfigElement
${repeat(
this.value,
(area) => area.key,
(area) =>
(area, index) =>
html`<umb-block-area-config-entry
class="umb-block-grid__area"
draggable="true"
.workspacePath=${this._workspacePath}
.areaGridColumns=${this._areaGridColumns}
@dragstart=${(e: any) => {
this._draggedIndex = index;
e.dataTransfer.effectAllowed = 'move';
}}
@dragover=${(e: any) => e.preventDefault()}
@drop=${() => this.#handleDrop(index)}
.key=${area.key}></umb-block-area-config-entry>`,
)}
</div>
<uui-button look="placeholder" label=${'Add area'} href=${this._workspacePath + 'create'}></uui-button>`
: '';
}

static override styles = [
UmbTextStyles,
css`
.umb-block-grid__area{
cursor: move;
}
`
]
}

export default UmbPropertyEditorUIBlockGridAreasConfigElement;
Expand Down
Loading