Collection book list: allow to directly input a position
This commit is contained in:
@@ -76,7 +76,7 @@ func PostCollectionChangePositionHandler(ac appcontext.AppContext) {
|
||||
newPosition = uint(count)
|
||||
}
|
||||
|
||||
if item.Position == collectionBookPosition.Position {
|
||||
if item.Position == newPosition {
|
||||
//nothing to do
|
||||
ac.C.String(http.StatusOK, "Success")
|
||||
return
|
||||
@@ -84,11 +84,11 @@ func PostCollectionChangePositionHandler(ac appcontext.AppContext) {
|
||||
lowerPosition := item.Position + 1
|
||||
higherPosition := item.Position - 1
|
||||
operationToDo := ""
|
||||
if item.Position < collectionBookPosition.Position {
|
||||
higherPosition = collectionBookPosition.Position
|
||||
if item.Position < newPosition {
|
||||
higherPosition = newPosition
|
||||
operationToDo = "position - 1"
|
||||
} else {
|
||||
lowerPosition = collectionBookPosition.Position
|
||||
lowerPosition = newPosition
|
||||
operationToDo = "position + 1"
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ func PostCollectionChangePositionHandler(ac appcontext.AppContext) {
|
||||
return
|
||||
}
|
||||
|
||||
item.Position = collectionBookPosition.Position
|
||||
item.Position = newPosition
|
||||
ac.Db.Save(&item)
|
||||
ac.C.String(http.StatusOK, "Success")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user