diff --git a/src/main/kotlin/wanijo/wanijo2/domain/document.kt b/src/main/kotlin/wanijo/wanijo2/domain/document.kt index 951f6eb..87eb19f 100644 --- a/src/main/kotlin/wanijo/wanijo2/domain/document.kt +++ b/src/main/kotlin/wanijo/wanijo2/domain/document.kt @@ -53,6 +53,11 @@ data class Document( updatedAt = Instant.now(), dateFields = dateFields.filter { it.id != fieldId }.toSet() ) + + fun updated() = + copy( + updatedAt = Instant.now() + ) } @Table("T_DOCUMENT") diff --git a/src/main/kotlin/wanijo/wanijo2/domain/handler/AssignTaggingHandler.kt b/src/main/kotlin/wanijo/wanijo2/domain/handler/AssignTaggingHandler.kt index f3b154d..3eaa258 100644 --- a/src/main/kotlin/wanijo/wanijo2/domain/handler/AssignTaggingHandler.kt +++ b/src/main/kotlin/wanijo/wanijo2/domain/handler/AssignTaggingHandler.kt @@ -1,15 +1,20 @@ package wanijo.wanijo2.domain.handler import org.springframework.stereotype.Service +import org.springframework.transaction.annotation.Transactional +import wanijo.wanijo2.domain.DocumentDao import wanijo.wanijo2.domain.DocumentTagging import wanijo.wanijo2.domain.DocumentTaggingDao import wanijo.wanijo2.domain.event.AssignTaggingCommand +import wanijo.wanijo2.http.DocumentNotFound @Service class AssignTaggingHandler( - val taggingDao: DocumentTaggingDao + val taggingDao: DocumentTaggingDao, + val documentDao: DocumentDao ) { + @Transactional fun exec(command: AssignTaggingCommand) { taggingDao.save( DocumentTagging.between( @@ -17,6 +22,11 @@ class AssignTaggingHandler( command.tagId ) ) + documentDao.save( + (documentDao + .findById(command.documentId) ?: throw DocumentNotFound()) + .updated() + ) } } diff --git a/src/main/kotlin/wanijo/wanijo2/domain/handler/DeleteTaggingHandler.kt b/src/main/kotlin/wanijo/wanijo2/domain/handler/DeleteTaggingHandler.kt index 2a770f8..062c1b2 100644 --- a/src/main/kotlin/wanijo/wanijo2/domain/handler/DeleteTaggingHandler.kt +++ b/src/main/kotlin/wanijo/wanijo2/domain/handler/DeleteTaggingHandler.kt @@ -1,19 +1,29 @@ package wanijo.wanijo2.domain.handler import org.springframework.stereotype.Service +import org.springframework.transaction.annotation.Transactional +import wanijo.wanijo2.domain.DocumentDao import wanijo.wanijo2.domain.DocumentTaggingDao import wanijo.wanijo2.domain.event.DeleteTaggingCommand +import wanijo.wanijo2.http.DocumentNotFound @Service class DeleteTaggingHandler( - val taggingDao: DocumentTaggingDao + val taggingDao: DocumentTaggingDao, + val documentDao: DocumentDao ) { + @Transactional fun exec(command: DeleteTaggingCommand) { taggingDao.delete( command.documentId, command.tagId ) + documentDao.save( + (documentDao + .findById(command.documentId) ?: throw DocumentNotFound()) + .updated() + ) } } diff --git a/src/main/kotlin/wanijo/wanijo2/http/controller/ShowController.kt b/src/main/kotlin/wanijo/wanijo2/http/controller/ShowController.kt index 7001317..5fab584 100644 --- a/src/main/kotlin/wanijo/wanijo2/http/controller/ShowController.kt +++ b/src/main/kotlin/wanijo/wanijo2/http/controller/ShowController.kt @@ -21,6 +21,9 @@ class ShowController( val tagDao: TagDao ) { + val markdownParser: Parser = Parser.builder().build() + val htmlRenderer: HtmlRenderer = HtmlRenderer.builder().build() + @GetMapping("/document/{id}") fun show( model: Model, @@ -29,11 +32,9 @@ class ShowController( val document = docDao.findById(id) ?: throw DocumentNotFound() model["document"] = document - - val descHtml = Parser.builder().build().parse(document.description).let { - HtmlRenderer.builder().build().render(it) + model["descHtml"] = markdownParser.parse(document.description).let { + htmlRenderer.render(it) } - model["descHtml"] = descHtml val documentTags = tagDao.ofDocument(id) model["documentTags"] = documentTags.sortedBy { it.name.lowercase() } diff --git a/src/main/resources/static/stylesheet.css b/src/main/resources/static/stylesheet.css index 88d98c3..8fe2e26 100644 --- a/src/main/resources/static/stylesheet.css +++ b/src/main/resources/static/stylesheet.css @@ -74,7 +74,10 @@ main { .tag-block { border: 1px solid var(--light-grey); border-left: .5rem solid AccentColor; - padding: .2rem .2rem .2rem .5rem; + + [type=submit] { + padding: .5rem; + } } fieldset { @@ -132,6 +135,25 @@ form { } } +form.vert { + display: grid; + grid-template-columns: 100%; + grid-auto-flow: row; + row-gap: 1rem; + + label { + grid-column: 1; + } + + input, textarea, select, button, .form__widget { + grid-column: 1; + } + + textarea { + min-height: 20rem; + } +} + .form-link { display: inline; diff --git a/src/main/resources/templates/new.html b/src/main/resources/templates/new.html index 6c58ebe..724920f 100644 --- a/src/main/resources/templates/new.html +++ b/src/main/resources/templates/new.html @@ -8,7 +8,7 @@
-
+ @@ -24,7 +24,7 @@ - + +
@@ -114,7 +114,7 @@
- +