@myrmidon/cadmus-thesaurus-list 17.0.0 → 20.0.0

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.
@@ -1,570 +1,1071 @@
1
- import * as i0 from '@angular/core';
2
- import { Injectable, ChangeDetectionStrategy, Component, inject, DestroyRef, output, signal } from '@angular/core';
3
- import * as i1 from '@angular/forms';
4
- import { FormsModule, ReactiveFormsModule, Validators, FormControl, FormGroup } from '@angular/forms';
5
- import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
6
- import { MatFormField, MatLabel, MatHint, MatError } from '@angular/material/form-field';
7
- import { MatInput } from '@angular/material/input';
8
- import { MatSelect, MatError as MatError$1, MatFormField as MatFormField$1, MatLabel as MatLabel$1 } from '@angular/material/select';
9
- import { MatOption } from '@angular/material/core';
10
- import { MatIconButton, MatButton } from '@angular/material/button';
11
- import { MatTooltip } from '@angular/material/tooltip';
12
- import { MatIcon } from '@angular/material/icon';
13
- import { BehaviorSubject, tap, switchMap, of, map, catchError, filter, finalize } from 'rxjs';
14
- import { PagedListStore } from '@myrmidon/paged-data-browsers';
15
- import * as i2 from '@myrmidon/cadmus-api';
16
- import { MatPaginator } from '@angular/material/paginator';
17
- import { AsyncPipe } from '@angular/common';
18
- import { MatCard, MatCardHeader, MatCardTitle, MatCardContent } from '@angular/material/card';
19
- import { MatProgressBar } from '@angular/material/progress-bar';
20
- import { MatExpansionPanel, MatExpansionPanelHeader, MatExpansionPanelTitle } from '@angular/material/expansion';
21
- import { HttpEventType } from '@angular/common/http';
22
- import { MatCheckbox } from '@angular/material/checkbox';
23
- import * as i2$1 from '@myrmidon/ngx-tools';
24
- import * as i3 from '@myrmidon/ngx-mat-tools';
25
- import * as i4 from '@angular/router';
26
- import * as i5 from '@myrmidon/auth-jwt-login';
27
- import * as i6 from '@angular/material/snack-bar';
28
-
29
- /**
30
- * Thesauri list repository.
31
- */
32
- class ThesaurusListRepository {
33
- _thesaurusService;
34
- _store;
35
- _loading$;
36
- get loading$() {
37
- return this._loading$.asObservable();
38
- }
39
- get filter$() {
40
- return this._store.filter$;
41
- }
42
- get page$() {
43
- return this._store.page$;
44
- }
45
- constructor(_thesaurusService) {
46
- this._thesaurusService = _thesaurusService;
47
- this._store = new PagedListStore(this);
48
- this._loading$ = new BehaviorSubject(undefined);
49
- this._store.reset();
50
- }
51
- loadPage(pageNumber, pageSize, filter) {
52
- this._loading$.next(true);
53
- return this._thesaurusService
54
- .getThesauri(filter, pageNumber, pageSize)
55
- .pipe(tap({
56
- next: () => this._loading$.next(false),
57
- error: () => this._loading$.next(false),
58
- }));
59
- }
60
- async reset() {
61
- this._loading$.next(true);
62
- try {
63
- await this._store.reset();
64
- }
65
- catch (error) {
66
- throw error;
67
- }
68
- finally {
69
- this._loading$.next(false);
70
- }
71
- }
72
- async setFilter(filter) {
73
- this._loading$.next(true);
74
- try {
75
- await this._store.setFilter(filter);
76
- }
77
- catch (error) {
78
- throw error;
79
- }
80
- finally {
81
- this._loading$.next(false);
82
- }
83
- }
84
- async setPage(pageNumber, pageSize) {
85
- this._loading$.next(true);
86
- try {
87
- await this._store.setPage(pageNumber, pageSize);
88
- }
89
- catch (error) {
90
- throw error;
91
- }
92
- finally {
93
- this._loading$.next(false);
94
- }
95
- }
96
- deleteThesaurus(id) {
97
- this._loading$.next(true);
98
- this._thesaurusService.deleteThesaurus(id).subscribe({
99
- next: () => {
100
- this._store.reset();
101
- },
102
- error: (error) => {
103
- console.error(error);
104
- this._loading$.next(false);
105
- },
106
- });
107
- }
108
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: ThesaurusListRepository, deps: [{ token: i2.ThesaurusService }], target: i0.ɵɵFactoryTarget.Injectable });
109
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: ThesaurusListRepository, providedIn: 'root' });
110
- }
111
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: ThesaurusListRepository, decorators: [{
112
- type: Injectable,
113
- args: [{ providedIn: 'root' }]
114
- }], ctorParameters: () => [{ type: i2.ThesaurusService }] });
115
-
116
- class ThesaurusFilterComponent {
117
- _repository;
118
- filter$;
119
- id;
120
- alias;
121
- language;
122
- form;
123
- constructor(formBuilder, _repository) {
124
- this._repository = _repository;
125
- this.filter$ = _repository.filter$;
126
- // form
127
- this.id = formBuilder.control('', { nonNullable: true });
128
- this.alias = formBuilder.control(false, { nonNullable: true });
129
- this.language = formBuilder.control('en', {
130
- nonNullable: true,
131
- });
132
- this.form = formBuilder.group({
133
- id: this.id,
134
- alias: this.alias,
135
- language: this.language,
136
- });
137
- // update form when filter changes
138
- this.filter$?.pipe(takeUntilDestroyed()).subscribe((f) => {
139
- this.updateForm(f);
140
- });
141
- }
142
- updateForm(filter) {
143
- this.id.setValue(filter.id || '');
144
- this.alias.setValue(filter.isAlias || false);
145
- this.language.setValue(filter.language || 'en');
146
- this.form.markAsPristine();
147
- }
148
- getFilter() {
149
- return {
150
- id: this.id.value,
151
- isAlias: this.alias.value || false,
152
- language: this.language.value,
153
- };
154
- }
155
- reset() {
156
- this.form.reset();
157
- this.apply();
158
- }
159
- apply() {
160
- if (this.form.invalid) {
161
- return;
162
- }
163
- const filter = this.getFilter();
164
- this._repository.setFilter(filter);
165
- }
166
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: ThesaurusFilterComponent, deps: [{ token: i1.FormBuilder }, { token: ThesaurusListRepository }], target: i0.ɵɵFactoryTarget.Component });
167
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.0.0", type: ThesaurusFilterComponent, isStandalone: true, selector: "cadmus-thesaurus-filter", ngImport: i0, template: "<form role=\"form\" [formGroup]=\"form\" (submit)=\"apply()\">\r\n <div class=\"form-row\">\r\n <!-- id -->\r\n <div>\r\n <mat-form-field>\r\n <mat-label>ID</mat-label>\r\n <input matInput formControlName=\"id\" maxlength=\"100\" />\r\n </mat-form-field>\r\n </div>\r\n\r\n <!-- language -->\r\n <div>\r\n <mat-form-field>\r\n <mat-label>language</mat-label>\r\n <input matInput formControlName=\"language\" maxlength=\"2\" />\r\n </mat-form-field>\r\n </div>\r\n\r\n <!-- alias -->\r\n <div>\r\n <mat-form-field>\r\n <mat-label>alias</mat-label>\r\n <mat-select formControlName=\"alias\">\r\n <mat-option [value]=\"null\">(any)</mat-option>\r\n <mat-option [value]=\"true\">alias</mat-option>\r\n <mat-option [value]=\"false\">not an alias</mat-option>\r\n </mat-select>\r\n </mat-form-field>\r\n </div>\r\n </div>\r\n\r\n <div>\r\n <button\r\n type=\"button\"\r\n mat-icon-button\r\n (click)=\"reset()\"\r\n matTooltip=\"Reset all the filters\"\r\n >\r\n <mat-icon class=\"mat-warn\">clear</mat-icon>\r\n </button>\r\n <button\r\n type=\"submit\"\r\n mat-icon-button\r\n [disabled]=\"form.invalid\"\r\n matTooltip=\"Apply filters\"\r\n >\r\n <mat-icon class=\"mat-primary\">check_circle</mat-icon>\r\n </button>\r\n </div>\r\n</form>\r\n", styles: [".form-row{display:flex;gap:8px;align-items:center;flex-wrap:wrap}.form-row *{flex:0 0 auto}\n"], dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox]):not([ngNoCva])[formControlName],textarea:not([ngNoCva])[formControlName],input:not([type=checkbox]):not([ngNoCva])[formControl],textarea:not([ngNoCva])[formControl],input:not([type=checkbox]):not([ngNoCva])[ngModel],textarea:not([ngNoCva])[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],[formArray],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1.MaxLengthValidator, selector: "[maxlength][formControlName],[maxlength][formControl],[maxlength][ngModel]", inputs: ["maxlength"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "component", type: MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: MatLabel, selector: "mat-label" }, { kind: "directive", type: MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly", "disabledInteractive"], exportAs: ["matInput"] }, { kind: "component", type: MatSelect, selector: "mat-select", inputs: ["aria-describedby", "panelClass", "disabled", "disableRipple", "tabIndex", "hideSingleSelectionIndicator", "placeholder", "required", "multiple", "disableOptionCentering", "compareWith", "value", "aria-label", "aria-labelledby", "errorStateMatcher", "typeaheadDebounceInterval", "sortComparator", "id", "panelWidth", "canSelectNullableOptions"], outputs: ["openedChange", "opened", "closed", "selectionChange", "valueChange"], exportAs: ["matSelect"] }, { kind: "component", type: MatOption, selector: "mat-option", inputs: ["value", "id", "disabled"], outputs: ["onSelectionChange"], exportAs: ["matOption"] }, { kind: "component", type: MatIconButton, selector: "button[mat-icon-button], a[mat-icon-button], button[matIconButton], a[matIconButton]", exportAs: ["matButton", "matAnchor"] }, { kind: "directive", type: MatTooltip, selector: "[matTooltip]", inputs: ["matTooltipPosition", "matTooltipPositionAtOrigin", "matTooltipDisabled", "matTooltipShowDelay", "matTooltipHideDelay", "matTooltipTouchGestures", "matTooltip", "matTooltipClass"], exportAs: ["matTooltip"] }, { kind: "component", type: MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
168
- }
169
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: ThesaurusFilterComponent, decorators: [{
170
- type: Component,
171
- args: [{ selector: 'cadmus-thesaurus-filter', changeDetection: ChangeDetectionStrategy.OnPush, imports: [
172
- FormsModule,
173
- ReactiveFormsModule,
174
- MatFormField,
175
- MatLabel,
176
- MatInput,
177
- MatSelect,
178
- MatOption,
179
- MatIconButton,
180
- MatTooltip,
181
- MatIcon,
182
- ], template: "<form role=\"form\" [formGroup]=\"form\" (submit)=\"apply()\">\r\n <div class=\"form-row\">\r\n <!-- id -->\r\n <div>\r\n <mat-form-field>\r\n <mat-label>ID</mat-label>\r\n <input matInput formControlName=\"id\" maxlength=\"100\" />\r\n </mat-form-field>\r\n </div>\r\n\r\n <!-- language -->\r\n <div>\r\n <mat-form-field>\r\n <mat-label>language</mat-label>\r\n <input matInput formControlName=\"language\" maxlength=\"2\" />\r\n </mat-form-field>\r\n </div>\r\n\r\n <!-- alias -->\r\n <div>\r\n <mat-form-field>\r\n <mat-label>alias</mat-label>\r\n <mat-select formControlName=\"alias\">\r\n <mat-option [value]=\"null\">(any)</mat-option>\r\n <mat-option [value]=\"true\">alias</mat-option>\r\n <mat-option [value]=\"false\">not an alias</mat-option>\r\n </mat-select>\r\n </mat-form-field>\r\n </div>\r\n </div>\r\n\r\n <div>\r\n <button\r\n type=\"button\"\r\n mat-icon-button\r\n (click)=\"reset()\"\r\n matTooltip=\"Reset all the filters\"\r\n >\r\n <mat-icon class=\"mat-warn\">clear</mat-icon>\r\n </button>\r\n <button\r\n type=\"submit\"\r\n mat-icon-button\r\n [disabled]=\"form.invalid\"\r\n matTooltip=\"Apply filters\"\r\n >\r\n <mat-icon class=\"mat-primary\">check_circle</mat-icon>\r\n </button>\r\n </div>\r\n</form>\r\n", styles: [".form-row{display:flex;gap:8px;align-items:center;flex-wrap:wrap}.form-row *{flex:0 0 auto}\n"] }]
183
- }], ctorParameters: () => [{ type: i1.FormBuilder }, { type: ThesaurusListRepository }] });
184
-
185
- class FileExtensionValidator {
186
- allowedExtensions;
187
- constructor(allowedExtensions) {
188
- this.allowedExtensions = allowedExtensions;
189
- }
190
- validate(control) {
191
- const file = control.value;
192
- if (file) {
193
- const fileName = file.name;
194
- const extension = fileName.split('.').pop();
195
- if (!this.allowedExtensions.includes(extension)) {
196
- return { invalidExtension: true };
197
- }
198
- }
199
- return null;
200
- }
1
+ import * as i0 from "@angular/core";
2
+ import { ChangeDetectionStrategy, Component, DestroyRef, Injectable, inject, linkedSignal, output, signal } from "@angular/core";
3
+ import { FormField, FormRoot, form, maxLength, min, required, validate } from "@angular/forms/signals";
4
+ import { BehaviorSubject, catchError, filter, finalize, map, of, switchMap, tap } from "rxjs";
5
+ import { takeUntilDestroyed, toSignal } from "@angular/core/rxjs-interop";
6
+ import { MatError, MatFormField, MatHint, MatLabel } from "@angular/material/form-field";
7
+ import { MatInput } from "@angular/material/input";
8
+ import { MatError as MatError$1, MatFormField as MatFormField$1, MatLabel as MatLabel$1, MatSelect } from "@angular/material/select";
9
+ import { MatOption } from "@angular/material/core";
10
+ import { MatButton, MatIconButton } from "@angular/material/button";
11
+ import { MatTooltip } from "@angular/material/tooltip";
12
+ import { MatIcon } from "@angular/material/icon";
13
+ import { PagedListStore } from "@myrmidon/paged-data-browsers";
14
+ import * as i1$1 from "@myrmidon/cadmus-api";
15
+ import { MatPaginator } from "@angular/material/paginator";
16
+ import { AsyncPipe } from "@angular/common";
17
+ import { MatCard, MatCardContent, MatCardHeader, MatCardTitle } from "@angular/material/card";
18
+ import { MatProgressBar } from "@angular/material/progress-bar";
19
+ import { MatExpansionPanel, MatExpansionPanelHeader, MatExpansionPanelTitle } from "@angular/material/expansion";
20
+ import { HttpEventType } from "@angular/common/http";
21
+ import { MatCheckbox } from "@angular/material/checkbox";
22
+ import * as i1 from "@myrmidon/ngx-tools";
23
+ import * as i3 from "@myrmidon/ngx-mat-tools";
24
+ import * as i4 from "@angular/router";
25
+ import * as i5 from "@myrmidon/auth-jwt-login";
26
+ import * as i6 from "@angular/material/snack-bar";
27
+ var ThesaurusListRepository = class ThesaurusListRepository {
28
+ _thesaurusService;
29
+ _store;
30
+ _loading$;
31
+ get loading$() {
32
+ return this._loading$.asObservable();
33
+ }
34
+ get filter$() {
35
+ return this._store.filter$;
36
+ }
37
+ get page$() {
38
+ return this._store.page$;
39
+ }
40
+ constructor(_thesaurusService) {
41
+ this._thesaurusService = _thesaurusService;
42
+ this._store = new PagedListStore(this);
43
+ this._loading$ = new BehaviorSubject(void 0);
44
+ this._store.reset();
45
+ }
46
+ loadPage(pageNumber, pageSize, filter) {
47
+ this._loading$.next(true);
48
+ return this._thesaurusService.getThesauri(filter, pageNumber, pageSize).pipe(tap({
49
+ next: () => this._loading$.next(false),
50
+ error: () => this._loading$.next(false)
51
+ }));
52
+ }
53
+ async reset() {
54
+ this._loading$.next(true);
55
+ try {
56
+ await this._store.reset();
57
+ } catch (error) {
58
+ throw error;
59
+ } finally {
60
+ this._loading$.next(false);
61
+ }
62
+ }
63
+ async setFilter(filter) {
64
+ this._loading$.next(true);
65
+ try {
66
+ await this._store.setFilter(filter);
67
+ } catch (error) {
68
+ throw error;
69
+ } finally {
70
+ this._loading$.next(false);
71
+ }
72
+ }
73
+ async setPage(pageNumber, pageSize) {
74
+ this._loading$.next(true);
75
+ try {
76
+ await this._store.setPage(pageNumber, pageSize);
77
+ } catch (error) {
78
+ throw error;
79
+ } finally {
80
+ this._loading$.next(false);
81
+ }
82
+ }
83
+ deleteThesaurus(id) {
84
+ this._loading$.next(true);
85
+ this._thesaurusService.deleteThesaurus(id).subscribe({
86
+ next: () => {
87
+ this._store.reset();
88
+ },
89
+ error: (error) => {
90
+ console.error(error);
91
+ this._loading$.next(false);
92
+ }
93
+ });
94
+ }
95
+ static ɵfac = i0.ɵɵngDeclareFactory({
96
+ minVersion: "12.0.0",
97
+ version: "22.2.0",
98
+ ngImport: i0,
99
+ type: ThesaurusListRepository,
100
+ deps: [{ token: i1$1.ThesaurusService }],
101
+ target: i0.ɵɵFactoryTarget.Injectable
102
+ });
103
+ static ɵprov = i0.ɵɵngDeclareInjectable({
104
+ minVersion: "12.0.0",
105
+ version: "22.2.0",
106
+ ngImport: i0,
107
+ type: ThesaurusListRepository,
108
+ providedIn: "root"
109
+ });
110
+ };
111
+ i0.ɵɵngDeclareClassMetadata({
112
+ minVersion: "12.0.0",
113
+ version: "22.2.0",
114
+ ngImport: i0,
115
+ type: ThesaurusListRepository,
116
+ decorators: [{
117
+ type: Injectable,
118
+ args: [{ providedIn: "root" }]
119
+ }],
120
+ ctorParameters: () => [{ type: i1$1.ThesaurusService }]
121
+ });
122
+ function makeEmptyDraft() {
123
+ return {
124
+ id: "",
125
+ alias: null,
126
+ language: "en"
127
+ };
201
128
  }
202
- /**
203
- * Thesaurus import component.
204
- */
205
- class ThesaurusImportComponent {
206
- _env;
207
- _uploadService;
208
- _destroyRef = inject(DestroyRef);
209
- _sub;
210
- uploadStart = output();
211
- uploadEnd = output();
212
- file;
213
- mode;
214
- excelSheet;
215
- excelRow;
216
- excelColumn;
217
- dryRun;
218
- form;
219
- uploadProgress = signal(0, /* @ts-ignore */
220
- ...(ngDevMode ? [{ debugName: "uploadProgress" }] : /* istanbul ignore next */ []));
221
- uploading = signal(false, /* @ts-ignore */
222
- ...(ngDevMode ? [{ debugName: "uploading" }] : /* istanbul ignore next */ []));
223
- result = signal(undefined, /* @ts-ignore */
224
- ...(ngDevMode ? [{ debugName: "result" }] : /* istanbul ignore next */ []));
225
- constructor(formBuilder, _env, _uploadService) {
226
- this._env = _env;
227
- this._uploadService = _uploadService;
228
- this._destroyRef.onDestroy(() => this._sub?.unsubscribe());
229
- const fileExtensionValidator = new FileExtensionValidator([
230
- 'json',
231
- 'csv',
232
- 'xls',
233
- 'xlsx',
234
- ]);
235
- this.file = formBuilder.control(null, [
236
- Validators.required,
237
- (control) => fileExtensionValidator.validate(control),
238
- ]);
239
- this.mode = formBuilder.control('R', {
240
- validators: Validators.required,
241
- nonNullable: true,
242
- });
243
- this.excelSheet = formBuilder.control(1, {
244
- nonNullable: true,
245
- validators: [Validators.min(1)],
246
- });
247
- this.excelRow = formBuilder.control(1, {
248
- nonNullable: true,
249
- validators: [Validators.min(1)],
250
- });
251
- this.excelColumn = formBuilder.control(1, {
252
- nonNullable: true,
253
- validators: [Validators.min(1)],
254
- });
255
- this.dryRun = formBuilder.control(false, {
256
- nonNullable: true,
257
- });
258
- this.form = formBuilder.group({
259
- file: this.file,
260
- mode: this.mode,
261
- excelSheet: this.excelSheet,
262
- excelRow: this.excelRow,
263
- excelColumn: this.excelColumn,
264
- dryRun: this.dryRun,
265
- });
266
- }
267
- onFileSelected(event) {
268
- this.file.setValue(event.target.files[0]);
269
- }
270
- upload() {
271
- if (!this.form.valid) {
272
- return;
273
- }
274
- this.result.set(undefined);
275
- this.uploading.set(true);
276
- this.uploadStart.emit();
277
- // build URL with proper query string
278
- const params = [];
279
- if (this.mode.value !== 'R') {
280
- params.push(`mode=${this.mode.value}`);
281
- }
282
- if (this.excelSheet.value !== 1) {
283
- params.push(`excelSheet=${this.excelSheet.value}`);
284
- }
285
- if (this.excelRow.value !== 1) {
286
- params.push(`excelRow=${this.excelRow.value}`);
287
- }
288
- if (this.excelColumn.value !== 1) {
289
- params.push(`excelColumn=${this.excelColumn.value}`);
290
- }
291
- if (this.dryRun.value) {
292
- params.push('dryRun=true');
293
- }
294
- let url = `${this._env.get('apiUrl')}thesauri/import`;
295
- if (params.length) {
296
- url += '?' + params.join('&');
297
- }
298
- this._sub = this._uploadService
299
- .uploadFile(this.file.value, url, {
300
- reportProgress: true,
301
- })
302
- .subscribe({
303
- next: (event) => {
304
- if (event.type === HttpEventType.UploadProgress) {
305
- this.uploadProgress.set(Math.round((event.loaded / event.total) * 100));
306
- }
307
- else if (event.type === HttpEventType.Response) {
308
- this.uploading.set(false);
309
- this.result.set(event.body);
310
- this.uploadEnd.emit(true);
311
- }
312
- },
313
- error: (error) => {
314
- console.error(error);
315
- this.uploading.set(false);
316
- this.uploadProgress.set(0);
317
- this.uploadEnd.emit(false);
318
- },
319
- });
320
- }
321
- onCancel() {
322
- this._sub?.unsubscribe();
323
- this.uploading.set(false);
324
- this.uploadProgress.set(0);
325
- this.uploadEnd.emit(false);
326
- }
327
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: ThesaurusImportComponent, deps: [{ token: i1.FormBuilder }, { token: i2$1.EnvService }, { token: i2.UploadService }], target: i0.ɵɵFactoryTarget.Component });
328
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.0", type: ThesaurusImportComponent, isStandalone: true, selector: "cadmus-thesaurus-import", outputs: { uploadStart: "uploadStart", uploadEnd: "uploadEnd" }, ngImport: i0, template: "<!-- form -->\r\n<form [formGroup]=\"form\" (submit)=\"upload()\">\r\n <fieldset>\r\n <legend>source</legend>\r\n\r\n <!-- file picker -->\r\n <div>\r\n <input\r\n #fileInput\r\n type=\"file\"\r\n class=\"hidden\"\r\n (change)=\"onFileSelected($event)\"\r\n />\r\n <button\r\n type=\"button\"\r\n mat-flat-button\r\n class=\"mat-primary\"\r\n (click)=\"fileInput.click()\"\r\n [disabled]=\"uploading()\"\r\n >\r\n select file\r\n </button>\r\n <span class=\"file-name\">{{ file.value?.name }}</span>\r\n @if ($any(file).errors?.required) {\r\n <span class=\"error\">file required</span>\r\n } @if ($any(file).errors?.invalidExtension) {\r\n <span class=\"error\">invalid file type</span>\r\n }\r\n </div>\r\n <br />\r\n\r\n <!-- mode -->\r\n <div class=\"form-row\">\r\n <mat-form-field>\r\n <mat-label>mode</mat-label>\r\n <mat-select [formControl]=\"mode\">\r\n <mat-option value=\"R\">replace</mat-option>\r\n <mat-option value=\"P\">patch</mat-option>\r\n <mat-option value=\"S\">synch</mat-option>\r\n </mat-select>\r\n <mat-hint>\r\n @if (mode.value === 'R') {\r\n <span\r\n >if the imported thesaurus already exists, it is fully replaced by\r\n the new one.</span\r\n >\r\n } @if (mode.value === 'P') {\r\n <span\r\n >the existing thesaurus is patched with the imported one: any\r\n existing entry has its value overwritten; any non existing entry is\r\n just added.</span\r\n >\r\n } @if (mode.value === 'S') {\r\n <span\r\n >equal to patch, with the addition that any existing entry not found\r\n in the imported thesaurus is removed.</span\r\n >\r\n }\r\n </mat-hint>\r\n @if ($any(mode).errors?.required && (mode.dirty || mode.touched)) {\r\n <mat-error>mode required</mat-error>\r\n }\r\n </mat-form-field>\r\n\r\n <!-- dry -->\r\n <mat-checkbox [formControl]=\"dryRun\">dry run</mat-checkbox>\r\n </div>\r\n\r\n <!-- Excel -->\r\n @if ( file.value?.name?.endsWith('.xlsx') ||\r\n file.value?.name?.endsWith('.xls') ) {\r\n <div>\r\n <fieldset>\r\n <legend>Excel</legend>\r\n <div class=\"form-row\">\r\n <!-- excelSheet -->\r\n <mat-form-field class=\"nr-input\">\r\n <mat-label>sheet</mat-label>\r\n <input matInput type=\"number\" min=\"1\" [formControl]=\"excelSheet\" />\r\n </mat-form-field>\r\n <!-- excelRow -->\r\n <mat-form-field class=\"nr-input\">\r\n <mat-label>1st row</mat-label>\r\n <input matInput type=\"number\" min=\"1\" [formControl]=\"excelRow\" />\r\n </mat-form-field>\r\n <!-- excelColumn -->\r\n <mat-form-field class=\"nr-input\">\r\n <mat-label>1st column</mat-label>\r\n <input matInput type=\"number\" min=\"1\" [formControl]=\"excelColumn\" />\r\n </mat-form-field>\r\n </div>\r\n </fieldset>\r\n </div>\r\n }\r\n\r\n <!-- submit -->\r\n <div style=\"margin-top: 16px\">\r\n <button\r\n type=\"submit\"\r\n mat-flat-button\r\n class=\"mat-warn\"\r\n [disabled]=\"uploading() || form.invalid\"\r\n >\r\n upload\r\n </button>\r\n </div>\r\n </fieldset>\r\n</form>\r\n\r\n<!-- uploading -->\r\n@if (uploading()) {\r\n<div>\r\n <div>\r\n <button type=\"button\" mat-flat-button class=\"mat-warn\" (click)=\"onCancel()\">\r\n cancel\r\n </button>\r\n </div>\r\n <div style=\"margin-top: 16px\">\r\n <mat-progress-bar max=\"100\" [value]=\"uploadProgress()\"></mat-progress-bar>\r\n </div>\r\n</div>\r\n}\r\n\r\n<!-- result -->\r\n@if (result()) {\r\n<div>\r\n @if (result()!.error) {\r\n <div class=\"error\">{{ result()!.error }}</div>\r\n } @if (result()!.importedIds.length) {\r\n <div>\r\n <div>\r\n <mat-card>\r\n <mat-card-header>\r\n <mat-card-title>Imported IDs</mat-card-title>\r\n </mat-card-header>\r\n <mat-card-content>\r\n <ol>\r\n @for (id of result()!.importedIds; track id) {\r\n <li>{{ id }}</li>\r\n }\r\n </ol>\r\n </mat-card-content>\r\n </mat-card>\r\n </div>\r\n </div>\r\n }\r\n</div>\r\n}\r\n", styles: ["fieldset{border:1px solid #ddd;border-radius:4px;margin:8px 0;padding:8px}legend{color:var(--mat-sys-on-surface-variant)}.hidden{display:none}.file-name{color:var(--mat-sys-primary);margin-left:16px}.nr-input{width:6em}.form-row{display:flex;gap:8px;align-items:center;flex-wrap:wrap}.form-row *{flex:0 0 auto}.error{margin:8px;color:var(--mat-sys-on-error);padding:4px 8px;background-color:var(--mat-sys-error);border:1px solid var(--mat-sys-error);border-radius:6px}\n"], dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox]):not([ngNoCva])[formControlName],textarea:not([ngNoCva])[formControlName],input:not([type=checkbox]):not([ngNoCva])[formControl],textarea:not([ngNoCva])[formControl],input:not([type=checkbox]):not([ngNoCva])[ngModel],textarea:not([ngNoCva])[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.NumberValueAccessor, selector: "input[type=number]:not([ngNoCva])[formControlName],input[type=number]:not([ngNoCva])[formControl],input[type=number]:not([ngNoCva])[ngModel]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],[formArray],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1.MinValidator, selector: "input[type=number][min][formControlName],input[type=number][min][formControl],input[type=number][min][ngModel]", inputs: ["min"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "directive", type: i1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "component", type: MatButton, selector: " button[matButton], a[matButton], button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button], a[mat-button], a[mat-raised-button], a[mat-flat-button], a[mat-stroked-button] ", inputs: ["matButton"], exportAs: ["matButton", "matAnchor"] }, { kind: "component", type: MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: MatLabel, selector: "mat-label" }, { kind: "component", type: MatSelect, selector: "mat-select", inputs: ["aria-describedby", "panelClass", "disabled", "disableRipple", "tabIndex", "hideSingleSelectionIndicator", "placeholder", "required", "multiple", "disableOptionCentering", "compareWith", "value", "aria-label", "aria-labelledby", "errorStateMatcher", "typeaheadDebounceInterval", "sortComparator", "id", "panelWidth", "canSelectNullableOptions"], outputs: ["openedChange", "opened", "closed", "selectionChange", "valueChange"], exportAs: ["matSelect"] }, { kind: "component", type: MatOption, selector: "mat-option", inputs: ["value", "id", "disabled"], outputs: ["onSelectionChange"], exportAs: ["matOption"] }, { kind: "directive", type: MatHint, selector: "mat-hint", inputs: ["align", "id"] }, { kind: "directive", type: MatError, selector: "mat-error, [matError]", inputs: ["id"] }, { kind: "component", type: MatCheckbox, selector: "mat-checkbox", inputs: ["aria-label", "aria-labelledby", "aria-describedby", "aria-expanded", "aria-controls", "aria-owns", "id", "required", "labelPosition", "name", "value", "disableRipple", "tabIndex", "color", "disabledInteractive", "checked", "disabled", "indeterminate"], outputs: ["change", "indeterminateChange"], exportAs: ["matCheckbox"] }, { kind: "directive", type: MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly", "disabledInteractive"], exportAs: ["matInput"] }, { kind: "component", type: MatProgressBar, selector: "mat-progress-bar", inputs: ["color", "value", "bufferValue", "mode"], outputs: ["animationEnd"], exportAs: ["matProgressBar"] }, { kind: "component", type: MatCard, selector: "mat-card", inputs: ["appearance"], exportAs: ["matCard"] }, { kind: "component", type: MatCardHeader, selector: "mat-card-header" }, { kind: "directive", type: MatCardTitle, selector: "mat-card-title, [mat-card-title], [matCardTitle]" }, { kind: "directive", type: MatCardContent, selector: "mat-card-content" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
129
+ function toDraft(filter) {
130
+ return !filter ? makeEmptyDraft() : {
131
+ id: filter.id || "",
132
+ alias: filter.isAlias ?? null,
133
+ language: filter.language || "en"
134
+ };
329
135
  }
330
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: ThesaurusImportComponent, decorators: [{
331
- type: Component,
332
- args: [{ selector: 'cadmus-thesaurus-import', changeDetection: ChangeDetectionStrategy.OnPush, imports: [
333
- FormsModule,
334
- ReactiveFormsModule,
335
- MatButton,
336
- MatFormField,
337
- MatLabel,
338
- MatSelect,
339
- MatOption,
340
- MatHint,
341
- MatError,
342
- MatCheckbox,
343
- MatInput,
344
- MatProgressBar,
345
- MatCard,
346
- MatCardHeader,
347
- MatCardTitle,
348
- MatCardContent,
349
- ], template: "<!-- form -->\r\n<form [formGroup]=\"form\" (submit)=\"upload()\">\r\n <fieldset>\r\n <legend>source</legend>\r\n\r\n <!-- file picker -->\r\n <div>\r\n <input\r\n #fileInput\r\n type=\"file\"\r\n class=\"hidden\"\r\n (change)=\"onFileSelected($event)\"\r\n />\r\n <button\r\n type=\"button\"\r\n mat-flat-button\r\n class=\"mat-primary\"\r\n (click)=\"fileInput.click()\"\r\n [disabled]=\"uploading()\"\r\n >\r\n select file\r\n </button>\r\n <span class=\"file-name\">{{ file.value?.name }}</span>\r\n @if ($any(file).errors?.required) {\r\n <span class=\"error\">file required</span>\r\n } @if ($any(file).errors?.invalidExtension) {\r\n <span class=\"error\">invalid file type</span>\r\n }\r\n </div>\r\n <br />\r\n\r\n <!-- mode -->\r\n <div class=\"form-row\">\r\n <mat-form-field>\r\n <mat-label>mode</mat-label>\r\n <mat-select [formControl]=\"mode\">\r\n <mat-option value=\"R\">replace</mat-option>\r\n <mat-option value=\"P\">patch</mat-option>\r\n <mat-option value=\"S\">synch</mat-option>\r\n </mat-select>\r\n <mat-hint>\r\n @if (mode.value === 'R') {\r\n <span\r\n >if the imported thesaurus already exists, it is fully replaced by\r\n the new one.</span\r\n >\r\n } @if (mode.value === 'P') {\r\n <span\r\n >the existing thesaurus is patched with the imported one: any\r\n existing entry has its value overwritten; any non existing entry is\r\n just added.</span\r\n >\r\n } @if (mode.value === 'S') {\r\n <span\r\n >equal to patch, with the addition that any existing entry not found\r\n in the imported thesaurus is removed.</span\r\n >\r\n }\r\n </mat-hint>\r\n @if ($any(mode).errors?.required && (mode.dirty || mode.touched)) {\r\n <mat-error>mode required</mat-error>\r\n }\r\n </mat-form-field>\r\n\r\n <!-- dry -->\r\n <mat-checkbox [formControl]=\"dryRun\">dry run</mat-checkbox>\r\n </div>\r\n\r\n <!-- Excel -->\r\n @if ( file.value?.name?.endsWith('.xlsx') ||\r\n file.value?.name?.endsWith('.xls') ) {\r\n <div>\r\n <fieldset>\r\n <legend>Excel</legend>\r\n <div class=\"form-row\">\r\n <!-- excelSheet -->\r\n <mat-form-field class=\"nr-input\">\r\n <mat-label>sheet</mat-label>\r\n <input matInput type=\"number\" min=\"1\" [formControl]=\"excelSheet\" />\r\n </mat-form-field>\r\n <!-- excelRow -->\r\n <mat-form-field class=\"nr-input\">\r\n <mat-label>1st row</mat-label>\r\n <input matInput type=\"number\" min=\"1\" [formControl]=\"excelRow\" />\r\n </mat-form-field>\r\n <!-- excelColumn -->\r\n <mat-form-field class=\"nr-input\">\r\n <mat-label>1st column</mat-label>\r\n <input matInput type=\"number\" min=\"1\" [formControl]=\"excelColumn\" />\r\n </mat-form-field>\r\n </div>\r\n </fieldset>\r\n </div>\r\n }\r\n\r\n <!-- submit -->\r\n <div style=\"margin-top: 16px\">\r\n <button\r\n type=\"submit\"\r\n mat-flat-button\r\n class=\"mat-warn\"\r\n [disabled]=\"uploading() || form.invalid\"\r\n >\r\n upload\r\n </button>\r\n </div>\r\n </fieldset>\r\n</form>\r\n\r\n<!-- uploading -->\r\n@if (uploading()) {\r\n<div>\r\n <div>\r\n <button type=\"button\" mat-flat-button class=\"mat-warn\" (click)=\"onCancel()\">\r\n cancel\r\n </button>\r\n </div>\r\n <div style=\"margin-top: 16px\">\r\n <mat-progress-bar max=\"100\" [value]=\"uploadProgress()\"></mat-progress-bar>\r\n </div>\r\n</div>\r\n}\r\n\r\n<!-- result -->\r\n@if (result()) {\r\n<div>\r\n @if (result()!.error) {\r\n <div class=\"error\">{{ result()!.error }}</div>\r\n } @if (result()!.importedIds.length) {\r\n <div>\r\n <div>\r\n <mat-card>\r\n <mat-card-header>\r\n <mat-card-title>Imported IDs</mat-card-title>\r\n </mat-card-header>\r\n <mat-card-content>\r\n <ol>\r\n @for (id of result()!.importedIds; track id) {\r\n <li>{{ id }}</li>\r\n }\r\n </ol>\r\n </mat-card-content>\r\n </mat-card>\r\n </div>\r\n </div>\r\n }\r\n</div>\r\n}\r\n", styles: ["fieldset{border:1px solid #ddd;border-radius:4px;margin:8px 0;padding:8px}legend{color:var(--mat-sys-on-surface-variant)}.hidden{display:none}.file-name{color:var(--mat-sys-primary);margin-left:16px}.nr-input{width:6em}.form-row{display:flex;gap:8px;align-items:center;flex-wrap:wrap}.form-row *{flex:0 0 auto}.error{margin:8px;color:var(--mat-sys-on-error);padding:4px 8px;background-color:var(--mat-sys-error);border:1px solid var(--mat-sys-error);border-radius:6px}\n"] }]
350
- }], ctorParameters: () => [{ type: i1.FormBuilder }, { type: i2$1.EnvService }, { type: i2.UploadService }], propDecorators: { uploadStart: [{ type: i0.Output, args: ["uploadStart"] }], uploadEnd: [{ type: i0.Output, args: ["uploadEnd"] }] } });
351
-
352
- /**
353
- * Thesaurus list component. This lists thesauri with paging and
354
- * filtering capabilities, and allows adding, editing, deleting,
355
- * and downloading thesauri; it can also import them if enabled.
356
- */
357
- class ThesaurusListComponent {
358
- _repository;
359
- _thesaurusService;
360
- _dialogService;
361
- _router;
362
- _authService;
363
- _userLevelService;
364
- _snackbar;
365
- _destroyRef = inject(DestroyRef);
366
- loading$;
367
- page$;
368
- userLevel = signal(0, /* @ts-ignore */
369
- ...(ngDevMode ? [{ debugName: "userLevel" }] : /* istanbul ignore next */ []));
370
- downloading = signal(false, /* @ts-ignore */
371
- ...(ngDevMode ? [{ debugName: "downloading" }] : /* istanbul ignore next */ []));
372
- importEnabled = signal(false, /* @ts-ignore */
373
- ...(ngDevMode ? [{ debugName: "importEnabled" }] : /* istanbul ignore next */ []));
374
- adding = signal(false, /* @ts-ignore */
375
- ...(ngDevMode ? [{ debugName: "adding" }] : /* istanbul ignore next */ []));
376
- newThesaurusId;
377
- newThesaurusTargetId;
378
- newThesaurusForm;
379
- constructor(_repository, _thesaurusService, _dialogService, _router, _authService, _userLevelService, _snackbar, env) {
380
- this._repository = _repository;
381
- this._thesaurusService = _thesaurusService;
382
- this._dialogService = _dialogService;
383
- this._router = _router;
384
- this._authService = _authService;
385
- this._userLevelService = _userLevelService;
386
- this._snackbar = _snackbar;
387
- this.loading$ = _repository.loading$;
388
- this.page$ = _repository.page$;
389
- this.importEnabled.set(_authService.isCurrentUserInRole('admin') && env.get('thesImportEnabled')
390
- ? true
391
- : false);
392
- // create form with cross-field validator
393
- this.newThesaurusId = new FormControl('', {
394
- validators: [Validators.required, Validators.maxLength(100)],
395
- nonNullable: true,
396
- });
397
- this.newThesaurusTargetId = new FormControl(null, {
398
- validators: Validators.maxLength(100),
399
- });
400
- this.newThesaurusForm = new FormGroup({
401
- newThesaurusId: this.newThesaurusId,
402
- newThesaurusTargetId: this.newThesaurusTargetId,
403
- }, { validators: this.validateTargetIdDifferent });
404
- }
405
- /**
406
- * Cross-field validator: ensures that targetId (when specified)
407
- * is different from the thesaurus ID.
408
- */
409
- validateTargetIdDifferent(group) {
410
- const id = group.get('newThesaurusId')?.value?.trim();
411
- const targetId = group.get('newThesaurusTargetId')?.value?.trim();
412
- if (targetId && id && targetId === id) {
413
- return { sameTargetId: true };
414
- }
415
- return null;
416
- }
417
- ngOnInit() {
418
- this._authService.currentUser$
419
- .pipe(takeUntilDestroyed(this._destroyRef))
420
- .subscribe(() => {
421
- this.userLevel.set(this._userLevelService.getCurrentUserLevel());
422
- });
423
- }
424
- onPageChange(event) {
425
- this._repository.setPage(event.pageIndex + 1, event.pageSize);
426
- }
427
- /**
428
- * Adds a new thesaurus (or alias) after validating that:
429
- * 1. The thesaurus ID does not already exist
430
- * 2. If it's an alias, the target thesaurus must exist
431
- */
432
- addThesaurus() {
433
- if (this.newThesaurusForm.invalid) {
434
- return;
435
- }
436
- const id = this.newThesaurusId.value.trim();
437
- const targetId = this.newThesaurusTargetId.value?.trim() || undefined;
438
- this.adding.set(true);
439
- // Step 1: Check if the thesaurus already exists
440
- this._thesaurusService
441
- .getThesaurus(id, true)
442
- .pipe(switchMap((existing) => {
443
- // If thesaurus exists (has entries or targetId), abort
444
- if (existing.entries?.length || existing.targetId) {
445
- this._snackbar.open(`Thesaurus with ID "${id}" already exists.`, 'OK');
446
- return of(null);
447
- }
448
- // Step 2: If alias, verify target thesaurus exists
449
- if (targetId) {
450
- return this._thesaurusService.getThesaurus(targetId, true).pipe(map((target) => {
451
- // Check if target exists (has entries or is itself an alias)
452
- if (!target.entries?.length && !target.targetId) {
453
- this._snackbar.open(`Target thesaurus "${targetId}" does not exist.`, 'OK');
454
- return null;
455
- }
456
- return { id, targetId };
457
- }), catchError((err) => {
458
- console.error(err);
459
- this._snackbar.open(`Error checking target thesaurus: ${err.message || err}`, 'OK');
460
- return of(null);
461
- }));
462
- }
463
- // Not an alias, proceed directly
464
- return of({ id, targetId: undefined });
465
- }), filter((data) => data !== null), switchMap(({ id, targetId }) => {
466
- // Step 3: Create and save the new thesaurus
467
- const thesaurus = {
468
- id,
469
- entries: [],
470
- targetId,
471
- };
472
- return this._thesaurusService.addThesaurus(thesaurus).pipe(map(() => thesaurus), catchError((err) => {
473
- console.error(err);
474
- this._snackbar.open(`Error adding thesaurus: ${err.message || err}`, 'OK');
475
- return of(null);
476
- }));
477
- }), filter((thesaurus) => thesaurus !== null), tap((thesaurus) => {
478
- // Step 4: Success - refresh and navigate
479
- this._repository.reset();
480
- this._snackbar.open(`Thesaurus "${thesaurus.id}" added.`, 'OK', {
481
- duration: 3000,
482
- });
483
- this.editThesaurus(thesaurus);
484
- }), finalize(() => this.adding.set(false)), takeUntilDestroyed(this._destroyRef))
485
- .subscribe();
486
- }
487
- editThesaurus(thesaurus) {
488
- this._router.navigate(['/thesauri', thesaurus.id]);
489
- }
490
- deleteThesaurus(thesaurus) {
491
- if (this.userLevel() < 3) {
492
- return;
493
- }
494
- this._dialogService
495
- .confirm('Confirm Deletion', `Delete thesaurus "${thesaurus.id}"?`)
496
- .subscribe((yes) => {
497
- if (yes) {
498
- this._repository.deleteThesaurus(thesaurus.id);
499
- }
500
- });
501
- }
502
- downloadThesaurus(id) {
503
- if (this.downloading()) {
504
- return;
505
- }
506
- this.downloading.set(true);
507
- this._thesaurusService.getThesaurus(id).subscribe({
508
- next: (thesaurus) => {
509
- this.downloading.set(false);
510
- const json = JSON.stringify(thesaurus, null, 2);
511
- const element = document.createElement('a');
512
- const file = new Blob([json], { type: 'application/json' });
513
- const url = URL.createObjectURL(file);
514
- element.href = url;
515
- element.download = `${thesaurus.id}.json`;
516
- document.body.appendChild(element);
517
- element.click();
518
- document.body.removeChild(element);
519
- URL.revokeObjectURL(url);
520
- },
521
- error: (err) => {
522
- this.downloading.set(false);
523
- console.error(err);
524
- this._snackbar.open('Error downloading thesaurus', 'OK');
525
- },
526
- });
527
- }
528
- onUploadEnd() {
529
- this._repository.reset();
530
- }
531
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: ThesaurusListComponent, deps: [{ token: ThesaurusListRepository }, { token: i2.ThesaurusService }, { token: i3.DialogService }, { token: i4.Router }, { token: i5.AuthJwtService }, { token: i2.UserLevelService }, { token: i6.MatSnackBar }, { token: i2$1.EnvService }], target: i0.ɵɵFactoryTarget.Component });
532
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.0", type: ThesaurusListComponent, isStandalone: true, selector: "cadmus-thesaurus-list", ngImport: i0, template: "<mat-card appearance=\"outlined\">\r\n <mat-card-header>\r\n <mat-card-title> Thesauri </mat-card-title>\r\n </mat-card-header>\r\n <mat-card-content>\r\n <div id=\"container\">\r\n <!-- filters -->\r\n <div id=\"filters\">\r\n <cadmus-thesaurus-filter></cadmus-thesaurus-filter>\r\n </div>\r\n\r\n <!-- list -->\r\n @if (page$ | async; as page) {\r\n <div id=\"list\">\r\n @if (loading$ | async) {\r\n <div>\r\n <mat-progress-bar mode=\"indeterminate\"></mat-progress-bar>\r\n </div>\r\n }\r\n <table>\r\n <thead>\r\n <th></th>\r\n <th>id</th>\r\n <th>entries</th>\r\n </thead>\r\n <tbody>\r\n @for (thesaurus of page.items; track thesaurus.id) {\r\n <tr>\r\n <td class=\"fit-width\">\r\n <button\r\n mat-icon-button\r\n type=\"button\"\r\n matTooltip=\"Edit {{ thesaurus.id }}\"\r\n (click)=\"editThesaurus(thesaurus)\"\r\n >\r\n <mat-icon class=\"mat-primary\">mode_edit</mat-icon>\r\n </button>\r\n @if (userLevel() > 2) {\r\n <button\r\n mat-icon-button\r\n type=\"button\"\r\n matTooltip=\"Delete {{ thesaurus.id }}\"\r\n (click)=\"deleteThesaurus(thesaurus)\"\r\n >\r\n <mat-icon class=\"mat-warn\">delete</mat-icon>\r\n </button>\r\n }\r\n <button\r\n type=\"button\"\r\n mat-icon-button\r\n matTooltip=\"Download this thesaurus\"\r\n [disabled]=\"downloading()\"\r\n (click)=\"downloadThesaurus(thesaurus.id)\"\r\n >\r\n <mat-icon>download</mat-icon>\r\n </button>\r\n </td>\r\n <td>{{ thesaurus.id }}</td>\r\n <td>\r\n {{ thesaurus.entries?.length || 0 }}\r\n </td>\r\n </tr>\r\n }\r\n </tbody>\r\n </table>\r\n <!-- pagination -->\r\n <mat-paginator\r\n [length]=\"page.total\"\r\n [pageIndex]=\"page.pageNumber - 1\"\r\n [pageSize]=\"page.pageSize\"\r\n [pageSizeOptions]=\"[5, 10, 20, 50, 100]\"\r\n (page)=\"onPageChange($event)\"\r\n [showFirstLastButtons]=\"true\"\r\n />\r\n\r\n <!-- adder -->\r\n <div>\r\n <fieldset>\r\n <legend>add thesaurus</legend>\r\n <form\r\n [formGroup]=\"newThesaurusForm\"\r\n (submit)=\"addThesaurus()\"\r\n class=\"form-row\"\r\n >\r\n <!-- id -->\r\n <mat-form-field>\r\n <mat-label>ID</mat-label>\r\n <input matInput [formControl]=\"newThesaurusId\" />\r\n @if (\r\n $any(newThesaurusId).errors?.required &&\r\n (newThesaurusId.dirty || newThesaurusId.touched)\r\n ) {\r\n <mat-error>ID required</mat-error>\r\n }\r\n @if (\r\n $any(newThesaurusId).errors?.maxLength &&\r\n (newThesaurusId.dirty || newThesaurusId.touched)\r\n ) {\r\n <mat-error>ID too long</mat-error>\r\n }\r\n </mat-form-field>\r\n <!-- target ID (for alias) -->\r\n <mat-form-field>\r\n <mat-label>target ID</mat-label>\r\n <input matInput [formControl]=\"newThesaurusTargetId\" />\r\n @if (\r\n $any(newThesaurusTargetId).errors?.maxLength &&\r\n (newThesaurusTargetId.dirty || newThesaurusTargetId.touched)\r\n ) {\r\n <mat-error>ID too long</mat-error>\r\n }\r\n @if (newThesaurusForm.errors?.[\"sameTargetId\"]) {\r\n <mat-error>Target ID must differ from ID</mat-error>\r\n }\r\n </mat-form-field>\r\n <!-- add button -->\r\n <button\r\n type=\"submit\"\r\n mat-flat-button\r\n color=\"primary\"\r\n matTooltip=\"Add a new thesaurus (or alias if target ID is set)\"\r\n [disabled]=\"newThesaurusForm.invalid || adding()\"\r\n >\r\n add\r\n </button>\r\n @if (adding()) {\r\n <div>\r\n <mat-progress-bar mode=\"indeterminate\" />\r\n </div>\r\n }\r\n </form>\r\n </fieldset>\r\n </div>\r\n\r\n <!-- importer -->\r\n @if (importEnabled()) {\r\n <div class=\"margin-top\">\r\n <mat-expansion-panel>\r\n <mat-expansion-panel-header>\r\n <mat-panel-title>Import thesauri</mat-panel-title>\r\n </mat-expansion-panel-header>\r\n <cadmus-thesaurus-import (uploadEnd)=\"onUploadEnd()\" />\r\n </mat-expansion-panel>\r\n </div>\r\n }\r\n </div>\r\n }\r\n </div>\r\n </mat-card-content>\r\n</mat-card>\r\n", styles: ["table{width:100%;border-collapse:collapse}tbody tr:nth-child(odd){background-color:var(--mat-sys-surface-container)}th{text-align:left;font-weight:400;color:var(--mat-sys-on-surface-variant)}tbody tr:hover{background-color:var(--mat-sys-surface-container-high)}td.fit-width{width:1px;white-space:nowrap}tbody tr.selected{background-color:var(--mat-sys-secondary-container);color:var(--mat-sys-on-secondary-container)}fieldset{border:1px solid var(--mat-sys-on-surface-variant);border-radius:6px;padding:6px}legend{color:var(--mat-sys-on-surface-variant)}.form-row{display:flex;gap:8px;align-items:center;flex-wrap:wrap}.form-row *{flex:0 0 auto}.margin-top{margin-top:1rem}div#container{display:grid;grid-template-rows:1fr;grid-template-columns:auto 1fr;grid-template-areas:\"filters list\";gap:16px}#filters{grid-area:filters;max-width:230px}#list{grid-area:list}@media only screen and (max-width:959px){div#container{grid-template-rows:1fr auto;grid-template-columns:1fr;grid-template-areas:\"list\" \"filters\"}#filters{max-width:none}.noif-lt-md{display:none}}\n"], dependencies: [{ kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox]):not([ngNoCva])[formControlName],textarea:not([ngNoCva])[formControlName],input:not([type=checkbox]):not([ngNoCva])[formControl],textarea:not([ngNoCva])[formControl],input:not([type=checkbox]):not([ngNoCva])[ngModel],textarea:not([ngNoCva])[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],[formArray],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "directive", type: i1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "component", type: MatButton, selector: " button[matButton], a[matButton], button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button], a[mat-button], a[mat-raised-button], a[mat-flat-button], a[mat-stroked-button] ", inputs: ["matButton"], exportAs: ["matButton", "matAnchor"] }, { kind: "component", type: MatCard, selector: "mat-card", inputs: ["appearance"], exportAs: ["matCard"] }, { kind: "component", type: MatCardHeader, selector: "mat-card-header" }, { kind: "directive", type: MatCardTitle, selector: "mat-card-title, [mat-card-title], [matCardTitle]" }, { kind: "directive", type: MatCardContent, selector: "mat-card-content" }, { kind: "directive", type: MatError$1, selector: "mat-error, [matError]", inputs: ["id"] }, { kind: "component", type: MatProgressBar, selector: "mat-progress-bar", inputs: ["color", "value", "bufferValue", "mode"], outputs: ["animationEnd"], exportAs: ["matProgressBar"] }, { kind: "component", type: MatFormField$1, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "component", type: MatIconButton, selector: "button[mat-icon-button], a[mat-icon-button], button[matIconButton], a[matIconButton]", exportAs: ["matButton", "matAnchor"] }, { kind: "component", type: MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "directive", type: MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly", "disabledInteractive"], exportAs: ["matInput"] }, { kind: "directive", type: MatLabel$1, selector: "mat-label" }, { kind: "directive", type: MatTooltip, selector: "[matTooltip]", inputs: ["matTooltipPosition", "matTooltipPositionAtOrigin", "matTooltipDisabled", "matTooltipShowDelay", "matTooltipHideDelay", "matTooltipTouchGestures", "matTooltip", "matTooltipClass"], exportAs: ["matTooltip"] }, { kind: "component", type: MatPaginator, selector: "mat-paginator", inputs: ["color", "pageIndex", "length", "pageSize", "pageSizeOptions", "hidePageSize", "showFirstLastButtons", "selectConfig", "disabled"], outputs: ["page"], exportAs: ["matPaginator"] }, { kind: "component", type: MatExpansionPanel, selector: "mat-expansion-panel", inputs: ["hideToggle", "togglePosition"], outputs: ["afterExpand", "afterCollapse"], exportAs: ["matExpansionPanel"] }, { kind: "component", type: MatExpansionPanelHeader, selector: "mat-expansion-panel-header", inputs: ["expandedHeight", "collapsedHeight", "tabIndex"] }, { kind: "directive", type: MatExpansionPanelTitle, selector: "mat-panel-title" }, { kind: "component", type: ThesaurusFilterComponent, selector: "cadmus-thesaurus-filter" }, { kind: "component", type: ThesaurusImportComponent, selector: "cadmus-thesaurus-import", outputs: ["uploadStart", "uploadEnd"] }, { kind: "pipe", type: AsyncPipe, name: "async" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
136
+ var ThesaurusFilterComponent = class ThesaurusFilterComponent {
137
+ _repository;
138
+ filter$;
139
+ _draft;
140
+ form;
141
+ constructor(_repository) {
142
+ this._repository = _repository;
143
+ this.filter$ = _repository.filter$;
144
+ const filter = toSignal(_repository.filter$ ?? of(void 0));
145
+ this._draft = linkedSignal(() => toDraft(filter()), ...ngDevMode ? [{ debugName: "_draft" }] : /* istanbul ignore next */ []);
146
+ this.form = form(this._draft, (path) => {
147
+ maxLength(path.id, 100);
148
+ maxLength(path.language, 2);
149
+ });
150
+ }
151
+ getFilter() {
152
+ const v = this._draft();
153
+ return {
154
+ id: v.id,
155
+ isAlias: v.alias ?? void 0,
156
+ language: v.language
157
+ };
158
+ }
159
+ reset() {
160
+ this._draft.set(makeEmptyDraft());
161
+ this.apply();
162
+ }
163
+ apply() {
164
+ if (this.form().invalid()) return;
165
+ const filter = this.getFilter();
166
+ this._repository.setFilter(filter);
167
+ }
168
+ static ɵfac = i0.ɵɵngDeclareFactory({
169
+ minVersion: "12.0.0",
170
+ version: "22.2.0",
171
+ ngImport: i0,
172
+ type: ThesaurusFilterComponent,
173
+ deps: [{ token: ThesaurusListRepository }],
174
+ target: i0.ɵɵFactoryTarget.Component
175
+ });
176
+ static ɵcmp = i0.ɵɵngDeclareComponent({
177
+ minVersion: "14.0.0",
178
+ version: "22.2.0",
179
+ type: ThesaurusFilterComponent,
180
+ isStandalone: true,
181
+ selector: "cadmus-thesaurus-filter",
182
+ ngImport: i0,
183
+ template: "<div role=\"form\">\r\n <div class=\"form-row\">\r\n <!-- id -->\r\n <div>\r\n <mat-form-field>\r\n <mat-label>ID</mat-label>\r\n <input matInput [formField]=\"form.id\" (keydown.enter)=\"apply()\" />\r\n </mat-form-field>\r\n </div>\r\n\r\n <!-- language -->\r\n <div>\r\n <mat-form-field>\r\n <mat-label>language</mat-label>\r\n <input matInput [formField]=\"form.language\" (keydown.enter)=\"apply()\" />\r\n </mat-form-field>\r\n </div>\r\n\r\n <!-- alias -->\r\n <div>\r\n <mat-form-field>\r\n <mat-label>alias</mat-label>\r\n <mat-select [formField]=\"form.alias\">\r\n <mat-option [value]=\"null\">(any)</mat-option>\r\n <mat-option [value]=\"true\">alias</mat-option>\r\n <mat-option [value]=\"false\">not an alias</mat-option>\r\n </mat-select>\r\n </mat-form-field>\r\n </div>\r\n </div>\r\n\r\n <div>\r\n <button\r\n type=\"button\"\r\n mat-icon-button\r\n (click)=\"reset()\"\r\n matTooltip=\"Reset all the filters\"\r\n >\r\n <mat-icon class=\"mat-warn\">clear</mat-icon>\r\n </button>\r\n <button\r\n type=\"button\"\r\n mat-icon-button\r\n [disabled]=\"form().invalid()\"\r\n matTooltip=\"Apply filters\"\r\n (click)=\"apply()\"\r\n >\r\n <mat-icon class=\"mat-primary\">check_circle</mat-icon>\r\n </button>\r\n </div>\r\n</div>\r\n",
184
+ styles: [".form-row{display:flex;gap:8px;align-items:center;flex-wrap:wrap}.form-row *{flex:0 0 auto}\n"],
185
+ dependencies: [
186
+ {
187
+ kind: "directive",
188
+ type: FormField,
189
+ selector: "[formField]",
190
+ inputs: ["formField"],
191
+ exportAs: ["formField"]
192
+ },
193
+ {
194
+ kind: "component",
195
+ type: MatFormField,
196
+ selector: "mat-form-field",
197
+ inputs: [
198
+ "hideRequiredMarker",
199
+ "color",
200
+ "floatLabel",
201
+ "appearance",
202
+ "subscriptSizing",
203
+ "hintLabel"
204
+ ],
205
+ exportAs: ["matFormField"]
206
+ },
207
+ {
208
+ kind: "directive",
209
+ type: MatLabel,
210
+ selector: "mat-label"
211
+ },
212
+ {
213
+ kind: "directive",
214
+ type: MatInput,
215
+ selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]",
216
+ inputs: [
217
+ "disabled",
218
+ "id",
219
+ "placeholder",
220
+ "name",
221
+ "required",
222
+ "type",
223
+ "errorStateMatcher",
224
+ "aria-describedby",
225
+ "value",
226
+ "readonly",
227
+ "disabledInteractive"
228
+ ],
229
+ exportAs: ["matInput"]
230
+ },
231
+ {
232
+ kind: "component",
233
+ type: MatSelect,
234
+ selector: "mat-select",
235
+ inputs: [
236
+ "aria-describedby",
237
+ "panelClass",
238
+ "disabled",
239
+ "disableRipple",
240
+ "tabIndex",
241
+ "hideSingleSelectionIndicator",
242
+ "placeholder",
243
+ "required",
244
+ "multiple",
245
+ "disableOptionCentering",
246
+ "compareWith",
247
+ "value",
248
+ "aria-label",
249
+ "aria-labelledby",
250
+ "errorStateMatcher",
251
+ "typeaheadDebounceInterval",
252
+ "sortComparator",
253
+ "id",
254
+ "panelWidth",
255
+ "canSelectNullableOptions"
256
+ ],
257
+ outputs: [
258
+ "openedChange",
259
+ "opened",
260
+ "closed",
261
+ "selectionChange",
262
+ "valueChange"
263
+ ],
264
+ exportAs: ["matSelect"]
265
+ },
266
+ {
267
+ kind: "component",
268
+ type: MatOption,
269
+ selector: "mat-option",
270
+ inputs: [
271
+ "value",
272
+ "id",
273
+ "disabled"
274
+ ],
275
+ outputs: ["onSelectionChange"],
276
+ exportAs: ["matOption"]
277
+ },
278
+ {
279
+ kind: "component",
280
+ type: MatIconButton,
281
+ selector: "button[mat-icon-button], a[mat-icon-button], button[matIconButton], a[matIconButton]",
282
+ exportAs: ["matButton", "matAnchor"]
283
+ },
284
+ {
285
+ kind: "directive",
286
+ type: MatTooltip,
287
+ selector: "[matTooltip]",
288
+ inputs: [
289
+ "matTooltipPosition",
290
+ "matTooltipPositionAtOrigin",
291
+ "matTooltipDisabled",
292
+ "matTooltipShowDelay",
293
+ "matTooltipHideDelay",
294
+ "matTooltipTouchGestures",
295
+ "matTooltip",
296
+ "matTooltipClass"
297
+ ],
298
+ exportAs: ["matTooltip"]
299
+ },
300
+ {
301
+ kind: "component",
302
+ type: MatIcon,
303
+ selector: "mat-icon",
304
+ inputs: [
305
+ "color",
306
+ "inline",
307
+ "svgIcon",
308
+ "fontSet",
309
+ "fontIcon"
310
+ ],
311
+ exportAs: ["matIcon"]
312
+ }
313
+ ],
314
+ changeDetection: i0.ChangeDetectionStrategy.OnPush
315
+ });
316
+ };
317
+ i0.ɵɵngDeclareClassMetadata({
318
+ minVersion: "12.0.0",
319
+ version: "22.2.0",
320
+ ngImport: i0,
321
+ type: ThesaurusFilterComponent,
322
+ decorators: [{
323
+ type: Component,
324
+ args: [{
325
+ selector: "cadmus-thesaurus-filter",
326
+ changeDetection: ChangeDetectionStrategy.OnPush,
327
+ imports: [
328
+ FormField,
329
+ MatFormField,
330
+ MatLabel,
331
+ MatInput,
332
+ MatSelect,
333
+ MatOption,
334
+ MatIconButton,
335
+ MatTooltip,
336
+ MatIcon
337
+ ],
338
+ template: "<div role=\"form\">\r\n <div class=\"form-row\">\r\n <!-- id -->\r\n <div>\r\n <mat-form-field>\r\n <mat-label>ID</mat-label>\r\n <input matInput [formField]=\"form.id\" (keydown.enter)=\"apply()\" />\r\n </mat-form-field>\r\n </div>\r\n\r\n <!-- language -->\r\n <div>\r\n <mat-form-field>\r\n <mat-label>language</mat-label>\r\n <input matInput [formField]=\"form.language\" (keydown.enter)=\"apply()\" />\r\n </mat-form-field>\r\n </div>\r\n\r\n <!-- alias -->\r\n <div>\r\n <mat-form-field>\r\n <mat-label>alias</mat-label>\r\n <mat-select [formField]=\"form.alias\">\r\n <mat-option [value]=\"null\">(any)</mat-option>\r\n <mat-option [value]=\"true\">alias</mat-option>\r\n <mat-option [value]=\"false\">not an alias</mat-option>\r\n </mat-select>\r\n </mat-form-field>\r\n </div>\r\n </div>\r\n\r\n <div>\r\n <button\r\n type=\"button\"\r\n mat-icon-button\r\n (click)=\"reset()\"\r\n matTooltip=\"Reset all the filters\"\r\n >\r\n <mat-icon class=\"mat-warn\">clear</mat-icon>\r\n </button>\r\n <button\r\n type=\"button\"\r\n mat-icon-button\r\n [disabled]=\"form().invalid()\"\r\n matTooltip=\"Apply filters\"\r\n (click)=\"apply()\"\r\n >\r\n <mat-icon class=\"mat-primary\">check_circle</mat-icon>\r\n </button>\r\n </div>\r\n</div>\r\n",
339
+ styles: [".form-row{display:flex;gap:8px;align-items:center;flex-wrap:wrap}.form-row *{flex:0 0 auto}\n"]
340
+ }]
341
+ }],
342
+ ctorParameters: () => [{ type: ThesaurusListRepository }]
343
+ });
344
+ function hasAllowedExtension(file, allowedExtensions) {
345
+ const extension = file.name.split(".").pop();
346
+ return allowedExtensions.includes(extension);
533
347
  }
