From fab11e90556164fb6310f1305016e97f8dfa1f47 Mon Sep 17 00:00:00 2001 From: Giuseppe Digilio Date: Thu, 2 Apr 2020 18:58:51 +0200 Subject: [PATCH] Added component to edit and create a resource policy --- resources/i18n/en.json5 | 40 ++++++++++++++++++- .../edit-item-page.routing.module.ts | 17 +++++++- .../resource-policy-create.component.html | 6 +++ .../resource-policy-create.component.ts | 32 +++++++++++++++ .../edit/resource-policy-edit.component.html | 5 +++ .../edit/resource-policy-edit.component.ts | 9 +++++ src/app/shared/shared.module.ts | 12 +++++- 7 files changed, 117 insertions(+), 4 deletions(-) create mode 100644 src/app/shared/resource-policies/create/resource-policy-create.component.html create mode 100644 src/app/shared/resource-policies/create/resource-policy-create.component.ts create mode 100644 src/app/shared/resource-policies/edit/resource-policy-edit.component.html create mode 100644 src/app/shared/resource-policies/edit/resource-policy-edit.component.ts diff --git a/resources/i18n/en.json5 b/resources/i18n/en.json5 index e85c374779..c869f51e5f 100644 --- a/resources/i18n/en.json5 +++ b/resources/i18n/en.json5 @@ -1667,15 +1667,51 @@ "resource-policies.add.for.item": "Add a new Item policy", + "resource-policies.create.modal.head": "Create new resource policy", + + "resource-policies.edit.modal.head": "Edit resource policy", + + "resource-policies.form.action-type.label": "Select the action type", + + "resource-policies.form.action-type.required": "You must select the resource policy action.", + + "resource-policies.form.eperson-group-list.label": "Select the eperson or group that will be grant of the permission", + + "resource-policies.form.eperson-group-list.select.btn": "Select", + + "resource-policies.form.eperson-group-list.tab.eperson": "Search for a ePerson", + + "resource-policies.form.eperson-group-list.tab.group": "Search for a group", + + "resource-policies.form.eperson-group-list.table.headers.action": "Action", + + "resource-policies.form.eperson-group-list.table.headers.id": "ID", + + "resource-policies.form.eperson-group-list.table.headers.name": "Name", + + "resource-policies.form.date.end.label": "End Date", + + "resource-policies.form.date.start.label": "Start Date", + + "resource-policies.form.description.label": "Description", + + "resource-policies.form.name.label": "Name", + + "resource-policies.form.policy-type.label": "Select the policy type", + + "resource-policies.form.policy-type.required": "You must select the resource policy type.", + "resource-policies.table.headers.action": "Action", "resource-policies.table.headers.date.end": "End Date", "resource-policies.table.headers.date.start": "Start Date", - "resource-policies.table.headers.group": "Group", + "resource-policies.table.headers.edit": "Edit", - "resource-policies.table.headers.group.edit": "Edit", + "resource-policies.table.headers.eperson": "EPerson", + + "resource-policies.table.headers.group": "Group", "resource-policies.table.headers.name": "Name", diff --git a/src/app/+item-page/edit-item-page/edit-item-page.routing.module.ts b/src/app/+item-page/edit-item-page/edit-item-page.routing.module.ts index b41df21eaf..c9bb14b1a9 100644 --- a/src/app/+item-page/edit-item-page/edit-item-page.routing.module.ts +++ b/src/app/+item-page/edit-item-page/edit-item-page.routing.module.ts @@ -15,6 +15,8 @@ import { ItemRelationshipsComponent } from './item-relationships/item-relationsh import { I18nBreadcrumbResolver } from '../../core/breadcrumbs/i18n-breadcrumb.resolver'; import { ItemVersionHistoryComponent } from './item-version-history/item-version-history.component'; import { ItemAuthorizationsComponent } from './item-authorizations/item-authorizations.component'; +import { ResourcePolicyEditComponent } from '../../shared/resource-policies/edit/resource-policy-edit.component'; +import { ResourcePolicyCreateComponent } from '../../shared/resource-policies/create/resource-policy-create.component'; export const ITEM_EDIT_WITHDRAW_PATH = 'withdraw'; export const ITEM_EDIT_REINSTATE_PATH = 'reinstate'; @@ -116,8 +118,21 @@ export const ITEM_EDIT_AUTHORIZATIONS_PATH = 'authorizations'; }, { path: ITEM_EDIT_AUTHORIZATIONS_PATH, - component: ItemAuthorizationsComponent, data: { title: 'item.edit.authorizations.title' }, + children: [ + { + path: ':dso/create', + component: ResourcePolicyCreateComponent, + }, + { + path: ':dso/:policy/edit', + component: ResourcePolicyEditComponent, + }, + { + path: '', + component: ItemAuthorizationsComponent + } + ] } ] } diff --git a/src/app/shared/resource-policies/create/resource-policy-create.component.html b/src/app/shared/resource-policies/create/resource-policy-create.component.html new file mode 100644 index 0000000000..7990b8eb43 --- /dev/null +++ b/src/app/shared/resource-policies/create/resource-policy-create.component.html @@ -0,0 +1,6 @@ +
+

