dima 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -159,6 +159,14 @@
159
159
  border-top: 2px solid #2fa000;
160
160
  background: #eee;
161
161
  }
162
+ .dim-form .dim-array-item,
163
+ .dim-table .dim-array-item {
164
+ margin-bottom: 4px;
165
+ }
166
+ .dim-form .dim-array-item:last-child,
167
+ .dim-table .dim-array-item:last-child {
168
+ margin-bottom: 0;
169
+ }
162
170
  .dim-form table,
163
171
  .dim-table table {
164
172
  width: 100%;
@@ -149,6 +149,7 @@ module Dima::Html
149
149
  attr_accessor :width, :height
150
150
  attr_accessor :readonly
151
151
  attr_accessor :model
152
+ attr_accessor :klass
152
153
 
153
154
  # Initialize this field from a model.
154
155
  #
@@ -159,9 +160,9 @@ module Dima::Html
159
160
  else
160
161
  self.model = v
161
162
  if self.lambda
162
- self.val = self.lambda.call(v)
163
+ self.val = self.lambda.call(v) rescue nil
163
164
  elsif self.name
164
- self.val = Dima::Utils.get(v, self.name)
165
+ self.val = Dima::Utils.get(v, self.name) rescue nil
165
166
  end
166
167
  end
167
168
  end
@@ -171,7 +172,9 @@ module Dima::Html
171
172
  end
172
173
 
173
174
  def main_content_node
174
- simple_value_node
175
+ n = simple_value_node
176
+ n.add_class(self.klass) if self.klass
177
+ n
175
178
  end
176
179
 
177
180
  def empty?
@@ -399,4 +402,20 @@ module Dima::Html
399
402
 
400
403
  end
401
404
 
405
+ class ArrayField < SimpleField
406
+ attr_accessor :field
407
+
408
+ def simple_value_node
409
+ ary = Node.new(tag: 'div', attributes: { class: 'dim-main-content dim-array' })
410
+ self.val.each do |v|
411
+ self.field << v
412
+ item = Node.new(tag: 'div', attributes: { class: 'dim-array-item' })
413
+ item << self.field.main_content_node
414
+ ary << item
415
+ end
416
+ ary
417
+ end
418
+
419
+ end
420
+
402
421
  end
data/lib/dima/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module Dima
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
@@ -18,6 +18,7 @@
18
18
  .dim-form .dim-required .dim-label,.dim-table .dim-required .dim-label{border-left:3px solid #c00;}
19
19
  .dim-form .dim-complex .dim-main-content,.dim-table .dim-complex .dim-main-content{margin-right:8px !important;}
20
20
  .dim-form .dim-form-buttom-actions,.dim-table .dim-form-buttom-actions{clear:both;padding:8px;margin-top:8px;border-top:2px solid #2fa000;background:#eee;}
21
+ .dim-form .dim-array-item,.dim-table .dim-array-item{margin-bottom:4px;}.dim-form .dim-array-item:last-child,.dim-table .dim-array-item:last-child{margin-bottom:0;}
21
22
  .dim-form table,.dim-table table{width:100%;border-collapse:collapse;}.dim-form table thead,.dim-table table thead{background:#e0ffd3;}.dim-form table thead th,.dim-table table thead th{padding:6px;font-size:13px;text-align:left;border-top:1px solid #2fa000;border-bottom:1px solid #2fa000;}
22
23
  .dim-form table tbody tr,.dim-table table tbody tr{border-bottom:1px solid #2fa000;}
23
24
  .dim-form table .dim-empty,.dim-table table .dim-empty{color:#aaaaaa;text-align:center;padding:8px;}
@@ -159,6 +159,14 @@
159
159
  border-top: 2px solid #2fa000;
160
160
  background: #eee;
161
161
  }
162
+ .dim-form .dim-array-item,
163
+ .dim-table .dim-array-item {
164
+ margin-bottom: 4px;
165
+ }
166
+ .dim-form .dim-array-item:last-child,
167
+ .dim-table .dim-array-item:last-child {
168
+ margin-bottom: 0;
169
+ }
162
170
  .dim-form table,
163
171
  .dim-table table {
164
172
  width: 100%;
@@ -150,6 +150,12 @@
150
150
  border-top: 2px solid @border;
151
151
  background: #eee;
152
152
  }
153
+ .dim-array-item {
154
+ margin-bottom: 4px;
155
+ &:last-child {
156
+ margin-bottom: 0;
157
+ }
158
+ }
153
159
  table {
154
160
  width: 100%;
155
161
  border-collapse: collapse;
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: dima
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.2
5
+ version: 0.0.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - Dimitri Kurashvili
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2013-03-18 00:00:00 Z
13
+ date: 2013-03-20 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rspec