glib-web 0.5.2 → 0.5.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (152) hide show
  1. checksums.yaml +5 -5
  2. data/app/controllers/concerns/glib/auth/policy.rb +0 -0
  3. data/app/controllers/concerns/glib/json/new_dynamic_text.rb +0 -0
  4. data/app/controllers/concerns/glib/json/traversal.rb +0 -0
  5. data/app/controllers/glib/home_controller.rb +1 -1
  6. data/app/helpers/glib/app_feature_support_helper.rb +16 -0
  7. data/app/helpers/glib/dynamic_images_helper.rb +0 -0
  8. data/app/helpers/glib/dynamic_texts_helper.rb +0 -0
  9. data/app/helpers/glib/forms_helper.rb +0 -0
  10. data/app/helpers/glib/json_ui/abstract_builder.rb +2 -2
  11. data/app/helpers/glib/json_ui/action_builder.rb +0 -0
  12. data/app/helpers/glib/json_ui/action_builder/dialogs.rb +0 -0
  13. data/app/helpers/glib/json_ui/action_builder/http.rb +0 -0
  14. data/app/helpers/glib/json_ui/action_builder/sheets.rb +0 -0
  15. data/app/helpers/glib/json_ui/action_builder/snackbars.rb +0 -0
  16. data/app/helpers/glib/json_ui/action_builder/windows.rb +1 -0
  17. data/app/helpers/glib/json_ui/generic_builders.rb +0 -0
  18. data/app/helpers/glib/json_ui/list_builders.rb +5 -0
  19. data/app/helpers/glib/json_ui/menu_builder.rb +0 -0
  20. data/app/helpers/glib/json_ui/page_helper.rb +27 -19
  21. data/app/helpers/glib/json_ui/response_helper.rb +0 -0
  22. data/app/helpers/glib/json_ui/split_builders.rb +0 -0
  23. data/app/helpers/glib/json_ui/styling_helper.rb +22 -0
  24. data/app/helpers/glib/json_ui/table_builders.rb +0 -0
  25. data/app/helpers/glib/json_ui/view_builder.rb +16 -16
  26. data/app/helpers/glib/json_ui/view_builder/banners.rb +0 -0
  27. data/app/helpers/glib/json_ui/view_builder/fields.rb +3 -0
  28. data/app/helpers/glib/json_ui/view_builder/panels.rb +2 -0
  29. data/app/helpers/glib/urls_helper.rb +7 -0
  30. data/app/models/glib/active_storage/attachment.rb +0 -0
  31. data/app/models/glib/active_storage/blob.rb +0 -0
  32. data/app/models/glib/dynamic_text_record.rb +0 -0
  33. data/app/models/glib/text.rb +0 -0
  34. data/app/policies/glib/application_policy.rb +27 -30
  35. data/app/validators/email_typo_validator.rb +0 -0
  36. data/app/validators/email_validator.rb +0 -0
  37. data/app/validators/url_validator.rb +0 -0
  38. data/app/views/app/views/json_ui/vue/renderer.html.erb +0 -0
  39. data/app/views/json_ui/garage/_nav_menu.json.jbuilder +0 -0
  40. data/app/views/json_ui/garage/actions/_dialogs.json.jbuilder +21 -12
  41. data/app/views/json_ui/garage/actions/_http.json.jbuilder +0 -0
  42. data/app/views/json_ui/garage/actions/_reload.json.jbuilder +0 -0
  43. data/app/views/json_ui/garage/actions/_sheets.json.jbuilder +0 -0
  44. data/app/views/json_ui/garage/actions/_snackbars.json.jbuilder +0 -0
  45. data/app/views/json_ui/garage/actions/_timeouts.json.jbuilder +0 -0
  46. data/app/views/json_ui/garage/actions/_windows.json.jbuilder +0 -0
  47. data/app/views/json_ui/garage/actions/dialogs_oauth_post.json.jbuilder +6 -0
  48. data/app/views/json_ui/garage/actions/index.json.jbuilder +2 -2
  49. data/app/views/json_ui/garage/forms/_alert_post_data.json.jbuilder +0 -0
  50. data/app/views/json_ui/garage/forms/basic.json.jbuilder +0 -0
  51. data/app/views/json_ui/garage/forms/basic_post.json.jbuilder +0 -0
  52. data/app/views/json_ui/garage/forms/checkboxes.json.jbuilder +0 -0
  53. data/app/views/json_ui/garage/forms/dynamic_group.json.jbuilder +9 -18
  54. data/app/views/json_ui/garage/forms/dynamic_select.json.jbuilder +0 -0
  55. data/app/views/json_ui/garage/forms/dynamic_select_data.json.jbuilder +25 -10
  56. data/app/views/json_ui/garage/forms/file_upload.json.jbuilder +5 -5
  57. data/app/views/json_ui/garage/forms/floating_submit.json.jbuilder +0 -0
  58. data/app/views/json_ui/garage/forms/generic_post.json.jbuilder +0 -0
  59. data/app/views/json_ui/garage/forms/get_request.json.jbuilder +0 -0
  60. data/app/views/json_ui/garage/forms/index.json.jbuilder +0 -0
  61. data/app/views/json_ui/garage/forms/pickers.json.jbuilder +6 -3
  62. data/app/views/json_ui/garage/forms/rich_text.json.jbuilder +0 -0
  63. data/app/views/json_ui/garage/forms/selects.json.jbuilder +0 -0
  64. data/app/views/json_ui/garage/forms/show_hide.json.jbuilder +0 -0
  65. data/app/views/json_ui/garage/forms/styled_boxes.json.jbuilder +4 -1
  66. data/app/views/json_ui/garage/forms/submission_flow.json.jbuilder +0 -0
  67. data/app/views/json_ui/garage/forms/submission_flow_post.json.jbuilder +0 -0
  68. data/app/views/json_ui/garage/forms/submission_indicator.json.jbuilder +0 -0
  69. data/app/views/json_ui/garage/forms/submission_indicator_post.json.jbuilder +0 -0
  70. data/app/views/json_ui/garage/forms/text_validation.json.jbuilder +0 -0
  71. data/app/views/json_ui/garage/home/blank.json.jbuilder +0 -0
  72. data/app/views/json_ui/garage/home/index.json.jbuilder +0 -0
  73. data/app/views/json_ui/garage/home/slow.json.jbuilder +0 -0
  74. data/app/views/json_ui/garage/lists/_infinite_scroll_section.json.jbuilder +15 -5
  75. data/app/views/json_ui/garage/lists/edit_actions.json.jbuilder +0 -0
  76. data/app/views/json_ui/garage/lists/fab.json.jbuilder +0 -0
  77. data/app/views/json_ui/garage/lists/index.json.jbuilder +0 -0
  78. data/app/views/json_ui/garage/lists/infinite_scroll.json.jbuilder +0 -0
  79. data/app/views/json_ui/garage/lists/templating.json.jbuilder +0 -0
  80. data/app/views/json_ui/garage/notifications/index.json.jbuilder +0 -43
  81. data/app/views/json_ui/garage/notifications/web_socket.json.jbuilder +19 -21
  82. data/app/views/json_ui/garage/pages/flat_centered.json.jbuilder +0 -0
  83. data/app/views/json_ui/garage/pages/full_width.json.jbuilder +0 -0
  84. data/app/views/json_ui/garage/pages/full_width_height.json.jbuilder +0 -0
  85. data/app/views/json_ui/garage/pages/index.json.jbuilder +11 -0
  86. data/app/views/json_ui/garage/pages/layout.json.jbuilder +12 -13
  87. data/app/views/json_ui/garage/pages/loading_indicator.json.jbuilder +0 -0
  88. data/app/views/json_ui/garage/pages/nav_buttons.json.jbuilder +28 -16
  89. data/app/views/json_ui/garage/pages/nested_scroll.json.jbuilder +40 -0
  90. data/app/views/json_ui/garage/pages/tab_bar.json.jbuilder +0 -0
  91. data/app/views/json_ui/garage/panels/_styled.json.jbuilder +0 -0
  92. data/app/views/json_ui/garage/panels/card.json.jbuilder +0 -0
  93. data/app/views/json_ui/garage/panels/carousel.json.jbuilder +24 -3
  94. data/app/views/json_ui/garage/panels/custom.json.jbuilder +0 -0
  95. data/app/views/json_ui/garage/panels/flow.json.jbuilder +0 -0
  96. data/app/views/json_ui/garage/panels/horizontal.json.jbuilder +0 -0
  97. data/app/views/json_ui/garage/panels/index.json.jbuilder +0 -0
  98. data/app/views/json_ui/garage/panels/outlined.json.jbuilder +0 -0
  99. data/app/views/json_ui/garage/panels/responsive.json.jbuilder +0 -0
  100. data/app/views/json_ui/garage/panels/split.json.jbuilder +0 -0
  101. data/app/views/json_ui/garage/panels/vertical.json.jbuilder +0 -0
  102. data/app/views/json_ui/garage/services/dynamic_text.json.jbuilder +0 -0
  103. data/app/views/json_ui/garage/services/image.json.jbuilder +0 -0
  104. data/app/views/json_ui/garage/services/index.json.jbuilder +0 -0
  105. data/app/views/json_ui/garage/tables/_autoload_section.json.jbuilder +0 -0
  106. data/app/views/json_ui/garage/tables/autoload_all.json.jbuilder +0 -0
  107. data/app/views/json_ui/garage/tables/autoload_as_needed.json.jbuilder +39 -0
  108. data/app/views/json_ui/garage/tables/export_import.json.jbuilder +0 -0
  109. data/app/views/json_ui/garage/tables/horizontal_scroll.json.jbuilder +0 -0
  110. data/app/views/json_ui/garage/tables/index.json.jbuilder +3 -0
  111. data/app/views/json_ui/garage/tables/layout.json.jbuilder +0 -0
  112. data/app/views/json_ui/garage/views/_chart_data.json.jbuilder +1 -1
  113. data/app/views/json_ui/garage/views/banners.json.jbuilder +0 -0
  114. data/app/views/json_ui/garage/views/calendar_data.json.jbuilder +23 -27
  115. data/app/views/json_ui/garage/views/charts.json.jbuilder +0 -0
  116. data/app/views/json_ui/garage/views/icons.json.jbuilder +22 -0
  117. data/app/views/json_ui/garage/views/images.json.jbuilder +4 -4
  118. data/app/views/json_ui/garage/views/index.json.jbuilder +3 -3
  119. data/app/views/json_ui/garage/views/links.json.jbuilder +0 -0
  120. data/app/views/json_ui/garage/views/map_data.json.jbuilder +0 -0
  121. data/app/views/json_ui/garage/views/misc.json.jbuilder +0 -0
  122. data/app/views/json_ui/garage/views/texts.json.jbuilder +0 -0
  123. data/config/routes.rb +0 -0
  124. data/lib/generators/glib/install_generator.rb +0 -0
  125. data/lib/generators/templates/20191017062519_create_texts.rb +0 -0
  126. data/lib/generators/templates/20191024063257_add_scope_to_texts.rb +0 -0
  127. data/lib/generators/templates/20191112095018_add_lang_to_texts.rb +0 -0
  128. data/lib/generators/templates/20191126071051_create_active_storage_tables.active_storage.rb +0 -0
  129. data/lib/generators/templates/database.yml +0 -0
  130. data/lib/generators/templates/dynamic_text.rb +0 -0
  131. data/lib/glib-web.rb +0 -0
  132. data/lib/glib/crypt.rb +1 -1
  133. data/lib/glib/crypt/utils.rb +0 -0
  134. data/lib/glib/dynamic_text.rb +1 -1
  135. data/lib/glib/dynamic_text/config.rb +0 -0
  136. data/lib/glib/engine.rb +0 -0
  137. data/lib/glib/json_crawler.rb +1 -0
  138. data/lib/glib/json_crawler/action_crawler.rb +0 -0
  139. data/lib/glib/json_crawler/action_crawlers/action_http.rb +0 -0
  140. data/lib/glib/json_crawler/action_crawlers/forms_submit.rb +0 -0
  141. data/lib/glib/json_crawler/action_crawlers/menu.rb +12 -0
  142. data/lib/glib/json_crawler/action_crawlers/nav_initiate.rb +1 -1
  143. data/lib/glib/json_crawler/action_crawlers/windows_open.rb +0 -0
  144. data/lib/glib/json_crawler/coverage.rb +0 -0
  145. data/lib/glib/json_crawler/http.rb +7 -4
  146. data/lib/glib/json_crawler/router.rb +2 -1
  147. data/lib/glib/test_helpers.rb +4 -4
  148. data/lib/glib/value.rb +0 -0
  149. data/lib/glib/version.rb +0 -0
  150. data/lib/tasks/db.rake +0 -0
  151. metadata +10 -3
  152. data/app/views/json_ui/garage/views/carousels.json.jbuilder +0 -37
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: 030e8fab91840b4a4337ebb8e867f56b9b658ec8932716afae41f1ebb84f93ee
4
- data.tar.gz: 1dc8364b2e509891eeed48c55f4aa8f9d8c89c3b9dad8dc700720d14e2b55e15
2
+ SHA1:
3
+ metadata.gz: d3229621ccc977c76e4adc70e1ab7271a76daf08
4
+ data.tar.gz: fa4e7c9f17a1d9c6b6cd770771730e13f583eb7e
5
5
  SHA512:
6
- metadata.gz: c94b19ff196e16ed430d973f295b64a4aa92e4a89f685e74731e5ecadb0a23a3ea39ab7aafe049e7bff46ffadb4d67f59d9a6b1791613cffcf63f66df611e806
7
- data.tar.gz: 9175751c633b836d10cfc4aa67d4af2e4e7ea8b837a99dfc34bf6fe91efc3ddf932a1aa227d13097cfbdb5aaab63ca9ecdd14fd3410a114e926c2896e36c6df0
6
+ metadata.gz: 2c1cf1ee7207ee7fa8276d6e94df95a6079bc011f429a0d9ca87a1305e4bb7201da04d13cda66de0c5872e7e1604374065dd307144e8e8d3110fcae424d5ae9f
7
+ data.tar.gz: '09fb824243fc37c0cd3ce3d6f0d0b6a85944ab02fa5b88383df8be9ff93394608fc1e0c394b9eadfa7fa51dbd854da3e8cf7ee4ed1da2895cfcdec06509a731e'
@@ -1,6 +1,6 @@
1
1
  module Glib
2
2
  class HomeController < ApplicationController
3
- if glib_auth_inited?
3
+ if try(:glib_auth_inited?)
4
4
  skip_before_action :glib_load_resource
5
5
  skip_before_action :glib_authorize_resource
6
6
  end
@@ -0,0 +1,16 @@
1
+ module Glib
2
+ module AppFeatureSupportHelper
3
+ def glib_app_feature_supported?(name, app_version, dictionary)
4
+ device = (app_device_os || :default).to_sym
5
+
6
+ version = dictionary[name.to_sym].try(:[], device)
7
+ except = dictionary[name.to_sym].try(:[], :except).try(:[], device)
8
+
9
+ !version.nil? && (version == :all || glib_app_version_gte(version, app_version)) && (except.nil? || except.to_s != app_version)
10
+ end
11
+
12
+ def glib_app_version_gte(feature_version, app_version)
13
+ app_version.blank? || Gem::Version.new(app_version) >= Gem::Version.new(feature_version)
14
+ end
15
+ end
16
+ end
File without changes
File without changes
File without changes
@@ -13,7 +13,7 @@ module Glib
13
13
  str.slice(0,1).capitalize + str.slice(1..-1)
14
14
  end
15
15
 
16
- def add_singleton_element type, name, *args
16
+ def add_singleton_element(type, name, *args)
17
17
  name_components = name.to_s.split('_')
18
18
  json.set! type, "#{name_components.join('/')}" if type
19
19
  args = [yield] if block_given?
@@ -22,7 +22,7 @@ module Glib
22
22
  "#{self.class.name}::#{name_components.map{ |str| capitalize_first_letter_and_leave_others_alone(str) }.join('::')}".constantize.new(json, @page).props(*args)
23
23
  end
24
24
 
25
- def add_element_to_array type, name, *args
25
+ def add_element_to_array(type, name, *args)
26
26
  json.child! do
27
27
  add_singleton_element type, name, *args
28
28
  end
@@ -2,6 +2,7 @@ class Glib::JsonUi::ActionBuilder
2
2
  module Windows
3
3
  class Close < Action
4
4
  action :onClose
5
+ # action :onAfterClose
5
6
  end
6
7
 
7
8
  class CloseAll < Action
@@ -41,6 +41,11 @@ module Glib
41
41
 
42
42
  class Custom < Thumbnail
43
43
  string :template
44
+
45
+ # TODO: Experimental
46
+ hash :extra
47
+
48
+ # TODO: Deprecate
44
49
  hash :data
45
50
  end
46
51
  end
File without changes
@@ -17,22 +17,27 @@ module Glib
17
17
  @__json_ui_page
18
18
  end
19
19
 
20
- # Use this only if you need to generate json independently from the current `json_ui_page`
21
- def json_ui_menu(&block)
22
- @__json_ui_menu_page ||= Page.new(Jbuilder.new, self)
23
- json = @__json_ui_menu_page.json
24
- json.nil!
25
- block&.call @__json_ui_menu_page.menu_builder
26
- json.attributes!
27
- end
28
-
29
- # Use this only if you need to generate json independently from the current `json_ui_page`
30
- def json_ui_panel(&block)
31
- @__json_ui_panel_page ||= Page.new(Jbuilder.new, self)
32
- json = @__json_ui_panel_page.json
33
- json.nil!
34
- block&.call @__json_ui_panel_page.view_builder
35
- json.attributes!
20
+ # # Use this only if you need to generate json independently from the current `json_ui_page`
21
+ # def json_ui_menu(&block)
22
+ # @__json_ui_menu_page ||= Page.new(Jbuilder.new, self)
23
+ # json = @__json_ui_menu_page.json
24
+ # json.nil!
25
+ # block&.call @__json_ui_menu_page.menu_builder
26
+ # json.attributes!
27
+ # end
28
+
29
+ # # Use this only if you need to generate json independently from the current `json_ui_page`
30
+ # def json_ui_panel(&block)
31
+ # @__json_ui_panel_page ||= Page.new(Jbuilder.new, self)
32
+ # json = @__json_ui_panel_page.json
33
+ # json.nil!
34
+ # block&.call @__json_ui_panel_page.view_builder
35
+ # json.attributes!
36
+ # end
37
+
38
+ def json_ui_section(json, &block)
39
+ @__json_ui_section ||= Page.new(json, self)
40
+ @__json_ui_section.list_section_builder
36
41
  end
