-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP: adding /publications/new and /publications/:pubId pages
- Loading branch information
Showing
14 changed files
with
187 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
1 change: 1 addition & 0 deletions
1
webapp-ng/src/app/components/publication-detail/publication-detail.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<p>publication-detail works!</p> |
23 changes: 23 additions & 0 deletions
23
webapp-ng/src/app/components/publication-detail/publication-detail.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { PublicationDetailComponent } from './publication-detail.component'; | ||
|
||
describe('PublicationDetailComponent', () => { | ||
let component: PublicationDetailComponent; | ||
let fixture: ComponentFixture<PublicationDetailComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [PublicationDetailComponent] | ||
}) | ||
.compileComponents(); | ||
|
||
fixture = TestBed.createComponent(PublicationDetailComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
13 changes: 13 additions & 0 deletions
13
webapp-ng/src/app/components/publication-detail/publication-detail.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Component } from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
|
||
@Component({ | ||
selector: 'app-publication-detail', | ||
standalone: true, | ||
imports: [CommonModule], | ||
templateUrl: './publication-detail.component.html', | ||
styleUrl: './publication-detail.component.css' | ||
}) | ||
export class PublicationDetailComponent { | ||
|
||
} |
35 changes: 34 additions & 1 deletion
35
webapp-ng/src/app/components/publication-edit/publication-edit.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,54 @@ | ||
import { Component, Input, Output, EventEmitter } from '@angular/core'; | ||
import { Publication } from 'src/app/core/modules/openapi/model/publication'; // Adjust the import path as necessary | ||
import { Publication } from 'src/app/core/modules/openapi/model/publication'; | ||
import {PublicationService} from "../publication-list/publication.service"; | ||
import {FormsModule} from "@angular/forms"; // Adjust the import path as necessary | ||
|
||
@Component({ | ||
selector: 'app-publication-edit', | ||
templateUrl: './publication-edit.component.html', | ||
standalone: true, | ||
imports: [ | ||
FormsModule | ||
], | ||
styleUrls: ['./publication-edit.component.css'] | ||
}) | ||
export class PublicationEditComponent { | ||
@Input() publication!: Publication;// The publication to edit | ||
@Output() save = new EventEmitter<Publication>(); // Event to emit when the publication is saved | ||
@Output() cancel = new EventEmitter<void>(); // Event to emit when the edit is canceled | ||
|
||
constructor(private publicationService: PublicationService) { | ||
} | ||
|
||
onSave() { | ||
this.save.emit(this.publication); | ||
} | ||
|
||
onCancel() { | ||
this.cancel.emit(); | ||
} | ||
|
||
saveEdit(pub: Publication) { | ||
// Call the service to save the publication | ||
this.publicationService.updatePublication(pub).subscribe({ | ||
next: () => { | ||
// show message that the record was saved | ||
console.log("Publication saved"); | ||
}, | ||
error: (err) => { | ||
// show error message | ||
console.error("Error saving publication", err); | ||
} | ||
}); | ||
} | ||
|
||
onDelete(pub: Publication) { | ||
// nothing to do | ||
this.publicationService.deletePublication(pub.pubKey!).subscribe((pub) => { | ||
console.log(pub); | ||
}); | ||
|
||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
2 changes: 2 additions & 0 deletions
2
webapp-ng/src/app/components/publication-new/publication-new.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<p>publication-new works!</p> | ||
<app-publication-edit [publication]="newPublication"></app-publication-edit> |
23 changes: 23 additions & 0 deletions
23
webapp-ng/src/app/components/publication-new/publication-new.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { PublicationNewComponent } from './publication-new.component'; | ||
|
||
describe('PublicationNewComponent', () => { | ||
let component: PublicationNewComponent; | ||
let fixture: ComponentFixture<PublicationNewComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [PublicationNewComponent] | ||
}) | ||
.compileComponents(); | ||
|
||
fixture = TestBed.createComponent(PublicationNewComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
52 changes: 52 additions & 0 deletions
52
webapp-ng/src/app/components/publication-new/publication-new.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import {Component} from '@angular/core'; | ||
import {CommonModule} from '@angular/common'; | ||
import {Publication} from "../../core/modules/openapi"; | ||
import {PublicationService} from "../publication-list/publication.service"; | ||
import {PublicationEditComponent} from "../publication-edit/publication-edit.component"; | ||
|
||
@Component({ | ||
selector: 'app-publication-new', | ||
standalone: true, | ||
imports: [CommonModule, PublicationEditComponent], | ||
templateUrl: './publication-new.component.html', | ||
styleUrl: './publication-new.component.css' | ||
}) | ||
export class PublicationNewComponent { | ||
newPublication: Publication; | ||
|
||
constructor(private publicationService: PublicationService) { | ||
this.newPublication = this.onNew(); | ||
} | ||
|
||
onNew(): Publication { | ||
return { | ||
title: "title", | ||
authors: [ | ||
"string" | ||
], | ||
year: 2023, | ||
citation: "citation", | ||
pubmedid: "pubmed-id", | ||
doi: "doi", | ||
endnoteid: 0, | ||
url: "url", | ||
wittid: 0, | ||
biomodelRefs: [], | ||
mathmodelRefs: [], | ||
date: "2023-12-28" | ||
}; | ||
} | ||
|
||
saveEdit(pub: Publication) { | ||
// Call the service to save the publication | ||
this.publicationService.updatePublication(pub).subscribe({ | ||
next: () => { | ||
console.log("saved publication"); | ||
}, | ||
error: (err) => { | ||
console.error("Error saving publication", err); | ||
} | ||
}); | ||
} | ||
|
||
} |