active_scaffold_child_memberships 0.1.1 → 0.1.2
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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dcae2e51da5f8fbd6657b07a650b7b2b14af07a2fa5050c7ef1da0efff40d2ca
|
4
|
+
data.tar.gz: 448d1630e63518f9a70ac0470ba274731d07774a1edc7fc8671f1a58a6458bab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1456b4e117597f4d3f113d27df2baca7b6f780d37586aa8a3e7781cb5106344c3ce2503b82651c75df54a0bb1a6ab7cd5c002df332072069be0b7c843beed40b
|
7
|
+
data.tar.gz: b6783c577d011dd4a011e9589e22b1cc398038402aeffba7cc1d86b13c5c93d04b73ddf6c6315736c56fa5a53dccad8fcb28234d3d5d828fa459c844b8cb4101
|
data/README.md
CHANGED
@@ -89,7 +89,7 @@ If new columns are not allowed, it can be disabled using `add_label: false`:
|
|
89
89
|
|
90
90
|
## Overriding Helpers
|
91
91
|
|
92
|
-
The helper `
|
92
|
+
The helper `active_scaffold_child_memberships_members` can be overrided to change the default columns rendered, instead of the assigned records only. For example to render all available roles:
|
93
93
|
|
94
94
|
```ruby
|
95
95
|
def active_scaffold_child_memberships_helper(column, row_records)
|
@@ -118,3 +118,15 @@ end
|
|
118
118
|
```
|
119
119
|
|
120
120
|
Also, the available records can be changed with the usual methods, `options_for_association_conditions` and `association_klass_scoped`, they receive the source association of the has_many through association (`:roles` in the example), and an empty record of the through association.
|
121
|
+
|
122
|
+
To change how checkboxes are rendered, for example, adding extra content, the helper `active_scaffold_child_memberships_checkbox` can be overrided. It supports model prefix too. The argument child is the record of the row, and member is the record of the column.
|
123
|
+
|
124
|
+
```ruby
|
125
|
+
def active_scaffold_child_memberships_checkbox(column, source_column, child, member, name:, value:)
|
126
|
+
if column == :roles
|
127
|
+
safe_join [super, content_tag(:span, member.state_for(child))]
|
128
|
+
else
|
129
|
+
super
|
130
|
+
end
|
131
|
+
end
|
132
|
+
```
|
@@ -15,9 +15,11 @@ module ActiveScaffoldChildMemberships
|
|
15
15
|
end
|
16
16
|
header.unshift content_tag(:th, through_col.label)
|
17
17
|
|
18
|
+
checkbox_helper = override_helper_per_model(:active_scaffold_child_membership_checkbox, column.active_record_class)
|
18
19
|
rows = children.map do |record|
|
20
|
+
checkbox_name = "#{options[:name]}[memberships][#{record.id}][]"
|
19
21
|
columns = column_records.map.with_index do |member, i|
|
20
|
-
content_tag(:td,
|
22
|
+
content_tag(:td, send(checkbox_helper, column, source_col, record, member, name: checkbox_name, value: i))
|
21
23
|
end
|
22
24
|
label = record.send(ui_options[:child_label_method] || :to_label)
|
23
25
|
columns.unshift content_tag(:td, h(label))
|
@@ -44,6 +46,10 @@ module ActiveScaffoldChildMemberships
|
|
44
46
|
row_records.flat_map(&column.association.source_reflection.name).uniq
|
45
47
|
end
|
46
48
|
|
49
|
+
def active_scaffold_child_membership_checkbox(column, source_column, child, member, name:, value:)
|
50
|
+
check_box_tag(name, value, child.send(source_column.name).include?(member), id: nil)
|
51
|
+
end
|
52
|
+
|
47
53
|
def active_scaffold_child_memberships_new_column(column, name, source_col, ui_options)
|
48
54
|
inplace_options = {object: source_col.active_record_class.new, id: '', disabled: true, associated: nil, class: 'inplace_field', name: name}
|
49
55
|
form_ui, form_ui_options = ui_options[:add_column_ui]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_scaffold_child_memberships
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergio Cambra
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-01-
|
11
|
+
date: 2025-01-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_scaffold
|