x-editable-rails 1.5.5 → 1.5.5.1

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: c489cb060a3a51dabf4062a91ce61ad348d0e1d4
4
- data.tar.gz: 58ebbc7b384c1691d0f868f93216609de5673963
3
+ metadata.gz: fee9739c77324495b6e7a6227d85fdb2f77c972b
4
+ data.tar.gz: fd6565d1908e346778674f1f42f95f235c335f01
5
5
  SHA512:
6
- metadata.gz: 7f630f0adc0740b0407c05f9086476034a072b6c6e547db23998245aaf2d2f59a4aee870c893ca101790417c47942105d9c3a390d3ad744fcbb74f5c0d4b91b3
7
- data.tar.gz: e06c81114244fd61c601ec095278eaa049b46bc6b4c3d074d7f540d7ebabe93c6c11b40f5b1a3e20098f2840b2ea6fc20845937bf10d824e6e05cb1009d2261a
6
+ metadata.gz: 5d3c95a332e7da5252af57f86fb0ae39d171566d7f616b09f9d691073fbd1051e64b53e35ff9f13dbd124f57b55901e2a2cbc3295451749f1a2997627b55ff05
7
+ data.tar.gz: d43ebe0f3957a31e1c8c6476494f869f37bd456af8878d4993363130de8b41795df1dd9012ed1948e32c1ba74fdad34af06085062a03a4e46368d0b703a6740a
data/README.md CHANGED
@@ -4,6 +4,10 @@
4
4
 
5
5
  X-editable for Rails
6
6
 
7
+ ## Live demo
8
+
9
+ Checkout live demo [here](https://x-editable-rails.herokuapp.com/?denied=true)
10
+
7
11
  ## Installation
8
12
 
9
13
  Add this line to your application's Gemfile:
@@ -77,8 +81,8 @@ And related stylesheets:
77
81
 
78
82
  ### Making Things Editable
79
83
 
80
- `x-editable-rails` provides a helper method in your view to make your model values editable.
81
- By default, you need to specify the model and property that should be editable.
84
+ `x-editable-rails` provides a helper method in your view to make your model values editable.
85
+ By default, you need to specify the model and property that should be editable.
82
86
  A `span` element is rendered with `data-*` attributes used by `x-editable`.
83
87
 
84
88
  ```ruby
@@ -154,14 +158,14 @@ end
154
158
 
155
159
  ### "Don't Repeat Yourself" Templates
156
160
 
157
- To make your views cleaner, you can specify all your options for each class and attribute in a YAML configuration file.
161
+ To make your views cleaner, you can specify all your options for each class and attribute in a YAML configuration file.
158
162
  Attributes where the `title` or `placeholder` are not different except maybe capitalized can be left out because they are automatically capitalized when rendered (see above).
159
163
 
160
- This example uses the `MailingList` class and its attributes.
161
- The attribute value can be a string, which is used as the `title` and `placeholder`.
164
+ This example uses the `MailingList` class and its attributes.
165
+ The attribute value can be a string, which is used as the `title` and `placeholder`.
162
166
  If you want to specify other options, create a hash of options.
163
167
 
164
- Install configuration file like this: `rails g x_editable_rails:install`, this step is not necessary
168
+ Install configuration file like this: `rails g x_editable_rails:install`, this step is not necessary
165
169
 
166
170
  ```yaml
167
171
  class_options:
@@ -1,7 +1,7 @@
1
1
  module X
2
2
  module Editable
3
3
  module Rails
4
- VERSION = "1.5.5"
4
+ VERSION = "1.5.5.1"
5
5
  end
6
6
  end
7
7
  end
@@ -33,11 +33,11 @@ module X
33
33
  html_options = options.delete(:html){ Hash.new }
34
34
 
35
35
  if xeditable?(object)
36
- model = object.class.model_name.element
36
+ model = object.class.model_name.param_key
37
37
  nid = options.delete(:nid)
38
38
  nested = options.delete(:nested)
39
39
  title = options.delete(:title) do
40
- klass = nested ? object.class.const_get(nested.to_s.singularize.capitalize) : object.class
40
+ klass = nested ? object.class.const_get(nested.to_s.classify) : object.class
41
41
  klass.human_attribute_name(method)
42
42
  end
43
43
 
@@ -72,7 +72,13 @@ module X
72
72
  })
