humdrum-rails 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +18 -0
- data/Features.md +23 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/humdrum-rails.gemspec +30 -0
- data/lib/humdrum/version.rb +4 -0
- data/lib/humdrum.rb +4 -0
- data/lib/rails/generators/humdrum/layout/layout_generator.rb +133 -0
- data/lib/rails/generators/humdrum/layout/templates/controllers/admin_controller.rb +5 -0
- data/lib/rails/generators/humdrum/layout/templates/controllers/application_controller.rb +14 -0
- data/lib/rails/generators/humdrum/layout/templates/controllers/public_controller.rb +5 -0
- data/lib/rails/generators/humdrum/layout/templates/controllers/user_controller.rb +5 -0
- data/lib/rails/generators/humdrum/layout/templates/controllers/welcome_controller.rb +7 -0
- data/lib/rails/generators/humdrum/layout/templates/helpers/display_helper.rb +41 -0
- data/lib/rails/generators/humdrum/layout/templates/helpers/meta_tags_helper.rb +3 -0
- data/lib/rails/generators/humdrum/layout/templates/helpers/navigation_helper.rb +19 -0
- data/lib/rails/generators/humdrum/layout/templates/helpers/title_helper.rb +15 -0
- data/lib/rails/generators/humdrum/layout/templates/images/favicon.ico +0 -0
- data/lib/rails/generators/humdrum/layout/templates/images/glyphicons-halflings-white.png +0 -0
- data/lib/rails/generators/humdrum/layout/templates/images/glyphicons-halflings.png +0 -0
- data/lib/rails/generators/humdrum/layout/templates/javascripts/bootstrap.js +2276 -0
- data/lib/rails/generators/humdrum/layout/templates/javascripts/modernizr.2.6.2.js +815 -0
- data/lib/rails/generators/humdrum/layout/templates/stylesheets/bootstrap-responsive.css +1109 -0
- data/lib/rails/generators/humdrum/layout/templates/stylesheets/bootstrap.css +6158 -0
- data/lib/rails/generators/humdrum/layout/templates/stylesheets/humdrum/boilerplate.css.scss +299 -0
- data/lib/rails/generators/humdrum/layout/templates/stylesheets/humdrum/box.css.scss +57 -0
- data/lib/rails/generators/humdrum/layout/templates/stylesheets/humdrum/caligraphy.css.scss +30 -0
- data/lib/rails/generators/humdrum/layout/templates/stylesheets/humdrum/dividers.css.scss +18 -0
- data/lib/rails/generators/humdrum/layout/templates/stylesheets/humdrum/form.css.scss +80 -0
- data/lib/rails/generators/humdrum/layout/templates/stylesheets/humdrum/misc.css.scss +9 -0
- data/lib/rails/generators/humdrum/layout/templates/stylesheets/humdrum/normalize.css.scss +533 -0
- data/lib/rails/generators/humdrum/layout/templates/stylesheets/humdrum/palettes.css.scss +66 -0
- data/lib/rails/generators/humdrum/layout/templates/stylesheets/humdrum/positioning.css.scss +702 -0
- data/lib/rails/generators/humdrum/layout/templates/stylesheets/overrides-bootstrap.css +24 -0
- data/lib/rails/generators/humdrum/layout/templates/views/layouts/admin/_footer.html.erb +0 -0
- data/lib/rails/generators/humdrum/layout/templates/views/layouts/admin/_header.html.erb +35 -0
- data/lib/rails/generators/humdrum/layout/templates/views/layouts/admin/_navbar.html.erb +0 -0
- data/lib/rails/generators/humdrum/layout/templates/views/layouts/admin.html.erb +65 -0
- data/lib/rails/generators/humdrum/layout/templates/views/layouts/common/_flash_message.html.erb +24 -0
- data/lib/rails/generators/humdrum/layout/templates/views/layouts/common/_meta_tags.html.erb +42 -0
- data/lib/rails/generators/humdrum/layout/templates/views/layouts/common/_overlays.html.erb +9 -0
- data/lib/rails/generators/humdrum/layout/templates/views/layouts/public/_footer.html.erb +0 -0
- data/lib/rails/generators/humdrum/layout/templates/views/layouts/public/_header.html.erb +35 -0
- data/lib/rails/generators/humdrum/layout/templates/views/layouts/public/_navbar.html.erb +0 -0
- data/lib/rails/generators/humdrum/layout/templates/views/layouts/public.html.erb +65 -0
- data/lib/rails/generators/humdrum/layout/templates/views/layouts/user/_footer.html.erb +0 -0
- data/lib/rails/generators/humdrum/layout/templates/views/layouts/user/_header.html.erb +35 -0
- data/lib/rails/generators/humdrum/layout/templates/views/layouts/user/_navbar.html.erb +0 -0
- data/lib/rails/generators/humdrum/layout/templates/views/layouts/user.html.erb +65 -0
- data/lib/rails/generators/humdrum/layout/templates/views/welcome/index.html.erb +5 -0
- data/lib/rails/generators/humdrum/resource/resource_generator.rb +237 -0
- data/lib/rails/generators/humdrum/resource/templates/config/locales/humdrum.en.yml +6 -0
- data/lib/rails/generators/humdrum/resource/templates/controllers/resource_controller.rb +192 -0
- data/lib/rails/generators/humdrum/resource/templates/migrations/create_resources.rb +14 -0
- data/lib/rails/generators/humdrum/resource/templates/models/resource.rb +5 -0
- data/lib/rails/generators/humdrum/resource/templates/views/resource/_edit.html.erb +7 -0
- data/lib/rails/generators/humdrum/resource/templates/views/resource/_filters.html.erb +9 -0
- data/lib/rails/generators/humdrum/resource/templates/views/resource/_form.html.erb +44 -0
- data/lib/rails/generators/humdrum/resource/templates/views/resource/_index.html.erb +22 -0
- data/lib/rails/generators/humdrum/resource/templates/views/resource/_item.html.erb +21 -0
- data/lib/rails/generators/humdrum/resource/templates/views/resource/_nav_filters.html.erb +9 -0
- data/lib/rails/generators/humdrum/resource/templates/views/resource/_new.html.erb +9 -0
- data/lib/rails/generators/humdrum/resource/templates/views/resource/_show.html.erb +38 -0
- data/lib/rails/generators/humdrum/resource/templates/views/resource/_summary.html.erb +10 -0
- data/lib/rails/generators/humdrum/resource/templates/views/resource/create.js.erb +15 -0
- data/lib/rails/generators/humdrum/resource/templates/views/resource/destroy.js.erb +14 -0
- data/lib/rails/generators/humdrum/resource/templates/views/resource/edit.js.erb +2 -0
- data/lib/rails/generators/humdrum/resource/templates/views/resource/index.html.erb +33 -0
- data/lib/rails/generators/humdrum/resource/templates/views/resource/index.js.erb +15 -0
- data/lib/rails/generators/humdrum/resource/templates/views/resource/new.js.erb +2 -0
- data/lib/rails/generators/humdrum/resource/templates/views/resource/show.js.erb +2 -0
- data/lib/rails/generators/humdrum/resource/templates/views/resource/update.js.erb +14 -0
- metadata +170 -0
@@ -0,0 +1,192 @@
|
|
1
|
+
class <%= controller_class %> < ApplicationController
|
2
|
+
|
3
|
+
#before_filter :require_user, :set_navs, :parse_filters_from_url
|
4
|
+
layout "public"
|
5
|
+
#authorize_actions_for Item, :actions => {:index => :delete}
|
6
|
+
|
7
|
+
# GET /<%= instances_name %>
|
8
|
+
# GET /<%= instances_name %>.js
|
9
|
+
# GET /<%= instances_name %>.json
|
10
|
+
def index
|
11
|
+
|
12
|
+
get_collections
|
13
|
+
|
14
|
+
respond_to do |format|
|
15
|
+
format.html # index.html.erb
|
16
|
+
format.json { render json: @<%= instances_name %> }
|
17
|
+
format.js {}
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# GET /<%= instances_name %>/1
|
22
|
+
# GET /<%= instances_name %>/1.js
|
23
|
+
# GET /<%= instances_name %>/1.json
|
24
|
+
def show
|
25
|
+
## Creating the <%= instance_name %> object
|
26
|
+
@<%= instance_name %> = <%= model_class %>.find(params[:id])
|
27
|
+
|
28
|
+
respond_to do |format|
|
29
|
+
format.html { get_collections and render :action => :index }
|
30
|
+
format.json { render json: @<%= instance_name %> }
|
31
|
+
format.js {}
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# GET /<%= instances_name %>/new
|
36
|
+
# GET /<%= instances_name %>/new.json
|
37
|
+
def new
|
38
|
+
## Intitializing the <%= instance_name %> object
|
39
|
+
@<%= instance_name %> = <%= model_class %>.new
|
40
|
+
|
41
|
+
respond_to do |format|
|
42
|
+
format.html # new.html.erb
|
43
|
+
format.json { render json: @<%= instance_name %> }
|
44
|
+
format.js {}
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# GET /<%= instances_name %>/1/edit
|
49
|
+
def edit
|
50
|
+
## Fetching the <%= instance_name %> object
|
51
|
+
@<%= instance_name %> = <%= model_class %>.find(params[:id])
|
52
|
+
end
|
53
|
+
|
54
|
+
# POST /<%= instances_name %>
|
55
|
+
# POST /<%= instances_name %>.js
|
56
|
+
# POST /<%= instances_name %>.json
|
57
|
+
def create
|
58
|
+
## Creating the <%= instance_name %> object
|
59
|
+
@<%= instance_name %> = <%= model_class %>.new(params[:<%= instance_name %>])
|
60
|
+
|
61
|
+
## Validating the data
|
62
|
+
@<%= instance_name %>.valid?
|
63
|
+
|
64
|
+
respond_to do |format|
|
65
|
+
if @<%= instance_name %>.errors.blank?
|
66
|
+
|
67
|
+
# Saving the <%= instance_name %> object
|
68
|
+
@<%= instance_name %>.save
|
69
|
+
|
70
|
+
# Setting the flash message
|
71
|
+
message = translate("forms.created_successfully", :item => "<%= instance_name.titleize %>")
|
72
|
+
store_flash_message(message, :success)
|
73
|
+
|
74
|
+
format.html {
|
75
|
+
redirect_to <%= resource_link('show','url') %>(@<%= instance_name %>), notice: message
|
76
|
+
}
|
77
|
+
format.json { render json: @<%= instance_name %>, status: :created, location: @<%= instance_name %> }
|
78
|
+
format.js {}
|
79
|
+
else
|
80
|
+
|
81
|
+
# Setting the flash message
|
82
|
+
message = @<%= instance_name %>.errors.full_messages.to_sentence
|
83
|
+
store_flash_message(message, :alert)
|
84
|
+
|
85
|
+
format.html { render action: "new" }
|
86
|
+
format.json { render json: @<%= instance_name %>.errors, status: :unprocessable_entity }
|
87
|
+
format.js {}
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
# PUT /<%= instances_name %>/1
|
93
|
+
# PUT /<%= instances_name %>/1.js
|
94
|
+
# PUT /<%= instances_name %>/1.json
|
95
|
+
def update
|
96
|
+
## Fetching the <%= instance_name %>
|
97
|
+
@<%= instance_name %> = <%= model_class %>.find(params[:id])
|
98
|
+
|
99
|
+
## Updating the @<%= instance_name %> object with params
|
100
|
+
@<%= instance_name %>.update_attributes(params[:<%= instance_name %>])
|
101
|
+
|
102
|
+
## Validating the data
|
103
|
+
@<%= instance_name %>.valid?
|
104
|
+
|
105
|
+
respond_to do |format|
|
106
|
+
if @<%= instance_name %>.errors.blank?
|
107
|
+
|
108
|
+
# Saving the <%= instance_name %> object
|
109
|
+
@<%= instance_name %>.save
|
110
|
+
|
111
|
+
# Setting the flash message
|
112
|
+
message = translate("forms.updated_successfully", :item => "<%= instance_name.titleize %>")
|
113
|
+
store_flash_message(message, :success)
|
114
|
+
|
115
|
+
format.html {
|
116
|
+
redirect_to <%= resource_link('show','url') %>(@<%= instance_name %>), notice: message
|
117
|
+
}
|
118
|
+
format.json { head :no_content }
|
119
|
+
format.js {}
|
120
|
+
|
121
|
+
else
|
122
|
+
|
123
|
+
# Setting the flash message
|
124
|
+
message = @<%= instance_name %>.errors.full_messages.to_sentence
|
125
|
+
store_flash_message(message, :alert)
|
126
|
+
|
127
|
+
format.html {
|
128
|
+
render action: "edit"
|
129
|
+
}
|
130
|
+
format.json { render json: @<%= instance_name %>.errors, status: :unprocessable_entity }
|
131
|
+
format.js {}
|
132
|
+
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
# DELETE /<%= instances_name %>/1
|
138
|
+
# DELETE /<%= instances_name %>/1.js
|
139
|
+
# DELETE /<%= instances_name %>/1.json
|
140
|
+
def destroy
|
141
|
+
## Fetching the <%= instance_name %>
|
142
|
+
@<%= instance_name %> = <%= model_class %>.find(params[:id])
|
143
|
+
|
144
|
+
respond_to do |format|
|
145
|
+
## Destroying the <%= instance_name %>
|
146
|
+
@<%= instance_name %>.destroy
|
147
|
+
|
148
|
+
# Fetch the <%= instances_name %> to refresh ths list and details box
|
149
|
+
get_collections
|
150
|
+
@<%= instance_name %> = @<%= instances_name %>.first
|
151
|
+
|
152
|
+
# Setting the flash message
|
153
|
+
message = translate("forms.destroyed_successfully", :item => "<%= instance_name.titleize %>")
|
154
|
+
store_flash_message(message, :success)
|
155
|
+
|
156
|
+
format.html {
|
157
|
+
redirect_to <%= resource_link('index', 'url') %> notice: message
|
158
|
+
}
|
159
|
+
format.json { head :no_content }
|
160
|
+
format.js {}
|
161
|
+
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
private
|
166
|
+
|
167
|
+
def set_navs
|
168
|
+
set_nav("<%= model_class %>")
|
169
|
+
end
|
170
|
+
|
171
|
+
def get_collections
|
172
|
+
# Fetching the <%= instances_name %>
|
173
|
+
relation = <%= model_class %>.where("")
|
174
|
+
@filters = {}
|
175
|
+
|
176
|
+
if params[:<%= instance_name %>] && params[:<%= instance_name %>][:query]
|
177
|
+
@query = params[:<%= instance_name %>][:query].strip
|
178
|
+
if !@query.blank?
|
179
|
+
relation = relation.where("LOWER(name) LIKE LOWER('%#{@query}%') OR LOWER(description) LIKE LOWER('%#{@query}%')")
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
@<%= instances_name %> = relation.order("created_at desc").page(@current_page).per(@per_page)
|
184
|
+
|
185
|
+
## Initializing the @<%= instance_name %> object so that we can render the show partial
|
186
|
+
@<%= instance_name %> = @<%= instances_name %>.first unless @<%= instance_name %>
|
187
|
+
|
188
|
+
return true
|
189
|
+
|
190
|
+
end
|
191
|
+
|
192
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class Create<%= model_class.pluralize %> < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :<%= table_name %> do |t|
|
4
|
+
<%- fields.each do |name, type| -%>
|
5
|
+
t.<%= type %> :<%= name %>
|
6
|
+
<%- end -%>
|
7
|
+
t.timestamps
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.down
|
12
|
+
drop_table :<%= table_name %>
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<%%= link_to raw("<i class='icon-plus icon-white margin-right-5'></i> New Item"), <%= resource_link('new', 'path') %>, :class=>"btn btn-warning pull-right margin-left-10", :remote=>true %>
|
2
|
+
|
3
|
+
<%# Used to add a search functionality %>
|
4
|
+
<%%= form_for <%= model_class %>.new, :url => <%= resource_link('index', 'path') %>, :method => :get, :remote=>true, :html=>{:class=>"pull-right", :style=>"margin-bottom:0px;"} do |f| %>
|
5
|
+
<div class="input-append">
|
6
|
+
<input type="text" style="width:160px;" name="item[query]" placeholder="Search Item ...">
|
7
|
+
<button type="submit" class="btn btn-inverse"><i class="icon-search icon-white"></i></button>
|
8
|
+
</div>
|
9
|
+
<%%- end %>
|
@@ -0,0 +1,44 @@
|
|
1
|
+
|
2
|
+
<%%# Renders a partial which is used to create a new <%= instance_name %> %>
|
3
|
+
<%%= simple_form_for(<%= form_link_param %>, :html => {:class=>"form-vertical", :style => "margin-bottom:0px;", :method => (@<%= instance_name %>.new_record? ? :post : :put), :remote=>true}) do |f| %>
|
4
|
+
|
5
|
+
<%%= f.error_notification %>
|
6
|
+
<%%= @<%= instance_name %>.errors[:base].to_sentence %>
|
7
|
+
|
8
|
+
<div class="form-inputs">
|
9
|
+
|
10
|
+
<%- fields.each do |name, type| -%>
|
11
|
+
<% if type == "text" %>
|
12
|
+
<%%= f.input :<%= name %>, :required => true, :input_html=>{:style=>"width:95%; margin-bottom:5px;", :rows=>"8"} %>
|
13
|
+
<% else %>
|
14
|
+
<%%= f.input :<%= name %>, :required => true, :input_html=>{:style=>"width:95%; margin-bottom:5px;"} %>
|
15
|
+
<% end %>
|
16
|
+
<%- end -%>
|
17
|
+
|
18
|
+
<%%#= f.input :name, :placeholder => 'Enter Item Name', :required => true, :input_html=>{:style=>"width:95%; margin-bottom:5px;"} %>
|
19
|
+
|
20
|
+
<%%#= f.input :age, :required => false, :input_html=>{:style=>"width:95%; margin-bottom:5px;"} %>
|
21
|
+
|
22
|
+
<%%#= f.input :description, :as => :text, :placeholder => 'Add Description for the Item', :input_html => { :rows => 6, :style => "width:95%;height:200px; margin-bottom:5px;" } %>
|
23
|
+
|
24
|
+
<%%#= f.input :cost, :hint => 'Enter Item Cost', :required => true, :input_html=>{:style=>"width:95%; margin-bottom:5px;"} %>
|
25
|
+
|
26
|
+
<%%# list = ['2010 - Margaret Blue', 'Agenta Black', 'Margaret Blue', 'Crimson Yellow', 'Scarlet Red', 'Peacock Blue'] %>
|
27
|
+
<%%#= f.input :model, :as => :select, :collection => list, :input_html=>{:class=>"select2 prompt", :style=>"width:100%;"}, :selected => [ "Scarlet Red" ] %>
|
28
|
+
|
29
|
+
</div>
|
30
|
+
<div class="cl-10"></div>
|
31
|
+
|
32
|
+
<%% button_text = "#{@<%= instance_name %>.new_record? ? "Create" : "Update"} Item" %>
|
33
|
+
<div class="pull-right">
|
34
|
+
<%% if @<%= instance_name %>.new_record? %>
|
35
|
+
<%%= link_to "Cancel", "#", :class => "btn", :remote=>true %>
|
36
|
+
<%% else %>
|
37
|
+
<%%= link_to 'Back', <%= resource_link('index', 'path') %>, :class=>"btn margin-left-10", :remote => true unless @<%= instance_name %>.new_record? %>
|
38
|
+
<%% end %>
|
39
|
+
<%%= f.submit button_text, "data-reset-text"=>button_text, "data-loading-text"=>"Saving ...", :class=>"btn btn-primary margin-left-10" %>
|
40
|
+
</div>
|
41
|
+
<div class="cl-10"></div>
|
42
|
+
|
43
|
+
<%% end %>
|
44
|
+
|
@@ -0,0 +1,22 @@
|
|
1
|
+
|
2
|
+
<%%# Displays list of @<%= instances_name %> %>
|
3
|
+
<div id="div_<%= instance_name %>_collections">
|
4
|
+
<%% @<%= instances_name %>.each do |<%= instance_name %>| %>
|
5
|
+
<div id="div_<%= instance_name %>_<%%= <%= instance_name %>.id %>">
|
6
|
+
<%%= render :partial=>"item", :locals=>{:<%= instance_name %>=><%= instance_name %>} %>
|
7
|
+
</div>
|
8
|
+
<%% end %>
|
9
|
+
<%% if @<%= instances_name %>.blank? %>
|
10
|
+
<div id="div_<%= instance_name %>_empty" class="box text-color-grey padding-80 text-align-center" style="height:200px;">
|
11
|
+
<%%= translate("forms.no_results_found") %>
|
12
|
+
</div>
|
13
|
+
<%% end %>
|
14
|
+
</div>
|
15
|
+
<div class="cl"></div>
|
16
|
+
|
17
|
+
<%% if @<%= instances_name %>.any? %>
|
18
|
+
<%%= content_tag :div, :class=>"pull-right" do %>
|
19
|
+
<%%= paginate @<%= instances_name %>, :remote => true, :theme => 'twitter-bootstrap' %>
|
20
|
+
<%% end %>
|
21
|
+
<%% end %>
|
22
|
+
<div class="cl"></div>
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<%%# describes about each <%= instance_name %> %>
|
2
|
+
<div class="box hoverable padding-10 box-border-black">
|
3
|
+
|
4
|
+
<div class="pull-left width-30">
|
5
|
+
<%%= link_to <%= instance_name %>.<%= main_string_field %>, <%= resource_link('show', 'path') %>(<%= instance_name %>), :remote=>true, :class=>"font-size-13" %></br>
|
6
|
+
|
7
|
+
<div class="text-color-grey">
|
8
|
+
<%%= display_time(<%= instance_name %>.created_at) %>
|
9
|
+
</div>
|
10
|
+
|
11
|
+
</div>
|
12
|
+
|
13
|
+
<div class="pull-left width-60">
|
14
|
+
<%- text_fields.each do |name| -%>
|
15
|
+
<%%= scrap_word(<%= instance_name %>.<%= name %>, 200) %>
|
16
|
+
<%- end -%>
|
17
|
+
</div>
|
18
|
+
|
19
|
+
<div class="cl"></div>
|
20
|
+
|
21
|
+
</div>
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<%%= link_to 'New <%= model_class %>', <%= resource_link('new', 'path') %>, :class=>"btn btn-mini btn-primary pull-right margin-left-10", :remote=>true %>
|
2
|
+
|
3
|
+
<%%# Used to add a search functionality %>
|
4
|
+
<%%= form_for <%= model_class %>.new, :url => <%= resource_link('index', 'path') %>, :method => :get, :remote=>true, :html=>{:class=>"pull-right", :style=>"margin-bottom:0px;"} do |f| %>
|
5
|
+
<div class="input-append">
|
6
|
+
<input type="text" style="height:13px;width:120px;" name="<%= instance_name %>[query]">
|
7
|
+
<button type="submit" class="btn btn-mini btn-primary"><i class="icon-search icon-white margin-right-5"></i>Search Item ...</button>
|
8
|
+
</div>
|
9
|
+
<%%- end %>
|
@@ -0,0 +1,38 @@
|
|
1
|
+
|
2
|
+
<%%# Displays a detailed view of the <%= instance_name %> %>
|
3
|
+
<%%# Display Flash Message if any only in case of ajax request %>
|
4
|
+
<%% if request.xhr? %>
|
5
|
+
<%%= render :partial=>"layouts/common/flash_message" %>
|
6
|
+
<%% end %>
|
7
|
+
|
8
|
+
<div class="box padding-10">
|
9
|
+
|
10
|
+
<div class="margin-10 text-color-blue font-size-22">
|
11
|
+
<%%= @<%= instance_name %>.<%= main_string_field %> %>
|
12
|
+
</div>
|
13
|
+
|
14
|
+
<%- string_fields.each do |name| -%>
|
15
|
+
<% next if name == main_string_field %>
|
16
|
+
<div class="margin-left-10">
|
17
|
+
<%= name.titleize %>: <%%= link_to @<%= instance_name %>.<%= name %>, "#", :class=>"text-color-red" %>
|
18
|
+
</div>
|
19
|
+
<%- end -%>
|
20
|
+
<% puts fields %>
|
21
|
+
<%- fields.map{|name, type| name unless ["text", "string"].include?(type)}.compact.uniq.each do |name| -%>
|
22
|
+
<div class="margin-left-10">
|
23
|
+
<%= name.titleize %>: <%%= @<%= instance_name %>.<%= name %> %>
|
24
|
+
</div>
|
25
|
+
<%- end -%>
|
26
|
+
|
27
|
+
<%- text_fields.each do |name| -%>
|
28
|
+
<div class='italic margin-10'><%%= simple_format @<%= instance_name %>.<%= name %> %></div>
|
29
|
+
<%- end -%>
|
30
|
+
|
31
|
+
<div class="palette-footer margin-left-10">
|
32
|
+
<%%= display_time(@<%= instance_name %>.created_at, "pull-left text-color-grey") %>
|
33
|
+
<%%= link_to raw("<i class=\"icon-pencil icon-white margin-right-5\"></i> Edit"), <%= resource_link('edit', 'path') %>(@<%= instance_name %>), :class=>"btn btn-inverse btn-mini pull-right margin-left-10", :remote=>true %>
|
34
|
+
<%%= link_to raw("<i class=\"icon-remove \"></i> Delete"), <%= resource_link('destroy', 'path') %>(@<%= instance_name %>), method: :delete, data: { confirm: 'Are you sure?' }, :class=>"btn btn-mini pull-right", :remote=>true %>
|
35
|
+
<div class="cl-10"></div>
|
36
|
+
</div>
|
37
|
+
|
38
|
+
</div>
|
@@ -0,0 +1,10 @@
|
|
1
|
+
|
2
|
+
<%%# Displays Total number of items in the system %>
|
3
|
+
<%%# Display Flash Message if any only in case of ajax request %>
|
4
|
+
<%% if request.xhr? %>
|
5
|
+
<%%= render :partial=>"layouts/common/flash_message" %>
|
6
|
+
<%% end %>
|
7
|
+
|
8
|
+
<div class="box padding-10" style="height:200px;">
|
9
|
+
Total Items = <%%= <%= model_class %>.count %>
|
10
|
+
</div>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<%% if @<%= instance_name %>.errors.blank? %>
|
2
|
+
|
3
|
+
// Fill the right box with first <%= instance_name %> details
|
4
|
+
$('#div_<%= instance_name %>_details').html("<%%= escape_javascript(render(:partial=>'show')) %>");
|
5
|
+
|
6
|
+
// Add the newly created item to the list
|
7
|
+
$("#div_<%= instance_name %>_collections").prepend("<div id=\"div_item_<%= instance_name %>_<%%= @<%= instance_name %>.id %>\"><%%= escape_javascript(render(:partial => 'item', :locals => { :<%= instance_name %> => @<%= instance_name %> })) %></div>")
|
8
|
+
$("#div_<%= instance_name %>_empty").hide();
|
9
|
+
|
10
|
+
<%% else %>
|
11
|
+
|
12
|
+
// Reload the form partial to display errors
|
13
|
+
$('#div_<%= instance_name %>_details').html("<%%= escape_javascript(render(:partial=>'new')) %>");
|
14
|
+
|
15
|
+
<%% end %>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<%% if @<%= instance_name %>.errors.blank? %>
|
2
|
+
|
3
|
+
// Fill the right box with first <%= instance_name %> details
|
4
|
+
$('#div_<%= instance_name %>_details').html("<%%= escape_javascript(render(:partial=>'show')) %>");
|
5
|
+
|
6
|
+
// Render health care <%= instances_name %> List
|
7
|
+
$('#div_<%= instance_name %>_collections').html("<%%= escape_javascript(render(:partial=>'index')) %>");
|
8
|
+
|
9
|
+
<%% else %>
|
10
|
+
|
11
|
+
// Render the show partial to show flash message
|
12
|
+
$('#div_<%= instance_name %>_details').html("<%%= escape_javascript(render(:partial=>'show')) %>");
|
13
|
+
|
14
|
+
<%% end %>
|
@@ -0,0 +1,33 @@
|
|
1
|
+
|
2
|
+
<%%# Displays to Manage the items %>
|
3
|
+
<div class="<%= row_class %> padding-top-10 margin-left-0">
|
4
|
+
<div class="font-size-22 pull-left">Manage <%= model_class.pluralize %></div>
|
5
|
+
<div id="div_<%= instance_name %>_filters pull-right">
|
6
|
+
<%%= render :partial=>"filters" %>
|
7
|
+
</div>
|
8
|
+
<div class="cl-20"></div>
|
9
|
+
</div>
|
10
|
+
<%%# Renders a partial to display all the <%= instances_name %> %>
|
11
|
+
<div class="<%= row_class %>">
|
12
|
+
<div id="div_<%= instance_name %>_index" class="span6">
|
13
|
+
<%%= render :partial=>"index" %>
|
14
|
+
</div>
|
15
|
+
|
16
|
+
<div id="div_<%= instance_name %>_details" class="span6">
|
17
|
+
<%% case params[:action] %>
|
18
|
+
<%% when "new", "edit", "show" %>
|
19
|
+
<%%= render :partial=>params[:action] %>
|
20
|
+
<%% when "index" %>
|
21
|
+
<%% if @<%= instances_name %>.empty? %>
|
22
|
+
<%%= render :partial=>"summary" %>
|
23
|
+
<%% else %>
|
24
|
+
<%%= render :partial=>"show" %>
|
25
|
+
<%% end %>
|
26
|
+
<%% else %>
|
27
|
+
<%%= render :partial=>"summary" %>
|
28
|
+
<%% end %>
|
29
|
+
</div>
|
30
|
+
|
31
|
+
</div>
|
32
|
+
|
33
|
+
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<%% if @<%= instances_name %>.any? %>
|
2
|
+
|
3
|
+
// Fill the right box with first <%= instance_name %> details in the list
|
4
|
+
$('#div_<%= instance_name %>_details').html("<%%= escape_javascript(render(:partial=>'show')) %>");
|
5
|
+
|
6
|
+
// Rendering the item list
|
7
|
+
$('#div_<%= instance_name %>_collections').html("<%%= escape_javascript(render(:partial=>"index")) %>");
|
8
|
+
|
9
|
+
<%% else %>
|
10
|
+
|
11
|
+
var noResultsText = "<div class='box padding-10' style='height:200px;'>No results found.</div>";
|
12
|
+
$('#div_<%= instance_name %>_list').html(noResultsText);
|
13
|
+
$('#div_<%= instance_name %>_list').html(noResultsText);
|
14
|
+
|
15
|
+
<%% end %>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<%% if @<%= instance_name %>.errors.blank? %>
|
2
|
+
|
3
|
+
// Fill the right box with first item details
|
4
|
+
$('#div_<%= instance_name %>_details').html("<%%= escape_javascript(render(:partial=>"show")) %>");
|
5
|
+
|
6
|
+
// Refresh the updated item in the list
|
7
|
+
$("#div_<%= instance_name %>_<%%= @<%= instance_name %>.id %>").html("<%%= escape_javascript(render :partial => 'item', :locals => { :<%= instance_name %> => @<%= instance_name %> }) %>")
|
8
|
+
|
9
|
+
<%% else %>
|
10
|
+
|
11
|
+
// Reload the form partial to display errors
|
12
|
+
$('#div_<%= instance_name %>_details').html("<%%= escape_javascript(render(:partial=>"edit")) %>");
|
13
|
+
|
14
|
+
<%% end %>
|