remove hacky check for children

This commit is contained in:
Mads Rasmussen
2023-12-12 20:13:16 +01:00
parent 89de262b08
commit 2cf7783724
8 changed files with 22 additions and 63 deletions

View File

@@ -13,19 +13,6 @@ export class UmbFileSystemTreeItemContext extends UmbTreeItemContextBase<UmbFile
super(host, (x: UmbFileSystemTreeItemModel) => x.path);
}
//TODO: this is not a nice solution! There should be a better way to distinguish in the tree between folders and files. Additionally we need to be able to register an action only on empty folder.
checkIfIsFolder() {
const treeItem = this.getTreeItem();
if (treeItem?.isFolder) {
if (treeItem.hasChildren) {
this.entityType = `${this.getTreeItem()?.entityType}-folder`;
} else {
this.entityType = `${this.getTreeItem()?.entityType}-folder-empty`;
}
}
}
constructPath(pathname: string, entityType: string, path: string) {
return `section/${pathname}/workspace/${entityType}/edit/${encodeURIComponent(path).replace('.', '-')}`;
}

View File

@@ -39,7 +39,6 @@ export class UmbFileSystemTreeItemElement extends UmbLitElement implements UmbTr
public set item(value: UmbFileSystemTreeItemModel | undefined) {
this._item = value;
this.#context.setTreeItem(value);
this.#context.checkIfIsFolder();
}
#context = new UmbFileSystemTreeItemContext(this);

View File

@@ -1,6 +1,5 @@
import {
UMB_PARTIAL_VIEW_ENTITY_TYPE,
UMB_PARTIAL_VIEW_FOLDER_EMPTY_ENTITY_TYPE,
UMB_PARTIAL_VIEW_FOLDER_ENTITY_TYPE,
UMB_PARTIAL_VIEW_ROOT_ENTITY_TYPE,
} from '../entity.js';
@@ -24,7 +23,7 @@ const partialViewActions: Array<ManifestEntityAction> = [
api: UmbDeleteEntityAction,
meta: {
icon: 'icon-trash',
label: 'Delete',
label: 'Delete...',
repositoryAlias: UMB_PARTIAL_VIEW_REPOSITORY_ALIAS,
entityTypes: [UMB_PARTIAL_VIEW_ENTITY_TYPE],
},
@@ -61,29 +60,25 @@ const partialViewFolderActions: Array<ManifestEntityAction> = [
{
type: 'entityAction',
alias: 'Umb.EntityAction.PartialViewFolder.DeleteFolder',
name: 'Remove empty folder',
name: 'Delete Partial View Folder',
api: UmbDeleteFolderEntityAction,
meta: {
icon: 'icon-trash',
label: 'Remove folder',
label: 'Delete folder...',
repositoryAlias: UMB_PARTIAL_VIEW_REPOSITORY_ALIAS,
entityTypes: [UMB_PARTIAL_VIEW_FOLDER_EMPTY_ENTITY_TYPE],
entityTypes: [UMB_PARTIAL_VIEW_FOLDER_ENTITY_TYPE],
},
},
{
type: 'entityAction',
alias: 'Umb.EntityAction.PartialViewFolder.CreateFolder',
name: 'Create empty folder',
name: 'Create Partial View folder',
api: UmbCreateFolderEntityAction,
meta: {
icon: 'icon-add',
label: 'Create folder',
label: 'Create folder...',
repositoryAlias: UMB_PARTIAL_VIEW_REPOSITORY_ALIAS,
entityTypes: [
UMB_PARTIAL_VIEW_FOLDER_EMPTY_ENTITY_TYPE,
UMB_PARTIAL_VIEW_FOLDER_ENTITY_TYPE,
UMB_PARTIAL_VIEW_ROOT_ENTITY_TYPE,
],
entityTypes: [UMB_PARTIAL_VIEW_FOLDER_ENTITY_TYPE, UMB_PARTIAL_VIEW_ROOT_ENTITY_TYPE],
},
},
];

View File

@@ -1,4 +1,3 @@
export const UMB_PARTIAL_VIEW_ENTITY_TYPE = 'partial-view';
export const UMB_PARTIAL_VIEW_ROOT_ENTITY_TYPE = 'partial-view-root';
export const UMB_PARTIAL_VIEW_FOLDER_ENTITY_TYPE = 'partial-view-folder';
export const UMB_PARTIAL_VIEW_FOLDER_EMPTY_ENTITY_TYPE = 'partial-view-folder-empty';

View File

@@ -1,10 +1,5 @@
import { UMB_SCRIPT_REPOSITORY_ALIAS } from '../repository/index.js';
import {
UMB_SCRIPT_ENTITY_TYPE,
UMB_SCRIPT_FOLDER_ENTITY_TYPE,
UMB_SCRIPT_ROOT_ENTITY_TYPE,
UMB_SCRIPT_FOLDER_EMPTY_ENTITY_TYPE,
} from '../entity.js';
import { UMB_SCRIPT_ENTITY_TYPE, UMB_SCRIPT_FOLDER_ENTITY_TYPE, UMB_SCRIPT_ROOT_ENTITY_TYPE } from '../entity.js';
import { UmbCreateScriptAction } from './create/create-empty.action.js';
import {
UmbCreateFolderEntityAction,
@@ -43,31 +38,31 @@ const scriptFolderActions: Array<ManifestEntityAction> = [
icon: 'icon-article',
label: 'New empty script',
repositoryAlias: UMB_SCRIPT_REPOSITORY_ALIAS,
entityTypes: [UMB_SCRIPT_FOLDER_ENTITY_TYPE, UMB_SCRIPT_FOLDER_EMPTY_ENTITY_TYPE, UMB_SCRIPT_ROOT_ENTITY_TYPE],
entityTypes: [UMB_SCRIPT_FOLDER_ENTITY_TYPE, UMB_SCRIPT_ROOT_ENTITY_TYPE],
},
},
{
type: 'entityAction',
alias: UMB_DELETE_SCRIPT_FOLDER_ENTITY_ACTION_ALIAS,
name: 'Remove empty folder',
name: 'Delete Script folder',
api: UmbDeleteFolderEntityAction,
meta: {
icon: 'icon-trash',
label: 'Remove folder',
label: 'Delete folder...',
repositoryAlias: UMB_SCRIPT_REPOSITORY_ALIAS,
entityTypes: [UMB_SCRIPT_FOLDER_EMPTY_ENTITY_TYPE],
entityTypes: [UMB_SCRIPT_FOLDER_ENTITY_TYPE],
},
},
{
type: 'entityAction',
alias: UMB_CREATE_SCRIPT_FOLDER_ENTITY_ACTION_ALIAS,
name: 'Create empty folder',
name: 'Create Script folder',
api: UmbCreateFolderEntityAction,
meta: {
icon: 'icon-add',
label: 'Create folder',
label: 'Create folder...',
repositoryAlias: UMB_SCRIPT_REPOSITORY_ALIAS,
entityTypes: [UMB_SCRIPT_FOLDER_EMPTY_ENTITY_TYPE, UMB_SCRIPT_FOLDER_ENTITY_TYPE, UMB_SCRIPT_ROOT_ENTITY_TYPE],
entityTypes: [UMB_SCRIPT_FOLDER_ENTITY_TYPE, UMB_SCRIPT_ROOT_ENTITY_TYPE],
},
},
];