73
73
 
74
74
  content_tag tag, html_options do
75
- safe_join(source_values_for(value, source), tag(:br)) unless %w(select checklist).include? data[:type]
75
+ if %w(select checklist).include?(data[:type].to_s) && !source.is_a?(String)
76
+ source = normalize_source(source)
77
+ content = source.detect { |t| output_value == output_value_for(t[0]) }
78
+ content.present? ? content[1] : ""
79
+ else
80
+ safe_join(source_values_for(value, source), tag(:br))
81
+ end
76
82
  end
77
83
  else
78
84
  error || safe_join(source_values_for(value, source), tag(:br))
@@ -81,6 +87,17 @@ module X
81
87
 
82
88
  private
83
89
 
90
+ def normalize_source(source)
91
+ return [] unless source
92
+ source.map do |el|
93
+ if el.is_a? Array
94
+ el
95
+ else
96
+ [el[:value], el[:text]]
97
+ end
98
+ end
99
+ end
100
+
84
101
  def output_value_for(value)
85
102
  value = case value
86
103
  when TrueClass
@@ -135,11 +152,9 @@ module X
135
152
  if source.is_a?(Array) && source.first.is_a?(String) && source.size == 2
136
153
  { '1' => source[0], '0' => source[1] }
137
154
  end
138
- when String
155
+ else
139
156
  if source.is_a?(Array) && source.first.is_a?(String)
140
- source.inject({}){|hash, key| hash.merge(key => key)}
141
- elsif source.is_a?(Hash)
142
- source
157
+ source.map { |v| { value: v, text: v } }
143
158
  end
144
159
  end
145
160
 
@@ -306,12 +306,12 @@ a.editable-click.editable-disabled:hover {
306
306
  .datepicker table tr td.today.disabled,
307
307
  .datepicker table tr td.today.disabled:hover {
308
308
  background-color: #fde19a;
309
- background-image: -moz-linear-gradient(top, #fdd49a, #fdf59a);
310
- background-image: -ms-linear-gradient(top, #fdd49a, #fdf59a);
309
+ background-image: -moz-linear-gradient(to bottom, #fdd49a, #fdf59a);
310
+ background-image: -ms-linear-gradient(to bottom, #fdd49a, #fdf59a);
311
311
  background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#fdd49a), to(#fdf59a));
312
- background-image: -webkit-linear-gradient(top, #fdd49a, #fdf59a);
313
- background-image: -o-linear-gradient(top, #fdd49a, #fdf59a);
314
- background-image: linear-gradient(top, #fdd49a, #fdf59a);
312
+ background-image: -webkit-linear-gradient(to bottom, #fdd49a, #fdf59a);
313
+ background-image: -o-linear-gradient(to bottom, #fdd49a, #fdf59a);
314
+ background-image: linear-gradient(to bottom, #fdd49a, #fdf59a);
315
315
  background-repeat: repeat-x;
316
316
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fdd49a', endColorstr='#fdf59a', GradientType=0);
317
317
  border-color: #fdf59a #fdf59a #fbed50;
@@ -371,12 +371,12 @@ a.editable-click.editable-disabled:hover {
371
371
  .datepicker table tr td.range.today.disabled,
372
372
  .datepicker table tr td.range.today.disabled:hover {
373
373
  background-color: #f3d17a;
374
- background-image: -moz-linear-gradient(top, #f3c17a, #f3e97a);
375
- background-image: -ms-linear-gradient(top, #f3c17a, #f3e97a);
374
+ background-image: -moz-linear-gradient(to bottom, #f3c17a, #f3e97a);
375
+ background-image: -ms-linear-gradient(to bottom, #f3c17a, #f3e97a);
376
376
  background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#f3c17a), to(#f3e97a));
377
- background-image: -webkit-linear-gradient(top, #f3c17a, #f3e97a);
378
- background-image: -o-linear-gradient(top, #f3c17a, #f3e97a);
379
- background-image: linear-gradient(top, #f3c17a, #f3e97a);
377
+ background-image: -webkit-linear-gradient(to bottom, #f3c17a, #f3e97a);
378
+ background-image: -o-linear-gradient(to bottom, #f3c17a, #f3e97a);
379
+ background-image: linear-gradient(to bottom, #f3c17a, #f3e97a);
380
380
  background-repeat: repeat-x;
381
381
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#f3c17a', endColorstr='#f3e97a', GradientType=0);
382
382
  border-color: #f3e97a #f3e97a #edde34;
@@ -423,12 +423,12 @@ a.editable-click.editable-disabled:hover {
423
423
  .datepicker table tr td.selected.disabled,
424
424
  .datepicker table tr td.selected.disabled:hover {
425
425
  background-color: #9e9e9e;
426
- background-image: -moz-linear-gradient(top, #b3b3b3, #808080);
427
- background-image: -ms-linear-gradient(top, #b3b3b3, #808080);
426
+ background-image: -moz-linear-gradient(to bottom, #b3b3b3, #808080);
427
+ background-image: -ms-linear-gradient(to bottom, #b3b3b3, #808080);
428
428
  background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#b3b3b3), to(#808080));
429
- background-image: -webkit-linear-gradient(top, #b3b3b3, #808080);
430
- background-image: -o-linear-gradient(top, #b3b3b3, #808080);
431
- background-image: linear-gradient(top, #b3b3b3, #808080);
429
+ background-image: -webkit-linear-gradient(to bottom, #b3b3b3, #808080);
430
+ background-image: -o-linear-gradient(to bottom, #b3b3b3, #808080);
431
+ background-image: linear-gradient(to bottom, #b3b3b3, #808080);
432
432
  background-repeat: repeat-x;
433
433
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#b3b3b3', endColorstr='#808080', GradientType=0);
434
434
  border-color: #808080 #808080 #595959;
@@ -474,12 +474,12 @@ a.editable-click.editable-disabled:hover {
474
474
  .datepicker table tr td.active.disabled,
475
475
  .datepicker table tr td.active.disabled:hover {
476
476
  background-color: #006dcc;
477
- background-image: -moz-linear-gradient(top, #0088cc, #0044cc);
478
- background-image: -ms-linear-gradient(top, #0088cc, #0044cc);
477
+ background-image: -moz-linear-gradient(to bottom, #0088cc, #0044cc);
478
+ background-image: -ms-linear-gradient(to bottom, #0088cc, #0044cc);
479
479
  background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#0088cc), to(#0044cc));
480
- background-image: -webkit-linear-gradient(top, #0088cc, #0044cc);
481
- background-image: -o-linear-gradient(top, #0088cc, #0044cc);
482
- background-image: linear-gradient(top, #0088cc, #0044cc);
480
+ background-image: -webkit-linear-gradient(to bottom, #0088cc, #0044cc);
481
+ background-image: -o-linear-gradient(to bottom, #0088cc, #0044cc);
482
+ background-image: linear-gradient(to bottom, #0088cc, #0044cc);
483
483
  background-repeat: repeat-x;
484
484
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#0088cc', endColorstr='#0044cc', GradientType=0);
485
485
  border-color: #0044cc #0044cc #002a80;
@@ -546,12 +546,12 @@ a.editable-click.editable-disabled:hover {
546
546
  .datepicker table tr td span.active.disabled,
547
547
  .datepicker table tr td span.active.disabled:hover {
548
548
  background-color: #006dcc;
549
- background-image: -moz-linear-gradient(top, #0088cc, #0044cc);
550
- background-image: -ms-linear-gradient(top, #0088cc, #0044cc);
549
+ background-image: -moz-linear-gradient(to bottom, #0088cc, #0044cc);
550
+ background-image: -ms-linear-gradient(to bottom, #0088cc, #0044cc);
551
551
  background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#0088cc), to(#0044cc));
552
- background-image: -webkit-linear-gradient(top, #0088cc, #0044cc);
553
- background-image: -o-linear-gradient(top, #0088cc, #0044cc);
554
- background-image: linear-gradient(top, #0088cc, #0044cc);
552
+ background-image: -webkit-linear-gradient(to bottom, #0088cc, #0044cc);
553
+ background-image: -o-linear-gradient(to bottom, #0088cc, #0044cc);
554
+ background-image: linear-gradient(to bottom, #0088cc, #0044cc);
555
555
  background-repeat: repeat-x;
556
556
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#0088cc', endColorstr='#0044cc', GradientType=0);
557
557
  border-color: #0044cc #0044cc #002a80;
@@ -306,12 +306,12 @@ a.editable-click.editable-disabled:hover {
306
306
  .datepicker table tr td.today.disabled,
307
307
  .datepicker table tr td.today.disabled:hover {
308
308
  background-color: #fde19a;
309
- background-image: -moz-linear-gradient(top, #fdd49a, #fdf59a);
310
- background-image: -ms-linear-gradient(top, #fdd49a, #fdf59a);
309
+ background-image: -moz-linear-gradient(to bottom, #fdd49a, #fdf59a);
310
+ background-image: -ms-linear-gradient(to bottom, #fdd49a, #fdf59a);
311
311
  background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#fdd49a), to(#fdf59a));
312
- background-image: -webkit-linear-gradient(top, #fdd49a, #fdf59a);
313
- background-image: -o-linear-gradient(top, #fdd49a, #fdf59a);
314
- background-image: linear-gradient(top, #fdd49a, #fdf59a);
312
+ background-image: -webkit-linear-gradient(to bottom, #fdd49a, #fdf59a);
313
+ background-image: -o-linear-gradient(to bottom, #fdd49a, #fdf59a);
314
+ background-image: linear-gradient(to bottom, #fdd49a, #fdf59a);
315
315
  background-repeat: repeat-x;
316
316
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fdd49a', endColorstr='#fdf59a', GradientType=0);
317
317
  border-color: #fdf59a #fdf59a #fbed50;
@@ -371,12 +371,12 @@ a.editable-click.editable-disabled:hover {
371
371
  .datepicker table tr td.range.today.disabled,
372
372
  .datepicker table tr td.range.today.disabled:hover {
373
373
  background-color: #f3d17a;
374
- background-image: -moz-linear-gradient(top, #f3c17a, #f3e97a);
375
- background-image: -ms-linear-gradient(top, #f3c17a, #f3e97a);
374
+ background-image: -moz-linear-gradient(to bottom, #f3c17a, #f3e97a);
375
+ background-image: -ms-linear-gradient(to bottom, #f3c17a, #f3e97a);
376
376
  background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#f3c17a), to(#f3e97a));
377
- background-image: -webkit-linear-gradient(top, #f3c17a, #f3e97a);
378
- background-image: -o-linear-gradient(top, #f3c17a, #f3e97a);
379
- background-image: linear-gradient(top, #f3c17a, #f3e97a);
377
+ background-image: -webkit-linear-gradient(to bottom, #f3c17a, #f3e97a);
378
+ background-image: -o-linear-gradient(to bottom, #f3c17a, #f3e97a);
379
+ background-image: linear-gradient(to bottom, #f3c17a, #f3e97a);
380
380
  background-repeat: repeat-x;
381
381
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#f3c17a', endColorstr='#f3e97a', GradientType=0);
382
382
  border-color: #f3e97a #f3e97a #edde34;
@@ -423,12 +423,12 @@ a.editable-click.editable-disabled:hover {
423
423
  .datepicker table tr td.selected.disabled,
424
424
  .datepicker table tr td.selected.disabled:hover {
425
425
  background-color: #9e9e9e;
426
- background-image: -moz-linear-gradient(top, #b3b3b3, #808080);
427
- background-image: -ms-linear-gradient(top, #b3b3b3, #808080);
426
+ background-image: -moz-linear-gradient(to bottom, #b3b3b3, #808080);
427
+ background-image: -ms-linear-gradient(to bottom, #b3b3b3, #808080);
428
428
  background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#b3b3b3), to(#808080));
429
- background-image: -webkit-linear-gradient(top, #b3b3b3, #808080);
430
- background-image: -o-linear-gradient(top, #b3b3b3, #808080);
431
- background-image: linear-gradient(top, #b3b3b3, #808080);
429
+ background-image: -webkit-linear-gradient(to bottom, #b3b3b3, #808080);
430
+ background-image: -o-linear-gradient(to bottom, #b3b3b3, #808080);
431
+ background-image: linear-gradient(to bottom, #b3b3b3, #808080);
432
432
  background-repeat: repeat-x;
433
433
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#b3b3b3', endColorstr='#808080', GradientType=0);
434
434
  border-color: #808080 #808080 #595959;
@@ -474,12 +474,12 @@ a.editable-click.editable-disabled:hover {
474
474
  .datepicker table tr td.active.disabled,
475
475
  .datepicker table tr td.active.disabled:hover {
476
476
  background-color: #006dcc;
477
- background-image: -moz-linear-gradient(top, #0088cc, #0044cc);
478
- background-image: -ms-linear-gradient(top, #0088cc, #0044cc);
477
+ background-image: -moz-linear-gradient(to bottom, #0088cc, #0044cc);
478
+ background-image: -ms-linear-gradient(to bottom, #0088cc, #0044cc);
479
479
  background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#0088cc), to(#0044cc));
480
- background-image: -webkit-linear-gradient(top, #0088cc, #0044cc);
481
- background-image: -o-linear-gradient(top, #0088cc, #0044cc);
482
- background-image: linear-gradient(top, #0088cc, #0044cc);
480
+ background-image: -webkit-linear-gradient(to bottom, #0088cc, #0044cc);
481
+ background-image: -o-linear-gradient(to bottom, #0088cc, #0044cc);
482
+ background-image: linear-gradient(to bottom, #0088cc, #0044cc);
483
483
  background-repeat: repeat-x;
484
484
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#0088cc', endColorstr='#0044cc', GradientType=0);
485
485
  border-color: #0044cc #0044cc #002a80;
@@ -546,12 +546,12 @@ a.editable-click.editable-disabled:hover {
546
546
  .datepicker table tr td span.active.disabled,
547
547
  .datepicker table tr td span.active.disabled:hover {
548
548
  background-color: #006dcc;
549
- background-image: -moz-linear-gradient(top, #0088cc, #0044cc);
550
- background-image: -ms-linear-gradient(top, #0088cc, #0044cc);
549
+ background-image: -moz-linear-gradient(to bottom, #0088cc, #0044cc);
550
+ background-image: -ms-linear-gradient(to bottom, #0088cc, #0044cc);
551
551
  background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#0088cc), to(#0044cc));
552
- background-image: -webkit-linear-gradient(top, #0088cc, #0044cc);
553
- background-image: -o-linear-gradient(top, #0088cc, #0044cc);
554
- background-image: linear-gradient(top, #0088cc, #0044cc);
552
+ background-image: -webkit-linear-gradient(to bottom, #0088cc, #0044cc);
553
+ background-image: -o-linear-gradient(to bottom, #0088cc, #0044cc);
554
+ background-image: linear-gradient(to bottom, #0088cc, #0044cc);
555
555
  background-repeat: repeat-x;
556
556
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#0088cc', endColorstr='#0044cc', GradientType=0);
557
557
  border-color: #0044cc #0044cc #002a80;
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: x-editable-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.5
4
+ version: 1.5.5.1
5
5
  platform: ruby
6
6
  authors:
7
- - Jiri Kolarik
7
+ - We're in
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-16 00:00:00.000000000 Z
11
+ date: 2017-12-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: '0'
55
55
  description: X-editable for Rails
56
56
  email:
57
- - jiri.kolarik@imin.cz
57
+ - info@wereinhq.com
58
58
  executables: []
59
59
  extensions: []
60
60
  extra_rdoc_files: []
@@ -112,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
112
112
  version: '0'
113
113
  requirements: []
114
114
  rubyforge_project:
115
- rubygems_version: 2.4.8
115
+ rubygems_version: 2.5.1
116
116
  signing_key:
117
117
  specification_version: 4
118
118
  summary: X-editable for Rails