Skip to content

Commit a36d2cf

Browse files
authored
Fix/201 - Add to Collection (#176)
* feat(add-to-collection-api): fixed comments * feat(add-to-collection-api): added shared bookmarks service * feat(add-to-collection-api): shorten import
1 parent deef6b7 commit a36d2cf

File tree

40 files changed

+539
-382
lines changed

40 files changed

+539
-382
lines changed

src/app/app.routes.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ import { provideStates } from '@ngxs/store';
22

33
import { Routes } from '@angular/router';
44

5-
import { CollectionsState } from '@osf/features/collections/store/collections';
6-
import { ProjectsState } from '@shared/stores';
5+
import { BookmarksState, ProjectsState } from '@shared/stores';
76

87
import { MyProfileResourceFiltersOptionsState } from './features/my-profile/components/filters/store';
98
import { MyProfileResourceFiltersState } from './features/my-profile/components/my-profile-resource-filters/store';
@@ -74,7 +73,7 @@ export const routes: Routes = [
7473
path: 'my-projects',
7574
loadComponent: () =>
7675
import('./features/my-projects/my-projects.component').then((mod) => mod.MyProjectsComponent),
77-
providers: [provideStates([CollectionsState])],
76+
providers: [provideStates([BookmarksState])],
7877
},
7978
{
8079
path: 'my-projects/:id',
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { ComponentFixture, TestBed } from '@angular/core/testing';
2+
3+
import { AddToCollectionConfirmationDialogComponent } from './add-to-collection-confirmation-dialog.component';
4+
5+
describe('AddToCollectionConfirmationDialogComponent', () => {
6+
let component: AddToCollectionConfirmationDialogComponent;
7+
let fixture: ComponentFixture<AddToCollectionConfirmationDialogComponent>;
8+
9+
beforeEach(async () => {
10+
await TestBed.configureTestingModule({
11+
imports: [AddToCollectionConfirmationDialogComponent],
12+
}).compileComponents();
13+
14+
fixture = TestBed.createComponent(AddToCollectionConfirmationDialogComponent);
15+
component = fixture.componentInstance;
16+
fixture.detectChanges();
17+
});
18+
19+
it('should create', () => {
20+
expect(component).toBeTruthy();
21+
});
22+
});

src/app/features/collections/components/add-to-collection/add-to-collection.component.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
@use "assets/styles/variables" as var;
21
@use "assets/styles/mixins" as mix;
32

43
:host {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { ComponentFixture, TestBed } from '@angular/core/testing';
2+
3+
import { CollectionMetadataStepComponent } from './collection-metadata-step.component';
4+
5+
describe('CollectionMetadataStepComponent', () => {
6+
let component: CollectionMetadataStepComponent;
7+
let fixture: ComponentFixture<CollectionMetadataStepComponent>;
8+
9+
beforeEach(async () => {
10+
await TestBed.configureTestingModule({
11+
imports: [CollectionMetadataStepComponent],
12+
}).compileComponents();
13+
14+
fixture = TestBed.createComponent(CollectionMetadataStepComponent);
15+
component = fixture.componentInstance;
16+
fixture.detectChanges();
17+
});
18+
19+
it('should create', () => {
20+
expect(component).toBeTruthy();
21+
});
22+
});

src/app/features/collections/components/add-to-collection/project-contributors-step/project-contributors-step.component.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,20 @@ <h3>{{ 'collections.addToCollection.projectContributors' | translate }}</h3>
3535
class="w-full"
3636
[contributors]="projectContributors()"
3737
[isLoading]="isContributorsLoading()"
38-
[showCuratorColumn]="true"
38+
[showCuratorColumn]="false"
3939
(remove)="handleRemoveContributor($event)"
4040
></osf-contributors-list>
4141

4242
<div class="flex justify-content-end gap-3 mt-4 w-full">
4343
<p-button
4444
[label]="'registries.metadata.addContributors' | translate"
4545
severity="secondary"
46+
[disabled]="isContributorsLoading()"
4647
(click)="handleAddContributor()"
4748
/>
4849
<p-button
49-
[loading]="isContributorsSubmitting()"
50+
[disabled]="isContributorsLoading() || !projectContributors().length"
5051
(click)="handleSaveContributors()"
51-
[disabled]="!projectContributors().length"
5252
[label]="'common.buttons.saveAndContinue' | translate"
5353
/>
5454
</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { ComponentFixture, TestBed } from '@angular/core/testing';
2+
3+
import { ProjectContributorsStepComponent } from './project-contributors-step.component';
4+
5+
describe('ProjectContributorsStepComponent', () => {
6+
let component: ProjectContributorsStepComponent;
7+
let fixture: ComponentFixture<ProjectContributorsStepComponent>;
8+
9+
beforeEach(async () => {
10+
await TestBed.configureTestingModule({
11+
imports: [ProjectContributorsStepComponent],
12+
}).compileComponents();
13+
14+
fixture = TestBed.createComponent(ProjectContributorsStepComponent);
15+
component = fixture.componentInstance;
16+
fixture.detectChanges();
17+
});
18+
19+
it('should create', () => {
20+
expect(component).toBeTruthy();
21+
});
22+
});

src/app/features/collections/components/add-to-collection/project-contributors-step/project-contributors-step.component.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ export class ProjectContributorsStepComponent {
4242

4343
protected readonly projectContributors = select(ContributorsSelectors.getContributors);
4444
protected readonly isContributorsLoading = select(ContributorsSelectors.isContributorsLoading);
45-
protected readonly isContributorsSubmitting = select(ContributorsSelectors.isContributorsSubmitting);
4645
protected readonly selectedProject = select(ProjectsSelectors.getSelectedProject);
4746

4847
private initialContributors = signal<ContributorModel[]>([]);

src/app/features/collections/components/add-to-collection/project-metadata-step/project-metadata-step.component.html

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,18 +52,10 @@ <h3>{{ 'collections.addToCollection.projectMetadata' | translate }}</h3>
5252
<ng-template class="m-0" #content>
5353
<p class="pt-3">{{ 'collections.addToCollection.projectMetadataMessage' | translate }}</p>
5454
<form [formGroup]="projectMetadataForm" class="flex flex-column gap-4 mt-4">
55-
<div class="flex flex-column gap-1">
56-
<label for="title">
57-
{{ 'collections.addToCollection.form.title' | translate }}
58-
</label>
59-
<input pInputText id="title" type="text" [formControlName]="ProjectMetadataFormControls.Title" />
60-
@let titleControl = projectMetadataForm.controls[ProjectMetadataFormControls.Title];
61-
@if (titleControl.errors?.['required'] && (titleControl.touched || titleControl.dirty)) {
62-
<p-message class="simple-variant flex mt-1" severity="error" variant="simple" size="small">
63-
{{ 'collections.addToCollection.form.fieldRequired' | translate }}
64-
</p-message>
65-
}
66-
</div>
55+
<osf-text-input
56+
label="collections.addToCollection.form.title"
57+
[control]="projectMetadataForm.controls[ProjectMetadataFormControls.Title]"
58+
/>
6759

6860
<div class="flex flex-column gap-1">
6961
<label for="description">
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { ComponentFixture, TestBed } from '@angular/core/testing';
2+
3+
import { ProjectMetadataStepComponent } from './project-metadata-step.component';
4+
5+
describe('ProjectMetadataStepComponent', () => {
6+
let component: ProjectMetadataStepComponent;
7+
let fixture: ComponentFixture<ProjectMetadataStepComponent>;
8+
9+
beforeEach(async () => {
10+
await TestBed.configureTestingModule({
11+
imports: [ProjectMetadataStepComponent],
12+
}).compileComponents();
13+
14+
fixture = TestBed.createComponent(ProjectMetadataStepComponent);
15+
component = fixture.componentInstance;
16+
fixture.detectChanges();
17+
});
18+
19+
it('should create', () => {
20+
expect(component).toBeTruthy();
21+
});
22+
});

src/app/features/collections/components/add-to-collection/project-metadata-step/project-metadata-step.component.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { Card } from 'primeng/card';
77
import { Chip } from 'primeng/chip';
88
import { DatePicker } from 'primeng/datepicker';
99
import { Divider } from 'primeng/divider';
10-
import { InputText } from 'primeng/inputtext';
1110
import { Message } from 'primeng/message';
1211
import { Select, SelectChangeEvent } from 'primeng/select';
1312
import { Step, StepItem, StepPanel } from 'primeng/stepper';
@@ -49,7 +48,6 @@ import { ProjectsSelectors } from '@shared/stores/projects/projects.selectors';
4948
imports: [
5049
Button,
5150
TranslatePipe,
52-
InputText,
5351
ReactiveFormsModule,
5452
Textarea,
5553
FormsModule,

0 commit comments

Comments
 (0)