dynamic_scaffold 1.10.0 → 1.12.2
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 +35 -0
- data/app/assets/javascripts/dynamic_scaffold/common.js +20 -1
- data/app/views/dynamic_scaffold/bootstrap/_form.html.erb +1 -1
- data/app/views/dynamic_scaffold/bootstrap/_list.html.erb +2 -2
- data/app/views/dynamic_scaffold/bootstrap/form/_row.html.erb +1 -1
- data/lib/dynamic_scaffold/form/item/base.rb +3 -3
- 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: c6af7a0d39b975f4f4b3117f6209b6acf62f7ddcedc709204cd0febedc023f0b
|
4
|
+
data.tar.gz: 9cedfa6276fa55e364afdde623e7c372568bbee2d88e01445a6f6d94bea83446
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 46543b0126d137d6dcedcbf9e7c7dc0891d2666686cb2dc72a30e31350c2afc753eee686c14f0983ba60c9b083d521a70e80ec099718d202eea6e5e92f565aca
|
7
|
+
data.tar.gz: ea52d29d1a5652bb160413e24c12e50e2f422d6a78e5c89b228d0025db21e9d3ff69734cdbf45080019fc6628751d2a73caea281a8cfcb379aac6f4f58962af4
|
@@ -0,0 +1,35 @@
|
|
1
|
+
var calcWidth = function(){
|
2
|
+
var firstRow = document.querySelector('.js-ds-list-row:first-child')
|
3
|
+
if(!firstRow){
|
4
|
+
return
|
5
|
+
}
|
6
|
+
|
7
|
+
var wrapperWidth = firstRow.clientWidth
|
8
|
+
|
9
|
+
var autoWidthItemIndexes = Array.prototype.filter.call(firstRow.querySelectorAll('.js-ds-list-item'), function(item){
|
10
|
+
return item.classList.contains('ds-auto-width')
|
11
|
+
}).map(function(item){
|
12
|
+
return parseInt(item.getAttribute('data-index'), 10)
|
13
|
+
})
|
14
|
+
|
15
|
+
autoWidthItemIndexes.forEach(function(index){
|
16
|
+
var items = document.querySelectorAll('.js-ds-list-item[data-index="' + index + '"]')
|
17
|
+
|
18
|
+
Array.prototype.forEach.call(items, function(item){
|
19
|
+
item.style.width = 'auto'
|
20
|
+
})
|
21
|
+
|
22
|
+
var maxWidth = Array.prototype.reduce.call(items, function(currentMax, item){
|
23
|
+
return Math.max(currentMax, item.offsetWidth)
|
24
|
+
}, 0)
|
25
|
+
|
26
|
+
maxWidth = Math.min(maxWidth, wrapperWidth)
|
27
|
+
|
28
|
+
Array.prototype.forEach.call(items, function(item){
|
29
|
+
item.style.width = maxWidth + 'px'
|
30
|
+
})
|
31
|
+
})
|
32
|
+
}
|
33
|
+
|
34
|
+
document.addEventListener('dynamic_scaffold:load', calcWidth)
|
35
|
+
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?
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<%= form_with method: method, model: @record, url: url, local: true, class: 'ds-form' do |form| %>
|
1
|
+
<%= form_with method: method, model: @record, scope: dynamic_scaffold.model.name.underscore, url: url, local: true, class: 'ds-form' do |form| %>
|
2
2
|
<%-dynamic_scaffold.form.items.each do |elem|-%>
|
3
3
|
<%= render 'dynamic_scaffold/bootstrap/form/row', form: form, elem: elem, depth: 0 %>
|
4
4
|
<% end %>
|
@@ -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%>
|
@@ -124,10 +124,10 @@ module DynamicScaffold
|
|
124
124
|
self
|
125
125
|
end
|
126
126
|
|
127
|
-
def needs_rendering?(view)
|
127
|
+
def needs_rendering?(view, record)
|
128
128
|
return true unless @if_block || @unless_block
|
129
|
-
return view.instance_exec(view.controller.params, &@if_block) if @if_block
|
130
|
-
return !view.instance_exec(view.controller.params, &@unless_block) if @unless_block
|
129
|
+
return view.instance_exec(view.controller.params, record, &@if_block) if @if_block
|
130
|
+
return !view.instance_exec(view.controller.params, record, &@unless_block) if @unless_block
|
131
131
|
end
|
132
132
|
|
133
133
|
def proxy(attribute_name)
|
@@ -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.2
|
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-05 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
|