create scaffold
This commit is contained in:
@@ -21,7 +21,7 @@ export class UmbUserGroupCollectionHeaderElement extends UmbLitElement {
|
||||
#onCreate() {
|
||||
//TODO Navigate to create workspace
|
||||
|
||||
history.pushState(null, '', 'section/users/view/user-groups/create/');
|
||||
history.pushState(null, '', 'section/users/view/user-groups/user-group/create/');
|
||||
}
|
||||
|
||||
#onSearch(event: UUIInputEvent) {
|
||||
|
||||
@@ -11,7 +11,7 @@ export class UmbUserGroupTableNameColumnLayoutElement extends LitElement {
|
||||
value!: any;
|
||||
|
||||
render() {
|
||||
return html` <a style="font-weight: bold;" href="section/users/view/user-groups/edit/${this.item.id}">
|
||||
return html` <a style="font-weight: bold;" href="section/users/view/user-groups/user-group/edit/${this.item.id}">
|
||||
${this.value.name}
|
||||
</a>`;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
UserGroupResource,
|
||||
UpdateUserGroupRequestModel,
|
||||
SaveUserGroupRequestModel,
|
||||
UserGroupBaseModel,
|
||||
} from '@umbraco-cms/backoffice/backend-api';
|
||||
import { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller';
|
||||
import { tryExecuteAndNotify } from '@umbraco-cms/backoffice/resources';
|
||||
@@ -26,9 +27,12 @@ export class UmbUserGroupServerDataSource implements UmbUserGroupDetailDataSourc
|
||||
constructor(host: UmbControllerHostElement) {
|
||||
this.#host = host;
|
||||
}
|
||||
createScaffold(parentId: string | null): Promise<DataSourceResponse<UserGroupPresentationModel>> {
|
||||
throw new Error('Method not implemented.');
|
||||
|
||||
async createScaffold(parentId: string | null) {
|
||||
const data: UserGroupBaseModel = {};
|
||||
return { data };
|
||||
}
|
||||
|
||||
get(id: string): Promise<DataSourceResponse<UserGroupPresentationModel>> {
|
||||
if (!id) throw new Error('Id is missing');
|
||||
return tryExecuteAndNotify(this.#host, UserGroupResource.getUserGroupById({ id }));
|
||||
|
||||
@@ -2,7 +2,12 @@ import { Observable } from 'rxjs';
|
||||
import { UmbUserGroupCollectionFilterModel, UmbUserGroupDetailDataSource } from '../types';
|
||||
import { UmbUserGroupServerDataSource } from './sources/user-group.server.data';
|
||||
import { UmbUserGroupCollectionServerDataSource } from './sources/user-group-collection.server.data';
|
||||
import { UserGroupPresentationModel } from '@umbraco-cms/backoffice/backend-api';
|
||||
import {
|
||||
SaveUserGroupRequestModel,
|
||||
UpdateUserGroupRequestModel,
|
||||
UserGroupBaseModel,
|
||||
UserGroupPresentationModel,
|
||||
} from '@umbraco-cms/backoffice/backend-api';
|
||||
import { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller';
|
||||
import {
|
||||
UmbCollectionDataSource,
|
||||
@@ -14,7 +19,9 @@ import {
|
||||
|
||||
// TODO: implement
|
||||
export class UmbUserGroupRepository
|
||||
implements UmbDetailRepository<UserGroupPresentationModel>, UmbCollectionRepository
|
||||
implements
|
||||
UmbDetailRepository<SaveUserGroupRequestModel, any, UpdateUserGroupRequestModel, UserGroupPresentationModel>,
|
||||
UmbCollectionRepository
|
||||
{
|
||||
#host: UmbControllerHostElement;
|
||||
|
||||
@@ -26,6 +33,9 @@ export class UmbUserGroupRepository
|
||||
this.#detailSource = new UmbUserGroupServerDataSource(this.#host);
|
||||
this.#collectionSource = new UmbUserGroupCollectionServerDataSource(this.#host);
|
||||
}
|
||||
createScaffold(parentId: string | null): Promise<UmbRepositoryResponse<UserGroupBaseModel>> {
|
||||
return this.#detailSource.createScaffold(parentId);
|
||||
}
|
||||
|
||||
// COLLECTION
|
||||
async requestCollection(filter: UmbUserGroupCollectionFilterModel = { skip: 0, take: 100 }) {
|
||||
@@ -34,10 +44,6 @@ export class UmbUserGroupRepository
|
||||
}
|
||||
|
||||
// DETAIL
|
||||
createScaffold(parentId: string | null): Promise<UmbRepositoryResponse<any>> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
async requestById(id: string) {
|
||||
if (!id) throw new Error('Id is missing');
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ export class UmbUserGroupsSectionViewElement extends UmbLitElement {
|
||||
component: () => import('../collection/user-group-collection.element'),
|
||||
},
|
||||
{
|
||||
path: 'edit',
|
||||
path: 'user-group',
|
||||
component: () => import('../workspace/user-group-workspace.element'),
|
||||
},
|
||||
{
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import {
|
||||
SaveUserGroupRequestModel,
|
||||
UpdateUserGroupRequestModel,
|
||||
UserGroupBaseModel,
|
||||
UserGroupPresentationModel,
|
||||
} from '@umbraco-cms/backoffice/backend-api';
|
||||
import type { UmbEntityBase } from '@umbraco-cms/backoffice/models';
|
||||
|
||||
@@ -177,7 +177,7 @@ export class UmbUserGroupWorkspaceEditElement extends UmbLitElement {
|
||||
#renderHeader() {
|
||||
return html`
|
||||
<div id="header" slot="header">
|
||||
<a href="/section/users/view/user-groups/">
|
||||
<a href="/section/users/view/user-groups">
|
||||
<uui-icon name="umb:arrow-left"></uui-icon>
|
||||
</a>
|
||||
<uui-input id="name" .value=${this._userGroup?.name ?? ''} @input="${this.#onNameChange}"></uui-input>
|
||||
|
||||
@@ -15,6 +15,14 @@ export class UmbUserGroupWorkspaceContext
|
||||
super(host, new UmbUserGroupRepository(host));
|
||||
}
|
||||
|
||||
async createScaffold() {
|
||||
const { data } = await this.repository.createScaffold(null);
|
||||
this.setIsNew(true);
|
||||
// TODO: Should the data be the base model or the presentation model?
|
||||
this.#data.next(data as unknown as UserGroupPresentationModel);
|
||||
return { data };
|
||||
}
|
||||
|
||||
async load(id: string) {
|
||||
console.log('load');
|
||||
|
||||
|
||||
@@ -14,7 +14,14 @@ export class UmbUserGroupWorkspaceElement extends UmbLitElement {
|
||||
@state()
|
||||
_routes: UmbRoute[] = [
|
||||
{
|
||||
path: ':id',
|
||||
path: 'create',
|
||||
component: () => this.#element,
|
||||
setup: (component, info) => {
|
||||
this.#workspaceContext.createScaffold();
|
||||
},
|
||||
},
|
||||
{
|
||||
path: 'edit/:id',
|
||||
component: () => this.#element,
|
||||
setup: (component, info) => {
|
||||
const id = info.match.params.id;
|
||||
|
||||
Reference in New Issue
Block a user