@zambon-dev/ui 1.3.0 → 1.4.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.
- package/CHANGELOG.md +27 -0
- package/fesm2022/zambon-dev-ui-shared.mjs +205 -35
- package/fesm2022/zambon-dev-ui-shared.mjs.map +1 -1
- package/i18n/shared/operations-history/en.json +15 -0
- package/i18n/shared/operations-history/pt.json +15 -0
- package/package.json +1 -1
- package/types/zambon-dev-ui-shared.d.ts +132 -2
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
{
|
|
2
|
+
"OperationsHistory-List-ChangedFields": "{{count}} field(s) changed",
|
|
3
|
+
"OperationsHistory-Modal-After": "After",
|
|
4
|
+
"OperationsHistory-Modal-Before": "Before",
|
|
5
|
+
"OperationsHistory-Modal-Changed": "changed",
|
|
6
|
+
"OperationsHistory-Modal-Field": "Field",
|
|
7
|
+
"OperationsHistory-Modal-NoChanges": "This operation changed no fields.",
|
|
8
|
+
"OperationsHistory-Modal-ShowAllFields": "Show all fields",
|
|
9
|
+
"OperationsHistory-Modal-SystemFields": "System fields",
|
|
2
10
|
"OperationsHistory-Modal-Title": "Object changes details",
|
|
11
|
+
"OperationsHistory-Operation-Added": "Created",
|
|
12
|
+
"OperationsHistory-Operation-Deleted": "Deleted",
|
|
13
|
+
"OperationsHistory-Operation-Modified": "Updated",
|
|
14
|
+
"OperationsHistory-Operation-Unchanged": "Unchanged",
|
|
15
|
+
"OperationsHistory-Value-Empty": "—",
|
|
16
|
+
"OperationsHistory-Value-No": "No",
|
|
17
|
+
"OperationsHistory-Value-Yes": "Yes",
|
|
3
18
|
|
|
4
19
|
"": ""
|
|
5
20
|
}
|
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
{
|
|
2
|
+
"OperationsHistory-List-ChangedFields": "{{count}} campo(s) alterado(s)",
|
|
3
|
+
"OperationsHistory-Modal-After": "Depois",
|
|
4
|
+
"OperationsHistory-Modal-Before": "Antes",
|
|
5
|
+
"OperationsHistory-Modal-Changed": "alterado",
|
|
6
|
+
"OperationsHistory-Modal-Field": "Campo",
|
|
7
|
+
"OperationsHistory-Modal-NoChanges": "Esta operação não alterou nenhum campo.",
|
|
8
|
+
"OperationsHistory-Modal-ShowAllFields": "Mostrar todos os campos",
|
|
9
|
+
"OperationsHistory-Modal-SystemFields": "Campos de sistema",
|
|
2
10
|
"OperationsHistory-Modal-Title": "Detalhes de alteração do objeto",
|
|
11
|
+
"OperationsHistory-Operation-Added": "Criado",
|
|
12
|
+
"OperationsHistory-Operation-Deleted": "Excluído",
|
|
13
|
+
"OperationsHistory-Operation-Modified": "Alterado",
|
|
14
|
+
"OperationsHistory-Operation-Unchanged": "Sem alteração",
|
|
15
|
+
"OperationsHistory-Value-Empty": "—",
|
|
16
|
+
"OperationsHistory-Value-No": "Não",
|
|
17
|
+
"OperationsHistory-Value-Yes": "Sim",
|
|
3
18
|
|
|
4
19
|
"": ""
|
|
5
20
|
}
|
package/package.json
CHANGED
|
@@ -113,17 +113,63 @@ export interface INotification {
|
|
|
113
113
|
/** Whether the notification has been read. */
|
|
114
114
|
isRead: boolean;
|
|
115
115
|
}
|
|
116
|
+
/** What kind of value an audited field holds, as ZWebAPI reports it. */
|
|
117
|
+
export type OperationsHistoryFieldType = 'boolean' | 'date' | 'enum' | 'key' | 'number' | 'other' | 'text' | 'time';
|
|
118
|
+
/** One field of an audited record, before and after an operation. */
|
|
119
|
+
export interface IOperationsHistoryField {
|
|
120
|
+
/** Whether the operation wrote this field. A creation writes every field, a deletion removes every one. */
|
|
121
|
+
isChanged: boolean;
|
|
122
|
+
/** Bookkeeping rather than data: the key, the audit columns, the concurrency token. */
|
|
123
|
+
isSystem: boolean;
|
|
124
|
+
/** The property name, as the backend declares it (`NomeCompleto`). */
|
|
125
|
+
name: string;
|
|
126
|
+
/** The value after the operation; `null` for a deletion, or when the backend could not rebuild it. */
|
|
127
|
+
newValue?: unknown;
|
|
128
|
+
/** The value before the operation; `null` for a creation, or when the backend could not rebuild it. */
|
|
129
|
+
oldValue?: unknown;
|
|
130
|
+
type: OperationsHistoryFieldType;
|
|
131
|
+
}
|
|
116
132
|
export interface IOperationsHistoryList {
|
|
117
133
|
/** Capitalised `ID` is intentional: the backend property is `EntityID`, and the camelCase
|
|
118
134
|
* serialization policy only lowercases a leading run of capitals — so the trailing ones survive. */
|
|
119
135
|
entityID?: number;
|
|
120
136
|
entityName?: string;
|
|
137
|
+
/**
|
|
138
|
+
* Every field of the record, before and after the operation. Sent by ZWebAPI 1.17 and later;
|
|
139
|
+
* without it only the fields the operation wrote are known, from `oldValues` and `newValues`.
|
|
140
|
+
*/
|
|
141
|
+
fields?: IOperationsHistoryField[];
|
|
121
142
|
id: number;
|
|
122
143
|
newValues?: string;
|
|
123
144
|
oldValues?: string;
|
|
124
145
|
operationType?: string;
|
|
125
146
|
tableName?: string;
|
|
126
147
|
}
|
|
148
|
+
/**
|
|
149
|
+
* Turns an audited field into the label the audit shows for it.
|
|
150
|
+
*
|
|
151
|
+
* The result goes through the translation pipe, so it may be a translation key. A key with no
|
|
152
|
+
* translation shows as itself, which is why the default returns readable text rather than a key.
|
|
153
|
+
*/
|
|
154
|
+
export type OperationsHistoryFieldLabel = (fieldName: string, entityName: string | undefined) => string;
|
|
155
|
+
/**
|
|
156
|
+
* Splits a PascalCase or camelCase property name into words, keeping acronyms whole.
|
|
157
|
+
*
|
|
158
|
+
* @param fieldName The property name.
|
|
159
|
+
* @returns The name as words, with only the first capitalised.
|
|
160
|
+
*/
|
|
161
|
+
export declare function humanizeFieldName(fieldName: string): string;
|
|
162
|
+
/**
|
|
163
|
+
* Labels the fields of the audit's change details.
|
|
164
|
+
*
|
|
165
|
+
* The default splits the property name into words: `NomeCompleto` reads "Nome completo" and
|
|
166
|
+
* `CadastroID` reads "Cadastro ID". Provide a function to use the application's own field labels:
|
|
167
|
+
*
|
|
168
|
+
* ```ts
|
|
169
|
+
* { provide: OPERATIONS_HISTORY_FIELD_LABEL, useValue: (field, entity) => `${entity}-Field-${field}` }
|
|
170
|
+
* ```
|
|
171
|
+
*/
|
|
172
|
+
export declare const OPERATIONS_HISTORY_FIELD_LABEL: InjectionToken<OperationsHistoryFieldLabel>;
|
|
127
173
|
export interface IServicesHistoryList {
|
|
128
174
|
changedByName: string;
|
|
129
175
|
changedOn: Date;
|
|
@@ -397,9 +443,14 @@ export declare class OperationsHistoryChildListComponent extends ChildList<any>
|
|
|
397
443
|
[key: string]: string;
|
|
398
444
|
} | undefined);
|
|
399
445
|
set serviceID(value: number | undefined);
|
|
446
|
+
/** @deprecated Read `selectedOperation` instead, which also carries the whole record. */
|
|
400
447
|
readonly selectedNewValues: WritableSignal<any | null>;
|
|
448
|
+
/** @deprecated Read `selectedOperation` instead, which also carries the whole record. */
|
|
401
449
|
readonly selectedOldValues: WritableSignal<any | null>;
|
|
450
|
+
readonly selectedOperation: WritableSignal<IOperationsHistoryList | null>;
|
|
402
451
|
ngAfterViewInit(): void;
|
|
452
|
+
/** How many data fields an operation changed, for the summary beside it. */
|
|
453
|
+
protected changedFieldsOf(operation: IOperationsHistoryList): number;
|
|
403
454
|
openModal(): void;
|
|
404
455
|
selectedRowChanged(): void;
|
|
405
456
|
static ɵfac: i0.ɵɵFactoryDeclaration<OperationsHistoryChildListComponent, never>;
|
|
@@ -418,12 +469,86 @@ export declare class OperationsHistoryChildListComponent extends ChildList<any>
|
|
|
418
469
|
};
|
|
419
470
|
}, {}, never, never, true, never>;
|
|
420
471
|
}
|
|
472
|
+
/** A value ready to show: either text as it is, or a translation key. */
|
|
473
|
+
interface IOperationsHistoryValue {
|
|
474
|
+
isKey: boolean;
|
|
475
|
+
text: string;
|
|
476
|
+
}
|
|
477
|
+
/**
|
|
478
|
+
* Every field an operation shows.
|
|
479
|
+
*
|
|
480
|
+
* ZWebAPI 1.17 and later send the whole record, rebuilt from its history. An older backend sends
|
|
481
|
+
* only what the operation wrote, as two JSON objects; those are read as the changed fields, with
|
|
482
|
+
* their kind of value guessed from the value itself.
|
|
483
|
+
*
|
|
484
|
+
* @param operation The operation, or nothing.
|
|
485
|
+
* @returns The fields, in the order the backend declares them.
|
|
486
|
+
*/
|
|
487
|
+
declare function getOperationFields(operation: IOperationsHistoryList | null | undefined): IOperationsHistoryField[];
|
|
488
|
+
/**
|
|
489
|
+
* How many data fields an operation changed, leaving bookkeeping out.
|
|
490
|
+
*
|
|
491
|
+
* @param operation The operation.
|
|
492
|
+
* @returns The count.
|
|
493
|
+
*/
|
|
494
|
+
declare function countChangedFields(operation: IOperationsHistoryList | null | undefined): number;
|
|
495
|
+
/**
|
|
496
|
+
* Formats a field's value for the user.
|
|
497
|
+
*
|
|
498
|
+
* Dates follow the locale, with the time left out when it is midnight; numbers are grouped;
|
|
499
|
+
* booleans and empty values become translation keys.
|
|
500
|
+
*
|
|
501
|
+
* @param value The value as the backend sent it.
|
|
502
|
+
* @param type What kind of value the field holds.
|
|
503
|
+
* @param locale The locale to format in.
|
|
504
|
+
* @returns The text to show, or the key to translate.
|
|
505
|
+
*/
|
|
506
|
+
declare function formatFieldValue(value: unknown, type: OperationsHistoryFieldType, locale: string): IOperationsHistoryValue;
|
|
507
|
+
/** One line of the change details. */
|
|
508
|
+
interface IOperationsHistoryRow {
|
|
509
|
+
isChanged: boolean;
|
|
510
|
+
isSystem: boolean;
|
|
511
|
+
label: string;
|
|
512
|
+
name: string;
|
|
513
|
+
newValue: IOperationsHistoryValue;
|
|
514
|
+
oldValue: IOperationsHistoryValue;
|
|
515
|
+
}
|
|
421
516
|
export declare class OperationsHistoryModalComponent extends ModalBase {
|
|
422
517
|
private readonly modal;
|
|
423
|
-
|
|
424
|
-
|
|
518
|
+
/**
|
|
519
|
+
* @deprecated Bind `operation` instead, which also carries the whole record. Read only when
|
|
520
|
+
* `operation` is not bound.
|
|
521
|
+
*/
|
|
522
|
+
readonly newValues: InputSignal<object | null | undefined>;
|
|
523
|
+
/**
|
|
524
|
+
* @deprecated Bind `operation` instead, which also carries the whole record. Read only when
|
|
525
|
+
* `operation` is not bound.
|
|
526
|
+
*/
|
|
527
|
+
readonly oldValues: InputSignal<object | null | undefined>;
|
|
528
|
+
/** The operation whose changes the modal shows. */
|
|
529
|
+
readonly operation: InputSignal<IOperationsHistoryList | null | undefined>;
|
|
530
|
+
/** Whether the unchanged fields are listed too, rather than only what the operation changed. */
|
|
531
|
+
protected readonly showAllFields: WritableSignal<boolean>;
|
|
532
|
+
/** Whether the bookkeeping fields are listed, when every field is. */
|
|
533
|
+
protected readonly showSystemFields: WritableSignal<boolean>;
|
|
534
|
+
private readonly fieldLabel;
|
|
535
|
+
private readonly locale;
|
|
425
536
|
/** Delegates to the inner modal; a signal query, so it re-runs once that child resolves. */
|
|
426
537
|
readonly isModalShown: Signal<boolean>;
|
|
538
|
+
/** The operation shown, built from the deprecated inputs when `operation` is not bound. */
|
|
539
|
+
protected readonly currentOperation: Signal<IOperationsHistoryList | null>;
|
|
540
|
+
/** Only a backend that rebuilds the record sends the unchanged fields, so only then can they be listed. */
|
|
541
|
+
protected readonly hasFullRecord: Signal<boolean>;
|
|
542
|
+
protected readonly isAdded: Signal<boolean>;
|
|
543
|
+
protected readonly isDeleted: Signal<boolean>;
|
|
544
|
+
protected readonly operationLabel: Signal<string>;
|
|
545
|
+
/** Data fields: the changed ones, or every one when asked. */
|
|
546
|
+
protected readonly dataRows: Signal<IOperationsHistoryRow[]>;
|
|
547
|
+
/** Bookkeeping fields, listed apart and only when every field is. */
|
|
548
|
+
protected readonly systemRows: Signal<IOperationsHistoryRow[]>;
|
|
549
|
+
private readonly rows;
|
|
550
|
+
protected onShowAllFieldsChanged(event: Event): void;
|
|
551
|
+
protected onSystemFieldsToggled(): void;
|
|
427
552
|
toggle(): void;
|
|
428
553
|
static ɵfac: i0.ɵɵFactoryDeclaration<OperationsHistoryModalComponent, never>;
|
|
429
554
|
static ɵcmp: i0.ɵɵComponentDeclaration<OperationsHistoryModalComponent, "shared-operations-history-modal", never, {
|
|
@@ -437,6 +562,11 @@ export declare class OperationsHistoryModalComponent extends ModalBase {
|
|
|
437
562
|
"required": false;
|
|
438
563
|
"isSignal": true;
|
|
439
564
|
};
|
|
565
|
+
"operation": {
|
|
566
|
+
"alias": "operation";
|
|
567
|
+
"required": false;
|
|
568
|
+
"isSignal": true;
|
|
569
|
+
};
|
|
440
570
|
}, {}, never, never, true, never>;
|
|
441
571
|
}
|
|
442
572
|
export declare class ServicesHistoryChildListComponent extends ChildList<any> implements AfterViewInit, OnInit {
|