View File

@@ -1,4 +1,3 @@
export const UMB_SCRIPT_ENTITY_TYPE = 'script';
export const UMB_SCRIPT_ROOT_ENTITY_TYPE = 'script-root';
export const UMB_SCRIPT_FOLDER_ENTITY_TYPE = 'script-folder';
export const UMB_SCRIPT_FOLDER_EMPTY_ENTITY_TYPE = 'script-folder-empty';

View File

@@ -1,6 +1,5 @@
import {
UMB_STYLESHEET_ENTITY_TYPE,
UMB_STYLESHEET_FOLDER_EMPTY_ENTITY_TYPE,
UMB_STYLESHEET_FOLDER_ENTITY_TYPE,
UMB_STYLESHEET_ROOT_ENTITY_TYPE,
} from '../entity.js';
@@ -45,11 +44,7 @@ const stylesheetFolderActions: Array<ManifestEntityAction> = [
icon: 'icon-script',
label: 'New stylesheet file',
repositoryAlias: UMB_STYLESHEET_REPOSITORY_ALIAS,
entityTypes: [
UMB_STYLESHEET_FOLDER_ENTITY_TYPE,
UMB_STYLESHEET_FOLDER_EMPTY_ENTITY_TYPE,
UMB_STYLESHEET_ROOT_ENTITY_TYPE,
],
entityTypes: [UMB_STYLESHEET_FOLDER_ENTITY_TYPE, UMB_STYLESHEET_ROOT_ENTITY_TYPE],
},
},
{
@@ -61,39 +56,31 @@ const stylesheetFolderActions: Array<ManifestEntityAction> = [
icon: 'icon-script',
label: 'New Rich Text Editor style sheet file',
repositoryAlias: UMB_STYLESHEET_REPOSITORY_ALIAS,
entityTypes: [
UMB_STYLESHEET_FOLDER_ENTITY_TYPE,
UMB_STYLESHEET_FOLDER_EMPTY_ENTITY_TYPE,
UMB_STYLESHEET_ROOT_ENTITY_TYPE,
],
entityTypes: [UMB_STYLESHEET_FOLDER_ENTITY_TYPE, UMB_STYLESHEET_ROOT_ENTITY_TYPE],
},
},
{
type: 'entityAction',
alias: 'Umb.EntityAction.Stylesheet.Folder.DeleteFolder',
name: 'Remove empty folder',
name: 'Delete folder...',
api: UmbDeleteFolderEntityAction,
meta: {
icon: 'icon-trash',
label: 'Remove folder',
label: 'Delete folder',
repositoryAlias: UMB_STYLESHEET_REPOSITORY_ALIAS,
entityTypes: [UMB_STYLESHEET_FOLDER_EMPTY_ENTITY_TYPE],
entityTypes: [UMB_STYLESHEET_FOLDER_ENTITY_TYPE],
},
},
{
type: 'entityAction',
alias: 'Umb.EntityAction.Stylesheet.Folder.CreateFolder',
name: 'Create empty folder',
name: 'Create folder...',
api: UmbCreateFolderEntityAction,
meta: {
icon: 'icon-add',
label: 'Create folder',
repositoryAlias: UMB_STYLESHEET_REPOSITORY_ALIAS,
entityTypes: [
UMB_STYLESHEET_FOLDER_EMPTY_ENTITY_TYPE,
UMB_STYLESHEET_FOLDER_ENTITY_TYPE,
UMB_STYLESHEET_ROOT_ENTITY_TYPE,
],
entityTypes: [UMB_STYLESHEET_FOLDER_ENTITY_TYPE, UMB_STYLESHEET_ROOT_ENTITY_TYPE],
},
},
];

View File

@@ -1,5 +1,3 @@
export const UMB_STYLESHEET_ENTITY_TYPE = 'stylesheet';
export const UMB_STYLESHEET_ROOT_ENTITY_TYPE = 'stylesheet-root';
export const UMB_STYLESHEET_FOLDER_ENTITY_TYPE = 'stylesheet-folder';
export const UMB_STYLESHEET_FOLDER_EMPTY_ENTITY_TYPE = 'stylesheet-folder-empty';