Skip to content

Commit a27049a

Browse files
committed
Update parentid on update
1 parent eadb511 commit a27049a

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

myndla-api/src/main/scala/no/ndla/myndlaapi/repository/FolderRepository.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ class FolderRepository(using clock: Clock, dbUtility: DBUtility) extends StrictL
138138
withSQL {
139139
update(Folder)
140140
.set(
141+
column("parent_id") -> folder.parentId,
141142
column("name") -> folder.name,
142143
column("status") -> folder.status.toString,
143144
column("shared") -> folder.shared,

myndla-api/src/main/scala/no/ndla/myndlaapi/service/FolderConverterService.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ class FolderConverterService(using clock: Clock) extends StrictLogging {
8383
case failure => throw failure.failed.get
8484
}
8585
}
86+
val rank = if (parentId != existing.parentId) {
87+
0
88+
} else {
89+
existing.rank
90+
}
8691
val name = updated.name.getOrElse(existing.name)
8792
val status = updated.status.flatMap(FolderStatus.valueOf).getOrElse(existing.status)
8893
val description = updated.description.orElse(existing.description)
@@ -103,7 +108,7 @@ class FolderConverterService(using clock: Clock) extends StrictLogging {
103108
parentId = parentId,
104109
name = name,
105110
status = status,
106-
rank = existing.rank,
111+
rank = rank,
107112
created = existing.created,
108113
updated = clock.now(),
109114
shared = shared,

myndla-api/src/main/scala/no/ndla/myndlaapi/service/FolderWriteService.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ class FolderWriteService(using
295295
_ <- validateUpdatedFolder(converted.name, converted.parentId, maybeSiblings, converted)
296296
updated <- folderRepository.updateFolder(id, feideId, converted)
297297
crumbs <- folderReadService.getBreadcrumbs(updated)(using ReadOnlyAutoSession)
298-
siblingsToSort <- getFolderWithDirectChildren(converted.parentId, feideId)
298+
siblingsToSort <- getFolderWithDirectChildren(updated.parentId, feideId)
299299
sortRequest = FolderSortRequestDTO(sortedIds = siblingsToSort.childrenFolders.map(_.id))
300300
_ <- performSort(siblingsToSort.childrenFolders, sortRequest, feideId, sharedFolderSort = false)
301301
feideUser <- userRepository.userWithFeideId(feideId)

0 commit comments

Comments
 (0)