feat: Adds multi-step form to generate equivalent lengths for a project.
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
import DatabaseClient
|
||||
import ManualDCore
|
||||
|
||||
extension SiteRoute.View.ProjectRoute.EquivalentLengthRoute.StepThree {
|
||||
|
||||
func validate() throws(ValidationError) {
|
||||
guard groupGroups.count == groupLengths.count,
|
||||
groupGroups.count == groupLetters.count,
|
||||
groupGroups.count == groupQuantities.count
|
||||
else {
|
||||
throw ValidationError("Equivalent length form group counts are not equal.")
|
||||
}
|
||||
}
|
||||
|
||||
var groups: [EffectiveLength.Group] {
|
||||
var groups = [EffectiveLength.Group]()
|
||||
for (n, group) in groupGroups.enumerated() {
|
||||
groups.append(
|
||||
.init(
|
||||
group: group,
|
||||
letter: groupLetters[n],
|
||||
value: Double(groupLengths[n]),
|
||||
quantity: groupQuantities[n]
|
||||
)
|
||||
)
|
||||
}
|
||||
return groups
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
extension EffectiveLength.Create {
|
||||
|
||||
init(
|
||||
form: SiteRoute.View.ProjectRoute.EquivalentLengthRoute.StepThree,
|
||||
projectID: Project.ID
|
||||
) {
|
||||
self.init(
|
||||
projectID: projectID,
|
||||
name: form.name,
|
||||
type: form.type,
|
||||
straightLengths: form.straightLengths,
|
||||
groups: form.groups
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user