Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed merge conflict on Gemfile

  • Loading branch information...
commit 9ad7c5f9db6e40439841d3eec490fe728f70a0d2 2 parents 4a214d2 + bcc05e3
hurrycane authored
Showing with 9,906 additions and 1,216 deletions.
  1. +2 −0  Gemfile
  2. +1 −0  Gemfile.lock
  3. +71 −12 app/controllers/rails_admin_controller.rb
  4. +172 −6 app/helpers/rails_admin_helper.rb
  5. +6 −6 app/views/layouts/_flash.html.erb
  6. +45 −33 app/views/layouts/dashboard.html.erb
  7. +52 −0 app/views/layouts/delete.html.erb
  8. +82 −45 app/views/layouts/form.html.erb
  9. +47 −39 app/views/layouts/list.html.erb
  10. +16 −15 app/views/rails_admin/_belongs_to_association.html.erb
  11. +3 −1 app/views/rails_admin/_big_decimal.html.erb
  12. +4 −3 app/views/rails_admin/_boolean.html.erb
  13. +4 −6 app/views/rails_admin/_date.html.erb
  14. +4 −6 app/views/rails_admin/_datetime.html.erb
  15. +4 −6 app/views/rails_admin/_float.html.erb
  16. +69 −9 app/views/rails_admin/_has_many_association.html.erb
  17. +16 −16 app/views/rails_admin/_has_one_association.html.erb
  18. +4 −6 app/views/rails_admin/_integer.html.erb
  19. +6 −0 app/views/rails_admin/_navigation.html.erb
  20. +16 −11 app/views/rails_admin/_properties.html.erb
  21. +7 −10 app/views/rails_admin/_string.html.erb
  22. +4 −7 app/views/rails_admin/_text.html.erb
  23. +5 −6 app/views/rails_admin/_time.html.erb
  24. +6 −6 app/views/rails_admin/_timestamp.html.erb
  25. +33 −28 app/views/rails_admin/delete.html.erb
  26. +26 −14 app/views/rails_admin/edit.html.erb
  27. +75 −21 app/views/rails_admin/index.html.erb
  28. +84 −84 app/views/rails_admin/list.html.erb
  29. +24 −9 app/views/rails_admin/new.html.erb
  30. +3 −3 db/migrate/001_create_divisions_migration.rb
  31. +10 −10 db/migrate/002_create_drafts_migration.rb
  32. +3 −3 db/migrate/003_create_leagues_migration.rb
  33. +11 −11 db/migrate/004_create_players_migration.rb
  34. +13 −13 db/migrate/005_create_teams_migration.rb
  35. +1 −0  lib/rails_admin/abstract_model.rb
  36. +1 −1  lib/rails_admin/active_record_support.rb
  37. BIN  public/images/.DS_Store
  38. BIN  public/images/add_new.png
  39. BIN  public/images/arrow-down.gif
  40. BIN  public/images/arrow-up.gif
  41. BIN  public/images/arrow_left.png
  42. BIN  public/images/arrow_right.png
  43. BIN  public/images/background.png
  44. BIN  public/images/bullet_arrow_down.png
  45. BIN  public/images/bullet_arrow_down_smaller.png
  46. BIN  public/images/bullet_arrow_up.png
  47. BIN  public/images/bullet_arrow_up_smaller.png
  48. BIN  public/images/bullet_black.png
  49. BIN  public/images/bullet_white.png
  50. BIN  public/images/calendar.png
  51. BIN  public/images/cancel.png
  52. BIN  public/images/changelist-bg.gif
  53. BIN  public/images/changelist-bg_rtl.gif
  54. BIN  public/images/chooser-bg.gif
  55. BIN  public/images/chooser_stacked-bg.gif
  56. BIN  public/images/clock.png
  57. BIN  public/images/cross.png
  58. BIN  public/images/default-bg-reverse.gif
  59. BIN  public/images/default-bg.gif
  60. BIN  public/images/delete_confirmation.png
  61. BIN  public/images/deleted-overlay.gif
  62. BIN  public/images/error.png
  63. BIN  public/images/fast_btn.png
  64. BIN  public/images/handler.png
  65. BIN  public/images/icon-no.gif
  66. BIN  public/images/icon-unknown.gif
  67. BIN  public/images/icon-yes.gif
  68. BIN  public/images/icon_addlink.gif
  69. BIN  public/images/icon_alert.gif
  70. BIN  public/images/icon_calendar.gif
  71. BIN  public/images/icon_changelink.gif
  72. BIN  public/images/icon_clock.gif
  73. BIN  public/images/icon_deletelink.gif
  74. BIN  public/images/icon_error.gif
  75. BIN  public/images/icon_searchbox.png
  76. BIN  public/images/icon_success.gif
  77. BIN  public/images/inline-delete-8bit.png
  78. BIN  public/images/inline-delete.png
  79. BIN  public/images/inline-restore-8bit.png
  80. BIN  public/images/inline-restore.png
  81. BIN  public/images/inline-splitter-bg.gif
  82. BIN  public/images/magnifier.png
  83. BIN  public/images/nav-bg-grabber.gif
  84. BIN  public/images/nav-bg-reverse.gif
  85. BIN  public/images/nav-bg.gif
  86. BIN  public/images/save.png
  87. BIN  public/images/saveandadd.png
  88. BIN  public/images/search.png
  89. BIN  public/images/selector-search.gif
  90. BIN  public/images/selector_stacked-add.gif
  91. BIN  public/images/selector_stacked-remove.gif
  92. BIN  public/images/tool-left.gif
  93. BIN  public/images/tool-left_over.gif
  94. BIN  public/images/tool-right.gif
  95. BIN  public/images/tool-right_over.gif
  96. BIN  public/images/tooltag-add.gif
  97. BIN  public/images/tooltag-add_over.gif
  98. BIN  public/images/tooltag-arrowright.gif
  99. BIN  public/images/tooltag-arrowright_over.gif
  100. BIN  public/images/undo.png
  101. BIN  public/javascripts/.DS_Store
  102. +182 −0 public/javascripts/associations.js
  103. +911 −0 public/javascripts/datepicker.js
  104. +22 −0 public/javascripts/prototype-base-extensions.js
  105. +230 −0 public/javascripts/prototype-date-extensions.js
  106. 0  public/{javascripts → javascripts_old}/CollapsedFieldsets.js
  107. 0  public/{javascripts → javascripts_old}/DateTimeShortcuts.js
  108. 0  public/{javascripts → javascripts_old}/RelatedObjectLookups.js
  109. 0  public/{javascripts → javascripts_old}/SelectBox.js
  110. 0  public/{javascripts → javascripts_old}/SelectFilter2.js
  111. 0  public/{javascripts → javascripts_old}/actions.js
  112. 0  public/{javascripts → javascripts_old}/application.js
  113. 0  public/{javascripts → javascripts_old}/calendar.js
  114. 0  public/{javascripts → javascripts_old}/controls.js
  115. 0  public/{javascripts → javascripts_old}/core.js
  116. 0  public/{javascripts → javascripts_old}/dateparse.js
  117. 0  public/{javascripts → javascripts_old}/dragdrop.js
  118. 0  public/{javascripts → javascripts_old}/effects.js
  119. 0  public/{javascripts → javascripts_old}/getElementsBySelector.js
  120. 0  public/{javascripts → javascripts_old}/i18n.js
  121. 0  public/{javascripts → javascripts_old}/master.js
  122. 0  public/{javascripts → javascripts_old}/ordering.js
  123. +4,874 −0 public/javascripts_old/prototype.js
  124. 0  public/{javascripts → javascripts_old}/rails.js
  125. 0  public/{javascripts → javascripts_old}/timeparse.js
  126. 0  public/{javascripts → javascripts_old}/urlify.js
  127. +237 −746 public/stylesheets/base.css
  128. +344 −0 public/stylesheets/create.css
  129. +220 −24 public/stylesheets/dashboard.css
  130. +108 −0 public/stylesheets/datepicker.css
  131. +38 −0 public/stylesheets/delete.css
  132. +301 −0 public/stylesheets/list.css
  133. 0  public/{stylesheets → stylesheets_old}/.gitkeep
  134. +746 −0 public/stylesheets_old/base.css
  135. 0  public/{stylesheets → stylesheets_old}/changelists.css
  136. +24 −0 public/stylesheets_old/dashboard.css
  137. 0  public/{stylesheets → stylesheets_old}/forms.css
  138. 0  public/{stylesheets → stylesheets_old}/global.css
  139. 0  public/{stylesheets → stylesheets_old}/ie.css
  140. 0  public/{stylesheets → stylesheets_old}/layout.css
  141. 0  public/{stylesheets → stylesheets_old}/login.css
  142. 0  public/{stylesheets → stylesheets_old}/master.css
  143. 0  public/{stylesheets → stylesheets_old}/null.css
  144. 0  public/{stylesheets → stylesheets_old}/patch-iewin.css
  145. 0  public/{stylesheets → stylesheets_old}/rtl.css
  146. +739 −0 public/stylesheets_old/style.css
  147. 0  public/{stylesheets → stylesheets_old}/widgets.css
View
2  Gemfile
@@ -11,6 +11,8 @@ group :test, :development do
gem "rspec-rails", ">= 2.0.0.beta.19"
end
+gem 'builder'
+
# Use unicorn as the web server
# gem 'unicorn'
View
1  Gemfile.lock
@@ -86,6 +86,7 @@ PLATFORMS
ruby
DEPENDENCIES
+ builder
rails (= 3.0.0.rc)
rspec-rails (>= 2.0.0.beta.19)
sqlite3-ruby
View
83 app/controllers/rails_admin_controller.rb
@@ -4,19 +4,27 @@ class RailsAdminController < ApplicationController
before_filter :get_model, :except => [:index]
before_filter :get_object, :only => [:edit, :update, :delete, :destroy]
before_filter :get_attributes, :only => [:create, :update]
+ before_filter :set_plugin_name
+ before_filter :check_for_cancel
def index
+ @page_name = "Site administration"
+ @page_type = "dashboard"
+
@abstract_models = MerbAdmin::AbstractModel.all
render(:layout => 'dashboard')
end
def list
+ @abstract_models = MerbAdmin::AbstractModel.all
+
options = {}
options.merge!(get_sort_hash)
options.merge!(get_sort_reverse_hash)
options.merge!(get_query_hash(options))
options.merge!(get_filter_hash(options))
per_page = 20 # HAX FIXME
+
# per_page = MerbAdmin[:per_page]
if params[:all]
options.merge!(:limit => per_page * 2)
@@ -31,28 +39,55 @@ def list
options.delete(:limit)
end
@record_count = @abstract_model.count(options)
- render(:layout => 'list')
+
+ @page_name = "Select " + @abstract_model.pretty_name.downcase + " to edit"
+ @page_type = @abstract_model.pretty_name.downcase
+ render :layout => 'list'
end
def new
@object = @abstract_model.new
- render(:layout => 'form')
+
+ @page_name = action_name.capitalize + " " + @abstract_model.pretty_name.downcase
+ @abstract_models = MerbAdmin::AbstractModel.all
+ @page_type = @abstract_model.pretty_name.downcase
+
+ render :layout => 'form'
end
def create
+
@object = @abstract_model.new(@attributes)
+
+ @page_name = action_name.capitalize + " " + @abstract_model.pretty_name.downcase
+ @abstract_models = MerbAdmin::AbstractModel.all
+ @page_type = @abstract_model.pretty_name.downcase
+
+
if @object.save && update_all_associations
redirect_to_on_success
else
render_error
end
+
end
def edit
+
+ @page_name = action_name.capitalize + " " + @abstract_model.pretty_name.downcase
+ @abstract_models = MerbAdmin::AbstractModel.all
+ @page_type = @abstract_model.pretty_name.downcase
+
render(:layout => 'form')
end
def update
+ @page_name = action_name.capitalize + " " + @abstract_model.pretty_name.downcase
+ @abstract_models = MerbAdmin::AbstractModel.all
+ @page_type = @abstract_model.pretty_name.downcase
+
+ update_all_associations
+
if @object.update_attributes(@attributes) && update_all_associations
redirect_to_on_success
else
@@ -61,26 +96,33 @@ def update
end
def delete
- render(:layout => 'form')
+ @page_name = action_name.capitalize + " " + @abstract_model.pretty_name.downcase
+ @abstract_models = MerbAdmin::AbstractModel.all
+ @page_type = @abstract_model.pretty_name.downcase
+
+ render(:layout => 'delete')
end
def destroy
@object.destroy
- redirect_to(url_for(:rails_admin_list, :model_name => @abstract_model.to_param), :message => {:notice => "#{@abstract_model.pretty_name} was successfully destroyed"})
+ flash[:notice] = "#{@abstract_model.pretty_name} was successfully destroyed"
+ redirect_to rails_admin_list_path(:model_name => @abstract_model.to_param)
end
private
def get_model
model_name = to_model_name(params[:model_name])
+ # FIXME: What method AbstractModel calls? => initialize.
@abstract_model = MerbAdmin::AbstractModel.new(model_name)
@properties = @abstract_model.properties
+
end
def get_object
@object = @abstract_model.get(params[:id])
# FIXME
- raise NotFound unless @object
+ NotFound unless @object
end
def get_sort_hash
@@ -133,6 +175,7 @@ def get_filter_hash(options)
def get_attributes
@attributes = params[@abstract_model.to_param] || {}
+
# Delete fields that are blank
@attributes.each do |key, value|
@attributes[key] = nil if value.blank?
@@ -140,8 +183,12 @@ def get_attributes
end
def update_all_associations
+
@abstract_model.associations.each do |association|
+
ids = (params[:associations] || {}).delete(association[:name])
+
+
case association[:type]
when :has_one
update_association(association, ids)
@@ -170,19 +217,20 @@ def redirect_to_on_success
param = @abstract_model.to_param
pretty_name = @abstract_model.pretty_name
action = params[:action]
- if params[:_continue]
- redirect_to(url_for(:rails_admin_edit, :model_name => param, :id => @object.id), :message => {:notice => "#{pretty_name} was successfully #{action}d"})
- elsif params[:_add_another]
- redirect_to(url_for(:rails_admin_new, :model_name => param), :notice => "#{pretty_name} was successfully #{action}d")
+
+ if params[:_add_another]
+ flash[:notice] = "#{pretty_name} was successfully #{action}d"
+ redirect_to rails_admin_new_path( :model_name => param)
else
- redirect_to(url_for(:rails_admin_list, :model_name => param), :notice => "#{pretty_name} was successfully #{action}d")
+ flash[:notice] = "#{pretty_name} was successfully #{action}d"
+ redirect_to rails_admin_list_path(:model_name => param)
end
end
def render_error
action = params[:action]
flash.now[:alert] = "#{@abstract_model.pretty_name} failed to be #{action}d"
- render(:new, :layout => 'form')
+ render :new, :layout => 'form'
end
private
@@ -190,5 +238,16 @@ def render_error
def to_model_name(param)
param.split("::").map{|x| x.camelize}.join("::")
end
+
+ def set_plugin_name
+ @plugin_name = "RailsAdmin"
+ end
+
+ def check_for_cancel
+ if params[:_continue]
+ flash[:notice] = "No actions where taken!"
+ redirect_to rails_admin_list_path( :model_name => @abstract_model.to_param)
+ end
+ end
-end
+end
View
178 app/helpers/rails_admin_helper.rb
@@ -1,6 +1,165 @@
require 'builder'
module RailsAdminHelper
+
+ def calculateWidth(properties)
+ # local variables
+ total = 0
+ set = []
+
+ # variables used in loop
+ partialTotal = 0
+ temp = []
+
+ # loop through properties
+ properties.each do |property|
+ # get width for the current property
+ width = getWidthForColumn(property)
+
+ # if properties that were gathered so far have the width
+ # over 697 make a set for them
+ if partialTotal + width >= 697
+ set << { :p => temp, :size =>partialTotal}
+ partialTotal = 0
+ temp = []
+ end
+
+ # continue to add properties to set
+ temp << property
+ partialTotal += width
+ total += width
+ end
+
+ # add final set to returned value
+ set << { :p => temp, :size =>partialTotal}
+
+ return set
+ end
+
+ # calculate sets
+ # expand set
+
+ def justifyProperties(sets, current_set)
+ total = 697
+ style = {}
+
+ properties = sets[current_set][:p]
+
+ # calculate the maximum distance
+ total = sets.size == 1 ? 784 : 744
+ max_sets = sets.size-2 > 1 ? sets.size-2 : 1
+ total = current_set.between?(1,max_sets) ? 704 : total
+
+ columnOffset = total-sets[current_set][:size]
+
+ per_property = columnOffset/properties.size
+
+ offset = columnOffset - per_property*properties.size
+
+ properties.each do |property|
+ property_type = getColumnType(property,"")
+ property_width = getWidthForColumn(property)
+
+ style[property_type] ||= {:size => 0, :occ => 0, :width => 0}
+
+ style[property_type][:size] += per_property
+ style[property_type][:occ] += 1
+ style[property_type][:width] = property_width + style[property_type][:size] / style[property_type][:occ]
+
+ end
+
+ other = []
+ if total == 784
+ other = ["otherHeaderLeft","otherHeaderRight","otherLeft","otherRight"]
+ elsif total == 744
+ if current_set == 0
+ other = ["otherHeaderLeft","otherLeft"]
+ else
+ other = ["otherHeaderRight","otherRight"]
+ end
+ end
+
+ return style, other
+ end
+
+ def getColumnSet(properties)
+ sets = calculateWidth(properties)
+
+ current_set ||= params[:set].to_i
+
+ raise NotFound if sets.size <= current_set
+ selected_set = sets[current_set][:p]
+
+ style, other = justifyProperties(sets, current_set)
+
+ return style, other, selected_set
+ end
+
+ def getWidthForColumn(property)
+ property_type = property[:type]
+ property_name = property[:name]
+
+ case property_type
+ when :boolean
+ return 60
+ when :datetime
+ return 170
+ when :date
+ return 90
+ when :time
+ return 60
+ when :string
+ if property[:length] < 100
+ return 180
+ else
+ return 250
+ end
+ when :text
+ return 250
+ when :integer
+ if property_name == :id
+ return 46
+ else
+ return 80
+ end
+ when :float
+ return 110
+ else
+ end
+ end
+
+ def getColumnType(property,type)
+ property_type = property[:type]
+ property_name = property[:name]
+
+ case property_type
+ when :boolean
+ "bool#{type}"
+ when :datetime
+ "dateTime#{type}"
+ when :date
+ "date#{type}"
+ when :time
+ "time#{type}"
+ when :string
+ if property[:length] < 100
+ "smallString#{type}"
+ else
+ "bigString#{type}"
+ end
+ when :text
+ "text#{type}"
+ when :integer
+ if property_name == :id
+ "id#{type}"
+ else
+ "int#{type}"
+ end
+ when :float
+ "float#{type}"
+ else
+ end
+ end
def object_label(object)
if object.nil?
@@ -14,16 +173,18 @@ def object_label(object)
end
end
+ # FIXME same as getColumnType - next iteration when adding associations
def object_property(object, property)
property_type = property[:type]
property_name = property[:name]
- return "" if object.send(property_name).nil?
+ return "".html_safe if object.send(property_name).nil?
+
case property_type
when :boolean
if object.send(property_name) == true
- Builder::XmlMarkup.new.img(:src => image_path("icon-yes.gif"), :alt => "True")
+ Builder::XmlMarkup.new.img(:src => image_path("bullet_black.png"), :alt => "True").html_safe
else
- Builder::XmlMarkup.new.img(:src => image_path("icon-no.gif"), :alt => "False")
+ Builder::XmlMarkup.new.img(:src => image_path("bullet_white.png"), :alt => "False").html_safe
end
when :datetime
object.send(property_name).strftime("%b. %d, %Y, %I:%M%p")
@@ -33,7 +194,7 @@ def object_property(object, property)
object.send(property_name).strftime("%I:%M%p")
when :string
if property_name.to_s =~ /(image|logo|photo|photograph|picture|thumb|thumbnail)_ur(i|l)/i
- Builder::XmlMarkup.new.img(:src => object.send(property_name), :width => 10, :height => 10)
+ Builder::XmlMarkup.new.img(:src => object.send(property_name), :width => 10, :height => 10).html_safe
else
object.send(property_name)
end
@@ -85,15 +246,19 @@ def object_property(object, property)
# Provides the base url to use in the page navigation links.
# Defaults to ''
def paginate(current_page, page_count, options = {})
+
options[:left_cut_label] ||= '&hellip;'
options[:right_cut_label] ||= '&hellip;'
options[:outer_window] ||= 2
options[:inner_window] ||= 7
options[:page_param] ||= 'page'
- options[:url] ||= ''
+ options[:url] ||= ""
url = options.delete(:url)
- url << (url.include?('?') ? '&' : '?') << options[:page_param]
+ url = url.to_a.collect{|x| x.join("=")}.join("&")
+
+ url += (url.include?('=') ? '&' : '') + options[:page_param]
+ url = "?"+url
pages = {
:all => (1..page_count).to_a,
@@ -133,6 +298,7 @@ def paginate(current_page, page_count, options = {})
[pages[:left], pages[:center], pages[:right]].each do |p|
p.each do |page_number|
+
case page_number
when String
b << page_number
View
12 app/views/layouts/_flash.html.erb
@@ -1,10 +1,10 @@
<% if flash && flash[:error] %>
- <p class="errornote">
- <%= flash[:error] %>
- </p>
+ <div id="error">
+ <%= flash[:error] %>
+ </div>
<% end %>
<% if flash && flash[:notice] %>
- <ul class="flashlist">
- <li><%= flash[:notice] %></li>
- </ul>
+ <div id="highlight">
+ <%= flash[:notice] %>
+ </div>
<% end %>
View
78 app/views/layouts/dashboard.html.erb
@@ -1,37 +1,49 @@
-<%
- # FIXME
- # slice_name = "RailsAdmin" + (RailsAdmin[:app_name].blank? ? "" : " for #{RailsAdmin[:app_name]}")
- slice_name = "RailsAdmin"
- page_name = "Site administration"
-%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-us" lang="en-us">
- <head>
- <meta http-equiv="content-type" content="text/html; charset=utf-8" />
- <meta name="robots" content="NONE,NOARCHIVE" />
- <title><%= page_name %> | <%= slice_name %></title>
- <!-- FIXME: These should use something like "public_path_for" from merb-slices -->
- <%= stylesheet_link_tag('base') %>
- <%= stylesheet_link_tag('dashboard') %>
- <!--[if lte IE 7]><%= stylesheet_link_tag('ie') %><![endif]-->
- </head>
- <body class="admin-slice dashboard">
- <div id="container">
- <div id="header">
- <div id="branding">
- <h1 id="site-name">
- <%= slice_name %>
- </h1>
- </div>
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <meta name="robots" content="NONE,NOARCHIVE" />
+ <title><%= @page_name %> | <%= @plugin_name %></title>
+ <%= stylesheet_link_tag('base') %>
+ <%= stylesheet_link_tag('dashboard') %>
+
+
+</head>
+
+<body>
+ <div id="wraper">
+ <div id="header">
+ <div id="headerLeft">
+ <ul class="breadcrumb">
+ <li>
+ <%= link_to("Dashboard", rails_admin_dashboard_path) %>
+ </li>
+ </ul>
+ <h1>Rails Admin</h1>
</div>
-<%= render(:partial => 'layouts/flash', :locals => {:flash => flash}) -%>
- <div id="content" class="colMS">
- <h1>
- <%= page_name %>
- </h1>
-<%= content_for(:layout) -%>
+
+<%= render(:partial => 'rails_admin/navigation', :locals => {:abstract_models => @abstract_models}) %>
+
+ <div id="headerRight">
+ <ul class="breadcrumb">
+ <li>
+ <a href="#">John Doe</a>
+ </li>
+ <li>|</li>
+ <li>
+ <a href="#">My profile</a>
+ </li>
+ <li>|</li>
+ <li>
+ <a href="#">Log out</a>
+ </li>
+ </ul>
</div>
- <div id="footer"></div>
</div>
- </body>
-</html>
+
+ <div id="content">
+<%= content_for(:layout) %>
+ </div>
+ </div>
+</body>
+</html>
View
52 app/views/layouts/delete.html.erb
@@ -0,0 +1,52 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <title><%= @page_name %> | <%= @plugin_name %></title>
+ <%= stylesheet_link_tag('base.css') %>
+ <%= stylesheet_link_tag('delete.css') %>
+ <title><%= @page_name %></title>
+ <link href="base.css" rel="stylesheet" type="text/css" />
+ <link href="delete.css" rel="stylesheet" type="text/css" />
+</head>
+
+<body>
+ <div id="wraper">
+ <div id="header">
+ <div id="headerLeft">
+ <ul class="breadcrumb">
+ <li>
+ <%= link_to("Dashboard", rails_admin_dashboard_path) %>
+ &rsaquo;
+ </li>
+ <li>
+ <%= link_to(@abstract_model.pretty_name, rails_admin_list_path(:model_name => @abstract_model.to_param)) %>
+ &rsaquo;
+ </li>
+ <li>
+ <%= link_to(@page_name, rails_admin_new_path(:model_name => @abstract_model.to_param)) %>
+ </li>
+ </ul>
+
+ <h1>Rails Admin</h1>
+ </div>
+
+<%= render(:partial => 'rails_admin/navigation', :locals => {:abstract_models => @abstract_models}) %>
+
+ <div id="headerRight">
+ <ul class="breadcrumb">
+ <li><a href="#">John Doe</a></li>
+ <li>|</li>
+ <li><a href="#">My profile</a></li>
+ <li>|</li>
+ <li><a href="#">Log out</a></li>
+ </ul>
+ </div>
+ </div>
+
+ <div id="content">
+<%= yield %>
+ </div>
+ </div>
+</body>
+</html>
View
127 app/views/layouts/form.html.erb
@@ -1,49 +1,86 @@
-<%
- slice_name = "RailsAdmin"
- page_name = action_name.capitalize + " " + @abstract_model.pretty_name.downcase
-%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-us" lang="en-us">
- <head>
- <meta http-equiv="content-type" content="text/html; charset=utf-8" />
- <meta name="robots" content="NONE,NOARCHIVE" />
- <title><%= page_name %> | <%= slice_name %></title>
- <!-- FIXME: These should use something like "public_path_for" from merb-slices -->
- <%= stylesheet_link_tag('base.css') %>
- <%= stylesheet_link_tag('forms.css') %>
- <!--[if lte IE 7]><%= stylesheet_link_tag('ie.css') %><![endif]-->
- <%= javascript_include_tag('i18n.js') %>
- <%= javascript_include_tag('core.js') %>
- <%= javascript_include_tag('RelatedObjectLookups.js') %>
- <%= javascript_include_tag('getElementsBySelector.js') %>
- <%= javascript_include_tag('actions.js') %>
- <%= javascript_include_tag('SelectBox.js') %>
- <%= javascript_include_tag('SelectFilter2.js') %>
- <%= javascript_include_tag('calendar.js') %>
- <%= javascript_include_tag('DateTimeShortcuts.js') %>
- </head>
- <body class="admin-slice change-form">
- <div id="container">
- <div id="header">
- <div id="branding">
- <h1 id="site-name">
- <%= slice_name %>
- </h1>
- </div>
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <title><%= @page_name %> | <%= @plugin_name %></title>
+ <%= stylesheet_link_tag('base.css') %>
+ <%= stylesheet_link_tag('create.css') %>
+
+ <%= javascript_include_tag('prototype.js') %>
+ <%= javascript_include_tag('prototype-base-extensions.js') %>
+ <%= javascript_include_tag('prototype-date-extensions.js') %>
+ <%= javascript_include_tag('getElementsBySelector.js') %>
+ <%= javascript_include_tag('datepicker.js') %>
+ <%= javascript_include_tag('associations.js') %>
+ <%= stylesheet_link_tag('datepicker.css') %>
+
+
+ <script type="text/javascript" language="javascript">
+ Control.DatePicker.Locale['en_US'] = {
+ dateTimeFormat: 'dd/MM/yyyy HH:mm',
+ dateFormat: 'dd/MM/yyyy'}
+
+
+ document.observe("dom:loaded", function() {
+ $$(".dateField").each(function(elem){
+ new Control.DatePicker(elem, {icon: '/images/calendar.png'});
+ });
+ // .dateField, .timestampField, .timeField, .datetimeField
+ $$(".timestampField").each(function(elem){
+ new Control.DatePicker(elem, {icon: '/images/clock.png',timePicker: true, timePickerAdjacent: true});
+ });
+ $$(".timeField").each(function(elem){
+ new Control.DatePicker(elem, {icon: '/images/clock.png',timePicker: true,datePicker :false});
+ });
+ $$(".datetimeField").each(function(elem){
+ new Control.DatePicker(elem, {icon: '/images/calendar.png',timePicker: true, timePickerAdjacent: true});
+ });
+ });
+
+ </script>
+
+ <title><%= @page_name %></title>
+ <link href="base.css" rel="stylesheet" type="text/css" />
+ <link href="create.css" rel="stylesheet" type="text/css" />
+</head>
+
+<body>
+ <div id="wraper">
+ <div id="header">
+ <div id="headerLeft">
+ <ul class="breadcrumb">
+ <li>
+ <%= link_to("Dashboard", rails_admin_dashboard_path) %>
+ &rsaquo;
+ </li>
+ <li>
+ <%= link_to(@abstract_model.pretty_name, rails_admin_list_path(:model_name => @abstract_model.to_param)) %>
+ &rsaquo;
+ </li>
+ <li>
+ <%= link_to(@page_name, rails_admin_new_path(:model_name => @abstract_model.to_param)) %>
+ </li>
+ </ul>
+
+ <h1>Rails Admin</h1>
+ </div>
+
+<%= render(:partial => 'rails_admin/navigation', :locals => {:abstract_models => @abstract_models}) %>
+
+ <div id="headerRight">
+ <ul class="breadcrumb">
+ <li><a href="#">John Doe</a></li>
+ <li>|</li>
+ <li><a href="#">My profile</a></li>
+ <li>|</li>
+ <li><a href="#">Log out</a></li>
+ </ul>
</div>
- <div class="breadcrumbs">
- <%= link_to("Home", rails_admin_dashboard_path) %> &rsaquo;
- <%= link_to(@abstract_model.pretty_name, rails_admin_list_path(:model_name => @abstract_model.to_param)) %> &rsaquo;
- <%= page_name %>
- </div>
-<%= partial('layout/flash', :flash => flash) unless flash.blank? %>
- <div id="content" class="colM">
- <h1>
- <%= page_name %>
- </h1>
-<%= yield %>
- </div>
- <div id="footer"></div>
</div>
- </body>
+
+ <div id="content">
+<%= yield %>
+ </div>
+ </div>
+</body>
</html>
View
86 app/views/layouts/list.html.erb
@@ -1,43 +1,51 @@
-<%
- slice_name = "RailsAdmin"
- page_name = "Select " + @abstract_model.pretty_name.downcase + " to edit"
-%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-us" lang="en-us">
- <head>
- <meta http-equiv="content-type" content="text/html; charset=utf-8" />
- <meta name="robots" content="NONE,NOARCHIVE" />
- <title><%= page_name %> | <%= slice_name %></title>
- <!-- FIXME: These should use something like "public_path_for" from merb-slices -->
- <%= stylesheet_link_tag('base.css') %>
- <%= stylesheet_link_tag('changelists.css') %>
- <!--[if lte IE 7]><%= stylesheet_link_tag('ie.css') %><![endif]-->
- <%= javascript_include_tag('core.js') %>
- <%= javascript_include_tag('RelatedObjectLookups.js') %>
- <%= javascript_include_tag('getElementsBySelector.js') %>
- <%= javascript_include_tag('actions.js') %>
- </head>
- <body class="admin-slice change-list">
- <div id="container">
- <div id="header">
- <div id="branding">
- <h1 id="site-name">
- <%= slice_name %>
- </h1>
- </div>
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <meta name="robots" content="NONE,NOARCHIVE" />
+ <title><%= @page_name %> | <%= @plugin_name %></title>
+ <%= stylesheet_link_tag('base') %>
+ <%= stylesheet_link_tag('list') %>
+</head>
+
+<body>
+ <div id="wraper">
+ <div id="header">
+ <div id="headerLeft">
+ <ul class="breadcrumb">
+ <li>
+ <%= link_to("Dashboard", rails_admin_dashboard_path) %>
+ &rsaquo;
+ </li>
+ <li>
+ <%= link_to(@abstract_model.pretty_name, rails_admin_list_path(:model_name => @abstract_model.to_param)) %>
+ </li>
+ </ul>
+ <h1>Rails Admin</h1>
</div>
- <div class="breadcrumbs">
- <%= link_to("Home", rails_admin_dashboard_path) %> &rsaquo;
- <%= @abstract_model.pretty_name %>
+
+<!-- FIXME no need to get whole array list with every model -->
+<%= render(:partial => 'rails_admin/navigation', :locals => {:abstract_models => @abstract_models}) %>
+
+ <div id="headerRight">
+ <ul class="breadcrumb">
+ <li>
+ <a href="#">John Doe</a>
+ </li>
+ <li>|</li>
+ <li>
+ <a href="#">My profile</a>
+ </li>
+ <li>|</li>
+ <li>
+ <a href="#">Log out</a>
+ </li>
+ </ul>
</div>
-<%= partial('layout/flash', :flash => flash) unless flash.blank? %>
- <div id="content" class="flex">
- <h1>
- <%= page_name %>
- </h1>
-<%= yield %>
- </div>
- <div id="footer"></div>
</div>
- </body>
-</html>
+
+ <div id="content">
+<%= content_for(:layout) %>
+ </div>
+</body>
+</html>
View
31 app/views/rails_admin/_belongs_to_association.html.erb
@@ -2,28 +2,29 @@
child_key = belongs_to_association[:child_key].first
collection = MerbAdmin::AbstractModel.new(belongs_to_association[:parent_model]).all.map{|object| [object_label(object), object.id]}.sort_by{|object| object.first}
selected = @object.send(child_key)
+
+ if selected.nil? && params["associations"]
+ selected = params["associations"][child_key.to_param.pluralize].to_i
+ end
+
label = belongs_to_association[:pretty_name]
required = false
errors_exist = !(@object.errors[child_key].nil? || @object.errors[child_key].empty?)
@properties.select{|property| property[:name] == child_key}.each do |property|
required = true unless property[:nullable?]
end
+ model_name = @abstract_model.to_param
%>
- <fieldset class="module aligned">
+
<h2><%= label %></h2>
- <div class="<%= errors_exist ? "form-row errors" : "form-row"%>">
- <% if errors_exist %>
- <ul class="errorlist">
- <% @object.errors[child_key].each do |error| %>
- <li><%= error %></li>
+ <div class="formSection">
+ <p>
+ <%= label_tag label %>
+ <%= select model_name, child_key, collection, {:include_blank => true, :selected => selected}, :class => "selectField #{errors_exist ? "errorField" : nil}" %>
+ <% if errors_exist %>
+ <span class="errorMessage"><%= "#{child_key.to_param.capitalize} #{@object.errors[child_key].first}" %></span>
<% end %>
- </ul>
- <% end %>
- <div>
- <%= select("object", child_key, collection, {:include_blank => true, :selected => selected.to_s, :label => label}) %>
- <p class="help">
- <%= required ? "Required." : "Optional." %>
- </p>
- </div>
+ </p>
+
+
</div>
- </fieldset>
View
4 app/views/rails_admin/_big_decimal.html.erb
@@ -3,9 +3,11 @@
length = property[:length]
label = property[:pretty_name]
required = !property[:nullable?] || property[:serial?]
+ model_name = @abstract_model.to_param
%>
<div>
- <%= text_field(property_name, :maxlength => length, :label => label) %>
+ <%= label_tag label %>
+ <%= text_field model_name, property_name, :maxlength => length, :label => label %>
<p class="help">
<%= required ? "Required." : "Optional." %>
</p>
View
7 app/views/rails_admin/_boolean.html.erb
@@ -1,7 +1,8 @@
<%
property_name = property[:name]
label = property[:pretty_name]
+ model_name = @abstract_model.to_param
%>
- <div>
- <%= check_box(property_name, :label => label) %>
- </div>
+
+ <%= label_tag label %>
+ <%= check_box model_name, property_name, :checked => @object.send(property_name) ? true : false %>
View
10 app/views/rails_admin/_date.html.erb
@@ -3,10 +3,8 @@
value = @object.send(property_name)
label = property[:pretty_name]
required = !property[:nullable?]
+ model_name = @abstract_model.to_param
%>
- <div>
- <%= text_field(property_name, :class => "vDateField", :value => value.respond_to?(:strftime) ? value.strftime("%Y-%m-%d") : nil, :label => label) %>
- <p class="help">
- <%= required ? "Required." : "Optional." %>
- </p>
- </div>
+ <%= label_tag "#{property_name}", label %>
+
+ <%= text_field model_name, property_name, :class => "dateField #{errors_exist ? "errorField" : nil}", :value => object_property(@object,property) %>
View
10 app/views/rails_admin/_datetime.html.erb
@@ -3,10 +3,8 @@
value = @object.send(property_name)
label = property[:pretty_name]
required = !property[:nullable?]
+ model_name = @abstract_model.to_param
%>
- <div>
- <%= text_field(property_name, :class => "vDateField", :value => value.respond_to?(:strftime) ? value.strftime("%Y-%m-%d %H:%M:%S") : nil, :label => label) %>
- <p class="help">
- <%= required ? "Required." : "Optional." %>
- </p>
- </div>
+ <%= label_tag "#{property_name}", label %>
+
+ <%= text_field model_name, property_name, :maxlength => length, :class => "datetimeField #{errors_exist ? "errorField" : nil}", :value => object_property(@object,property) %>
View
10 app/views/rails_admin/_float.html.erb
@@ -3,10 +3,8 @@
length = property[:length]
label = property[:pretty_name]
required = !property[:nullable?] || property[:serial?]
+ model_name = @abstract_model.to_param
%>
- <div>
- <%= text_field(property_name, :maxlength => length, :label => label) %>
- <p class="help">
- <%= required ? "Required." : "Optional." %>
- </p>
- </div>
+ <%= label_tag "#{property_name}", label %>
+
+ <%= text_field model_name, property_name, :maxlength => length, :class => "floatField #{errors_exist ? "errorField" : nil}", :value => object_property(@object,property) %>
View
78 app/views/rails_admin/_has_many_association.html.erb
@@ -1,16 +1,76 @@
<%
association_name = has_many_association[:name]
+ child_key = has_many_association[:child_key].first
collection = MerbAdmin::AbstractModel.new(has_many_association[:child_model]).all.map{|object| [object_label(object), object.id]}.sort_by{|object| object.first}
- selected = @object.send(association_name)
+
+ # for edit action
+ selected = @object.send(association_name).map{|object|
+ [object_label(object), object.id]
+ }.sort_by{|object| object.first}
+
+ # if error accurs - show the selected associations
+ if params["associations"]
+ select = params["associations"][association_name.to_param.pluralize].to_a.map{|o| o.to_i}
+ selected = collection.map{|t|
+ t if select.include?(t[1])
+ }.compact
+
+ end
+
+ # exclude selected from the original collection
+ collection = collection.map{|t|
+ t if not selected.include?(t)
+ }.compact
+
label = has_many_association[:pretty_name]
+ errors_exist = !(@object.errors[child_key].nil? || @object.errors[child_key].empty?)
+
%>
- <fieldset class="module aligned">
- <h2><%= label %></h2>
- <div class="form-row">
- <div>
- <%= select("associations", association_name, collection, :id => association_name, :selected => selected.map{|o| o.id.to_s}, :label => label, :multiple => true) %>
- <script type="text/javascript">addEvent(window, "load", function(e) {SelectFilter.init("<%= association_name %>", "<%= association_name %>", 0, "<%= image_path("") %>"); });</script>
- <p class="help">Hold down "Control", or "Command" on a Mac, to select more than one.</p>
+ <h2><%= label %></h2>
+
+ <div class="formSection">
+ <%= label_tag label %>
+ <div class="many_header">
+ <input type="text" class="searchMany" value="Search <%= association_name %>" ref="<%= association_name %>" class="many_text" used="0" />
+ <p>
+ <strong>Chosen <%= association_name %></strong>
+ Select your choise(s) and click <img src="/images/selector-add.gif" alt="Add" />
+ </p>
+ </div>
+ <div class="manySelector">
+ <select multiple="multiple" size="8" class="firstSelect">
+ <%= options_for_select(collection) %>
+ </select>
+
+ <a href="javascript:void(0)" class="addAssoc"><img src="/images/selector-add.gif" alt="Add element" class="add_elem"/></a>
+ <a href="javascript:void(0)" class="removeAssoc"><img src="/images/selector-remove.gif" alt="Remove element" class="remove_elem"/></a>
+
+ <select id="associations_<%= association_name %>" multiple="multiple" class="secondSelect" size="8">
+ <%= options_for_select(selected) %>
+ </select>
+ </div>
+ <div class="many_controls">
+ <a href="javascript:void(0)" class="addAssoc"><img src="/images/selector-addall.gif" alt="Add all" class="add_all" /> Choose all</a>
+ <a href="javascript:void(0)" class="clearAssoc"><img src="/images/selector-removeall.gif" alt="Clear all" class="clear_all"/>Clear all</a>
+ </div>
+ <div class="manyHidden">
+ <% if selected.empty? %>
+ <input type="hidden" name="associations[<%= association_name %>][]" />
+ <% else %>
+ <% selected.each do |t|%>
+ <input type="hidden" name="associations[<%= association_name %>][]" value="<%= t[1] %>" />
+ <% end %>
+ <% end %>
+
</div>
+
+ <span class="breakSpan"></span>
</div>
- </fieldset>
+
+ <!-- > select "associations", association_name, collection, :id => association_name, :selected => selected, :class => "#{errors_exist ? "errorField" : nil}", :multiple => true -->
+
+
+ <% if errors_exist %>
+ <span class="errorMessage"><%= "#{association_name.to_param.capitalize} #{@object.errors[association_name].first}" %></span>
+ <% end %>
+
View
32 app/views/rails_admin/_has_one_association.html.erb
@@ -3,6 +3,12 @@
association_name = has_one_association[:name]
collection = MerbAdmin::AbstractModel.new(has_one_association[:child_model]).all.map{|object| [object_label(object), object.id]}.sort_by{|object| object.first}
selected = @object.send(association_name)
+
+ if selected.nil? && params["associations"]
+ selected = params["associations"][child_key.to_param.pluralize].to_i
+ end
+
+
label = has_one_association[:pretty_name]
required = false
errors_exist = !(@object.errors[child_key].nil? || @object.errors[child_key].empty?)
@@ -10,21 +16,15 @@
required = true unless property[:nullable?]
end
%>
- <fieldset class="module aligned">
<h2><%= label %></h2>
- <div class="<%= errors_exist ? "form-row errors" : "form-row" %>">
- <% if errors_exist %>
- <ul class="errorlist">
- <% @object.errors[child_key].each do |error| %>
- <li><%= error %></li>
+ <div class="formSection">
+ <p>
+ <%= label_tag label %>
+ <%= select("associations", association_name, collection, {:id => association_name, :include_blank => true, :selected => selected},:class => "#{errors_exist ? "errorField" : nil}") %>
+ <% if errors_exist %>
+ <span class="errorMessage"><%= "#{association_name.to_param.capitalize} #{@object.errors[association_name].first}" %></span>
<% end %>
- </ul>
- <% end %>
- <div>
- <%= select("associations", association_name, collection, {:id => association_name, :include_blank => true, :selected => selected ? selected.id.to_s : nil, :label => label}) %>
- <p class="help">
- <%= required ? "Required." : "Optional." %>
- </p>
- </div>
- </div>
- </fieldset>
+ </p>
+
+
+ </div>
View
10 app/views/rails_admin/_integer.html.erb
@@ -3,10 +3,8 @@
length = property[:length]
label = property[:pretty_name]
required = !property[:nullable?] || property[:serial?]
+ model_name = @abstract_model.to_param
%>
- <div>
- <%= text_field(property_name, :maxlength => length, :label => label) %>
- <p class="help">
- <%= required ? "Required." : "Optional." %>
- </p>
- </div>
+ <%= label_tag "#{property_name}", label %>
+
+ <%= text_field model_name, property_name, :maxlength => length, :class => "intField #{errors_exist ? "errorField" : nil}", :value => object_property(@object,property) %>
View
6 app/views/rails_admin/_navigation.html.erb
@@ -0,0 +1,6 @@
+ <ul id="nav">
+ <li <%if @page_type == "dashboard" %>id="active"<% end %>><%= link_to("Dashboard", rails_admin_dashboard_path) %></li>
+<% @abstract_models.each do |abstract_model| %>
+ <li <%if @page_type == abstract_model.pretty_name.downcase %>id="active"<% end %>><%= link_to(abstract_model.pretty_name, rails_admin_list_path(:model_name => abstract_model.to_param)) %></li>
+<% end %>
+ </ul>
View
27 app/views/rails_admin/_properties.html.erb
@@ -1,18 +1,23 @@
- <fieldset class="module aligned">
<% belongs_to_keys = @abstract_model.belongs_to_associations.map{|b| b[:child_key].first} %>
+ <% # reject some attributes and loop through the properties
+ %>
<% @properties.reject{|property| [:id, :created_at, :created_on, :deleted_at, :updated_at, :updated_on, :deleted_on].include?(property[:name]) || belongs_to_keys.include?(property[:name])}.each do |property| %>
+ <% required = !property[:nullable?] %>
+
<% property_name = property[:name] %>
<% property_type = property[:type] %>
<% errors_exist = !(@object.errors[property_name].nil? || @object.errors[property_name].empty?) %>
- <div class="<%= errors_exist ? "form-row errors" : "form-row" %>">
- <% if errors_exist %>
- <ul class="errorlist">
- <% @object.errors[property_name].each do |error| %>
- <li><%= error %></li>
- <% end %>
- </ul>
+
+ <p>
+<%= render :partial => property_type.to_s, :locals => {:property => property, :errors_exist => errors_exist} %>
+ <% if errors_exist %>
+ <span class="errorMessage"><%= "#{property_name.capitalize} #{@object.errors[property_name].first}" %></span>
<% end %>
-<%= render(:partial => property_type.to_s, :locals => {:property => property}) -%>
- </div>
+ </p>
+ <p class="help"><%= required ? "Required." : "Optional." %>
+ <% if property_type == :string %>
+ <% length = property[:length] %>
+ <%= length %> <%= length == 1 ? "character." : "characters or fewer." %>
+ <% end %>
+ </p>
<% end %>
- </fieldset>
View
17 app/views/rails_admin/_string.html.erb
@@ -1,15 +1,12 @@
<%
property_name = property[:name]
+ model_name = @abstract_model.to_param
length = property[:length]
label = property[:pretty_name]
- required = !property[:nullable?]
+
+
%>
- <div>
- <%= text_field(property_name, :size => [50, length].min, :maxlength => length, :label => label) %>
- <% if property_name.to_s =~ /(image|logo|photo|photograph|picture|thumb|thumbnail)_ur(i|l)/i %>
- <img src="<%= @object.send(property_name) %>" width="10" height"10" />
- <% end %>
- <p class="help">
- <%= required ? "Required." : "Optional." %> <%= length %> <%= length == 1 ? "character." : "characters or fewer." %>
- </p>
- </div>
+ <%= label_tag "#{property_name}", label %>
+ <% object_property(@object,property) %>
+ <%= text_field model_name, property_name, :size => [50, length].min, :maxlength => length, :class => "stringField #{errors_exist ? "errorField" : nil}", :value => @object.send(property_name) %>
+
View
11 app/views/rails_admin/_text.html.erb
@@ -1,11 +1,8 @@
<%
- name = property[:name]
+ property_name = property[:name]
label = property[:pretty_name]
required = !property[:nullable?]
+ model_name = @abstract_model.to_param
%>
- <div>
- <%= text_area(name, :cols => 80, :label => label) %>
- <p class="help">
- <%= required ? "Required." : "Optional." %>
- </p>
- </div>
+ <%= label_tag label %>
+ <%= text_area model_name, property_name, :cols => 50, :rows => 10, :class => "textField" %>
View
11 app/views/rails_admin/_time.html.erb
@@ -3,10 +3,9 @@
value = @object.send(property_name)
label = property[:pretty_name]
required = !property[:nullable?]
+ model_name = @abstract_model.to_param
%>
- <div>
- <%= text_field(property_name, :class => "vTimeField", :value => value.respond_to?(:strftime) ? value.strftime("%H:%M:%S") : nil, :label => label) %>
- <p class="help">
- <%= required ? "Required." : "Optional." %>
- </p>
- </div>
+ <%= label_tag "#{property_name}", label %>
+
+ <%= text_field model_name, property_name, :maxlength => length, :class => "timeField #{errors_exist ? "errorField" : nil}", :value => object_property(@object,property) %>
+
View
12 app/views/rails_admin/_timestamp.html.erb
@@ -3,10 +3,10 @@
value = @object.send(property_name)
label = property[:pretty_name]
required = !property[:nullable?]
+ model_name = @abstract_model.to_param
%>
- <div>
- <%= text_field(property_name, :class => "vDateField", :value => value.respond_to?(:strftime) ? value.strftime("%Y-%m-%d %H:%M:%S") : nil, :label => label) %>
- <p class="help">
- <%= required ? "Required." : "Optional." %>
- </p>
- </div>
+ <%= label_tag "#{property_name}", label %>
+
+ <%= text_field model_name, property_name, :maxlength => length, :class => "timestampField #{errors_exist ? "errorField" : nil}", :value => object_property(@object,property) %>
+
+
View
61 app/views/rails_admin/delete.html.erb
@@ -1,28 +1,33 @@
- <p>Are you sure you want to delete the <%= @abstract_model.pretty_name.downcase %> &ldquo;<%= object_label(@object) %>&rdquo;? All of the following related items will be deleted:</p>
- <ul>
- <li>
- <%= @abstract_model.pretty_name %>: <%= link_to(object_label(@object), rails_admin_edit_path(:model_name => @abstract_model.to_param, :id => @object.id)) %>
- <ul>
- <% @abstract_model.has_many_associations.each do |association| %>
- <% @object.send(association[:name]).reject{|child| child.nil?}.each do |child| %>
- <li>
- One or more <%= @abstract_model.pretty_name.pluralize.downcase %> in <%= association[:pretty_name].downcase %>: <%= link_to(object_label(child), rails_admin_edit_path(:model_name => association[:name].to_s.singularize.to_sym, :id => child.id)) %>
- </li>
- <% end %>
- <% end %>
- <% @abstract_model.has_one_associations.each do |association| %>
- <% child = @object.send(association[:name]) %>
- <% next if child.nil? %>
- <li>
- A <%= @abstract_model.pretty_name.downcase %> in <%= association[:pretty_name].downcase %>: <%= link_to(object_label(child), rails_admin_edit_path(:model_name => association[:name], :id => child.id)) %>
- </li>
- <% end %>
- </ul>
- </li>
- </ul>
- <%= form_for(@object, :action => rails_admin_destroy_path(:model_name => @abstract_model.to_param, :id => @object.id), :method => :delete) do %>
- <div>
- <%= submit "Yes, I'm sure" %>
- </div>
- <% end =%>
-
+ <div id="contentHeader">
+ <h2>Delete confirmation</h2>
+ </div>
+<%= render(:partial => 'layouts/flash', :locals => {:flash => flash}) -%>
+ <div id="contentMainDelete">
+ <p>Are you sure you want to delete the <%= @abstract_model.pretty_name.downcase %> &ldquo;<strong><%= object_label(@object) %></strong>&rdquo;? All of the following related items will be deleted:</p>
+ <ul>
+ <li>
+ <%= @abstract_model.pretty_name %>: <%= link_to(object_label(@object), rails_admin_edit_path(:model_name => @abstract_model.to_param, :id => @object.id)) %>
+ <ul>
+ <% @abstract_model.has_many_associations.each do |association| %>
+ <% @object.send(association[:name]).reject{|child| child.nil?}.each do |child| %>
+ <li>
+ One or more <%= @abstract_model.pretty_name.pluralize.downcase %> in <%= association[:pretty_name].downcase %>: <%= link_to(object_label(child), rails_admin_edit_path(:model_name => association[:name].to_s.singularize.to_sym, :id => child.id)) %>
+ </li>
+ <% end %>
+ <% end %>
+ <% @abstract_model.has_one_associations.each do |association| %>
+ <% child = @object.send(association[:name]) %>
+ <% next if child.nil? %>
+ <li>
+ A <%= @abstract_model.pretty_name.downcase %> in <%= association[:pretty_name].downcase %>: <%= link_to(object_label(child), rails_admin_edit_path(:model_name => association[:name], :id => child.id)) %>
+ </li>
+ <% end %>
+ </ul>
+ </li>
+ </ul>
+ <%= form_for(@object, :url => rails_admin_destroy_path(:model_name => @abstract_model.to_param, :id => @object.id), :method => :delete) do %>
+ <div id="deleteConfirmation">
+ <%= submit_tag "Yes, I'm sure" %>
+ </div>
+ <% end =%>
+ </div>
View
40 app/views/rails_admin/edit.html.erb
@@ -1,19 +1,31 @@
- <div id="content-main">
+ <div id="contentHeader">
+ <h2><%= @page_name %></h2>
+ </div>
+<%= render(:partial => 'layouts/flash', :locals => {:flash => flash}) -%>
+ <div id="contentMainNew">
<%= form_for(@object, :url => rails_admin_update_path(:model_name => @abstract_model.to_param, :id => @object.id)) do %>
- <div>
-<%= render(:partial => 'properties', :object => @properties) -%>
+ <fieldset>
+ <h2>BASIC INFO</h2>
+ <div class="formSection">
+<%= render(:partial => 'properties', :properties => @properties) -%>
+ </div>
+
<%= render(:partial => 'belongs_to_association', :collection => @abstract_model.belongs_to_associations) -%>
<%= render(:partial => 'has_one_association', :collection => @abstract_model.has_one_associations) -%>
<%= render(:partial => 'has_many_association', :collection => @abstract_model.has_many_associations) -%>
- <div class="submit-row" >
- <%= submit_tag "Save", :class => "default", :name => "_save" %>
- <p class="deletelink-box">
- <%= link_to("Delete", rails_admin_delete_path(:model_name => @abstract_model.to_param, :id => @object.id), :class => "deletelink") %>
- </p>
- <%= submit_tag "Save and add another", :name => "_add_another" %>
- <%= submit_tag "Save and continue editing", :name => "_continue" %>
- </div>
- </div>
- <% end =%>
- </div>
+ <ul id="submitArea">
+ <li id="saveContainer">
+ <%= submit_tag "Save", :class => "default", :name => "_save", :id => "save_btn" %>
+ </li>
+ <li id="saveAddContainer">
+ <%= submit_tag "Save and add another", :name => "_add_another", :id => "saveAdd_btn" %>
+ </li>
+ <li id="cancelContainer">
+ <%= submit_tag "cancel", :name => "_continue", :id => "cancel_btn" %>
+ </li>
+ </ul>
+ </fieldset>
+ </div>
+ <% end %>
+ </div>
View
96 app/views/rails_admin/index.html.erb
@@ -1,22 +1,76 @@
- <div id="content-main">
- <div class="module">
- <table summary="Models available in the application.">
- <caption>
- <%= link_to("Models", rails_admin_dashboard_path, :class => "section") %>
- </caption>
- <% @abstract_models.each do |abstract_model| %>
- <tr>
- <th scope="row">
- <%= link_to(abstract_model.pretty_name, rails_admin_list_path(:model_name => abstract_model.to_param)) %>
- </th>
- <td>
- <%= link_to("Add", rails_admin_new_path(:model_name => abstract_model.to_param), :class => "addlink") %>
- </td>
- <td>
- <%= link_to("Edit", rails_admin_list_path(:model_name => abstract_model.to_param), :class => "changelink") %>
- </td>
- </tr>
- <% end %>
- </table>
- </div>
+ <div id="contentHeader">
+ <h2><%= @page_name %></h2>
</div>
+<%= render(:partial => 'layouts/flash', :locals => {:flash => flash}) -%>
+ <div id="contentMain">
+ <div class="section">
+ <ul class="menu">
+ <li id="modelNameHeader">Model name</li>
+ <li id="lastUsedHeader">Last used</li>
+ <li id="recordsHeader">Records</li>
+ <li id="modifyHeader">Modify</li>
+ </ul>
+ <% @abstract_models.each do |abstract_model| %>
+ <ul class="row">
+ <li class="modelNameRow"><%= abstract_model.pretty_name %></li>
+ <li class="lastUsedRow">Yesterday</li>
+ <li class="recordsRow">
+ <div class="scale">
+ <div class="bar" style="width:20%;"></div>
+ </div>
+ </li>
+ <li class="modifyRow">
+ <%= link_to("Add new", rails_admin_new_path(:model_name => abstract_model.to_param), :class => "add") %>|<%= link_to("Show", rails_admin_list_path(:model_name => abstract_model.to_param), :class => "show") %>
+ </li>
+ </ul>
+ <% end %>
+ </div>
+
+ <div class="section">
+ <h2>History</h2>
+ <div id="timeline">
+ <a href="#" id="arrowLeft"><img src="images/arrow_left.png" alt="Left" /></a>
+ <div id="timelineSlider">
+ <ul>
+ <li>Ian '10
+ <span class="bars">
+ <span class="indicator" style="height:15%"></span>
+ </span>
+ </li>
+ <li>Feb '10
+ <span class="bars">
+ <span class="indicator medium" style="height:50%"></span>
+ </span>
+ </li>
+ <li>Mar '10
+ <span class="bars">
+ <span class="indicator" style="height:20%"></span>
+ </span>
+ </li>
+ <li>Apr '10
+ <span class="bars">
+ <span class="indicator high" style="height:80%"></span>
+ </span>
+ </li>
+ <li>May '10
+ <span class="bars">
+ <span class="indicator" style="height:30%"></span>
+ </span>
+ </li>
+ </ul>
+
+ <div id="handler">
+ <img src="images/handler.png"/>
+ </div>
+ </div>
+
+ <a href="#" id="arrowRight"><img src="images/arrow_right.png" alt="Right" /></a>
+ </div>
+ <p id="listing">Listing <strong>IAN'10</strong> History:</p>
+ <ul id="history">
+ <li>John added <em>Poll #1</em></li>
+ <li>John added a <em>Poll type - Question</em></li>
+ <li>John deleted <em>Poll #1</em></li>
+ </ul>
+ </div>
+ </div>
View
168 app/views/rails_admin/list.html.erb
@@ -5,89 +5,89 @@
sort = params[:sort]
sort_reverse = params[:sort_reverse]
filters_exist = !@properties.select{|property| property[:type] == :boolean}.empty?
+ # columns paginate
+ @style, @other, @properties = getColumnSet(@properties)
%>
- <div id="content-main">
- <ul class="object-tools">
- <li>
- <%= link_to("Add #{@abstract_model.pretty_name.downcase}", rails_admin_new_path(:model_name => @abstract_model.to_param), :class => "addlink") %>
- </li>
- </ul>
- <div class="<%= filters_exist ? "module filtered" : "module" %>" id="changelist">
- <div id="toolbar">
- <form id="changelist-search" action="" method="get">
- <div>
- <label for="searchbar"><img src="<%= image_path("icon_searchbox.png") %>" alt="Search" /></label>
- <input type="text" size="40" name="query" value="<%= query %>" id="searchbar" />
- <input type="submit" value="Search" />
- <% if query || filter %>
- <span class="small quiet"><%= @record_count %> <%= @record_count == 1 ? "result" : "results" %> (<%= link_to("#{@abstract_model.count} total", "?") %>)</span>
- <% end %>
- <% if filter %>
- <% filter.each do |name, value| %>
- <input type="hidden" name="filter[<%= name %>]" value="<%= value %>"/>
- <% end %>
- <% end %>
- </div>
- </form>
- </div>
- <script type="text/javascript">document.getElementById("searchbar").focus();</script>
- <% if filters_exist %>
- <div id="changelist-filter">
- <h2>Filter</h2>
- <% @properties.each do |property| %>
- <% property_type = property[:type] %>
- <% property_name = property[:name] %>
- <% property_pretty_name = property[:pretty_name] %>
- <% if property_type == :boolean %>
- <h3>By <%= property_pretty_name %></h3>
- <ul>
- <li class="<%= filter.nil? || filter[property_name].blank? ? "selected" : nil %>">
- <%= link_to("All", params.merge(:filter => (filter || {}).reject{|key, value| key.to_sym == property_name})) %>
- </li>
- <li class="<%= filter && filter[property_name] == "true" ? "selected" : nil %>">
- <%= link_to("Yes", params.merge(:filter => (filter || {}).merge({property_name => "true"}))) %>
- </li>
- <li class="<%= filter && filter[property_name] == "false" ? "selected" : nil %>">
- <%= link_to("No", params.merge(:filter => (filter || {}).merge({property_name => "false"}))) %>
- </li>
- </ul>
- <% end %>
- <% end %>
- </div>
- <% end %>
- <table cellspacing="0">
- <thead>
- <tr>
- <% @properties.each do |property| %>
- <% property_name = property[:name] %>
- <% property_pretty_name = property[:pretty_name] %>
- <th class="<%= sort == property_name.to_s ? sort_reverse ? "sorted descending" : "sorted ascending" : nil %>">
- <%= link_to(property_pretty_name, params.merge(:sort => property_name).reject{|key, value| key.to_sym == :sort_reverse}.merge(sort == property_name.to_s && sort_reverse != "true" ? {:sort_reverse => "true"} : {})) %>
- </th>
- <% end %>
- </tr>
- </thead>
- <tbody>
- <% @objects.each_with_index do |object, index| %>
- <tr class="row<%= index % 2 == 0 ? "1" : "2" %>">
- <% @properties.each do |property| %>
- <td>
- <%= link_to(object_property(object, property), rails_admin_edit_path(:model_name => @abstract_model.to_param, :id => object.id)) %>
- </td>
- <% end %>
- </tr>
- <% end %>
- </tbody>
- </table>
- <p class="paginator">
- <% if @page_count.to_i > 1 %>
- <%= paginate(@current_page, @page_count, :url => params) %>
- <% end %>
- <%= @record_count %> <%= @record_count == 1 ? @abstract_model.pretty_name.downcase : @abstract_model.pretty_name.downcase.pluralize %>
- <% if @page_count.to_i == 2 %>
- <%= link_to("Show all", params.merge(:all => true), :class => "showall") %>
- <% end %>
- </p>
- </div>
+
+<style type="text/css">
+<% @style.each do |key,value| %>
+ <%= ".#{key}Header" %>{
+ width: <%= value[:width] %>px;
+ }
+
+ <%= ".#{key}Row" %>{
+ width: <%= value[:width] %>px;
+ }
+<% end %>
+<% @other.each do |t| %>
+ <%= ".#{t}"%>{
+ display:none;
+ }
+<% end %>
+</style>
+ <div id="contentHeader">
+ <h2><%= @page_name %></h2>
+
+ <div id="quickAccess">
+ <ul id="quick">
+ <li><a href="#">Quick add</a></li>
+ <li>
+ <%= link_to("Add new", rails_admin_new_path(:model_name => @abstract_model.to_param), :class => "addlink") %>
+ </li>
+ </ul>
+ </div>
+ </div>
+<%= render(:partial => 'layouts/flash', :locals => {:flash => flash}) -%>
+ <div id="contentMainModules">
+ <div class="searchBox">
+ <form action="#" action="" method="get">
+ <fieldset>
+ <input type="text" id="searchBar" name="query" value="<%= query %>"/>
+ <input type="submit" id="searchbar_btn" value="SEARCH" />
+ </fieldset>
+ </form>
</div>
- <br class="clear" />
+ <ul id="moduleHeader">
+ <li class="otherHeader otherHeaderLeft">...</li>
+ <% @properties.each do |property| %>
+ <% property_name = property[:name] %>
+ <% property_pretty_name = property[:pretty_name] %>
+ <li class="<%= getColumnType(property,"Header") %> <%= sort == property_name.to_s ? "columnSelected" : nil %>">
+ <%= link_to(property_pretty_name.upcase, params.merge(:sort => property_name).reject{|key, value| key.to_sym == :sort_reverse}.merge(sort == property_name.to_s && sort_reverse != "true" ? {:sort_reverse => "true"} : {})) %>
+ <% if sort == property_name.to_s %>
+ <% image_name = sort_reverse ? "bullet_arrow_down.png" : "bullet_arrow_up.png"%>
+ <%= link_to image_tag(image_name), params.merge(:sort => property_name).reject{|key, value| key.to_sym == :sort_reverse}.merge(sort == property_name.to_s && sort_reverse != "true" ? {:sort_reverse => "true"} : {}) %>
+ <% end %>
+ </li>
+ <% end %>
+ <li class="otherHeader otherHeaderRight">...</li>
+ <li class="actionHeader">EDIT</li>
+ <li class="actionHeader">DELETE</li>
+ </ul>
+
+
+ <% @objects.each_with_index do |object, index| %>
+ <ul class="infoRow <%= index % 2 == 0 ? nil : "greyRow" %>">
+ <li class="otherRow otherLeft"><%= link_to("...",params.reject{|key,value| key == "set"}.merge(:set => params[:set].to_i - 1)) %></li>
+ <% @properties.each do |property| %>
+ <li class="<%= getColumnType(property,"Row") %>"><%= object_property(object, property) %></li>
+ <% end %>
+ <li class="otherRow otherRight"><%= link_to("...",params.reject{|key,value| key == "set"}.merge(:set => params[:set].to_i + 1)) %></li>
+ <li class="actionRow editAction"><%= link_to("Edit", rails_admin_edit_path(:model_name => @abstract_model.to_param, :id => object.id)) %></li>
+ <li class="actionRow deleteAction"><%= link_to("Delete",rails_admin_delete_path(:model_name => @abstract_model.to_param, :id => object.id)) %></li>
+ </ul>
+ <% end %>
+ </div>
+ </div>
+ <div id="pagination">
+ <p class="paginator">
+ <% if @page_count.to_i > 1 %>
+ <%= paginate(@current_page, @page_count, :url => params).html_safe %>
+ <% end %>
+ <%= @record_count %> <%= @record_count == 1 ? @abstract_model.pretty_name.downcase : @abstract_model.pretty_name.downcase.pluralize %>
+ <% if @page_count.to_i == 2 %>
+ <%= link_to("Show all", params.merge(:all => true), :class => "showall") %>
+ <% end %>
+ </p>
+ </div>
+
View
33 app/views/rails_admin/new.html.erb
@@ -1,16 +1,31 @@
- <div id="content-main">
+ <div id="contentHeader">
+ <h2><%= @page_name %></h2>
+ </div>
+<%= render(:partial => 'layouts/flash', :locals => {:flash => flash}) -%>
+ <div id="contentMainNew">
<%= form_tag(rails_admin_create_path(:model_name => @abstract_model.to_param)) do %>
- <div>
+ <fieldset>
+ <h2>BASIC INFO</h2>
+ <div class="formSection">
<%= render(:partial => 'properties', :properties => @properties) -%>
+ </div>
+
<%= render(:partial => 'belongs_to_association', :collection => @abstract_model.belongs_to_associations) -%>
<%= render(:partial => 'has_one_association', :collection => @abstract_model.has_one_associations) -%>
<%= render(:partial => 'has_many_association', :collection => @abstract_model.has_many_associations) -%>
- <div class="submit-row" >
- <%= submit_tag "Save", :class => "default", :name => "_save" %>
- <%= submit_tag "Save and add another", :name => "_add_another" %>
- <%= submit_tag "Save and continue editing", :name => "_continue" %>
- </div>
+
+ <ul id="submitArea">
+ <li id="saveContainer">
+ <%= submit_tag "Save", :class => "default", :name => "_save", :id => "save_btn" %>
+ </li>
+ <li id="saveAddContainer">
+ <%= submit_tag "Save and add another", :name => "_add_another", :id => "saveAdd_btn" %>
+ </li>
+ <li id="cancelContainer">
+ <%= submit_tag "cancel", :name => "_continue", :id => "cancel_btn" %>
+ </li>
+ </ul>
+ </fieldset>
</div>
<% end %>
-
- </div>
+ </div>
View
6 db/migrate/001_create_divisions_migration.rb
@@ -1,9 +1,9 @@
class CreateDivisionsMigration < ActiveRecord::Migration
def self.up
- create_table(:divisions) do |t|
+ create_table :divisions do |t|
t.timestamps
- t.integer(:league_id)
- t.string(:name, :limit => 50, :null => false)
+ t.integer :league_id
+ t.string :name, :limit => 50, :null => false
end
end
View
20 db/migrate/002_create_drafts_migration.rb
@@ -1,19 +1,19 @@
class CreateDraftsMigration < ActiveRecord::Migration
def self.up
- create_table(:drafts) do |t|
+ create_table :drafts do |t|
t.timestamps
- t.integer(:player_id)
- t.integer(:team_id)
- t.date(:date)
- t.integer(:round)
- t.integer(:pick)
- t.integer(:overall)
- t.string(:college, :limit => 100)
- t.text(:notes)
+ t.integer :player_id
+ t.integer :team_id
+ t.date :date
+ t.integer :round
+ t.integer :pick
+ t.integer :overall
+ t.string :college, :limit => 100
+ t.text :notes
end
end
def self.down
- drop_table(:drafts)
+ drop_table :drafts
end
end
View
6 db/migrate/003_create_leagues_migration.rb
@@ -1,12 +1,12 @@
class CreateLeaguesMigration < ActiveRecord::Migration
def self.up
- create_table(:leagues) do |t|
+ create_table :leagues do |t|
t.timestamps
- t.string(:name, :limit => 50, :null => false)
+ t.string :name, :limit => 50, :null => false
end
end
def self.down
- drop_table(:leagues)
+ drop_table :leagues
end
end
View
22 db/migrate/004_create_players_migration.rb
@@ -1,20 +1,20 @@
class CreatePlayersMigration < ActiveRecord::Migration
def self.up
- create_table(:players) do |t|
+ create_table :players do |t|
t.timestamps
- t.datetime(:deleted_at)
- t.integer(:team_id)
- t.string(:name, :limit => 100, :null => false)
- t.string(:position, :limit => 50)
- t.integer(:number, :null => false)
- t.boolean(:retired, :default => false)
- t.boolean(:injured, :default => false)
- t.date(:born_on)
- t.text(:notes)
+ t.datetime :deleted_at
+ t.integer :team_id
+ t.string :name, :limit => 100, :null => false
+ t.string :position, :limit => 50
+ t.integer :number, :null => false
+ t.boolean :retired, :default => false
+ t.boolean :injured, :default => false
+ t.date :born_on
+ t.text :notes
end
end
def self.down
- drop_table(:players)
+ drop_table :players
end
end
View
26 db/migrate/005_create_teams_migration.rb
@@ -1,22 +1,22 @@
class CreateTeamsMigration < ActiveRecord::Migration
def self.up
- create_table(:teams) do |t|
+ create_table :teams do |t|
t.timestamps
- t.integer(:league_id)
- t.integer(:division_id)
- t.string(:name, :limit => 50)
- t.string(:logo_url, :limit => 255)
- t.string(:manager, :limit => 100, :null => false)
- t.string(:ballpark, :limit => 100)
- t.string(:mascot, :limit => 100)
- t.integer(:founded)
- t.integer(:wins)
- t.integer(:losses)
- t.float(:win_percentage)
+ t.integer :league_id
+ t.integer :division_id
+ t.string :name, :limit => 50
</