-
-
+
diff --git a/apps/red-ui/src/app/modules/admin/screens/rule-sets-listing/rule-sets-listing-screen.component.ts b/apps/red-ui/src/app/modules/admin/screens/rule-sets-listing/rule-sets-listing-screen.component.ts
index 105a1afd6..5b227b3d8 100644
--- a/apps/red-ui/src/app/modules/admin/screens/rule-sets-listing/rule-sets-listing-screen.component.ts
+++ b/apps/red-ui/src/app/modules/admin/screens/rule-sets-listing/rule-sets-listing-screen.component.ts
@@ -1,57 +1,43 @@
-import { Component, OnInit } from '@angular/core';
-import { SortingOption, SortingService } from '../../../../services/sorting.service';
+import { Component, Injector, OnInit } from '@angular/core';
import { AppStateService } from '../../../../state/app-state.service';
import { PermissionsService } from '../../../../services/permissions.service';
-import { FormBuilder, FormGroup } from '@angular/forms';
-import { debounce } from '../../../../utils/debounce';
-import { RuleSetModel } from '@redaction/red-ui-http';
import { UserPreferenceService } from '../../../../services/user-preference.service';
import { AdminDialogService } from '../../services/admin-dialog.service';
+import { BaseListingComponent } from '../../../shared/base/base-listing.component';
@Component({
selector: 'redaction-rule-sets-listing-screen',
templateUrl: './rule-sets-listing-screen.component.html',
styleUrls: ['./rule-sets-listing-screen.component.scss']
})
-export class RuleSetsListingScreenComponent implements OnInit {
- public ruleSets: RuleSetModel[];
- public displayedRuleSets: RuleSetModel[];
- public selectedRuleSetIds: string[] = [];
- public searchForm: FormGroup;
+export class RuleSetsListingScreenComponent extends BaseListingComponent implements OnInit {
+ protected readonly _searchKey = 'name';
+ protected readonly _selectionKey = 'ruleSetId';
+ protected readonly _sortKey = 'rule-sets-listing';
constructor(
private readonly _dialogService: AdminDialogService,
- private readonly _sortingService: SortingService,
- private readonly _formBuilder: FormBuilder,
private readonly _appStateService: AppStateService,
public readonly permissionsService: PermissionsService,
- public readonly userPreferenceService: UserPreferenceService
+ public readonly userPreferenceService: UserPreferenceService,
+ protected readonly _injector: Injector
) {
- this.searchForm = this._formBuilder.group({
- query: ['']
- });
-
- this.searchForm.valueChanges.subscribe((value) => this._executeSearch(value));
+ super(_injector);
}
ngOnInit(): void {
this.loadRuleSetsData();
}
- @debounce(200)
- private _executeSearch(value: { query: string }) {
- this.displayedRuleSets = this.ruleSets.filter((pt) => pt.name.toLowerCase().includes(value.query.toLowerCase()));
- }
-
public loadRuleSetsData() {
this._appStateService.reset();
- this.ruleSets = this._appStateService.ruleSets;
- this.displayedRuleSets = [...this.ruleSets];
+ this.allEntities = this._appStateService.ruleSets;
+ this._executeSearch();
this._loadRuleSetStats();
}
private _loadRuleSetStats() {
- this.ruleSets.forEach((rs) => {
+ this.allEntities.forEach((rs) => {
const dictionaries = this._appStateService.dictionaryData[rs.ruleSetId];
if (dictionaries) {
rs.dictionariesCount = Object.keys(dictionaries)
@@ -64,45 +50,7 @@ export class RuleSetsListingScreenComponent implements OnInit {
});
}
- public get sortingOption(): SortingOption {
- return this._sortingService.getSortingOption('rule-sets-listing');
- }
-
- public toggleSort($event) {
- this._sortingService.toggleSort('rule-sets-listing', $event);
- }
-
- toggleTemplateSelected($event: MouseEvent, ruleSet: RuleSetModel) {
- $event.stopPropagation();
- const idx = this.selectedRuleSetIds.indexOf(ruleSet.ruleSetId);
- if (idx === -1) {
- this.selectedRuleSetIds.push(ruleSet.ruleSetId);
- } else {
- this.selectedRuleSetIds.splice(idx, 1);
- }
- }
-
- public toggleSelectAll() {
- if (this.areSomeRuleSetsSelected) {
- this.selectedRuleSetIds = [];
- } else {
- this.selectedRuleSetIds = this.displayedRuleSets.map((rs) => rs.ruleSetId);
- }
- }
-
- public get areAllRuleSetsSelected() {
- return this.displayedRuleSets.length !== 0 && this.selectedRuleSetIds.length === this.displayedRuleSets.length;
- }
-
- public get areSomeRuleSetsSelected() {
- return this.selectedRuleSetIds.length > 0;
- }
-
- public isRuleSetSelected(ruleSet: RuleSetModel) {
- return this.selectedRuleSetIds.indexOf(ruleSet.ruleSetId) !== -1;
- }
-
- openAddRuleSetDialog() {
+ public openAddRuleSetDialog() {
this._dialogService.openAddEditRuleSetDialog(null, async (newRuleSet) => {
if (newRuleSet) {
this.loadRuleSetsData();
diff --git a/apps/red-ui/src/app/modules/projects/screens/project-listing-screen/project-listing-screen.component.html b/apps/red-ui/src/app/modules/projects/screens/project-listing-screen/project-listing-screen.component.html
index 580753ad9..c037ce2a2 100644
--- a/apps/red-ui/src/app/modules/projects/screens/project-listing-screen/project-listing-screen.component.html
+++ b/apps/red-ui/src/app/modules/projects/screens/project-listing-screen/project-listing-screen.component.html
@@ -54,7 +54,7 @@