File tree 5 files changed +49
-33
lines changed
5 files changed +49
-33
lines changed Original file line number Diff line number Diff line change
1
+ module Admin
2
+ module Components
3
+ class Header < Arbre ::HTML ::Tag
4
+ builder_method :html5_header
5
+ end
6
+
7
+ class Dialog < Arbre ::HTML ::Tag
8
+ builder_method :dialog
9
+ attr_accessor :inner_content
10
+
11
+ def build ( attributes = { } )
12
+ title = attributes [ :title ]
13
+ super ( attributes . except ( :title ) )
14
+ html5_header do
15
+ strong title if title . present?
16
+ button "X" , title : "Close" , class : "button close-dialog-button"
17
+ end
18
+ @inner_content = div
19
+ end
20
+
21
+ def add_child ( child )
22
+ if @inner_content
23
+ @inner_content . add_child child
24
+ else
25
+ super
26
+ end
27
+ end
28
+
29
+ def children?
30
+ @inner_content . children?
31
+ end
32
+ end
33
+ end
34
+ end
Original file line number Diff line number Diff line change @@ -117,26 +117,14 @@ def download_shapefiles(fmus)
117
117
end
118
118
if resource . geojson
119
119
row ( :geojson ) do
120
- dialog id : "geojson_modal" do
121
- html5_header do
122
- strong Fmu . human_attribute_name ( :geojson )
123
- button "Close" , class : "button close-dialog-button"
124
- end
125
- div do
126
- resource . geojson
127
- end
120
+ dialog id : "geojson_modal" , title : Fmu . human_attribute_name ( :geojson ) do
121
+ resource . geojson
128
122
end
129
123
link_to t ( "active_admin.view" ) , "javascript:void(0)" , onclick : "document.querySelector('#geojson_modal').showModal()"
130
124
end
131
125
row ( :properties ) do
132
- dialog id : "properties_modal" do
133
- html5_header do
134
- strong Fmu . human_attribute_name ( :properties )
135
- button "Close" , class : "button close-dialog-button"
136
- end
137
- div do
138
- resource . properties
139
- end
126
+ dialog id : "properties_modal" , title : Fmu . human_attribute_name ( :properties ) do
127
+ resource . properties
140
128
end
141
129
link_to t ( "active_admin.view" ) , "javascript:void(0)" , onclick : "document.querySelector('#properties_modal').showModal()"
142
130
end
Original file line number Diff line number Diff line change @@ -14,8 +14,10 @@ function initializeDialog() {
14
14
}
15
15
} ) ;
16
16
17
- dialog . querySelector ( ".close-dialog-button" ) . addEventListener ( "click" , ( ) => {
18
- dialog . close ( ) ;
17
+ dialog . querySelectorAll ( ".close-dialog-button" ) . forEach ( ( button ) => {
18
+ button . addEventListener ( "click" , ( ) => {
19
+ dialog . close ( ) ;
20
+ } ) ;
19
21
} ) ;
20
22
} ) ;
21
23
}
Original file line number Diff line number Diff line change @@ -229,11 +229,15 @@ dialog {
229
229
justify-content : space-between ;
230
230
align-items : center ;
231
231
padding : 10px ;
232
- border-bottom : 1px solid #ccc ;
233
232
234
- .close-dialog {
233
+ > strong {
234
+ font-size : 1.2em ;
235
+ }
236
+
237
+ .close-dialog-button {
235
238
cursor : pointer ;
236
- font-size : 1.5em ;
239
+ padding : 10px 15px ;
240
+ margin-left : auto ;
237
241
}
238
242
}
239
243
Original file line number Diff line number Diff line change @@ -369,18 +369,6 @@ def set_admin_locale
369
369
app . view_factory . register header : CustomAdminHeader
370
370
end
371
371
372
- module Arbre
373
- module HTML
374
- class Dialog < Tag
375
- builder_method :dialog
376
- end
377
-
378
- class Header < Tag
379
- builder_method :html5_header
380
- end
381
- end
382
- end
383
-
384
372
# activeadmin_addons update in 1.10 introduced a bug where it raises Formtastic::UnsupportedEnumCollection for multiple selects with enum values
385
373
# not sure why it should be raising not supported but it works so for me it's supported just fine
386
374
# https://github.com/platanus/activeadmin_addons/pull/442/files#diff-811ca221eee9c4866653114961ac21bcd0398557bb402c60f149be506c385a8eR3
You can’t perform that action at this time.
0 commit comments