dima 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/dima/html/field.rb +35 -0
- data/lib/dima/version.rb +1 -1
- metadata +2 -2
data/lib/dima/html/field.rb
CHANGED
@@ -364,4 +364,39 @@ module Dima::Html
|
|
364
364
|
|
365
365
|
end
|
366
366
|
|
367
|
+
class SelectField < SimpleField
|
368
|
+
attr_accessor :collection
|
369
|
+
|
370
|
+
def simple_value_node
|
371
|
+
if self.edit?
|
372
|
+
id = self.val.id rescue nil
|
373
|
+
node = Node.new(tag: 'select', attributes: { name: "dim[#{name}]", class: 'dim-main-content dim-select' })
|
374
|
+
self.collection.each do |v|
|
375
|
+
node << Node.new(tag: 'option', attributes: { value: v.id, selected: (v.id == id) }, text: v.to_s)
|
376
|
+
end if self.collection
|
377
|
+
node
|
378
|
+
else
|
379
|
+
Node.new(tag: 'span', attributes: { class: 'dim-select' }, text: self.val.to_s)
|
380
|
+
end
|
381
|
+
end
|
382
|
+
|
383
|
+
def value_from_text(val)
|
384
|
+
self.collection.each do |v|
|
385
|
+
if val == v.id.to_s
|
386
|
+
self.val = v.id
|
387
|
+
break
|
388
|
+
end
|
389
|
+
end if self.collection
|
390
|
+
end
|
391
|
+
|
392
|
+
end
|
393
|
+
|
394
|
+
class IconField < SimpleField
|
395
|
+
|
396
|
+
def simple_value_node
|
397
|
+
Node.new(tag: 'img', attributes: { class: 'dim-main-content dim-icon', src: self.val })
|
398
|
+
end
|
399
|
+
|
400
|
+
end
|
401
|
+
|
367
402
|
end
|
data/lib/dima/version.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: dima
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.2
|
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-
|
13
|
+
date: 2013-03-18 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rspec
|