matestack-ui-core 0.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (202) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +228 -0
  4. data/Rakefile +34 -0
  5. data/app/concepts/matestack/ui/core/abbr/abbr.haml +5 -0
  6. data/app/concepts/matestack/ui/core/abbr/abbr.rb +12 -0
  7. data/app/concepts/matestack/ui/core/absolute/absolute.haml +3 -0
  8. data/app/concepts/matestack/ui/core/absolute/absolute.rb +17 -0
  9. data/app/concepts/matestack/ui/core/action/action.haml +3 -0
  10. data/app/concepts/matestack/ui/core/action/action.js +49 -0
  11. data/app/concepts/matestack/ui/core/action/action.rb +52 -0
  12. data/app/concepts/matestack/ui/core/address/address.haml +5 -0
  13. data/app/concepts/matestack/ui/core/address/address.rb +5 -0
  14. data/app/concepts/matestack/ui/core/app/app.haml +4 -0
  15. data/app/concepts/matestack/ui/core/app/app.js +27 -0
  16. data/app/concepts/matestack/ui/core/app/app.rb +98 -0
  17. data/app/concepts/matestack/ui/core/app/store.js +70 -0
  18. data/app/concepts/matestack/ui/core/article/article.haml +5 -0
  19. data/app/concepts/matestack/ui/core/article/article.rb +5 -0
  20. data/app/concepts/matestack/ui/core/async/async.haml +2 -0
  21. data/app/concepts/matestack/ui/core/async/async.js +76 -0
  22. data/app/concepts/matestack/ui/core/async/async.rb +12 -0
  23. data/app/concepts/matestack/ui/core/blockquote/blockquote.haml +5 -0
  24. data/app/concepts/matestack/ui/core/blockquote/blockquote.rb +11 -0
  25. data/app/concepts/matestack/ui/core/br/br.haml +5 -0
  26. data/app/concepts/matestack/ui/core/br/br.rb +5 -0
  27. data/app/concepts/matestack/ui/core/button/button.haml +5 -0
  28. data/app/concepts/matestack/ui/core/button/button.rb +11 -0
  29. data/app/concepts/matestack/ui/core/caption/caption.haml +5 -0
  30. data/app/concepts/matestack/ui/core/caption/caption.rb +5 -0
  31. data/app/concepts/matestack/ui/core/collection/content/content.js +98 -0
  32. data/app/concepts/matestack/ui/core/collection/content/content.rb +18 -0
  33. data/app/concepts/matestack/ui/core/collection/content/next/next.haml +3 -0
  34. data/app/concepts/matestack/ui/core/collection/content/next/next.rb +5 -0
  35. data/app/concepts/matestack/ui/core/collection/content/page/link/link.haml +3 -0
  36. data/app/concepts/matestack/ui/core/collection/content/page/link/link.rb +5 -0
  37. data/app/concepts/matestack/ui/core/collection/content/previous/previous.haml +3 -0
  38. data/app/concepts/matestack/ui/core/collection/content/previous/previous.rb +5 -0
  39. data/app/concepts/matestack/ui/core/collection/filter/filter.js +48 -0
  40. data/app/concepts/matestack/ui/core/collection/filter/filter.rb +17 -0
  41. data/app/concepts/matestack/ui/core/collection/filter/input/input.haml +2 -0
  42. data/app/concepts/matestack/ui/core/collection/filter/input/input.rb +25 -0
  43. data/app/concepts/matestack/ui/core/collection/filter/reset/reset.haml +3 -0
  44. data/app/concepts/matestack/ui/core/collection/filter/reset/reset.rb +5 -0
  45. data/app/concepts/matestack/ui/core/collection/filter/submit/submit.haml +3 -0
  46. data/app/concepts/matestack/ui/core/collection/filter/submit/submit.rb +5 -0
  47. data/app/concepts/matestack/ui/core/collection/helper.rb +113 -0
  48. data/app/concepts/matestack/ui/core/collection/order/order.js +56 -0
  49. data/app/concepts/matestack/ui/core/collection/order/order.rb +17 -0
  50. data/app/concepts/matestack/ui/core/collection/order/toggle/indicator/indicator.rb +13 -0
  51. data/app/concepts/matestack/ui/core/collection/order/toggle/toggle.haml +3 -0
  52. data/app/concepts/matestack/ui/core/collection/order/toggle/toggle.rb +5 -0
  53. data/app/concepts/matestack/ui/core/component/anonym-dynamic-component.js +10 -0
  54. data/app/concepts/matestack/ui/core/component/children.haml +2 -0
  55. data/app/concepts/matestack/ui/core/component/component.js +59 -0
  56. data/app/concepts/matestack/ui/core/component/dynamic.haml +6 -0
  57. data/app/concepts/matestack/ui/core/component/dynamic.rb +261 -0
  58. data/app/concepts/matestack/ui/core/component/dynamic_without_rerender.haml +2 -0
  59. data/app/concepts/matestack/ui/core/component/response.haml +2 -0
  60. data/app/concepts/matestack/ui/core/component/response_dynamic.haml +7 -0
  61. data/app/concepts/matestack/ui/core/component/response_dynamic_without_rerender.haml +3 -0
  62. data/app/concepts/matestack/ui/core/component/static.haml +1 -0
  63. data/app/concepts/matestack/ui/core/component/static.rb +16 -0
  64. data/app/concepts/matestack/ui/core/details/details.haml +3 -0
  65. data/app/concepts/matestack/ui/core/details/details.rb +5 -0
  66. data/app/concepts/matestack/ui/core/div/div.haml +3 -0
  67. data/app/concepts/matestack/ui/core/div/div.rb +5 -0
  68. data/app/concepts/matestack/ui/core/footer/footer.haml +3 -0
  69. data/app/concepts/matestack/ui/core/footer/footer.rb +5 -0
  70. data/app/concepts/matestack/ui/core/form/form.haml +2 -0
  71. data/app/concepts/matestack/ui/core/form/form.js +136 -0
  72. data/app/concepts/matestack/ui/core/form/form.rb +71 -0
  73. data/app/concepts/matestack/ui/core/form/inline/inline.haml +6 -0
  74. data/app/concepts/matestack/ui/core/form/inline/inline.rb +9 -0
  75. data/app/concepts/matestack/ui/core/form/input/input.haml +27 -0
  76. data/app/concepts/matestack/ui/core/form/input/input.rb +74 -0
  77. data/app/concepts/matestack/ui/core/form/select/select.haml +76 -0
  78. data/app/concepts/matestack/ui/core/form/select/select.rb +73 -0
  79. data/app/concepts/matestack/ui/core/form/submit/submit.haml +3 -0
  80. data/app/concepts/matestack/ui/core/form/submit/submit.rb +9 -0
  81. data/app/concepts/matestack/ui/core/header/header.haml +3 -0
  82. data/app/concepts/matestack/ui/core/header/header.rb +5 -0
  83. data/app/concepts/matestack/ui/core/heading/heading.haml +50 -0
  84. data/app/concepts/matestack/ui/core/heading/heading.rb +5 -0
  85. data/app/concepts/matestack/ui/core/hr/hr.haml +1 -0
  86. data/app/concepts/matestack/ui/core/hr/hr.rb +5 -0
  87. data/app/concepts/matestack/ui/core/html/html.haml +3 -0
  88. data/app/concepts/matestack/ui/core/html/html.js +10 -0
  89. data/app/concepts/matestack/ui/core/html/html.rb +17 -0
  90. data/app/concepts/matestack/ui/core/icon/icon.haml +5 -0
  91. data/app/concepts/matestack/ui/core/icon/icon.rb +5 -0
  92. data/app/concepts/matestack/ui/core/img/img.haml +1 -0
  93. data/app/concepts/matestack/ui/core/img/img.rb +5 -0
  94. data/app/concepts/matestack/ui/core/input/input.haml +3 -0
  95. data/app/concepts/matestack/ui/core/input/input.rb +5 -0
  96. data/app/concepts/matestack/ui/core/isolate/isolate.haml +2 -0
  97. data/app/concepts/matestack/ui/core/isolate/isolate.rb +11 -0
  98. data/app/concepts/matestack/ui/core/js/core.js +30 -0
  99. data/app/concepts/matestack/ui/core/js/event-hub.js +5 -0
  100. data/app/concepts/matestack/ui/core/js/helpers/query-params-helper.js +56 -0
  101. data/app/concepts/matestack/ui/core/label/label.haml +5 -0
  102. data/app/concepts/matestack/ui/core/label/label.rb +5 -0
  103. data/app/concepts/matestack/ui/core/li/li.haml +5 -0
  104. data/app/concepts/matestack/ui/core/li/li.rb +5 -0
  105. data/app/concepts/matestack/ui/core/link/link.haml +5 -0
  106. data/app/concepts/matestack/ui/core/link/link.rb +26 -0
  107. data/app/concepts/matestack/ui/core/main/main.haml +3 -0
  108. data/app/concepts/matestack/ui/core/main/main.rb +5 -0
  109. data/app/concepts/matestack/ui/core/nav/nav.haml +3 -0
  110. data/app/concepts/matestack/ui/core/nav/nav.rb +5 -0
  111. data/app/concepts/matestack/ui/core/ol/ol.haml +3 -0
  112. data/app/concepts/matestack/ui/core/ol/ol.rb +5 -0
  113. data/app/concepts/matestack/ui/core/onclick/onclick.haml +2 -0
  114. data/app/concepts/matestack/ui/core/onclick/onclick.js +21 -0
  115. data/app/concepts/matestack/ui/core/onclick/onclick.rb +5 -0
  116. data/app/concepts/matestack/ui/core/page/content.haml +7 -0
  117. data/app/concepts/matestack/ui/core/page/content.js +17 -0
  118. data/app/concepts/matestack/ui/core/page/content.rb +5 -0
  119. data/app/concepts/matestack/ui/core/page/page.haml +9 -0
  120. data/app/concepts/matestack/ui/core/page/page.rb +175 -0
  121. data/app/concepts/matestack/ui/core/paragraph/paragraph.haml +5 -0
  122. data/app/concepts/matestack/ui/core/paragraph/paragraph.rb +5 -0
  123. data/app/concepts/matestack/ui/core/partial/partial.haml +2 -0
  124. data/app/concepts/matestack/ui/core/partial/partial.rb +5 -0
  125. data/app/concepts/matestack/ui/core/pg/pg.haml +5 -0
  126. data/app/concepts/matestack/ui/core/pg/pg.rb +5 -0
  127. data/app/concepts/matestack/ui/core/plain/plain.rb +9 -0
  128. data/app/concepts/matestack/ui/core/progress/progress.haml +3 -0
  129. data/app/concepts/matestack/ui/core/progress/progress.rb +14 -0
  130. data/app/concepts/matestack/ui/core/section/section.haml +3 -0
  131. data/app/concepts/matestack/ui/core/section/section.rb +5 -0
  132. data/app/concepts/matestack/ui/core/slot/slot.haml +2 -0
  133. data/app/concepts/matestack/ui/core/slot/slot.rb +5 -0
  134. data/app/concepts/matestack/ui/core/small/small.haml +5 -0
  135. data/app/concepts/matestack/ui/core/small/small.rb +5 -0
  136. data/app/concepts/matestack/ui/core/span/span.haml +5 -0
  137. data/app/concepts/matestack/ui/core/span/span.rb +5 -0
  138. data/app/concepts/matestack/ui/core/strong/strong.haml +5 -0
  139. data/app/concepts/matestack/ui/core/strong/strong.rb +5 -0
  140. data/app/concepts/matestack/ui/core/sub/sub.haml +5 -0
  141. data/app/concepts/matestack/ui/core/sub/sub.rb +5 -0
  142. data/app/concepts/matestack/ui/core/summary/summary.haml +5 -0
  143. data/app/concepts/matestack/ui/core/summary/summary.rb +5 -0
  144. data/app/concepts/matestack/ui/core/table/table.haml +3 -0
  145. data/app/concepts/matestack/ui/core/table/table.rb +5 -0
  146. data/app/concepts/matestack/ui/core/tbody/tbody.haml +3 -0
  147. data/app/concepts/matestack/ui/core/tbody/tbody.rb +5 -0
  148. data/app/concepts/matestack/ui/core/td/td.haml +5 -0
  149. data/app/concepts/matestack/ui/core/td/td.rb +5 -0
  150. data/app/concepts/matestack/ui/core/tfoot/tfoot.haml +3 -0
  151. data/app/concepts/matestack/ui/core/tfoot/tfoot.rb +5 -0
  152. data/app/concepts/matestack/ui/core/th/th.haml +5 -0
  153. data/app/concepts/matestack/ui/core/th/th.rb +5 -0
  154. data/app/concepts/matestack/ui/core/thead/thead.haml +3 -0
  155. data/app/concepts/matestack/ui/core/thead/thead.rb +5 -0
  156. data/app/concepts/matestack/ui/core/time/time.haml +3 -0
  157. data/app/concepts/matestack/ui/core/time/time.rb +11 -0
  158. data/app/concepts/matestack/ui/core/tr/tr.haml +3 -0
  159. data/app/concepts/matestack/ui/core/tr/tr.rb +5 -0
  160. data/app/concepts/matestack/ui/core/transition/transition.haml +5 -0
  161. data/app/concepts/matestack/ui/core/transition/transition.js +26 -0
  162. data/app/concepts/matestack/ui/core/transition/transition.rb +31 -0
  163. data/app/concepts/matestack/ui/core/ul/ul.haml +3 -0
  164. data/app/concepts/matestack/ui/core/ul/ul.rb +5 -0
  165. data/app/concepts/matestack/ui/core/video/video.haml +1 -0
  166. data/app/concepts/matestack/ui/core/video/video.rb +7 -0
  167. data/app/concepts/matestack/ui/core/view/view.haml +2 -0
  168. data/app/concepts/matestack/ui/core/view/view.js +42 -0
  169. data/app/concepts/matestack/ui/core/view/view.rb +5 -0
  170. data/app/concepts/matestack/ui/core/youtube/youtube.haml +1 -0
  171. data/app/concepts/matestack/ui/core/youtube/youtube.rb +26 -0
  172. data/app/helpers/matestack/ui/core/application_helper.rb +35 -0
  173. data/app/lib/matestack/ui/app.rb +1 -0
  174. data/app/lib/matestack/ui/core/app_node.rb +53 -0
  175. data/app/lib/matestack/ui/core/component_node.rb +73 -0
  176. data/app/lib/matestack/ui/core/page_node.rb +96 -0
  177. data/app/lib/matestack/ui/core/to_cell.rb +129 -0
  178. data/app/lib/matestack/ui/dynamic_component.rb +1 -0
  179. data/app/lib/matestack/ui/page.rb +1 -0
  180. data/app/lib/matestack/ui/static_component.rb +1 -0
  181. data/config/routes.rb +3 -0
  182. data/lib/generators/matestack_app/USAGE +21 -0
  183. data/lib/generators/matestack_app/matestack_app_generator.rb +26 -0
  184. data/lib/generators/matestack_app/templates/matestack_app.erb +26 -0
  185. data/lib/generators/matestack_app/templates/matestack_app_controller.erb +7 -0
  186. data/lib/generators/matestack_component/USAGE +20 -0
  187. data/lib/generators/matestack_component/matestack_component_generator.rb +30 -0
  188. data/lib/generators/matestack_component/templates/matestack_component.haml.erb +5 -0
  189. data/lib/generators/matestack_component/templates/matestack_component.js.erb +17 -0
  190. data/lib/generators/matestack_component/templates/matestack_component.rb.erb +13 -0
  191. data/lib/generators/matestack_component/templates/matestack_component.scss.erb +1 -0
  192. data/lib/generators/matestack_page/USAGE +28 -0
  193. data/lib/generators/matestack_page/matestack_page_generator.rb +41 -0
  194. data/lib/generators/matestack_page/templates/matestack_page.erb +15 -0
  195. data/lib/matestack/ui/core.rb +15 -0
  196. data/lib/matestack/ui/core/engine.rb +19 -0
  197. data/lib/matestack/ui/core/version.rb +7 -0
  198. data/lib/tasks/matestack/ui/core_tasks.rake +4 -0
  199. data/vendor/assets/javascripts/manifest.json +4 -0
  200. data/vendor/assets/javascripts/matestack-ui-core.js +15309 -0
  201. data/vendor/assets/javascripts/matestack-ui-core.js.map +1 -0
  202. metadata +350 -0
@@ -0,0 +1,18 @@
1
+ module Matestack::Ui::Core::Collection::Content
2
+ class Content < Matestack::Ui::Core::Component::Dynamic
3
+
4
+ def setup
5
+ @rerender = true
6
+ @component_config = @component_config.except(:data, :paginated_data)
7
+ end
8
+
9
+ def response
10
+ components {
11
+ div @tag_attributes do
12
+ yield_components
13
+ end
14
+ }
15
+ end
16
+
17
+ end
18
+ end
@@ -0,0 +1,3 @@
1
+ %a{@tag_attributes, "@click": "next()"}
2
+ - if block_given?
3
+ = yield
@@ -0,0 +1,5 @@
1
+ module Matestack::Ui::Core::Collection::Content::Next
2
+ class Next < Matestack::Ui::Core::Component::Static
3
+
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ %a{@tag_attributes, "@click": "goToPage(#{@options[:page]})"}
2
+ - if block_given?
3
+ = yield
@@ -0,0 +1,5 @@
1
+ module Matestack::Ui::Core::Collection::Content::Page::Link
2
+ class Link < Matestack::Ui::Core::Component::Static
3
+
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ %a{@tag_attributes, "@click": "previous()"}
2
+ - if block_given?
3
+ = yield
@@ -0,0 +1,5 @@
1
+ module Matestack::Ui::Core::Collection::Content::Previous
2
+ class Previous < Matestack::Ui::Core::Component::Static
3
+
4
+ end
5
+ end
@@ -0,0 +1,48 @@
1
+ import Vue from 'vue/dist/vue.esm'
2
+ import matestackEventHub from 'js/event-hub'
3
+ import queryParamsHelper from 'js/helpers/query-params-helper'
4
+ import componentMixin from 'component/component'
5
+
6
+ const componentDef = {
7
+ mixins: [componentMixin],
8
+ data: function(){
9
+ return {
10
+ filter: {}
11
+ }
12
+ },
13
+ methods: {
14
+ submitFilter: function(){
15
+ var url;
16
+ var filter = this.filter
17
+ for (var key in this.filter) {
18
+ url = queryParamsHelper.updateQueryParams(this.componentConfig["id"] + "-filter-" + key, this.filter[key], url)
19
+ }
20
+ url = queryParamsHelper.updateQueryParams(this.componentConfig["id"] + "-offset", 0, url)
21
+ window.history.pushState({matestackApp: true, url: url}, null, url);
22
+ matestackEventHub.$emit(this.componentConfig["id"] + "-update")
23
+ },
24
+ resetFilter: function(){
25
+ var url;
26
+ for (var key in this.filter) {
27
+ url = queryParamsHelper.updateQueryParams(this.componentConfig["id"] + "-filter-" + key, null, url)
28
+ this.filter[key] = null;
29
+ this.$forceUpdate();
30
+ }
31
+ window.history.pushState({matestackApp: true, url: url}, null, url);
32
+ matestackEventHub.$emit(this.componentConfig["id"] + "-update")
33
+ }
34
+ },
35
+ created: function(){
36
+ var self = this;
37
+ var queryParamsObject = queryParamsHelper.queryParamsToObject()
38
+ Object.keys(queryParamsObject).forEach(function(key){
39
+ if (key.startsWith(self.componentConfig["id"] + "-filter-")){
40
+ self.filter[key.replace(self.componentConfig["id"] + "-filter-", "")] = queryParamsObject[key]
41
+ }
42
+ })
43
+ }
44
+ }
45
+
46
+ let component = Vue.component('matestack-ui-core-collection-filter', componentDef)
47
+
48
+ export default componentDef
@@ -0,0 +1,17 @@
1
+ module Matestack::Ui::Core::Collection::Filter
2
+ class Filter < Matestack::Ui::Core::Component::Dynamic
3
+
4
+ def setup
5
+ @component_config = @component_config.except(:data, :paginated_data)
6
+ end
7
+
8
+ def response
9
+ components {
10
+ div @tag_attributes do
11
+ yield_components
12
+ end
13
+ }
14
+ end
15
+
16
+ end
17
+ end
@@ -0,0 +1,2 @@
1
+ - if [:text, :number, :email, :date, :password].include?(options[:type])
2
+ %input{@tag_attributes}
@@ -0,0 +1,25 @@
1
+ module Matestack::Ui::Core::Collection::Filter::Input
2
+ class Input < Matestack::Ui::Core::Component::Static
3
+
4
+ def setup
5
+ @tag_attributes.merge!({
6
+ "v-model#{'.number' if options[:type] == :number}": input_key,
7
+ type: options[:type],
8
+ class: options[:class],
9
+ id: component_id,
10
+ "@keyup.enter": "submitFilter()",
11
+ ref: "filter.#{attr_key}",
12
+ placeholder: options[:placeholder]
13
+ })
14
+ end
15
+
16
+ def input_key
17
+ 'filter["' + options[:key].to_s + '"]'
18
+ end
19
+
20
+ def attr_key
21
+ return options[:key].to_s
22
+ end
23
+
24
+ end
25
+ end
@@ -0,0 +1,3 @@
1
+ %a{@tag_attributes, "@click": "resetFilter()"}
2
+ - if block_given?
3
+ = yield
@@ -0,0 +1,5 @@
1
+ module Matestack::Ui::Core::Collection::Filter::Reset
2
+ class Reset < Matestack::Ui::Core::Component::Static
3
+
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ %a{@tag_attributes, "@click": "submitFilter()"}
2
+ - if block_given?
3
+ = yield
@@ -0,0 +1,5 @@
1
+ module Matestack::Ui::Core::Collection::Filter::Submit
2
+ class Submit < Matestack::Ui::Core::Component::Static
3
+
4
+ end
5
+ end
@@ -0,0 +1,113 @@
1
+ module Matestack::Ui::Core::Collection
2
+
3
+ CollectionConfig = Struct.new(:id, :init_offset, :init_limit, :filtered_count, :base_count, :data, :context) do
4
+
5
+ def paginated_data
6
+ resulting_data = data
7
+ resulting_data = resulting_data.offset(get_collection_offset) unless get_collection_offset == 0
8
+ resulting_data = resulting_data.limit(get_collection_limit) unless get_collection_limit == 0
9
+
10
+ return resulting_data
11
+ end
12
+
13
+ def get_collection_offset
14
+ (context[:params]["#{id}-offset".to_sym] ||= init_offset).to_i
15
+ end
16
+
17
+ def get_collection_limit
18
+ (context[:params]["#{id}-limit".to_sym] ||= init_limit).to_i
19
+ end
20
+
21
+ def pages
22
+ offset = get_collection_offset
23
+ limit = get_collection_limit
24
+ if filtered_count.present?
25
+ count = filtered_count
26
+ else
27
+ count = base_count
28
+ end
29
+ page_count = count/limit
30
+ page_count += 1 if count%limit > 0
31
+ return (1..page_count).to_a
32
+ end
33
+
34
+ def from
35
+ return get_collection_offset + 1 if to > 0
36
+ return 0 if to == 0
37
+ end
38
+
39
+ def to
40
+ current_to = get_collection_offset + get_collection_limit
41
+ if filtered_count.present?
42
+ if current_to > filtered_count
43
+ return filtered_count
44
+ else
45
+ return current_to
46
+ end
47
+ else
48
+ if current_to > base_count
49
+ return base_count
50
+ else
51
+ return current_to
52
+ end
53
+ end
54
+ end
55
+
56
+ def config
57
+ self.to_h.except(:context)
58
+ end
59
+
60
+ end
61
+
62
+ module Helper
63
+
64
+ def get_collection_filter collection_id, key=nil
65
+ filter_hash = {}
66
+ context[:params].each do |param_key, param_value|
67
+ if param_key.start_with?("#{collection_id}-filter-")
68
+ param_key.gsub("#{collection_id}-filter-", "")
69
+ filter_hash[param_key.gsub("#{collection_id}-filter-", "").to_sym] = param_value
70
+ end
71
+ end
72
+ if key.nil?
73
+ return filter_hash
74
+ else
75
+ return filter_hash[key]
76
+ end
77
+ end
78
+
79
+ def get_collection_order collection_id, key=nil
80
+ order_hash = {}
81
+ context[:params].each do |param_key, param_value|
82
+ if param_key.start_with?("#{collection_id}-order-")
83
+ param_key.gsub("#{collection_id}-order-", "")
84
+ order_hash[param_key.gsub("#{collection_id}-order-", "").to_sym] = param_value
85
+ end
86
+ end
87
+ if key.nil?
88
+ return order_hash
89
+ else
90
+ return order_hash[key]
91
+ end
92
+ end
93
+
94
+ def set_collection id: nil, init_offset: 0, init_limit: nil, base_count: nil, filtered_count: nil, data: nil
95
+ @collections = {} if @collections.nil?
96
+
97
+ collection_config = CollectionConfig.new(
98
+ id,
99
+ init_offset,
100
+ init_limit,
101
+ filtered_count,
102
+ base_count,
103
+ data,
104
+ context
105
+ )
106
+
107
+ @collections[id.to_sym] = collection_config
108
+
109
+ return collection_config
110
+ end
111
+
112
+ end
113
+ end
@@ -0,0 +1,56 @@
1
+ import Vue from 'vue/dist/vue.esm'
2
+ import matestackEventHub from 'js/event-hub'
3
+ import queryParamsHelper from 'js/helpers/query-params-helper'
4
+ import componentMixin from 'component/component'
5
+
6
+ const componentDef = {
7
+ mixins: [componentMixin],
8
+ data: function(){
9
+ return {
10
+ ordering: {}
11
+ }
12
+ },
13
+ methods: {
14
+ toggleOrder: function(key){
15
+ if (this.ordering[key] == undefined) {
16
+ this.ordering[key] = "asc"
17
+ } else if (this.ordering[key] == "asc") {
18
+ this.ordering[key] = "desc"
19
+ } else if (this.ordering[key] = "desc") {
20
+ this.ordering[key] = undefined
21
+ }
22
+ var url;
23
+ url = queryParamsHelper.updateQueryParams(this.componentConfig["id"] + "-order-" + key, this.ordering[key])
24
+ url = queryParamsHelper.updateQueryParams(this.componentConfig["id"] + "-offset", 0, url)
25
+ window.history.pushState({matestackApp: true, url: url}, null, url);
26
+ matestackEventHub.$emit(this.componentConfig["id"] + "-update")
27
+ this.$forceUpdate()
28
+ },
29
+ orderIndicator(key, indicators){
30
+ return indicators[this.ordering[key]]
31
+ },
32
+ resetFilter: function(){
33
+ var url;
34
+ for (var key in this.filter) {
35
+ url = queryParamsHelper.updateQueryParams(this.componentConfig["id"] + "-filter-" + key, null)
36
+ this.filter[key] = null;
37
+ this.$forceUpdate();
38
+ }
39
+ window.history.pushState({matestackApp: true, url: url}, null, url);
40
+ matestackEventHub.$emit(this.componentConfig["id"] + "-update")
41
+ }
42
+ },
43
+ created: function(){
44
+ var self = this;
45
+ var queryParamsObject = queryParamsHelper.queryParamsToObject()
46
+ Object.keys(queryParamsObject).forEach(function(key){
47
+ if (key.startsWith(self.componentConfig["id"] + "-order-")){
48
+ self.ordering[key.replace(self.componentConfig["id"] + "-order-", "")] = queryParamsObject[key]
49
+ }
50
+ })
51
+ }
52
+ }
53
+
54
+ let component = Vue.component('matestack-ui-core-collection-order', componentDef)
55
+
56
+ export default componentDef
@@ -0,0 +1,17 @@
1
+ module Matestack::Ui::Core::Collection::Order
2
+ class Order < Matestack::Ui::Core::Component::Dynamic
3
+
4
+ def setup
5
+ @component_config = @component_config.except(:data, :paginated_data)
6
+ end
7
+
8
+ def response
9
+ components {
10
+ div @tag_attributes do
11
+ yield_components
12
+ end
13
+ }
14
+ end
15
+
16
+ end
17
+ end
@@ -0,0 +1,13 @@
1
+ module Matestack::Ui::Core::Collection::Order::Toggle::Indicator
2
+ class Indicator < Matestack::Ui::Core::Component::Static
3
+
4
+ def response
5
+ components {
6
+ span @tag_attributes do
7
+ plain "{{orderIndicator( '#{@component_config[:key]}', {asc: '#{@component_config[:asc]}', desc: '#{@component_config[:desc]}'} ) }}"
8
+ end
9
+ }
10
+ end
11
+
12
+ end
13
+ end
@@ -0,0 +1,3 @@
1
+ %a{@tag_attributes, "@click": "toggleOrder(\"#{@component_config[:key]}\")"}
2
+ - if block_given?
3
+ = yield
@@ -0,0 +1,5 @@
1
+ module Matestack::Ui::Core::Collection::Order::Toggle
2
+ class Toggle < Matestack::Ui::Core::Component::Static
3
+
4
+ end
5
+ end
@@ -0,0 +1,10 @@
1
+ import Vue from 'vue/dist/vue.esm'
2
+ import componentMixin from 'component/component'
3
+
4
+ const componentDef = {
5
+ mixins: [componentMixin]
6
+ }
7
+
8
+ let component = Vue.component('matestack-ui-core-anonym-dynamic-component', componentDef)
9
+
10
+ export default componentDef
@@ -0,0 +1,2 @@
1
+ - @children_cells.each do |key, cell|
2
+ = cell.call(:show)
@@ -0,0 +1,59 @@
1
+ import Vue from 'vue/dist/vue.esm'
2
+ import axios from 'axios'
3
+ import VRuntimeTemplate from "v-runtime-template"
4
+ import matestackEventHub from 'js/event-hub'
5
+
6
+ const componentMixin = {
7
+ props: ['componentConfig', 'params'],
8
+ data: function(){
9
+ return {
10
+ asyncTemplate: null
11
+ }
12
+ },
13
+ methods: {
14
+ onRerender: function(event){
15
+ if (this.$el.id === event+"__wrapper"){
16
+ this.rerender()
17
+ }
18
+ },
19
+ onMatestackUiCoreChannel: function(event){
20
+ if (this.componentConfig["rerender_on"] == event.message){
21
+ this.rerender()
22
+ }
23
+ },
24
+ rerender: function(){
25
+ var self = this;
26
+ self.params["component_key"] = self.componentConfig["component_key"]
27
+ axios({
28
+ method: "get",
29
+ url: location.pathname + location.search,
30
+ headers: {
31
+ 'X-CSRF-Token': document.getElementsByName("csrf-token")[0].getAttribute('content')
32
+ },
33
+ params: {"component_key": self.componentConfig["component_key"]}
34
+ })
35
+ .then(function(response){
36
+ self.asyncTemplate = response["data"];
37
+ })
38
+ },
39
+ rerenderWith: function(newParams){
40
+ Object.assign(this.params, newParams);
41
+ this.rerender()
42
+ }
43
+ },
44
+ created: function () {
45
+ const self = this
46
+ matestackEventHub.$on('rerender', self.onRerender)
47
+ matestackEventHub.$on('MatestackUiCoreChannel', self.onMatestackUiCoreChannel)
48
+ },
49
+ beforeDestroy: function() {
50
+ const self = this
51
+ matestackEventHub.$off('rerender', self.onRerender);
52
+ matestackEventHub.$off('MatestackUiCoreChannel', self.onMatestackUiCoreChannel)
53
+ },
54
+ components: {
55
+ VRuntimeTemplate: VRuntimeTemplate
56
+ }
57
+ }
58
+
59
+ export default componentMixin