Mark Drake
05/30/2024, 11:30 PMnathanwoulfe
05/31/2024, 1:45 AMnathanwoulfe
05/31/2024, 1:45 AMMark Drake
05/31/2024, 1:56 AMnathanwoulfe
05/31/2024, 2:05 AMMark Drake
05/31/2024, 2:06 AMMark Drake
05/31/2024, 2:09 AMMark Drake
05/31/2024, 2:09 AMnathanwoulfe
05/31/2024, 2:10 AMMark Drake
06/02/2024, 2:06 AMMark Drake
06/02/2024, 7:41 PMMark Drake
06/02/2024, 7:43 PMKenneth Solberg
06/03/2024, 6:00 AMconst treeItem: ManifestTreeItem = {
type: 'treeItem',
alias: 'My.TreeItem.NameOfEntity',
name: 'Name Of Entity Tree Item',
element: () => import('./my-tree-item.element.js'),
api: () => import('./my-tree-item.context.js'),
forEntityTypes: ['my-entity-type'],
};
In the core we register a custom tree item for the Document (Content) tree, where we show a label based on the current variant, custom icons etc. I think this is the best place for inspiration at the moment:https://github.com/umbraco/Umbraco.CMS.Backoffice/tree/main/src/packages/documents/documents/tree/tree-itemMark Drake
06/03/2024, 3:02 PMimport { html, nothing, classMap } from "@umbraco-cms/backoffice/external/lit";
// Wait for the original class to be defined
customElements.whenDefined("umb-document-tree-item").then(() => {
// Get a reference to the original class
const originalClass = customElements.get("umb-document-tree-item");
// Patch the renderIconContainer method on the prototype
const originalRenderIconContainer = originalClass.prototype.renderIconContainer;
// Private properties
function getPrivateField(instance, fieldName) {
const privateField = Object.getOwnPropertySymbols(instance).find(symbol =>
symbol.toString().includes(fieldName)
);
return instance[privateField];
}
originalClass.prototype.renderIconContainer = function() {
const isDraft = getPrivateField(this, "#isDraft");
const icon = "icon-t-shirt";
return html`
<span id="icon-container" slot="icon" class=${classMap({ draft: isDraft})}>
${this.item?.documentType.icon
? html`<umb-icon id="icon" slot="icon" name="${icon}"></umb-icon>`
: nothing}
</span>
`;
};
});
Mark Drake
06/03/2024, 3:04 PMWarren Buckley
06/03/2024, 3:04 PMMark Drake
06/03/2024, 3:05 PMWarren Buckley
06/03/2024, 3:05 PMKenneth Solberg
06/10/2024, 12:56 PM