forked from MapComplete/MapComplete
Refactoring: change order of parameters and remove parameter for Conversion.ts
This commit is contained in:
parent
49fc8e4bcf
commit
72e06448fc
20 changed files with 147 additions and 213 deletions
|
@ -5,32 +5,26 @@ import { QuestionableTagRenderingConfigJson } from "../src/Models/ThemeConfig/Js
|
|||
import * as fakedom from "fake-dom"
|
||||
import Script from "./Script"
|
||||
import { FixedUiElement } from "../src/UI/Base/FixedUiElement"
|
||||
import { ConversionContext } from "../src/Models/ThemeConfig/Conversion/ConversionContext"
|
||||
|
||||
class ExtractQuestionHint extends DesugaringStep<QuestionableTagRenderingConfigJson> {
|
||||
constructor() {
|
||||
super(
|
||||
"ExtractQuestionHint",
|
||||
"Tries to extract a 'questionHint' from the question",
|
||||
["question", "questionhint"],
|
||||
"ExtractQuestionHint"
|
||||
)
|
||||
}
|
||||
|
||||
convert(
|
||||
json: QuestionableTagRenderingConfigJson,
|
||||
context: string
|
||||
): {
|
||||
result: QuestionableTagRenderingConfigJson
|
||||
errors?: string[]
|
||||
warnings?: string[]
|
||||
information?: string[]
|
||||
} {
|
||||
json: QuestionableTagRenderingConfigJson
|
||||
): QuestionableTagRenderingConfigJson {
|
||||
json = { ...json }
|
||||
if (json.question === undefined || json.questionHint !== undefined) {
|
||||
return { result: json }
|
||||
return json
|
||||
}
|
||||
|
||||
if (typeof json.question === "string") {
|
||||
return { result: json }
|
||||
return json
|
||||
}
|
||||
|
||||
const hint: Record<string, string> = {}
|
||||
|
@ -64,12 +58,11 @@ class ExtractQuestionHint extends DesugaringStep<QuestionableTagRenderingConfigJ
|
|||
|
||||
console.log("Inspecting ", json.question)
|
||||
|
||||
return { result: json }
|
||||
return json
|
||||
}
|
||||
}
|
||||
|
||||
class FixQuestionHint extends Script {
|
||||
private fs: any
|
||||
constructor() {
|
||||
super("Extracts a 'questionHint' from a question for a given 'layer.json' or 'theme.json'")
|
||||
if (fakedom === undefined) {
|
||||
|
@ -89,7 +82,9 @@ class FixQuestionHint extends Script {
|
|||
}
|
||||
contents[key] = convertor.convertStrict(
|
||||
tr,
|
||||
"While automatically extracting questiondHints of " + filepath
|
||||
ConversionContext.construct([],
|
||||
["While automatically extracting questiondHints of " + filepath]
|
||||
)
|
||||
)
|
||||
}
|
||||
fs.writeFileSync(filepath, JSON.stringify(contents, null, " "), { encoding: "utf-8" })
|
||||
|
@ -105,7 +100,9 @@ class FixQuestionHint extends Script {
|
|||
}
|
||||
layer.tagRenderings[i] = convertor.convertStrict(
|
||||
<QuestionableTagRenderingConfigJson>tagRendering,
|
||||
ConversionContext.construct([], [
|
||||
"While automatically extracting questionHints of " + filepath
|
||||
])
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue