dynamic_scaffold 1.11.0 → 1.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/dynamic_scaffold.js +1 -0
- data/app/assets/javascripts/dynamic_scaffold/auto_width.js +32 -0
- data/app/assets/javascripts/dynamic_scaffold/common.js +20 -1
- data/app/views/dynamic_scaffold/bootstrap/_list.html.erb +2 -2
- data/lib/dynamic_scaffold/version.rb +1 -1
- data/lib/generators/dynamic_scaffold/templates/controller.erb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c42e88067995f3753891fcc0e2a29aa8a8b8fd7ff9b093780f20455db67eb731
|
4
|
+
data.tar.gz: 1872ac09ed02e4a0524e7bc0d26900d1e493596bcafe47b177bfda380e741d9a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f893ff9dbb40db07c63c6929c11ccae374ac17e82621bf8f878325b7b2393da1f7ffc12e354ccac152579b8f888d2c66780179c015be4cb361bfa9e7837835b
|
7
|
+
data.tar.gz: d2ce03bded48b344d364a737b38bed3a4aa4129b431189fcb213092c5385652cb148513aaef7bb4070ee62b53d3edd42225405335d1357947ddec65a7a374c42
|
@@ -0,0 +1,32 @@
|
|
1
|
+
var calcWidth = function(){
|
2
|
+
var firstRow = document.querySelector('.js-ds-list-row:first-child')
|
3
|
+
|
4
|
+
var wrapperWidth = firstRow.clientWidth
|
5
|
+
|
6
|
+
var autoWidthItemIndexes = Array.prototype.filter.call(firstRow.querySelectorAll('.js-ds-list-item'), function(item){
|
7
|
+
return item.classList.contains('ds-auto-width')
|
8
|
+
}).map(function(item){
|
9
|
+
return parseInt(item.getAttribute('data-index'), 10)
|
10
|
+
})
|
11
|
+
|
12
|
+
autoWidthItemIndexes.forEach(function(index){
|
13
|
+
var items = document.querySelectorAll('.js-ds-list-item[data-index="' + index + '"]')
|
14
|
+
|
15
|
+
Array.prototype.forEach.call(items, function(item){
|
16
|
+
item.style.width = 'auto'
|
17
|
+
})
|
18
|
+
|
19
|
+
var maxWidth = Array.prototype.reduce.call(items, function(currentMax, item){
|
20
|
+
return Math.max(currentMax, item.offsetWidth)
|
21
|
+
}, 0)
|
22
|
+
|
23
|
+
maxWidth = Math.min(maxWidth, wrapperWidth)
|
24
|
+
|
25
|
+
Array.prototype.forEach.call(items, function(item){
|
26
|
+
item.style.width = maxWidth + 'px'
|
27
|
+
})
|
28
|
+
})
|
29
|
+
}
|
30
|
+
|
31
|
+
document.addEventListener('dynamic_scaffold:load', calcWidth)
|
32
|
+
document.addEventListener('dynamic_scaffold:window_resized', calcWidth)
|
@@ -13,6 +13,7 @@ if (window.Element && !Element.prototype.closest) {
|
|
13
13
|
};
|
14
14
|
}
|
15
15
|
|
16
|
+
// dynamic_scaffold:load
|
16
17
|
(function(){
|
17
18
|
var fireEvent = function(){
|
18
19
|
var event = document.createEvent("HTMLEvents");
|
@@ -25,7 +26,25 @@ if (window.Element && !Element.prototype.closest) {
|
|
25
26
|
// Not fire after the initial page load
|
26
27
|
if (e.data.timing.visitEnd) fireEvent()
|
27
28
|
})
|
28
|
-
})()
|
29
|
+
})();
|
30
|
+
|
31
|
+
|
32
|
+
// dynamic_scaffold:window_resized
|
33
|
+
(function(){
|
34
|
+
var fireEvent = function(){
|
35
|
+
var event = document.createEvent("HTMLEvents");
|
36
|
+
event.initEvent('dynamic_scaffold:window_resized', false, false)
|
37
|
+
document.dispatchEvent(event)
|
38
|
+
}
|
39
|
+
|
40
|
+
var timeout = 0
|
41
|
+
window.addEventListener('resize', function(e){
|
42
|
+
this.clearTimeout(timeout)
|
43
|
+
timeout = setTimeout(function(){
|
44
|
+
fireEvent()
|
45
|
+
}, 300)
|
46
|
+
})
|
47
|
+
})();
|
29
48
|
|
30
49
|
// promise polyfill
|
31
50
|
// IE 11 has no Promise? Are you kidding?
|
@@ -38,9 +38,9 @@
|
|
38
38
|
<div class="ds-list-heading"><%= dynamic_scaffold.list.title(record) %></div>
|
39
39
|
<% end %>
|
40
40
|
<div class="ds-list-items">
|
41
|
-
<%dynamic_scaffold.list.items.
|
41
|
+
<%dynamic_scaffold.list.items.each_with_index do |disp, index|%>
|
42
42
|
<%- if disp.show?(self, record) -%>
|
43
|
-
<%= content_tag :div, class: class_names('ds-list-item', disp.classnames), **disp.html_attributes do%>
|
43
|
+
<%= content_tag :div, class: class_names('ds-list-item js-ds-list-item', disp.classnames), **{**disp.html_attributes, 'data-index': index} do%>
|
44
44
|
<div class="ds-list-label"><%= disp.label %></div>
|
45
45
|
<div class="ds-list-value"><%= disp.value self, record %></div>
|
46
46
|
<%end%>
|
@@ -62,7 +62,7 @@ class <%= @class_scope.present? ? "#{@class_scope}::" : '' %><%= @plural_model_n
|
|
62
62
|
# Please see https://github.com/gomo/dynamic_scaffold#customize-list for details.
|
63
63
|
|
64
64
|
<%- @model.column_names.each do |column| -%>
|
65
|
-
config.list.item(:<%= column %>,
|
65
|
+
config.list.item(:<%= column %>, class: 'ds-auto-width')
|
66
66
|
<%- end -%>
|
67
67
|
|
68
68
|
# You can customize the form fields through `config.form`.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dynamic_scaffold
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masamoto Miyata
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-08-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: classnames-rails-view
|
@@ -252,6 +252,7 @@ files:
|
|
252
252
|
- app/assets/images/dynamic_scaffold/fontawesome/step-forward.svg
|
253
253
|
- app/assets/images/dynamic_scaffold/fontawesome/times.svg
|
254
254
|
- app/assets/javascripts/dynamic_scaffold.js
|
255
|
+
- app/assets/javascripts/dynamic_scaffold/auto_width.js
|
255
256
|
- app/assets/javascripts/dynamic_scaffold/common.js
|
256
257
|
- app/assets/javascripts/dynamic_scaffold/delete.js
|
257
258
|
- app/assets/javascripts/dynamic_scaffold/image.js
|