You have been redirected from an outdated version of the article. Below is the content available on this topic. To view the old article click here.

Views

In the context of Structr’s schema, the basic concept View is used to group a set of attributes.

Built-in Views

Built-in views are provided by Structr itself and can only be added to. The following built-in views exist:

public Default view to be used if no view is requested explicitely. Contains at least id and type.
protected User-definable view, typically used to provide an extended set of attributes to authenticated users
ui View including most of the attributes, used mainly by the UI components in the admin backend (e.g. Data section)
html View including all HTML attributes
all System view containing all attributes. Caution: Handle with care, could yield very large result sets!

In the Schema Editor, you can add more views and assign attributes to existing or custom views. Views defined that way can be append to any REST query or used in internal queries to filter attributes.

Search results for "Views"

Views

The Views option shows the bulk editing view for all views of this type. It allows to create, edit, delete all views.

Relationship Details Dialog

The Cascading Delete settings allow configuration of what happens when either end of the relationship is deleted. The possible values are explained in-depth in the help popup in the dialog.
Automatic Creation of Related Nodes configures if it is allowed to include nested nodes in a REST POST request for this relationship. A node with the given property set is automatically created and linked to the node. If the nested node contains an id attribute (or another property marked as unique) a node is searched for that property and linked if found.

Permission Resolution allows configuration of rights propagation in the graph. If NONE is selected, no rights propagation is applied for this relationship. If SOURCE_TO_TARGET is selected the rights are propagated along the relationship direction to the next node. For TARGET_TO_SOURCE the rights propagation is works against the relationship direction. For ALWAYS the direction of the relationship does not matter and rights propagation is always applied.
Specific rights (Read, Write, Delete, AccessControl) can be added, kept or removed according to the propagation configuration. If a user has read rights to the previous node and Read is configured to Keep, the user also has read rights for the next node. (Specific User/Group rights are applied before using permission propagation - i.e. if a user has specific rights configured for a node, permission resolution is not evaluated as user rights are more specific).
Along the way of permission propagation, properties can be hidden in order to hide sensitive information from users who get rights from permission propagation. The property names can be separated by comma , or space character.

There are 3 tabs where the functionality of the type can be configured:

  • Local Attributes
    A Custom Type can be extended with dynamic properties to provide the data model for the intended use-case. This list contains all local properties (meaning they are defined on this type directly).
  • Views
    The properties of a type can be combined into named Views, which are accessible under an individual REST URL. Access to these URLs can be configured independently for each HTTP method using Resource Access Grants, which makes them an ideal tool to create specialised endpoints for different client applications (e.g. mobile clients etc.).
  • Methods
    There are different kinds of methods - callback methods and entity methods. Callback methods are automatically executed by the framework upon certain lifecycle events and have a strict naming convention. Entity methods are called by the user/programmer.
    Entity methods are not automatically run by the framework and must be called manually. This either means making a POST request to /structr/rest/(Type)/(<a data-id="7c9c8218bced42bab66868373e64d885" class="mention">UUID</a>)/(methodName) or in serverside JavaScript as node.methodName();

Views

The attributes in a view can be arranged in any order and are then written to the output in exactly that order. You can add and remove attributes to and from views. Views are inherited from the base class to derived classes.

Type Details Dialog

There are 5 tabs where the functionality of the type can be configured:

  • Local Attributes
    A Custom Type can be extended with dynamic properties to provide the data model for the intended use-case. This list contains all local properties (meaning they are defined on this type directly).

  • Views
    The properties of a type can be combined into named Views, which are accessible under an individual REST URL. Access to these URLs can be configured independently for each HTTP method using Resource Access Grants, which makes them an ideal tool to create specialised endpoints for different client applications (e.g. mobile clients etc.).

  • Methods
    There are different kinds of methods - callback methods and entity methods. Callback methods are automatically executed by the framework upon certain lifecycle events and have a strict naming convention. Entity methods are called by the user/programmer.
    Entity methods are not automatically run by the framework and must be called manually. This either means making a POST request to /structr/rest/<Type>/<UUID>/<methodName> or in serverside JavaScript as <node>.<methodName>();

  • Remote Attributes
    Custom types can be linked to other types, including base types. Structr will automatically create Remote Attributes on either side of the link, which can then be used to create, update or remove the relationships between instances of the two types. In this tab the configuration of the remote attributes can be viewed and edited. The names configured here are used throughout the application to refer to the other side of the relationship(s).

  • Inherited Attributes
    The content of this tab is of informative character. All inherited attributes are shown with an information from where it was inherited.

Simple Data Model

Once the message disappears, the schema has been updated successfully to include the new data type Project. There’s a lot more functionality related to data types, e.g. adding relations between multiple types, adding properties, views, methods etc. that is handled in an entire section down below.

Overview

The Overview section allows navigation and search of Global Methods and Types. The latter are split into Custom and Built-In Types and each specific Type contains sections for it’s Properties, Views, Methods and Inherited Properties.

Types

Each Type contains child elements representing it’s Local Attributes, Remote Attributes, Views, Methods and Inherited Attributes. With the exception of Inherited Attributes, which are read-only, all children provide options to mange their respective content.

Views

Builtin views can not be deleted - upon deletion they will be restored with their initial configuration.

In the View detail section the selected View can be renamed and it’s referenced Properties can be changed by clicking into the input area and selecting additional properties from the dropdown menu. Removable properties will have a small “x” button next to their name, which allows their removal.

The exception to this are the properties contained in default views, which cannot be removed.

The properties of a schema type can be combined into named groups, called views, which are primarily used to configure the JSON output of the corresponding REST endpoint.

The base classes provide three preconfigured views.

View Selection

A View is a named group of properties that specifies the contents of an object in the JSON output. We recommend to create dedicated views for the individual consumers of your API, to optimize data transfer and allow for independent development and modification of the endpoints.

You can select any of the Views defined in the data model by appending its name to the request URL. If the URL does not contain a view, the public view is selected automatically.

Remote Attributes