@abp/ng.feature-management 5.0.0-rc.1 → 5.1.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.
Files changed (43) hide show
  1. package/README.md +3 -3
  2. package/{esm2015/abp-ng.feature-management.js → esm2020/abp-ng.feature-management.mjs} +0 -0
  3. package/esm2020/lib/components/feature-management/feature-management.component.mjs +159 -0
  4. package/{esm2015/lib/components/index.js → esm2020/lib/components/index.mjs} +1 -1
  5. package/esm2020/lib/directives/free-text-input.directive.mjs +36 -0
  6. package/{esm2015/lib/directives/index.js → esm2020/lib/directives/index.mjs} +1 -1
  7. package/{esm2015/lib/enums/components.js → esm2020/lib/enums/components.mjs} +1 -1
  8. package/{esm2015/lib/feature-management.module.js → esm2020/lib/feature-management.module.mjs} +5 -5
  9. package/esm2020/lib/models/feature-management.mjs +2 -0
  10. package/{esm2015/lib/models/index.js → esm2020/lib/models/index.mjs} +1 -1
  11. package/{esm2015/proxy/abp-ng.feature-management-proxy.js → esm2020/proxy/abp-ng.feature-management-proxy.mjs} +0 -0
  12. package/{esm2015/proxy/lib/index.js → esm2020/proxy/lib/index.mjs} +1 -1
  13. package/{esm2015/proxy/lib/proxy/feature-management/features.service.js → esm2020/proxy/lib/proxy/feature-management/features.service.mjs} +4 -4
  14. package/{esm2015/proxy/lib/proxy/feature-management/index.js → esm2020/proxy/lib/proxy/feature-management/index.mjs} +1 -1
  15. package/esm2020/proxy/lib/proxy/feature-management/models.mjs +2 -0
  16. package/{esm2015/proxy/lib/proxy/validation/index.js → esm2020/proxy/lib/proxy/validation/index.mjs} +1 -1
  17. package/{esm2015/proxy/lib/proxy/validation/string-values/index.js → esm2020/proxy/lib/proxy/validation/string-values/index.mjs} +1 -1
  18. package/esm2020/proxy/lib/proxy/validation/string-values/models.mjs +2 -0
  19. package/{esm2015/proxy/public-api.js → esm2020/proxy/public-api.mjs} +1 -1
  20. package/{esm2015/public-api.js → esm2020/public-api.mjs} +1 -1
  21. package/fesm2015/{abp-ng.feature-management-proxy.js → abp-ng.feature-management-proxy.mjs} +5 -5
  22. package/fesm2015/abp-ng.feature-management-proxy.mjs.map +1 -0
  23. package/fesm2015/abp-ng.feature-management.mjs +211 -0
  24. package/fesm2015/abp-ng.feature-management.mjs.map +1 -0
  25. package/fesm2020/abp-ng.feature-management-proxy.mjs +40 -0
  26. package/fesm2020/abp-ng.feature-management-proxy.mjs.map +1 -0
  27. package/fesm2020/abp-ng.feature-management.mjs +215 -0
  28. package/fesm2020/abp-ng.feature-management.mjs.map +1 -0
  29. package/package.json +29 -8
  30. package/proxy/package.json +5 -5
  31. package/proxy/src/lib/proxy/README.md +17 -0
  32. package/bundles/abp-ng.feature-management-proxy.umd.js +0 -70
  33. package/bundles/abp-ng.feature-management-proxy.umd.js.map +0 -1
  34. package/bundles/abp-ng.feature-management.umd.js +0 -585
  35. package/bundles/abp-ng.feature-management.umd.js.map +0 -1
  36. package/esm2015/lib/components/feature-management/feature-management.component.js +0 -158
  37. package/esm2015/lib/directives/free-text-input.directive.js +0 -37
  38. package/esm2015/lib/models/feature-management.js +0 -2
  39. package/esm2015/proxy/lib/proxy/feature-management/models.js +0 -2
  40. package/esm2015/proxy/lib/proxy/validation/string-values/models.js +0 -2
  41. package/fesm2015/abp-ng.feature-management-proxy.js.map +0 -1
  42. package/fesm2015/abp-ng.feature-management.js +0 -215
  43. package/fesm2015/abp-ng.feature-management.js.map +0 -1