37
42
 
38
43
  class Page
@@ -94,9 +99,12 @@ module Glib
94
99
  # options[:leftItems]&.call @menu_builder
95
100
  # end
96
101
  # json.logoUrl "http://localhost:3000/assets/logo_dark-02d9b6a91fdbf22515da7b921d31367b70696214415f6789d2f90232e4a287b7.svg"
97
- json.rightItems do
98
- options[:rightItems]&.call @menu_builder
99
- end
102
+
103
+ # json.rightItems do
104
+ # options[:rightItems]&.call @menu_builder
105
+ # end
106
+
107
+ @view_builder.add_singleton_view('appBar', options)
100
108
  end
101
109
  end
102
110
 
@@ -1,6 +1,9 @@
1
1
  module Glib
2
2
  module JsonUi
3
3
  module StylingHelper
4
+
5
+ ### Padding
6
+
4
7
  def glib_json_padding_body
5
8
  { top: 12, left: 20, right: 20, bottom: 12 }
6
9
  end
@@ -9,6 +12,12 @@ module Glib
9
12
  { top: 12, bottom: 12, left: 16, right: 16 }
10
13
  end
11
14
 
15
+ ###
16
+
17
+
18
+
19
+ ### Image
20
+
12
21
  def glib_json_image_standard_url
13
22
  'https://cdn-images-1.medium.com/max/1200/1*Qc0XxYm-qAZL-7tjjlNfrg.png'
14
23
  end
@@ -20,6 +29,19 @@ module Glib
20
29
  def glib_json_image_blob_key
21
30
  'o6CKzNt67PWnkPdUEnWMt7pr'
22
31
  end
32
+
33
+ ###
34
+
35
+
36
+
37
+ ### Color
38
+
39
+ def glib_color_panel_background
40
+ '#b3bac2'
41
+ end
42
+
43
+ ###
44
+
23
45
  end
24
46
  end
25
47
  end
@@ -15,6 +15,10 @@ module Glib
15
15
  end
16
16
  end
17
17
 
18
+ def add_singleton_view(name, *args)
19
+ add_singleton_element 'view', name, *args
20
+ end
21
+
18
22
  def method_missing(m, *args)
19
23
  add_view m, *args
20
24
  end
@@ -152,26 +156,22 @@ module Glib
152
156
  block.call page.menu_builder
153
157
  end
154
158
  end
159
+ end
155
160
 
156
- # Should be deprecated
157
- # def tabButtons(block)
158
- # json.tabButtons do
159
- # block.call page.menu_builder
160
- # end
161
- # end
162
-
163
- # def options(options)
164
- # current_url = page.context.request.base_url + page.context.request.fullpath
161
+ class AppBar < View
162
+ color :color
165
163
 
166
- # buttons ->(menu) do
167
- # options.each do |tab|
168
- # menu.button text: tab[:text], disabled: tab[:url] == current_url, onClick: ->(action) do
169
- # action.windows_reload url: tab[:url]
170
- # end
171
- # end
164
+ # def leftButtons(block)
165
+ # json.leftButtons do
166
+ # block.call page.menu_builder
172
167
  # end
173
168
  # end
174
169
 
170
+ def rightButtons(block)
171
+ json.rightButtons do
172
+ block.call page.menu_builder
173
+ end
174
+ end
175
175
  end
176
176
 
177
177
  class Datetime < View
@@ -182,4 +182,4 @@ module Glib
182
182
 
183
183
  end
184
184
  end
185
- end
185
+ end
@@ -104,6 +104,9 @@ class Glib::JsonUi::ViewBuilder
104
104
 
105
105
  class Check < Text
106
106
  string :uncheckValue
107
+ string :checkValue
108
+
109
+ # Where possible, use value instead of this
107
110
  bool :checked
108
111
  end
109
112
 
@@ -123,6 +123,8 @@ class Glib::JsonUi::ViewBuilder
123
123
  hash :nextPage
124
124
  hash :export
125
125
  hash :import
126
+ action :onScrollToTop
127
+ action :onScrollToBottom
126
128
 
127
129
  def firstSection(block)
128
130
  json.sections [1] do
@@ -0,0 +1,7 @@
1
+ module Glib
2
+ module UrlsHelper
3
+ def glib_url_current(new_params)
4
+ url_for(params.to_unsafe_h.merge(new_params.merge(only_path: false)))
5
+ end
6
+ end
7
+ end
File without changes
File without changes
File without changes
@@ -113,41 +113,17 @@ module Glib
113
113
  controller.policy_scope(record.class, policy_scope_class: policy_scope_class)
114
114
  end
115
115
 
116
- # TODO: Remove. Deprecated
117
- private # Used by child
118
- def public?
119
- true
120
- end
121
-
122
- private # Used by child
123
- def everyone
124
- true
125
- end
126
-
127
- # TODO: Deprecate `user()`
128
- private # Used by child
129
- def current_user
130
- user
131
- end
132
-
133
- # # TODO: Revise because it seems there is no justification for allowing owner to see any of the deleted entities, which include User, Guild, and Post
134
- # private # Used by child
135
- # def not_deleted_unless_owner_or_moderator?(&block)
136
- # block ||= lambda { |unused_arg| @user.moderator? }
137
- # !@record.deleted? || (@user && (@user.id == @record.user_owner_id || block.call(@record)))
138
- # end
139
-
140
- # private # Used by child
141
- # def not_deleted_unless_moderator?(&block)
142
- # block ||= lambda { |unused_arg| @user.moderator? }
143
- # !@record.deleted? || (@user && block.call(@record))
144
- # end
145
-
146
116
  public
147
117
  def self.args_builder
148
118
  Proc.new { |controller| [] }
149
119
  end
150
120
 
121
+ # TODO: Remove. Deprecated
122
+ # private # Used by child
123
+ # def public?
124
+ # true
125
+ # end
126
+
151
127
  class Scope
152
128
  attr_reader :user, :scope
153
129
 
@@ -156,9 +132,30 @@ module Glib
156
132
  @scope = scope
157
133
  end
158
134
 
135
+ # def current_user
136
+ # user
137
+ # end
138
+
139
+ # To be overridden
159
140
  def resolve
160
141
  scope.none
161
142
  end
162
143
  end
144
+
145
+ private # Used by child
146
+ def everyone
147
+ true
148
+ end
149
+
150
+ # def current_user
151
+ # user
152
+ # end
153
+
154
+ # TODO: Bad pattern. Implement explicit policy parameter instead.
155
+ # - E.g. can? :destroy, :service_subscription_auto_renewal, { service_subscription: @service_subscription }
156
+ # - E.g. super class: :service_subscription_auto_renewal, { service_subscription: @service_subscription }
157
+ def controller_var(name)
158
+ controller.instance_variable_get(:"@#{name}")
159
+ end
163
160
  end
164
161
  end
File without changes
File without changes
File without changes
@@ -79,17 +79,26 @@ section.rows builder: ->(template) do
79
79
  end
80
80
 
81
81
  template.thumbnail title: 'dialogs/oauth', onClick: ->(action) do
82
- provider = {
83
- name: "facebook",
84
- webRequestUrl: "https://www.facebook.com/v3.1/dialog/oauth?auth_type=rerequest&client_id=CLIENT_ID&redirect_uri=http%3A%2F%2Fwww.lvh.me%3A3000%2Foauth_callback%2Ffacebook&response_type=code&scope=email",
85
- requestUrl: "https://www.facebook.com/v3.1/dialog/oauth",
86
- clientId: "CLIENT_ID",
87
- redirectUrl: "http://www.lvh.me:3000/oauth_callback/facebook.json"
88
- }
89
-
90
- action.dialogs_oauth provider: provider, providerParamName: "session[oauth_provider]", callbackUrlParamName: "session[[oauth_callback_url]", onSuccess: ->(action) do
91
- action.http_post url: 'TODO: post params to server'
82
+ if respond_to?(:user_facebook_omniauth_authorize_url)
83
+ provider = {
84
+ name: 'facebook',
85
+ webRequestUrl: user_facebook_omniauth_authorize_url(format: nil, _render: nil),
86
+ requestUrl: user_facebook_omniauth_authorize_url(format: nil),
87
+ clientId: Devise.omniauth_configs[:facebook].strategy[:client_id],
88
+ permissions: Devise.omniauth_configs[:facebook].strategy[:scope],
89
+ redirectUrl: user_facebook_omniauth_callback_url(format: nil)
90
+ }
91
+ action.dialogs_oauth provider: provider, providerParamName: 'session[oauth_provider]', callbackUrlParamName: 'session[[oauth_callback_url]', onSuccess: ->(subaction) do
92
+ subaction.http_post url: json_ui_garage_url(path: 'actions/dialogs_oauth_post'), formData: {
93
+ authenticity_token: form_authenticity_token
94
+ }
95
+ end
96
+ else
97
+ action.dialogs_alert message: 'To enable this, set up omniauth using devise'
98
+ # E.g.
99
+ # Add `devise :omniauthable, omniauth_providers: %i[facebook]` to user.rb
100
+ # Add `gem 'omniauth-facebook'` to Gemfile
101
+ # Add `config.omniauth :facebook` to devise.rb
92
102
  end
93
103
  end
94
-
95
- end
104
+ end