mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-18 15:33:04 +00:00
[CST-9636] Added bulk access condition options service
This commit is contained in:
@@ -1,19 +1,24 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { AccessControlItem } from '../../../shared/access-control-array-form/access-control-array-form.component';
|
import { of } from 'rxjs';
|
||||||
import { Observable, of } from 'rxjs';
|
import { BulkAccessConditionOptionsService } from '../../../core/data/bulk-access-condition-options.service';
|
||||||
|
import { BulkAccessConditionOptions } from '../../../core/shared/bulk-access-condition-options.model';
|
||||||
|
|
||||||
export interface AccessControlDropdownDataResponse {
|
|
||||||
id: string;
|
|
||||||
itemAccessConditionOptions: AccessControlItem[];
|
|
||||||
bitstreamAccessConditionOptions: AccessControlItem[];
|
|
||||||
}
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class CommunityAccessControlService {
|
export class CommunityAccessControlService {
|
||||||
dropdownData$: Observable<AccessControlDropdownDataResponse> = of(accessControlDropdownData);
|
constructor(private service: BulkAccessConditionOptionsService) {}
|
||||||
|
|
||||||
|
dropdownData$ = of(accessControlDropdownData);
|
||||||
|
|
||||||
|
// dropdownData$ = this.service.getAll().pipe(
|
||||||
|
// getAllSucceededRemoteData(),
|
||||||
|
// filter((data) => data.hasSucceeded),
|
||||||
|
// map((data) => data.payload)
|
||||||
|
// );
|
||||||
}
|
}
|
||||||
|
|
||||||
const accessControlDropdownData: AccessControlDropdownDataResponse = {
|
const accessControlDropdownData: BulkAccessConditionOptions = {
|
||||||
|
_links: { self: undefined }, type: undefined, uuid: '',
|
||||||
'id': 'default',
|
'id': 'default',
|
||||||
'itemAccessConditionOptions': [
|
'itemAccessConditionOptions': [
|
||||||
{
|
{
|
||||||
|
33
src/app/core/data/bulk-access-condition-options.service.ts
Normal file
33
src/app/core/data/bulk-access-condition-options.service.ts
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
import { Observable } from 'rxjs';
|
||||||
|
import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service';
|
||||||
|
import { ObjectCacheService } from '../cache/object-cache.service';
|
||||||
|
import { HALEndpointService } from '../shared/hal-endpoint.service';
|
||||||
|
import { RemoteData } from './remote-data';
|
||||||
|
import { RequestService } from './request.service';
|
||||||
|
import { IdentifiableDataService } from './base/identifiable-data.service';
|
||||||
|
import { BulkAccessConditionOptions } from '../shared/bulk-access-condition-options.model';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
/**
|
||||||
|
* Data Service responsible for retrieving Bulk Access Condition Options from the REST API
|
||||||
|
*/
|
||||||
|
export class BulkAccessConditionOptionsService extends IdentifiableDataService<BulkAccessConditionOptions> {
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
protected requestService: RequestService,
|
||||||
|
protected rdbService: RemoteDataBuildService,
|
||||||
|
protected objectCache: ObjectCacheService,
|
||||||
|
protected halService: HALEndpointService,
|
||||||
|
) {
|
||||||
|
super('bulkaccessconditionoptions', requestService, rdbService, objectCache, halService);
|
||||||
|
}
|
||||||
|
|
||||||
|
getAll(): Observable<RemoteData<BulkAccessConditionOptions>> {
|
||||||
|
return this.findByHref(this.halService.getEndpoint(this.linkPath));
|
||||||
|
}
|
||||||
|
|
||||||
|
// findByPropertyName(name: string): Observable<RemoteData<BulkAccessConditionOptions>> {
|
||||||
|
// return this.findById(name);
|
||||||
|
// }
|
||||||
|
}
|
45
src/app/core/shared/bulk-access-condition-options.model.ts
Normal file
45
src/app/core/shared/bulk-access-condition-options.model.ts
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
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
|
||||||
|
}
|
@@ -6,15 +6,8 @@ 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';
|
||||||
|
|
||||||
// type of the dropdown item that comes from backend
|
|
||||||
export interface AccessControlItem {
|
|
||||||
name: string
|
|
||||||
hasStartDate?: boolean
|
|
||||||
maxStartDate?: string
|
|
||||||
hasEndDate?: boolean
|
|
||||||
maxEndDate?: string
|
|
||||||
}
|
|
||||||
|
|
||||||
// will be used on the form value
|
// will be used on the form value
|
||||||
export interface AccessControlItemValue {
|
export interface AccessControlItemValue {
|
||||||
@@ -23,10 +16,6 @@ export interface AccessControlItemValue {
|
|||||||
endDate?: string;
|
endDate?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AccessControlArrayFormValue {
|
|
||||||
accessControl: AccessControlItemValue[];
|
|
||||||
}
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ds-access-control-array-form',
|
selector: 'ds-access-control-array-form',
|
||||||
templateUrl: './access-control-array-form.component.html',
|
templateUrl: './access-control-array-form.component.html',
|
||||||
|
Reference in New Issue
Block a user