@yuuvis/app-templates 1.0.0-alpha.1

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.
package/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # @yuuvis/app-templates
2
+
3
+ @yuuvis/app-templates is a yuuvis® MOMENTUM client app to work with template based word documents.
4
+
5
+ ## Installation
6
+
7
+ The app can be installed in a custom client project as follows:
8
+
9
+ ```sh
10
+ npm install @yuuvis/app-templates --save
11
+ ```
12
+
13
+ ## Enable the extension to apply templates
14
+
15
+ In your `app.config.ts` add the `YuvTemplatesExtension` to the providers:
16
+
17
+ ```ts
18
+ import { YuvTemplatesExtension } from '@yuuvis/app-templates/extensions';
19
+
20
+ export const appConfig: ApplicationConfig = {
21
+ providers: [
22
+ importShellExtensions([YuvTemplatesExtension])
23
+ ]
24
+ }
25
+ ```
26
+
27
+ ## Enable the app to manage templates
28
+
29
+ In your `app.routes.ts` add a new lazy loaded route for the `@yuuvis/app-templates` package:
30
+
31
+ ```ts
32
+ export const app: App[] = [
33
+ {
34
+ id: 'io.yuuvis.app.templates',
35
+ title: "yuuvis Templates",
36
+ path: 'templates',
37
+ iconName: 'library_books',
38
+ loadChildren: () => import('@yuuvis/app-templates').then((m) => m.YuvTemplateManagerRoutes)
39
+ },
40
+ ]
41
+ ```
@@ -0,0 +1,3 @@
1
+ # @yuuvis/app-templates/extensions
2
+
3
+ Secondary entry point of `@yuuvis/app-templates`. It can be used by importing from `@yuuvis/app-templates/extensions`.
@@ -0,0 +1 @@
1
+ export * from './lib/extensions.service';
@@ -0,0 +1,16 @@
1
+ import { DmsObject } from '@yuuvis/client-core';
2
+ import { AbstractContextAction, Action, ActionSupport, SelectionRange } from '@yuuvis/client-framework/actions';
3
+ import { Observable } from 'rxjs';
4
+ export declare class ApplyTemplateAction extends AbstractContextAction implements Action {
5
+ #private;
6
+ id: string;
7
+ label: any;
8
+ description: any;
9
+ icon: string;
10
+ group: string;
11
+ priority: number;
12
+ range: SelectionRange;
13
+ supports: ActionSupport;
14
+ isExecutable(selection: DmsObject[]): Observable<boolean>;
15
+ run(selection: DmsObject[]): Observable<boolean>;
16
+ }
@@ -0,0 +1,28 @@
1
+ import { DmsObject } from '@yuuvis/client-core';
2
+ import { TemplateObject } from '@yuuvis/app-templates';
3
+ import * as i0 from "@angular/core";
4
+ export declare class ApplyTemplateComponent {
5
+ #private;
6
+ dmsObject: import("@angular/core").InputSignal<DmsObject>;
7
+ supportedTemplates: import("@angular/core").WritableSignal<TemplateObject[]>;
8
+ selectedTemplate: import("@angular/core").WritableSignal<TemplateObject | undefined>;
9
+ busy: import("@angular/core").WritableSignal<boolean>;
10
+ error: import("@angular/core").WritableSignal<boolean>;
11
+ icons: {
12
+ close: string;
13
+ refresh: string;
14
+ actionApplyTemplate: string;
15
+ actionCreateNewTemplate: string;
16
+ actionToggleStateToPublished: string;
17
+ actionToggleStateToUnpublished: string;
18
+ actionDeleteTemplate: string;
19
+ actionDownloadTemplateContent: string;
20
+ actionReplaceTemplateContent: string;
21
+ toggleRight: string;
22
+ };
23
+ onItemSelect(idx: number[]): void;
24
+ cancel(): void;
25
+ apply(): void;
26
+ static ɵfac: i0.ɵɵFactoryDeclaration<ApplyTemplateComponent, never>;
27
+ static ɵcmp: i0.ɵɵComponentDeclaration<ApplyTemplateComponent, "ymtmpl-apply", never, { "dmsObject": { "alias": "dmsObject"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
28
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "yuv.app.templates.action.apply.label": "Vorlage anwenden",
3
+ "yuv.app.templates.action.apply.list.empty": "Keine Vorlagen vorhanden",
4
+ "yuv.app.templates.action.apply.error": "Fehler beim Laden der Vorlagen",
5
+ "yuv.app.templates.action.apply.success": "Vorlage erfolgreich angewendet",
6
+ "yuv.app.templates.action.apply.description": "Ersetzt die Dokumentdatei auf Basis einer Vorlage und fügt sie als neue Version hinzu.",
7
+ "yuv.app.templates.action.apply.headline": "Vorlage anwenden",
8
+ "yuv.app.templates.action.apply.text": "Wählen Sie die Vorlage aus, die auf das Objekt angewendet werden soll.",
9
+ "yuv.app.templates.action.apply.button.cancel": "Abbrechen",
10
+ "yuv.app.templates.action.apply.button.ok": "Anwenden"
11
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "yuv.app.templates.action.apply.label": "Apply template",
3
+ "yuv.app.templates.action.apply.list.empty": "No templates available",
4
+ "yuv.app.templates.action.apply.error": "Error loading the templates",
5
+ "yuv.app.templates.action.apply.success": "Template applied successfully",
6
+ "yuv.app.templates.action.apply.description": "Replaces the document file based on a template and adds it as a new version.",
7
+ "yuv.app.templates.action.apply.headline": "Apply template",
8
+ "yuv.app.templates.action.apply.text": "Select the template that should be applied to the object.",
9
+ "yuv.app.templates.action.apply.button.cancel": "Cancel",
10
+ "yuv.app.templates.action.apply.button.ok": "Apply"
11
+ }
@@ -0,0 +1,14 @@
1
+ import { DmsObject } from '@yuuvis/client-core';
2
+ import { ClientShellExtension } from '@yuuvis/client-shell-core';
3
+ import { Observable } from 'rxjs';
4
+ import { TemplateSearchResponse } from '@yuuvis/app-templates';
5
+ import * as i0 from "@angular/core";
6
+ export declare class YuvTemplatesExtension implements ClientShellExtension {
7
+ #private;
8
+ static MAX_TEMPLATES: number;
9
+ init(): Promise<any>;
10
+ getTemplatesForObject(object: DmsObject, pageNumber?: number): Observable<TemplateSearchResponse>;
11
+ applyTemplateOnObject(templateRef: String, object: DmsObject, silent?: boolean): Observable<DmsObject>;
12
+ static ɵfac: i0.ɵɵFactoryDeclaration<YuvTemplatesExtension, never>;
13
+ static ɵprov: i0.ɵɵInjectableDeclaration<YuvTemplatesExtension>;
14
+ }
@@ -0,0 +1,182 @@
1
+ import { HttpParams } from '@angular/common/http';
2
+ import * as i0 from '@angular/core';
3
+ import { inject, input, effect, untracked, signal, Component, Injectable } from '@angular/core';
4
+ import * as i1 from '@yuuvis/client-core';
5
+ import { TranslateModule, NotificationService, TranslateService, SystemType, BackendService, DmsService, EventService, ApiBase, YuvEventType } from '@yuuvis/client-core';
6
+ import { AbstractContextAction, SelectionRange, ActionsService } from '@yuuvis/client-framework/actions';
7
+ import { finalize, of, map, switchMap, tap } from 'rxjs';
8
+ import { APP_ICONS, APP_ACTIONS, TemplateObject } from '@yuuvis/app-templates';
9
+ import { TranslateService as TranslateService$1 } from '@ngx-translate/core';
10
+ import { MAT_DIALOG_DATA, MatDialogRef, MatDialog } from '@angular/material/dialog';
11
+ import { CommonModule } from '@angular/common';
12
+ import * as i2 from '@angular/material/icon';
13
+ import { MatIconModule } from '@angular/material/icon';
14
+ import { BusyOverlayDirective, DialogComponent } from '@yuuvis/client-framework/common';
15
+ import { ListComponent, ListItemDirective } from '@yuuvis/client-framework/list';
16
+ import { MatProgressBarModule } from '@angular/material/progress-bar';
17
+ import { YmtButtonDirective } from '@yuuvis/material';
18
+
19
+ const components = [
20
+ BusyOverlayDirective,
21
+ ListComponent,
22
+ ListItemDirective,
23
+ DialogComponent,
24
+ YmtButtonDirective
25
+ ];
26
+ const modules = [
27
+ CommonModule,
28
+ TranslateModule,
29
+ MatIconModule,
30
+ MatProgressBarModule,
31
+ ];
32
+ class ApplyTemplateComponent {
33
+ constructor() {
34
+ this.#extension = inject(YuvTemplatesExtension);
35
+ this.#notificationService = inject(NotificationService);
36
+ this.#translateService = inject(TranslateService);
37
+ this.#dialogData = inject(MAT_DIALOG_DATA);
38
+ this.#dialogRef = inject((MatDialogRef));
39
+ this.dmsObject = input(this.#dialogData);
40
+ this.#dmsObjectEffect = effect(() => {
41
+ if (this.dmsObject())
42
+ untracked(() => {
43
+ this.#init();
44
+ });
45
+ });
46
+ this.supportedTemplates = signal([]);
47
+ this.selectedTemplate = signal(undefined);
48
+ this.busy = signal(false);
49
+ this.error = signal(false);
50
+ this.icons = {
51
+ ...APP_ICONS
52
+ };
53
+ }
54
+ #extension;
55
+ #notificationService;
56
+ #translateService;
57
+ #dialogData;
58
+ #dialogRef;
59
+ #dmsObjectEffect;
60
+ #init() {
61
+ this.busy.set(true);
62
+ this.#extension.getTemplatesForObject(this.dmsObject())
63
+ .pipe(finalize(() => this.busy.set(false)))
64
+ .subscribe({
65
+ next: (res) => {
66
+ this.error.set(false);
67
+ this.supportedTemplates.set(res.items);
68
+ },
69
+ error: () => {
70
+ this.error.set(true);
71
+ }
72
+ });
73
+ }
74
+ onItemSelect(idx) {
75
+ this.selectedTemplate.set(this.supportedTemplates()[idx[0]]);
76
+ }
77
+ cancel() {
78
+ this.#dialogRef.close();
79
+ }
80
+ apply() {
81
+ this.busy.set(true);
82
+ this.#extension.applyTemplateOnObject(`obj:${this.selectedTemplate()?.id}`, this.dmsObject()).subscribe({
83
+ next: () => {
84
+ this.#notificationService.success(this.#translateService.instant('yuv.app.templates.action.apply.success'));
85
+ },
86
+ error: (err) => {
87
+ this.#notificationService.error(err);
88
+ this.busy.set(false);
89
+ },
90
+ complete: () => {
91
+ this.#dialogRef.close();
92
+ }
93
+ });
94
+ }
95
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: ApplyTemplateComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
96
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.13", type: ApplyTemplateComponent, isStandalone: true, selector: "ymtmpl-apply", inputs: { dmsObject: { classPropertyName: "dmsObject", publicName: "dmsObject", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "<yuv-dialog [headertitel]=\"'yuv.app.templates.action.apply.headline' | translate\">\n <main [yuvBusyOverlay]=\"busy()\">\n @let templates = supportedTemplates(); @if (templates.length) {\n <p>{{ \"yuv.app.templates.action.apply.text\" | translate }}</p>\n <yuv-list selectOnEnter=\"true\" (itemSelect)=\"onItemSelect($event)\">\n @for (t of templates; track $index) {\n <div yuvListItem>\n <mat-icon class=\"icon\">{{ icons.actionApplyTemplate }}</mat-icon>\n <div class=\"name\">{{ t.name }}</div>\n <div class=\"description\">{{ t.description }}</div>\n </div>\n }\n </yuv-list>\n } @else if (!busy()) { @if (!error()) {\n <div class=\"hint empty\">\n <p>{{ \"yuv.app.templates.action.apply.list.empty\" | translate }}</p>\n </div>\n } @else {\n <div class=\"hint error\">\n <p>{{ \"yuv.app.templates.action.apply.error\" | translate }}</p>\n </div>\n } }\n </main>\n <footer>\n <button [disabled]=\"busy()\" type=\"button\" ymtButton=\"secondary\" (click)=\"cancel()\">{{ \"yuv.app.templates.action.apply.button.cancel\" | translate }}</button>\n <button [disabled]=\"busy() || error() || !selectedTemplate()\" ymtButton=\"primary\" (click)=\"apply()\">{{ \"yuv.app.templates.action.apply.button.ok\" | translate }}</button>\n </footer>\n</yuv-dialog>\n", styles: [":host{--container-width: 300px;display:flex;flex-flow:column;min-width:var(--container-width);max-width:90vw;height:100%}:host main{flex:1;overflow-y:auto;min-height:200px}:host main p{padding:var(--ymt-spacing-m);margin:0}:host main yuv-list{flex:1}:host main yuv-list [yuvListItem]{--icon-size: 24px;--list-item-hover-background: var(--ymt-focus-background);display:grid;padding:var(--ymt-spacing-s) var(--ymt-spacing-m);grid-template-columns:var(--icon-size) auto;grid-template-rows:auto auto;grid-template-areas:\"icon name\" \"icon description\";align-items:center;line-height:1em;column-gap:var(--ymt-spacing-m);row-gap:var(--ymt-spacing-xs);cursor:pointer}:host main yuv-list [yuvListItem] .icon{grid-area:icon}:host main yuv-list [yuvListItem] .name{grid-area:name}:host main yuv-list [yuvListItem] .description{grid-area:description;color:var(--ymt-text-color-subtle)}:host main yuv-list [yuvListItem]:not(:last-child){border-block-end:1px solid var(--ymt-outline-variant)}:host main yuv-pagination{flex:0 0 auto;border-block-start:1px solid var(--ymt-outline-variant)}:host main .hint{height:100%;padding:0;margin:0;display:flex;align-items:center;justify-content:center}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "ngmodule", type: TranslateModule }, { kind: "pipe", type: i1.TranslatePipe, name: "translate" }, { kind: "ngmodule", type: MatIconModule }, { kind: "component", type: i2.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "ngmodule", type: MatProgressBarModule }, { kind: "directive", type: BusyOverlayDirective, selector: "[yuvBusyOverlay]", inputs: ["yuvBusyOverlay"] }, { kind: "component", type: ListComponent, selector: "yuv-list", inputs: ["multiselect", "selfHandleSelection", "disableSelection"], outputs: ["itemSelect", "itemFocus"] }, { kind: "directive", type: ListItemDirective, selector: "[yuvListItem]", inputs: ["disabled", "active", "selected"] }, { kind: "component", type: DialogComponent, selector: "yuv-dialog", inputs: ["headertitel"] }, { kind: "directive", type: YmtButtonDirective, selector: "button[ymtButton], a[ymtButton]", inputs: ["ymtButton", "disabled", "aria-disabled", "disableRipple", "disabledInteractive", "button-size"] }] }); }
97
+ }
98
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: ApplyTemplateComponent, decorators: [{
99
+ type: Component,
100
+ args: [{ selector: 'ymtmpl-apply', standalone: true, imports: [...modules, ...components], template: "<yuv-dialog [headertitel]=\"'yuv.app.templates.action.apply.headline' | translate\">\n <main [yuvBusyOverlay]=\"busy()\">\n @let templates = supportedTemplates(); @if (templates.length) {\n <p>{{ \"yuv.app.templates.action.apply.text\" | translate }}</p>\n <yuv-list selectOnEnter=\"true\" (itemSelect)=\"onItemSelect($event)\">\n @for (t of templates; track $index) {\n <div yuvListItem>\n <mat-icon class=\"icon\">{{ icons.actionApplyTemplate }}</mat-icon>\n <div class=\"name\">{{ t.name }}</div>\n <div class=\"description\">{{ t.description }}</div>\n </div>\n }\n </yuv-list>\n } @else if (!busy()) { @if (!error()) {\n <div class=\"hint empty\">\n <p>{{ \"yuv.app.templates.action.apply.list.empty\" | translate }}</p>\n </div>\n } @else {\n <div class=\"hint error\">\n <p>{{ \"yuv.app.templates.action.apply.error\" | translate }}</p>\n </div>\n } }\n </main>\n <footer>\n <button [disabled]=\"busy()\" type=\"button\" ymtButton=\"secondary\" (click)=\"cancel()\">{{ \"yuv.app.templates.action.apply.button.cancel\" | translate }}</button>\n <button [disabled]=\"busy() || error() || !selectedTemplate()\" ymtButton=\"primary\" (click)=\"apply()\">{{ \"yuv.app.templates.action.apply.button.ok\" | translate }}</button>\n </footer>\n</yuv-dialog>\n", styles: [":host{--container-width: 300px;display:flex;flex-flow:column;min-width:var(--container-width);max-width:90vw;height:100%}:host main{flex:1;overflow-y:auto;min-height:200px}:host main p{padding:var(--ymt-spacing-m);margin:0}:host main yuv-list{flex:1}:host main yuv-list [yuvListItem]{--icon-size: 24px;--list-item-hover-background: var(--ymt-focus-background);display:grid;padding:var(--ymt-spacing-s) var(--ymt-spacing-m);grid-template-columns:var(--icon-size) auto;grid-template-rows:auto auto;grid-template-areas:\"icon name\" \"icon description\";align-items:center;line-height:1em;column-gap:var(--ymt-spacing-m);row-gap:var(--ymt-spacing-xs);cursor:pointer}:host main yuv-list [yuvListItem] .icon{grid-area:icon}:host main yuv-list [yuvListItem] .name{grid-area:name}:host main yuv-list [yuvListItem] .description{grid-area:description;color:var(--ymt-text-color-subtle)}:host main yuv-list [yuvListItem]:not(:last-child){border-block-end:1px solid var(--ymt-outline-variant)}:host main yuv-pagination{flex:0 0 auto;border-block-start:1px solid var(--ymt-outline-variant)}:host main .hint{height:100%;padding:0;margin:0;display:flex;align-items:center;justify-content:center}\n"] }]
101
+ }] });
102
+
103
+ class ApplyTemplateAction extends AbstractContextAction {
104
+ constructor() {
105
+ super(...arguments);
106
+ this.#translateService = inject(TranslateService$1);
107
+ this.#dialog = inject(MatDialog);
108
+ this.id = APP_ACTIONS.apply;
109
+ this.label = this.#translateService.instant('yuv.app.templates.action.apply.label');
110
+ this.description = this.#translateService.instant('yuv.app.templates.action.apply.description');
111
+ this.icon = APP_ICONS.actionApplyTemplate;
112
+ this.group = 'common';
113
+ this.priority = 0;
114
+ this.range = SelectionRange.SINGLE_SELECT;
115
+ this.supports = {
116
+ types: [SystemType.DOCUMENT],
117
+ };
118
+ }
119
+ #translateService;
120
+ #dialog;
121
+ isExecutable(selection) {
122
+ const i = selection[0];
123
+ return of(i && !i.isFolder);
124
+ }
125
+ run(selection) {
126
+ this.#dialog.open(ApplyTemplateComponent, {
127
+ width: '400px',
128
+ maxWidth: '90vw',
129
+ data: selection[0],
130
+ });
131
+ return of(true);
132
+ }
133
+ }
134
+
135
+ class YuvTemplatesExtension {
136
+ static { this.MAX_TEMPLATES = 20; }
137
+ #actions = [
138
+ { id: APP_ACTIONS.apply, action: ApplyTemplateAction }
139
+ ];
140
+ #actionsService = inject(ActionsService);
141
+ #backendService = inject(BackendService);
142
+ #dmsService = inject(DmsService);
143
+ #eventService = inject(EventService);
144
+ init() {
145
+ this.#actionsService.registerActions(this.#actions);
146
+ return Promise.resolve();
147
+ }
148
+ getTemplatesForObject(object, pageNumber = 0) {
149
+ let searchParams = new HttpParams()
150
+ .set('page', 0)
151
+ .set('size', YuvTemplatesExtension.MAX_TEMPLATES)
152
+ .set('sort', 'name%2Casc')
153
+ .set('published', true)
154
+ .set('type', object.objectTypeId);
155
+ object.sots.forEach((sot) => {
156
+ searchParams = searchParams.append('type', sot);
157
+ });
158
+ return this.#backendService.get(`/template-service/api/objects/?${searchParams}`, ApiBase.none).pipe(map((res) => ({
159
+ pageNumber: pageNumber,
160
+ pageSize: YuvTemplatesExtension.MAX_TEMPLATES,
161
+ totalNumItems: res.totalNumItems,
162
+ items: res.objects.map((obj) => new TemplateObject(obj))
163
+ })));
164
+ }
165
+ applyTemplateOnObject(templateRef, object, silent = false) {
166
+ return this.#backendService.post(`/template-service/api/:createAndSaveDocument?templateRef=${templateRef}&targetObjectId=${object.id}`, { objectData: object.id }, ApiBase.none).pipe(map((res) => {
167
+ return this.#dmsService.coreApiResponseToDmsObject(res);
168
+ })).pipe(switchMap((res) => (!object.id ? of(res) : this.#dmsService.getDmsObject(object.id))), tap((res) => !silent && this.#eventService.trigger(YuvEventType.DMS_OBJECT_UPDATED, res)));
169
+ }
170
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: YuvTemplatesExtension, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
171
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: YuvTemplatesExtension }); }
172
+ }
173
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: YuvTemplatesExtension, decorators: [{
174
+ type: Injectable
175
+ }] });
176
+
177
+ /**
178
+ * Generated bundle index. Do not edit.
179
+ */
180
+
181
+ export { YuvTemplatesExtension };
182
+ //# sourceMappingURL=yuuvis-app-templates-extensions.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"yuuvis-app-templates-extensions.mjs","sources":["../../../../projects/yuuvis/app-templates/extensions/src/lib/actions/apply.component.ts","../../../../projects/yuuvis/app-templates/extensions/src/lib/actions/apply.component.html","../../../../projects/yuuvis/app-templates/extensions/src/lib/actions/apply.action.ts","../../../../projects/yuuvis/app-templates/extensions/src/lib/extensions.service.ts","../../../../projects/yuuvis/app-templates/extensions/src/yuuvis-app-templates-extensions.ts"],"sourcesContent":["import { CommonModule } from '@angular/common';\nimport { Component, effect, inject, input, signal, untracked } from '@angular/core';\nimport { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';\nimport { MatIconModule } from '@angular/material/icon';\nimport { DmsObject, NotificationService, TranslateModule, TranslateService } from '@yuuvis/client-core';\nimport { BusyOverlayDirective, DialogComponent } from '@yuuvis/client-framework/common';\nimport { ListComponent, ListItemDirective } from '@yuuvis/client-framework/list';\nimport { finalize } from 'rxjs';\nimport { MatProgressBarModule } from '@angular/material/progress-bar';\nimport { YmtButtonDirective } from '@yuuvis/material';\nimport { APP_ICONS, TemplateObject, TemplateSearchResponse } from '@yuuvis/app-templates';\nimport { YuvTemplatesExtension } from './../extensions.service';\n\nconst components = [\n BusyOverlayDirective,\n ListComponent,\n ListItemDirective,\n DialogComponent,\n YmtButtonDirective\n];\n\nconst modules = [\n CommonModule,\n TranslateModule,\n MatIconModule,\n MatProgressBarModule,\n];\n\n@Component({\n selector: 'ymtmpl-apply',\n templateUrl: './apply.component.html',\n styleUrls: ['./apply.component.scss'],\n standalone: true,\n imports: [...modules, ...components]\n})\nexport class ApplyTemplateComponent {\n\n readonly #extension = inject(YuvTemplatesExtension);\n readonly #notificationService = inject(NotificationService);\n readonly #translateService = inject(TranslateService);\n\n #dialogData = inject<DmsObject>(MAT_DIALOG_DATA);\n readonly #dialogRef = inject(MatDialogRef<ApplyTemplateComponent>);\n\n dmsObject = input<DmsObject>(this.#dialogData);\n\n #dmsObjectEffect = effect(() => {\n if (this.dmsObject())\n untracked(() => {\n this.#init()\n });\n });\n\n supportedTemplates = signal<TemplateObject[]>([]);\n\n selectedTemplate = signal<TemplateObject | undefined>(undefined);\n\n busy = signal<boolean>(false);\n\n error = signal<boolean>(false);\n\n icons = {\n ...APP_ICONS\n };\n\n #init() {\n this.busy.set(true)\n this.#extension.getTemplatesForObject(this.dmsObject())\n .pipe(finalize(() => this.busy.set(false)))\n .subscribe({\n next: (res: TemplateSearchResponse) => {\n this.error.set(false);\n this.supportedTemplates.set(res.items);\n },\n error: () => {\n this.error.set(true);\n }\n });\n }\n\n onItemSelect(idx: number[]) {\n this.selectedTemplate.set(this.supportedTemplates()[idx[0]]);\n }\n\n cancel() {\n this.#dialogRef.close();\n }\n \n apply() {\n this.busy.set(true)\n this.#extension.applyTemplateOnObject(`obj:${this.selectedTemplate()?.id}`, this.dmsObject()).subscribe({\n next: () => {\n this.#notificationService.success(this.#translateService.instant('yuv.app.templates.action.apply.success'));\n },\n error: (err: any) => {\n this.#notificationService.error(err);\n this.busy.set(false);\n },\n complete: () => {\n this.#dialogRef.close();\n }\n });\n }\n} \n","<yuv-dialog [headertitel]=\"'yuv.app.templates.action.apply.headline' | translate\">\n <main [yuvBusyOverlay]=\"busy()\">\n @let templates = supportedTemplates(); @if (templates.length) {\n <p>{{ \"yuv.app.templates.action.apply.text\" | translate }}</p>\n <yuv-list selectOnEnter=\"true\" (itemSelect)=\"onItemSelect($event)\">\n @for (t of templates; track $index) {\n <div yuvListItem>\n <mat-icon class=\"icon\">{{ icons.actionApplyTemplate }}</mat-icon>\n <div class=\"name\">{{ t.name }}</div>\n <div class=\"description\">{{ t.description }}</div>\n </div>\n }\n </yuv-list>\n } @else if (!busy()) { @if (!error()) {\n <div class=\"hint empty\">\n <p>{{ \"yuv.app.templates.action.apply.list.empty\" | translate }}</p>\n </div>\n } @else {\n <div class=\"hint error\">\n <p>{{ \"yuv.app.templates.action.apply.error\" | translate }}</p>\n </div>\n } }\n </main>\n <footer>\n <button [disabled]=\"busy()\" type=\"button\" ymtButton=\"secondary\" (click)=\"cancel()\">{{ \"yuv.app.templates.action.apply.button.cancel\" | translate }}</button>\n <button [disabled]=\"busy() || error() || !selectedTemplate()\" ymtButton=\"primary\" (click)=\"apply()\">{{ \"yuv.app.templates.action.apply.button.ok\" | translate }}</button>\n </footer>\n</yuv-dialog>\n","import { inject } from '@angular/core';\nimport { TranslateService } from '@ngx-translate/core';\nimport { DmsObject, SystemType } from '@yuuvis/client-core';\nimport {\n AbstractContextAction,\n Action,\n ActionSupport,\n SelectionRange,\n} from '@yuuvis/client-framework/actions';\nimport { Observable, of } from 'rxjs';\nimport { MatDialog } from '@angular/material/dialog';\nimport { APP_ACTIONS, APP_ICONS } from '@yuuvis/app-templates';\nimport { ApplyTemplateComponent } from './apply.component';\n\nexport class ApplyTemplateAction\n extends AbstractContextAction\n implements Action\n{\n readonly #translateService = inject(TranslateService);\n #dialog = inject(MatDialog);\n\n id = APP_ACTIONS.apply;\n label = this.#translateService.instant(\n 'yuv.app.templates.action.apply.label'\n );\n description = this.#translateService.instant(\n 'yuv.app.templates.action.apply.description'\n );\n icon = APP_ICONS.actionApplyTemplate;\n group = 'common';\n priority = 0;\n range = SelectionRange.SINGLE_SELECT;\n supports: ActionSupport = {\n types: [SystemType.DOCUMENT],\n };\n\n isExecutable(selection: DmsObject[]) {\n const i = selection[0];\n return of(i && !i.isFolder);\n }\n\n run(selection: DmsObject[]): Observable<boolean> {\n this.#dialog.open(ApplyTemplateComponent, {\n width: '400px',\n maxWidth: '90vw',\n data: selection[0],\n });\n return of(true);\n }\n}\n","import { HttpParams } from '@angular/common/http';\nimport { inject, Injectable } from '@angular/core';\nimport { ApiBase, BackendService, CoreApiObject, CoreApiResponse, DmsObject, DmsService, EventService, SearchResponse, YuvEventType } from '@yuuvis/client-core';\nimport { ActionsService } from '@yuuvis/client-framework/actions';\nimport { ClientShellExtension } from '@yuuvis/client-shell-core';\nimport { map, Observable, of, switchMap, tap } from 'rxjs';\nimport { APP_ACTIONS, TemplateObject, TemplateSearchResponse } from '@yuuvis/app-templates';\nimport { ApplyTemplateAction } from './actions/apply.action';\n\n@Injectable()\nexport class YuvTemplatesExtension implements ClientShellExtension {\n static MAX_TEMPLATES = 20;\n\n readonly #actions = [\n { id: APP_ACTIONS.apply, action: ApplyTemplateAction }\n ];\n\n readonly #actionsService = inject(ActionsService);\n readonly #backendService = inject(BackendService);\n readonly #dmsService = inject(DmsService);\n readonly #eventService = inject(EventService);\n \n init(): Promise<any> {\n this.#actionsService.registerActions(this.#actions);\n return Promise.resolve();\n }\n\n getTemplatesForObject(object: DmsObject, pageNumber = 0): Observable<TemplateSearchResponse> {\n let searchParams = new HttpParams()\n .set('page', 0)\n .set('size', YuvTemplatesExtension.MAX_TEMPLATES)\n .set('sort', 'name%2Casc')\n .set('published', true)\n .set('type', object.objectTypeId);\n\n object.sots.forEach((sot) => { \n searchParams = searchParams.append('type', sot)\n });\n\n return this.#backendService.get(`/template-service/api/objects/?${searchParams}`, ApiBase.none).pipe(\n map((res: SearchResponse) => ({\n pageNumber: pageNumber,\n pageSize: YuvTemplatesExtension.MAX_TEMPLATES,\n totalNumItems: res.totalNumItems,\n items: res.objects.map((obj: CoreApiObject) => new TemplateObject(obj))\n }))\n );\n }\n\n applyTemplateOnObject(templateRef: String, object: DmsObject, silent = false): Observable<DmsObject> {\n return this.#backendService.post(`/template-service/api/:createAndSaveDocument?templateRef=${templateRef}&targetObjectId=${object.id}`, { objectData: object.id }, ApiBase.none).pipe(\n map((res: CoreApiResponse) => {\n return this.#dmsService.coreApiResponseToDmsObject(res)\n })\n ).pipe(\n switchMap((res) => (!object.id ? of(res) : this.#dmsService.getDmsObject(object.id))),\n tap((res: any) => !silent && this.#eventService.trigger(YuvEventType.DMS_OBJECT_UPDATED, res))\n );\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["TranslateService"],"mappings":";;;;;;;;;;;;;;;;;;AAaA,MAAM,UAAU,GAAG;IACjB,oBAAoB;IACpB,aAAa;IACb,iBAAiB;IACjB,eAAe;IACf;CACD;AAED,MAAM,OAAO,GAAG;IACd,YAAY;IACZ,eAAe;IACf,aAAa;IACb,oBAAoB;CACrB;MASY,sBAAsB,CAAA;AAPnC,IAAA,WAAA,GAAA;AASW,QAAA,IAAA,CAAA,UAAU,GAAG,MAAM,CAAC,qBAAqB,CAAC;AAC1C,QAAA,IAAA,CAAA,oBAAoB,GAAG,MAAM,CAAC,mBAAmB,CAAC;AAClD,QAAA,IAAA,CAAA,iBAAiB,GAAG,MAAM,CAAC,gBAAgB,CAAC;AAErD,QAAA,IAAA,CAAA,WAAW,GAAG,MAAM,CAAY,eAAe,CAAC;AACvC,QAAA,IAAA,CAAA,UAAU,GAAG,MAAM,EAAC,YAAoC,EAAC;AAElE,QAAA,IAAA,CAAA,SAAS,GAAG,KAAK,CAAY,IAAI,CAAC,WAAW,CAAC;AAE9C,QAAA,IAAA,CAAA,gBAAgB,GAAG,MAAM,CAAC,MAAK;YAC7B,IAAI,IAAI,CAAC,SAAS,EAAE;gBAClB,SAAS,CAAC,MAAK;oBACb,IAAI,CAAC,KAAK,EAAE;AACd,iBAAC,CAAC;AACN,SAAC,CAAC;AAEF,QAAA,I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