schofield 0.2.1 → 0.2.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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.1
1
+ 0.2.2
@@ -63,10 +63,21 @@ module Schofield
63
63
  end
64
64
 
65
65
  def to_column
66
+ "'#{actual_name.humanize}', lambda { |x| " +
66
67
  case
67
- when image? then "'#{actual_name.humanize} ', lambda { |x| image_tag(x.#{@attachment_name}.url(:thumbnail), :alt => '', :class => 'thumbnail') }"
68
+ when image? then "image_tag(x.#{@attachment_name}.url(:thumbnail), :alt => '', :class => 'thumbnail')"
68
69
  when attachment? then "link_to('#{actual_name.humanize}', x.#{@attachment_name}.url)"
69
- else "'#{actual_name.humanize}', lambda { |x| x.#{actual_name} }"
70
+ else "x.#{actual_name}"
71
+ end + ' }'
72
+ end
73
+
74
+ def weight
75
+ case
76
+ when image? then 1
77
+ when @name == 'name' then 2
78
+ when @name == 'title' then 3
79
+ when reference? then 4
80
+ else 5
70
81
  end
71
82
  end
72
83
 
@@ -64,8 +64,7 @@ module Schofield
64
64
  tables = []
65
65
  Levels.all.select(&:tables?).each do |level|
66
66
  columns_level = level.subclass? ? level.superclass : level
67
- columns = columns_level.attributes.select{ |a| columns_level.form_field?(a) }.map(&:to_column)
68
- columns.shift if level.join?
67
+ columns = columns_level.attributes.select{ |a| columns_level.form_field?(a) }.sort{ |a,b| a.weight <=> b.weight }.map(&:to_column)
69
68
  if level.nested?
70
69
  tables << <<-STRING.gsub(/^ {12}/, '')
71
70
  def #{level.name.pluralize}_table
data/schofield.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{schofield}
8
- s.version = "0.2.1"
8
+ s.version = "0.2.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Marc Tauber"]
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: schofield
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 1
10
- version: 0.2.1
9
+ - 2
10
+ version: 0.2.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Marc Tauber