adminable 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/app/controllers/adminable/resources_controller.rb +1 -1
- data/app/views/adminable/resources/form/_has_one.html.haml +3 -0
- data/app/views/adminable/resources/index/_has_one.html.haml +2 -0
- data/config/locales/adminable.en.yml +1 -0
- data/config/locales/adminable.ru.yml +1 -0
- data/lib/adminable.rb +3 -1
- data/lib/adminable/{presenters → decorators}/fields.rb +1 -1
- data/lib/adminable/field_collector.rb +0 -2
- data/lib/adminable/fields/has_one.rb +6 -0
- data/lib/adminable/presenters/entry.rb +19 -1
- data/lib/adminable/version.rb +1 -1
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe14efbd7a9b891b5bc5589e45c36348e669dbde
|
4
|
+
data.tar.gz: f7e2f55e7616fc473e3bdec17a4c7fe99ed87631
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 15ac25cf770b37f9d7b5a59213328722766d4d90c62e43eb26e150805b795dda42ee9335478f6a73365113fcef04cf1a942bf4ead32ad323beb7222194ae472f
|
7
|
+
data.tar.gz: fd6965f302510e697657e792d6f1c83fab0058cfe3b58e5acd1ab49676bd096b6e327de10fdd54ccf40acf252d231792e3153e1e028867cd2b62bc5c9cbc52c5
|
data/README.md
CHANGED
@@ -75,6 +75,7 @@ Change fields as you like inside `fields` method array:
|
|
75
75
|
class Adminable::Blog::PostsController < Adminable::ResourcesController
|
76
76
|
def fields
|
77
77
|
[
|
78
|
+
Adminable::Fields::Integer.new(:id, form: false),
|
78
79
|
Adminable::Fields::String.new(:title),
|
79
80
|
Adminable::Fields::Text.new(:body),
|
80
81
|
Adminable::Fields::Float.new(:rating, form: false),
|
@@ -105,6 +106,7 @@ Adds `text-align: center` for field value on index page.
|
|
105
106
|
|
106
107
|
#### search
|
107
108
|
`true` or `false`, default: `false`.
|
109
|
+
|
108
110
|
Enables search for this field.
|
109
111
|
|
110
112
|
### See Also
|
data/lib/adminable.rb
CHANGED
@@ -7,7 +7,8 @@ require 'adminable/resource'
|
|
7
7
|
require 'adminable/presenters/base'
|
8
8
|
require 'adminable/presenters/entry'
|
9
9
|
require 'adminable/presenters/entries'
|
10
|
-
|
10
|
+
|
11
|
+
require 'adminable/decorators/fields'
|
11
12
|
|
12
13
|
require 'adminable/field_collector'
|
13
14
|
|
@@ -19,6 +20,7 @@ require 'adminable/fields/datetime'
|
|
19
20
|
require 'adminable/fields/decimal'
|
20
21
|
require 'adminable/fields/float'
|
21
22
|
require 'adminable/fields/has_many'
|
23
|
+
require 'adminable/fields/has_one'
|
22
24
|
require 'adminable/fields/integer'
|
23
25
|
require 'adminable/fields/string'
|
24
26
|
require 'adminable/fields/text'
|
@@ -1,8 +1,10 @@
|
|
1
1
|
module Adminable
|
2
2
|
module Presenters
|
3
3
|
class Entry < Base
|
4
|
-
def initialize(entry)
|
4
|
+
def initialize(entry, field: nil)
|
5
5
|
@entry = entry
|
6
|
+
@field = field
|
7
|
+
@value = entry.public_send(field.name) if field
|
6
8
|
end
|
7
9
|
|
8
10
|
def to_name
|
@@ -57,6 +59,22 @@ module Adminable
|
|
57
59
|
)
|
58
60
|
end
|
59
61
|
|
62
|
+
def has_one_value
|
63
|
+
association = @entry.association(@field.name).klass
|
64
|
+
|
65
|
+
if @value
|
66
|
+
Adminable::Presenters::Entry(@value).link_to_self
|
67
|
+
else
|
68
|
+
view.link_to(
|
69
|
+
I18n.t(
|
70
|
+
'adminable.ui.no_has_one',
|
71
|
+
resource: association.model_name.human
|
72
|
+
),
|
73
|
+
polymorphic_path(association),
|
74
|
+
)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
60
78
|
def method_missing(method_name, *args, &block)
|
61
79
|
entry.public_send(method_name, *args, &block)
|
62
80
|
end
|
data/lib/adminable/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: adminable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergey Novikov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -343,6 +343,7 @@ files:
|
|
343
343
|
- app/views/adminable/resources/form/_decimal.html.haml
|
344
344
|
- app/views/adminable/resources/form/_float.html.haml
|
345
345
|
- app/views/adminable/resources/form/_has_many.html.haml
|
346
|
+
- app/views/adminable/resources/form/_has_one.html.haml
|
346
347
|
- app/views/adminable/resources/form/_integer.html.haml
|
347
348
|
- app/views/adminable/resources/form/_string.html.haml
|
348
349
|
- app/views/adminable/resources/form/_text.html.haml
|
@@ -356,6 +357,7 @@ files:
|
|
356
357
|
- app/views/adminable/resources/index/_decimal.html.haml
|
357
358
|
- app/views/adminable/resources/index/_float.html.haml
|
358
359
|
- app/views/adminable/resources/index/_has_many.html.haml
|
360
|
+
- app/views/adminable/resources/index/_has_one.html.haml
|
359
361
|
- app/views/adminable/resources/index/_integer.html.haml
|
360
362
|
- app/views/adminable/resources/index/_string.html.haml
|
361
363
|
- app/views/adminable/resources/index/_text.html.haml
|
@@ -371,6 +373,7 @@ files:
|
|
371
373
|
- config/routes.rb
|
372
374
|
- lib/adminable.rb
|
373
375
|
- lib/adminable/configuration.rb
|
376
|
+
- lib/adminable/decorators/fields.rb
|
374
377
|
- lib/adminable/engine.rb
|
375
378
|
- lib/adminable/errors.rb
|
376
379
|
- lib/adminable/field_collector.rb
|
@@ -382,6 +385,7 @@ files:
|
|
382
385
|
- lib/adminable/fields/decimal.rb
|
383
386
|
- lib/adminable/fields/float.rb
|
384
387
|
- lib/adminable/fields/has_many.rb
|
388
|
+
- lib/adminable/fields/has_one.rb
|
385
389
|
- lib/adminable/fields/integer.rb
|
386
390
|
- lib/adminable/fields/string.rb
|
387
391
|
- lib/adminable/fields/text.rb
|
@@ -390,7 +394,6 @@ files:
|
|
390
394
|
- lib/adminable/presenters/base.rb
|
391
395
|
- lib/adminable/presenters/entries.rb
|
392
396
|
- lib/adminable/presenters/entry.rb
|
393
|
-
- lib/adminable/presenters/fields.rb
|
394
397
|
- lib/adminable/resource.rb
|
395
398
|
- lib/adminable/version.rb
|
396
399
|
- lib/generators/adminable/install/templates/application_controller.rb
|