{{'resource-policies.create.modal.head' | translate}}

+ + +
diff --git a/src/app/shared/resource-policies/create/resource-policy-create.component.ts b/src/app/shared/resource-policies/create/resource-policy-create.component.ts new file mode 100644 index 0000000000..e92dab14da --- /dev/null +++ b/src/app/shared/resource-policies/create/resource-policy-create.component.ts @@ -0,0 +1,32 @@ +import { Component } from '@angular/core'; +import { Router } from '@angular/router'; + +import { take } from 'rxjs/operators'; + +import { ResourcePolicyEvent } from '../form/resource-policy-form'; +import { RouteService } from '../../../core/services/route.service'; +import { ResourcePolicyService } from '../../../core/resource-policy/resource-policy.service'; + +@Component({ + selector: 'ds-resource-policy-create', + templateUrl: './resource-policy-create.component.html' +}) +export class ResourcePolicyCreateComponent { + + constructor( + protected resourcePolicy: ResourcePolicyService, + protected router: Router, + protected routeService: RouteService) { + } + + createResourcePolicy(event: ResourcePolicyEvent) { + + } + + redirectToPreviousPage() { + this.routeService.getPreviousUrl().pipe(take(1)) + .subscribe((url) => { + this.router.navigateByUrl(url); + }) + } +} diff --git a/src/app/shared/resource-policies/edit/resource-policy-edit.component.html b/src/app/shared/resource-policies/edit/resource-policy-edit.component.html new file mode 100644 index 0000000000..d463e7fc1a --- /dev/null +++ b/src/app/shared/resource-policies/edit/resource-policy-edit.component.html @@ -0,0 +1,5 @@ +
+

{{'resource-policies.edit.modal.head' | translate}}

+ + +
diff --git a/src/app/shared/resource-policies/edit/resource-policy-edit.component.ts b/src/app/shared/resource-policies/edit/resource-policy-edit.component.ts new file mode 100644 index 0000000000..fa55979d35 --- /dev/null +++ b/src/app/shared/resource-policies/edit/resource-policy-edit.component.ts @@ -0,0 +1,9 @@ +import { Component } from '@angular/core'; + +@Component({ + selector: 'ds-resource-policy-edit', + templateUrl: './resource-policy-edit.component.html' +}) +export class ResourcePolicyEditComponent { + +} diff --git a/src/app/shared/shared.module.ts b/src/app/shared/shared.module.ts index 313c56089b..86ae893057 100644 --- a/src/app/shared/shared.module.ts +++ b/src/app/shared/shared.module.ts @@ -181,6 +181,10 @@ import { SortablejsModule } from 'ngx-sortablejs'; import { MissingTranslationHelper } from './translate/missing-translation.helper'; import { ResourcePoliciesComponent } from './resource-policies/resource-policies.component'; import { NgForTrackByIdDirective } from './ng-for-track-by-id.directive'; +import { ResourcePolicyFormComponent } from './resource-policies/form/resource-policy-form'; +import { ResourcePolicyCreateComponent } from './resource-policies/create/resource-policy-create.component'; +import { ResourcePolicyEditComponent } from './resource-policies/edit/resource-policy-edit.component'; +import { EpersonGroupListComponent } from './resource-policies/form/eperson-group-list/eperson-group-list.component'; const MODULES = [ // Do NOT include UniversalModule, HttpModule, or JsonpModule here @@ -349,7 +353,11 @@ const COMPONENTS = [ ExistingMetadataListElementComponent, ItemVersionsComponent, PublicationSearchResultListElementComponent, - ResourcePoliciesComponent + ResourcePoliciesComponent, + ResourcePolicyFormComponent, + ResourcePolicyCreateComponent, + ResourcePolicyEditComponent, + EpersonGroupListComponent ]; const ENTRY_COMPONENTS = [ @@ -414,6 +422,8 @@ const ENTRY_COMPONENTS = [ DsDynamicLookupRelationExternalSourceTabComponent, ExternalSourceEntryImportModalComponent, ItemVersionsComponent, + ResourcePolicyCreateComponent, + ResourcePolicyEditComponent ]; const SHARED_ITEM_PAGE_COMPONENTS = [