chapter form isDefaultName for pgn import

pull/9910/head
Thibault Duplessis 2021-09-30 10:56:56 +02:00
parent 63ab3e23aa
commit dacca99d97
1 changed files with 12 additions and 9 deletions

View File

@ -60,13 +60,14 @@ object StudyForm {
lazy val form = Form(
mapping(
"name" -> cleanNonEmptyText,
"orientation" -> optional(nonEmptyText),
"variant" -> optional(nonEmptyText),
"mode" -> nonEmptyText.verifying(ChapterMaker.Mode(_).isDefined),
"initial" -> boolean,
"sticky" -> boolean,
"pgn" -> nonEmptyText
"name" -> cleanNonEmptyText,
"orientation" -> optional(nonEmptyText),
"variant" -> optional(nonEmptyText),
"mode" -> nonEmptyText.verifying(ChapterMaker.Mode(_).isDefined),
"initial" -> boolean,
"sticky" -> boolean,
"pgn" -> nonEmptyText,
"isDefaultName" -> boolean
)(Data.apply)(Data.unapply)
)
@ -77,7 +78,8 @@ object StudyForm {
mode: String,
initial: Boolean,
sticky: Boolean,
pgn: String
pgn: String,
isDefaultName: Boolean
) {
def toChapterDatas = {
@ -90,7 +92,8 @@ object StudyForm {
pgn = onePgn.some,
orientation = orientationStr | "white",
mode = mode,
initial = initial && index == 0
initial = initial && index == 0,
isDefaultName = index > 0 || isDefaultName
)
}
}