foam-framework / foam2

FOAM: Feature-Oriented Active Modeller, Version 2
Apache License 2.0
73 stars 63 forks source link

Prototypes #1551

Open TW80000 opened 5 years ago

TW80000 commented 5 years ago

Definition

A prototype is just an instance of a model with some properties set to default values.

Purpose

The purpose of prototypes is to make it easier to create new instances of models, particularly through the DAO Controller GUI. Instead of the DAO Controller simply having a "Create" button, check if there are any prototypes for the "of" of the DAO (the model being stored in it) and add a dropdown to the create button that lets you create an instance with some of the properties set to default values.

For example: We could make a prototype of the foam.nanos.auth.User model where the group property is set to a default value of "business". This is a very simple prototype where only one property has a default value, but multiple properties could be set to default values.

Prototypes could also include custom views.

Implementation

Prototypes should be modelled and stored in prototypeDAO, which needs to be created. The model should have the following properties:

modelId

The model that this is a prototype of.

label

The label to display in the create dropdown.

prototype

An array of properties.

[optional] detailView

A view used in place of the normal DetailView for editing an instance.

kgrgreer commented 5 years ago

The prototype should also have an optional view: or detailView: property for configuring an alternative DetailView.