Create a new window - songgz/fastui GitHub Wiki
The following makes an example with a window and a model.
- create a model called Product with Rails Generator.
rails generate model Product id:integer name:string title:string note:text price:integer quantity:integer
- create a window for Product in the file config/initializers/fastui_config.rb. Code is as follows.
conf.win :product, title: 'Product', window_kind: 'maintain' do |w|
w.tab :product title: 'Product', entity: 'Product', members: [
{name: 'id', title: 'ID', datatype: 'VInteger', readonly: true, },
{name: 'title', title: 'Name', datatype: 'VString'},
{name: 'name', title: 'Code', datatype: 'VString'},
{name: 'price', title: 'Price', datatype: 'VNumber'},
{name: 'quantity', title: 'Quantity', datatype: 'VInteger'},
{name: 'note', title: 'Note', datatype: 'VText'}
]
end
- create a controller for Product resource.
rails generate scaffold_controller products
write code in products_controller.
def index
@products = Product.all
respond_with(@products.to_json())
end
- create a menu item for Product window in Menu item. make window field to 'product'.