Edit this topic

File placement strategy

: shell

: placement-strategy

: file-placement-strategy

: /modules/core/ui/services/file-placement-strategy.js

: https://github.com/DecentCMS/DecentCMS/blob/master/modules/core/ui/services/file-placement-strategy.js

class: FilePlacementStrategy

new FilePlacementStrategy()

Uses placement.js and placement.json files found at the root of modules to dispatch shapes into.

The placement.js files should export a function(scope, rootShape, shapes) that should splice shapes out of the shapes array if and when it decides to place them on the rootShape.

The placement.json files contain an object that may have one "matches" property that contains an array of objects that must expose a path and an order property. They can have any combination of id, type, and displayType regular expressions that shapes will be matched against.

Besides the matches array, the top object in the placement.json file can have properties whose names are shape types, that have a path and an order properties.

filePlacementStrategy.placeShapes(context, done)

Dispatches a list of shapes under a root shape, by handing over the task to the placement strategies discovered by the constructor.

Param Type Description
context object The context.
context.shape object The root shape under which the shapes must be placed.
context.shapes Array The list of shapes that must be placed.
done function The callback.