Skip to content

Commit

Permalink
in annotate: delete paper
Browse files Browse the repository at this point in the history
  • Loading branch information
rwst committed Nov 22, 2023
1 parent cc965b3 commit 4e9efff
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/main/kotlin/org/reactome/lit_ball/common/PaperList.kt
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,15 @@ object PaperList {
}
}

fun delete(id: Int) {
val index = shadowMap[id] ?: return
val tmp = list.toMutableList()
tmp.removeAt(index)
list = tmp.toList()
updateShadowMap()
save()
}

fun new(files: List<File>): PaperList {
if (files.size > 1) throw Exception("multiple files selected in New")
val file = files[0]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ object AnnotatingRootStore : ModelHandle {
PaperList.setFlag(id, flagNo, value)
}

fun deleteClicked(id: Int) {
PaperList.delete(id)
refreshList()
}

private fun onDoAnnotateStopped() {
runBlocking {
PaperList.saveAnnotated()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ fun CardWithFlagBoxes(
onClicked: () -> Unit,
onFlagSet: (Int, Boolean) -> Unit,
) {
val model = AnnotatingRootStore
val cardTitle = item.details.title
val cardPMID: String? = item.details.externalIds?.get("PubMed")
val year = item.details.publicationDate?.substringBefore("-")?: ""
Expand Down Expand Up @@ -184,6 +185,22 @@ fun CardWithFlagBoxes(
onFlagSet,
)
Spacer(modifier = Modifier.width(16.dp))
Tooltip("Remove paper from accepted", Modifier.align(Alignment.CenterVertically)) {
IconButton(
onClick = { model.deleteClicked(item.id) },
modifier = Modifier
.size(height = 30.dp, width = 30.dp)
.align(Alignment.CenterVertically),
) {
Icon(
painter = painterResource(Icons.Delete),
contentDescription = "Remove Query",
tint = Color.Gray,
modifier = Modifier.size(48.dp).align(Alignment.CenterVertically),
)
}
}
Spacer(modifier = Modifier.width(16.dp))
}
}
}

0 comments on commit 4e9efff

Please sign in to comment.