mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
[CST-9636] WIP add bulk-access-config-data.service
This commit is contained in:
@@ -17,56 +17,7 @@ import { hasValue } from '../../../shared/empty.util';
|
|||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ds-bulk-access-browse',
|
selector: 'ds-bulk-access-browse',
|
||||||
template: `
|
templateUrl: 'bulk-access-browse.component.html',
|
||||||
<ngb-accordion #acc="ngbAccordion" [activeIds]="'browse'">
|
|
||||||
<ngb-panel [id]="'browse'">
|
|
||||||
<ng-template ngbPanelHeader>
|
|
||||||
<div class="w-100 d-flex justify-content-between collapse-toggle" ngbPanelToggle (click)="acc.toggle('browse')"
|
|
||||||
data-test="browse">
|
|
||||||
<button type="button" class="btn btn-link p-0" (click)="$event.preventDefault()"
|
|
||||||
[attr.aria-expanded]="!acc.isExpanded('browse')"
|
|
||||||
aria-controls="collapsePanels">
|
|
||||||
{{ 'admin.access-control.bulk-access-browse.header' | translate }}
|
|
||||||
</button>
|
|
||||||
<div class="text-right d-flex">
|
|
||||||
<div class="ml-3 d-inline-block">
|
|
||||||
<span *ngIf="acc.isExpanded('browse')" class="fas fa-chevron-up fa-fw"></span>
|
|
||||||
<span *ngIf="!acc.isExpanded('browse')" class="fas fa-chevron-down fa-fw"></span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</ng-template>
|
|
||||||
<ng-template ngbPanelContent>
|
|
||||||
<ul ngbNav #nav="ngbNav" [(activeId)]="activateId" class="nav-pills">
|
|
||||||
<li [ngbNavItem]="'search'">
|
|
||||||
<a ngbNavLink>{{'admin.access-control.bulk-access-browse.search.header' | translate}}</a>
|
|
||||||
<ng-template ngbNavContent>
|
|
||||||
<div class="mx-n3">
|
|
||||||
<ds-themed-search [configuration]="'default'"
|
|
||||||
[selectable]="true"
|
|
||||||
[selectionConfig]="{ repeatable: true, listId: listId }"
|
|
||||||
[showThumbnails]="false"></ds-themed-search>
|
|
||||||
</div>
|
|
||||||
</ng-template>
|
|
||||||
</li>
|
|
||||||
<li [ngbNavItem]="'selected'">
|
|
||||||
<a
|
|
||||||
ngbNavLink>{{'admin.access-control.bulk-access-browse.selected.header' | translate: {number: ((objectsSelected$ | async)?.payload?.totalElements) ? (objectsSelected$ | async)?.payload?.totalElements : '0'} }}</a>
|
|
||||||
<ng-template ngbNavContent>
|
|
||||||
<ds-viewable-collection [config]="paginationOptions"
|
|
||||||
[hideGear]="true"
|
|
||||||
[objects]="objectsSelected$ | async"
|
|
||||||
[selectable]="true"
|
|
||||||
[selectionConfig]="{ repeatable: true, listId: listId }"
|
|
||||||
[showThumbnails]="false"></ds-viewable-collection>
|
|
||||||
</ng-template>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
<div [ngbNavOutlet]="nav" class="mt-5"></div>
|
|
||||||
</ng-template>
|
|
||||||
</ngb-panel>
|
|
||||||
</ngb-accordion>
|
|
||||||
`,
|
|
||||||
styleUrls: ['./bulk-access-browse.component.scss'],
|
styleUrls: ['./bulk-access-browse.component.scss'],
|
||||||
providers: [
|
providers: [
|
||||||
{
|
{
|
||||||
|
@@ -1,59 +0,0 @@
|
|||||||
import { Injectable } from '@angular/core';
|
|
||||||
import { of } from 'rxjs';
|
|
||||||
import { BulkAccessConditionOptionsService } from '../../../core/data/bulk-access-condition-options.service';
|
|
||||||
import { BulkAccessConditionOptions } from '../../../core/shared/bulk-access-condition-options.model';
|
|
||||||
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class CommunityAccessControlService {
|
|
||||||
constructor(private service: BulkAccessConditionOptionsService) {}
|
|
||||||
|
|
||||||
dropdownData$ = of(accessControlDropdownData);
|
|
||||||
|
|
||||||
// dropdownData$ = this.service.getAll().pipe(
|
|
||||||
// getAllSucceededRemoteData(),
|
|
||||||
// filter((data) => data.hasSucceeded),
|
|
||||||
// map((data) => data.payload)
|
|
||||||
// );
|
|
||||||
}
|
|
||||||
|
|
||||||
const accessControlDropdownData: BulkAccessConditionOptions = {
|
|
||||||
_links: { self: undefined }, type: undefined, uuid: '',
|
|
||||||
'id': 'default',
|
|
||||||
'itemAccessConditionOptions': [
|
|
||||||
{
|
|
||||||
'name': 'openaccess'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'name': 'administrator'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'name': 'embargo',
|
|
||||||
'hasStartDate': true,
|
|
||||||
'maxStartDate': '2018-06-24T00:40:54.970+0000'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'name': 'lease',
|
|
||||||
'hasEndDate': true,
|
|
||||||
'maxEndDate': '2017-12-24T00:40:54.970+0000'
|
|
||||||
}
|
|
||||||
],
|
|
||||||
'bitstreamAccessConditionOptions': [
|
|
||||||
{
|
|
||||||
'name': 'openaccess'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'name': 'administrator'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'name': 'embargo',
|
|
||||||
'hasStartDate': true,
|
|
||||||
'maxStartDate': '2018-06-24T00:40:54.970+0000'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'name': 'lease',
|
|
||||||
'hasEndDate': true,
|
|
||||||
'maxEndDate': '2017-12-24T00:40:54.970+0000'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
};
|
|
@@ -3,16 +3,16 @@ import { Observable } from 'rxjs';
|
|||||||
import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service';
|
import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service';
|
||||||
import { ObjectCacheService } from '../cache/object-cache.service';
|
import { ObjectCacheService } from '../cache/object-cache.service';
|
||||||
import { HALEndpointService } from '../shared/hal-endpoint.service';
|
import { HALEndpointService } from '../shared/hal-endpoint.service';
|
||||||
import { RemoteData } from './remote-data';
|
import { RemoteData } from '../data/remote-data';
|
||||||
import { RequestService } from './request.service';
|
import { RequestService } from '../data/request.service';
|
||||||
import { IdentifiableDataService } from './base/identifiable-data.service';
|
import { BulkAccessConditionOptions } from './models/bulk-access-condition-options.model';
|
||||||
import { BulkAccessConditionOptions } from '../shared/bulk-access-condition-options.model';
|
import { ConfigDataService } from './config-data.service';
|
||||||
|
|
||||||
@Injectable({ providedIn: 'root' })
|
@Injectable({ providedIn: 'root' })
|
||||||
/**
|
/**
|
||||||
* Data Service responsible for retrieving Bulk Access Condition Options from the REST API
|
* Data Service responsible for retrieving Bulk Access Condition Options from the REST API
|
||||||
*/
|
*/
|
||||||
export class BulkAccessConditionOptionsService extends IdentifiableDataService<BulkAccessConditionOptions> {
|
export class BulkAccessConfigDataService extends ConfigDataService {
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
protected requestService: RequestService,
|
protected requestService: RequestService,
|
||||||
@@ -23,11 +23,7 @@ export class BulkAccessConditionOptionsService extends IdentifiableDataService<B
|
|||||||
super('bulkaccessconditionoptions', requestService, rdbService, objectCache, halService);
|
super('bulkaccessconditionoptions', requestService, rdbService, objectCache, halService);
|
||||||
}
|
}
|
||||||
|
|
||||||
getAll(): Observable<RemoteData<BulkAccessConditionOptions>> {
|
findByPropertyName(name: string): Observable<RemoteData<BulkAccessConditionOptions>> {
|
||||||
return this.findByHref(this.halService.getEndpoint(this.linkPath));
|
return this.findById(name) as Observable<RemoteData<BulkAccessConditionOptions>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
// findByPropertyName(name: string): Observable<RemoteData<BulkAccessConditionOptions>> {
|
|
||||||
// return this.findById(name);
|
|
||||||
// }
|
|
||||||
}
|
}
|
@@ -4,13 +4,13 @@ import { RemoteData } from '../data/remote-data';
|
|||||||
import { FollowLinkConfig } from '../../shared/utils/follow-link-config.model';
|
import { FollowLinkConfig } from '../../shared/utils/follow-link-config.model';
|
||||||
import { getFirstCompletedRemoteData } from '../shared/operators';
|
import { getFirstCompletedRemoteData } from '../shared/operators';
|
||||||
import { map } from 'rxjs/operators';
|
import { map } from 'rxjs/operators';
|
||||||
import { BaseDataService } from '../data/base/base-data.service';
|
import { IdentifiableDataService } from '../data/base/identifiable-data.service';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract data service to retrieve configuration objects from the REST server.
|
* Abstract data service to retrieve configuration objects from the REST server.
|
||||||
* Common logic for configuration objects should be implemented here.
|
* Common logic for configuration objects should be implemented here.
|
||||||
*/
|
*/
|
||||||
export abstract class ConfigDataService extends BaseDataService<ConfigObject> {
|
export abstract class ConfigDataService extends IdentifiableDataService<ConfigObject> {
|
||||||
/**
|
/**
|
||||||
* Returns an observable of {@link RemoteData} of an object, based on an href, with a list of
|
* Returns an observable of {@link RemoteData} of an object, based on an href, with a list of
|
||||||
* {@link FollowLinkConfig}, to automatically resolve {@link HALLink}s of the object
|
* {@link FollowLinkConfig}, to automatically resolve {@link HALLink}s of the object
|
||||||
@@ -37,4 +37,8 @@ export abstract class ConfigDataService extends BaseDataService<ConfigObject> {
|
|||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
findByName(name: string, useCachedVersionIfAvailable = true, reRequestOnStale = true, ...linksToFollow: FollowLinkConfig<ConfigObject>[]): Observable<RemoteData<ConfigObject>> {
|
||||||
|
return super.findById(name, useCachedVersionIfAvailable, reRequestOnStale, ...linksToFollow);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,38 @@
|
|||||||
|
import { autoserialize, autoserializeAs, deserialize } from 'cerialize';
|
||||||
|
import { typedObject } from '../../cache/builders/build-decorators';
|
||||||
|
import { excludeFromEquals } from '../../utilities/equals.decorators';
|
||||||
|
import { ResourceType } from '../../shared/resource-type';
|
||||||
|
import { HALLink } from '../../shared/hal-link.model';
|
||||||
|
import { ConfigObject } from './config.model';
|
||||||
|
import { AccessesConditionOption } from './config-accesses-conditions-options.model';
|
||||||
|
|
||||||
|
export const BULK_ACCESS_CONDITION_OPTIONS = new ResourceType('bulkAccessConditionOptions');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Model class for a bulk access condition options
|
||||||
|
*/
|
||||||
|
@typedObject
|
||||||
|
export class BulkAccessConditionOptions extends ConfigObject {
|
||||||
|
static type = BULK_ACCESS_CONDITION_OPTIONS;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The object type
|
||||||
|
*/
|
||||||
|
@excludeFromEquals
|
||||||
|
@autoserialize
|
||||||
|
type: ResourceType;
|
||||||
|
|
||||||
|
@autoserializeAs(String, 'name')
|
||||||
|
uuid: string;
|
||||||
|
|
||||||
|
@autoserialize
|
||||||
|
id: string;
|
||||||
|
|
||||||
|
@deserialize
|
||||||
|
itemAccessConditionOptions: AccessesConditionOption[];
|
||||||
|
|
||||||
|
@deserialize
|
||||||
|
bitstreamAccessConditionOptions: AccessesConditionOption[];
|
||||||
|
|
||||||
|
_links: { self: HALLink };
|
||||||
|
}
|
@@ -1,45 +0,0 @@
|
|||||||
import { autoserialize, autoserializeAs, deserialize } from 'cerialize';
|
|
||||||
import { typedObject } from '../cache/builders/build-decorators';
|
|
||||||
import { excludeFromEquals } from '../utilities/equals.decorators';
|
|
||||||
import { ResourceType } from './resource-type';
|
|
||||||
import { CacheableObject } from '../cache/cacheable-object.model';
|
|
||||||
import { HALLink } from './hal-link.model';
|
|
||||||
|
|
||||||
export const BULK_ACCESS_CONDITION_OPTIONS = new ResourceType('bulkAccessConditionOptions');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Model class for a bulk access condition options
|
|
||||||
*/
|
|
||||||
@typedObject
|
|
||||||
export class BulkAccessConditionOptions implements CacheableObject {
|
|
||||||
static type = BULK_ACCESS_CONDITION_OPTIONS;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The object type
|
|
||||||
*/
|
|
||||||
@excludeFromEquals
|
|
||||||
@autoserialize
|
|
||||||
type: ResourceType;
|
|
||||||
|
|
||||||
@autoserializeAs(String, 'name')
|
|
||||||
uuid: string;
|
|
||||||
|
|
||||||
@autoserialize
|
|
||||||
id: string;
|
|
||||||
|
|
||||||
@deserialize
|
|
||||||
itemAccessConditionOptions: AccessControlItem[];
|
|
||||||
|
|
||||||
@deserialize
|
|
||||||
bitstreamAccessConditionOptions: AccessControlItem[];
|
|
||||||
|
|
||||||
_links: { self: HALLink };
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface AccessControlItem {
|
|
||||||
name: string
|
|
||||||
hasStartDate?: boolean
|
|
||||||
maxStartDate?: string
|
|
||||||
hasEndDate?: boolean
|
|
||||||
maxEndDate?: string
|
|
||||||
}
|
|
@@ -7,7 +7,7 @@
|
|||||||
<div>
|
<div>
|
||||||
<select id="accesscontroloption" formControlName="itemName" class="form-control">
|
<select id="accesscontroloption" formControlName="itemName" class="form-control">
|
||||||
<option value=""></option>
|
<option value=""></option>
|
||||||
<option *ngFor="let option of dropdownOptions" [value]="option.name">
|
<option *ngFor="let option of (dropdownData$ | async)" [value]="option.name">
|
||||||
{{ option.name }}
|
{{ option.name }}
|
||||||
</option>
|
</option>
|
||||||
</select>
|
</select>
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
placeholder="yyyy-mm-dd"
|
placeholder="yyyy-mm-dd"
|
||||||
name="dp"
|
name="dp"
|
||||||
formControlName="startDate"
|
formControlName="startDate"
|
||||||
[minDate]="control | maxStartDate: dropdownOptions"
|
[minDate]="control | maxStartDate: (dropdownData$ | async)"
|
||||||
ngbDatepicker
|
ngbDatepicker
|
||||||
#d="ngbDatepicker"
|
#d="ngbDatepicker"
|
||||||
/>
|
/>
|
||||||
@@ -40,7 +40,7 @@
|
|||||||
placeholder="yyyy-mm-dd"
|
placeholder="yyyy-mm-dd"
|
||||||
name="dp"
|
name="dp"
|
||||||
formControlName="endDate"
|
formControlName="endDate"
|
||||||
[maxDate]="control | maxEndDate: dropdownOptions"
|
[maxDate]="control | maxEndDate: (dropdownData$ | async)"
|
||||||
ngbDatepicker
|
ngbDatepicker
|
||||||
#d1="ngbDatepicker"
|
#d1="ngbDatepicker"
|
||||||
/>
|
/>
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { Component, Input, NgModule, OnDestroy, OnInit } from '@angular/core';
|
import { Component, NgModule, OnDestroy, OnInit } from '@angular/core';
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
import { FormArray, FormBuilder, FormControl, ReactiveFormsModule } from '@angular/forms';
|
import { FormArray, FormBuilder, FormControl, ReactiveFormsModule } from '@angular/forms';
|
||||||
import { SharedBrowseByModule } from '../browse-by/shared-browse-by.module';
|
import { SharedBrowseByModule } from '../browse-by/shared-browse-by.module';
|
||||||
@@ -6,9 +6,13 @@ import { TranslateModule } from '@ngx-translate/core';
|
|||||||
import { NgbDatepickerModule } from '@ng-bootstrap/ng-bootstrap';
|
import { NgbDatepickerModule } from '@ng-bootstrap/ng-bootstrap';
|
||||||
import { ControlMaxStartDatePipe } from './control-max-start-date.pipe';
|
import { ControlMaxStartDatePipe } from './control-max-start-date.pipe';
|
||||||
import { ControlMaxEndDatePipe } from './control-max-end-date.pipe';
|
import { ControlMaxEndDatePipe } from './control-max-end-date.pipe';
|
||||||
import { AccessControlItem } from '../../core/shared/bulk-access-condition-options.model';
|
|
||||||
import { distinctUntilChanged, takeUntil } from 'rxjs/operators';
|
import { distinctUntilChanged, map, shareReplay, takeUntil, tap } from 'rxjs/operators';
|
||||||
import { Subject } from 'rxjs';
|
import { Subject } from 'rxjs';
|
||||||
|
import { getFirstCompletedRemoteData } from '../../core/shared/operators';
|
||||||
|
import { RemoteData } from '../../core/data/remote-data';
|
||||||
|
import { BulkAccessConditionOptions } from '../../core/config/models/bulk-access-condition-options.model';
|
||||||
|
import { BulkAccessConfigDataService } from '../../core/config/bulk-access-config-data.service';
|
||||||
|
|
||||||
|
|
||||||
// will be used on the form value
|
// will be used on the form value
|
||||||
@@ -25,8 +29,6 @@ export interface AccessControlItemValue {
|
|||||||
exportAs: 'accessControlArrayForm'
|
exportAs: 'accessControlArrayForm'
|
||||||
})
|
})
|
||||||
export class AccessControlArrayFormComponent implements OnInit, OnDestroy {
|
export class AccessControlArrayFormComponent implements OnInit, OnDestroy {
|
||||||
@Input() dropdownOptions: AccessControlItem[] = [];
|
|
||||||
@Input() accessControlItems: AccessControlItemValue[] = [];
|
|
||||||
|
|
||||||
private destroy$ = new Subject<void>();
|
private destroy$ = new Subject<void>();
|
||||||
|
|
||||||
@@ -34,17 +36,28 @@ export class AccessControlArrayFormComponent implements OnInit, OnDestroy {
|
|||||||
accessControl: this.fb.array([])
|
accessControl: this.fb.array([])
|
||||||
});
|
});
|
||||||
|
|
||||||
constructor(private fb: FormBuilder) {
|
constructor(private bulkAccessConfigService: BulkAccessConfigDataService,
|
||||||
|
private fb: FormBuilder) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dropdownData$ = this.bulkAccessConfigService.findByPropertyName('default').pipe(
|
||||||
|
getFirstCompletedRemoteData(),
|
||||||
|
map((configRD: RemoteData<BulkAccessConditionOptions>) => configRD.hasSucceeded ? configRD.payload : null),
|
||||||
|
shareReplay(1),
|
||||||
|
tap(console.log)
|
||||||
|
);
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
if (this.accessControlItems.length === 0) {
|
// console.log(this.dropdownOptions);
|
||||||
|
/* if (this.accessControlItems.length === 0) {
|
||||||
this.addAccessControlItem();
|
this.addAccessControlItem();
|
||||||
} else {
|
} else {
|
||||||
for (const item of this.accessControlItems) {
|
for (const item of this.accessControlItems) {
|
||||||
this.addAccessControlItem(item.itemName);
|
this.addAccessControlItem(item.itemName);
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
|
this.addAccessControlItem();
|
||||||
|
|
||||||
this.accessControl.valueChanges
|
this.accessControl.valueChanges
|
||||||
.pipe(
|
.pipe(
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
import { Pipe, PipeTransform } from '@angular/core';
|
import { Pipe, PipeTransform } from '@angular/core';
|
||||||
import { AbstractControl } from '@angular/forms';
|
import { AbstractControl } from '@angular/forms';
|
||||||
import { NgbDateStruct } from '@ng-bootstrap/ng-bootstrap/datepicker/ngb-date-struct';
|
import { NgbDateStruct } from '@ng-bootstrap/ng-bootstrap/datepicker/ngb-date-struct';
|
||||||
import { AccessControlItem } from 'src/app/core/shared/bulk-access-condition-options.model';
|
import { AccessesConditionOption } from '../../core/config/models/config-accesses-conditions-options.model';
|
||||||
|
|
||||||
@Pipe({
|
@Pipe({
|
||||||
// eslint-disable-next-line @angular-eslint/pipe-prefix
|
// eslint-disable-next-line @angular-eslint/pipe-prefix
|
||||||
@@ -9,7 +9,7 @@ import { AccessControlItem } from 'src/app/core/shared/bulk-access-condition-opt
|
|||||||
pure: false
|
pure: false
|
||||||
})
|
})
|
||||||
export class ControlMaxEndDatePipe implements PipeTransform {
|
export class ControlMaxEndDatePipe implements PipeTransform {
|
||||||
transform(control: AbstractControl, dropdownOptions: AccessControlItem[]): NgbDateStruct | null {
|
transform(control: AbstractControl, dropdownOptions: AccessesConditionOption[]): NgbDateStruct | null {
|
||||||
const { itemName } = control.value;
|
const { itemName } = control.value;
|
||||||
const item = dropdownOptions.find((x) => x.name === itemName);
|
const item = dropdownOptions.find((x) => x.name === itemName);
|
||||||
if (!item?.hasEndDate) {
|
if (!item?.hasEndDate) {
|
||||||
|
@@ -1,7 +1,8 @@
|
|||||||
import { Pipe, PipeTransform } from '@angular/core';
|
import { Pipe, PipeTransform } from '@angular/core';
|
||||||
import { AbstractControl } from '@angular/forms';
|
import { AbstractControl } from '@angular/forms';
|
||||||
import { NgbDateStruct } from '@ng-bootstrap/ng-bootstrap/datepicker/ngb-date-struct';
|
import { NgbDateStruct } from '@ng-bootstrap/ng-bootstrap/datepicker/ngb-date-struct';
|
||||||
import { AccessControlItem } from 'src/app/core/shared/bulk-access-condition-options.model';
|
import { AccessesConditionOption } from '../../core/config/models/config-accesses-conditions-options.model';
|
||||||
|
|
||||||
|
|
||||||
@Pipe({
|
@Pipe({
|
||||||
// eslint-disable-next-line @angular-eslint/pipe-prefix
|
// eslint-disable-next-line @angular-eslint/pipe-prefix
|
||||||
@@ -9,7 +10,7 @@ import { AccessControlItem } from 'src/app/core/shared/bulk-access-condition-opt
|
|||||||
pure: false
|
pure: false
|
||||||
})
|
})
|
||||||
export class ControlMaxStartDatePipe implements PipeTransform {
|
export class ControlMaxStartDatePipe implements PipeTransform {
|
||||||
transform(control: AbstractControl, dropdownOptions: AccessControlItem[]): NgbDateStruct | null {
|
transform(control: AbstractControl, dropdownOptions: AccessesConditionOption[]): NgbDateStruct | null {
|
||||||
const { itemName } = control.value;
|
const { itemName } = control.value;
|
||||||
const item = dropdownOptions.find((x) => x.name === itemName);
|
const item = dropdownOptions.find((x) => x.name === itemName);
|
||||||
if (!item?.hasStartDate) {
|
if (!item?.hasStartDate) {
|
||||||
|
@@ -48,10 +48,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<ds-access-control-array-form
|
<ds-access-control-array-form #itemAccessCmp></ds-access-control-array-form>
|
||||||
#itemAccessCmp
|
|
||||||
[dropdownOptions]="(dropdownData$ | async)?.itemAccessConditionOptions || []">
|
|
||||||
</ds-access-control-array-form>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="col-12 col-md-6">
|
<div class="col-12 col-md-6">
|
||||||
@@ -137,10 +134,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<ds-access-control-array-form
|
<ds-access-control-array-form #bitstreamAccessCmp></ds-access-control-array-form>
|
||||||
#bitstreamAccessCmp
|
|
||||||
[dropdownOptions]="(dropdownData$ | async)?.bitstreamAccessConditionOptions || []">
|
|
||||||
</ds-access-control-array-form>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { ChangeDetectorRef, Component, Input, NgModule, ViewChild } from '@angular/core';
|
import { ChangeDetectorRef, Component, Input, NgModule, ViewChild } from '@angular/core';
|
||||||
import { concatMap, shareReplay } from 'rxjs';
|
import { concatMap } from 'rxjs';
|
||||||
import { RemoteData } from '../../core/data/remote-data';
|
import { RemoteData } from '../../core/data/remote-data';
|
||||||
import { Item } from '../../core/shared/item.model';
|
import { Item } from '../../core/shared/item.model';
|
||||||
import {
|
import {
|
||||||
@@ -20,6 +20,7 @@ import {
|
|||||||
ITEM_ACCESS_CONTROL_SELECT_BITSTREAMS_LIST_ID,
|
ITEM_ACCESS_CONTROL_SELECT_BITSTREAMS_LIST_ID,
|
||||||
ItemAccessControlSelectBitstreamsModalComponent
|
ItemAccessControlSelectBitstreamsModalComponent
|
||||||
} from './item-access-control-select-bitstreams-modal/item-access-control-select-bitstreams-modal.component';
|
} from './item-access-control-select-bitstreams-modal/item-access-control-select-bitstreams-modal.component';
|
||||||
|
import { BulkAccessConfigDataService } from '../../core/config/bulk-access-config-data.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ds-access-control-form-container',
|
selector: 'ds-access-control-form-container',
|
||||||
@@ -27,7 +28,7 @@ import {
|
|||||||
styleUrls: [ './access-control-form-container.component.scss' ],
|
styleUrls: [ './access-control-form-container.component.scss' ],
|
||||||
exportAs: 'dsAccessControlForm'
|
exportAs: 'dsAccessControlForm'
|
||||||
})
|
})
|
||||||
export class AccessControlFormContainerComponent<T extends DSpaceObject> {
|
export class AccessControlFormContainerComponent<T extends DSpaceObject> implements OnInit {
|
||||||
|
|
||||||
@Input() showLimitToSpecificBitstreams = false;
|
@Input() showLimitToSpecificBitstreams = false;
|
||||||
@Input() itemRD: RemoteData<T>;
|
@Input() itemRD: RemoteData<T>;
|
||||||
@@ -38,6 +39,7 @@ export class AccessControlFormContainerComponent<T extends DSpaceObject> {
|
|||||||
@ViewChild('itemAccessCmp', { static: true }) itemAccessCmp: AccessControlArrayFormComponent;
|
@ViewChild('itemAccessCmp', { static: true }) itemAccessCmp: AccessControlArrayFormComponent;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
private bulkAccessConfigService: BulkAccessConfigDataService,
|
||||||
private bulkAccessControlService: BulkAccessControlService,
|
private bulkAccessControlService: BulkAccessControlService,
|
||||||
private selectableListService: SelectableListService,
|
private selectableListService: SelectableListService,
|
||||||
protected modalService: NgbModal,
|
protected modalService: NgbModal,
|
||||||
@@ -46,9 +48,16 @@ export class AccessControlFormContainerComponent<T extends DSpaceObject> {
|
|||||||
|
|
||||||
state = initialState;
|
state = initialState;
|
||||||
|
|
||||||
dropdownData$ = this.bulkAccessControlService.dropdownData$.pipe(
|
/* dropdownData$ = this.bulkAccessConfigService.findByPropertyName('default').pipe(
|
||||||
|
getFirstCompletedRemoteData(),
|
||||||
|
map((configRD: RemoteData<BulkAccessConditionOptions>) => configRD.hasSucceeded ? configRD.payload : null),
|
||||||
|
shareReplay(1),
|
||||||
|
tap(console.log)
|
||||||
|
);*/
|
||||||
|
|
||||||
|
/* dropdownData$ = this.bulkAccessControlService.dropdownData$.pipe(
|
||||||
shareReplay(1)
|
shareReplay(1)
|
||||||
);
|
);*/
|
||||||
|
|
||||||
getFormValue() {
|
getFormValue() {
|
||||||
return {
|
return {
|
||||||
|
@@ -1,21 +1,12 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { Observable, of } from 'rxjs';
|
|
||||||
import { AccessControlItem } from '../../core/shared/bulk-access-condition-options.model';
|
|
||||||
import { ScriptDataService } from '../../core/data/processes/script-data.service';
|
import { ScriptDataService } from '../../core/data/processes/script-data.service';
|
||||||
import { ProcessParameter } from '../../process-page/processes/process-parameter.model';
|
import { ProcessParameter } from '../../process-page/processes/process-parameter.model';
|
||||||
|
|
||||||
export interface AccessControlDropdownDataResponse {
|
|
||||||
id: string;
|
|
||||||
itemAccessConditionOptions: AccessControlItem[];
|
|
||||||
bitstreamAccessConditionOptions: AccessControlItem[];
|
|
||||||
}
|
|
||||||
|
|
||||||
@Injectable({ providedIn: 'root' })
|
@Injectable({ providedIn: 'root' })
|
||||||
export class BulkAccessControlService {
|
export class BulkAccessControlService {
|
||||||
constructor(private scriptService: ScriptDataService) {}
|
constructor(private scriptService: ScriptDataService) {}
|
||||||
|
|
||||||
dropdownData$: Observable<AccessControlDropdownDataResponse> = of(accessControlDropdownData);
|
|
||||||
|
|
||||||
createPayloadFile(payload: any) {
|
createPayloadFile(payload: any) {
|
||||||
console.log('execute', payload);
|
console.log('execute', payload);
|
||||||
|
|
||||||
@@ -43,43 +34,3 @@ export class BulkAccessControlService {
|
|||||||
return this.scriptService.invoke('bulk-access-control', params, [file]);
|
return this.scriptService.invoke('bulk-access-control', params, [file]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const accessControlDropdownData: AccessControlDropdownDataResponse = {
|
|
||||||
'id': 'default',
|
|
||||||
'itemAccessConditionOptions': [
|
|
||||||
{
|
|
||||||
'name': 'openaccess'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'name': 'administrator'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'name': 'embargo',
|
|
||||||
'hasStartDate': true,
|
|
||||||
'maxStartDate': '2023-05-12T00:40:54.970+0000'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'name': 'lease',
|
|
||||||
'hasEndDate': true,
|
|
||||||
'maxEndDate': '2017-12-24T00:40:54.970+0000'
|
|
||||||
}
|
|
||||||
],
|
|
||||||
'bitstreamAccessConditionOptions': [
|
|
||||||
{
|
|
||||||
'name': 'openaccess'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'name': 'administrator'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'name': 'embargo',
|
|
||||||
'hasStartDate': true,
|
|
||||||
'maxStartDate': '2018-06-24T00:40:54.970+0000'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'name': 'lease',
|
|
||||||
'hasEndDate': true,
|
|
||||||
'maxEndDate': '2017-12-24T00:40:54.970+0000'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
};
|
|
||||||
|
Reference in New Issue
Block a user