app kit
Advanced data applications in minutes

Configuration

Application configuration is done in the initialization file install by running the installation generator. This file is placed in config/initializers/app_kit.rb.

Dashboard

The dashboard must be setup from this file, since it does not have an associated resource, or model. The dashboard is meant to be a collection of useful overview information for the user.

Tables

The primary purpose of the dashboard is to display specific types of tabular data. Tables are created by the table command.

AppKit.setup do |config|
  dashboard do
    table :invoice, title: 'Open Invoices', :scope => :open
  end
end

Resources

Resources are the configuration object for a specific set of data, namely a model. A resource should be defined for each model that the application needs to build controllers and views for.

Resource files are expected to be in app/app_kit.

Generating resources

AppKit comes with a generator for creating resource files. From the root of your rails project run:

rails g app_kit:resource MODEL_NAME

This will create a new file inside the app/app_kit/ folder with a default configurations.

An example resource definition may look like this:

AppKit.Register Invoice do
  show_in_navigation true
  icon 'list'

  field :invoice_number, editable: false
  field :invoice_total, editable: false, :formatter => :currency
  field :invoice_date, :formatter => :date
  field :published, show_in_table: false

  before(:new) { |record|
    record.invoice_number =  record.set_invoice_number
  }
end

Configuration commands

Defining fields

Resource fields are the data attributes on the model that will be displayed when viewing tables or records. Fields are defined with the field command:

field model_name, options_hash

Field options

Before actions

Before actions let you define small pieces of logic that should occure during the execution of an action on a given resource.

  before(:action_name) { |r|
    # some code to execute
  }

The action can be any of the standard restful actions :index, :show, :new, :create, :edit, :update, or :destroy. The block of code is also passed the record object that the action is currently acting on.