engine_room 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +10 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +159 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +44 -0
- data/Rakefile +30 -0
- data/TODO +3 -0
- data/app/controllers/engine_room/content_controller.rb +117 -0
- data/app/controllers/engine_room/fields_controller.rb +119 -0
- data/app/controllers/engine_room/models_controller.rb +89 -0
- data/app/controllers/engine_room/pages_controller.rb +17 -0
- data/app/controllers/engine_room/sections_controller.rb +74 -0
- data/app/controllers/engine_room/users_controller.rb +84 -0
- data/app/controllers/er_devise/passwords_controller.rb +6 -0
- data/app/controllers/er_devise/registrations_controller.rb +8 -0
- data/app/controllers/er_devise/sessions_controller.rb +6 -0
- data/app/helpers/engine_room/content_helper.rb +103 -0
- data/app/helpers/engine_room/models_helper.rb +21 -0
- data/app/models/field.rb +89 -0
- data/app/models/section.rb +68 -0
- data/app/models/user.rb +31 -0
- data/app/views/engine_room/content/_form.html.erb +13 -0
- data/app/views/engine_room/content/_overview.html.erb +28 -0
- data/app/views/engine_room/content/_sidebar.html.erb +14 -0
- data/app/views/engine_room/content/edit.html.erb +38 -0
- data/app/views/engine_room/content/index.html.erb +1 -0
- data/app/views/engine_room/content/new.html.erb +1 -0
- data/app/views/engine_room/content/overview.html.erb +3 -0
- data/app/views/engine_room/fields/_form.html.erb +57 -0
- data/app/views/engine_room/fields/edit.html.erb +1 -0
- data/app/views/engine_room/fields/new.html.erb +1 -0
- data/app/views/engine_room/models/_form.html.erb +0 -0
- data/app/views/engine_room/models/edit.html.erb +14 -0
- data/app/views/engine_room/models/index.html.erb +16 -0
- data/app/views/engine_room/models/new.html.erb +14 -0
- data/app/views/engine_room/models/overview.html.erb +14 -0
- data/app/views/engine_room/pages/dashboard.html.erb +1 -0
- data/app/views/engine_room/pages/settings.html.erb +1 -0
- data/app/views/engine_room/sections/_form.html.erb +34 -0
- data/app/views/engine_room/sections/_sidebar.html.erb +11 -0
- data/app/views/engine_room/sections/edit.html.erb +81 -0
- data/app/views/engine_room/sections/index.html.erb +3 -0
- data/app/views/engine_room/sections/new.html.erb +1 -0
- data/app/views/engine_room/users/_form.html.erb +47 -0
- data/app/views/engine_room/users/edit.html.erb +11 -0
- data/app/views/engine_room/users/index.html.erb +24 -0
- data/app/views/engine_room/users/new.html.erb +1 -0
- data/app/views/er_devise/mailer/confirmation_instructions.html.erb +5 -0
- data/app/views/er_devise/mailer/reset_password_instructions.html.erb +8 -0
- data/app/views/er_devise/mailer/unlock_instructions.html.erb +7 -0
- data/app/views/er_devise/passwords/edit.html.erb +16 -0
- data/app/views/er_devise/passwords/new.html.erb +13 -0
- data/app/views/er_devise/registrations/edit.html.erb +42 -0
- data/app/views/er_devise/registrations/new.html.erb +21 -0
- data/app/views/er_devise/sessions/new.html.erb +23 -0
- data/app/views/er_devise/shared/_links.erb +19 -0
- data/app/views/layouts/engine_room.html.erb +103 -0
- data/app/views/layouts/login.html.erb +71 -0
- data/app/views/shared/_content_layout_selector.html.erb +45 -0
- data/app/views/shared/_error_messages.html.erb +17 -0
- data/config/initializers/devise.rb +146 -0
- data/config/initializers/locale.rb +5 -0
- data/config/locales/devise.de.yml +42 -0
- data/config/locales/devise.en.yml +39 -0
- data/config/locales/engine_room.de.yml +33 -0
- data/config/locales/engine_room.en.yml +42 -0
- data/config/routes.rb +62 -0
- data/engine_room.gemspec +35 -0
- data/lib/engine_room.rb +17 -0
- data/lib/engine_room/action_controller/controller_methods.rb +21 -0
- data/lib/engine_room/action_view/view_methods.rb +8 -0
- data/lib/engine_room/active_record/record_methods.rb +18 -0
- data/lib/engine_room/crummy/custom_renderer.rb +63 -0
- data/lib/engine_room/engine.rb +40 -0
- data/lib/engine_room/railties/tasks.rake +6 -0
- data/lib/engine_room/version.rb +3 -0
- data/lib/generators/engine_room/create_image_generator.rb +26 -0
- data/lib/generators/engine_room/setup_generator.rb +30 -0
- data/lib/generators/engine_room/templates/001_devise_create_users.rb +28 -0
- data/lib/generators/engine_room/templates/002_create_sections.rb +16 -0
- data/lib/generators/engine_room/templates/003_create_fields.rb +18 -0
- data/lib/generators/engine_room/templates/004_create_images.rb +19 -0
- data/lib/generators/engine_room/templates/image.rb +4 -0
- data/lib/tasks/dummy.rake +45 -0
- data/lib/tasks/templates/migrate/050_create_dogs.rb +18 -0
- data/lib/tasks/templates/models/dog.rb +3 -0
- data/public/images/er/accept.png +0 -0
- data/public/images/er/add.png +0 -0
- data/public/images/er/add_small.png +0 -0
- data/public/images/er/ajax-loader.gif +0 -0
- data/public/images/er/attach.png +0 -0
- data/public/images/er/back_disabled.jpg +0 -0
- data/public/images/er/back_enabled.jpg +0 -0
- data/public/images/er/bg/header_gradient_center.jpg +0 -0
- data/public/images/er/bg/header_gradient_left.jpg +0 -0
- data/public/images/er/bg/header_gradient_right.jpg +0 -0
- data/public/images/er/cancel.png +0 -0
- data/public/images/er/cog.png +0 -0
- data/public/images/er/database_add.png +0 -0
- data/public/images/er/delete.png +0 -0
- data/public/images/er/delete_small.png +0 -0
- data/public/images/er/down_arrow.gif +0 -0
- data/public/images/er/down_arrow.png +0 -0
- data/public/images/er/email.png +0 -0
- data/public/images/er/exclamation.png +0 -0
- data/public/images/er/forward_disabled.jpg +0 -0
- data/public/images/er/forward_enabled.jpg +0 -0
- data/public/images/er/help.png +0 -0
- data/public/images/er/image_add.png +0 -0
- data/public/images/er/information.png +0 -0
- data/public/images/er/link.png +0 -0
- data/public/images/er/loader.gif +0 -0
- data/public/images/er/telephone.png +0 -0
- data/public/images/er/up_arrow.gif +0 -0
- data/public/images/er/up_arrow.png +0 -0
- data/public/images/er/user.png +0 -0
- data/public/images/er/wrench.png +0 -0
- data/public/images/er/zoom.png +0 -0
- data/public/javascripts/er/dd_belatedpng.js +328 -0
- data/public/javascripts/er/fancybox/blank.gif +0 -0
- data/public/javascripts/er/fancybox/fancy_close.png +0 -0
- data/public/javascripts/er/fancybox/fancy_loading.png +0 -0
- data/public/javascripts/er/fancybox/fancy_nav_left.png +0 -0
- data/public/javascripts/er/fancybox/fancy_nav_right.png +0 -0
- data/public/javascripts/er/fancybox/fancy_shadow_e.png +0 -0
- data/public/javascripts/er/fancybox/fancy_shadow_n.png +0 -0
- data/public/javascripts/er/fancybox/fancy_shadow_ne.png +0 -0
- data/public/javascripts/er/fancybox/fancy_shadow_nw.png +0 -0
- data/public/javascripts/er/fancybox/fancy_shadow_s.png +0 -0
- data/public/javascripts/er/fancybox/fancy_shadow_se.png +0 -0
- data/public/javascripts/er/fancybox/fancy_shadow_sw.png +0 -0
- data/public/javascripts/er/fancybox/fancy_shadow_w.png +0 -0
- data/public/javascripts/er/fancybox/fancy_title_left.png +0 -0
- data/public/javascripts/er/fancybox/fancy_title_main.png +0 -0
- data/public/javascripts/er/fancybox/fancy_title_over.png +0 -0
- data/public/javascripts/er/fancybox/fancy_title_right.png +0 -0
- data/public/javascripts/er/fancybox/fancybox-x.png +0 -0
- data/public/javascripts/er/fancybox/fancybox-y.png +0 -0
- data/public/javascripts/er/fancybox/fancybox.png +0 -0
- data/public/javascripts/er/fancybox/jquery.fancybox-1.3.4.css +359 -0
- data/public/javascripts/er/fancybox/jquery.fancybox-1.3.4.pack.js +46 -0
- data/public/javascripts/er/jquery-1.4.4.min.js +167 -0
- data/public/javascripts/er/jquery-ui-1.8.6.custom.min.js +477 -0
- data/public/javascripts/er/modernizr-1.5.min.js +28 -0
- data/public/javascripts/er/plugins.js +48 -0
- data/public/javascripts/er/rails.js +156 -0
- data/public/javascripts/er/script.js +50 -0
- data/public/stylesheets/.gitkeep +0 -0
- data/public/stylesheets/admin.css +417 -0
- data/public/stylesheets/boilerplate.css +264 -0
- data/public/stylesheets/handheld.css +7 -0
- data/public/stylesheets/login.css +125 -0
- data/public/stylesheets/skin.css +2 -0
- data/public/stylesheets/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/public/stylesheets/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/public/stylesheets/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/public/stylesheets/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/public/stylesheets/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/public/stylesheets/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/public/stylesheets/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/public/stylesheets/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/public/stylesheets/smoothness/images/ui-icons_222222_256x240.png +0 -0
- data/public/stylesheets/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
- data/public/stylesheets/smoothness/images/ui-icons_454545_256x240.png +0 -0
- data/public/stylesheets/smoothness/images/ui-icons_888888_256x240.png +0 -0
- data/public/stylesheets/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/public/stylesheets/smoothness/jquery-ui-1.8.6.custom.css +479 -0
- data/spec/controllers/content_controller_spec.rb +132 -0
- data/spec/controllers/fields_controller_spec.rb +103 -0
- data/spec/controllers/models_controller_spec.rb +65 -0
- data/spec/controllers/pages_controller_spec.rb +40 -0
- data/spec/controllers/sections_controller_spec.rb +124 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +45 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +22 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +26 -0
- data/spec/dummy/config/environments/production.rb +49 -0
- data/spec/dummy/config/environments/test.rb +35 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +10 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +58 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +26 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/public/javascripts/application.js +2 -0
- data/spec/dummy/public/javascripts/controls.js +965 -0
- data/spec/dummy/public/javascripts/dragdrop.js +974 -0
- data/spec/dummy/public/javascripts/effects.js +1123 -0
- data/spec/dummy/public/javascripts/prototype.js +6001 -0
- data/spec/dummy/public/javascripts/rails.js +175 -0
- data/spec/dummy/public/stylesheets/.gitkeep +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/engine_room_spec.rb +7 -0
- data/spec/factories.rb +32 -0
- data/spec/integration/navigation_spec.rb +9 -0
- data/spec/models/dog_spec.rb +14 -0
- data/spec/models/field_spec.rb +74 -0
- data/spec/models/section_spec.rb +70 -0
- data/spec/models/user_spec.rb +77 -0
- data/spec/routing/models_routing_spec.rb +66 -0
- data/spec/spec_helper.rb +39 -0
- data/spec/support/devise.rb +3 -0
- metadata +492 -0
@@ -0,0 +1,68 @@
|
|
1
|
+
class ValidModelValidator < ActiveModel::EachValidator
|
2
|
+
def validate_each(record, attribute, value)
|
3
|
+
record.errors.add(attribute, "is not a valid model.") unless
|
4
|
+
Section.valid_model_name?(record[attribute])
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
class Section < ActiveRecord::Base
|
9
|
+
has_many :fields, :dependent => :destroy
|
10
|
+
attr_accessible :name, :model_name, :view_type, :condition, :sort_order
|
11
|
+
|
12
|
+
validates :name, :presence => true
|
13
|
+
validates :model_name, :presence => true, :valid_model => true
|
14
|
+
|
15
|
+
default_scope :order => 'sections.sort_order ASC'
|
16
|
+
|
17
|
+
# returns array of model names found in app/models/
|
18
|
+
def self.model_names
|
19
|
+
Dir.glob(Rails.root.to_s + '/app/models/*.rb').collect { |file| File.basename(file, '.*') }
|
20
|
+
end
|
21
|
+
|
22
|
+
# check if given model name matches existing model
|
23
|
+
def self.valid_model_name?(name)
|
24
|
+
!name.blank? && self.model_names.include?(name.downcase)
|
25
|
+
end
|
26
|
+
|
27
|
+
def name=(name_string)
|
28
|
+
write_attribute(:name, name_string.gsub(/ /, "_").underscore)
|
29
|
+
end
|
30
|
+
|
31
|
+
# returns model corresponding to model_name, or nil if not found
|
32
|
+
def model
|
33
|
+
begin
|
34
|
+
return Object.const_get(model_name.singularize.camelize)
|
35
|
+
rescue NameError
|
36
|
+
return nil
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def detail_fields
|
41
|
+
self.fields.where(:display_type => 'detail')
|
42
|
+
end
|
43
|
+
|
44
|
+
def has_many_fields
|
45
|
+
self.fields.where(:display_type => 'has_many')
|
46
|
+
end
|
47
|
+
|
48
|
+
def overview_fields
|
49
|
+
self.fields.where(:display_type => 'overview')
|
50
|
+
end
|
51
|
+
|
52
|
+
# returns array of valid column names of associated model
|
53
|
+
def column_names
|
54
|
+
names = []
|
55
|
+
model.column_names.each do |col_name|
|
56
|
+
# for paperclip attachments, add base name
|
57
|
+
if col_name.match(/(.*)_file_name$/)
|
58
|
+
names << $1
|
59
|
+
end
|
60
|
+
names << col_name
|
61
|
+
end
|
62
|
+
return names
|
63
|
+
end
|
64
|
+
|
65
|
+
def model_count
|
66
|
+
model.count
|
67
|
+
end
|
68
|
+
end
|
data/app/models/user.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
class User < ActiveRecord::Base
|
2
|
+
# Include default devise modules. Others available are:
|
3
|
+
# :token_authenticatable, :confirmable, :lockable and :timeoutable, :registerable
|
4
|
+
devise :database_authenticatable,
|
5
|
+
:recoverable, :rememberable, :trackable, :validatable
|
6
|
+
|
7
|
+
# Setup accessible (or protected) attributes for your model
|
8
|
+
attr_accessible :username, :email, :password, :password_confirmation, :remember_me, :last_sign_in_at, :is_admin
|
9
|
+
|
10
|
+
|
11
|
+
def is_admin?
|
12
|
+
self.is_admin==1 ? true : false
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
def update_with_admin_check(user_params, is_admin=false)
|
17
|
+
if is_admin
|
18
|
+
self.update_attributes(user_params)
|
19
|
+
else
|
20
|
+
self.update_with_password(user_params)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
# MonkeyPatch of Devise method in devise/lib/devise/models/validatable.rb
|
26
|
+
# to enable updating user without specifying password
|
27
|
+
def password_required?
|
28
|
+
!persisted? || !password.blank? # || !password_confirmation.nil?
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<%= render 'shared/error_messages', :object => @element %>
|
2
|
+
|
3
|
+
<%= form_for @element, :url => {:controller => 'engine_room/content', :section_name => @section.name, :action => @element.id ? :update : :create, :id => @element.id, :bt_section => params[:bt_section], :bt_id => params[:bt_id]}, :html => {:multipart => true} do |f| %>
|
4
|
+
|
5
|
+
<% @section.detail_fields.each do |field| %>
|
6
|
+
<%= field_to_form(field, @element, f) %>
|
7
|
+
<% end %>
|
8
|
+
|
9
|
+
<div class="actions">
|
10
|
+
<button type="submit"><%= @element.id ? "Update" : "Create" %></button>
|
11
|
+
</div>
|
12
|
+
|
13
|
+
<% end %>
|
@@ -0,0 +1,28 @@
|
|
1
|
+
<%
|
2
|
+
bt_section_name ||= nil
|
3
|
+
bt_id ||= nil
|
4
|
+
%>
|
5
|
+
<div class="box">
|
6
|
+
<%= link_to "Add New #{section.model_name.humanize}", {:controller => 'engine_room/content', :section_name => section.name, :action => :new, :bt_section => bt_section_name, :bt_id => bt_id}, :class => "button" %>
|
7
|
+
<% unless elements.empty? %>
|
8
|
+
<table>
|
9
|
+
<tr>
|
10
|
+
<% section.overview_fields.each do |field| %>
|
11
|
+
<th><%= sortable field.column %></th>
|
12
|
+
<% end %>
|
13
|
+
<th>actions</th>
|
14
|
+
</tr>
|
15
|
+
<% elements.each do |element| %>
|
16
|
+
<tr>
|
17
|
+
<% section.overview_fields.each do |field| %>
|
18
|
+
<%= field_to_overview(field, element, section, bt_section_name, bt_id) %>
|
19
|
+
<% end %>
|
20
|
+
<td><%= link_to "delete", {:controller => 'engine_room/content', :section_name => section.name, :id => element.id, :action => :destroy, :bt_section => bt_section_name, :bt_id => bt_id}, :method => :delete, :confirm => "You sure?", :title => "Delete?" %></td>
|
21
|
+
</tr>
|
22
|
+
<% end %>
|
23
|
+
</table>
|
24
|
+
|
25
|
+
<br />
|
26
|
+
<%= will_paginate elements %>
|
27
|
+
<% end %>
|
28
|
+
</div>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<div class="box">
|
2
|
+
<h3>Content Sections</h3>
|
3
|
+
<div class="box-content">
|
4
|
+
<ul>
|
5
|
+
<% @sections.each do |section| %>
|
6
|
+
<li><%= link_to section.name.titleize, { :controller => 'content', :action => :index, :section_name => section.name }%>
|
7
|
+
<% unless section.view_type == 'detail' %>
|
8
|
+
(<%= section.model_count %>)
|
9
|
+
<% end %>
|
10
|
+
</li>
|
11
|
+
<% end %>
|
12
|
+
</ul>
|
13
|
+
</div>
|
14
|
+
</div>
|
@@ -0,0 +1,38 @@
|
|
1
|
+
<%
|
2
|
+
hm_relationships = @section.has_many_fields
|
3
|
+
%>
|
4
|
+
|
5
|
+
<% if hm_relationships.length > 0 %>
|
6
|
+
<div id="tabs">
|
7
|
+
<ul class="clearfix">
|
8
|
+
<li><a href="#tab1">Form</a></li>
|
9
|
+
<%
|
10
|
+
counter = 1
|
11
|
+
hm_relationships.each do |hm_field|
|
12
|
+
counter += 1
|
13
|
+
%>
|
14
|
+
<li><a href="#tab<%= counter %>"><%= hm_field.target_model.pluralize %></a></li>
|
15
|
+
<% end %>
|
16
|
+
</ul>
|
17
|
+
|
18
|
+
<div id="tab1">
|
19
|
+
<%= render 'form' %>
|
20
|
+
</div>
|
21
|
+
|
22
|
+
<%
|
23
|
+
counter = 1
|
24
|
+
hm_relationships.each do |hm_field|
|
25
|
+
counter += 1
|
26
|
+
hm_section = Section.find(hm_field.target_section_id)
|
27
|
+
hm_elements = has_many_elements(@element, hm_field.target_model)
|
28
|
+
%>
|
29
|
+
|
30
|
+
<div id="tab<%= counter %>">
|
31
|
+
<%= render :partial => "overview", :locals => {:section => hm_section, :elements => hm_elements, :bt_section_name => @section.name, :bt_id => @element.id} %>
|
32
|
+
</div>
|
33
|
+
<% end %>
|
34
|
+
</div>
|
35
|
+
|
36
|
+
<% else %>
|
37
|
+
<%= render 'form' %>
|
38
|
+
<% end %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= render :partial => "overview", :locals => {:section => @section, :elements => @elements} %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= render 'form' %>
|
@@ -0,0 +1,57 @@
|
|
1
|
+
<%= render 'shared/error_messages', :object => @field %>
|
2
|
+
|
3
|
+
<%
|
4
|
+
view_type = params[:field] && params[:field][:display_type] ? params[:field][:display_type] : ""
|
5
|
+
%>
|
6
|
+
|
7
|
+
<%= form_for [:engine_room, @section, @field] do |f| %>
|
8
|
+
<div class="field reload">
|
9
|
+
<%= f.label :display_type %>
|
10
|
+
<%= f.select :display_type, options_for_select(["detail", "overview", "has_many"], @field.display_type) %>
|
11
|
+
</div>
|
12
|
+
<% unless view_type=="has_many" %>
|
13
|
+
<div class="field">
|
14
|
+
<%= f.label :column %>
|
15
|
+
<%= f.select :column, options_for_select(@section.column_names, @field.column), {:include_blank => ''} %>
|
16
|
+
</div>
|
17
|
+
<div class="field reload">
|
18
|
+
<%= f.label :field_type %>
|
19
|
+
<%= f.select :field_type, options_for_select(Field.field_types, @field.field_type), {:include_blank => ''} %>
|
20
|
+
</div>
|
21
|
+
<% else %>
|
22
|
+
<%= f.hidden_field :column, :value => @field.column %>
|
23
|
+
<%= f.hidden_field :field_type, :value => @field.field_type %>
|
24
|
+
<% end %>
|
25
|
+
<% if view_type=="overview" %>
|
26
|
+
<div class="field">
|
27
|
+
<%= f.label :overview_link, "Overview link?" %>
|
28
|
+
<%= f.check_box :overview_link %>
|
29
|
+
</div>
|
30
|
+
<% end %>
|
31
|
+
<div class="field">
|
32
|
+
<%= f.label :help, "Help Text" %>
|
33
|
+
<%= f.text_field :help %>
|
34
|
+
</div>
|
35
|
+
<% if view_type=="detail" %>
|
36
|
+
<div class="field">
|
37
|
+
<%= f.label :options %>
|
38
|
+
<%= f.text_area :options, :rows => 3 %>
|
39
|
+
</div>
|
40
|
+
<% end %>
|
41
|
+
<div class="field">
|
42
|
+
<%= f.label :sort_order %>
|
43
|
+
<%= f.number_field :sort_order, :min => 1, :max => 100 %>
|
44
|
+
</div>
|
45
|
+
|
46
|
+
<% @field.option_fields.each do |ofield| %>
|
47
|
+
<div class="field">
|
48
|
+
<%= f.label ofield, ofield.titleize %>
|
49
|
+
<%= f.text_field ofield %>
|
50
|
+
</div>
|
51
|
+
<% end %>
|
52
|
+
|
53
|
+
<div class="actions">
|
54
|
+
<%= f.hidden_field :section_id, :value => @section.id %>
|
55
|
+
<button type="submit"><%= @field.id ? "Update" : "Create" %></button>
|
56
|
+
</div>
|
57
|
+
<% end %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= render 'form' %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= render 'form' %>
|
File without changes
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<%= form_for [:engine_room, @element] do |f| %>
|
2
|
+
<%= render 'shared/error_messages', :object => f.object %>
|
3
|
+
|
4
|
+
<% @model.columns.each do |column| %>
|
5
|
+
<div class="field">
|
6
|
+
<%= f.label column.name, @model.human_attribute_name(column.name) %>
|
7
|
+
<%= get_form_field_for_column(f, @element, column) %>
|
8
|
+
</div>
|
9
|
+
<% end %>
|
10
|
+
|
11
|
+
<div class="actions">
|
12
|
+
<button type="submit">Submit</button>
|
13
|
+
</div>
|
14
|
+
<% end %>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
|
2
|
+
<%= link_to "Add Item", { :controller => 'models', :action => :new, :modelname => @modelname }, :class => "button" %>
|
3
|
+
|
4
|
+
<ul>
|
5
|
+
<% @elements.each do |element| %>
|
6
|
+
<li>
|
7
|
+
<%
|
8
|
+
@model.column_names.each do |cname|
|
9
|
+
if cname == "id" || cname == "title" || cname == "name"
|
10
|
+
%>
|
11
|
+
<%= link_to element[cname], { :controller => 'models', :action => :edit, :id => element.id } %>
|
12
|
+
<% end
|
13
|
+
end %>
|
14
|
+
</li>
|
15
|
+
<% end %>
|
16
|
+
</ul>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<%= form_for @element, {:controller => 'engine_room/models', :action => 'create', :modelname => @modelname} do |f| %>
|
2
|
+
<%= render 'shared/error_messages', :object => f.object %>
|
3
|
+
|
4
|
+
<% @model.columns.each do |column| %>
|
5
|
+
<div class="field">
|
6
|
+
<%= f.label column.name, @model.human_attribute_name(column.name) %>
|
7
|
+
<%= get_form_field_for_column(f, @element, column) %>
|
8
|
+
</div>
|
9
|
+
<% end %>
|
10
|
+
|
11
|
+
<div class="actions">
|
12
|
+
<button type="submit">Create</button>
|
13
|
+
</div>
|
14
|
+
<% end %>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<div class="box">
|
2
|
+
<table>
|
3
|
+
<tr>
|
4
|
+
<th>Section</th>
|
5
|
+
<th>Sort Order</th>
|
6
|
+
</tr>
|
7
|
+
<% @sections.each do |section| %>
|
8
|
+
<tr>
|
9
|
+
<td><%= link_to section.name, { :controller => 'models', :action => :index, :modelname => section.model_name }%></td>
|
10
|
+
<td><%= section.sort_order %></td>
|
11
|
+
</tr>
|
12
|
+
<% end %>
|
13
|
+
</table>
|
14
|
+
</div>
|
@@ -0,0 +1 @@
|
|
1
|
+
<h1><%= t('.title') %></h1>
|
@@ -0,0 +1 @@
|
|
1
|
+
<h1><%= t('.title') %></h1>
|
@@ -0,0 +1,34 @@
|
|
1
|
+
<%= render 'shared/error_messages', :object => @section %>
|
2
|
+
|
3
|
+
<%= form_for [:engine_room, @section] do |f| %>
|
4
|
+
<div class="field">
|
5
|
+
<%= f.label :name %>
|
6
|
+
<%= f.text_field :name %>
|
7
|
+
</div>
|
8
|
+
<div class="field">
|
9
|
+
<%= f.label :model_name %>
|
10
|
+
<%= f.select :model_name, options_for_select(Section.model_names.collect!{ |name| [name.camelize,name] }, @section.model_name), {:include_blank => ''} %>
|
11
|
+
</div>
|
12
|
+
<div class="field">
|
13
|
+
<%= f.label :view_type %>
|
14
|
+
<%= f.select :view_type, options_for_select(['overview','detail'], @section.view_type) %>
|
15
|
+
</div>
|
16
|
+
<div class="field">
|
17
|
+
<%= f.label :condition %>
|
18
|
+
<%= f.text_field :condition %>
|
19
|
+
</div>
|
20
|
+
<div class="field">
|
21
|
+
<%= f.label :sort_order %>
|
22
|
+
<%= f.number_field :sort_order %>
|
23
|
+
</div>
|
24
|
+
<div class="actions">
|
25
|
+
<button type="submit"><%= @section.id ? "Update" : "Create" %></button>
|
26
|
+
</div>
|
27
|
+
|
28
|
+
<% if @section.id %>
|
29
|
+
<div class="actions">
|
30
|
+
<%= link_to 'Delete Section?', { :controller => 'engine_room/sections', :action => :destroy, :id => @section.id }, :method => :delete, :confirm => "You sure?", :title => "Delete?" %>
|
31
|
+
</div>
|
32
|
+
<% end %>
|
33
|
+
|
34
|
+
<% end %>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<div class="box">
|
2
|
+
<h3>Sections</h3>
|
3
|
+
<div class="box-content">
|
4
|
+
<ul>
|
5
|
+
<% @sections.each do |section| %>
|
6
|
+
<li><%= link_to section.name.titleize, { :controller => 'engine_room/sections', :action => :edit, :id => section.id } %></li>
|
7
|
+
<% end %>
|
8
|
+
</ul>
|
9
|
+
<%= link_to 'Add Section', new_engine_room_section_path, :class => "button" %>
|
10
|
+
</div>
|
11
|
+
</div>
|
@@ -0,0 +1,81 @@
|
|
1
|
+
<div id="tabs">
|
2
|
+
<ul>
|
3
|
+
<li><a href="#tab1"><%= @section.name.titleize %></a></li>
|
4
|
+
<li><a href="#tab2">Overview Fields</a></li>
|
5
|
+
<li><a href="#tab3">Detail Fields</a></li>
|
6
|
+
<li><a href="#tab4">Has_Many Relationships</a></li>
|
7
|
+
</ul>
|
8
|
+
|
9
|
+
<div id="tab1">
|
10
|
+
<%= render 'form' %>
|
11
|
+
</div>
|
12
|
+
|
13
|
+
<div id="tab2">
|
14
|
+
<div class="box">
|
15
|
+
<%= link_to "Add Field", new_engine_room_section_field_path(@section), :class => "button" %>
|
16
|
+
<table id="overview-fields-table">
|
17
|
+
<thead>
|
18
|
+
<tr>
|
19
|
+
<th>Column</th>
|
20
|
+
<th>Type</th>
|
21
|
+
<th>Sort Order</th>
|
22
|
+
<th>Actions</th>
|
23
|
+
</tr>
|
24
|
+
</thead>
|
25
|
+
<tbody>
|
26
|
+
<% @section.overview_fields.each do |field| %>
|
27
|
+
<tr>
|
28
|
+
<td><%= link_to field.column, edit_engine_room_section_field_path(@section, field) %></td>
|
29
|
+
<td><%= field.field_type %></td>
|
30
|
+
<td><%= field.sort_order %></td>
|
31
|
+
<td><%= link_to 'delete', engine_room_section_field_path(@section, field), :method => :delete, :confirm => "You sure?", :title => "Delete?" %></td>
|
32
|
+
</tr>
|
33
|
+
<% end %>
|
34
|
+
</tbody>
|
35
|
+
</table>
|
36
|
+
</div>
|
37
|
+
</div>
|
38
|
+
|
39
|
+
<div id="tab3">
|
40
|
+
<div class="box">
|
41
|
+
<%= link_to "Add Field", new_engine_room_section_field_path(@section), :class => "button" %>
|
42
|
+
<table>
|
43
|
+
<tr>
|
44
|
+
<th>Column</th>
|
45
|
+
<th>Type</th>
|
46
|
+
<th>Sort Order</th>
|
47
|
+
<th>Actions</th>
|
48
|
+
</tr>
|
49
|
+
<% @section.detail_fields.each do |field| %>
|
50
|
+
<tr>
|
51
|
+
<td><%= link_to field.column, edit_engine_room_section_field_path(@section, field) %></td>
|
52
|
+
<td><%= field.field_type %></td>
|
53
|
+
<td><%= field.sort_order %></td>
|
54
|
+
<td><%= link_to 'delete', engine_room_section_field_path(@section, field), :method => :delete, :confirm => "You sure?", :title => "Delete?" %></td>
|
55
|
+
</tr>
|
56
|
+
<% end %>
|
57
|
+
</table>
|
58
|
+
</div>
|
59
|
+
</div>
|
60
|
+
|
61
|
+
<div id="tab4">
|
62
|
+
<div class="box">
|
63
|
+
<%= link_to "Add Field", new_engine_room_section_field_path(@section), :class => "button" %>
|
64
|
+
<table>
|
65
|
+
<tr>
|
66
|
+
<th>Model</th>
|
67
|
+
<th>Sort Order</th>
|
68
|
+
<th>Actions</th>
|
69
|
+
</tr>
|
70
|
+
<% @section.has_many_fields.each do |field| %>
|
71
|
+
<tr>
|
72
|
+
<td><%= link_to field.target_model, edit_engine_room_section_field_path(@section, field) %></td>
|
73
|
+
<td><%= field.sort_order %></td>
|
74
|
+
<td><%= link_to 'delete', engine_room_section_field_path(@section, field), :method => :delete, :confirm => "You sure?", :title => "Delete?" %></td>
|
75
|
+
</tr>
|
76
|
+
<% end %>
|
77
|
+
</table>
|
78
|
+
</div>
|
79
|
+
</div>
|
80
|
+
|
81
|
+
</div><!-- #tabs -->
|