Skip to content

Commit

Permalink
publication edit form properly handle biomodel and mathmodel ref ids
Browse files Browse the repository at this point in the history
  • Loading branch information
jcschaff committed Jun 19, 2024
1 parent 78d45e7 commit 6f38035
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,22 @@ <h3 *ngIf="publication.pubKey; else newPublication">{{ "Edit Publication, key="
</div>
<div class="row">
<div class="col" style="text-align: right;"><label for="biomodelRefs">Biomodel IDs:</label></div>
<div class="col"><textarea type="text" id="biomodelRefs" [ngModel]="publication.biomodelRefs?.join(',')"
(ngModelChange)="publication.biomodelRefs = $event.split(',')" name="biomodelRefs"></textarea>
<div class="col">
<textarea type="text" id="biomodelRefs"
[ngModel]="getBmKeys(publication.biomodelRefs)"
(ngModelChange)="setBmRefsFromBmKeys($event.split(','))"
name="biomodelRefs">
</textarea>
</div>
</div>
<div class="row">
<div class="col" style="text-align: right;"><label for="mathmodelRefs">Mathmodel IDs:</label></div>
<div class="col"><textarea type="text" id="mathmodelRefs" [ngModel]="publication.mathmodelRefs?.join(',')"
(ngModelChange)="publication.mathmodelRefs = $event.split(',')" name="mathmodelRefs"></textarea>
<div class="col">
<textarea type="text" id="mathmodelRefs"
[ngModel]="getMmKeys(publication.mathmodelRefs)"
(ngModelChange)="setMmRefsFromMmKeys($event.split(','))"
name="mathmodelRefs">
</textarea>
</div>
</div>
<div class="row">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
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 {BiomodelRef, MathmodelRef} from "../../core/modules/openapi"; // Adjust the import path as necessary

@Component({
selector: 'app-publication-edit',
Expand All @@ -18,4 +19,26 @@ export class PublicationEditComponent {
onCancel() {
this.cancel.emit();
}

getBmKeys(biomodelRefs: Array<BiomodelRef> | undefined): string {
if (!biomodelRefs) return "";
return biomodelRefs?.map(bm => bm.bmKey?.toString()).join(", ");
}

setBmRefsFromBmKeys(bmKeyString: string[]) {
this.publication.biomodelRefs = bmKeyString.map(bmKey => {
return {bmKey: parseInt(bmKey)};
});
}

getMmKeys(mathmodelRefs: Array<MathmodelRef> | undefined): string {
if (!mathmodelRefs) return "";
return mathmodelRefs?.map(mm => mm.mmKey?.toString()).join(", ");
}

setMmRefsFromMmKeys(mmKeyString: string[]) {
this.publication.mathmodelRefs = mmKeyString.map(mmKey => {
return {mmKey: parseInt(mmKey)};
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export class PublicationListComponent implements OnInit {

onEdit(pub: Publication) {
// nothing to do

console.log("editing publication "+pub.title);
this.startEdit(pub)
}
Expand Down

0 comments on commit 6f38035

Please sign in to comment.