@@ -1,215 +0,0 @@
1
- import * as i1 from '@abp/ng.core';
2
- import { CoreModule } from '@abp/ng.core';
3
- import * as i2 from '@abp/ng.feature-management/proxy';
4
- import * as i0 from '@angular/core';
5
- import { Directive, Input, HostBinding, EventEmitter, Component, Output, NgModule } from '@angular/core';
6
- import { finalize } from 'rxjs/operators';
7
- import * as i3 from '@abp/ng.theme.shared';
8
- import { ThemeSharedModule } from '@abp/ng.theme.shared';
9
- import * as i4 from '@ng-bootstrap/ng-bootstrap';
10
- import { NgbNavModule } from '@ng-bootstrap/ng-bootstrap';
11
- import * as i5 from '@angular/common';
12
- import * as i6 from '@angular/forms';
13
-
14
- const INPUT_TYPES = {
15
- numeric: 'number',
16
- default: 'text',
17
- };
18
- class FreeTextInputDirective {
19
- // eslint-disable-next-line @angular-eslint/no-input-rename
20
- set feature(val) {
21
- this._feature = val;
22
- this.setInputType();
23
- }
24
- get feature() {
25
- return this._feature;
26
- }
27
- setInputType() {
28
- var _a, _b, _c, _d;
29
- const validatorType = (_c = (_b = (_a = this.feature) === null || _a === void 0 ? void 0 : _a.valueType) === null || _b === void 0 ? void 0 : _b.validator) === null || _c === void 0 ? void 0 : _c.name.toLowerCase();
30
- this.type = (_d = INPUT_TYPES[validatorType]) !== null && _d !== void 0 ? _d : INPUT_TYPES.default;
31
- }
32
- }
33
- FreeTextInputDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.13", ngImport: i0, type: FreeTextInputDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
34
- FreeTextInputDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.13", type: FreeTextInputDirective, selector: "input[abpFeatureManagementFreeText]", inputs: { feature: ["abpFeatureManagementFreeText", "feature"] }, host: { properties: { "type": "this.type" } }, exportAs: ["inputAbpFeatureManagementFreeText"], ngImport: i0 });
35
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.13", ngImport: i0, type: FreeTextInputDirective, decorators: [{
36
- type: Directive,
37
- args: [{
38
- selector: 'input[abpFeatureManagementFreeText]',
39
- exportAs: 'inputAbpFeatureManagementFreeText',
40
- }]
41
- }], propDecorators: { feature: [{
42
- type: Input,
43
- args: ['abpFeatureManagementFreeText']
44
- }], type: [{
45
- type: HostBinding,
46
- args: ['type']
47
- }] } });
48
-
49
- var ValueTypes;
50
- (function (ValueTypes) {
51
- ValueTypes["ToggleStringValueType"] = "ToggleStringValueType";
52
- ValueTypes["FreeTextStringValueType"] = "FreeTextStringValueType";
53
- ValueTypes["SelectionStringValueType"] = "SelectionStringValueType";
54
- })(ValueTypes || (ValueTypes = {}));
55
- class FeatureManagementComponent {
56
- constructor(track, service, configState) {
57
- this.track = track;
58
- this.service = service;
59
- this.configState = configState;
60
- this.groups = [];
61
- this.valueTypes = ValueTypes;
62
- this.visibleChange = new EventEmitter();
63
- this.modalBusy = false;
64
- }
65
- get visible() {
66
- return this._visible;
67
- }
68
- set visible(value) {
69
- if (this._visible === value)
70
- return;
71
- this._visible = value;
72
- this.visibleChange.emit(value);
73
- if (value)
74
- this.openModal();
75
- }
76
- openModal() {
77
- if (!this.providerName) {
78
- throw new Error('providerName is required.');
79
- }
80
- this.getFeatures();
81
- }
82
- getFeatures() {
83
- this.service.get(this.providerName, this.providerKey).subscribe(res => {
84
- var _a;
85
- if (!((_a = res.groups) === null || _a === void 0 ? void 0 : _a.length))
86
- return;
87
- this.groups = res.groups.map(({ name, displayName }) => ({ name, displayName }));
88
- this.selectedGroupDisplayName = this.groups[0].displayName;
89
- this.features = res.groups.reduce((acc, val) => (Object.assign(Object.assign({}, acc), { [val.name]: mapFeatures(val.features, document.body.dir) })), {});
90
- });
91
- }
92
- save() {
93
- if (this.modalBusy)
94
- return;
95
- const changedFeatures = [];
96
- Object.keys(this.features).forEach(key => {
97
- this.features[key].forEach(feature => {
98
- if (feature.value !== feature.initialValue)
99
- changedFeatures.push({ name: feature.name, value: `${feature.value}` });
100
- });
101
- });
102
- if (!changedFeatures.length) {
103
- this.visible = false;
104
- return;
105
- }
106
- this.modalBusy = true;
107
- this.service
108
- .update(this.providerName, this.providerKey, { features: changedFeatures })
109
- .pipe(finalize(() => (this.modalBusy = false)))
110
- .subscribe(() => {
111
- this.visible = false;
112
- if (!this.providerKey) {
113
- // to refresh host's features
114
- this.configState.refreshAppState().subscribe();
115
- }
116
- });
117
- }
118
- onCheckboxClick(val, feature) {
119
- if (val) {
120
- this.checkToggleAncestors(feature);
121
- }
122
- else {
123
- this.uncheckToggleDescendants(feature);
124
- }
125
- }
126
- uncheckToggleDescendants(feature) {
127
- this.findAllDescendantsOfByType(feature, ValueTypes.ToggleStringValueType).forEach(node => this.setFeatureValue(node, false));
128
- }
129
- checkToggleAncestors(feature) {
130
- this.findAllAncestorsOfByType(feature, ValueTypes.ToggleStringValueType).forEach(node => this.setFeatureValue(node, true));
131
- }
132
- findAllAncestorsOfByType(feature, type) {
133
- let parent = this.findParentByType(feature, type);
134
- const ancestors = [];
135
- while (parent) {
136
- ancestors.push(parent);
137
- parent = this.findParentByType(parent, type);
138
- }
139
- return ancestors;
140
- }
141
- findAllDescendantsOfByType(feature, type) {
142
- const descendants = [];
143
- const queue = [feature];
144
- while (queue.length) {
145
- const node = queue.pop();
146
- const newDescendants = this.findChildrenByType(node, type);
147
- descendants.push(...newDescendants);
148
- queue.push(...newDescendants);
149
- }
150
- return descendants;
151
- }
152
- findParentByType(feature, type) {
153
- return this.getCurrentGroup().find(f => f.valueType.name === type && f.name === feature.parentName);
154
- }
155
- findChildrenByType(feature, type) {
156
- return this.getCurrentGroup().filter(f => f.valueType.name === type && f.parentName === feature.name);
157
- }
158
- getCurrentGroup() {
159
- var _a;
160
- return (_a = this.features[this.selectedGroupDisplayName]) !== null && _a !== void 0 ? _a : [];
161
- }
162
- setFeatureValue(feature, val) {
163
- feature.value = val;
164
- }
165
- }
166
- FeatureManagementComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.13", ngImport: i0, type: FeatureManagementComponent, deps: [{ token: i1.TrackByService }, { token: i2.FeaturesService }, { token: i1.ConfigStateService }], target: i0.ɵɵFactoryTarget.Component });
167
- FeatureManagementComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.13", type: FeatureManagementComponent, selector: "abp-feature-management", inputs: { providerKey: "providerKey", providerName: "providerName", visible: "visible" }, outputs: { visibleChange: "visibleChange" }, exportAs: ["abpFeatureManagement"], ngImport: i0, template: "<abp-modal *ngIf=\"visible\" [(visible)]=\"visible\" [busy]=\"modalBusy\" [options]=\"{ size: 'lg' }\">\n <ng-template #abpHeader>\n <h3>{{ 'AbpFeatureManagement::Features' | abpLocalization }}</h3>\n </ng-template>\n\n <ng-template #abpBody>\n <div class=\"row\">\n <div class=\"col-md-4\">\n <ul\n ngbNav\n #nav=\"ngbNav\"\n [(activeId)]=\"selectedGroupDisplayName\"\n class=\"nav-pills\"\n orientation=\"vertical\"\n >\n <li\n *ngFor=\"let group of groups; trackBy: track.by('name')\"\n [ngbNavItem]=\"group.displayName\"\n >\n <a ngbNavLink>{{ group.displayName }}</a>\n <ng-template ngbNavContent>\n <h4>{{ selectedGroupDisplayName }}</h4>\n <hr class=\"mt-2 mb-3\" />\n\n <div\n class=\"mt-2\"\n *ngFor=\"let feature of features[group.name]; let i = index; trackBy: track.by('id')\"\n [ngStyle]=\"feature.style\"\n [ngSwitch]=\"feature.valueType?.name\"\n (keyup.enter)=\"save()\"\n >\n <ng-container *ngSwitchCase=\"valueTypes.ToggleStringValueType\">\n <div class=\"form-check\">\n <input\n class=\"form-check-input\"\n type=\"checkbox\"\n [id]=\"feature.name\"\n [(ngModel)]=\"feature.value\"\n (ngModelChange)=\"onCheckboxClick($event, feature)\"\n />\n\n <label class=\"form-check-label\" [htmlFor]=\"feature.name\">{{\n feature.displayName\n }}</label>\n <ng-container\n *ngTemplateOutlet=\"descTmp; context: { $implicit: feature.description }\"\n ></ng-container>\n </div>\n </ng-container>\n <ng-container *ngSwitchCase=\"valueTypes.FreeTextStringValueType\">\n <div class=\"mb-3 form-group\">\n <label [htmlFor]=\"feature.name\" class=\"form-label\">{{\n feature.displayName\n }}</label>\n <input\n class=\"form-control\"\n type=\"text\"\n [id]=\"feature.name\"\n [(ngModel)]=\"feature.value\"\n [abpFeatureManagementFreeText]=\"feature\"\n />\n\n <ng-container\n *ngTemplateOutlet=\"descTmp; context: { $implicit: feature.description }\"\n ></ng-container>\n </div>\n </ng-container>\n <ng-container *ngSwitchCase=\"valueTypes.SelectionStringValueType\">\n <ng-container *ngIf=\"feature.valueType.itemSource?.items?.length\">\n <div class=\"mb-3 form-group\">\n <label [htmlFor]=\"feature.name\" class=\"form-label\">{{\n feature.displayName\n }}</label>\n <select class=\"form-select\" [id]=\"feature.name\" [(ngModel)]=\"feature.value\">\n <option\n *ngFor=\"\n let item of feature.valueType.itemSource?.items;\n trackBy: track.by('value')\n \"\n [ngValue]=\"item.value\"\n >\n {{\n item.displayText?.resourceName + '::' + item.displayText?.name\n | abpLocalization\n }}\n </option>\n </select>\n <ng-container\n *ngTemplateOutlet=\"descTmp; context: { $implicit: feature.description }\"\n ></ng-container>\n </div>\n </ng-container>\n </ng-container>\n <ng-container *ngSwitchDefault>{{ feature.displayName }}</ng-container>\n </div>\n </ng-template>\n </li>\n </ul>\n </div>\n\n <ng-template #descTmp let-description>\n <small *ngIf=\"description\" class=\"d-block form-text text-muted\">{{ description }}</small>\n </ng-template>\n\n <div class=\"col-md-8\"><div [ngbNavOutlet]=\"nav\"></div></div>\n\n <div class=\"mx-3\" *ngIf=\"!groups.length\">\n {{ 'AbpFeatureManagement::NoFeatureFoundMessage' | abpLocalization }}\n </div>\n </div>\n </ng-template>\n\n <ng-template #abpFooter>\n <button abpClose type=\"button\" class=\"btn btn-secondary\">\n {{ 'AbpFeatureManagement::Cancel' | abpLocalization }}\n </button>\n <abp-button\n *ngIf=\"groups.length\"\n iconClass=\"fa fa-check\"\n [disabled]=\"modalBusy\"\n (click)=\"save()\"\n >\n {{ 'AbpFeatureManagement::Save' | abpLocalization }}\n </abp-button>\n </ng-template>\n</abp-modal>\n", components: [{ type: i3.ModalComponent, selector: "abp-modal", inputs: ["visible", "busy", "options", "suppressUnsavedChangesWarning"], outputs: ["visibleChange", "init", "appear", "disappear"] }, { type: i4.NgbNavOutlet, selector: "[ngbNavOutlet]", inputs: ["paneRole", "ngbNavOutlet"] }, { type: i3.ButtonComponent, selector: "abp-button", inputs: ["buttonId", "buttonClass", "buttonType", "iconClass", "loading", "disabled", "attributes"], outputs: ["click", "focus", "blur", "abpClick", "abpFocus", "abpBlur"] }], directives: [{ type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i4.NgbNav, selector: "[ngbNav]", inputs: ["animation", "destroyOnHide", "orientation", "roles", "keyboard", "activeId"], outputs: ["activeIdChange", "shown", "hidden", "navChange"], exportAs: ["ngbNav"] }, { type: i5.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i4.NgbNavItem, selector: "[ngbNavItem]", inputs: ["disabled", "domId", "destroyOnHide", "ngbNavItem"], outputs: ["shown", "hidden"], exportAs: ["ngbNavItem"] }, { type: i4.NgbNavLink, selector: "a[ngbNavLink]" }, { type: i4.NgbNavContent, selector: "ng-template[ngbNavContent]" }, { type: i5.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { type: i5.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { type: i5.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { type: i6.CheckboxControlValueAccessor, selector: "input[type=checkbox][formControlName],input[type=checkbox][formControl],input[type=checkbox][ngModel]" }, { type: i6.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i6.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { type: i5.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }, { type: i6.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: FreeTextInputDirective, selector: "input[abpFeatureManagementFreeText]", inputs: ["abpFeatureManagementFreeText"], exportAs: ["inputAbpFeatureManagementFreeText"] }, { type: i6.SelectControlValueAccessor, selector: "select:not([multiple])[formControlName],select:not([multiple])[formControl],select:not([multiple])[ngModel]", inputs: ["compareWith"] }, { type: i6.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { type: i6.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }, { type: i5.NgSwitchDefault, selector: "[ngSwitchDefault]" }, { type: i3.ModalCloseDirective, selector: "[abpClose]" }], pipes: { "abpLocalization": i1.LocalizationPipe } });
168
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.13", ngImport: i0, type: FeatureManagementComponent, decorators: [{
169
- type: Component,
170
- args: [{
171
- selector: 'abp-feature-management',
172
- templateUrl: './feature-management.component.html',
173
- exportAs: 'abpFeatureManagement',
174
- }]
175
- }], ctorParameters: function () { return [{ type: i1.TrackByService }, { type: i2.FeaturesService }, { type: i1.ConfigStateService }]; }, propDecorators: { providerKey: [{
176
- type: Input
177
- }], providerName: [{
178
- type: Input
179
- }], visible: [{
180
- type: Input
181
- }], visibleChange: [{
182
- type: Output
183
- }] } });
184
- function mapFeatures(features, dir) {
185
- const margin = `margin-${dir === 'rtl' ? 'right' : 'left'}.px`;
186
- return features.map(feature => {
187
- var _a;
188
- const value = ((_a = feature.valueType) === null || _a === void 0 ? void 0 : _a.name) === ValueTypes.ToggleStringValueType
189
- ? (feature.value || '').toLowerCase() === 'true'
190
- : feature.value;
191
- return Object.assign(Object.assign({}, feature), { value, initialValue: value, style: { [margin]: feature.depth * 20 } });
192
- });
193
- }
194
-
195
- const exported = [FeatureManagementComponent, FreeTextInputDirective];
196
- class FeatureManagementModule {
197
- }
198
- FeatureManagementModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.13", ngImport: i0, type: FeatureManagementModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
199
- FeatureManagementModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.13", ngImport: i0, type: FeatureManagementModule, declarations: [FeatureManagementComponent, FreeTextInputDirective], imports: [CoreModule, ThemeSharedModule, NgbNavModule], exports: [FeatureManagementComponent, FreeTextInputDirective] });
200
- FeatureManagementModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.13", ngImport: i0, type: FeatureManagementModule, imports: [[CoreModule, ThemeSharedModule, NgbNavModule]] });
201
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.13", ngImport: i0, type: FeatureManagementModule, decorators: [{
202
- type: NgModule,
203
- args: [{
204
- declarations: [...exported],
205
- imports: [CoreModule, ThemeSharedModule, NgbNavModule],
206
- exports: [...exported],
207
- }]
208
- }] });
209
-
210
- /**
211
- * Generated bundle index. Do not edit.
212
- */
213
-
214
- export { FeatureManagementComponent, FeatureManagementModule, FreeTextInputDirective, INPUT_TYPES };
215
- //# sourceMappingURL=abp-ng.feature-management.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"abp-ng.feature-management.js","sources":["../../../../packages/feature-management/src/lib/directives/free-text-input.directive.ts","../../../../packages/feature-management/src/lib/components/feature-management/feature-management.component.ts","../../../../packages/feature-management/src/lib/components/feature-management/feature-management.component.html","../../../../packages/feature-management/src/lib/feature-management.module.ts","../../../../packages/feature-management/src/abp-ng.feature-management.ts"],"sourcesContent":["import { Directive, HostBinding, Input } from '@angular/core';\n\n// TODO: improve this type\nexport interface FreeTextType {\n valueType: {\n validator: {\n name: string;\n };\n };\n}\n\nexport const INPUT_TYPES = {\n numeric: 'number',\n default: 'text',\n};\n\n@Directive({\n selector: 'input[abpFeatureManagementFreeText]',\n exportAs: 'inputAbpFeatureManagementFreeText',\n})\nexport class FreeTextInputDirective {\n _feature: FreeTextType;\n // eslint-disable-next-line @angular-eslint/no-input-rename\n @Input('abpFeatureManagementFreeText') set feature(val: FreeTextType) {\n this._feature = val;\n this.setInputType();\n }\n\n get feature() {\n return this._feature;\n }\n\n @HostBinding('type') type: string;\n\n private setInputType() {\n const validatorType = this.feature?.valueType?.validator?.name.toLowerCase();\n this.type = INPUT_TYPES[validatorType] ?? INPUT_TYPES.default;\n }\n}\n","import { ConfigStateService, TrackByService } from '@abp/ng.core';\nimport {\n FeatureDto,\n FeatureGroupDto,\n FeaturesService,\n UpdateFeatureDto,\n} from '@abp/ng.feature-management/proxy';\nimport { LocaleDirection } from '@abp/ng.theme.shared';\nimport { Component, EventEmitter, Input, Output } from '@angular/core';\nimport { finalize } from 'rxjs/operators';\nimport { FeatureManagement } from '../../models/feature-management';\n\nenum ValueTypes {\n ToggleStringValueType = 'ToggleStringValueType',\n FreeTextStringValueType = 'FreeTextStringValueType',\n SelectionStringValueType = 'SelectionStringValueType',\n}\n\n@Component({\n selector: 'abp-feature-management',\n templateUrl: './feature-management.component.html',\n exportAs: 'abpFeatureManagement',\n})\nexport class FeatureManagementComponent\n implements\n FeatureManagement.FeatureManagementComponentInputs,\n FeatureManagement.FeatureManagementComponentOutputs\n{\n @Input()\n providerKey: string;\n\n @Input()\n providerName: string;\n\n selectedGroupDisplayName: string;\n\n groups: Pick<FeatureGroupDto, 'name' | 'displayName'>[] = [];\n\n features: {\n [group: string]: Array<FeatureDto & { style?: { [key: string]: number }; initialValue: any }>;\n };\n\n valueTypes = ValueTypes;\n\n protected _visible;\n\n @Input()\n get visible(): boolean {\n return this._visible;\n }\n\n set visible(value: boolean) {\n if (this._visible === value) return;\n\n this._visible = value;\n this.visibleChange.emit(value);\n if (value) this.openModal();\n }\n\n @Output() readonly visibleChange = new EventEmitter<boolean>();\n\n modalBusy = false;\n\n constructor(\n public readonly track: TrackByService,\n protected service: FeaturesService,\n protected configState: ConfigStateService,\n ) {}\n\n openModal() {\n if (!this.providerName) {\n throw new Error('providerName is required.');\n }\n\n this.getFeatures();\n }\n\n getFeatures() {\n this.service.get(this.providerName, this.providerKey).subscribe(res => {\n if (!res.groups?.length) return;\n this.groups = res.groups.map(({ name, displayName }) => ({ name, displayName }));\n this.selectedGroupDisplayName = this.groups[0].displayName;\n this.features = res.groups.reduce(\n (acc, val) => ({\n ...acc,\n [val.name]: mapFeatures(val.features, document.body.dir as LocaleDirection),\n }),\n {},\n );\n });\n }\n\n save() {\n if (this.modalBusy) return;\n\n const changedFeatures = [] as UpdateFeatureDto[];\n\n Object.keys(this.features).forEach(key => {\n this.features[key].forEach(feature => {\n if (feature.value !== feature.initialValue)\n changedFeatures.push({ name: feature.name, value: `${feature.value}` });\n });\n });\n\n if (!changedFeatures.length) {\n this.visible = false;\n return;\n }\n\n this.modalBusy = true;\n this.service\n .update(this.providerName, this.providerKey, { features: changedFeatures })\n .pipe(finalize(() => (this.modalBusy = false)))\n .subscribe(() => {\n this.visible = false;\n\n if (!this.providerKey) {\n // to refresh host's features\n this.configState.refreshAppState().subscribe();\n }\n });\n }\n\n onCheckboxClick(val: boolean, feature: FeatureDto) {\n if (val) {\n this.checkToggleAncestors(feature);\n } else {\n this.uncheckToggleDescendants(feature);\n }\n }\n\n private uncheckToggleDescendants(feature: FeatureDto) {\n this.findAllDescendantsOfByType(feature, ValueTypes.ToggleStringValueType).forEach(node =>\n this.setFeatureValue(node, false),\n );\n }\n\n private checkToggleAncestors(feature: FeatureDto) {\n this.findAllAncestorsOfByType(feature, ValueTypes.ToggleStringValueType).forEach(node =>\n this.setFeatureValue(node, true),\n );\n }\n\n private findAllAncestorsOfByType(feature: FeatureDto, type: ValueTypes) {\n let parent = this.findParentByType(feature, type);\n const ancestors = [];\n while (parent) {\n ancestors.push(parent);\n parent = this.findParentByType(parent, type);\n }\n return ancestors;\n }\n\n private findAllDescendantsOfByType(feature: FeatureDto, type: ValueTypes) {\n const descendants = [];\n const queue = [feature];\n\n while (queue.length) {\n const node = queue.pop();\n const newDescendants = this.findChildrenByType(node, type);\n descendants.push(...newDescendants);\n queue.push(...newDescendants);\n }\n\n return descendants;\n }\n\n private findParentByType(feature: FeatureDto, type: ValueTypes) {\n return this.getCurrentGroup().find(\n f => f.valueType.name === type && f.name === feature.parentName,\n );\n }\n\n private findChildrenByType(feature: FeatureDto, type: ValueTypes) {\n return this.getCurrentGroup().filter(\n f => f.valueType.name === type && f.parentName === feature.name,\n );\n }\n\n private getCurrentGroup() {\n return this.features[this.selectedGroupDisplayName] ?? [];\n }\n\n private setFeatureValue(feature: FeatureDto, val: boolean) {\n feature.value = val as any;\n }\n}\n\nfunction mapFeatures(features: FeatureDto[], dir: LocaleDirection) {\n const margin = `margin-${dir === 'rtl' ? 'right' : 'left'}.px`;\n\n return features.map(feature => {\n const value =\n feature.valueType?.name === ValueTypes.ToggleStringValueType\n ? (feature.value || '').toLowerCase() === 'true'\n : feature.value;\n\n return {\n ...feature,\n value,\n initialValue: value,\n style: { [margin]: feature.depth * 20 },\n };\n });\n}\n","<abp-modal *ngIf=\"visible\" [(visible)]=\"visible\" [busy]=\"modalBusy\" [options]=\"{ size: 'lg' }\">\n <ng-template #abpHeader>\n <h3>{{ 'AbpFeatureManagement::Features' | abpLocalization }}</h3>\n </ng-template>\n\n <ng-template #abpBody>\n <div class=\"row\">\n <div class=\"col-md-4\">\n <ul\n ngbNav\n #nav=\"ngbNav\"\n [(activeId)]=\"selectedGroupDisplayName\"\n class=\"nav-pills\"\n orientation=\"vertical\"\n >\n <li\n *ngFor=\"let group of groups; trackBy: track.by('name')\"\n [ngbNavItem]=\"group.displayName\"\n >\n <a ngbNavLink>{{ group.displayName }}</a>\n <ng-template ngbNavContent>\n <h4>{{ selectedGroupDisplayName }}</h4>\n <hr class=\"mt-2 mb-3\" />\n\n <div\n class=\"mt-2\"\n *ngFor=\"let feature of features[group.name]; let i = index; trackBy: track.by('id')\"\n [ngStyle]=\"feature.style\"\n [ngSwitch]=\"feature.valueType?.name\"\n (keyup.enter)=\"save()\"\n >\n <ng-container *ngSwitchCase=\"valueTypes.ToggleStringValueType\">\n <div class=\"form-check\">\n <input\n class=\"form-check-input\"\n type=\"checkbox\"\n [id]=\"feature.name\"\n [(ngModel)]=\"feature.value\"\n (ngModelChange)=\"onCheckboxClick($event, feature)\"\n />\n\n <label class=\"form-check-label\" [htmlFor]=\"feature.name\">{{\n feature.displayName\n }}</label>\n <ng-container\n *ngTemplateOutlet=\"descTmp; context: { $implicit: feature.description }\"\n ></ng-container>\n </div>\n </ng-container>\n <ng-container *ngSwitchCase=\"valueTypes.FreeTextStringValueType\">\n <div class=\"mb-3 form-group\">\n <label [htmlFor]=\"feature.name\" class=\"form-label\">{{\n feature.displayName\n }}</label>\n <input\n class=\"form-control\"\n type=\"text\"\n [id]=\"feature.name\"\n [(ngModel)]=\"feature.value\"\n [abpFeatureManagementFreeText]=\"feature\"\n />\n\n <ng-container\n *ngTemplateOutlet=\"descTmp; context: { $implicit: feature.description }\"\n ></ng-container>\n </div>\n </ng-container>\n <ng-container *ngSwitchCase=\"valueTypes.SelectionStringValueType\">\n <ng-container *ngIf=\"feature.valueType.itemSource?.items?.length\">\n <div class=\"mb-3 form-group\">\n <label [htmlFor]=\"feature.name\" class=\"form-label\">{{\n feature.displayName\n }}</label>\n <select class=\"form-select\" [id]=\"feature.name\" [(ngModel)]=\"feature.value\">\n <option\n *ngFor=\"\n let item of feature.valueType.itemSource?.items;\n trackBy: track.by('value')\n \"\n [ngValue]=\"item.value\"\n >\n {{\n item.displayText?.resourceName + '::' + item.displayText?.name\n | abpLocalization\n }}\n </option>\n </select>\n <ng-container\n *ngTemplateOutlet=\"descTmp; context: { $implicit: feature.description }\"\n ></ng-container>\n </div>\n </ng-container>\n </ng-container>\n <ng-container *ngSwitchDefault>{{ feature.displayName }}</ng-container>\n </div>\n </ng-template>\n </li>\n </ul>\n </div>\n\n <ng-template #descTmp let-description>\n <small *ngIf=\"description\" class=\"d-block form-text text-muted\">{{ description }}</small>\n </ng-template>\n\n <div class=\"col-md-8\"><div [ngbNavOutlet]=\"nav\"></div></div>\n\n <div class=\"mx-3\" *ngIf=\"!groups.length\">\n {{ 'AbpFeatureManagement::NoFeatureFoundMessage' | abpLocalization }}\n </div>\n </div>\n </ng-template>\n\n <ng-template #abpFooter>\n <button abpClose type=\"button\" class=\"btn btn-secondary\">\n {{ 'AbpFeatureManagement::Cancel' | abpLocalization }}\n </button>\n <abp-button\n *ngIf=\"groups.length\"\n iconClass=\"fa fa-check\"\n [disabled]=\"modalBusy\"\n (click)=\"save()\"\n >\n {{ 'AbpFeatureManagement::Save' | abpLocalization }}\n </abp-button>\n </ng-template>\n</abp-modal>\n","import { CoreModule } from '@abp/ng.core';\nimport { ThemeSharedModule } from '@abp/ng.theme.shared';\nimport { NgModule } from '@angular/core';\nimport { NgbNavModule } from '@ng-bootstrap/ng-bootstrap';\nimport { FeatureManagementComponent } from './components/feature-management/feature-management.component';\nimport { FreeTextInputDirective } from './directives/free-text-input.directive';\n\nconst exported = [FeatureManagementComponent, FreeTextInputDirective];\n\n@NgModule({\n declarations: [...exported],\n imports: [CoreModule, ThemeSharedModule, NgbNavModule],\n exports: [...exported],\n})\nexport class FeatureManagementModule {}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;;;;;MAWa,WAAW,GAAG;IACzB,OAAO,EAAE,QAAQ;IACjB,OAAO,EAAE,MAAM;EACf;MAMW,sBAAsB;;IAGjC,IAA2C,OAAO,CAAC,GAAiB;QAClE,IAAI,CAAC,QAAQ,GAAG,GAAG,CAAC;QACpB,IAAI,CAAC,YAAY,EAAE,CAAC;KACrB;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC;KACtB;IAIO,YAAY;;QAClB,MAAM,aAAa,GAAG,MAAA,MAAA,MAAA,IAAI,CAAC,OAAO,0CAAE,SAAS,0CAAE,SAAS,0CAAE,IAAI,CAAC,WAAW,EAAE,CAAC;QAC7E,IAAI,CAAC,IAAI,GAAG,MAAA,WAAW,CAAC,aAAa,CAAC,mCAAI,WAAW,CAAC,OAAO,CAAC;KAC/D;;oHAjBU,sBAAsB;wGAAtB,sBAAsB;4FAAtB,sBAAsB;kBAJlC,SAAS;mBAAC;oBACT,QAAQ,EAAE,qCAAqC;o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