express_admin 1.7.25 → 1.7.26

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ead2f7234d30986e7ae5191a3b2ab0e52255f4e1
4
- data.tar.gz: 12034e77823a4c1f6c5235366b1cca85397320e1
3
+ metadata.gz: 997e0b7b334817dc76efd76805c325b81c93f5e2
4
+ data.tar.gz: ed78a8471ebbad6147f00c27dfaa535aa23ca577
5
5
  SHA512:
6
- metadata.gz: 41eeca514e5102d7d5fd3df73296e49142c1b5eee4c450cd466408ed77d37528ba6f6e755c9ec726d2ed696cfd71dc8bf52424fe14d34eb9d758ed5ed8b31e3f
7
- data.tar.gz: 162968e3617a7c3db30d5e626887e8e6e3dba6672098aa2f7f2edd5651dcddb198a2c68b84474e67f59130f97953241b7daf2840cbab0e75a984a07d7cfeb566
6
+ metadata.gz: 62c247411891b79fc02576251dac34a8824e14e2c096ee183d16253fde0eb8198a596cb860b1cd2b3cc231a2b39a26262e955803960ac03ae0df59bc7cbe05d0
7
+ data.tar.gz: 58363ee6be8f1035361032868b8dab0134fb50a705ec5966d7cbc29a98c0326020cf264979e28da5f75275d1646e96aed4bf99a3d3f61be11f6078bcf83bb084
@@ -4,6 +4,10 @@ module ExpressAdmin
4
4
  class DefinitionList < ExpressTemplates::Components::Configurable
5
5
  include ExpressTemplates::Components::Capabilities::Resourceful
6
6
 
7
+ COLUMN_REGEX_LIST = {
8
+ in_words: /(\w+)_in_words/
9
+ }
10
+
7
11
  tag :dl
8
12
 
9
13
  list_types = {}
@@ -31,13 +35,24 @@ module ExpressAdmin
31
35
 
32
36
  def definitions_from_hash(hash)
33
37
  processed = hash.map do |k,v|
34
- value = if v.kind_of? Symbol
35
- resource.send(v)
36
- elsif v.respond_to?(:call)
37
- v.call(resource).html_safe
38
- else
39
- v
40
- end
38
+ value =
39
+ if attrib = v.to_s.match(COLUMN_REGEX_LIST[:in_words]).try(:[], 1)
40
+ if resource.send(attrib)
41
+ if resource.send(attrib) < DateTime.now
42
+ "#{helpers.time_ago_in_words(resource.send(attrib))} ago"
43
+ else
44
+ "in #{helpers.time_ago_in_words(resource.send(attrib))}"
45
+ end
46
+ else
47
+ 'never'
48
+ end
49
+ elsif v.kind_of? Symbol
50
+ resource.send(v)
51
+ elsif v.respond_to?(:call)
52
+ v.call(resource).to_s.html_safe
53
+ else
54
+ v
55
+ end
41
56
  [promptify(k), value]
42
57
  end
43
58
  Hash[processed]
@@ -59,4 +74,4 @@ module ExpressAdmin
59
74
  end
60
75
  end
61
76
  end
62
- end
77
+ end
@@ -16,7 +16,6 @@ module ExpressAdmin
16
16
  end
17
17
  }
18
18
  }
19
-
20
19
  end
21
20
  end
22
21
  end
@@ -1,3 +1,3 @@
1
1
  module ExpressAdmin
2
- VERSION = "1.7.25"
2
+ VERSION = "1.7.26"
3
3
  end
Binary file
@@ -17,7 +17,8 @@ module ExpressAdmin
17
17
  array: ["field1", "field2"],
18
18
  hash: {term1: "def1",
19
19
  term2: "def2",
20
- term3: "def3"})
20
+ term3: "def3"},
21
+ hash_with_in_words: { "Created At:" => :created_at_in_words })
21
22
  end
22
23
 
23
24
  def deflist(*args)
@@ -26,6 +27,12 @@ module ExpressAdmin
26
27
  }.to_s
27
28
  end
28
29
 
30
+ def deflist_with_resource(*args)
31
+ arbre(widget: Widget.first) {
32
+ definition_list(:widget, *args)
33
+ }.to_s
34
+ end
35
+
29
36
  test "accepts array as input" do
30
37
  assert deflist(list_types[:array])
31
38
  end
@@ -66,6 +73,9 @@ HTML
66
73
  assert_equal DEFLIST_MARKUP_ARR, deflist(list_types[:array])
67
74
  end
68
75
 
69
- end
76
+ test "definition_list renders attribute in words" do
77
+ assert_match "<dt>Created At:</dt>\n <dd>less than a minute ago</dd>", deflist_with_resource(list_types[:hash_with_in_words])
78
+ end
70
79
 
80
+ end
71
81
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: express_admin
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.25
4
+ version: 1.7.26
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steven Talcott Smith
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-11 00:00:00.000000000 Z
11
+ date: 2015-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: express_templates