534
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: ThesaurusListComponent, decorators: [{
535
- type: Component,
536
- args: [{ selector: 'cadmus-thesaurus-list', changeDetection: ChangeDetectionStrategy.OnPush, imports: [
537
- AsyncPipe,
538
- ReactiveFormsModule,
539
- MatButton,
540
- MatCard,
541
- MatCardHeader,
542
- MatCardTitle,
543
- MatCardContent,
544
- MatError$1,
545
- MatProgressBar,
546
- MatFormField$1,
547
- MatIconButton,
548
- MatIcon,
549
- MatInput,
550
- MatLabel$1,
551
- MatTooltip,
552
- MatPaginator,
553
- MatExpansionPanel,
554
- MatExpansionPanelHeader,
555
- MatExpansionPanelTitle,
556
- ThesaurusFilterComponent,
557
- ThesaurusImportComponent,
558
- ], template: "<mat-card appearance=\"outlined\">\r\n <mat-card-header>\r\n <mat-card-title> Thesauri </mat-card-title>\r\n </mat-card-header>\r\n <mat-card-content>\r\n <div id=\"container\">\r\n <!-- filters -->\r\n <div id=\"filters\">\r\n <cadmus-thesaurus-filter></cadmus-thesaurus-filter>\r\n </div>\r\n\r\n <!-- list -->\r\n @if (page$ | async; as page) {\r\n <div id=\"list\">\r\n @if (loading$ | async) {\r\n <div>\r\n <mat-progress-bar mode=\"indeterminate\"></mat-progress-bar>\r\n </div>\r\n }\r\n <table>\r\n <thead>\r\n <th></th>\r\n <th>id</th>\r\n <th>entries</th>\r\n </thead>\r\n <tbody>\r\n @for (thesaurus of page.items; track thesaurus.id) {\r\n <tr>\r\n <td class=\"fit-width\">\r\n <button\r\n mat-icon-button\r\n type=\"button\"\r\n matTooltip=\"Edit {{ thesaurus.id }}\"\r\n (click)=\"editThesaurus(thesaurus)\"\r\n >\r\n <mat-icon class=\"mat-primary\">mode_edit</mat-icon>\r\n </button>\r\n @if (userLevel() > 2) {\r\n <button\r\n mat-icon-button\r\n type=\"button\"\r\n matTooltip=\"Delete {{ thesaurus.id }}\"\r\n (click)=\"deleteThesaurus(thesaurus)\"\r\n >\r\n <mat-icon class=\"mat-warn\">delete</mat-icon>\r\n </button>\r\n }\r\n <button\r\n type=\"button\"\r\n mat-icon-button\r\n matTooltip=\"Download this thesaurus\"\r\n [disabled]=\"downloading()\"\r\n (click)=\"downloadThesaurus(thesaurus.id)\"\r\n >\r\n <mat-icon>download</mat-icon>\r\n </button>\r\n </td>\r\n <td>{{ thesaurus.id }}</td>\r\n <td>\r\n {{ thesaurus.entries?.length || 0 }}\r\n </td>\r\n </tr>\r\n }\r\n </tbody>\r\n </table>\r\n <!-- pagination -->\r\n <mat-paginator\r\n [length]=\"page.total\"\r\n [pageIndex]=\"page.pageNumber - 1\"\r\n [pageSize]=\"page.pageSize\"\r\n [pageSizeOptions]=\"[5, 10, 20, 50, 100]\"\r\n (page)=\"onPageChange($event)\"\r\n [showFirstLastButtons]=\"true\"\r\n />\r\n\r\n <!-- adder -->\r\n <div>\r\n <fieldset>\r\n <legend>add thesaurus</legend>\r\n <form\r\n [formGroup]=\"newThesaurusForm\"\r\n (submit)=\"addThesaurus()\"\r\n class=\"form-row\"\r\n >\r\n <!-- id -->\r\n <mat-form-field>\r\n <mat-label>ID</mat-label>\r\n <input matInput [formControl]=\"newThesaurusId\" />\r\n @if (\r\n $any(newThesaurusId).errors?.required &&\r\n (newThesaurusId.dirty || newThesaurusId.touched)\r\n ) {\r\n <mat-error>ID required</mat-error>\r\n }\r\n @if (\r\n $any(newThesaurusId).errors?.maxLength &&\r\n (newThesaurusId.dirty || newThesaurusId.touched)\r\n ) {\r\n <mat-error>ID too long</mat-error>\r\n }\r\n </mat-form-field>\r\n <!-- target ID (for alias) -->\r\n <mat-form-field>\r\n <mat-label>target ID</mat-label>\r\n <input matInput [formControl]=\"newThesaurusTargetId\" />\r\n @if (\r\n $any(newThesaurusTargetId).errors?.maxLength &&\r\n (newThesaurusTargetId.dirty || newThesaurusTargetId.touched)\r\n ) {\r\n <mat-error>ID too long</mat-error>\r\n }\r\n @if (newThesaurusForm.errors?.[\"sameTargetId\"]) {\r\n <mat-error>Target ID must differ from ID</mat-error>\r\n }\r\n </mat-form-field>\r\n <!-- add button -->\r\n <button\r\n type=\"submit\"\r\n mat-flat-button\r\n color=\"primary\"\r\n matTooltip=\"Add a new thesaurus (or alias if target ID is set)\"\r\n [disabled]=\"newThesaurusForm.invalid || adding()\"\r\n >\r\n add\r\n </button>\r\n @if (adding()) {\r\n <div>\r\n <mat-progress-bar mode=\"indeterminate\" />\r\n </div>\r\n }\r\n </form>\r\n </fieldset>\r\n </div>\r\n\r\n <!-- importer -->\r\n @if (importEnabled()) {\r\n <div class=\"margin-top\">\r\n <mat-expansion-panel>\r\n <mat-expansion-panel-header>\r\n <mat-panel-title>Import thesauri</mat-panel-title>\r\n </mat-expansion-panel-header>\r\n <cadmus-thesaurus-import (uploadEnd)=\"onUploadEnd()\" />\r\n </mat-expansion-panel>\r\n </div>\r\n }\r\n </div>\r\n }\r\n </div>\r\n </mat-card-content>\r\n</mat-card>\r\n", styles: ["table{width:100%;border-collapse:collapse}tbody tr:nth-child(odd){background-color:var(--mat-sys-surface-container)}th{text-align:left;font-weight:400;color:var(--mat-sys-on-surface-variant)}tbody tr:hover{background-color:var(--mat-sys-surface-container-high)}td.fit-width{width:1px;white-space:nowrap}tbody tr.selected{background-color:var(--mat-sys-secondary-container);color:var(--mat-sys-on-secondary-container)}fieldset{border:1px solid var(--mat-sys-on-surface-variant);border-radius:6px;padding:6px}legend{color:var(--mat-sys-on-surface-variant)}.form-row{display:flex;gap:8px;align-items:center;flex-wrap:wrap}.form-row *{flex:0 0 auto}.margin-top{margin-top:1rem}div#container{display:grid;grid-template-rows:1fr;grid-template-columns:auto 1fr;grid-template-areas:\"filters list\";gap:16px}#filters{grid-area:filters;max-width:230px}#list{grid-area:list}@media only screen and (max-width:959px){div#container{grid-template-rows:1fr auto;grid-template-columns:1fr;grid-template-areas:\"list\" \"filters\"}#filters{max-width:none}.noif-lt-md{display:none}}\n"] }]
559
- }], ctorParameters: () => [{ type: ThesaurusListRepository }, { type: i2.ThesaurusService }, { type: i3.DialogService }, { type: i4.Router }, { type: i5.AuthJwtService }, { type: i2.UserLevelService }, { type: i6.MatSnackBar }, { type: i2$1.EnvService }] });
560
-
561
- /*
562
- * Public API Surface of cadmus-thesaurus-list
563
- */
564
-
565
- /**
566
- * Generated bundle index. Do not edit.
567
- */
568
-
348
+ var ThesaurusImportComponent = class ThesaurusImportComponent {
349
+ _env;
350
+ _uploadService;
351
+ _destroyRef = inject(DestroyRef);
352
+ _sub;
353
+ uploadStart = output();
354
+ uploadEnd = output();
355
+ form = form(signal({
356
+ file: null,
357
+ mode: "R",
358
+ dryRun: false,
359
+ excelSheet: 1,
360
+ excelRow: 1,
361
+ excelColumn: 1
362
+ }), (path) => {
363
+ required(path.file);
364
+ validate(path.file, ({ value }) => {
365
+ const file = value();
366
+ return file && !hasAllowedExtension(file, [
367
+ "json",
368
+ "csv",
369
+ "xls",
370
+ "xlsx"
371
+ ]) ? { kind: "invalidExtension" } : null;
372
+ });
373
+ required(path.mode);
374
+ min(path.excelSheet, 1);
375
+ min(path.excelRow, 1);
376
+ min(path.excelColumn, 1);
377
+ });
378
+ uploadProgress = signal(0, ...ngDevMode ? [{ debugName: "uploadProgress" }] : /* istanbul ignore next */ []);
379
+ uploading = signal(false, ...ngDevMode ? [{ debugName: "uploading" }] : /* istanbul ignore next */ []);
380
+ result = signal(void 0, ...ngDevMode ? [{ debugName: "result" }] : /* istanbul ignore next */ []);
381
+ constructor(_env, _uploadService) {
382
+ this._env = _env;
383
+ this._uploadService = _uploadService;
384
+ this._destroyRef.onDestroy(() => this._sub?.unsubscribe());
385
+ }
386
+ onFileSelected(event) {
387
+ this.form.file().value.set(event.target.files[0] ?? null);
388
+ }
389
+ upload() {
390
+ if (!this.form().valid()) return;
391
+ this.result.set(void 0);
392
+ this.uploading.set(true);
393
+ this.uploadStart.emit();
394
+ const params = [];
395
+ if (this.form.mode().value() !== "R") params.push(`mode=${this.form.mode().value()}`);
396
+ if (this.form.excelSheet().value() !== 1) params.push(`excelSheet=${this.form.excelSheet().value()}`);
397
+ if (this.form.excelRow().value() !== 1) params.push(`excelRow=${this.form.excelRow().value()}`);
398
+ if (this.form.excelColumn().value() !== 1) params.push(`excelColumn=${this.form.excelColumn().value()}`);
399
+ if (this.form.dryRun().value()) params.push("dryRun=true");
400
+ let url = `${this._env.get("apiUrl")}thesauri/import`;
401
+ if (params.length) url += "?" + params.join("&");
402
+ this._sub = this._uploadService.uploadFile(this.form.file().value(), url, { reportProgress: true }).subscribe({
403
+ next: (event) => {
404
+ if (event.type === HttpEventType.UploadProgress) this.uploadProgress.set(Math.round(event.loaded / event.total * 100));
405
+ else if (event.type === HttpEventType.Response) {
406
+ this.uploading.set(false);
407
+ this.result.set(event.body);
408
+ this.uploadEnd.emit(true);
409
+ }
410
+ },
411
+ error: (error) => {
412
+ console.error(error);
413
+ this.uploading.set(false);
414
+ this.uploadProgress.set(0);
415
+ this.uploadEnd.emit(false);
416
+ }
417
+ });
418
+ }
419
+ onCancel() {
420
+ this._sub?.unsubscribe();
421
+ this.uploading.set(false);
422
+ this.uploadProgress.set(0);
423
+ this.uploadEnd.emit(false);
424
+ }
425
+ static ɵfac = i0.ɵɵngDeclareFactory({
426
+ minVersion: "12.0.0",
427
+ version: "22.2.0",
428
+ ngImport: i0,
429
+ type: ThesaurusImportComponent,
430
+ deps: [{ token: i1.EnvService }, { token: i1$1.UploadService }],
431
+ target: i0.ɵɵFactoryTarget.Component
432
+ });
433
+ static ɵcmp = i0.ɵɵngDeclareComponent({
434
+ minVersion: "17.0.0",
435
+ version: "22.2.0",
436
+ type: ThesaurusImportComponent,
437
+ isStandalone: true,
438
+ selector: "cadmus-thesaurus-import",
439
+ outputs: {
440
+ uploadStart: "uploadStart",
441
+ uploadEnd: "uploadEnd"
442
+ },
443
+ ngImport: i0,
444
+ template: "<!-- form -->\n<div>\n <fieldset>\n <legend>source</legend>\n\n <!-- file picker -->\n <div>\n <input\n #fileInput\n type=\"file\"\n class=\"hidden\"\n (change)=\"onFileSelected($event)\"\n />\n <button\n type=\"button\"\n mat-flat-button\n class=\"mat-primary\"\n (click)=\"fileInput.click()\"\n [disabled]=\"uploading()\"\n >\n select file\n </button>\n <span class=\"file-name\">{{ form.file().value()?.name }}</span>\n @if (form.file().getError('required')) {\n <span class=\"error\">file required</span>\n } @if (form.file().getError('invalidExtension')) {\n <span class=\"error\">invalid file type</span>\n }\n </div>\n <br />\n\n <!-- mode -->\n <div class=\"form-row\">\n <mat-form-field>\n <mat-label>mode</mat-label>\n <mat-select [formField]=\"form.mode\">\n <mat-option value=\"R\">replace</mat-option>\n <mat-option value=\"P\">patch</mat-option>\n <mat-option value=\"S\">synch</mat-option>\n </mat-select>\n <mat-hint>\n @if (form.mode().value() === 'R') {\n <span\n >if the imported thesaurus already exists, it is fully replaced by\n the new one.</span\n >\n } @if (form.mode().value() === 'P') {\n <span\n >the existing thesaurus is patched with the imported one: any\n existing entry has its value overwritten; any non existing entry is\n just added.</span\n >\n } @if (form.mode().value() === 'S') {\n <span\n >equal to patch, with the addition that any existing entry not found\n in the imported thesaurus is removed.</span\n >\n }\n </mat-hint>\n @if (form.mode().getError('required') && (form.mode().dirty() || form.mode().touched())) {\n <mat-error>mode required</mat-error>\n }\n </mat-form-field>\n\n <!-- dry -->\n <mat-checkbox [formField]=\"form.dryRun\">dry run</mat-checkbox>\n </div>\n\n <!-- Excel -->\n @if ( form.file().value()?.name?.endsWith('.xlsx') ||\n form.file().value()?.name?.endsWith('.xls') ) {\n <div>\n <fieldset>\n <legend>Excel</legend>\n <div class=\"form-row\">\n <!-- excelSheet -->\n <mat-form-field class=\"nr-input\">\n <mat-label>sheet</mat-label>\n <input\n matInput\n type=\"number\"\n [formField]=\"form.excelSheet\"\n (keydown.enter)=\"!uploading() && upload()\"\n />\n </mat-form-field>\n <!-- excelRow -->\n <mat-form-field class=\"nr-input\">\n <mat-label>1st row</mat-label>\n <input\n matInput\n type=\"number\"\n [formField]=\"form.excelRow\"\n (keydown.enter)=\"!uploading() && upload()\"\n />\n </mat-form-field>\n <!-- excelColumn -->\n <mat-form-field class=\"nr-input\">\n <mat-label>1st column</mat-label>\n <input\n matInput\n type=\"number\"\n [formField]=\"form.excelColumn\"\n (keydown.enter)=\"!uploading() && upload()\"\n />\n </mat-form-field>\n </div>\n </fieldset>\n </div>\n }\n\n <!-- submit -->\n <div style=\"margin-top: 16px\">\n <button\n type=\"button\"\n mat-flat-button\n class=\"mat-warn\"\n [disabled]=\"uploading() || form().invalid()\"\n (click)=\"upload()\"\n >\n upload\n </button>\n </div>\n </fieldset>\n</div>\n\n<!-- uploading -->\n@if (uploading()) {\n<div>\n <div>\n <button type=\"button\" mat-flat-button class=\"mat-warn\" (click)=\"onCancel()\">\n cancel\n </button>\n </div>\n <div style=\"margin-top: 16px\">\n <mat-progress-bar max=\"100\" [value]=\"uploadProgress()\"></mat-progress-bar>\n </div>\n</div>\n}\n\n<!-- result -->\n@if (result()) {\n<div>\n @if (result()!.error) {\n <div class=\"error\">{{ result()!.error }}</div>\n } @if (result()!.importedIds.length) {\n <div>\n <div>\n <mat-card>\n <mat-card-header>\n <mat-card-title>Imported IDs</mat-card-title>\n </mat-card-header>\n <mat-card-content>\n <ol>\n @for (id of result()!.importedIds; track id) {\n <li>{{ id }}</li>\n }\n </ol>\n </mat-card-content>\n </mat-card>\n </div>\n </div>\n }\n</div>\n}\n",
445
+ styles: ["fieldset{border:1px solid #ddd;border-radius:4px;margin:8px 0;padding:8px}legend{color:var(--mat-sys-on-surface-variant)}.hidden{display:none}.file-name{color:var(--mat-sys-primary);margin-left:16px}.nr-input{width:6em}.form-row{display:flex;gap:8px;align-items:center;flex-wrap:wrap}.form-row *{flex:0 0 auto}.error{margin:8px;color:var(--mat-sys-on-error);padding:4px 8px;background-color:var(--mat-sys-error);border:1px solid var(--mat-sys-error);border-radius:6px}\n"],
446
+ dependencies: [
447
+ {
448
+ kind: "directive",
449
+ type: FormField,
450
+ selector: "[formField]",
451
+ inputs: ["formField"],
452
+ exportAs: ["formField"]
453
+ },
454
+ {
455
+ kind: "component",
456
+ type: MatButton,
457
+ selector: " button[matButton], a[matButton], button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button], a[mat-button], a[mat-raised-button], a[mat-flat-button], a[mat-stroked-button] ",
458
+ inputs: ["matButton"],
459
+ exportAs: ["matButton", "matAnchor"]
460
+ },
461
+ {
462
+ kind: "component",
463
+ type: MatFormField,
464
+ selector: "mat-form-field",
465
+ inputs: [
466
+ "hideRequiredMarker",
467
+ "color",
468
+ "floatLabel",
469
+ "appearance",
470
+ "subscriptSizing",
471
+ "hintLabel"
472
+ ],
473
+ exportAs: ["matFormField"]
474
+ },
475
+ {
476
+ kind: "directive",
477
+ type: MatLabel,
478
+ selector: "mat-label"
479
+ },
480
+ {
481
+ kind: "component",
482
+ type: MatSelect,
483
+ selector: "mat-select",
484
+ inputs: [
485
+ "aria-describedby",
486
+ "panelClass",
487
+ "disabled",
488
+ "disableRipple",
489
+ "tabIndex",
490
+ "hideSingleSelectionIndicator",
491
+ "placeholder",
492
+ "required",
493
+ "multiple",
494
+ "disableOptionCentering",
495
+ "compareWith",
496
+ "value",
497
+ "aria-label",
498
+ "aria-labelledby",
499
+ "errorStateMatcher",
500
+ "typeaheadDebounceInterval",
501
+ "sortComparator",
502
+ "id",
503
+ "panelWidth",
504
+ "canSelectNullableOptions"
505
+ ],
506
+ outputs: [
507
+ "openedChange",
508
+ "opened",
509
+ "closed",
510
+ "selectionChange",
511
+ "valueChange"
512
+ ],
513
+ exportAs: ["matSelect"]
514
+ },
515
+ {
516
+ kind: "component",
517
+ type: MatOption,
518
+ selector: "mat-option",
519
+ inputs: [
520
+ "value",
521
+ "id",
522
+ "disabled"
523
+ ],
524
+ outputs: ["onSelectionChange"],
525
+ exportAs: ["matOption"]
526
+ },
527
+ {
528
+ kind: "directive",
529
+ type: MatHint,
530
+ selector: "mat-hint",
531
+ inputs: ["align", "id"]
532
+ },
533
+ {
534
+ kind: "directive",
535
+ type: MatError,
536
+ selector: "mat-error, [matError]",
537
+ inputs: ["id"]
538
+ },
539
+ {
540
+ kind: "component",
541
+ type: MatCheckbox,
542
+ selector: "mat-checkbox",
543
+ inputs: [
544
+ "aria-label",
545
+ "aria-labelledby",
546
+ "aria-describedby",
547
+ "aria-expanded",
548
+ "aria-controls",
549
+ "aria-owns",
550
+ "id",
551
+ "required",
552
+ "labelPosition",
553
+ "name",
554
+ "value",
555
+ "disableRipple",
556
+ "tabIndex",
557
+ "color",
558
+ "disabledInteractive",
559
+ "checked",
560
+ "disabled",
561
+ "indeterminate"
562
+ ],
563
+ outputs: ["change", "indeterminateChange"],
564
+ exportAs: ["matCheckbox"]
565
+ },
566
+ {
567
+ kind: "directive",
568
+ type: MatInput,
569
+ selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]",
570
+ inputs: [
571
+ "disabled",
572
+ "id",
573
+ "placeholder",
574
+ "name",
575
+ "required",
576
+ "type",
577
+ "errorStateMatcher",
578
+ "aria-describedby",
579
+ "value",
580
+ "readonly",
581
+ "disabledInteractive"
582
+ ],
583
+ exportAs: ["matInput"]
584
+ },
585
+ {
586
+ kind: "component",
587
+ type: MatProgressBar,
588
+ selector: "mat-progress-bar",
589
+ inputs: [
590
+ "color",
591
+ "value",
592
+ "bufferValue",
593
+ "mode"
594
+ ],
595
+ outputs: ["animationEnd"],
596
+ exportAs: ["matProgressBar"]
597
+ },
598
+ {
599
+ kind: "component",
600
+ type: MatCard,
601
+ selector: "mat-card",
602
+ inputs: ["appearance"],
603
+ exportAs: ["matCard"]
604
+ },
605
+ {
606
+ kind: "component",
607
+ type: MatCardHeader,
608
+ selector: "mat-card-header"
609
+ },
610
+ {
611
+ kind: "directive",
612
+ type: MatCardTitle,
613
+ selector: "mat-card-title, [mat-card-title], [matCardTitle]"
614
+ },
615
+ {
616
+ kind: "directive",
617
+ type: MatCardContent,
618
+ selector: "mat-card-content"
619
+ }
620
+ ],
621
+ changeDetection: i0.ChangeDetectionStrategy.OnPush
622
+ });
623
+ };
624
+ i0.ɵɵngDeclareClassMetadata({
625
+ minVersion: "12.0.0",
626
+ version: "22.2.0",
627
+ ngImport: i0,
628
+ type: ThesaurusImportComponent,
629
+ decorators: [{
630
+ type: Component,
631
+ args: [{
632
+ selector: "cadmus-thesaurus-import",
633
+ changeDetection: ChangeDetectionStrategy.OnPush,
634
+ imports: [
635
+ FormField,
636
+ MatButton,
637
+ MatFormField,
638
+ MatLabel,
639
+ MatSelect,
640
+ MatOption,
641
+ MatHint,
642
+ MatError,
643
+ MatCheckbox,
644
+ MatInput,
645
+ MatProgressBar,
646
+ MatCard,
647
+ MatCardHeader,
648
+ MatCardTitle,
649
+ MatCardContent
650
+ ],
651
+ template: "<!-- form -->\n<div>\n <fieldset>\n <legend>source</legend>\n\n <!-- file picker -->\n <div>\n <input\n #fileInput\n type=\"file\"\n class=\"hidden\"\n (change)=\"onFileSelected($event)\"\n />\n <button\n type=\"button\"\n mat-flat-button\n class=\"mat-primary\"\n (click)=\"fileInput.click()\"\n [disabled]=\"uploading()\"\n >\n select file\n </button>\n <span class=\"file-name\">{{ form.file().value()?.name }}</span>\n @if (form.file().getError('required')) {\n <span class=\"error\">file required</span>\n } @if (form.file().getError('invalidExtension')) {\n <span class=\"error\">invalid file type</span>\n }\n </div>\n <br />\n\n <!-- mode -->\n <div class=\"form-row\">\n <mat-form-field>\n <mat-label>mode</mat-label>\n <mat-select [formField]=\"form.mode\">\n <mat-option value=\"R\">replace</mat-option>\n <mat-option value=\"P\">patch</mat-option>\n <mat-option value=\"S\">synch</mat-option>\n </mat-select>\n <mat-hint>\n @if (form.mode().value() === 'R') {\n <span\n >if the imported thesaurus already exists, it is fully replaced by\n the new one.</span\n >\n } @if (form.mode().value() === 'P') {\n <span\n >the existing thesaurus is patched with the imported one: any\n existing entry has its value overwritten; any non existing entry is\n just added.</span\n >\n } @if (form.mode().value() === 'S') {\n <span\n >equal to patch, with the addition that any existing entry not found\n in the imported thesaurus is removed.</span\n >\n }\n </mat-hint>\n @if (form.mode().getError('required') && (form.mode().dirty() || form.mode().touched())) {\n <mat-error>mode required</mat-error>\n }\n </mat-form-field>\n\n <!-- dry -->\n <mat-checkbox [formField]=\"form.dryRun\">dry run</mat-checkbox>\n </div>\n\n <!-- Excel -->\n @if ( form.file().value()?.name?.endsWith('.xlsx') ||\n form.file().value()?.name?.endsWith('.xls') ) {\n <div>\n <fieldset>\n <legend>Excel</legend>\n <div class=\"form-row\">\n <!-- excelSheet -->\n <mat-form-field class=\"nr-input\">\n <mat-label>sheet</mat-label>\n <input\n matInput\n type=\"number\"\n [formField]=\"form.excelSheet\"\n (keydown.enter)=\"!uploading() && upload()\"\n />\n </mat-form-field>\n <!-- excelRow -->\n <mat-form-field class=\"nr-input\">\n <mat-label>1st row</mat-label>\n <input\n matInput\n type=\"number\"\n [formField]=\"form.excelRow\"\n (keydown.enter)=\"!uploading() && upload()\"\n />\n </mat-form-field>\n <!-- excelColumn -->\n <mat-form-field class=\"nr-input\">\n <mat-label>1st column</mat-label>\n <input\n matInput\n type=\"number\"\n [formField]=\"form.excelColumn\"\n (keydown.enter)=\"!uploading() && upload()\"\n />\n </mat-form-field>\n </div>\n </fieldset>\n </div>\n }\n\n <!-- submit -->\n <div style=\"margin-top: 16px\">\n <button\n type=\"button\"\n mat-flat-button\n class=\"mat-warn\"\n [disabled]=\"uploading() || form().invalid()\"\n (click)=\"upload()\"\n >\n upload\n </button>\n </div>\n </fieldset>\n</div>\n\n<!-- uploading -->\n@if (uploading()) {\n<div>\n <div>\n <button type=\"button\" mat-flat-button class=\"mat-warn\" (click)=\"onCancel()\">\n cancel\n </button>\n </div>\n <div style=\"margin-top: 16px\">\n <mat-progress-bar max=\"100\" [value]=\"uploadProgress()\"></mat-progress-bar>\n </div>\n</div>\n}\n\n<!-- result -->\n@if (result()) {\n<div>\n @if (result()!.error) {\n <div class=\"error\">{{ result()!.error }}</div>\n } @if (result()!.importedIds.length) {\n <div>\n <div>\n <mat-card>\n <mat-card-header>\n <mat-card-title>Imported IDs</mat-card-title>\n </mat-card-header>\n <mat-card-content>\n <ol>\n @for (id of result()!.importedIds; track id) {\n <li>{{ id }}</li>\n }\n </ol>\n </mat-card-content>\n </mat-card>\n </div>\n </div>\n }\n</div>\n}\n",
652
+ styles: ["fieldset{border:1px solid #ddd;border-radius:4px;margin:8px 0;padding:8px}legend{color:var(--mat-sys-on-surface-variant)}.hidden{display:none}.file-name{color:var(--mat-sys-primary);margin-left:16px}.nr-input{width:6em}.form-row{display:flex;gap:8px;align-items:center;flex-wrap:wrap}.form-row *{flex:0 0 auto}.error{margin:8px;color:var(--mat-sys-on-error);padding:4px 8px;background-color:var(--mat-sys-error);border:1px solid var(--mat-sys-error);border-radius:6px}\n"]
653
+ }]
654
+ }],
655
+ ctorParameters: () => [{ type: i1.EnvService }, { type: i1$1.UploadService }],
656
+ propDecorators: {
657
+ uploadStart: [{
658
+ type: i0.Output,
659
+ args: ["uploadStart"]
660
+ }],
661
+ uploadEnd: [{
662
+ type: i0.Output,
663
+ args: ["uploadEnd"]
664
+ }]
665
+ }
666
+ });
667
+ var ThesaurusListComponent = class ThesaurusListComponent {
668
+ _repository;
669
+ _thesaurusService;
670
+ _dialogService;
671
+ _router;
672
+ _authService;
673
+ _userLevelService;
674
+ _snackbar;
675
+ _destroyRef = inject(DestroyRef);
676
+ loading$;
677
+ page$;
678
+ userLevel = signal(0, ...ngDevMode ? [{ debugName: "userLevel" }] : /* istanbul ignore next */ []);
679
+ downloading = signal(false, ...ngDevMode ? [{ debugName: "downloading" }] : /* istanbul ignore next */ []);
680
+ importEnabled = signal(false, ...ngDevMode ? [{ debugName: "importEnabled" }] : /* istanbul ignore next */ []);
681
+ adding = signal(false, ...ngDevMode ? [{ debugName: "adding" }] : /* istanbul ignore next */ []);
682
+ newThesaurusForm = form(signal({
683
+ newThesaurusId: "",
684
+ newThesaurusTargetId: ""
685
+ }), (path) => {
686
+ required(path.newThesaurusId);
687
+ maxLength(path.newThesaurusId, 100);
688
+ maxLength(path.newThesaurusTargetId, 100);
689
+ validate(path.newThesaurusTargetId, ({ value, valueOf }) => {
690
+ const id = valueOf(path.newThesaurusId).trim();
691
+ const targetId = value().trim();
692
+ return targetId && id && targetId === id ? { kind: "sameTargetId" } : null;
693
+ });
694
+ }, { submission: { action: async () => {
695
+ this.addThesaurus();
696
+ } } });
697
+ constructor(_repository, _thesaurusService, _dialogService, _router, _authService, _userLevelService, _snackbar, env) {
698
+ this._repository = _repository;
699
+ this._thesaurusService = _thesaurusService;
700
+ this._dialogService = _dialogService;
701
+ this._router = _router;
702
+ this._authService = _authService;
703
+ this._userLevelService = _userLevelService;
704
+ this._snackbar = _snackbar;
705
+ this.loading$ = _repository.loading$;
706
+ this.page$ = _repository.page$;
707
+ this.importEnabled.set(_authService.isCurrentUserInRole("admin") && env.get("thesImportEnabled") ? true : false);
708
+ }
709
+ ngOnInit() {
710
+ this._authService.currentUser$.pipe(takeUntilDestroyed(this._destroyRef)).subscribe(() => {
711
+ this.userLevel.set(this._userLevelService.getCurrentUserLevel());
712
+ });
713
+ }
714
+ onPageChange(event) {
715
+ this._repository.setPage(event.pageIndex + 1, event.pageSize);
716
+ }
717
+ addThesaurus() {
718
+ if (this.newThesaurusForm().invalid()) return;
719
+ const id = this.newThesaurusForm.newThesaurusId().value().trim();
720
+ const targetId = this.newThesaurusForm.newThesaurusTargetId().value().trim() || void 0;
721
+ this.adding.set(true);
722
+ this._thesaurusService.getThesaurus(id, true).pipe(switchMap((existing) => {
723
+ if (existing.entries?.length || existing.targetId) {
724
+ this._snackbar.open(`Thesaurus with ID "${id}" already exists.`, "OK");
725
+ return of(null);
726
+ }
727
+ if (targetId) return this._thesaurusService.getThesaurus(targetId, true).pipe(map((target) => {
728
+ if (!target.entries?.length && !target.targetId) {
729
+ this._snackbar.open(`Target thesaurus "${targetId}" does not exist.`, "OK");
730
+ return null;
731
+ }
732
+ return {
733
+ id,
734
+ targetId
735
+ };
736
+ }), catchError((err) => {
737
+ console.error(err);
738
+ this._snackbar.open(`Error checking target thesaurus: ${err.message || err}`, "OK");
739
+ return of(null);
740
+ }));
741
+ return of({
742
+ id,
743
+ targetId: void 0
744
+ });
745
+ }), filter((data) => data !== null), switchMap(({ id, targetId }) => {
746
+ const thesaurus = {
747
+ id,
748
+ entries: [],
749
+ targetId
750
+ };
751
+ return this._thesaurusService.addThesaurus(thesaurus).pipe(map(() => thesaurus), catchError((err) => {
752
+ console.error(err);
753
+ this._snackbar.open(`Error adding thesaurus: ${err.message || err}`, "OK");
754
+ return of(null);
755
+ }));
756
+ }), filter((thesaurus) => thesaurus !== null), tap((thesaurus) => {
757
+ this._repository.reset();
758
+ this._snackbar.open(`Thesaurus "${thesaurus.id}" added.`, "OK", { duration: 3e3 });
759
+ this.editThesaurus(thesaurus);
760
+ }), finalize(() => this.adding.set(false)), takeUntilDestroyed(this._destroyRef)).subscribe();
761
+ }
762
+ editThesaurus(thesaurus) {
763
+ this._router.navigate(["/thesauri", thesaurus.id]);
764
+ }
765
+ deleteThesaurus(thesaurus) {
766
+ if (this.userLevel() < 3) return;
767
+ this._dialogService.confirm("Confirm Deletion", `Delete thesaurus "${thesaurus.id}"?`).subscribe((yes) => {
768
+ if (yes) this._repository.deleteThesaurus(thesaurus.id);
769
+ });
770
+ }
771
+ downloadThesaurus(id) {
772
+ if (this.downloading()) return;
773
+ this.downloading.set(true);
774
+ this._thesaurusService.getThesaurus(id).subscribe({
775
+ next: (thesaurus) => {
776
+ this.downloading.set(false);
777
+ const json = JSON.stringify(thesaurus, null, 2);
778
+ const element = document.createElement("a");
779
+ const file = new Blob([json], { type: "application/json" });
780
+ const url = URL.createObjectURL(file);
781
+ element.href = url;
782
+ element.download = `${thesaurus.id}.json`;
783
+ document.body.appendChild(element);
784
+ element.click();
785
+ document.body.removeChild(element);
786
+ URL.revokeObjectURL(url);
787
+ },
788
+ error: (err) => {
789
+ this.downloading.set(false);
790
+ console.error(err);
791
+ this._snackbar.open("Error downloading thesaurus", "OK");
792
+ }
793
+ });
794
+ }
795
+ onUploadEnd() {
796
+ this._repository.reset();
797
+ }
798
+ static ɵfac = i0.ɵɵngDeclareFactory({
799
+ minVersion: "12.0.0",
800
+ version: "22.2.0",
801
+ ngImport: i0,
802
+ type: ThesaurusListComponent,
803
+ deps: [
804
+ { token: ThesaurusListRepository },
805
+ { token: i1$1.ThesaurusService },
806
+ { token: i3.DialogService },
807
+ { token: i4.Router },
808
+ { token: i5.AuthJwtService },
809
+ { token: i1$1.UserLevelService },
810
+ { token: i6.MatSnackBar },
811
+ { token: i1.EnvService }
812
+ ],
813
+ target: i0.ɵɵFactoryTarget.Component
814
+ });
815
+ static ɵcmp = i0.ɵɵngDeclareComponent({
816
+ minVersion: "17.0.0",
817
+ version: "22.2.0",
818
+ type: ThesaurusListComponent,
819
+ isStandalone: true,
820
+ selector: "cadmus-thesaurus-list",
821
+ ngImport: i0,
822
+ template: "<mat-card appearance=\"outlined\">\r\n <mat-card-header>\r\n <mat-card-title> Thesauri </mat-card-title>\r\n </mat-card-header>\r\n <mat-card-content>\r\n <div id=\"container\">\r\n <!-- filters -->\r\n <div id=\"filters\">\r\n <cadmus-thesaurus-filter></cadmus-thesaurus-filter>\r\n </div>\r\n\r\n <!-- list -->\r\n @if (page$ | async; as page) {\r\n <div id=\"list\">\r\n @if (loading$ | async) {\r\n <div>\r\n <mat-progress-bar mode=\"indeterminate\"></mat-progress-bar>\r\n </div>\r\n }\r\n <table>\r\n <thead>\r\n <th></th>\r\n <th>id</th>\r\n <th>entries</th>\r\n </thead>\r\n <tbody>\r\n @for (thesaurus of page.items; track thesaurus.id) {\r\n <tr>\r\n <td class=\"fit-width\">\r\n <button\r\n mat-icon-button\r\n type=\"button\"\r\n matTooltip=\"Edit {{ thesaurus.id }}\"\r\n (click)=\"editThesaurus(thesaurus)\"\r\n >\r\n <mat-icon class=\"mat-primary\">mode_edit</mat-icon>\r\n </button>\r\n @if (userLevel() > 2) {\r\n <button\r\n mat-icon-button\r\n type=\"button\"\r\n matTooltip=\"Delete {{ thesaurus.id }}\"\r\n (click)=\"deleteThesaurus(thesaurus)\"\r\n >\r\n <mat-icon class=\"mat-warn\">delete</mat-icon>\r\n </button>\r\n }\r\n <button\r\n type=\"button\"\r\n mat-icon-button\r\n matTooltip=\"Download this thesaurus\"\r\n [disabled]=\"downloading()\"\r\n (click)=\"downloadThesaurus(thesaurus.id)\"\r\n >\r\n <mat-icon>download</mat-icon>\r\n </button>\r\n </td>\r\n <td>{{ thesaurus.id }}</td>\r\n <td>\r\n {{ thesaurus.entries?.length || 0 }}\r\n </td>\r\n </tr>\r\n }\r\n </tbody>\r\n </table>\r\n <!-- pagination -->\r\n <mat-paginator\r\n [length]=\"page.total\"\r\n [pageIndex]=\"page.pageNumber - 1\"\r\n [pageSize]=\"page.pageSize\"\r\n [pageSizeOptions]=\"[5, 10, 20, 50, 100]\"\r\n (page)=\"onPageChange($event)\"\r\n [showFirstLastButtons]=\"true\"\r\n />\r\n\r\n <!-- adder -->\r\n <div>\r\n <fieldset>\r\n <legend>add thesaurus</legend>\r\n <form [formRoot]=\"newThesaurusForm\" class=\"form-row\">\r\n <!-- id -->\r\n <mat-form-field>\r\n <mat-label>ID</mat-label>\r\n <input matInput [formField]=\"newThesaurusForm.newThesaurusId\" />\r\n @if (\r\n newThesaurusForm.newThesaurusId().getError('required') &&\r\n (newThesaurusForm.newThesaurusId().dirty() ||\r\n newThesaurusForm.newThesaurusId().touched())\r\n ) {\r\n <mat-error>ID required</mat-error>\r\n }\r\n @if (\r\n newThesaurusForm.newThesaurusId().getError('maxLength') &&\r\n (newThesaurusForm.newThesaurusId().dirty() ||\r\n newThesaurusForm.newThesaurusId().touched())\r\n ) {\r\n <mat-error>ID too long</mat-error>\r\n }\r\n </mat-form-field>\r\n <!-- target ID (for alias) -->\r\n <mat-form-field>\r\n <mat-label>target ID</mat-label>\r\n <input matInput [formField]=\"newThesaurusForm.newThesaurusTargetId\" />\r\n @if (\r\n newThesaurusForm.newThesaurusTargetId().getError('maxLength') &&\r\n (newThesaurusForm.newThesaurusTargetId().dirty() ||\r\n newThesaurusForm.newThesaurusTargetId().touched())\r\n ) {\r\n <mat-error>ID too long</mat-error>\r\n }\r\n @if (newThesaurusForm.newThesaurusTargetId().getError(\"sameTargetId\")) {\r\n <mat-error>Target ID must differ from ID</mat-error>\r\n }\r\n </mat-form-field>\r\n <!-- add button -->\r\n <button\r\n type=\"submit\"\r\n mat-flat-button\r\n color=\"primary\"\r\n matTooltip=\"Add a new thesaurus (or alias if target ID is set)\"\r\n [disabled]=\"newThesaurusForm().invalid() || adding()\"\r\n >\r\n add\r\n </button>\r\n @if (adding()) {\r\n <div>\r\n <mat-progress-bar mode=\"indeterminate\" />\r\n </div>\r\n }\r\n </form>\r\n </fieldset>\r\n </div>\r\n\r\n <!-- importer -->\r\n @if (importEnabled()) {\r\n <div class=\"margin-top\">\r\n <mat-expansion-panel>\r\n <mat-expansion-panel-header>\r\n <mat-panel-title>Import thesauri</mat-panel-title>\r\n </mat-expansion-panel-header>\r\n <cadmus-thesaurus-import (uploadEnd)=\"onUploadEnd()\" />\r\n </mat-expansion-panel>\r\n </div>\r\n }\r\n </div>\r\n }\r\n </div>\r\n </mat-card-content>\r\n</mat-card>\r\n",
823
+ styles: ["table{width:100%;border-collapse:collapse}tbody tr:nth-child(odd){background-color:var(--mat-sys-surface-container)}th{text-align:left;font-weight:400;color:var(--mat-sys-on-surface-variant)}tbody tr:hover{background-color:var(--mat-sys-surface-container-high)}td.fit-width{width:1px;white-space:nowrap}tbody tr.selected{background-color:var(--mat-sys-secondary-container);color:var(--mat-sys-on-secondary-container)}fieldset{border:1px solid var(--mat-sys-on-surface-variant);border-radius:6px;padding:6px}legend{color:var(--mat-sys-on-surface-variant)}.form-row{display:flex;gap:8px;align-items:center;flex-wrap:wrap}.form-row *{flex:0 0 auto}.margin-top{margin-top:1rem}div#container{display:grid;grid-template-rows:1fr;grid-template-columns:auto 1fr;grid-template-areas:\"filters list\";gap:16px}#filters{grid-area:filters;max-width:230px}#list{grid-area:list}@media only screen and (max-width:959px){div#container{grid-template-rows:1fr auto;grid-template-columns:1fr;grid-template-areas:\"list\" \"filters\"}#filters{max-width:none}.noif-lt-md{display:none}}\n"],
824
+ dependencies: [
825
+ {
826
+ kind: "directive",
827
+ type: FormField,
828
+ selector: "[formField]",
829
+ inputs: ["formField"],
830
+ exportAs: ["formField"]
831
+ },
832
+ {
833
+ kind: "directive",
834
+ type: FormRoot,
835
+ selector: "form[formRoot]",
836
+ inputs: ["formRoot"]
837
+ },
838
+ {
839
+ kind: "component",
840
+ type: MatButton,
841
+ selector: " button[matButton], a[matButton], button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button], a[mat-button], a[mat-raised-button], a[mat-flat-button], a[mat-stroked-button] ",
842
+ inputs: ["matButton"],
843
+ exportAs: ["matButton", "matAnchor"]
844
+ },
845
+ {
846
+ kind: "component",
847
+ type: MatCard,
848
+ selector: "mat-card",
849
+ inputs: ["appearance"],
850
+ exportAs: ["matCard"]
851
+ },
852
+ {
853
+ kind: "component",
854
+ type: MatCardHeader,
855
+ selector: "mat-card-header"
856
+ },
857
+ {
858
+ kind: "directive",
859
+ type: MatCardTitle,
860
+ selector: "mat-card-title, [mat-card-title], [matCardTitle]"
861
+ },
862
+ {
863
+ kind: "directive",
864
+ type: MatCardContent,
865
+ selector: "mat-card-content"
866
+ },
867
+ {
868
+ kind: "directive",
869
+ type: MatError$1,
870
+ selector: "mat-error, [matError]",
871
+ inputs: ["id"]
872
+ },
873
+ {
874
+ kind: "component",
875
+ type: MatProgressBar,
876
+ selector: "mat-progress-bar",
877
+ inputs: [
878
+ "color",
879
+ "value",
880
+ "bufferValue",
881
+ "mode"
882
+ ],
883
+ outputs: ["animationEnd"],
884
+ exportAs: ["matProgressBar"]
885
+ },
886
+ {
887
+ kind: "component",
888
+ type: MatFormField$1,
889
+ selector: "mat-form-field",
890
+ inputs: [
891
+ "hideRequiredMarker",
892
+ "color",
893
+ "floatLabel",
894
+ "appearance",
895
+ "subscriptSizing",
896
+ "hintLabel"
897
+ ],
898
+ exportAs: ["matFormField"]
899
+ },
900
+ {
901
+ kind: "component",
902
+ type: MatIconButton,
903
+ selector: "button[mat-icon-button], a[mat-icon-button], button[matIconButton], a[matIconButton]",
904
+ exportAs: ["matButton", "matAnchor"]
905
+ },
906
+ {
907
+ kind: "component",
908
+ type: MatIcon,
909
+ selector: "mat-icon",
910
+ inputs: [
911
+ "color",
912
+ "inline",
913
+ "svgIcon",
914
+ "fontSet",
915
+ "fontIcon"
916
+ ],
917
+ exportAs: ["matIcon"]
918
+ },
919
+ {
920
+ kind: "directive",
921
+ type: MatInput,
922
+ selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]",
923
+ inputs: [
924
+ "disabled",
925
+ "id",
926
+ "placeholder",
927
+ "name",
928
+ "required",
929
+ "type",
930
+ "errorStateMatcher",
931
+ "aria-describedby",
932
+ "value",
933
+ "readonly",
934
+ "disabledInteractive"
935
+ ],
936
+ exportAs: ["matInput"]
937
+ },
938
+ {
939
+ kind: "directive",
940
+ type: MatLabel$1,
941
+ selector: "mat-label"
942
+ },
943
+ {
944
+ kind: "directive",
945
+ type: MatTooltip,
946
+ selector: "[matTooltip]",
947
+ inputs: [
948
+ "matTooltipPosition",
949
+ "matTooltipPositionAtOrigin",
950
+ "matTooltipDisabled",
951
+ "matTooltipShowDelay",
952
+ "matTooltipHideDelay",
953
+ "matTooltipTouchGestures",
954
+ "matTooltip",
955
+ "matTooltipClass"
956
+ ],
957
+ exportAs: ["matTooltip"]
958
+ },
959
+ {
960
+ kind: "component",
961
+ type: MatPaginator,
962
+ selector: "mat-paginator",
963
+ inputs: [
964
+ "color",
965
+ "pageIndex",
966
+ "length",
967
+ "pageSize",
968
+ "pageSizeOptions",
969
+ "hidePageSize",
970
+ "showFirstLastButtons",
971
+ "selectConfig",
972
+ "disabled"
973
+ ],
974
+ outputs: ["page"],
975
+ exportAs: ["matPaginator"]
976
+ },
977
+ {
978
+ kind: "component",
979
+ type: MatExpansionPanel,
980
+ selector: "mat-expansion-panel",
981
+ inputs: ["hideToggle", "togglePosition"],
982
+ outputs: ["afterExpand", "afterCollapse"],
983
+ exportAs: ["matExpansionPanel"]
984
+ },
985
+ {
986
+ kind: "component",
987
+ type: MatExpansionPanelHeader,
988
+ selector: "mat-expansion-panel-header",
989
+ inputs: [
990
+ "expandedHeight",
991
+ "collapsedHeight",
992
+ "tabIndex"
993
+ ]
994
+ },
995
+ {
996
+ kind: "directive",
997
+ type: MatExpansionPanelTitle,
998
+ selector: "mat-panel-title"
999
+ },
1000
+ {
1001
+ kind: "component",
1002
+ type: ThesaurusFilterComponent,
1003
+ selector: "cadmus-thesaurus-filter"
1004
+ },
1005
+ {
1006
+ kind: "component",
1007
+ type: ThesaurusImportComponent,
1008
+ selector: "cadmus-thesaurus-import",
1009
+ outputs: ["uploadStart", "uploadEnd"]
1010
+ },
1011
+ {
1012
+ kind: "pipe",
1013
+ type: AsyncPipe,
1014
+ name: "async"
1015
+ }
1016
+ ],
1017
+ changeDetection: i0.ChangeDetectionStrategy.OnPush
1018
+ });
1019
+ };
1020
+ i0.ɵɵngDeclareClassMetadata({
1021
+ minVersion: "12.0.0",
1022
+ version: "22.2.0",
1023
+ ngImport: i0,
1024
+ type: ThesaurusListComponent,
1025
+ decorators: [{
1026
+ type: Component,
1027
+ args: [{
1028
+ selector: "cadmus-thesaurus-list",
1029
+ changeDetection: ChangeDetectionStrategy.OnPush,
1030
+ imports: [
1031
+ AsyncPipe,
1032
+ FormField,
1033
+ FormRoot,
1034
+ MatButton,
1035
+ MatCard,
1036
+ MatCardHeader,
1037
+ MatCardTitle,
1038
+ MatCardContent,
1039
+ MatError$1,
1040
+ MatProgressBar,
1041
+ MatFormField$1,
1042
+ MatIconButton,
1043
+ MatIcon,
1044
+ MatInput,
1045
+ MatLabel$1,
1046
+ MatTooltip,
1047
+ MatPaginator,
1048
+ MatExpansionPanel,
1049
+ MatExpansionPanelHeader,
1050
+ MatExpansionPanelTitle,
1051
+ ThesaurusFilterComponent,
1052
+ ThesaurusImportComponent
1053
+ ],
1054
+ template: "<mat-card appearance=\"outlined\">\r\n <mat-card-header>\r\n <mat-card-title> Thesauri </mat-card-title>\r\n </mat-card-header>\r\n <mat-card-content>\r\n <div id=\"container\">\r\n <!-- filters -->\r\n <div id=\"filters\">\r\n <cadmus-thesaurus-filter></cadmus-thesaurus-filter>\r\n </div>\r\n\r\n <!-- list -->\r\n @if (page$ | async; as page) {\r\n <div id=\"list\">\r\n @if (loading$ | async) {\r\n <div>\r\n <mat-progress-bar mode=\"indeterminate\"></mat-progress-bar>\r\n </div>\r\n }\r\n <table>\r\n <thead>\r\n <th></th>\r\n <th>id</th>\r\n <th>entries</th>\r\n </thead>\r\n <tbody>\r\n @for (thesaurus of page.items; track thesaurus.id) {\r\n <tr>\r\n <td class=\"fit-width\">\r\n <button\r\n mat-icon-button\r\n type=\"button\"\r\n matTooltip=\"Edit {{ thesaurus.id }}\"\r\n (click)=\"editThesaurus(thesaurus)\"\r\n >\r\n <mat-icon class=\"mat-primary\">mode_edit</mat-icon>\r\n </button>\r\n @if (userLevel() > 2) {\r\n <button\r\n mat-icon-button\r\n type=\"button\"\r\n matTooltip=\"Delete {{ thesaurus.id }}\"\r\n (click)=\"deleteThesaurus(thesaurus)\"\r\n >\r\n <mat-icon class=\"mat-warn\">delete</mat-icon>\r\n </button>\r\n }\r\n <button\r\n type=\"button\"\r\n mat-icon-button\r\n matTooltip=\"Download this thesaurus\"\r\n [disabled]=\"downloading()\"\r\n (click)=\"downloadThesaurus(thesaurus.id)\"\r\n >\r\n <mat-icon>download</mat-icon>\r\n </button>\r\n </td>\r\n <td>{{ thesaurus.id }}</td>\r\n <td>\r\n {{ thesaurus.entries?.length || 0 }}\r\n </td>\r\n </tr>\r\n }\r\n </tbody>\r\n </table>\r\n <!-- pagination -->\r\n <mat-paginator\r\n [length]=\"page.total\"\r\n [pageIndex]=\"page.pageNumber - 1\"\r\n [pageSize]=\"page.pageSize\"\r\n [pageSizeOptions]=\"[5, 10, 20, 50, 100]\"\r\n (page)=\"onPageChange($event)\"\r\n [showFirstLastButtons]=\"true\"\r\n />\r\n\r\n <!-- adder -->\r\n <div>\r\n <fieldset>\r\n <legend>add thesaurus</legend>\r\n <form [formRoot]=\"newThesaurusForm\" class=\"form-row\">\r\n <!-- id -->\r\n <mat-form-field>\r\n <mat-label>ID</mat-label>\r\n <input matInput [formField]=\"newThesaurusForm.newThesaurusId\" />\r\n @if (\r\n newThesaurusForm.newThesaurusId().getError('required') &&\r\n (newThesaurusForm.newThesaurusId().dirty() ||\r\n newThesaurusForm.newThesaurusId().touched())\r\n ) {\r\n <mat-error>ID required</mat-error>\r\n }\r\n @if (\r\n newThesaurusForm.newThesaurusId().getError('maxLength') &&\r\n (newThesaurusForm.newThesaurusId().dirty() ||\r\n newThesaurusForm.newThesaurusId().touched())\r\n ) {\r\n <mat-error>ID too long</mat-error>\r\n }\r\n </mat-form-field>\r\n <!-- target ID (for alias) -->\r\n <mat-form-field>\r\n <mat-label>target ID</mat-label>\r\n <input matInput [formField]=\"newThesaurusForm.newThesaurusTargetId\" />\r\n @if (\r\n newThesaurusForm.newThesaurusTargetId().getError('maxLength') &&\r\n (newThesaurusForm.newThesaurusTargetId().dirty() ||\r\n newThesaurusForm.newThesaurusTargetId().touched())\r\n ) {\r\n <mat-error>ID too long</mat-error>\r\n }\r\n @if (newThesaurusForm.newThesaurusTargetId().getError(\"sameTargetId\")) {\r\n <mat-error>Target ID must differ from ID</mat-error>\r\n }\r\n </mat-form-field>\r\n <!-- add button -->\r\n <button\r\n type=\"submit\"\r\n mat-flat-button\r\n color=\"primary\"\r\n matTooltip=\"Add a new thesaurus (or alias if target ID is set)\"\r\n [disabled]=\"newThesaurusForm().invalid() || adding()\"\r\n >\r\n add\r\n </button>\r\n @if (adding()) {\r\n <div>\r\n <mat-progress-bar mode=\"indeterminate\" />\r\n </div>\r\n }\r\n </form>\r\n </fieldset>\r\n </div>\r\n\r\n <!-- importer -->\r\n @if (importEnabled()) {\r\n <div class=\"margin-top\">\r\n <mat-expansion-panel>\r\n <mat-expansion-panel-header>\r\n <mat-panel-title>Import thesauri</mat-panel-title>\r\n </mat-expansion-panel-header>\r\n <cadmus-thesaurus-import (uploadEnd)=\"onUploadEnd()\" />\r\n </mat-expansion-panel>\r\n </div>\r\n }\r\n </div>\r\n }\r\n </div>\r\n </mat-card-content>\r\n</mat-card>\r\n",
1055
+ styles: ["table{width:100%;border-collapse:collapse}tbody tr:nth-child(odd){background-color:var(--mat-sys-surface-container)}th{text-align:left;font-weight:400;color:var(--mat-sys-on-surface-variant)}tbody tr:hover{background-color:var(--mat-sys-surface-container-high)}td.fit-width{width:1px;white-space:nowrap}tbody tr.selected{background-color:var(--mat-sys-secondary-container);color:var(--mat-sys-on-secondary-container)}fieldset{border:1px solid var(--mat-sys-on-surface-variant);border-radius:6px;padding:6px}legend{color:var(--mat-sys-on-surface-variant)}.form-row{display:flex;gap:8px;align-items:center;flex-wrap:wrap}.form-row *{flex:0 0 auto}.margin-top{margin-top:1rem}div#container{display:grid;grid-template-rows:1fr;grid-template-columns:auto 1fr;grid-template-areas:\"filters list\";gap:16px}#filters{grid-area:filters;max-width:230px}#list{grid-area:list}@media only screen and (max-width:959px){div#container{grid-template-rows:1fr auto;grid-template-columns:1fr;grid-template-areas:\"list\" \"filters\"}#filters{max-width:none}.noif-lt-md{display:none}}\n"]
1056
+ }]
1057
+ }],
1058
+ ctorParameters: () => [
1059
+ { type: ThesaurusListRepository },
1060
+ { type: i1$1.ThesaurusService },
1061
+ { type: i3.DialogService },
1062
+ { type: i4.Router },
1063
+ { type: i5.AuthJwtService },
1064
+ { type: i1$1.UserLevelService },
1065
+ { type: i6.MatSnackBar },
1066
+ { type: i1.EnvService }
1067
+ ]
1068
+ });
569
1069
  export { ThesaurusFilterComponent, ThesaurusImportComponent, ThesaurusListComponent, ThesaurusListRepository };
570
- //# sourceMappingURL=myrmidon-cadmus-thesaurus-list.mjs.map
1070
+
1071
+ //# sourceMappingURL=myrmidon-cadmus-thesaurus-list.mjs.map