glib-web 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/home_controller.rb +1 -1
- data/app/helpers/glib/web/json_ui_helper.rb +37 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 58e7303d43cb79ad1bb67de2ee06a41928010ba7
|
4
|
+
data.tar.gz: f9152dfd8538f68686e6bfbf3a26bfa8514715d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7fefed6116c08f30ef5f042d7dc58f2d63d48d1050f61209664d371b438d6c6058e8f79afa9013b9bcf9c479d9ef3c5d140393e7cf07a4e994c0d034921e2828
|
7
|
+
data.tar.gz: a75b13fead8a276bb14aee83e329b95ceee3ad4eef35aed8bd4e614891f27ece990d0f59367c9819f774fc5b1fd025b2898893f43863927127ba6d95349c8d61
|
@@ -4,7 +4,7 @@ class HomeController < ApplicationController
|
|
4
4
|
@path_prefix = 'json_ui/garage'
|
5
5
|
@sample_image_url = 'https://cdn-images-1.medium.com/max/1200/1*Qc0XxYm-qAZL-7tjjlNfrg.png'
|
6
6
|
|
7
|
-
# prepend_view_path
|
7
|
+
# We can't use prepend_view_path because it affects the app, not the gem
|
8
8
|
path = "#{@path_prefix}/#{params[:path] || 'home/index'}"
|
9
9
|
render path
|
10
10
|
end
|
@@ -1,6 +1,18 @@
|
|
1
1
|
module Glib
|
2
2
|
module Web
|
3
3
|
module JsonUiHelper
|
4
|
+
class Builder
|
5
|
+
def initialize(json)
|
6
|
+
@json = json
|
7
|
+
end
|
8
|
+
|
9
|
+
def optional(options, *props)
|
10
|
+
props.each do |prop|
|
11
|
+
@json.set! prop, options[prop]
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
4
16
|
def json_body_with_list(json, header = nil, footer = nil, options = {})
|
5
17
|
json.header header
|
6
18
|
json.content do
|
@@ -17,12 +29,16 @@ module Glib
|
|
17
29
|
end
|
18
30
|
|
19
31
|
def json_body_with_scroll(json, header = nil, footer = nil, options = {})
|
32
|
+
builder = Builder.new(json)
|
33
|
+
|
20
34
|
json.header header
|
21
35
|
json.content do
|
22
36
|
json.subviews [1] do
|
23
37
|
json.view 'panels/scroll-v1'
|
24
38
|
json.width 'matchParent'
|
25
|
-
|
39
|
+
|
40
|
+
builder.optional(options, :padding, :backgroundColor)
|
41
|
+
|
26
42
|
json.subviews do
|
27
43
|
yield
|
28
44
|
end
|
@@ -34,10 +50,20 @@ module Glib
|
|
34
50
|
def json_body_with_form(json, header = nil, footer = nil, options = {})
|
35
51
|
json.header header
|
36
52
|
json_body_with_scroll json do
|
53
|
+
method = options[:method].to_sym
|
54
|
+
|
37
55
|
json.child! do
|
38
56
|
json.view 'panels/form-v1'
|
39
57
|
json.width 'matchParent'
|
40
|
-
json.(options, :url
|
58
|
+
json.(options, :url)
|
59
|
+
|
60
|
+
case method
|
61
|
+
when :patch, :put, :delete
|
62
|
+
json.method :post
|
63
|
+
else
|
64
|
+
json.method method
|
65
|
+
end
|
66
|
+
|
41
67
|
json.padding options[:padding]
|
42
68
|
json.local options[:local]
|
43
69
|
json.subviews do
|
@@ -47,6 +73,15 @@ module Glib
|
|
47
73
|
json.value form_authenticity_token
|
48
74
|
end
|
49
75
|
|
76
|
+
case method
|
77
|
+
when :patch, :put, :delete
|
78
|
+
json.child! do
|
79
|
+
json.view 'fields/hidden-v1'
|
80
|
+
json.name '_method'
|
81
|
+
json.value method
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
50
85
|
yield
|
51
86
|
end
|
52
87
|
end
|