feat(partial views): make updating partial view possible

You can now update existing partial views, yay!
This commit is contained in:
Julia Gru
2023-07-19 15:03:22 +02:00
parent f568f659ae
commit eadcdd832f
3 changed files with 25 additions and 4 deletions

View File

@@ -14,5 +14,6 @@
"variantable"
],
"exportall.config.folderListener": [],
"exportall.config.relExclusion": []
"exportall.config.relExclusion": [],
"conventionalCommits.scopes": ["partial views"]
}

View File

@@ -111,7 +111,7 @@ export class UmbPartialViewsWorkspaceEditElement extends UmbLitElement {
.value=${this._name}
@input=${this.#onNameInput}
label="template name"></uui-input>
<small>${this._path}</small>
<small>Views/Partials/${this._path}</small>
</div>
<uui-box>
<div slot="header" id="code-editor-menu-container">

View File

@@ -4,8 +4,12 @@ import { createObservablePart, UmbBooleanState, UmbDeepState } from '@umbraco-cm
import { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller-api';
import { UmbWorkspaceContext } from '@umbraco-cms/backoffice/workspace';
import { loadCodeEditor } from '@umbraco-cms/backoffice/code-editor';
import { UpdatePartialViewRequestModel } from '@umbraco-cms/backoffice/backend-api';
export class UmbPartialViewsWorkspaceContext extends UmbWorkspaceContext<UmbPartialViewsRepository, PartialViewDetails> {
export class UmbPartialViewsWorkspaceContext extends UmbWorkspaceContext<
UmbPartialViewsRepository,
PartialViewDetails
> {
getEntityId(): string | undefined {
throw new Error('Method not implemented.');
}
@@ -13,7 +17,23 @@ export class UmbPartialViewsWorkspaceContext extends UmbWorkspaceContext<UmbPart
throw new Error('Method not implemented.');
}
save(): Promise<void> {
throw new Error('Method not implemented.');
const partialView = this.getData();
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()
console.log('create');
return Promise.resolve();
}
if (!partialView.path) return Promise.reject('There is no path');
const updateRequestBody: UpdatePartialViewRequestModel = {
name: partialView.name,
existingPath: partialView.path,
content: partialView.content,
};
this.repository.save(partialView.path, updateRequestBody);
return Promise.resolve();
}
destroy(): void {
throw new Error('Method not implemented.');