View - songgz/fastui GitHub Wiki
Fastui generates a user interface from the model. but it is necessary to model with precision the format of the user interface or view. In this chapter you will learn how to do this.
Window <-- Tab <-- Field
^ ^
| |
Model <-- Attribute
How is a window created? A Window normally contains several Tabs, and a Tab contains several Fields. A Tab is based on a “Entity”, so a Field in a tab is just a “Attribute” in a “Entity”. So the process to generate a window is to:
- Create a "table" into Rails (Or use an existing migration)
- Create a entity(model) in Rails (Or use an existing model)
- Create attributes in Rails for this Model
- Create A window in Fastui_config
- Create Tabs for this window using a entity(model) in Rails
- Create members(fields) for the Tab
- Create a new Menu item and add a window menu into the menu tree
Window
The Window, Tab & Field view defines the presentation (GUI) of entity and attribute within each window. Each Tab in a Window refers to a single entity. The Fields in the Tab of a Window refers to the attributes in the entity.
The syntax for window is:
conf.win :m_list, title: '数据字典', window_kind: 'maintain' do |w|
w.tab :m_list, title: '枚举', entity:'Fastui::MList'
w.tab :m_list_item, title:'枚举项', entity:'Fastui::MListItem', included_tab: 'm_list'
end
Tab
The entity can be used in an tab in order to define the view of its members in the user interface.
The syntax for tab is:
w.tab :m_list, title: '枚举', entity:'Fastui::MList', members:[
{name:'id', title: 'ID', datatype:'VInteger', readonly: true},
{name:'title', title: '标题', datatype:'VString'},
{name:'print_text', title: '打印文本', datatype:'VString'},
{name:'name', title: '标识', datatype:'VString'}
]
in the Tab:
- name (first optional): This name identifies the tab, and can be used in other window. If the tab has no name then the tab is assumed as the default one, that is the natural form to display an object of this ype.
- title (optional): This title identifies the lable text, and can be used in window title.
- entity (optional), Which entity is the tab used, (a tab must depend on a model defined in Rails).
- members (optional): Indicates the members to display and its layout in the tab. it displays member(attribute) in which are declared in the model. Inside members you can use section and group elements for layout purposes; or action element for showing a link associated to a custom action inside your tab.
in the member:
- name, The model’s attribute, a field must depend on a attribute.
- title, Show the attribute’s name.
- datatype, Show Form field type.