allow create empty

This commit is contained in:
Julia Gru
2023-07-20 13:08:59 +02:00
parent eefb35fae0
commit 8427de721c
2 changed files with 18 additions and 4 deletions

View File

@@ -11,8 +11,16 @@ import { Subject, debounceTime } from '@umbraco-cms/backoffice/external/rxjs';
@customElement('umb-partial-views-workspace-edit')
export class UmbPartialViewsWorkspaceEditElement extends UmbLitElement {
#name: string | undefined = '';
@state()
private _name?: string | null = '';
private get _name() {
return this.#name;
}
private set _name(value) {
this.#name = value?.replace('.cshtml', '');
this.requestUpdate();
}
@state()
private _content?: string | null = '';
@@ -64,7 +72,7 @@ export class UmbPartialViewsWorkspaceEditElement extends UmbLitElement {
});
this.inputQuery$.pipe(debounceTime(250)).subscribe((nameInputValue: string) => {
this.#partialViewsWorkspaceContext?.setName(nameInputValue);
this.#partialViewsWorkspaceContext?.setName(`${nameInputValue}.cshtml`);
});
});
}

View File

@@ -19,7 +19,14 @@ export class UmbPartialViewsWorkspaceContext extends UmbWorkspaceContext<UmbPart
if (!partialView)
return Promise.reject('Something went wrong, there is no data for partial view you want to save...');
if (this.getIsNew()) {
//this.repository.create()
const createRequestBody = {
name: partialView.name,
content: partialView.content,
parentPath: partialView.path + '/',
}
this.repository.create(createRequestBody)
console.log('create');
return Promise.resolve();
}
@@ -80,7 +87,6 @@ export class UmbPartialViewsWorkspaceContext extends UmbWorkspaceContext<UmbPart
async create(parentKey: string | null, name = 'Empty') {
const { data } = await this.repository.createScaffold(parentKey, name);
debugger;
const newPartial = {
...data,
name: '',