active_scaffold 3.4.22 → 3.4.23

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5e3c5d2bad80f3ddbf5610ba433594ce55fc3373
4
- data.tar.gz: a37268b8a8c4633e5324154e9c764ace3feecb94
3
+ metadata.gz: f7165870ea614c4b6716d2e3471179817ddff211
4
+ data.tar.gz: d8cf35a1036360fc2f78e061b1f1e34d54b4449f
5
5
  SHA512:
6
- metadata.gz: b05685d5fbbe603c317c6b01f5d2b6af1ba7fb44b8e246d6b2ac54675699d08f4263c529ed36042ba8135990b377b340b98371040bb3ebbde270db7f70651650
7
- data.tar.gz: 838826402a406aada754ab436857ba53b3c4026a00466417d64970f9a52057154083bf006643d7e302b8db6f7891e0c101aba7b7fc477778c89b709a067ac9f1
6
+ metadata.gz: 85707d87e834e46b05a286db1dd795980c9329c53563d28238a69e459a72a7825d2faf78ff55898d0cf58b4180932d5cd4eafba81c9ca62a743e5ea23d0a3884
7
+ data.tar.gz: 262c83c84c084418072a6706d9db22b0f9d04d93b5fa6fa4be552b386663ffd18f2c3b2ca252cf039f2e302ea7fc4c5c0d44ba954d9d63bab349d6a2deebb70b
data/CHANGELOG CHANGED
@@ -1,3 +1,8 @@
1
+ = 3.4.23
2
+ - fix chosen on new subform rows
3
+ - add show_ui to column
4
+ - add :vertical and :horizontal show_ui for associations
5
+
1
6
  = 3.4.22
2
7
  - fix has_one/many tableless model through association
3
8
  - fix check default value for checkboxes, so if record in subform, with checkbox, is left as default, is not saved, but setting checkbox would save record
@@ -1,4 +1,4 @@
1
- Copyright (c) 2006 Richard White
1
+ Copyright (c) 2006-2015 Richard White, Sergio Cambra and contributors
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
@@ -1,5 +1,5 @@
1
1
  jQuery(document).ready(function() {
2
- jQuery(document).on('as:element_updated', function(event) {
2
+ jQuery(document).on('as:element_updated as:element_created', function(event) {
3
3
  jQuery('select.chosen', event.target).chosen();
4
4
  });
5
5
  jQuery(document).on('as:action_success', 'a.as_action', function(event, action_link) {
@@ -130,7 +130,8 @@ background-color: $column_header_bg;
130
130
  color: $column_header_link_color;
131
131
  }
132
132
 
133
- .active-scaffold th p {
133
+ .active-scaffold th p,
134
+ .active-scaffold .show-view th {
134
135
  color: $column_header_color;
135
136
  }
136
137
 
@@ -149,8 +149,12 @@ text-align: left;
149
149
  }
150
150
 
151
151
  .active-scaffold th a,
152
- .active-scaffold th p {
152
+ .active-scaffold th p,
153
+ .active-scaffold .show-view th {
153
154
  font: bold 11px arial, sans-serif;
155
+ }
156
+ .active-scaffold th a,
157
+ .active-scaffold th p {
154
158
  display: block;
155
159
  }
156
160
 
@@ -158,7 +162,8 @@ display: block;
158
162
  padding: 2px 2px 2px 5px;
159
163
  }
160
164
 
161
- .active-scaffold th p {
165
+ .active-scaffold th p,
166
+ .active-scaffold .show-view th {
162
167
  padding: 2px 5px;
163
168
  }
164
169
 
@@ -183,8 +188,11 @@ display: none;
183
188
  /* Table :: Record Rows
184
189
  ============================= */
185
190
 
186
- .active-scaffold tr.record td {
191
+ .active-scaffold tr.record td,
192
+ .active-scaffold .show-view td {
187
193
  padding: 5px 4px;
194
+ }
195
+ .active-scaffold tr.record td {
188
196
  font-family: Verdana, sans-serif;
189
197
  font-size: 11px;
190
198
  border: solid 1px;
@@ -555,6 +563,16 @@ margin-left: 5px;
555
563
  }
556
564
  .active-scaffold .show-view dl dl {
557
565
  margin-left: 0px;
566
+ margin-top: 5px;
567
+ }
568
+ .active-scaffold .show-view dl dl:first-child {
569
+ margin-top: 0;
570
+ }
571
+ .active-scaffold .show-view dl dl:after {
572
+ display: block;
573
+ content: "";
574
+ height: 1px;
575
+ clear: both;
558
576
  }
559
577
 
560
578
  .active-scaffold .show-view dt {
@@ -1,6 +1,6 @@
1
1
  <h4><%= active_scaffold_config.show.label(@record.to_label.nil? ? nil : h(@record.to_label)) %></h4>
2
2
 
3
- <%= render :partial => 'show_columns', :locals => {:columns => active_scaffold_config.show.columns} -%>
3
+ <%= render :partial => 'show_columns', :locals => {:columns => active_scaffold_config.show.columns, :record => @record} -%>
4
4
 
5
5
  <p class="form-footer">
6
6
  <%= link_to as_(:close), main_path_to_return, :class => 'as_cancel', :remote => request.xhr? %>
@@ -0,0 +1,2 @@
1
+ <% associated = column.singular_association? ? [parent_record.send(column.name)].compact : parent_record.send(column.name).to_a -%>
2
+ <%= render :partial => "show_association_#{show_partial}", :locals => {:column => column, :parent_record => parent_record, :associated => associated} if associated.present? %>
@@ -0,0 +1,17 @@
1
+ <%
2
+ columns_hash = {}
3
+ %>
4
+ <table>
5
+ <thead>
6
+ <tr>
7
+ <% show_columns_for(associated.first, column, columns_hash).each(:skip_groups => true) do |column| -%>
8
+ <th><%= show_label(column) %></th>
9
+ <% end -%>
10
+ </tr>
11
+ </thead>
12
+ <tbody>
13
+ <% associated.each do |record| -%>
14
+ <%= render :partial => 'show_horizontal_record', :locals => {:record => record, :parent_record => parent_record, :columns => show_columns_for(associated.first, column, columns_hash)} %>
15
+ <% end -%>
16
+ </tbody>
17
+ </table>
@@ -0,0 +1,4 @@
1
+ <% columns_hash = {} -%>
2
+ <% associated.each do |record| -%>
3
+ <%= render :partial => "show_columns", :locals => {:columns => show_columns_for(record, column, columns_hash), :record => record} %>
4
+ <% end -%>
@@ -1,14 +1,14 @@
1
1
  <dl>
2
- <% columns.each :for => @record do |column| %>
3
- <dt><%= column.label -%></dt>
2
+ <% columns.each :for => record do |column| %>
3
+ <dt><%= show_label(column) -%></dt>
4
4
  <% if column.respond_to? :each -%>
5
5
  <dd>
6
- <%= render :partial => 'show_columns', :locals => {:columns => column} %>
6
+ <%= render :partial => 'show_columns', :locals => {:columns => column, :record => record} %>
7
7
  <% else -%>
8
8
  <% css_class = "#{column.name}-view"
9
9
  css_class.concat(" #{column.css_class}") unless column.css_class.nil? %>
10
10
  <dd class="<%= css_class.strip %>">
11
- <%= show_column_value(@record, column) -%>
11
+ <%= show_column_value(record, column) -%>
12
12
  <% end -%>
13
13
  </dd>
14
14
  <% end -%>
@@ -0,0 +1,25 @@
1
+ <%
2
+ columns_length = 0
3
+ columns_groups = []
4
+ %>
5
+ <tr>
6
+ <% columns.each :for => record do |column| -%>
7
+ <%
8
+ if column.respond_to? :each
9
+ columns_groups << column
10
+ next
11
+ end
12
+ columns_length += 1
13
+ %>
14
+ <%= content_tag :td, content_tag(:span, show_column_value(record, column)), :class => "#{column.name}-column #{:numeric if column.number?}" %>
15
+ <% end -%>
16
+ </tr>
17
+ <% columns_groups.each do |columns| %>
18
+ <tr>
19
+ <td colspan="<%= columns_length %>">
20
+ <% columns.each do |column| %>
21
+ <%= show_column_value(record, column) %>
22
+ <% end %>
23
+ </td>
24
+ </tr>
25
+ <% end -%>
@@ -120,7 +120,12 @@ module ActiveScaffold::DataStructures
120
120
  end
121
121
 
122
122
  def list_ui
123
- @list_ui || @form_ui
123
+ @list_ui || form_ui
124
+ end
125
+
126
+ attr_writer :show_ui
127
+ def show_ui
128
+ @show_ui || list_ui
124
129
  end
125
130
 
126
131
  attr_writer :search_ui
@@ -10,7 +10,7 @@ module ActiveScaffold
10
10
  # performance of our default formatting. see issue #138.
11
11
  send(method, record, column)
12
12
  # second, check if the dev has specified a valid list_ui for this column
13
- elsif column.list_ui && (method = override_show_column_ui(column.list_ui))
13
+ elsif column.show_ui && (method = override_show_column_ui(column.show_ui))
14
14
  send(method, record, column)
15
15
  else
16
16
  if column.column && (method = override_show_column_ui(column.column.type))
@@ -25,13 +25,35 @@ module ActiveScaffold
25
25
  simple_format(clean_column_value(record.send(column.name)))
26
26
  end
27
27
 
28
+ def active_scaffold_show_horizontal(record, column)
29
+ raise ":horizontal show_ui must be used on association column" unless column.association
30
+ render :partial => 'show_association', :locals => {:column => column, :parent_record => record, :show_partial => :horizontal}
31
+ end
32
+
33
+ def active_scaffold_show_vertical(record, column)
34
+ raise ":vertical show_ui must be used on association column" unless column.association
35
+ render :partial => 'show_association', :locals => {:column => column, :parent_record => record, :show_partial => :vertical}
36
+ end
37
+
38
+ def show_columns_for(record, parent_column = nil, hash = {})
39
+ hash[record.class] ||= begin
40
+ columns = active_scaffold_config_for(record.class).show.columns
41
+ columns.constraint_columns = [parent_column.association.reverse] if parent_column
42
+ columns
43
+ end
44
+ end
45
+
46
+ def show_label(column)
47
+ column.label
48
+ end
49
+
28
50
  def show_column_override(column)
29
51
  override_helper column, 'show_column'
30
52
  end
31
53
 
32
54
  # the naming convention for overriding show types with helpers
33
- def override_show_column_ui(list_ui)
34
- method = "active_scaffold_show_#{list_ui}"
55
+ def override_show_column_ui(show_ui)
56
+ method = "active_scaffold_show_#{show_ui}"
35
57
  method if respond_to? method
36
58
  end
37
59
  end
@@ -2,7 +2,7 @@ module ActiveScaffold
2
2
  module Version
3
3
  MAJOR = 3
4
4
  MINOR = 4
5
- PATCH = 22
5
+ PATCH = 23
6
6
 
7
7
  STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_scaffold
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.22
4
+ version: 3.4.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - Many, see README
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-10 00:00:00.000000000 Z
11
+ date: 2015-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: brakeman
@@ -162,7 +162,11 @@ files:
162
162
  - app/views/active_scaffold_overrides/_row.html.erb
163
163
  - app/views/active_scaffold_overrides/_search.html.erb
164
164
  - app/views/active_scaffold_overrides/_show.html.erb
165
+ - app/views/active_scaffold_overrides/_show_association.html.erb
166
+ - app/views/active_scaffold_overrides/_show_association_horizontal.html.erb
167
+ - app/views/active_scaffold_overrides/_show_association_vertical.html.erb
165
168
  - app/views/active_scaffold_overrides/_show_columns.html.erb
169
+ - app/views/active_scaffold_overrides/_show_horizontal_record.html.erb
166
170
  - app/views/active_scaffold_overrides/_update_actions.html.erb
167
171
  - app/views/active_scaffold_overrides/_update_calculations.js.erb
168
172
  - app/views/active_scaffold_overrides/_update_column.js.erb