Giter VIP home page Giter VIP logo

king_views's Introduction

KingViews

KingViews where extracted from SalesKing(www.SalesKing.eu) and consist of three different view helpers, KingForm( dl or labeled forms, enhanced inputs ), KingList( dl, tables ) and KingFormat( date, money, percent )

This stuff is not tested with rails 3.0 and testing is still stuck in SalesKing .. leaving space for forks.

Install

You must use HAML for your views .. the cure for erb eye cancer

gem install king_views

KingForm

Clean up your forms with helpers in rails haml views, with support for:

  • dl or labeled forms

  • shorter syntax for inputs

  • fieldset support (section)

  • labels auto translated when present in I18n or Gettext

  • info-text for auto translated info after each input

  • bundle a couple of inputs under one label or dt incl. css class based counter for the wrapper

  • based on rails action view helpers so all parameters are passed through(nearly all) to the original versions

Also see README in KingForm: github.com/salesking/king_views/tree/master/king_form/

Example

- dl_form_for @payment, :url => 'a path', :html => { :method => :post } do |f|
  -f.section do
    = f.hidden :lock_version
    = f.text :amount, :class => 'required', :value=> 'a custom val'
    = f.date :date, :title => t(:'from'), :info=>'Help me'
    = f.selection :payment_method
    - f.bundle 'status' do
      = f.radio :new_status, :closed, :checked=>true
      %span=t(:'status.closed')
      = f.radio :new_status, :open
      %span= t(:'activerecord.attributes.document.enum.status.open')
  -f.actions do
    = f.submit t(:'form.save')
    = secondary_link_to t(:'link.cancel'), parent_path

KingList

Use KingList for an easy markup inside your lists and detail views. Its not as extensive as KingForm and only provides the following:

  • easy to use tables for listings

  • dl-helper for detail views

  • action_icons & action_buttons(forms) for css enabled icon markup

Also see README in KingList: github.com/salesking/king_views/tree/master/king_list/

Quick Example

# Definition list for detail views
- dl_for @invoice do |f|
  = f.show :number
  = f.show :date # auto-formated date field see KingFormat
  = f.show :total # auto-formated money field see KingFormat

# table with header-klick sorting disabled and icons in first column
- table_for(@payments,{:sorting => false} ) do |t, payment|
  - t.action_column do
    = action_icon :edit, edit_payment_path(payment)
    = action_button 'delete', {:url=> 'some-path', :title => t(:'link.delete'), :method => :delete, :class=>'delete'}
  = t.column :date
  = t.column :amount, :td_options => {opt=>val}

KingFormat

Provides a semi-automatic formatting of date, money, percent fields. The field types are defined inside each model. And the view helpers will show a nice output.

Also see README github.com/salesking/king_views/tree/master/king_format/

Example:

#define date fields you model definition
class Invoice < ActiveRecord::Base
  has_date_fields :date, :valid_until
  has_money_fields :total, :price
end
# see above for usage in views

License

Copyright © 2009,2010 Georg Leciejewski, released under the MIT-LICENSE

king_views's People

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.