Skip to content

Commit

Permalink
fix: duplicate events while editing
Browse files Browse the repository at this point in the history
  • Loading branch information
bayang committed Feb 26, 2022
1 parent b153036 commit dbe3ad1
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 57 deletions.
3 changes: 2 additions & 1 deletion src/jelu-ui/src/components/BookDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ const toggleEdit = () => {
canCancel: ['x', 'button', 'outside'],
scroll: 'clip',
props: {
"book" : book.value
"book" : book.value,
canAddEvent: false
},
onClose: modalClosed
});
Expand Down
9 changes: 6 additions & 3 deletions src/jelu-ui/src/components/EditBookModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { StringUtils } from "../utils/StringUtils";
import { useProgrammatic } from "@oruga-ui/oruga-next";
import { Tag } from "../model/Tag";
const props = defineProps<{ bookId: string, book: UserBook|null }>()
const props = defineProps<{ bookId: string, book: UserBook|null, canAddEvent: boolean }>()
const oruga = useProgrammatic();
const emit = defineEmits(['close']);
Expand Down Expand Up @@ -62,7 +62,7 @@ const toReadDisplay = computed(() => {
const importBook = () => {
console.log("import")
console.log(userbook)
if (userbook.value.lastReadingEvent === ReadingEventType.NONE) {
if (!props.canAddEvent || userbook.value.lastReadingEvent === ReadingEventType.NONE) {
userbook.value.lastReadingEvent = null
}
userbook.value.book.image = null
Expand Down Expand Up @@ -375,7 +375,10 @@ function toggleRemoveImage() {
/>
</o-field>
</div>
<div class="block">
<div
v-if="props.canAddEvent"
class="block"
>
<o-field
horizontal
label="Status : "
Expand Down
3 changes: 2 additions & 1 deletion src/jelu-ui/src/components/SearchResultsDisplay.vue
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ const toggleEdit = (book: UserBook) => {
canCancel: ['x', 'button', 'outside'],
scroll: 'clip',
props: {
"book" : book
"book" : book,
canAddEvent: true
},
onClose: modalClosed
});
Expand Down
3 changes: 2 additions & 1 deletion src/jelu-ui/src/components/TagBooks.vue
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ const toggleEdit = (book: UserBook) => {
canCancel: ['x', 'button', 'outside'],
scroll: 'clip',
props: {
"book" : book
"book" : book,
canAddEvent: true
},
onClose: modalClosed
});
Expand Down
70 changes: 19 additions & 51 deletions src/main/kotlin/io/github/bayang/jelu/dao/BookRepository.kt
Original file line number Diff line number Diff line change
Expand Up @@ -261,46 +261,24 @@ class BookRepository(
if (!book.title.isNullOrBlank()) {
updated.title = book.title.trim()
}
if (!book.isbn10.isNullOrBlank()) {
updated.isbn10 = book.isbn10.trim()
}
if (!book.isbn13.isNullOrBlank()) {
updated.isbn13 = book.isbn13.trim()
}
if (book.pageCount != null) {
updated.pageCount = book.pageCount
}
if (!book.publisher.isNullOrBlank()) {
updated.publisher = book.publisher.trim()
}
updated.isbn10 = book.isbn10?.trim()
updated.isbn13 = book.isbn13?.trim()
updated.pageCount = book.pageCount
updated.publisher = book.publisher?.trim()
if (!book.summary.isNullOrBlank()) {
updated.summary = sanitizeHtml(book.summary)
} else {
updated.summary = book.summary
}
// image must be set when saving file succeeds
if (!book.publishedDate.isNullOrBlank()) {
updated.publishedDate = book.publishedDate.trim()
}
if (!book.series.isNullOrBlank()) {
updated.series = book.series.trim()
}
if (book.numberInSeries != null) {
updated.numberInSeries = book.numberInSeries
}
if (!book.amazonId.isNullOrBlank()) {
updated.amazonId = book.amazonId.trim()
}
if (!book.goodreadsId.isNullOrBlank()) {
updated.goodreadsId = book.goodreadsId.trim()
}
if (!book.googleId.isNullOrBlank()) {
updated.googleId = book.googleId.trim()
}
if (!book.librarythingId.isNullOrBlank()) {
updated.librarythingId = book.librarythingId.trim()
}
if (!book.language.isNullOrBlank()) {
updated.language = book.language.trim()
}
updated.publishedDate = book.publishedDate?.trim()
updated.series = book.series?.trim()
updated.numberInSeries = book.numberInSeries
updated.amazonId = book.amazonId?.trim()
updated.goodreadsId = book.goodreadsId?.trim()
updated.googleId = book.googleId?.trim()
updated.librarythingId = book.librarythingId?.trim()
updated.language = book.language?.trim()
updated.modificationDate = nowInstant()
val authorsList = mutableListOf<Author>()
book.authors?.forEach {
Expand Down Expand Up @@ -346,9 +324,7 @@ class BookRepository(
if (book.owned != null) {
found.owned = book.owned
}
if (!book.personalNotes.isNullOrBlank()) {
found.personalNotes = book.personalNotes.trim()
}
found.personalNotes = book.personalNotes?.trim()
if (book.toRead != null) {
found.toRead = book.toRead
}
Expand Down Expand Up @@ -376,18 +352,10 @@ class BookRepository(
if (!author.name.isNullOrBlank()) {
found.name = author.name.trim()
}
if (!author.biography.isNullOrBlank()) {
found.biography = author.biography.trim()
}
if (!author.dateOfDeath.isNullOrBlank()) {
found.dateOfDeath = author.dateOfDeath.trim()
}
if (!author.dateOfBirth.isNullOrBlank()) {
found.dateOfBirth = author.dateOfBirth.trim()
}
if (!author.image.isNullOrBlank()) {
found.image = author.image.trim()
}
found.biography = author.biography?.trim()
found.dateOfDeath = author.dateOfDeath?.trim()
found.dateOfBirth = author.dateOfBirth?.trim()
found.image = author.image?.trim()
found.modificationDate = nowInstant()
return found
}
Expand Down

0 comments on commit dbe3ad1

Please sign in to comment.