@abp/ng.components 8.3.1 → 9.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm2022/extensible/lib/components/extensible-table/extensible-table.component.mjs +16 -9
- package/esm2022/extensible/lib/models/internal/object-extensions.mjs +1 -1
- package/esm2022/extensible/lib/utils/form-props.util.mjs +8 -2
- package/esm2022/extensible/lib/utils/props.util.mjs +35 -1
- package/esm2022/extensible/lib/utils/state.util.mjs +8 -5
- package/extensible/lib/components/extensible-table/extensible-table.component.d.ts +24 -22
- package/extensible/lib/models/internal/object-extensions.d.ts +15 -0
- package/extensible/lib/utils/props.util.d.ts +3 -0
- package/extensible/lib/utils/state.util.d.ts +2 -2
- package/fesm2022/abp-ng.components-extensible.mjs +66 -16
- package/fesm2022/abp-ng.components-extensible.mjs.map +1 -1
- package/package.json +3 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { inject, ChangeDetectorRef, Optional, SkipSelf, Component, ChangeDetectionStrategy, Input, ViewChild, InjectionToken, Injectable, Pipe, Injector, Directive, ViewChildren,
|
|
2
|
+
import { inject, ChangeDetectorRef, Optional, SkipSelf, Component, ChangeDetectionStrategy, Input, ViewChild, InjectionToken, Injectable, Pipe, Injector, Directive, ViewChildren, LOCALE_ID, EventEmitter, Output, NgModule } from '@angular/core';
|
|
3
3
|
import * as i5 from '@angular/common';
|
|
4
4
|
import { CommonModule, NgClass, NgTemplateOutlet, formatDate, AsyncPipe, NgComponentOutlet } from '@angular/common';
|
|
5
5
|
import * as i2 from '@angular/forms';
|
|
@@ -12,8 +12,8 @@ import { DateTimeAdapter, DisabledDirective, DateAdapter, TimeAdapter, EllipsisD
|
|
|
12
12
|
import { LinkedList } from '@abp/utils';
|
|
13
13
|
import * as i2$1 from '@abp/ng.core';
|
|
14
14
|
import { RestService, ConfigStateService, AbpValidators, TrackByService, ShowPasswordDirective, PermissionDirective, LocalizationModule, escapeHtmlChars, PermissionService, getShortDateShortTimeFormat, getShortTimeFormat, getShortDateFormat, LocalizationService, createLocalizationPipeKeyGenerator, CoreModule } from '@abp/ng.core';
|
|
15
|
-
import { of, merge, pipe, zip } from 'rxjs';
|
|
16
|
-
import { map, debounceTime, distinctUntilChanged, switchMap, filter, take } from 'rxjs/operators';
|
|
15
|
+
import { of, map as map$1, filter, merge, pipe, zip } from 'rxjs';
|
|
16
|
+
import { map, debounceTime, distinctUntilChanged, switchMap, filter as filter$1, take } from 'rxjs/operators';
|
|
17
17
|
import * as i1$1 from '@swimlane/ngx-datatable';
|
|
18
18
|
import { NgxDatatableModule } from '@swimlane/ngx-datatable';
|
|
19
19
|
|
|
@@ -916,6 +916,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.5", ngImpor
|
|
|
916
916
|
|
|
917
917
|
const DEFAULT_ACTIONS_COLUMN_WIDTH = 150;
|
|
918
918
|
class ExtensibleTableComponent {
|
|
919
|
+
#injector;
|
|
919
920
|
set actionsText(value) {
|
|
920
921
|
this._actionsText = value;
|
|
921
922
|
}
|
|
@@ -925,16 +926,16 @@ class ExtensibleTableComponent {
|
|
|
925
926
|
set actionsColumnWidth(width) {
|
|
926
927
|
this.setColumnWidths(width ? Number(width) : undefined);
|
|
927
928
|
}
|
|
928
|
-
#injector;
|
|
929
929
|
constructor() {
|
|
930
|
-
this
|
|
931
|
-
this.
|
|
930
|
+
this.#injector = inject(Injector);
|
|
931
|
+
this.getInjected = this.#injector.get.bind(this.#injector);
|
|
932
|
+
this.cdr = inject(ChangeDetectorRef);
|
|
932
933
|
this.locale = inject(LOCALE_ID);
|
|
933
934
|
this.config = inject(ConfigStateService);
|
|
934
935
|
this.entityPropTypeClasses = inject(ENTITY_PROP_TYPE_CLASSES);
|
|
935
|
-
this
|
|
936
|
-
this.
|
|
937
|
-
this.
|
|
936
|
+
this.permissionService = inject(PermissionService);
|
|
937
|
+
this.tableActivate = new EventEmitter();
|
|
938
|
+
this.trackByFn = (_, item) => item.name;
|
|
938
939
|
const extensions = this.#injector.get(ExtensionsService);
|
|
939
940
|
const name = this.#injector.get(EXTENSIONS_IDENTIFIER);
|
|
940
941
|
this.propList = extensions.entityProps.get(name).props;
|
|
@@ -966,7 +967,7 @@ class ExtensibleTableComponent {
|
|
|
966
967
|
return key;
|
|
967
968
|
}
|
|
968
969
|
getContent(prop, data) {
|
|
969
|
-
return prop.valueResolver(data).pipe(map(value => {
|
|
970
|
+
return prop.valueResolver(data).pipe(map$1(value => {
|
|
970
971
|
switch (prop.type) {
|
|
971
972
|
case "boolean" /* ePropType.Boolean */:
|
|
972
973
|
return this.getIcon(value);
|
|
@@ -1031,6 +1032,12 @@ class ExtensibleTableComponent {
|
|
|
1031
1032
|
});
|
|
1032
1033
|
return visibleActions.length > 0;
|
|
1033
1034
|
}
|
|
1035
|
+
ngAfterViewInit() {
|
|
1036
|
+
this.list?.requestStatus$?.pipe(filter(status => status === 'loading')).subscribe(() => {
|
|
1037
|
+
this.data = [];
|
|
1038
|
+
this.cdr.markForCheck();
|
|
1039
|
+
});
|
|
1040
|
+
}
|
|
1034
1041
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.5", ngImport: i0, type: ExtensibleTableComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
1035
1042
|
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.1.5", type: ExtensibleTableComponent, isStandalone: true, selector: "abp-extensible-table", inputs: { actionsText: "actionsText", data: "data", list: "list", recordsTotal: "recordsTotal", actionsColumnWidth: "actionsColumnWidth", actionsTemplate: "actionsTemplate" }, outputs: { tableActivate: "tableActivate" }, exportAs: ["abpExtensibleTable"], usesOnChanges: true, ngImport: i0, template: "<ngx-datatable\r\n default\r\n [rows]=\"data\"\r\n [count]=\"recordsTotal\"\r\n [list]=\"list\"\r\n (activate)=\"tableActivate.emit($event)\"\r\n>\r\n @if (actionsTemplate || (actionList.length && hasAtLeastOnePermittedAction)) {\r\n <ngx-datatable-column\r\n [name]=\"actionsText | abpLocalization\"\r\n [maxWidth]=\"columnWidths[0]\"\r\n [width]=\"columnWidths[0]\"\r\n [sortable]=\"false\"\r\n >\r\n <ng-template let-row=\"row\" let-i=\"rowIndex\" ngx-datatable-cell-template>\r\n <ng-container\r\n *ngTemplateOutlet=\"actionsTemplate || gridActions; context: { $implicit: row, index: i }\"\r\n ></ng-container>\r\n <ng-template #gridActions>\r\n @if (isVisibleActions(row)) {\r\n <abp-grid-actions [index]=\"i\" [record]=\"row\" text=\"AbpUi::Actions\"></abp-grid-actions>\r\n }\r\n </ng-template>\r\n </ng-template>\r\n </ngx-datatable-column>\r\n }\r\n @for (prop of propList; track prop.name; let i = $index) {\r\n <ngx-datatable-column\r\n *abpVisible=\"prop.columnVisible(getInjected)\"\r\n [width]=\"columnWidths[i + 1] || 200\"\r\n [name]=\"prop.displayName | abpLocalization\"\r\n [prop]=\"prop.name\"\r\n [sortable]=\"prop.sortable\"\r\n >\r\n <ng-template ngx-datatable-header-template let-column=\"column\">\r\n @if (prop.tooltip) {\r\n <span\r\n [ngbTooltip]=\"prop.tooltip.text | abpLocalization\"\r\n [placement]=\"prop.tooltip.placement || 'auto'\"\r\n container=\"body\"\r\n >\r\n {{ column.name }} <i class=\"fa fa-info-circle\" aria-hidden=\"true\"></i>\r\n </span>\r\n } @else {\r\n {{ column.name }}\r\n }\r\n </ng-template>\r\n <ng-template let-row=\"row\" let-i=\"index\" ngx-datatable-cell-template>\r\n <ng-container *abpPermission=\"prop.permission; runChangeDetection: false\">\r\n <ng-container *abpVisible=\"row['_' + prop.name]?.visible\">\r\n @if (!row['_' + prop.name].component) {\r\n <div\r\n [innerHTML]=\"\r\n !prop.isExtra\r\n ? (row['_' + prop.name]?.value | async)\r\n : ('::' + (row['_' + prop.name]?.value | async) | abpLocalization)\r\n \"\r\n (click)=\"\r\n prop.action && prop.action({ getInjected: getInjected, record: row, index: i })\r\n \"\r\n [ngClass]=\"entityPropTypeClasses[prop.type]\"\r\n [class.pointer]=\"prop.action\"\r\n ></div>\r\n } @else {\r\n <ng-container\r\n *ngComponentOutlet=\"\r\n row['_' + prop.name].component;\r\n injector: row['_' + prop.name].injector\r\n \"\r\n ></ng-container>\r\n }\r\n </ng-container>\r\n </ng-container>\r\n </ng-template>\r\n </ngx-datatable-column>\r\n }\r\n</ngx-datatable>\r\n", dependencies: [{ kind: "directive", type: AbpVisibleDirective, selector: "[abpVisible]", inputs: ["abpVisible"] }, { kind: "ngmodule", type: NgxDatatableModule }, { kind: "component", type: i1$1.DatatableComponent, selector: "ngx-datatable", inputs: ["targetMarkerTemplate", "rows", "groupRowsBy", "groupedRows", "columns", "selected", "scrollbarV", "scrollbarH", "rowHeight", "columnMode", "headerHeight", "footerHeight", "externalPaging", "externalSorting", "limit", "count", "offset", "loadingIndicator", "selectionType", "reorderable", "swapColumns", "sortType", "sorts", "cssClasses", "messages", "rowClass", "selectCheck", "displayCheck", "groupExpansionDefault", "trackByProp", "selectAllRowsOnPage", "virtualization", "treeFromRelation", "treeToRelation", "summaryRow", "summaryHeight", "summaryPosition", "rowIdentity"], outputs: ["scroll", "activate", "select", "sort", "page", "reorder", "resize", "tableContextmenu", "treeAction"] }, { kind: "directive", type: i1$1.DataTableColumnDirective, selector: "ngx-datatable-column", inputs: ["name", "prop", "frozenLeft", "frozenRight", "flexGrow", "resizeable", "comparator", "pipe", "sortable", "draggable", "canAutoResize", "minWidth", "width", "maxWidth", "checkboxable", "headerCheckboxable", "headerClass", "cellClass", "isTreeColumn", "treeLevelIndent", "summaryFunc", "summaryTemplate", "cellTemplate", "headerTemplate", "treeToggleTemplate"] }, { kind: "directive", type: i1$1.DataTableColumnHeaderDirective, selector: "[ngx-datatable-header-template]" }, { kind: "directive", type: i1$1.DataTableColumnCellDirective, selector: "[ngx-datatable-cell-template]" }, { kind: "component", type: GridActionsComponent, selector: "abp-grid-actions", inputs: ["icon", "index", "text"], exportAs: ["abpGridActions"] }, { kind: "directive", type: NgbTooltip, selector: "[ngbTooltip]", inputs: ["animation", "autoClose", "placement", "popperOptions", "triggers", "positionTarget", "container", "disableTooltip", "tooltipClass", "tooltipContext", "openDelay", "closeDelay", "ngbTooltip"], outputs: ["shown", "hidden"], exportAs: ["ngbTooltip"] }, { kind: "directive", type: NgxDatatableDefaultDirective, selector: "ngx-datatable[default]", inputs: ["class"], exportAs: ["ngxDatatableDefault"] }, { kind: "directive", type: NgxDatatableListDirective, selector: "ngx-datatable[list]", inputs: ["list"], exportAs: ["ngxDatatableList"] }, { kind: "directive", type: PermissionDirective, selector: "[abpPermission]", inputs: ["abpPermission", "abpPermissionRunChangeDetection"] }, { kind: "ngmodule", type: LocalizationModule }, { kind: "pipe", type: i2$1.LocalizationPipe, name: "abpLocalization" }, { kind: "pipe", type: AsyncPipe, name: "async" }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: NgComponentOutlet, selector: "[ngComponentOutlet]", inputs: ["ngComponentOutlet", "ngComponentOutletInputs", "ngComponentOutletInjector", "ngComponentOutletContent", "ngComponentOutletNgModule", "ngComponentOutletNgModuleFactory"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
1036
1043
|
}
|
|
@@ -1130,7 +1137,13 @@ function generateFormFromProps(data) {
|
|
|
1130
1137
|
props.forEach(({ value: prop }) => {
|
|
1131
1138
|
const name = prop.name;
|
|
1132
1139
|
const isExtraProperty = prop.isExtra || name in extraProperties;
|
|
1133
|
-
let value =
|
|
1140
|
+
let value = undefined;
|
|
1141
|
+
if (isExtraProperty) {
|
|
1142
|
+
value = extraProperties[name];
|
|
1143
|
+
}
|
|
1144
|
+
else if (name in record) {
|
|
1145
|
+
value = record[name];
|
|
1146
|
+
}
|
|
1134
1147
|
if (typeof value === 'undefined')
|
|
1135
1148
|
value = prop.defaultValue;
|
|
1136
1149
|
if (value) {
|
|
@@ -1172,6 +1185,40 @@ function mergeWithDefaultProps(extension, defaultProps, ...contributors) {
|
|
|
1172
1185
|
contributors.forEach(contributor => (contributor[name] || []).forEach((callback) => props.addContributor(callback)));
|
|
1173
1186
|
});
|
|
1174
1187
|
}
|
|
1188
|
+
function checkPolicies(properties, configState, permissionService) {
|
|
1189
|
+
const props = Object.entries(properties);
|
|
1190
|
+
const checkPolicy = (policy) => {
|
|
1191
|
+
const { permissions, globalFeatures, features } = policy;
|
|
1192
|
+
const checks = [
|
|
1193
|
+
{
|
|
1194
|
+
items: permissions?.permissionNames,
|
|
1195
|
+
requiresAll: permissions?.requiresAll,
|
|
1196
|
+
check: (item) => permissionService.getGrantedPolicy(item),
|
|
1197
|
+
},
|
|
1198
|
+
{
|
|
1199
|
+
items: globalFeatures?.features,
|
|
1200
|
+
requiresAll: globalFeatures?.requiresAll,
|
|
1201
|
+
check: (item) => configState.getGlobalFeatureIsEnabled(item),
|
|
1202
|
+
},
|
|
1203
|
+
{
|
|
1204
|
+
items: features?.features,
|
|
1205
|
+
requiresAll: features?.requiresAll,
|
|
1206
|
+
check: (item) => configState.getFeatureIsEnabled(item),
|
|
1207
|
+
},
|
|
1208
|
+
];
|
|
1209
|
+
return checks.every(({ items, requiresAll, check }) => {
|
|
1210
|
+
if (!items?.length) {
|
|
1211
|
+
return true;
|
|
1212
|
+
}
|
|
1213
|
+
return requiresAll ? items.every(check) : items.some(check);
|
|
1214
|
+
});
|
|
1215
|
+
};
|
|
1216
|
+
props.forEach(([name, property]) => {
|
|
1217
|
+
if (property.policy && !checkPolicy(property.policy)) {
|
|
1218
|
+
delete properties[name];
|
|
1219
|
+
}
|
|
1220
|
+
});
|
|
1221
|
+
}
|
|
1175
1222
|
|
|
1176
1223
|
function createEnum(members) {
|
|
1177
1224
|
const enumObject = {};
|
|
@@ -1256,9 +1303,9 @@ function getObjectExtensionEntitiesFromStore(configState, moduleKey) {
|
|
|
1256
1303
|
return null;
|
|
1257
1304
|
return (extensions.modules[moduleKey] || {})
|
|
1258
1305
|
.entities;
|
|
1259
|
-
}), map(entities => (isUndefined(entities) ? {} : entities)), filter(Boolean), take(1));
|
|
1306
|
+
}), map(entities => (isUndefined(entities) ? {} : entities)), filter$1(Boolean), take(1));
|
|
1260
1307
|
}
|
|
1261
|
-
function mapEntitiesToContributors(configState, resource) {
|
|
1308
|
+
function mapEntitiesToContributors(configState, permissionService, resource) {
|
|
1262
1309
|
return pipe(switchMap((entities) => zip(selectLocalization(configState), selectEnums(configState)).pipe(map(([localization, enums]) => {
|
|
1263
1310
|
const generateDisplayName = createDisplayNameLocalizationPipeKeyGenerator(localization);
|
|
1264
1311
|
return Object.keys(entities).reduce((acc, key) => {
|
|
@@ -1266,11 +1313,14 @@ function mapEntitiesToContributors(configState, resource) {
|
|
|
1266
1313
|
acc.createForm[key] = [];
|
|
1267
1314
|
acc.editForm[key] = [];
|
|
1268
1315
|
const entity = entities[key];
|
|
1269
|
-
if (!entity)
|
|
1316
|
+
if (!entity) {
|
|
1270
1317
|
return acc;
|
|
1318
|
+
}
|
|
1271
1319
|
const properties = entity.properties;
|
|
1272
|
-
if (!properties)
|
|
1320
|
+
if (!properties) {
|
|
1273
1321
|
return acc;
|
|
1322
|
+
}
|
|
1323
|
+
checkPolicies(properties, configState, permissionService);
|
|
1274
1324
|
const mapPropertiesToContributors = createPropertiesToContributorsMapper(generateDisplayName, resource, enums);
|
|
1275
1325
|
return mapPropertiesToContributors(properties, acc, key);
|
|
1276
1326
|
}, {
|
|
@@ -1424,5 +1474,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.5", ngImpor
|
|
|
1424
1474
|
* Generated bundle index. Do not edit.
|
|
1425
1475
|
*/
|
|
1426
1476
|
|
|
1427
|
-
export { ActionList, CreateFormPropsFactory, CreateInjectorPipe, ENTITY_PROP_TYPE_CLASSES, EXTENSIBLE_FORM_VIEW_PROVIDER, EXTENSIONS_ACTION_CALLBACK, EXTENSIONS_ACTION_DATA, EXTENSIONS_ACTION_TYPE, EXTENSIONS_FORM_PROP, EXTENSIONS_FORM_PROP_DATA, EXTENSIONS_IDENTIFIER, EXTRA_PROPERTIES_KEY, EditFormPropsFactory, EntityAction, EntityActionList, EntityActions, EntityActionsFactory, EntityProp, EntityPropList, EntityProps, EntityPropsFactory, ExtensibleDateTimePickerComponent, ExtensibleFormComponent, ExtensibleFormPropComponent, ExtensibleModule, ExtensibleTableComponent, ExtensionsService, FormProp, FormPropData, FormPropList, FormProps, GridActionsComponent, objectExtensions as ObjectExtensions, PROP_DATA_STREAM, PageToolbarComponent, PropDataDirective, PropList, ToolbarAction, ToolbarActionList, ToolbarActions, ToolbarActionsFactory, ToolbarComponent, createExtraPropertyValueResolver, generateFormFromProps, getObjectExtensionEntitiesFromStore, mapEntitiesToContributors, mergeWithDefaultActions, mergeWithDefaultProps };
|
|
1477
|
+
export { ActionList, CreateFormPropsFactory, CreateInjectorPipe, ENTITY_PROP_TYPE_CLASSES, EXTENSIBLE_FORM_VIEW_PROVIDER, EXTENSIONS_ACTION_CALLBACK, EXTENSIONS_ACTION_DATA, EXTENSIONS_ACTION_TYPE, EXTENSIONS_FORM_PROP, EXTENSIONS_FORM_PROP_DATA, EXTENSIONS_IDENTIFIER, EXTRA_PROPERTIES_KEY, EditFormPropsFactory, EntityAction, EntityActionList, EntityActions, EntityActionsFactory, EntityProp, EntityPropList, EntityProps, EntityPropsFactory, ExtensibleDateTimePickerComponent, ExtensibleFormComponent, ExtensibleFormPropComponent, ExtensibleModule, ExtensibleTableComponent, ExtensionsService, FormProp, FormPropData, FormPropList, FormProps, GridActionsComponent, objectExtensions as ObjectExtensions, PROP_DATA_STREAM, PageToolbarComponent, PropDataDirective, PropList, ToolbarAction, ToolbarActionList, ToolbarActions, ToolbarActionsFactory, ToolbarComponent, checkPolicies, createExtraPropertyValueResolver, generateFormFromProps, getObjectExtensionEntitiesFromStore, mapEntitiesToContributors, mergeWithDefaultActions, mergeWithDefaultProps };
|
|
1428
1478
|
//# sourceMappingURL=abp-ng.components-extensible.mjs.map
|