feat(icons): Made icons for libraries and shelves optional with no default icons. (#2599)
* feat(icons): Made icons for libraries and shelves optional with no default icon displayed. * Added tests for making sure the API handles nullable icons for Shelves and Libraries. * Fixed some issues identified during PR review. * Rebased on develop.
This commit is contained in:
@@ -15,7 +15,6 @@ public class MagicShelf {
|
||||
@Size(max = 255, message = "Shelf name must not exceed 255 characters")
|
||||
private String name;
|
||||
|
||||
@NotBlank(message = "Icon must not be blank")
|
||||
@Size(max = 64, message = "Icon must not exceed 64 characters")
|
||||
private String icon;
|
||||
|
||||
|
||||
@@ -19,10 +19,7 @@ public class CreateLibraryRequest {
|
||||
@NotBlank(message = "Library name must not be empty.")
|
||||
private String name;
|
||||
|
||||
@NotBlank(message = "Library icon must not be empty.")
|
||||
private String icon;
|
||||
|
||||
@NotNull(message = "Library icon type must not be null.")
|
||||
private IconType iconType;
|
||||
|
||||
@NotEmpty(message = "Library paths must not be empty.")
|
||||
|
||||
@@ -16,10 +16,7 @@ public class ShelfCreateRequest {
|
||||
@NotBlank(message = "Shelf name must not be empty.")
|
||||
private String name;
|
||||
|
||||
@NotBlank(message = "Shelf icon must not be empty.")
|
||||
private String icon;
|
||||
|
||||
@NotNull(message = "Shelf icon type must not be null.")
|
||||
private IconType iconType;
|
||||
|
||||
private boolean publicShelf;
|
||||
|
||||
@@ -44,9 +44,8 @@ public class LibraryEntity {
|
||||
private String icon;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
@Column(name = "icon_type", nullable = false)
|
||||
@Builder.Default
|
||||
private IconType iconType = IconType.PRIME_NG;
|
||||
@Column(name = "icon_type")
|
||||
private IconType iconType;
|
||||
|
||||
@Column(name = "file_naming_pattern")
|
||||
private String fileNamingPattern;
|
||||
@@ -65,10 +64,4 @@ public class LibraryEntity {
|
||||
@Builder.Default
|
||||
private LibraryOrganizationMode organizationMode = LibraryOrganizationMode.AUTO_DETECT;
|
||||
|
||||
@PrePersist
|
||||
public void ensureIconType() {
|
||||
if (this.iconType == null) {
|
||||
this.iconType = IconType.PRIME_NG;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,13 +27,11 @@ public class MagicShelfEntity {
|
||||
@Column(nullable = false)
|
||||
private String name;
|
||||
|
||||
@Column(nullable = false)
|
||||
private String icon;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
@Column(name = "icon_type", nullable = false)
|
||||
@Builder.Default
|
||||
private IconType iconType = IconType.PRIME_NG;
|
||||
@Column(name = "icon_type")
|
||||
private IconType iconType;
|
||||
|
||||
@Column(name = "filter_json", columnDefinition = "json", nullable = false)
|
||||
private String filterJson;
|
||||
@@ -54,11 +52,4 @@ public class MagicShelfEntity {
|
||||
public void onUpdate() {
|
||||
updatedAt = LocalDateTime.now();
|
||||
}
|
||||
|
||||
@PrePersist
|
||||
public void ensureIconType() {
|
||||
if (this.iconType == null) {
|
||||
this.iconType = IconType.PRIME_NG;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,9 +36,8 @@ public class ShelfEntity {
|
||||
private String icon;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
@Column(name = "icon_type", nullable = false)
|
||||
@Builder.Default
|
||||
private IconType iconType = IconType.PRIME_NG;
|
||||
@Column(name = "icon_type")
|
||||
private IconType iconType;
|
||||
|
||||
@Column(name = "is_public", nullable = false)
|
||||
@Builder.Default
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.booklore.model.enums.IconType;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@@ -24,6 +25,7 @@ public class UserDefaultsService {
|
||||
.user(user)
|
||||
.name("Favorites")
|
||||
.icon("heart")
|
||||
.iconType(IconType.PRIME_NG)
|
||||
.build();
|
||||
shelfRepository.save(shelf);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
ALTER TABLE library MODIFY COLUMN icon VARCHAR(64) NULL;
|
||||
ALTER TABLE library MODIFY COLUMN icon_type VARCHAR(255) NULL;
|
||||
|
||||
ALTER TABLE magic_shelf MODIFY COLUMN icon VARCHAR(64) NULL;
|
||||
ALTER TABLE magic_shelf MODIFY COLUMN icon_type VARCHAR(255) NULL;
|
||||
|
||||
ALTER TABLE shelf MODIFY COLUMN icon VARCHAR(64) NULL;
|
||||
ALTER TABLE shelf MODIFY COLUMN icon_type VARCHAR(255) NULL;
|
||||
Reference in New Issue
Block a user