This commit is contained in:
Niels Lyngsø
2024-02-28 13:34:22 +01:00
parent 20284d60cf
commit 0e845941d4

View File

@@ -16,7 +16,6 @@ import { UmbSorterController } from '@umbraco-cms/backoffice/sorter';
@customElement('umb-document-type-workspace-view-edit-tab')
export class UmbDocumentTypeWorkspaceViewEditTabElement extends UmbLitElement {
#model: Array<UmbPropertyTypeContainerModel> = [];
#sorter = new UmbSorterController<UmbPropertyTypeContainerModel, UmbDocumentTypeWorkspaceViewEditPropertiesElement>(
this,
{
@@ -27,15 +26,15 @@ export class UmbDocumentTypeWorkspaceViewEditTabElement extends UmbLitElement {
itemSelector: '.container-handle',
containerSelector: '.container-list',
onChange: ({ model }) => {
console.log('change groups model');
this._groups = model;
this.#model = model;
},
onEnd: ({ item }) => {
/** Explanation: If the item is the first in list, we compare it to the item behind it to set a sortOrder.
* If it's not the first in list, we will compare to the item in before it, and check the following item to see if it caused overlapping sortOrder, then update
* the overlap if true, which may cause another overlap, so we loop through them till no more overlaps...
*/
const model = this.#model;
const model = this._groups;
const newIndex = model.findIndex((entry) => entry.id === item.id);
// Doesn't exist in model
@@ -130,11 +129,10 @@ export class UmbDocumentTypeWorkspaceViewEditTabElement extends UmbLitElement {
(context as UmbDocumentTypeWorkspaceContext).isSorting,
(isSorting) => {
this._sortModeActive = isSorting;
if (isSorting) {
this.#sorter.setModel(this._groups);
this.#sorter.enable();
} else {
this.#sorter.setModel([]);
this.#sorter.disable();
}
},
'_observeIsSorting',
@@ -142,11 +140,7 @@ export class UmbDocumentTypeWorkspaceViewEditTabElement extends UmbLitElement {
});
this.observe(this._groupStructureHelper.containers, (groups) => {
this._groups = groups;
if (this._sortModeActive) {
this.#sorter.setModel(this._groups);
} else {
this.#sorter.setModel([]);
}
this.#sorter.setModel(this._groups);
this.requestUpdate('_groups');
});
this.observe(this._groupStructureHelper.hasProperties, (hasProperties) => {