/model/

Description

Models will create Templates and Categories. They define the actual structure of the development model.

Models declare

  • Which models they inherit from
  • Which fields are used
  • The order of the fields
  • Mandatory and recommended fields
  • The template “rendering” mode (table, unordered lists, …)
  • If they are stored as regular semantic properties or a subobject
  • MediaWiki Categories
  • Prepend and append wikitext

Available Properties

ID Description
$abstract

If true this object is only used for inheritance and will not be created by itself.

Type(s): boolean

Specific to: intermediary

Default: false

Example:

$abstract: true
$extend

This includes and extends another file of the development.
Inheritance is applied, the children (the current file) overwrites the parent properties.

Type(s): arraystring

Specific to: intermediary

Example:

# Inherit a single parent
$extend: /model/_Shape

Example:

# Multiple parents are possible
$extend:
  - /field/fieldA
  - /field/fieldB

Example:

# extend is also used to import fields into models or models into forms.
title: A Model with two fields
items:
  - $extend: /field/fieldA
  - $extend: /field/fieldB
$ignore

If true, this file will be ignored completely.
Use this to temporarily remove parts of the development model without deleting them.

Type(s): boolean

Specific to: intermediary

Default: false

Example:

$ignore: true
$remove

Array, containing the IDs of all items/properties to remove from current object.

Type(s): array

Specific to: intermediary

Example:

$remove:
  - fieldA
  - fieldB
description

General Description. Fields may use them as tooltips, forms can display a small description box. This depends on the used template.

Type(s): string

Specific to: domain

Example:

description: |
  Longer description of the current model part.
items

The items property contains an array of all fields that are used by the model. Fields usually should be implemented using $extend, so every field can have its own file and inheritance. It is possible to overwrite properties from the field directly in the mode.

Type(s): arrayobject

Specific to: domain

Default: {}

Example:

items:
- $extend: /field/brand
  title: Overwritten brand title
- $extend: /field/modelName
itemsOrder

In case that fields have been inherited, they might not end up in the correct order.
The itemsOrder array lists the order of the fields. Every field that is not listed will be appended at the bottom, in their regular order.

Type(s): array

Specific to: domain

Example:

itemsOrder:
  - brand
  - modelName

Example:

itemsOrder:
  - '@unique'
  - '@sorted'
  - b
  - c
  - a
  - b
recommended

Array of fields that should be marked as recommended (complementary to mandatory).
Please note that the template and the MediaWiki skin have to support this, since it is not an official feature.

Type(s): array

Specific to: domain

Example:

recommended:
  - fieldA
  - fieldB
required

Array containing the IDs of all required fields.

Type(s): array

Specific to: domain

Example:

required:
  - fieldA
  - fieldB
showForm

If true the template/model will be hidden in the form view. This will usually be declared in the forms by adding this after the model $extend.

Type(s): boolean

Specific to: domain

Default: true

Example:

showForm: false
showPage

If true the template/model will be hidden in the page view. This will usually be declared in the forms by adding this after the model $extend.

Type(s): boolean

Specific to: domain

Default: true

Example:

showPage: false
smw_append

Adds a append wikitext to forms and models.

Type(s): objectstring

Specific to: implementation

Example:

smw_append: |
  Some appended wikitext
  Will be inserted after the H1 header

Contains:

ID Description
template

Name of the template to inject.

Type(s): string

wikitext

Wikitext to append.

Type(s): string

smw_appendCategory

Wikitext to append on the category page

Type(s): string

Specific to: implementation

Example:

smw_appendCategory: |
  Some wikitext to append on the category page
smw_appendForm

Appends wikitext only to forms (edit-view). Can either be a string or an object for more advanced features. (auto-generate headers, inject templates or add arbitrary wikitext)

Type(s): objectstring

Specific to: implementation

Contains:

ID Description
template

name of a template to inject. Must exist

Type(s): arraystring

wikitext

wikitext to prepend

Type(s): string

smw_appendPage

Appends wikitext only to templates (page-view). Can either be a string or an object for more advanced features (auto-generate headers, inject templates or add arbitrary wikitext)

Type(s): objectstring

Specific to: implementation

