leonardo 1.6.0 → 1.6.1
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/CHANGELOG +5 -0
- data/lib/generators/base.rb +8 -1
- data/lib/generators/erb/leosca/leosca_generator.rb +1 -1
- data/lib/generators/erb/leosca/templates/index.html.erb +1 -1
- data/lib/generators/erb/leosca/templates/show.html.erb +1 -1
- data/lib/generators/erb/leosca/templates/show.js.erb +1 -1
- data/lib/generators/rails/leosca_controller/templates/controller.rb +14 -6
- metadata +4 -4
data/CHANGELOG
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
1.6.1 (September 20th, 2011) Marco Mastrodonato
|
2
|
+
* Improved ajax show title
|
3
|
+
* List resource: the link to parent show resource is now ajax (if remote = true)
|
4
|
+
* Minor bug fix
|
5
|
+
|
1
6
|
1.6.0 (September 16th, 2011) Marco Mastrodonato
|
2
7
|
* Nested resource: use new option rails g leosca product --under=category field:type
|
3
8
|
* Improved views data format
|
data/lib/generators/base.rb
CHANGED
@@ -69,7 +69,7 @@ module Leonardo
|
|
69
69
|
def attribute_to_erb(attribute, object)
|
70
70
|
case attribute.type
|
71
71
|
when :boolean then "<%= #{object}.#{attribute.name} ? style_image_tag(\"ico_v.png\", :class => \"ico_true\") : style_image_tag(\"ico_x.png\", :class => \"ico_false\") %>"
|
72
|
-
when :references, :belongs_to then "<%= link_to((#{object}.#{attribute.name}.try(:name) || \"\#{t('models.#{attribute.name}')} \#{#{object}.#{attribute.name}.try(:id)}\"), #{object}.#{attribute.name}) %>"
|
72
|
+
when :references, :belongs_to then "<%= link_to((#{object}.#{attribute.name}.try(:name) || \"\#{t('models.#{attribute.name}')} \#{#{object}.#{attribute.name}.try(:id)}\"), #{object}.#{attribute.name}, :remote => remote) %>"
|
73
73
|
when :integer then "<%= number_with_delimiter #{object}.#{attribute.name} %>"
|
74
74
|
when :decimal then "<%= number_to_currency #{object}.#{attribute.name} %>"
|
75
75
|
when :float then "<%= number_with_precision #{object}.#{attribute.name} %>"
|
@@ -122,6 +122,13 @@ module Leonardo
|
|
122
122
|
"#{underscore_resource_path(:parent_singular_resource_plural)}_path(#{formatted_parent_resources("@")})"
|
123
123
|
end
|
124
124
|
|
125
|
+
#product under category => category_products_path(category)
|
126
|
+
#product under brand/category => brand_category_products_path(@brand, category)
|
127
|
+
def list_resources_path_back
|
128
|
+
return unless nested?
|
129
|
+
"#{underscore_resource_path(:parent_singular_resource_plural)}_path(#{formatted_parent_resources("@").reverse.sub(/@/, "").reverse})"
|
130
|
+
end
|
131
|
+
|
125
132
|
#product => "product"
|
126
133
|
#product under category => "[@category, product]"
|
127
134
|
#product under brand/category => "[@brand, @category, product]"
|
@@ -69,7 +69,7 @@ module Erb
|
|
69
69
|
file = "app/views/#{plural_last_parent}/_list.erb"
|
70
70
|
inject_into_file file, :before => "<!-- Manage section, do not remove this tag -->" do
|
71
71
|
<<-FILE.gsub(/^ /, '')
|
72
|
-
<td><%= link_to t('models.#{plural_table_name}'), #{
|
72
|
+
<td><%= link_to t('models.#{plural_table_name}'), #{list_resources_path_back} %></td>
|
73
73
|
|
74
74
|
FILE
|
75
75
|
end if File.exists?(file)
|
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
<%% title t('attributes.<%= singular_table_name %>.op_index'<%= ", {:parent => \"#{last_parent}\", :name => @#{last_parent}.try(:name) || @#{last_parent}.try(:id)}" if nested? -%>) %>
|
6
6
|
|
7
|
-
<%% remote =
|
7
|
+
<%% remote = @remote %>
|
8
8
|
<%%= form_for <%= show_resource_path("@") %>, :remote => remote, :html => { :method => :get, :id => "form_search" } do |f| %>
|
9
9
|
<div class="filter-container">
|
10
10
|
<%- attributes.each do |attribute| -%>
|
@@ -2,6 +2,6 @@ var $dialog = $('<div></div>')
|
|
2
2
|
.html("<%%= escape_javascript(render('show'))%>")
|
3
3
|
.dialog({
|
4
4
|
autoOpen: false,
|
5
|
-
title: '<%%= "#{t(:
|
5
|
+
title: '<%%= "#{t('models.<%= singular_table_name %>')} #{@<%= singular_table_name %>.try(:name) || @<%= singular_table_name %>.try(:id)}"%>'
|
6
6
|
});
|
7
7
|
$dialog.dialog('open');
|
@@ -2,7 +2,15 @@
|
|
2
2
|
class <%= controller_class_name %>Controller < ApplicationController
|
3
3
|
<%= "before_filter :authenticate_user!#{CRLF}" if authentication? -%>
|
4
4
|
<%= "load_and_authorize_resource#{CRLF}" if authorization? -%>
|
5
|
-
|
5
|
+
<%#= "before_filter :load_parents#{CRLF}" if nested? -%>
|
6
|
+
before_filter :load_before
|
7
|
+
|
8
|
+
def load_before
|
9
|
+
@remote = <%= options.remote? %>
|
10
|
+
<% base_parent_resources.each do |parent| -%>
|
11
|
+
@<%= parent %> = <%= parent.classify %>.find params[:<%= parent %>_id]
|
12
|
+
<% end -%>
|
13
|
+
end
|
6
14
|
|
7
15
|
<% if nested? -%>
|
8
16
|
def load_parents
|
@@ -19,11 +27,11 @@ end
|
|
19
27
|
conditions_fields = []
|
20
28
|
conditions_values = []
|
21
29
|
|
22
|
-
<%-
|
23
|
-
|
24
|
-
conditions_fields << "#{<%= class_name %>.table_name}.<%=
|
25
|
-
conditions_values << @<%=
|
26
|
-
|
30
|
+
<%- base_parent_resources.each do |parent| -%>
|
31
|
+
<%- if attributes.map(&:name).include? parent -%>
|
32
|
+
conditions_fields << "#{<%= class_name %>.table_name}.<%= parent %>_id = ?"
|
33
|
+
conditions_values << @<%= parent %>.id
|
34
|
+
<%- end -%>
|
27
35
|
<%- end -%>
|
28
36
|
|
29
37
|
if params[:<%= singular_table_name %>]
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: leonardo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 13
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 6
|
9
|
-
-
|
10
|
-
version: 1.6.
|
9
|
+
- 1
|
10
|
+
version: 1.6.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Marco Mastrodonato
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-09-
|
18
|
+
date: 2011-09-20 00:00:00 Z
|
19
19
|
dependencies: []
|
20
20
|
|
21
21
|
description: A generator for creating Rails 3.1 applications ready to go. It generates the layout, the style, the internationalization and manage external gems for authentication, authorization and other. It also provides a customized scaffold to generates cool sites ajax ready in few minutes. If you find a bug please report to m.mastrodonato@gmail.com
|