asf_scaffold_generator 0.0.6 → 0.0.7

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.
@@ -54,11 +54,11 @@
54
54
  <%% for column_name in columns; column = <%= model_name %>.columns_hash[column_name.to_s] %>
55
55
  <%% value = <%= singular_name %>.send(column.name) %>
56
56
  <td class='dataCell'>
57
- <%% unless column.reference_to %>
58
- <%%= value ? link_to(value, :action => 'show', :id => <%= singular_name %>) : '&nbsp;' %>
59
- <%% else %>
57
+ <%% if column.respond_to?(:reference_to) and column.reference_to %>
60
58
  <%%= value ? link_to(column.reference_to,
61
59
  { :controller => column.reference_to.pluralize.underscore, :action=> 'show', :id => value }) : '&nbsp;' %>
60
+ <%% else %>
61
+ <%%= value ? link_to(value, :action => 'show', :id => <%= singular_name %>) : '&nbsp;' %>
62
62
  <%% end %>
63
63
  </td>
64
64
  <%% end %>
@@ -1,39 +1,39 @@
1
+ <% def safe_array(value)
2
+ if value.is_a? Array
3
+ value
4
+ else
5
+ value.nil? ? [] : [ value ]
6
+ end
7
+ end
8
+ %>
1
9
  <% model = model_name.constantize
2
10
  connection = model.connection
3
11
  entity_name = connection.entity_name_from_table(model.table_name)
4
12
  entity_def = connection.get_entity_def(entity_name)
5
- layouts = entity_def.layouts
13
+ layoutMetadata = entity_def.layouts
6
14
  %>
7
15
  <div class="bPageBlock secondaryPalette" id="ep"><div class="pbHeader">
8
16
  <div class="pbBody"><div class="pbSubsection">
9
17
  <table class="detailList">
10
- <% layouts[:layouts][:detailLayoutSections].each do |section|
11
- rows = section[:layoutRows]
12
- rows = [ rows ] unless rows.is_a? Array
13
- rows.each do | row |
18
+ <% safe_array(layoutMetadata[:layouts]).each do |layout|
19
+ safe_array(layout[:detailLayoutSections]).each do |section|
20
+ safe_array(section[:layoutRows]).each do | row |
14
21
  %>
15
22
  <tr>
16
- <% items = row[:layoutItems]
17
- items = [ items ] unless items.is_a? Array
18
- items.each do | item |
19
- %>
23
+ <% safe_array(row[:layoutItems]).each do | item | %>
20
24
  <td class="labelCol"><%= item[:label] %></td>
21
- <% components = item[:layoutComponents]
22
- components = [ components ] unless components.is_a? Array
23
- %>
24
25
  <td class="dataCol col02">
25
- <% components.each do |component|
26
- next if component.nil?
26
+ <% safe_array(item[:layoutComponents]).each do |component|
27
27
  if component[:type] == "Field"
28
28
  field = component[:value]
29
29
  column = entity_def.api_name_to_column[field]
30
30
 
31
31
  col_ref = "@#{singular_name}.#{column.name}"
32
- unless column.reference_to
32
+ if column.respond_to?(:reference_to) and column.reference_to
33
33
  %>
34
- <%%= <%= col_ref %> ? <%= col_ref %> : '&nbsp;' %>
34
+ <%%= <%= col_ref %> ? link_to(<%= col_ref %>, { :controller => '<%= column.reference_to.pluralize.underscore %>', :action=> 'show', :id => <%= col_ref %> }) : '&nbsp;' %>
35
35
  <% else %>
36
- <%%= <%= col_ref %> ? link_to(<%= col_ref %>, { :controller => '<%= column.reference_to.pluralize.underscore %>', :action=> 'show', :id => <%= col_ref %> }) : '&nbsp;' %>
36
+ <%%= <%= col_ref %> ? <%= col_ref %> : '&nbsp;' %>
37
37
  <% end
38
38
  end
39
39
  end
@@ -43,6 +43,7 @@
43
43
  </tr>
44
44
  <% end
45
45
  end
46
+ end
46
47
  %>
47
48
  </table>
48
49
  </div></div>
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
3
3
  specification_version: 1
4
4
  name: asf_scaffold_generator
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.0.6
7
- date: 2006-02-26 00:00:00 -05:00
6
+ version: 0.0.7
7
+ date: 2006-02-27 00:00:00 -05:00
8
8
  summary: ActiveSalesforce Generator provides additional salesforce aware scaffolding support.
9
9
  require_paths:
10
10
  - lib