Skip to content

Commit

Permalink
Merge pull request DSpace#1475 from 4Science/CST-4506_item_embargo
Browse files Browse the repository at this point in the history
Add submission section for item embargo
  • Loading branch information
tdonohue authored Jan 31, 2022
2 parents 3d7fcef + 67d6c6f commit 0fbd48e
Show file tree
Hide file tree
Showing 35 changed files with 1,379 additions and 84 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
* Model class for an Item Access Condition
*/
export class AccessesConditionOption {

/**
* The name for this Access Condition
*/
name: string;

/**
* The groupName for this Access Condition
*/
groupName: string;

/**
* A boolean representing if this Access Condition has a start date
*/
hasStartDate: boolean;

/**
* A boolean representing if this Access Condition has an end date
*/
hasEndDate: boolean;

/**
* Maximum value of the start date
*/
endDateLimit?: string;

/**
* Maximum value of the end date
*/
startDateLimit?: string;

/**
* Maximum value of the start date
*/
maxStartDate?: string;

/**
* Maximum value of the end date
*/
maxEndDate?: string;
}
42 changes: 42 additions & 0 deletions src/app/core/config/models/config-submission-access.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { autoserialize, deserialize, inheritSerialization } from 'cerialize';
import { typedObject } from '../../cache/builders/build-decorators';
import { ConfigObject } from './config.model';
import { AccessesConditionOption } from './config-accesses-conditions-options.model';
import { SUBMISSION_ACCESSES_TYPE } from './config-type';
import { HALLink } from '../../shared/hal-link.model';

/**
* Class for the configuration describing the item accesses condition
*/
@typedObject
@inheritSerialization(ConfigObject)
export class SubmissionAccessModel extends ConfigObject {
static type = SUBMISSION_ACCESSES_TYPE;

/**
* A list of available item access conditions
*/
@autoserialize
accessConditionOptions: AccessesConditionOption[];

/**
* Boolean that indicates whether the current item must be findable via search or browse.
*/
@autoserialize
discoverable: boolean;

/**
* Boolean that indicates whether or not the user can change the discoverable flag.
*/
@autoserialize
canChangeDiscoverable: boolean;

/**
* The links to all related resources returned by the rest api.
*/
@deserialize
_links: {
self: HALLink
};

}
10 changes: 10 additions & 0 deletions src/app/core/config/models/config-submission-accesses.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { inheritSerialization } from 'cerialize';
import { typedObject } from '../../cache/builders/build-decorators';
import { SUBMISSION_ACCESSES_TYPE } from './config-type';
import { SubmissionAccessModel } from './config-submission-access.model';

@typedObject
@inheritSerialization(SubmissionAccessModel)
export class SubmissionAccessesModel extends SubmissionAccessModel {
static type = SUBMISSION_ACCESSES_TYPE;
}
2 changes: 2 additions & 0 deletions src/app/core/config/models/config-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ export const SUBMISSION_SECTION_TYPE = new ResourceType('submissionsection');
export const SUBMISSION_UPLOADS_TYPE = new ResourceType('submissionuploads');

export const SUBMISSION_UPLOAD_TYPE = new ResourceType('submissionupload');

export const SUBMISSION_ACCESSES_TYPE = new ResourceType('submissionaccessoption');
42 changes: 42 additions & 0 deletions src/app/core/config/submission-accesses-config.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { Injectable } from '@angular/core';
import { ConfigService } from './config.service';
import { RequestService } from '../data/request.service';
import { HALEndpointService } from '../shared/hal-endpoint.service';
import { ObjectCacheService } from '../cache/object-cache.service';
import { dataService } from '../cache/builders/build-decorators';
import { SUBMISSION_ACCESSES_TYPE } from './models/config-type';
import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service';
import { Store } from '@ngrx/store';
import { CoreState } from '../core.reducers';
import { NotificationsService } from '../../shared/notifications/notifications.service';
import { HttpClient } from '@angular/common/http';
import { DefaultChangeAnalyzer } from '../data/default-change-analyzer.service';
import { ConfigObject } from './models/config.model';
import { SubmissionAccessesModel } from './models/config-submission-accesses.model';
import { RemoteData } from '../data/remote-data';
import { Observable } from 'rxjs';
import { FollowLinkConfig } from '../../shared/utils/follow-link-config.model';

/**
* Provides methods to retrieve, from REST server, bitstream access conditions configurations applicable during the submission process.
*/
@Injectable()
@dataService(SUBMISSION_ACCESSES_TYPE)
export class SubmissionAccessesConfigService extends ConfigService {
constructor(
protected requestService: RequestService,
protected rdbService: RemoteDataBuildService,
protected store: Store<CoreState>,
protected objectCache: ObjectCacheService,
protected halService: HALEndpointService,
protected notificationsService: NotificationsService,
protected http: HttpClient,
protected comparator: DefaultChangeAnalyzer<SubmissionAccessesModel>
) {
super(requestService, rdbService, null, objectCache, halService, notificationsService, http, comparator, 'submissionaccessoptions');
}

findByHref(href: string, useCachedVersionIfAvailable = true, reRequestOnStale = true, ...linksToFollow): Observable<RemoteData<SubmissionAccessesModel>> {
return super.findByHref(href, useCachedVersionIfAvailable, reRequestOnStale, ...linksToFollow as FollowLinkConfig<ConfigObject>[]) as Observable<RemoteData<SubmissionAccessesModel>>;
}
}
10 changes: 4 additions & 6 deletions src/app/core/core.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@ import { CommonModule } from '@angular/common';
import { HttpClient } from '@angular/common/http';
import { ModuleWithProviders, NgModule, Optional, SkipSelf } from '@angular/core';

