Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 0 additions & 111 deletions src/app/components/auth-dialog/auth-dialog.component.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/app/components/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export { ActionbarComponent } from './actionbar/actionbar.component';
export { AuthDialogComponent } from './auth-dialog/auth-dialog.component';
export { AuthDialogComponent } from '../dialogs/auth-dialog/auth-dialog.component';
export { CompilationDetailComponent } from './compilation-detail/compilation-detail.component';
export { DetailEntityComponent } from './entity-detail/detail-entity/detail-entity.component';
export { EntityDetailComponent } from './entity-detail/entity-detail.component';
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/metadata/agents/agents.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@

<p class="sub-headers">{{ 'Assigned role(s)' | translate }}</p>
<div class="role-selection">
@for (role of availableRoles; track role) {
@for (role of availableRoles(); track role) {
<mat-checkbox color="primary" [(ngModel)]="role.checked">
{{ role.value }}
</mat-checkbox>
Expand Down
42 changes: 20 additions & 22 deletions src/app/components/metadata/agents/agents.component.ts

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Works for now, but we could switch to Angular Signal Forms and replace some getters with computed-signals instead.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
signal,
SimpleChanges,
viewChild,
ViewChild,
} from '@angular/core';
import { FormControl, FormsModule, ReactiveFormsModule } from '@angular/forms';

Expand All @@ -26,7 +25,7 @@ import { MatIconModule } from '@angular/material/icon';
import { MatInputModule } from '@angular/material/input';
import { MatTabChangeEvent, MatTabGroup, MatTabsModule } from '@angular/material/tabs';

import { Address, AnyEntity, ContactReference, Institution, Person, Tag } from 'src/app/metadata';
import { Address, AnyEntity, ContactReference, Institution, Person } from 'src/app/metadata';
import { TranslatePipe } from '../../../pipes/translate.pipe';

import {
Expand All @@ -44,7 +43,6 @@ import { AccountService, BackendService } from 'src/app/services';
import { MetadataCommunicationService } from 'src/app/services/metadata-communication.service';
import { AgentListComponent } from './agent-list/agent-list.component';
import {
Collection,
IInstitution,
IPerson,
isAddress,
Expand Down Expand Up @@ -284,10 +282,10 @@ export class AgentsComponent implements OnDestroy, OnChanges, OnInit {

selectedTabIndex = 0;

availableRoles = [
availableRoles = signal([
{ type: 'RIGHTS_OWNER', value: 'Rightsowner', checked: false },
{ type: 'CONTACT_PERSON', value: 'Contact person', checked: false },
];
]);

newCustomRole = { value: '', checked: false };

Expand Down Expand Up @@ -323,7 +321,7 @@ export class AgentsComponent implements OnDestroy, OnChanges, OnInit {

get atLeastOneRoleSelected(): boolean {
return (
this.availableRoles.some(role => role.checked) ||
this.availableRoles().some(role => role.checked) ||
(this.newCustomRole.checked && this.newCustomRole.value != '')
);
}
Expand All @@ -333,7 +331,7 @@ export class AgentsComponent implements OnDestroy, OnChanges, OnInit {
}

get currentRoleSelection(): string[] {
const availableRoleTypes = this.availableRoles
const availableRoleTypes = this.availableRoles()
.filter(role => role.checked)
.map(role => role.type);

Expand Down Expand Up @@ -422,11 +420,13 @@ export class AgentsComponent implements OnDestroy, OnChanges, OnInit {
if (this.isUpdating()) {
this.clearRoleSelection();

for (const role of agent.roles[this.entityId()] ?? []) {
for (const roleOption of this.availableRoles) {
if (roleOption.type === role) roleOption.checked = true;
}
}
const rolesToActivate = agent.roles[this.entityId()] ?? [];

this.availableRoles.update(roles =>
roles.map(role =>
rolesToActivate.includes(role.type) ? { ...role, checked: true } : role,
),
);
}
}

Expand Down Expand Up @@ -511,13 +511,13 @@ export class AgentsComponent implements OnDestroy, OnChanges, OnInit {
private addRoleIfNotExists(newRoleName: string) {
const entity = this.entity();
const cleanedUpRoleName = entity.formatRoleLabel(newRoleName);
if (!cleanedUpRoleName || this.availableRoles.some(r => r.value === cleanedUpRoleName)) return;
if (!cleanedUpRoleName || this.availableRoles().some(r => r.value === cleanedUpRoleName))
return;

this.availableRoles.push({
type: cleanedUpRoleName,
value: cleanedUpRoleName,
checked: false,
});
this.availableRoles.update(roles => [
...roles,
{ type: cleanedUpRoleName, value: cleanedUpRoleName, checked: false },
]);
}

public updateAgent() {
Expand Down Expand Up @@ -592,9 +592,7 @@ export class AgentsComponent implements OnDestroy, OnChanges, OnInit {
}

clearRoleSelection() {
this.availableRoles.forEach(role => {
role.checked = false;
});
this.availableRoles.update(roles => roles.map(role => ({ ...role, checked: false })));
this.newCustomRole = { value: '', checked: false };
}

Expand All @@ -615,7 +613,7 @@ export class AgentsComponent implements OnDestroy, OnChanges, OnInit {
}

ngOnInit(): void {
const fixedRoles = this.availableRoles.map(r => r.type);
const fixedRoles = this.availableRoles().map(r => r.type);
const allAgents = [...this.entity().persons, ...this.entity().institutions];

for (const agent of allAgents) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<button
mat-flat-button
color="primary"
[disabled]="!isFormValid"
[disabled]="!isFormValid()"
(click)="addNewCreationData()"
>
{{ 'Add' | translate }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export class CreationComponent implements OnInit {

addNewCreationData() {
const value = this.form.value;
if (!this.isFormValid()) return;

let formattedDate = '';
if (value.start && value.end) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div>
@for (data of optionalData(); track $index) {
<div class="card-wrapper">
<div class="card">
<div class="card" [class.is-editable]="propertyType() === 'biblio'">
@switch (propertyType()) {
@case ('dimension') {
@if (data | isDimensionTuple) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
border-radius: 1rem !important;
justify-items: center;
justify-content: center;
padding-right: 45px;
}

.card.is-editable {
padding-right: 90px;
}

div.card .actions {
Expand Down
Loading
Loading