diff --git a/apps/red-ui/src/app/app.module.ts b/apps/red-ui/src/app/app.module.ts index b46078f62..b3f4625ce 100644 --- a/apps/red-ui/src/app/app.module.ts +++ b/apps/red-ui/src/app/app.module.ts @@ -98,10 +98,10 @@ import { HtmlDebugScreenComponent } from './screens/html-debug-screen/html-debug import { ReportDownloadBtnComponent } from './components/buttons/report-download-btn/report-download-btn.component'; import { ProjectListingActionsComponent } from './screens/project-listing-screen/project-listing-actions/project-listing-actions.component'; import { HasScrollbarDirective } from './utils/has-scrollbar.directive'; -import { ProjectTemplatesListingScreenComponent } from './screens/admin/project-templates-listing-screen/project-templates-listing-screen.component'; -import { AddEditProjectTemplateDialogComponent } from './screens/admin/project-templates-listing-screen/add-edit-project-template-dialog/add-edit-project-template-dialog.component'; -import { ProjectTemplateActionsComponent } from './components/project-template-actions/project-template-actions.component'; -import { ProjectTemplateViewSwitchComponent } from './components/project-template-view-switch/project-template-view-switch.component'; +import { RuleSetsListingScreenComponent } from './screens/admin/rule-sets-listing-screen/rule-sets-listing-screen.component'; +import { AddEditRuleSetDialogComponent } from './screens/admin/rule-sets-listing-screen/add-edit-rule-set-dialog/add-edit-rule-set-dialog.component'; +import { RuleSetActionsComponent } from './components/rule-set-actions/rule-set-actions.component'; +import { RuleSetViewSwitchComponent } from './components/rule-set-view-switch/rule-set-view-switch.component'; import { MatSliderModule } from '@angular/material/slider'; import { PendingChangesGuard } from './utils/can-deactivate.guard'; @@ -178,14 +178,14 @@ const routes = [ children: [ { path: '', - component: ProjectTemplatesListingScreenComponent, + component: RuleSetsListingScreenComponent, canActivate: [CompositeRouteGuard], data: { routeGuards: [AuthGuard, RedRoleGuard, AppStateGuard] } }, { - path: ':templateId', + path: ':ruleSetId', children: [ { path: 'dictionaries', @@ -313,8 +313,8 @@ const matImports = [ CircleButtonComponent, ChevronButtonComponent, DictionaryListingScreenComponent, - ProjectTemplatesListingScreenComponent, - AddEditProjectTemplateDialogComponent, + RuleSetsListingScreenComponent, + AddEditRuleSetDialogComponent, SyncWidthDirective, HasScrollbarDirective, AddEditDictionaryDialogComponent, @@ -329,8 +329,8 @@ const matImports = [ HtmlDebugScreenComponent, ReportDownloadBtnComponent, ProjectListingActionsComponent, - ProjectTemplateActionsComponent, - ProjectTemplateViewSwitchComponent + RuleSetActionsComponent, + RuleSetViewSwitchComponent ], imports: [ BrowserModule, diff --git a/apps/red-ui/src/app/components/admin-page-header/admin-breadcrumbs.component.html b/apps/red-ui/src/app/components/admin-page-header/admin-breadcrumbs.component.html index 5549ff5ea..33266b062 100644 --- a/apps/red-ui/src/app/components/admin-page-header/admin-breadcrumbs.component.html +++ b/apps/red-ui/src/app/components/admin-page-header/admin-breadcrumbs.component.html @@ -5,7 +5,7 @@ [routerLinkActiveOptions]="{ exact: true }" routerLinkActive="active" translate="project-templates" - *ngIf="root || !!projectTemplate" + *ngIf="root || !!ruleSet" > - + - - {{ projectTemplate.name }} + + {{ ruleSet.name }} @@ -37,7 +37,7 @@ {{ dictionary.label }} diff --git a/apps/red-ui/src/app/components/admin-page-header/admin-breadcrumbs.component.ts b/apps/red-ui/src/app/components/admin-page-header/admin-breadcrumbs.component.ts index b4931d79d..d7b4e412c 100644 --- a/apps/red-ui/src/app/components/admin-page-header/admin-breadcrumbs.component.ts +++ b/apps/red-ui/src/app/components/admin-page-header/admin-breadcrumbs.component.ts @@ -1,7 +1,7 @@ import { Component, Input, OnInit } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; -import { TypeValue } from '@redaction/red-ui-http'; -import { AppStateService, ProjectTemplate } from '../../state/app-state.service'; +import { RuleSetModel, TypeValue } from '@redaction/red-ui-http'; +import { AppStateService } from '../../state/app-state.service'; import { UserPreferenceService } from '../../common/service/user-preference.service'; import { PermissionsService } from '../../common/service/permissions.service'; @@ -12,7 +12,7 @@ import { PermissionsService } from '../../common/service/permissions.service'; }) export class AdminBreadcrumbsComponent implements OnInit { public dictionary: TypeValue; - public projectTemplate: ProjectTemplate; + public ruleSet: RuleSetModel; @Input() public root = false; @@ -25,8 +25,8 @@ export class AdminBreadcrumbsComponent implements OnInit { ngOnInit(): void { this._activatedRoute.params.subscribe((params) => { - if (params.templateId) { - this.projectTemplate = this._appStateService.getProjectTemplateById(params.templateId); + if (params.ruleSetId) { + this.ruleSet = this._appStateService.getRuleSetById(params.ruleSetId); } if (params.type) { this.dictionary = this._appStateService.getDictionaryTypeValue(params.type); diff --git a/apps/red-ui/src/app/components/project-template-actions/project-template-actions.component.ts b/apps/red-ui/src/app/components/project-template-actions/project-template-actions.component.ts deleted file mode 100644 index 7316bdd35..000000000 --- a/apps/red-ui/src/app/components/project-template-actions/project-template-actions.component.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; -import { ProjectTemplate } from '../../state/app-state.service'; -import { DialogService } from '../../dialogs/dialog.service'; -import { PermissionsService } from '../../common/service/permissions.service'; - -@Component({ - selector: 'redaction-project-template-actions', - templateUrl: './project-template-actions.component.html', - styleUrls: ['./project-template-actions.component.scss'] -}) -export class ProjectTemplateActionsComponent implements OnInit { - @Input() template: ProjectTemplate; - @Output() loadTemplatesData = new EventEmitter(); - - constructor(private readonly _dialogService: DialogService, public readonly permissionsService: PermissionsService) {} - - ngOnInit(): void {} - - openAddEditTemplateDialog(template?: ProjectTemplate) { - this._dialogService.openAddEditTemplateDialog(template, async (newTemplate) => { - if (newTemplate) { - this.loadTemplatesData.emit(); - } - }); - } - - openEditTemplateDialog($event: any, pt: ProjectTemplate) { - $event.stopPropagation(); - this.openAddEditTemplateDialog(pt); - } - - openDeleteTemplateDialog($event: any, template: ProjectTemplate) { - this._dialogService.openDeleteProjectTemplateDialog($event, template, async () => { - this.loadTemplatesData.emit(); - }); - } -} diff --git a/apps/red-ui/src/app/components/project-template-actions/project-template-actions.component.html b/apps/red-ui/src/app/components/rule-set-actions/rule-set-actions.component.html similarity index 79% rename from apps/red-ui/src/app/components/project-template-actions/project-template-actions.component.html rename to apps/red-ui/src/app/components/rule-set-actions/rule-set-actions.component.html index 9b0edb1f4..04d19f2f8 100644 --- a/apps/red-ui/src/app/components/project-template-actions/project-template-actions.component.html +++ b/apps/red-ui/src/app/components/rule-set-actions/rule-set-actions.component.html @@ -1,6 +1,6 @@
(); + + constructor(private readonly _dialogService: DialogService, public readonly permissionsService: PermissionsService) {} + + ngOnInit(): void {} + + openEditRuleSetDialog($event: any, ruleSet: RuleSetModel) { + $event.stopPropagation(); + this._dialogService.openAddEditRuleSetDialog(ruleSet, async (newRuleSet) => { + if (newRuleSet) { + this.loadRuleSetsData.emit(); + } + }); + } + + openDeleteRuleSetDialog($event: any, ruleSet: RuleSetModel) { + this._dialogService.openDeleteRuleSetDialog($event, ruleSet, async () => { + this.loadRuleSetsData.emit(); + }); + } +} diff --git a/apps/red-ui/src/app/components/project-template-view-switch/project-template-view-switch.component.html b/apps/red-ui/src/app/components/rule-set-view-switch/rule-set-view-switch.component.html similarity index 100% rename from apps/red-ui/src/app/components/project-template-view-switch/project-template-view-switch.component.html rename to apps/red-ui/src/app/components/rule-set-view-switch/rule-set-view-switch.component.html diff --git a/apps/red-ui/src/app/components/project-template-view-switch/project-template-view-switch.component.scss b/apps/red-ui/src/app/components/rule-set-view-switch/rule-set-view-switch.component.scss similarity index 100% rename from apps/red-ui/src/app/components/project-template-view-switch/project-template-view-switch.component.scss rename to apps/red-ui/src/app/components/rule-set-view-switch/rule-set-view-switch.component.scss diff --git a/apps/red-ui/src/app/components/project-template-view-switch/project-template-view-switch.component.ts b/apps/red-ui/src/app/components/rule-set-view-switch/rule-set-view-switch.component.ts similarity index 53% rename from apps/red-ui/src/app/components/project-template-view-switch/project-template-view-switch.component.ts rename to apps/red-ui/src/app/components/rule-set-view-switch/rule-set-view-switch.component.ts index 170a27221..c5ef646b8 100644 --- a/apps/red-ui/src/app/components/project-template-view-switch/project-template-view-switch.component.ts +++ b/apps/red-ui/src/app/components/rule-set-view-switch/rule-set-view-switch.component.ts @@ -2,26 +2,26 @@ import { Component, Input, OnInit } from '@angular/core'; import { ActivatedRoute, Router } from '@angular/router'; @Component({ - selector: 'redaction-project-template-view-switch', - templateUrl: './project-template-view-switch.component.html', - styleUrls: ['./project-template-view-switch.component.scss'] + selector: 'redaction-rule-set-view-switch', + templateUrl: './rule-set-view-switch.component.html', + styleUrls: ['./rule-set-view-switch.component.scss'] }) -export class ProjectTemplateViewSwitchComponent implements OnInit { +export class RuleSetViewSwitchComponent implements OnInit { @Input() public screen: 'rules' | 'dictionaries'; - private readonly _projectTemplateId: string; + private readonly _ruleSetId: string; constructor(private readonly _actr: ActivatedRoute, private _router: Router) { - this._projectTemplateId = this._actr.snapshot.params.templateId; + this._ruleSetId = this._actr.snapshot.params.ruleSetId; } ngOnInit(): void {} public switchView($event) { if ($event.value === 'dictionaries') { - this._router.navigate(['ui/admin/project-templates/' + this._projectTemplateId + '/dictionaries']); + this._router.navigate(['ui/admin/project-templates/' + this._ruleSetId + '/dictionaries']); } else { - this._router.navigate(['ui/admin/project-templates/' + this._projectTemplateId + '/rules']); + this._router.navigate(['ui/admin/project-templates/' + this._ruleSetId + '/rules']); } } } diff --git a/apps/red-ui/src/app/dialogs/add-edit-project-dialog/add-edit-project-dialog.component.html b/apps/red-ui/src/app/dialogs/add-edit-project-dialog/add-edit-project-dialog.component.html index 966f47acc..d92c4f67a 100644 --- a/apps/red-ui/src/app/dialogs/add-edit-project-dialog/add-edit-project-dialog.component.html +++ b/apps/red-ui/src/app/dialogs/add-edit-project-dialog/add-edit-project-dialog.component.html @@ -19,9 +19,9 @@
{{ 'project-listing.add-edit-dialog.form.template' | translate }} - - - {{ type }} + + + {{ ruleSet.name }} diff --git a/apps/red-ui/src/app/dialogs/add-edit-project-dialog/add-edit-project-dialog.component.ts b/apps/red-ui/src/app/dialogs/add-edit-project-dialog/add-edit-project-dialog.component.ts index 2fa878326..db8e19078 100644 --- a/apps/red-ui/src/app/dialogs/add-edit-project-dialog/add-edit-project-dialog.component.ts +++ b/apps/red-ui/src/app/dialogs/add-edit-project-dialog/add-edit-project-dialog.component.ts @@ -1,6 +1,6 @@ import { Component, Inject } from '@angular/core'; import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; -import { Project } from '@redaction/red-ui-http'; +import { Project, RuleSetModel } from '@redaction/red-ui-http'; import { FormBuilder, FormGroup, Validators } from '@angular/forms'; import { AppStateService } from '../../state/app-state.service'; import { ProjectWrapper } from '../../state/model/project.wrapper'; @@ -23,12 +23,17 @@ export class AddEditProjectDialogComponent { ) { this.projectForm = this._formBuilder.group({ projectName: [this.project?.projectName, Validators.required], + ruleSet: [{ value: this.project?.ruleSetId, disabled: this.project?.hasFiles }, Validators.required], description: [this.project?.description], dueDate: [this.project?.dueDate] }); this.hasDueDate = !!this.project?.dueDate; } + public get ruleSets(): RuleSetModel[] { + return this._appStateService.ruleSets; + } + public get changed() { if (!this.project) { return true; @@ -77,7 +82,8 @@ export class AddEditProjectDialogComponent { return { projectName: this.projectForm.get('projectName').value, description: this.projectForm.get('description').value, - dueDate: this.hasDueDate ? this.projectForm.get('dueDate').value : undefined + dueDate: this.hasDueDate ? this.projectForm.get('dueDate').value : undefined, + ruleSetId: this.projectForm.get('ruleSet').value }; } diff --git a/apps/red-ui/src/app/dialogs/dialog.service.ts b/apps/red-ui/src/app/dialogs/dialog.service.ts index 1dff8b33a..76a992b44 100644 --- a/apps/red-ui/src/app/dialogs/dialog.service.ts +++ b/apps/red-ui/src/app/dialogs/dialog.service.ts @@ -1,10 +1,17 @@ import { Injectable } from '@angular/core'; import { MatDialog, MatDialogRef } from '@angular/material/dialog'; -import { DictionaryControllerService, FileManagementControllerService, FileStatus, ManualRedactionControllerService, TypeValue } from '@redaction/red-ui-http'; +import { + DictionaryControllerService, + FileManagementControllerService, + FileStatus, + ManualRedactionControllerService, + RuleSetModel, + TypeValue +} from '@redaction/red-ui-http'; import { ConfirmationDialogComponent, ConfirmationDialogInput } from './confirmation-dialog/confirmation-dialog.component'; import { NotificationService, NotificationType } from '../notification/notification.service'; import { TranslateService } from '@ngx-translate/core'; -import { AppStateService, ProjectTemplate } from '../state/app-state.service'; +import { AppStateService } from '../state/app-state.service'; import { AddEditProjectDialogComponent } from './add-edit-project-dialog/add-edit-project-dialog.component'; import { AssignOwnerDialogComponent } from './assign-owner-dialog/assign-owner-dialog.component'; import { ManualRedactionEntryWrapper } from '../screens/file/model/manual-redaction-entry.wrapper'; @@ -13,7 +20,7 @@ import { ManualAnnotationDialogComponent } from './manual-redaction-dialog/manua import { ManualAnnotationService } from '../screens/file/service/manual-annotation.service'; import { ProjectWrapper } from '../state/model/project.wrapper'; import { AddEditDictionaryDialogComponent } from '../screens/admin/dictionary-listing-screen/add-edit-dictionary-dialog/add-edit-dictionary-dialog.component'; -import { AddEditProjectTemplateDialogComponent } from '../screens/admin/project-templates-listing-screen/add-edit-project-template-dialog/add-edit-project-template-dialog.component'; +import { AddEditRuleSetDialogComponent } from '../screens/admin/rule-sets-listing-screen/add-edit-rule-set-dialog/add-edit-rule-set-dialog.component'; import { DEFAULT_RUL_SET_UUID } from '../utils/rule-set-default'; const dialogConfig = { @@ -175,7 +182,7 @@ export class DialogService { return ref; } - public openDeleteProjectTemplateDialog($event: MouseEvent, projectTemplate: ProjectTemplate, cb?: Function): MatDialogRef { + public openDeleteRuleSetDialog($event: MouseEvent, ruleSet: RuleSetModel, cb?: Function): MatDialogRef { $event.stopPropagation(); const ref = this._dialog.open(ConfirmationDialogComponent, dialogConfig); ref.afterClosed().subscribe(async (result) => { @@ -285,10 +292,10 @@ export class DialogService { return ref; } - public openAddEditTemplateDialog(template: ProjectTemplate, cb?: Function): MatDialogRef { - const ref = this._dialog.open(AddEditProjectTemplateDialogComponent, { + public openAddEditRuleSetDialog(ruleSet: RuleSetModel, cb?: Function): MatDialogRef { + const ref = this._dialog.open(AddEditRuleSetDialogComponent, { ...dialogConfig, - data: template, + data: ruleSet, autoFocus: true }); diff --git a/apps/red-ui/src/app/screens/admin/dictionary-listing-screen/add-edit-dictionary-dialog/add-edit-dictionary-dialog.component.ts b/apps/red-ui/src/app/screens/admin/dictionary-listing-screen/add-edit-dictionary-dialog/add-edit-dictionary-dialog.component.ts index b7bb110f7..c30163e83 100644 --- a/apps/red-ui/src/app/screens/admin/dictionary-listing-screen/add-edit-dictionary-dialog/add-edit-dictionary-dialog.component.ts +++ b/apps/red-ui/src/app/screens/admin/dictionary-listing-screen/add-edit-dictionary-dialog/add-edit-dictionary-dialog.component.ts @@ -63,7 +63,8 @@ export class AddEditDictionaryDialogComponent { observable = this._dictionaryControllerService.updateType(typeValue, typeValue.type, DEFAULT_RUL_SET_UUID); } else { // create mode - observable = this._dictionaryControllerService.addType(typeValue, DEFAULT_RUL_SET_UUID); + typeValue.ruleSetId = DEFAULT_RUL_SET_UUID; + observable = this._dictionaryControllerService.addType(typeValue); } // diff --git a/apps/red-ui/src/app/screens/admin/dictionary-listing-screen/dictionary-listing-screen.component.html b/apps/red-ui/src/app/screens/admin/dictionary-listing-screen/dictionary-listing-screen.component.html index f67bc5685..7417f7e3b 100644 --- a/apps/red-ui/src/app/screens/admin/dictionary-listing-screen/dictionary-listing-screen.component.html +++ b/apps/red-ui/src/app/screens/admin/dictionary-listing-screen/dictionary-listing-screen.component.html @@ -2,11 +2,10 @@