import {
DynamicFormLayoutService,
DynamicFormService,
DynamicFormValidationService
} from '@ng-dynamic-forms/core';
import { DynamicFormLayoutService, DynamicFormService, DynamicFormValidationService } from '@ng-dynamic-forms/core';
import { EffectsModule } from '@ngrx/effects';

import { Action, StoreConfig, StoreModule } from '@ngrx/store';
Expand Down Expand Up @@ -165,6 +161,7 @@ import { Root } from './data/root.model';
import { SearchConfig } from './shared/search/search-filters/search-config.model';
import { SequenceService } from './shared/sequence.service';
import { GroupDataService } from './eperson/group-data.service';
import { SubmissionAccessesModel } from './config/models/config-submission-accesses.model';

/**
* When not in production, endpoint responses can be mocked for testing purposes
Expand Down Expand Up @@ -347,7 +344,8 @@ export const models =
Registration,
UsageReport,
Root,
SearchConfig
SearchConfig,
SubmissionAccessesModel
];

@NgModule({
Expand Down
25 changes: 25 additions & 0 deletions src/app/core/submission/models/access-condition.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* An interface to represent an access condition.
*/
export class AccessConditionObject {

/**
* The access condition id
*/
id: string;

/**
* The access condition name
*/
name: string;

/**
* Possible start date of the access condition
*/
startDate: string;

/**
* Possible end date of the access condition
*/
endDate: string;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { ResourceType } from '../../shared/resource-type';

/**
* The resource type for Accesses section
*
* Needs to be in a separate file to prevent circular
* dependencies in webpack.
*/
export const SUBMISSION_ACCESSES = new ResourceType('submissionaccesses');
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { AccessConditionObject } from './access-condition.model';

/**
* An interface to represent item's access condition.
*/
export class SubmissionItemAccessConditionObject extends AccessConditionObject {

}
Original file line number Diff line number Diff line change
@@ -1,25 +1,8 @@
import { AccessConditionObject } from './access-condition.model';

/**
* An interface to represent bitstream's access condition.
*/
export class SubmissionUploadFileAccessConditionObject {

/**
* The access condition id
*/
id: string;

/**
* The access condition name
*/
name: string;

/**
* Possible start date of the access condition
*/
startDate: string;
export class SubmissionUploadFileAccessConditionObject extends AccessConditionObject {

/**
* Possible end date of the access condition
*/
endDate: string;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { SubmissionItemAccessConditionObject } from './submission-item-access-condition.model';

/**
* An interface to represent the submission's item accesses condition.
*/
export interface WorkspaceitemSectionAccessesObject {
/**
* The access condition id
*/
id: string;

/**
* Boolean that indicates whether the current item must be findable via search or browse.
*/
discoverable: boolean;

/**
* A list of available item access conditions
*/
accessConditions: SubmissionItemAccessConditionObject[];
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { WorkspaceitemSectionAccessesObject } from './workspaceitem-section-accesses.model';
import { WorkspaceitemSectionFormObject } from './workspaceitem-section-form.model';
import { WorkspaceitemSectionLicenseObject } from './workspaceitem-section-license.model';
import { WorkspaceitemSectionUploadObject } from './workspaceitem-section-upload.model';
Expand All @@ -19,4 +20,5 @@ export type WorkspaceitemSectionDataType
| WorkspaceitemSectionFormObject
| WorkspaceitemSectionLicenseObject
| WorkspaceitemSectionCcLicenseObject
| WorkspaceitemSectionAccessesObject
| string;
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
<div>
<ng-container #componentViewContainer></ng-container>
</div>
<small *ngIf="hasHint && ((model.repeatable === false && (isRelationship === false || value?.value === null)) || (model.repeatable === true && context?.index === context?.context?.groups?.length - 1)) && (!showErrorMessages || errorMessages.length === 0)"

<small *ngIf="hasHint && ((!model.repeatable && (isRelationship === false || value?.value === null)) || (model.repeatable === true && context?.index === context?.context?.groups?.length - 1)) && (!showErrorMessages || errorMessages.length === 0)"
class="text-muted ds-hint" [innerHTML]="model.hint | translate" [ngClass]="getClass('element', 'hint')"></small>
<!-- In case of repeatable fields show empty space for all elements except the first -->
<div *ngIf="context?.index !== null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
[cdkDragDisabled]="dragDisabled"
[cdkDragPreviewClass]="'ds-submission-reorder-dragging'">
<!-- Item content -->
<div class="drag-handle" [class.invisible]="dragDisabled" tabindex="0">
<i class="drag-icon fas fa-grip-vertical fa-fw" ></i>
<div class="drag-handle" [class.drag-disable]="dragDisabled" tabindex="0">
<i class="drag-icon fas fa-grip-vertical fa-fw" [class.drag-disable]="dragDisabled" ></i>
</div>
<ng-container *ngTemplateOutlet="startTemplate?.templateRef; context: groupModel"></ng-container>
<ds-dynamic-form-control-container *ngFor="let _model of groupModel.group"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@
:host {
display: block;
}

.drag-disable {
visibility: hidden !important;
&:hover, &:focus {
cursor: default;
.drag-icon {
visibility: hidden !important;
}
}
}
.cdk-drag {
margin-left: calc(-2.3 * var(--bs-spacer));
margin-right: calc(-0.5 * var(--bs-spacer));
Expand Down
Loading

0 comments on commit 0fbd48e

Please sign in to comment.