Skip to content

Admin: Add customize templates feature#519

Open
BlueTechie wants to merge 1 commit intonextfrom
rds/upload-custom-templates
Open

Admin: Add customize templates feature#519
BlueTechie wants to merge 1 commit intonextfrom
rds/upload-custom-templates

Conversation

@BlueTechie
Copy link
Contributor

Description

Feature

What does this PR do?

Backend PR description for context: damap-org/damap-backend#471

In short: this frontend PR adds an admin/templates page where admins can add custom variations of the Science Europe template. They can also delete these custom templates and toggle the active status of all templates (the 3 base templates as well as the custom ones).

  • Admin Management Page:
    • New EditTemplatesPageComponent for managing export templates.
    • Implemented activation/deactivation toggle. The deactivation toggle is disabled for the last active template.
    • Added custom Science Europe variation upload functionality with .docx extension enforcement (the backend also does this but in a more proper way using the Fits service).
  • Translations:
    • Added translation keys both in the currently used en.json and in the new flat translations.json file.
  • Preview and Export DMP:
    • Only active templates are shown in the dropdown.

Dependencies

Backend PRs: damap-org/damap-backend#471

closes GH-

@BlueTechie BlueTechie force-pushed the rds/upload-custom-templates branch from c46adb6 to c7cf20f Compare February 25, 2026 13:02
Copy link
Contributor

@ValentinFutterer ValentinFutterer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost just small things in the comments, but exporting needs a little bit more testing.

Comment on lines +43 to +54
.current-grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 10px;
padding: 0 8px 8px 8px;
}

.current-grid .centered {
grid-column: 1 / span 3;
margin: 0 auto;
justify-self: center;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 grid columns work fine mostly, but it leaves a lot of empty space here

Image

Its not backbreaking but maybe there is an easy solution to make it dynamic. Otherwise its also fine as is.

Comment on lines +136 to +138
if (!isExtensionValid && !isMimeValid) {
this.feedbackService.error(
'Only Microsoft Word files (.docx or .doc) are allowed.',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This text is hardcoded and not necessary. There is a second error that pops up and says something similar.

const config$ = this.http.get<Config>(`${host}config`);
const rawConfig = await lastValueFrom(config$);
this.config = rawConfig;
this.configSubject.next(rawConfig);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can remove this line and all mentions of the subject from the file - its never queried only written to.

Comment on lines +113 to +119
next: () => {
this.configService.refreshConfig().then(() => {
this.feedbackService.success('admin.templates.success.status');
});
},
error: () => {
template.active = previousState;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just FYI, this doesnt take into account the config call failing, so the frontend just continues as is. Maybe add error handling to the refresh method?

Comment on lines +170 to +171
"admin.template": "Templates",
"admin.edit.templates": "Edit templates",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"admin.template": "Templates",
"admin.edit.templates": "Edit templates",
"admin.template.sectionTitle": "Templates",
"admin.edit.templates": "Edit templates",

check the conventions on naming

}

private isValidWordFile(file: File): boolean {
const allowedExtensions = ['.docx', '.doc'];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The file upload component itself only allows .docx

Comment on lines +146 to +157
const previousTemplates = this.localTemplates();

this.localTemplates.update(templates => templates.filter(t => t.id !== id));

this.backendService.deleteExportTemplate(id).subscribe({
next: () => {
this.configService.refreshConfig().then(() => {
this.feedbackService.success('admin.templates.success.delete');
});
},
error: err => {
this.localTemplates.set(previousTemplates);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No ned to store previous templates, you could just pdate local templates in the success case.

});
}

private isValidWordFile(file: File): boolean {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should also be a basic size check. Max size can be generous.

Comment on lines +133 to 136
if (result && result !== 'cancel') {
const template = result;
if (!funderSupported) {
this.exportDmpType = template;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Normal export fails when you deactivate the template type the project has. For example deactivate HE template and then try to export a HE project DMP. Testexporting again using preview and export in different scenarios.

Comment on lines +21 to +25
readonly activeTemplates = computed(() => {
const config = this.configService.getConfig();
// Filter for active templates only
return config?.templates?.filter(t => t.active) || [];
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method is duplicated, maybe put it inside of configservice or config?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants