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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d8c6729fef9f47c547f09daaefc76fbe6732f1a6
4
- data.tar.gz: 56535d062ad8e4c956d6d79bb43cf794b5b56b24
3
+ metadata.gz: 58e7303d43cb79ad1bb67de2ee06a41928010ba7
4
+ data.tar.gz: f9152dfd8538f68686e6bfbf3a26bfa8514715d0
5
5
  SHA512:
6
- metadata.gz: 99098abc2072c7f901b86bfbc9b205cc1a9f7d5c5dc02bcbf7eee97a06510ba7fca76b494463f8013cbe5eaddddefbc38a7270a55cc665528427ce227107a243
7
- data.tar.gz: 66b542dc266d511deac569350cf68a32b5bffa6e3d107d5d288e83bcc4bb296906fc619c70ca857d4a19a234d4f33f82fd75eeeec47bc314b32a7f256b642673
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 'app/views/json_ui/garage'
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
- json.padding options[:padding]
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, :method)
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glib-web
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - ''