@umbraco-cms/backoffice 14.0.0-8a5fc0ad → 14.0.0-8c1d7e37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. package/dist-cms/apps/backoffice/backoffice.element.js +1 -1
  2. package/dist-cms/custom-elements.json +81 -81
  3. package/dist-cms/mocks/data/partial-views.data.d.ts +19 -3
  4. package/dist-cms/mocks/data/partial-views.data.js +277 -10
  5. package/dist-cms/mocks/data/utils.d.ts +2 -1
  6. package/dist-cms/mocks/data/utils.js +5 -0
  7. package/dist-cms/mocks/handlers/partial-views.handlers.d.ts +2 -1
  8. package/dist-cms/mocks/handlers/partial-views.handlers.js +37 -5
  9. package/dist-cms/packages/core/entity-action/common/create-folder/create-folder.action.d.ts +8 -0
  10. package/dist-cms/packages/core/entity-action/common/create-folder/create-folder.action.js +21 -0
  11. package/dist-cms/packages/core/entity-action/common/index.d.ts +1 -0
  12. package/dist-cms/packages/core/entity-action/common/index.js +1 -0
  13. package/dist-cms/packages/core/modal/common/folder/folder-modal.element.js +4 -1
  14. package/dist-cms/packages/core/modal/token/folder-modal.token.d.ts +1 -0
  15. package/dist-cms/packages/core/section/section-default.element.js +1 -1
  16. package/dist-cms/packages/core/section/section-views/index.d.ts +1 -1
  17. package/dist-cms/packages/core/section/section-views/index.js +1 -1
  18. package/dist-cms/packages/core/tree/file-system-tree-item/file-system-tree-item.context.d.ts +1 -0
  19. package/dist-cms/packages/core/tree/file-system-tree-item/file-system-tree-item.context.js +12 -0
  20. package/dist-cms/packages/core/tree/file-system-tree-item/file-system-tree-item.element.js +1 -0
  21. package/dist-cms/packages/core/workspace/workspace-action/workspace-action.element.js +12 -4
  22. package/dist-cms/packages/{translation → dictionary}/dictionary/entity-actions/export/export.action.d.ts +0 -1
  23. package/dist-cms/packages/{translation → dictionary}/dictionary/entity-actions/export/export.action.js +0 -1
  24. package/dist-cms/packages/{translation → dictionary}/dictionary/entity-actions/import/import.action.d.ts +0 -1
  25. package/dist-cms/packages/{translation → dictionary}/dictionary/entity-actions/import/import.action.js +0 -1
  26. package/dist-cms/packages/dictionary/dictionary/index.d.ts +1 -0
  27. package/dist-cms/packages/dictionary/dictionary/index.js +1 -0
  28. package/dist-cms/packages/dictionary/dictionary/repository/index.d.ts +3 -0
  29. package/dist-cms/packages/dictionary/dictionary/repository/index.js +3 -0
  30. package/dist-cms/packages/{translation → dictionary}/dictionary/repository/manifests.js +1 -1
  31. package/dist-cms/packages/{translation → dictionary}/section.manifest.js +4 -4
  32. package/dist-cms/packages/{translation → dictionary}/umbraco-package.d.ts +1 -1
  33. package/dist-cms/packages/dictionary/umbraco-package.js +9 -0
  34. package/dist-cms/packages/settings/dashboards/published-status/dashboard-published-status.element.js +11 -3
  35. package/dist-cms/packages/settings/languages/workspace/language/language-workspace.element.d.ts +0 -1
  36. package/dist-cms/packages/settings/languages/workspace/language/language-workspace.element.js +0 -1
  37. package/dist-cms/packages/templating/components/insert-menu/templating-insert-menu.element.js +1 -1
  38. package/dist-cms/packages/templating/manifests.d.ts +6 -1
  39. package/dist-cms/packages/templating/partial-views/config.d.ts +3 -4
  40. package/dist-cms/packages/templating/partial-views/config.js +1 -0
  41. package/dist-cms/packages/templating/partial-views/entity-actions/create/create-empty.action.js +1 -1
  42. package/dist-cms/packages/templating/partial-views/entity-actions/create/create-from-snippet.action.d.ts +10 -1
  43. package/dist-cms/packages/templating/partial-views/entity-actions/create/create-from-snippet.action.js +16 -1
  44. package/dist-cms/packages/templating/partial-views/entity-actions/create/create-from-snippet.modal.d.ts +16 -0
  45. package/dist-cms/packages/templating/partial-views/entity-actions/create/create-from-snippet.modal.js +73 -0
  46. package/dist-cms/packages/templating/partial-views/entity-actions/manifests.d.ts +6 -1
  47. package/dist-cms/packages/templating/partial-views/entity-actions/manifests.js +43 -5
  48. package/dist-cms/packages/templating/partial-views/manifests.d.ts +6 -1
  49. package/dist-cms/packages/templating/partial-views/repository/partial-views.repository.d.ts +39 -23
  50. package/dist-cms/packages/templating/partial-views/repository/partial-views.repository.js +66 -19
  51. package/dist-cms/packages/templating/partial-views/repository/sources/partial-views.detail.server.data.d.ts +48 -13
  52. package/dist-cms/packages/templating/partial-views/repository/sources/partial-views.detail.server.data.js +56 -17
  53. package/dist-cms/packages/templating/partial-views/repository/sources/partial-views.folder.server.data.d.ts +17 -0
  54. package/dist-cms/packages/templating/partial-views/repository/sources/partial-views.folder.server.data.js +23 -0
  55. package/dist-cms/packages/templating/partial-views/workspace/partial-views-workspace-edit.element.d.ts +6 -1
  56. package/dist-cms/packages/templating/partial-views/workspace/partial-views-workspace-edit.element.js +123 -27
  57. package/dist-cms/packages/templating/partial-views/workspace/partial-views-workspace.context.d.ts +8 -6
  58. package/dist-cms/packages/templating/partial-views/workspace/partial-views-workspace.context.js +47 -6
  59. package/dist-cms/packages/templating/partial-views/workspace/partial-views-workspace.element.d.ts +1 -0
  60. package/dist-cms/packages/templating/partial-views/workspace/partial-views-workspace.element.js +7 -3
  61. package/dist-cms/shared/repository/data-source/data-source.interface.d.ts +2 -2
  62. package/dist-cms/shared/repository/detail-repository.interface.d.ts +2 -2
  63. package/dist-cms/tsconfig.tsbuildinfo +1 -1
  64. package/dist-cms/vscode-html-custom-data.json +40 -40
  65. package/package.json +19 -19
  66. package/dist-cms/packages/translation/umbraco-package.js +0 -9
  67. /package/dist-cms/packages/{translation → dictionary}/dashboards/dictionary/dashboard-translation-dictionary.element.d.ts +0 -0
  68. /package/dist-cms/packages/{translation → dictionary}/dashboards/dictionary/dashboard-translation-dictionary.element.js +0 -0
  69. /package/dist-cms/packages/{translation → dictionary}/dictionary/entity-actions/create/create-dictionary-modal.element.d.ts +0 -0
  70. /package/dist-cms/packages/{translation → dictionary}/dictionary/entity-actions/create/create-dictionary-modal.element.js +0 -0
  71. /package/dist-cms/packages/{translation → dictionary}/dictionary/entity-actions/create/create.action.d.ts +0 -0
  72. /package/dist-cms/packages/{translation → dictionary}/dictionary/entity-actions/create/create.action.js +0 -0
  73. /package/dist-cms/packages/{translation → dictionary}/dictionary/entity-actions/export/export-dictionary-modal.element.d.ts +0 -0
  74. /package/dist-cms/packages/{translation → dictionary}/dictionary/entity-actions/export/export-dictionary-modal.element.js +0 -0
  75. /package/dist-cms/packages/{translation → dictionary}/dictionary/entity-actions/import/import-dictionary-modal.element.d.ts +0 -0
  76. /package/dist-cms/packages/{translation → dictionary}/dictionary/entity-actions/import/import-dictionary-modal.element.js +0 -0
  77. /package/dist-cms/packages/{translation → dictionary}/dictionary/entity-actions/manifests.d.ts +0 -0
  78. /package/dist-cms/packages/{translation → dictionary}/dictionary/entity-actions/manifests.js +0 -0
  79. /package/dist-cms/packages/{translation → dictionary}/dictionary/entity-actions/reload.action.d.ts +0 -0
  80. /package/dist-cms/packages/{translation → dictionary}/dictionary/entity-actions/reload.action.js +0 -0
  81. /package/dist-cms/packages/{translation → dictionary}/dictionary/manifests.d.ts +0 -0
  82. /package/dist-cms/packages/{translation → dictionary}/dictionary/manifests.js +0 -0
  83. /package/dist-cms/packages/{translation → dictionary}/dictionary/menu-item/dictionary-menu-item.element.d.ts +0 -0
  84. /package/dist-cms/packages/{translation → dictionary}/dictionary/menu-item/dictionary-menu-item.element.js +0 -0
  85. /package/dist-cms/packages/{translation → dictionary}/dictionary/menu-item/manifests.d.ts +0 -0
  86. /package/dist-cms/packages/{translation → dictionary}/dictionary/menu-item/manifests.js +0 -0
  87. /package/dist-cms/packages/{translation → dictionary}/dictionary/menu.manifests.d.ts +0 -0
  88. /package/dist-cms/packages/{translation → dictionary}/dictionary/menu.manifests.js +0 -0
  89. /package/dist-cms/packages/{translation → dictionary}/dictionary/repository/dictionary.repository.d.ts +0 -0
  90. /package/dist-cms/packages/{translation → dictionary}/dictionary/repository/dictionary.repository.js +0 -0
  91. /package/dist-cms/packages/{translation → dictionary}/dictionary/repository/dictionary.store.d.ts +0 -0
  92. /package/dist-cms/packages/{translation → dictionary}/dictionary/repository/dictionary.store.js +0 -0
  93. /package/dist-cms/packages/{translation → dictionary}/dictionary/repository/dictionary.tree.store.d.ts +0 -0
  94. /package/dist-cms/packages/{translation → dictionary}/dictionary/repository/dictionary.tree.store.js +0 -0
  95. /package/dist-cms/packages/{translation → dictionary}/dictionary/repository/manifests.d.ts +0 -0
  96. /package/dist-cms/packages/{translation → dictionary}/dictionary/repository/sources/dictionary.detail.server.data.d.ts +0 -0
  97. /package/dist-cms/packages/{translation → dictionary}/dictionary/repository/sources/dictionary.detail.server.data.js +0 -0
  98. /package/dist-cms/packages/{translation → dictionary}/dictionary/repository/sources/dictionary.tree.server.data.d.ts +0 -0
  99. /package/dist-cms/packages/{translation → dictionary}/dictionary/repository/sources/dictionary.tree.server.data.js +0 -0
  100. /package/dist-cms/packages/{translation → dictionary}/dictionary/tree/manifests.d.ts +0 -0
  101. /package/dist-cms/packages/{translation → dictionary}/dictionary/tree/manifests.js +0 -0
  102. /package/dist-cms/packages/{translation → dictionary}/dictionary/workspace/dictionary-workspace-editor.element.d.ts +0 -0
  103. /package/dist-cms/packages/{translation → dictionary}/dictionary/workspace/dictionary-workspace-editor.element.js +0 -0
  104. /package/dist-cms/packages/{translation → dictionary}/dictionary/workspace/dictionary-workspace.context.d.ts +0 -0
  105. /package/dist-cms/packages/{translation → dictionary}/dictionary/workspace/dictionary-workspace.context.js +0 -0
  106. /package/dist-cms/packages/{translation → dictionary}/dictionary/workspace/dictionary-workspace.element.d.ts +0 -0
  107. /package/dist-cms/packages/{translation → dictionary}/dictionary/workspace/dictionary-workspace.element.js +0 -0
  108. /package/dist-cms/packages/{translation → dictionary}/dictionary/workspace/manifests.d.ts +0 -0
  109. /package/dist-cms/packages/{translation → dictionary}/dictionary/workspace/manifests.js +0 -0
  110. /package/dist-cms/packages/{translation → dictionary}/dictionary/workspace/views/editor/workspace-view-dictionary-editor.element.d.ts +0 -0
  111. /package/dist-cms/packages/{translation → dictionary}/dictionary/workspace/views/editor/workspace-view-dictionary-editor.element.js +0 -0
  112. /package/dist-cms/packages/{translation → dictionary}/manifests.d.ts +0 -0
  113. /package/dist-cms/packages/{translation → dictionary}/manifests.js +0 -0
  114. /package/dist-cms/packages/{translation → dictionary}/section.manifest.d.ts +0 -0
@@ -4,18 +4,37 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
4
4
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
+ import { UMB_TEMPLATE_QUERY_BUILDER_MODAL } from '../../templates/modals/modal-tokens.js';
8
+ import { getQuerySnippet } from '../../utils.js';
7
9
  import { UUITextStyles } from '../../../../external/uui/index.js';
8
10
  import { css, html, customElement, query, state } from '../../../../external/lit/index.js';
9
11
  import { UmbLitElement } from '../../../../shared/lit-element/index.js';
12
+ import { UMB_MODAL_MANAGER_CONTEXT_TOKEN } from '../../../core/modal/index.js';
13
+ import { Subject, debounceTime } from '../../../../external/rxjs/index.js';
10
14
  export let UmbPartialViewsWorkspaceEditElement = class UmbPartialViewsWorkspaceEditElement extends UmbLitElement {
15
+ #name;
16
+ get _name() {
17
+ return this.#name;
18
+ }
19
+ set _name(value) {
20
+ this.#name = value?.replace('.cshtml', '');
21
+ this.requestUpdate();
22
+ }
11
23
  #partialViewsWorkspaceContext;
12
24
  #isNew;
13
25
  constructor() {
14
26
  super();
15
- this._name = '';
27
+ this.#name = '';
16
28
  this._content = '';
29
+ this._path = '';
30
+ this._ready = false;
17
31
  this.#isNew = false;
18
- this.consumeContext('umbWorkspaceContext', (workspaceContext) => {
32
+ this.inputQuery$ = new Subject();
33
+ this.consumeContext(UMB_MODAL_MANAGER_CONTEXT_TOKEN, (instance) => {
34
+ this._modalContext = instance;
35
+ });
36
+ //tODO: should this be called something else here?
37
+ this.consumeContext('UmbEntityWorkspaceContext', (workspaceContext) => {
19
38
  this.#partialViewsWorkspaceContext = workspaceContext;
20
39
  this.observe(this.#partialViewsWorkspaceContext.name, (name) => {
21
40
  this._name = name;
@@ -23,44 +42,73 @@ export let UmbPartialViewsWorkspaceEditElement = class UmbPartialViewsWorkspaceE
23
42
  this.observe(this.#partialViewsWorkspaceContext.content, (content) => {
24
43
  this._content = content;
25
44
  });
26
- // this.observe(this.#partialViewsWorkspaceContext.isNew, (isNew) => {
27
- // this.#isNew = !!isNew;
28
- // });
45
+ this.observe(this.#partialViewsWorkspaceContext.path, (path) => {
46
+ this._path = path;
47
+ });
48
+ this.observe(this.#partialViewsWorkspaceContext.isNew, (isNew) => {
49
+ this.#isNew = !!isNew;
50
+ });
51
+ this.observe(this.#partialViewsWorkspaceContext.isCodeEditorReady, (isReady) => {
52
+ this._ready = isReady;
53
+ });
54
+ this.inputQuery$.pipe(debounceTime(250)).subscribe((nameInputValue) => {
55
+ this.#partialViewsWorkspaceContext?.setName(`${nameInputValue}.cshtml`);
56
+ });
29
57
  });
30
58
  }
31
- // TODO: temp code for testing create and save
32
59
  #onNameInput(event) {
33
60
  const target = event.target;
34
61
  const value = target.value;
35
- this.#partialViewsWorkspaceContext?.setName(value);
62
+ this.inputQuery$.next(value);
36
63
  }
37
- //TODO - debounce that
38
64
  #onCodeEditorInput(event) {
39
65
  const target = event.target;
40
66
  const value = target.code;
41
67
  this.#partialViewsWorkspaceContext?.setContent(value);
42
68
  }
43
- #insertCode(event) {
69
+ #insertSnippet(event) {
44
70
  const target = event.target;
45
71
  const value = target.value;
46
- this._codeEditor?.insert(`My hovercraft is full of eels`);
72
+ this._codeEditor?.insert(value);
73
+ }
74
+ #openQueryBuilder() {
75
+ const queryBuilderModal = this._modalContext?.open(UMB_TEMPLATE_QUERY_BUILDER_MODAL);
76
+ queryBuilderModal?.onSubmit().then((queryBuilderModalResult) => {
77
+ if (queryBuilderModalResult.value)
78
+ this._codeEditor?.insert(getQuerySnippet(queryBuilderModalResult.value));
79
+ });
80
+ }
81
+ #renderCodeEditor() {
82
+ return html `<umb-code-editor
83
+ language="razor"
84
+ id="content"
85
+ .code=${this._content ?? ''}
86
+ @input=${this.#onCodeEditorInput}></umb-code-editor>`;
47
87
  }
48
88
  render() {
49
- // TODO: add correct UI elements
50
- return html `<umb-body-layout alias="Umb.Workspace.Template">
51
- <uui-input slot="header" .value=${this._name} @input=${this.#onNameInput}></uui-input>
89
+ return html `<umb-workspace-editor alias="Umb.Workspace.Template">
90
+ <div id="workspace-header" slot="header">
91
+ <uui-input
92
+ placeholder="Enter name..."
93
+ .value=${this._name}
94
+ @input=${this.#onNameInput}
95
+ label="template name"></uui-input>
96
+ <small>Views/Partials/${this._path}</small>
97
+ </div>
52
98
  <uui-box>
53
- <uui-button color="danger" look="primary" slot="header" @click=${this.#insertCode}
54
- >Insert "My hovercraft is full of eels"</uui-button
55
- >
56
-
57
- <umb-code-editor
58
- language="razor"
59
- id="content"
60
- .code=${this._content ?? ''}
61
- @input=${this.#onCodeEditorInput}></umb-code-editor>
99
+ <div slot="header" id="code-editor-menu-container">
100
+ <umb-templating-insert-menu @insert=${this.#insertSnippet}></umb-templating-insert-menu>
101
+ <uui-button look="secondary" id="query-builder-button" label="Query builder" @click=${this.#openQueryBuilder}>
102
+ <uui-icon name="umb:wand"></uui-icon>Query builder
103
+ </uui-button>
104
+ </div>
105
+ ${this._ready
106
+ ? this.#renderCodeEditor()
107
+ : html `<div id="loader-container">
108
+ <uui-loader></uui-loader>
109
+ </div>`}
62
110
  </uui-box>
63
- </umb-body-layout>`;
111
+ </umb-workspace-editor>`;
64
112
  }
65
113
  static { this.styles = [
66
114
  UUITextStyles,
@@ -71,28 +119,76 @@ export let UmbPartialViewsWorkspaceEditElement = class UmbPartialViewsWorkspaceE
71
119
  height: 100%;
72
120
  }
73
121
 
122
+ #loader-container {
123
+ display: grid;
124
+ place-items: center;
125
+ min-height: calc(100dvh - 360px);
126
+ }
127
+
74
128
  umb-code-editor {
75
- --editor-height: calc(100vh - 300px);
129
+ --editor-height: calc(100dvh - 300px);
76
130
  }
77
131
 
78
132
  uui-box {
79
- margin: 1em;
133
+ min-height: calc(100dvh - 300px);
134
+ margin: var(--uui-size-layout-1);
80
135
  --uui-box-default-padding: 0;
136
+ /* remove header border bottom as code editor looks better in this box */
137
+ --uui-color-divider-standalone: transparent;
138
+ }
139
+
140
+ #workspace-header {
141
+ width: 100%;
81
142
  }
82
143
 
83
144
  uui-input {
84
145
  width: 100%;
85
- margin: 1em;
146
+ }
147
+
148
+ #code-editor-menu-container uui-icon:not([name='umb:delete']) {
149
+ margin-right: var(--uui-size-space-3);
150
+ }
151
+
152
+ #insert-menu {
153
+ margin: 0;
154
+ padding: 0;
155
+ margin-top: var(--uui-size-space-3);
156
+ background-color: var(--uui-color-surface);
157
+ box-shadow: var(--uui-shadow-depth-3);
158
+ min-width: calc(100% + var(--uui-size-8, 24px));
159
+ }
160
+
161
+ #insert-menu > li,
162
+ ul {
163
+ padding: 0;
164
+ width: 100%;
165
+ list-style: none;
166
+ }
167
+
168
+ .insert-menu-item {
169
+ width: 100%;
170
+ }
171
+
172
+ #code-editor-menu-container {
173
+ display: flex;
174
+ justify-content: flex-end;
175
+ gap: var(--uui-size-space-3);
86
176
  }
87
177
  `,
88
178
  ]; }
89
179
  };
90
180
  __decorate([
91
181
  state()
92
- ], UmbPartialViewsWorkspaceEditElement.prototype, "_name", void 0);
182
+ ], UmbPartialViewsWorkspaceEditElement.prototype, "_name", null);
93
183
  __decorate([
94
184
  state()
95
185
  ], UmbPartialViewsWorkspaceEditElement.prototype, "_content", void 0);
186
+ __decorate([
187
+ state()
188
+ ], UmbPartialViewsWorkspaceEditElement.prototype, "_path", void 0);
189
+ __decorate([
190
+ state()
191
+ ], UmbPartialViewsWorkspaceEditElement.prototype, "_ready", void 0);
96
192
  __decorate([
97
193
  query('umb-code-editor')
98
194
  ], UmbPartialViewsWorkspaceEditElement.prototype, "_codeEditor", void 0);
@@ -1,20 +1,22 @@
1
1
  import { UmbPartialViewsRepository } from '../repository/partial-views.repository.js';
2
- import { TemplateResponseModel } from '../../../../external/backend-api/index.js';
2
+ import { PartialViewDetails } from '../config.js';
3
3
  import { UmbControllerHostElement } from '../../../../libs/controller-api/index.js';
4
4
  import { UmbWorkspaceContext } from '../../../core/workspace/index.js';
5
- export declare class UmbPartialViewsWorkspaceContext extends UmbWorkspaceContext<UmbPartialViewsRepository, TemplateResponseModel> {
5
+ export declare class UmbPartialViewsWorkspaceContext extends UmbWorkspaceContext<UmbPartialViewsRepository, PartialViewDetails> {
6
6
  #private;
7
7
  getEntityId(): string | undefined;
8
8
  getEntityType(): string;
9
9
  save(): Promise<void>;
10
10
  destroy(): void;
11
- data: import("rxjs").Observable<TemplateResponseModel | undefined>;
11
+ data: import("rxjs").Observable<import("../../../../external/backend-api/index.js").TextFileResponseModelBaseModel | undefined>;
12
12
  name: import("rxjs").Observable<string | undefined>;
13
- content: import("rxjs").Observable<string | null | undefined>;
13
+ content: import("rxjs").Observable<string | undefined>;
14
+ path: import("rxjs").Observable<string | undefined>;
15
+ isCodeEditorReady: import("rxjs").Observable<boolean>;
14
16
  constructor(host: UmbControllerHostElement);
15
- getData(): TemplateResponseModel | undefined;
17
+ getData(): import("../../../../external/backend-api/index.js").TextFileResponseModelBaseModel | undefined;
16
18
  setName(value: string): void;
17
19
  setContent(value: string): void;
18
20
  load(entityKey: string): Promise<void>;
19
- create(parentKey: string | null): Promise<void>;
21
+ create(parentKey: string | null, name?: string): Promise<void>;
20
22
  }
@@ -1,26 +1,62 @@
1
1
  import { UmbPartialViewsRepository } from '../repository/partial-views.repository.js';
2
- import { createObservablePart, UmbDeepState } from '../../../../libs/observable-api/index.js';
2
+ import { createObservablePart, UmbBooleanState, UmbDeepState } from '../../../../libs/observable-api/index.js';
3
3
  import { UmbWorkspaceContext } from '../../../core/workspace/index.js';
4
+ import { loadCodeEditor } from '../../code-editor/index.js';
4
5
  export class UmbPartialViewsWorkspaceContext extends UmbWorkspaceContext {
5
6
  getEntityId() {
6
- throw new Error('Method not implemented.');
7
+ return this.getData()?.path;
7
8
  }
8
9
  getEntityType() {
9
10
  throw new Error('Method not implemented.');
10
11
  }
11
12
  save() {
12
- throw new Error('Method not implemented.');
13
+ const partialView = this.getData();
14
+ if (!partialView)
15
+ return Promise.reject('Something went wrong, there is no data for partial view you want to save...');
16
+ if (this.getIsNew()) {
17
+ const createRequestBody = {
18
+ name: partialView.name,
19
+ content: partialView.content,
20
+ parentPath: partialView.path + '/',
21
+ };
22
+ this.repository.create(createRequestBody);
23
+ console.log('create');
24
+ return Promise.resolve();
25
+ }
26
+ if (!partialView.path)
27
+ return Promise.reject('There is no path');
28
+ const updateRequestBody = {
29
+ name: partialView.name,
30
+ existingPath: partialView.path,
31
+ content: partialView.content,
32
+ };
33
+ this.repository.save(partialView.path, updateRequestBody);
34
+ return Promise.resolve();
13
35
  }
14
36
  destroy() {
15
37
  throw new Error('Method not implemented.');
16
38
  }
17
39
  #data;
40
+ #isCodeEditorReady;
18
41
  constructor(host) {
19
42
  super(host, new UmbPartialViewsRepository(host));
20
43
  this.#data = new UmbDeepState(undefined);
21
44
  this.data = this.#data.asObservable();
22
45
  this.name = createObservablePart(this.#data, (data) => data?.name);
23
46
  this.content = createObservablePart(this.#data, (data) => data?.content);
47
+ this.path = createObservablePart(this.#data, (data) => data?.path);
48
+ this.#isCodeEditorReady = new UmbBooleanState(false);
49
+ this.isCodeEditorReady = this.#isCodeEditorReady.asObservable();
50
+ this.#loadCodeEditor();
51
+ }
52
+ async #loadCodeEditor() {
53
+ try {
54
+ await loadCodeEditor();
55
+ this.#isCodeEditorReady.next(true);
56
+ }
57
+ catch (error) {
58
+ console.error(error);
59
+ }
24
60
  }
25
61
  getData() {
26
62
  return this.#data.getValue();
@@ -38,11 +74,16 @@ export class UmbPartialViewsWorkspaceContext extends UmbWorkspaceContext {
38
74
  this.#data.next(data);
39
75
  }
40
76
  }
41
- async create(parentKey) {
42
- const { data } = await this.repository.createScaffold(parentKey);
77
+ async create(parentKey, name = 'Empty') {
78
+ const { data } = await this.repository.createScaffold(parentKey, name);
79
+ const newPartial = {
80
+ ...data,
81
+ name: '',
82
+ path: parentKey ?? '',
83
+ };
43
84
  if (!data)
44
85
  return;
45
86
  this.setIsNew(true);
46
- this.#data.next(data);
87
+ this.#data.next(newPartial);
47
88
  }
48
89
  }
@@ -1,6 +1,7 @@
1
1
  import { UmbLitElement } from '../../../../shared/lit-element/index.js';
2
2
  import { UmbRoute } from '../../../../shared/router/index.js';
3
3
  import './partial-views-workspace-edit.element.js';
4
+ import '../../components/insert-menu/templating-insert-menu.element.js';
4
5
  export declare class UmbPartialViewsWorkspaceElement extends UmbLitElement {
5
6
  #private;
6
7
  _routes: UmbRoute[];
@@ -9,6 +9,7 @@ import { UUITextStyles } from '../../../../external/uui/index.js';
9
9
  import { css, html, customElement, state } from '../../../../external/lit/index.js';
10
10
  import { UmbLitElement } from '../../../../shared/lit-element/index.js';
11
11
  import './partial-views-workspace-edit.element.js';
12
+ import '../../components/insert-menu/templating-insert-menu.element.js';
12
13
  import { UmbWorkspaceIsNewRedirectController } from '../../../core/workspace/index.js';
13
14
  export let UmbPartialViewsWorkspaceElement = class UmbPartialViewsWorkspaceElement extends UmbLitElement {
14
15
  constructor() {
@@ -17,11 +18,13 @@ export let UmbPartialViewsWorkspaceElement = class UmbPartialViewsWorkspaceEleme
17
18
  this.#element = document.createElement('umb-partial-views-workspace-edit');
18
19
  this._routes = [
19
20
  {
20
- path: 'create/:parentKey',
21
+ path: 'create/:parentKey/:snippetName',
21
22
  component: () => this.#element,
22
23
  setup: async (component, info) => {
23
24
  const parentKey = info.match.params.parentKey;
24
- this.#partialViewsWorkspaceContext.create(parentKey);
25
+ const decodePath = decodeURIComponent(parentKey);
26
+ const snippetName = info.match.params.snippetName;
27
+ this.#partialViewsWorkspaceContext.create(decodePath === 'null' ? null : parentKey, snippetName);
25
28
  new UmbWorkspaceIsNewRedirectController(this, this.#partialViewsWorkspaceContext, this.shadowRoot.querySelector('umb-router-slot'));
26
29
  },
27
30
  },
@@ -30,7 +33,8 @@ export let UmbPartialViewsWorkspaceElement = class UmbPartialViewsWorkspaceEleme
30
33
  component: () => this.#element,
31
34
  setup: (component, info) => {
32
35
  const key = info.match.params.key;
33
- this.#partialViewsWorkspaceContext.load(key);
36
+ const decodePath = decodeURIComponent(key).replace('-cshtml', '.cshtml');
37
+ this.#partialViewsWorkspaceContext.load(decodePath);
34
38
  },
35
39
  },
36
40
  ];
@@ -1,6 +1,6 @@
1
1
  import type { DataSourceResponse } from '../index.js';
2
- export interface UmbDataSource<CreateRequestType, CreateResponseType, UpdateRequestType, ResponseType> {
3
- createScaffold(parentId: string | null): Promise<DataSourceResponse<CreateRequestType>>;
2
+ export interface UmbDataSource<CreateRequestType, CreateResponseType, UpdateRequestType, ResponseType, CreateScaffoldPresetType = Partial<CreateRequestType>> {
3
+ createScaffold(parentId: string | null, preset?: Partial<CreateRequestType> | CreateScaffoldPresetType): Promise<DataSourceResponse<CreateRequestType>>;
4
4
  get(unique: string): Promise<DataSourceResponse<ResponseType>>;
5
5
  insert(data: CreateRequestType): Promise<DataSourceResponse<CreateResponseType>>;
6
6
  update(unique: string, data: UpdateRequestType): Promise<DataSourceResponse<ResponseType>>;
@@ -1,7 +1,7 @@
1
1
  import type { DataSourceResponse, UmbDataSourceErrorResponse } from './data-source/index.js';
2
2
  import { Observable } from '../../external/rxjs/index.js';
3
- export interface UmbDetailRepository<CreateRequestType = any, CreateResponseType = any, UpdateRequestType = any, ResponseType = any> {
4
- createScaffold(parentId: string | null, preset?: Partial<CreateRequestType>): Promise<DataSourceResponse<CreateRequestType>>;
3
+ export interface UmbDetailRepository<CreateRequestType = any, CreateResponseType = any, UpdateRequestType = any, ResponseType = any, CreateScaffoldPresetType = Partial<CreateRequestType>> {
4
+ createScaffold(parentId: string | null, preset?: Partial<CreateRequestType> | CreateScaffoldPresetType): Promise<DataSourceResponse<CreateRequestType>>;
5
5
  requestById(id: string): Promise<DataSourceResponse<ResponseType | undefined>>;
6
6
  byId(id: string): Promise<Observable<ResponseType | undefined>>;
7
7
  create(data: CreateRequestType): Promise<DataSourceResponse<CreateResponseType>>;