forked from MapComplete/MapComplete
Scripts: automatically reorder layers and themes into the fixed order
This commit is contained in:
parent
40678a2eb3
commit
8761685fa6
4 changed files with 55 additions and 46 deletions
|
@ -32,6 +32,7 @@ import { ExpandRewrite } from "./ExpandRewrite"
|
|||
import { TagUtils } from "../../../Logic/Tags/TagUtils"
|
||||
import { ExpandFilter, PruneFilters } from "./ExpandFilter"
|
||||
import { ExpandTagRendering } from "./ExpandTagRendering"
|
||||
import layerconfig from "../../../assets/schemas/layerconfigmeta.json"
|
||||
|
||||
class AddFiltersFromTagRenderings extends DesugaringStep<LayerConfigJson> {
|
||||
constructor() {
|
||||
|
@ -1077,6 +1078,20 @@ class DeriveSource extends DesugaringStep<LayerConfigJson> {
|
|||
}
|
||||
}
|
||||
|
||||
class OrderLayer extends DesugaringStep<LayerConfigJson>{
|
||||
|
||||
private static readonly layerAttributesOrder: ReadonlyArray<string> = Utils.Dedup(
|
||||
(<ConfigMeta[]>layerconfig).filter((c) => c.path.length === 1).map((c) => c.path[0])
|
||||
)
|
||||
constructor() {
|
||||
super("OrderLayer", "Reorders the layer to the default order")
|
||||
}
|
||||
|
||||
public convert(json: LayerConfigJson, context: ConversionContext): LayerConfigJson {
|
||||
return Utils.reorder(json, OrderLayer.layerAttributesOrder)
|
||||
}
|
||||
}
|
||||
|
||||
export class PrepareLayer extends Fuse<LayerConfigJson> {
|
||||
constructor(
|
||||
state: DesugaringContext,
|
||||
|
@ -1125,7 +1140,8 @@ export class PrepareLayer extends Fuse<LayerConfigJson> {
|
|||
new AddFiltersFromTagRenderings(),
|
||||
new ExpandFilter(state),
|
||||
new MoveUnitConfigs(),
|
||||
new PruneFilters()
|
||||
new PruneFilters(),
|
||||
new OrderLayer()
|
||||
)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue