rails_admin_extended_fields 0.1.2 → 0.1.4

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: ad603b539fdc7c10228f295d2569719c278c7957
4
- data.tar.gz: 789311fcb9586347d1c20704ed004592d528f235
3
+ metadata.gz: e28f2a3bde9798f57820594063077fc03c5ba85a
4
+ data.tar.gz: 49cfb5454d471c48108b551c285b0756bbf83098
5
5
  SHA512:
6
- metadata.gz: 45f21ab1906fd9699d8415409f2b115494032dc4b7a04aefc16e575fe97bf127e5dce234192b8073bcca9b000d859912d4ca2533fb6f95fc60261ccc51b46edb
7
- data.tar.gz: e627486169c7a510573984cbb6406bbc50a87317650d0a71ef1b52e2e128d94f91bbcb093639f680923cf0e1d8c5b4bae6981dc4417e05b9dd7d64dd954c2115
6
+ metadata.gz: 441a36af699d87c75bb7a24b288abdc1c8e3ac3a1bf5ad20a185ecc1571d0a1c7ce01ee95a1913f9fe6d86d677be6f0f29ec76c17cd1eae0161fec7414c7c0e5
7
+ data.tar.gz: dcab1b069f94a52fab807cc2521ab39b936c3065e94aa3c46ca52cfac56c8f3c48bf7c933eb20da55c89c74a42042be41f2362d6b3e1a92f74117a9c7577e71a
data/README.md CHANGED
@@ -4,17 +4,17 @@ A [rails_admin](https://github.com/sferik/rails_admin) plugin to add more option
4
4
 
5
5
  Features:
6
6
 
7
- - nested sortable tabs
7
+ - load fields css classes from models
8
8
 
9
- - load fields css classes from model
9
+ - nested sortable tabs (with drag and drop)
10
10
 
11
- - nested_list: has_many associations alternative view (list and accordion)
11
+ - *nested_list*: has_many associations alternative views (list and accordion)
12
12
 
13
- - nested_one: has_one associations alternative view
13
+ - *nested_one*: has_one associations alternative view
14
14
 
15
15
  Notes:
16
16
 
17
- - nested_list and nested_one don't support creating new records and deleting existing ones
17
+ - *nested_list* and *nested_one* don't support creating new records and deleting existing ones
18
18
 
19
19
  ## Install
20
20
 
@@ -28,6 +28,29 @@ Notes:
28
28
 
29
29
  ## Usage
30
30
 
31
+ #### load fields css classes from model
32
+
33
+ It can be useful to add specific classes to some fields using Single Table Inheritance models:
34
+
35
+ ```ruby
36
+ class Block < ApplicationRecord
37
+ def type_enum
38
+ @type_enum ||= [ 'BlockImage', 'BlockText' ]
39
+ end
40
+ end
41
+
42
+ class BlockImage < Block
43
+ def css_class
44
+ @css_class ||= {
45
+ abstract: 'hide',
46
+ name: 'hide'
47
+ }
48
+ end
49
+ end
50
+ ```
51
+
52
+ Class 'hide' is added to *abstract* and *name* fields of *BlockImage* only.
53
+
31
54
  #### nested sortable tabs
32
55
 
33
56
  Example: a parent model *Page* and a nested model *Block* (page has many blocks)
@@ -40,7 +63,7 @@ Example: a parent model *Page* and a nested model *Block* (page has many blocks)
40
63
 
41
64
  - Add a default ordered scope to the nested model:
42
65
 
43
- `default_scope { order( position: :desc ) }`
66
+ `default_scope { order( :position ) }`
44
67
 
45
68
  - rails_admin config:
46
69
 
@@ -64,28 +87,7 @@ Example: a parent model *Page* and a nested model *Block* (page has many blocks)
64
87
 
65
88
  - If you edit a *Page* in rails_admin *Blocks* should be draggable
66
89
 
67
- #### load fields css classes from model
68
-
69
- It can be useful to add specific classes to some fields using Single Table Inheritance models:
70
-
71
- ```ruby
72
- class Block < ApplicationRecord
73
- def type_enum
74
- @type_enum ||= [ 'BlockImage', 'BlockText' ]
75
- end
76
- end
77
-
78
- class BlockImage < Block
79
- def css_class
80
- @css_class ||= {
81
- abstract: 'hide',
82
- name: 'hide'
83
- }
84
- end
85
- end
86
- ```
87
-
88
- Class 'hide' is added to *abstract* and *name* fields of *BlockImage* only.
90
+ - If you want to add a symbol to draggable handlers you can add a CSS rule like: `.ui-sortable-handle > a::before { content: '\2194 '; }`
89
91
 
90
92
  #### nested_list
91
93
 
@@ -30,6 +30,10 @@ module RailsAdmin::Config::Fields::Types
30
30
  false
31
31
  end
32
32
 
33
+ register_instance_option :orderable do
34
+ false
35
+ end
36
+
33
37
  register_instance_option :sortable do
34
38
  false
35
39
  end
@@ -1,3 +1,3 @@
1
1
  module RailsAdminExtendedFields
2
- VERSION = '0.1.2'
2
+ VERSION = '0.1.4'
3
3
  end
@@ -11,6 +11,8 @@
11
11
  html_attributes 'data-sortable': 'true'
12
12
  end
13
13
  */
14
+ // Handle style: .ui-sortable-handle > a::before { content: '\2194 '; }
15
+
14
16
  function set_sortable( element, cnt, position ) {
15
17
  element.addClass( 'nested-sortable-' + cnt );
16
18
  // Add tab content reference
@@ -23,9 +25,8 @@ function set_sortable( element, cnt, position ) {
23
25
  update: function( event, ui ) {
24
26
  // Update each position field
25
27
  var positions = $('.nested-sortable-' + $(this).attr('data-sortable') + ' input[data-sortable]');
26
- var len = positions.length;
27
28
  $(this).find('> li').each( function( i ) {
28
- positions.eq( $(this).attr( 'data-tab' ) ).val( len-- );
29
+ positions.eq( $(this).attr( 'data-tab' ) ).val( i );
29
30
  });
30
31
  }
31
32
  });
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_admin_extended_fields
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mattia Roccoberton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-12 00:00:00.000000000 Z
11
+ date: 2017-06-15 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: RailsAdminExtendedFields adds more options to rails_admin fields
14
14
  email:
@@ -47,7 +47,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
47
47
  version: '0'
48
48
  requirements: []
49
49
  rubyforge_project:
50
- rubygems_version: 2.6.8
50
+ rubygems_version: 2.5.2
51
51
  signing_key:
52
52
  specification_version: 4
53
53
  summary: RailsAdminExtendedFields plugin