Skip to content

Commit e88a40d

Browse files
[DURACOM-413] update labels, fix sync script, adapt section handling
1 parent b42bf55 commit e88a40d

52 files changed

Lines changed: 11274 additions & 2072 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

scripts/sync-i18n-files.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,11 @@ function parseCliInput() {
3737
.option('-o, --output-file <output>', 'where output of script ends up; mutually exclusive with -i')
3838
.usage('([-d <output-dir>] [-s <source-file>]) || (-t <target-file> (-i | -o <output>) [-s <source-file>])')
3939
.parse(process.argv);
40-
4140
if (!program.targetFile) {
4241
fs.readdirSync(projectRoot(LANGUAGE_FILES_LOCATION)).forEach(file => {
43-
if (!program.sourceFile.toString().endsWith(file)) {
42+
if (program.opts().sourceFile && !program.opts().sourceFile.toString().endsWith(file)) {
4443
const targetFileLocation = projectRoot(LANGUAGE_FILES_LOCATION + "/" + file);
45-
console.log('Syncing file at: ' + targetFileLocation + ' with source file at: ' + program.sourceFile);
44+
console.log('Syncing file at: ' + targetFileLocation + ' with source file at: ' + program.opts().sourceFile);
4645
if (program.outputDir) {
4746
if (!fs.existsSync(program.outputDir)) {
4847
fs.mkdirSync(program.outputDir);
@@ -67,7 +66,7 @@ function parseCliInput() {
6766
console.log(program.outputHelp());
6867
process.exit(1);
6968
}
70-
if (!checkIfFileExists(program.sourceFile)) {
69+
if (!checkIfFileExists(program.opts().sourceFile)) {
7170
console.error('Path of source file is not valid.');
7271
console.log(program.outputHelp());
7372
process.exit(1);
@@ -101,7 +100,7 @@ function syncFileWithSource(pathToTargetFile, pathToOutputFile) {
101100
targetLines.push(line.trim());
102101
}));
103102
progressBar.update(10);
104-
const sourceFile = readFileIfExists(program.sourceFile);
103+
const sourceFile = readFileIfExists(program.opts().sourceFile);
105104
sourceFile.toString().split("\n").forEach((function (line) {
106105
sourceLines.push(line.trim());
107106
}));

src/app/core/provide-core.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
makeEnvironmentProviders,
55
} from '@angular/core';
66
import { APP_CONFIG } from '@dspace/config/app-config.interface';
7+
import { SubmissionCustomUrl } from '@dspace/core/submission/models/submission-custom-url.model';
78

89
import { AuthStatus } from './auth/models/auth-status.model';
910
import { ShortLivedToken } from './auth/models/short-lived-token.model';
@@ -228,4 +229,5 @@ export const models =
228229
StatisticsEndpoint,
229230
CorrectionType,
230231
SupervisionOrder,
232+
SubmissionCustomUrl,
231233
];

src/app/core/router/utils/dso-route.utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ export function getItemPageRoute(item: Item) {
3333
const type = item.firstMetadataValue('dspace.entity.type');
3434
let url = item.uuid;
3535

36-
if (isNotEmpty(item.metadata) && item.hasMetadata('cris.customurl')) {
37-
url = item.firstMetadataValue('cris.customurl');
36+
if (isNotEmpty(item.metadata) && item.hasMetadata('dspace.customurl')) {
37+
url = item.firstMetadataValue('dspace.customurl');
3838
}
3939

4040
return getEntityPageRoute(type, url);
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import {
2+
autoserialize,
3+
inheritSerialization,
4+
} from 'cerialize';
5+
6+
import { typedObject } from '../../cache/builders/build-decorators';
7+
import { HALResource } from '../../shared/hal-resource.model';
8+
import { ResourceType } from '../../shared/resource-type';
9+
import { excludeFromEquals } from '../../utilities/equals.decorators';
10+
import { SUBMISSION_CUSTOM_URL } from './submission-custom-url.resource-type';
11+
12+
@typedObject
13+
@inheritSerialization(HALResource)
14+
export class SubmissionCustomUrl extends HALResource {
15+
16+
static type = SUBMISSION_CUSTOM_URL;
17+
18+
/**
19+
* The object type
20+
*/
21+
@excludeFromEquals
22+
@autoserialize
23+
type: ResourceType;
24+
25+
@autoserialize
26+
url: string;
27+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { ResourceType } from '../../shared/resource-type';
2+
3+
/**
4+
* The resource type for License
5+
*
6+
* Needs to be in a separate file to prevent circular
7+
* dependencies in webpack.
8+
*/
9+
export const SUBMISSION_CUSTOM_URL = new ResourceType('submissioncustomcurl');

src/app/item-page/item-page.resolver.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ describe('itemPageResolver', () => {
102102

103103
});
104104

105-
describe('when item has cris.customurl metadata', () => {
105+
describe('when item has dspace.customurl metadata', () => {
106106

107107

108108
const customUrl = 'my-custom-item';
@@ -126,7 +126,7 @@ describe('itemPageResolver', () => {
126126
return true;
127127
},
128128
metadata: {
129-
'cris.customurl': customUrl,
129+
'dspace.customurl': customUrl,
130130
},
131131
});
132132
itemService = {
@@ -139,7 +139,7 @@ describe('itemPageResolver', () => {
139139
resolver = itemPageResolver;
140140
});
141141

142-
it('should navigate to the new custom URL if cris.customurl is defined and different from route param', (done) => {
142+
it('should navigate to the new custom URL if dspace.customurl is defined and different from route param', (done) => {
143143
spyOn(router, 'navigateByUrl').and.callThrough();
144144

145145
const route = { params: { id: uuid } } as any;
@@ -154,7 +154,7 @@ describe('itemPageResolver', () => {
154154
});
155155
});
156156

157-
it('should not navigate if cris.customurl matches the current route id', (done) => {
157+
it('should not navigate if dspace.customurl matches the current route id', (done) => {
158158
spyOn(router, 'navigateByUrl').and.callThrough();
159159

160160
const route = { params: { id: customUrl } } as any;

src/app/item-page/item-page.resolver.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ export const itemPageResolver: ResolveFn<RemoteData<Item>> = (
6161
if (rd.hasSucceeded && hasValue(rd.payload)) {
6262
const isItemEditPage = state.url.includes('/edit');
6363
let itemRoute = isItemEditPage ? state.url : router.parseUrl(getItemPageRoute(rd.payload)).toString();
64-
if (hasValue(rd.payload.metadata) && rd.payload.hasMetadata('cris.customurl')) {
65-
if (route.params.id !== rd.payload.firstMetadataValue('cris.customurl')) {
66-
const newUrl = itemRoute.replace(route.params.id,rd.payload.firstMetadataValue('cris.customurl'));
64+
if (hasValue(rd.payload.metadata) && rd.payload.hasMetadata('dspace.customurl')) {
65+
if (route.params.id !== rd.payload.firstMetadataValue('dspace.customurl')) {
66+
const newUrl = itemRoute.replace(route.params.id,rd.payload.firstMetadataValue('dspace.customurl'));
6767
router.navigateByUrl(newUrl);
6868
}
6969
} else {

src/app/submission/edit/submission-edit.component.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@
66
[submissionErrors]="submissionErrors"
77
[item]="item"
88
[collectionModifiable]="collectionModifiable"
9-
[submissionId]="submissionId"></ds-submission-form>
9+
[submissionId]="submissionId"
10+
[entityType]="entityType"></ds-submission-form>
1011
</div>

src/app/submission/edit/submission-edit.component.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ export class SubmissionEditComponent implements OnDestroy, OnInit {
6767
*/
6868
public collectionModifiable: boolean | null = null;
6969

70+
/**
71+
* The entity type of the submission
72+
* @type {string}
73+
*/
74+
public entityType: string;
7075

7176
/**
7277
* The list of submission's sections
@@ -155,6 +160,11 @@ export class SubmissionEditComponent implements OnDestroy, OnInit {
155160
this.notificationsService.info(null, this.translate.get('submission.general.cannot_submit'));
156161
this.router.navigate(['/mydspace']);
157162
} else {
163+
const collection = submissionObjectRD.payload.collection as Collection;
164+
const entityType = collection.hasMetadata('dspace.entity.type') ? collection.firstMetadataValue('dspace.entity.type') : null;
165+
if (hasValue(entityType)) {
166+
this.entityType = entityType;
167+
}
158168
const { errors } = submissionObjectRD.payload;
159169
this.submissionErrors = parseSectionErrors(errors);
160170
this.submissionId = submissionObjectRD.payload.id.toString();

src/app/submission/form/submission-form.component.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
@for (object of $any(submissionSections | async); track object) {
3737
<ds-submission-section-container [collectionId]="collectionId"
3838
[submissionId]="submissionId"
39+
[entityType]="entityType"
3940
[sectionData]="$any(object)">
4041
</ds-submission-section-container>
4142
}

0 commit comments

Comments
 (0)