Contains:

ID Description
template

name of a template to inject. Must exist

Type(s): arraystring

wikitext

wikitext to prepend

Type(s): string

smw_categories

Array of additional categories the template should set.

Type(s): array

Specific to: platform

Example:

smw_categories:
  - additionalCategoryA
  - additionalCategoryB
smw_category

If true, the models template will assign a category. The name of the category is the model ID.

Type(s): boolean

Specific to: platform

Default: true

Example:

smw_category: false
smw_display

Defines the template output rendering mode, whether the template should use tables, ul, etc.
The rendering mode must be available in /mobo_template/template.wikitext!

Type(s): string

Specific to: platform

Default: "table"

Example:

smw_display: ul
smw_prepend

Prepends wikitext to both forms and templates. Can either be a string or an object for more advanced features (auto-generate headers, inject templates or add arbitrary wikitext).

Type(s): objectstring

Specific to: implementation

Example:

smw_prepend:
  header: 1
  wikitext: |
    Some prepended wikitext
    Will be inserted after the H1 header

Example:

smw_prepend: 'Some prepended wikitext'

Contains:

ID Description
header

Inserts auto generated header of given hierachy (1-6)

Type(s): number

template

name of a template to inject. Must exist

Type(s): string

wikitext

wikitext to prepend

Type(s): string

smw_prependCategory

Wikitext to prepend on the category page

Type(s): string

Specific to: implementation

Example:

smw_prependCategory: |
  Some wikitext to prepend on the category page
smw_prependForm

Prepends wikitext only to forms (edit-view). Can either be a string or an object for more advanced features (auto-generate headers, inject templates or add arbitrary wikitext)

Type(s): objectstring

Specific to: implementation

Contains:

ID Description
header

Inserts auto generated header of given hierachy (1-6)

Type(s): number

template

name of a template to inject. Must exist

Type(s): arraystring

wikitext

wikitext to prepend

Type(s): string

smw_prependPage

Prepends wikitext only to templates (page-view). Can either be a string or an object for more advanced features (auto-generate headers, inject templates or add arbitrary wikitext)

Type(s): objectstring

Specific to: implementation

Contains:

ID Description
header

Inserts auto generated header of given hierachy (1-6)

Type(s): number

template

name of a template to inject. Must exist

Type(s): arraystring

wikitext

wikitext to prepend

Type(s): string

smw_set

Contains a set (object) of additional #set properties.

Type(s): object

Specific to: platform

Example:

smw_set:
  additionalProp2: 'Some fixed text'
  additionalProp3: '/subpath/{{{fieldId|}}}'
smw_subobject

If true, this models attributes will be created as subobjects.
This may be appropiate when model is used through multiple instances.

Mobo will automantically introduce two additional helper attributes `subobjectType` and `subobjectParent` that help with querying subobjects.

Type(s): boolean

Specific to: platform

Default: false

Example:

smw_subobject: true
smw_subobjectExtend

Contains a set (object) of additional #subobject properties.

Type(s): object

Specific to: platform

Example:

smw_subobjectExtend:
  additionalSubObjProp2: 'Some fixed text'
  additionalSubObjProp3: '/subpath/{{{fieldId|}}}'
title

Human readable title.

Type(s): string

Specific to: domain

Example:

title: Some title
todo

If TODO notes are placed here, mobo can print them in the CLI (If the corresponding global setting is enabled).

Type(s): string

Specific to: domain

type

Defines the data-type.

Type(s): string

Specific to: domain

Valid entries: string, number, boolean, array, object

Example:

type: number

Annotated Examples

Model inheritance

/model/_Shape.json
# Abstract model. Will not be created on the target wiki.
$abstract: true

title: Shape
description: Generic Shape

# A shape model consists of two fields.
items:
  - $extend: /field/x
  - $extend: /field/y

required:
  - x
  - y
/model/Circle.json
$extend: /model/_Shape

title: Circle

# Addes the radius field
items:
  - $extend: /field/radius

# Add radius to the required array
required:
  - radius

In this example the Circle inherits all attributes of _Shape, especially the fields x and y. The Circle overwrites attributes like title and introduces a new field radius.