shakes 0.4.1 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/app/views/shakes/_form.html.erb +2 -2
- data/app/views/shakes/form/_boolean.html.erb +1 -1
- data/app/views/shakes/form/_date.html.erb +1 -1
- data/app/views/shakes/form/_datetime.html.erb +1 -1
- data/app/views/shakes/form/_field.html.erb +1 -1
- data/app/views/shakes/form/_text.html.erb +1 -1
- data/app/views/shakes/form/_time.html.erb +1 -1
- data/app/views/shakes/form/_timestamp.html.erb +1 -1
- data/app/views/shakes/index.html.erb +2 -2
- data/lib/shakes/has_the_shakes.rb +5 -0
- data/lib/shakes/helpers/layout_helper.rb +1 -1
- data/lib/shakes/helpers/views_helper.rb +19 -5
- metadata +3 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<%- unless Shakes::Helpers::ViewsHelper::Configuration.use_formtastic -%>
|
|
2
|
-
<% form_for @resource do |form| %>
|
|
2
|
+
<% form_for(@resource, :url => shakes_path_for(action, @resource)) do |form| %>
|
|
3
3
|
<fieldset class="inputs">
|
|
4
4
|
<ol>
|
|
5
5
|
<%- shakes_fields_for(action).each do |field| -%>
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
</fieldset>
|
|
19
19
|
<% end %>
|
|
20
20
|
<%- else -%>
|
|
21
|
-
<% semantic_form_for @resource do |form| %>
|
|
21
|
+
<% semantic_form_for(@resource, :url => shakes_path_for(action, @resource)) do |form| %>
|
|
22
22
|
<%= form.inputs %>
|
|
23
23
|
<%= form.buttons %>
|
|
24
24
|
<% end %>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<%= form.label field %> <%= form.check_box field %>
|
|
1
|
+
<%= form.label field, shakes_human_attribute_name_for(field).titleize %> <%= form.check_box field %>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<%= form.label field %> <%= form.date_select field %>
|
|
1
|
+
<%= form.label field, shakes_human_attribute_name_for(field).titleize %> <%= form.date_select field %>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<%= form.label field %> <%= form.datetime_select field %>
|
|
1
|
+
<%= form.label field, shakes_human_attribute_name_for(field).titleize %> <%= form.datetime_select field %>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<%= form.label field %> <%= form.text_field field %>
|
|
1
|
+
<%= form.label field, shakes_human_attribute_name_for(field).titleize %> <%= form.text_field field %>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<%= form.label field %> <%= form.text_area field %>
|
|
1
|
+
<%= form.label field, shakes_human_attribute_name_for(field).titleize %> <%= form.text_area field %>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<%= form.label field %> <%= form.time_select field %>
|
|
1
|
+
<%= form.label field, shakes_human_attribute_name_for(field).titleize %> <%= form.time_select field %>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<%= form.label field %> <%= form.datetime_select field %>
|
|
1
|
+
<%= form.label field, shakes_human_attribute_name_for(field).titleize %> <%= form.datetime_select field %>
|
|
@@ -4,14 +4,14 @@
|
|
|
4
4
|
<%- shakes_fields_for(:index).each do |field| -%>
|
|
5
5
|
<%= content_tag :th, shakes_human_attribute_name_for(field).titleize, :class => shakes_field_type_for(field).to_s %>
|
|
6
6
|
<%- end -%>
|
|
7
|
-
|
|
7
|
+
<%= content_tag :th, 'Actions', :class => 'actions' %>
|
|
8
8
|
</tr>
|
|
9
9
|
<%- @resources.each do |resource| -%>
|
|
10
10
|
<tr>
|
|
11
11
|
<%- shakes_fields_for(:index).each do |field| -%>
|
|
12
12
|
<%= content_tag :td, shakes_render_field(field, :index, resource), :class => shakes_field_type_for(field).to_s %>
|
|
13
13
|
<%- end -%>
|
|
14
|
-
|
|
14
|
+
<%= content_tag :td, shakes_link_to_for([:show, :edit, :destroy], resource), :class => 'actions' %>
|
|
15
15
|
</tr>
|
|
16
16
|
<%- end -%>
|
|
17
17
|
</table>
|
|
@@ -40,6 +40,10 @@ module Shakes
|
|
|
40
40
|
@controller_class ||= Object::const_get(self.class.name.classify)
|
|
41
41
|
end
|
|
42
42
|
|
|
43
|
+
def controller_class_name
|
|
44
|
+
@controller_class_name ||= self.class.name.sub!(/Controller$/,'').singularize.underscore
|
|
45
|
+
end
|
|
46
|
+
|
|
43
47
|
def resource_class
|
|
44
48
|
@resource_class ||= Object::const_get(self.class.shakes_resource.classify)
|
|
45
49
|
end
|
|
@@ -64,6 +68,7 @@ module Shakes
|
|
|
64
68
|
raise unless self.shakes_actions.include? options[:action].to_sym
|
|
65
69
|
|
|
66
70
|
controller_class
|
|
71
|
+
controller_class_name
|
|
67
72
|
resource_class
|
|
68
73
|
resource_collection_name
|
|
69
74
|
resource_instance_name
|
|
@@ -24,23 +24,37 @@ module Shakes
|
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
def shakes_human_name
|
|
27
|
+
puts @resource_class.human_name
|
|
27
28
|
@resource_class.human_name
|
|
28
29
|
end
|
|
29
30
|
|
|
31
|
+
def shakes_path_for(action, resource=nil)
|
|
32
|
+
case action
|
|
33
|
+
when :index
|
|
34
|
+
method("#{@controller_class_name.pluralize}_path".to_sym).call
|
|
35
|
+
when :new
|
|
36
|
+
method("new_#{@controller_class_name}_path".to_sym).call
|
|
37
|
+
when :show, :destroy
|
|
38
|
+
method("#{@controller_class_name}_path".to_sym).call(resource)
|
|
39
|
+
when :edit
|
|
40
|
+
method("edit_#{@controller_class_name}_path".to_sym).call(resource)
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
30
44
|
def shakes_link_to_for(actions=[], resource=nil)
|
|
31
45
|
links = []
|
|
32
46
|
(actions.map { |action| action.to_sym }).each do |action|
|
|
33
47
|
case action
|
|
34
48
|
when :index
|
|
35
|
-
links << link_to("Back",
|
|
49
|
+
links << link_to("Back", shakes_path_for(:index)) if @controller_class.new.respond_to? :index
|
|
36
50
|
when :new
|
|
37
|
-
links << link_to("New #{shakes_human_name}",
|
|
51
|
+
links << link_to("New #{shakes_human_name}", shakes_path_for(:new)) if @controller_class.new.respond_to? :new
|
|
38
52
|
when :show
|
|
39
|
-
links << link_to('Show', resource) if @controller_class.new.respond_to? :show
|
|
53
|
+
links << link_to('Show', shakes_path_for(:show, resource)) if @controller_class.new.respond_to? :show
|
|
40
54
|
when :edit
|
|
41
|
-
links << link_to('Edit',
|
|
55
|
+
links << link_to('Edit', shakes_path_for(:edit, resource)) if @controller_class.new.respond_to? :edit
|
|
42
56
|
when :destroy
|
|
43
|
-
links << link_to('Destroy', resource, :confirm => 'Are you sure?', :method => :delete) if @controller_class.new.respond_to? :destroy
|
|
57
|
+
links << link_to('Destroy', shakes_path_for(:destroy, resource), :confirm => 'Are you sure?', :method => :delete) if @controller_class.new.respond_to? :destroy
|
|
44
58
|
end
|
|
45
59
|
end
|
|
46
60
|
links.join(' | ')
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: shakes
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
hash:
|
|
4
|
+
hash: 11
|
|
5
5
|
prerelease: false
|
|
6
6
|
segments:
|
|
7
7
|
- 0
|
|
8
8
|
- 4
|
|
9
|
-
-
|
|
10
|
-
version: 0.4.
|
|
9
|
+
- 2
|
|
10
|
+
version: 0.4.2
|
|
11
11
|
platform: ruby
|
|
12
12
|
authors:
|
|
13
13
|
- Jason Stahl
|