matestack-ui-core 2.1.1 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -1
  3. data/README.md +15 -478
  4. data/lib/matestack/ui/core/base.rb +17 -8
  5. data/lib/matestack/ui/core/context.rb +2 -2
  6. data/lib/matestack/ui/core/helper.rb +29 -29
  7. data/lib/matestack/ui/core/{app.rb → layout.rb} +6 -17
  8. data/lib/matestack/ui/core/page.rb +0 -44
  9. data/lib/matestack/ui/core/tag_helper.rb +17 -10
  10. data/lib/matestack/ui/core/version.rb +1 -1
  11. data/lib/matestack/ui/core.rb +2 -47
  12. data/lib/matestack/ui/layout.rb +1 -0
  13. data/lib/matestack/ui/page.rb +1 -1
  14. metadata +4 -67
  15. data/lib/matestack/ui/app.rb +0 -1
  16. data/lib/matestack/ui/core/vue_attributes.rb +0 -13
  17. data/lib/matestack/ui/vue_js/app/app.js +0 -40
  18. data/lib/matestack/ui/vue_js/app/location.js +0 -9
  19. data/lib/matestack/ui/vue_js/app/store.js +0 -103
  20. data/lib/matestack/ui/vue_js/components/action.js +0 -151
  21. data/lib/matestack/ui/vue_js/components/action.rb +0 -46
  22. data/lib/matestack/ui/vue_js/components/async.js +0 -110
  23. data/lib/matestack/ui/vue_js/components/async.rb +0 -84
  24. data/lib/matestack/ui/vue_js/components/cable.js +0 -100
  25. data/lib/matestack/ui/vue_js/components/cable.rb +0 -69
  26. data/lib/matestack/ui/vue_js/components/collection/content.js +0 -97
  27. data/lib/matestack/ui/vue_js/components/collection/content.rb +0 -32
  28. data/lib/matestack/ui/vue_js/components/collection/filter.js +0 -46
  29. data/lib/matestack/ui/vue_js/components/collection/filter.rb +0 -29
  30. data/lib/matestack/ui/vue_js/components/collection/filter_reset.rb +0 -19
  31. data/lib/matestack/ui/vue_js/components/collection/helper.rb +0 -128
  32. data/lib/matestack/ui/vue_js/components/collection/next.rb +0 -19
  33. data/lib/matestack/ui/vue_js/components/collection/order.js +0 -46
  34. data/lib/matestack/ui/vue_js/components/collection/order.rb +0 -28
  35. data/lib/matestack/ui/vue_js/components/collection/order_toggle.rb +0 -21
  36. data/lib/matestack/ui/vue_js/components/collection/order_toggle_indicator.rb +0 -30
  37. data/lib/matestack/ui/vue_js/components/collection/page.rb +0 -21
  38. data/lib/matestack/ui/vue_js/components/collection/previous.rb +0 -19
  39. data/lib/matestack/ui/vue_js/components/form/base.rb +0 -171
  40. data/lib/matestack/ui/vue_js/components/form/checkbox.js +0 -15
  41. data/lib/matestack/ui/vue_js/components/form/checkbox.rb +0 -105
  42. data/lib/matestack/ui/vue_js/components/form/checkbox_mixin.js +0 -70
  43. data/lib/matestack/ui/vue_js/components/form/context.rb +0 -15
  44. data/lib/matestack/ui/vue_js/components/form/fields_for_add_item.rb +0 -35
  45. data/lib/matestack/ui/vue_js/components/form/fields_for_remove_item.rb +0 -19
  46. data/lib/matestack/ui/vue_js/components/form/form.js +0 -473
  47. data/lib/matestack/ui/vue_js/components/form/form.rb +0 -84
  48. data/lib/matestack/ui/vue_js/components/form/input.js +0 -15
  49. data/lib/matestack/ui/vue_js/components/form/input.rb +0 -42
  50. data/lib/matestack/ui/vue_js/components/form/input_mixin.js +0 -53
  51. data/lib/matestack/ui/vue_js/components/form/radio.js +0 -15
  52. data/lib/matestack/ui/vue_js/components/form/radio.rb +0 -76
  53. data/lib/matestack/ui/vue_js/components/form/radio_mixin.js +0 -55
  54. data/lib/matestack/ui/vue_js/components/form/select.js +0 -15
  55. data/lib/matestack/ui/vue_js/components/form/select.rb +0 -88
  56. data/lib/matestack/ui/vue_js/components/form/select_mixin.js +0 -55
  57. data/lib/matestack/ui/vue_js/components/form/textarea.js +0 -15
  58. data/lib/matestack/ui/vue_js/components/form/textarea.rb +0 -37
  59. data/lib/matestack/ui/vue_js/components/form/textarea_mixin.js +0 -37
  60. data/lib/matestack/ui/vue_js/components/isolated.js +0 -108
  61. data/lib/matestack/ui/vue_js/components/isolated.rb +0 -86
  62. data/lib/matestack/ui/vue_js/components/mixin.js +0 -22
  63. data/lib/matestack/ui/vue_js/components/onclick.js +0 -19
  64. data/lib/matestack/ui/vue_js/components/onclick.rb +0 -37
  65. data/lib/matestack/ui/vue_js/components/toggle.js +0 -71
  66. data/lib/matestack/ui/vue_js/components/toggle.rb +0 -38
  67. data/lib/matestack/ui/vue_js/components/transition.js +0 -42
  68. data/lib/matestack/ui/vue_js/components/transition.rb +0 -40
  69. data/lib/matestack/ui/vue_js/components.rb +0 -111
  70. data/lib/matestack/ui/vue_js/event_hub.js +0 -5
  71. data/lib/matestack/ui/vue_js/helpers/query_params_helper.js +0 -56
  72. data/lib/matestack/ui/vue_js/index.js +0 -52
  73. data/lib/matestack/ui/vue_js/initialize.rb +0 -5
  74. data/lib/matestack/ui/vue_js/page/content.js +0 -23
  75. data/lib/matestack/ui/vue_js/vue.rb +0 -63
  76. data/lib/matestack/ui/vue_js_component.rb +0 -2
@@ -1,71 +0,0 @@
1
- import Vue from 'vue/dist/vue.esm'
2
- import matestackEventHub from '../event_hub'
3
- import componentMixin from './mixin'
4
-
5
- const componentDef = {
6
- mixins: [componentMixin],
7
- data: function(){
8
- return {
9
- showing: true,
10
- hide_after_timeout: null,
11
- event: {
12
- data: {}
13
- }
14
- }
15
- },
16
- methods: {
17
- show: function(event_data){
18
- const self = this
19
- if (this.showing === true){
20
- return
21
- }
22
- this.showing = true
23
- this.event.data = event_data
24
- if(this.props["hide_after"] != undefined){
25
- self.hide_after_timeout = setTimeout(function () {
26
- self.hide()
27
- }, parseInt(this.props["hide_after"]));
28
- }
29
- },
30
- hide: function(){
31
- this.showing = false
32
- this.event.data = {}
33
- }
34
- },
35
- created: function () {
36
- const self = this
37
- if(this.props["show_on"] != undefined){
38
- this.showing = false
39
- var show_events = this.props["show_on"].split(",")
40
- show_events.forEach(show_event => matestackEventHub.$on(show_event.trim(), self.show));
41
- }
42
- if(this.props["hide_on"] != undefined){
43
- var hide_events = this.props["hide_on"].split(",")
44
- hide_events.forEach(hide_event => matestackEventHub.$on(hide_event.trim(), self.hide));
45
- }
46
- if(this.props["show_on"] != undefined){
47
- this.showing = false
48
- }
49
- if(this.props["init_show"] == true){
50
- this.showing = true
51
- }
52
- },
53
- beforeDestroy: function() {
54
- const self = this
55
- clearTimeout(self.hide_after_timeout)
56
- matestackEventHub.$off(this.props["show_on"], self.show);
57
- matestackEventHub.$off(this.props["hide_on"], self.hide);
58
- if(this.props["show_on"] != undefined){
59
- var shown_events = this.props["show_on"].split(",")
60
- shown_events.forEach(show_event => matestackEventHub.$off(show_event.trim(), self.show));
61
- }
62
- if(this.props["hide_on"] != undefined){
63
- var hiden_events = this.props["hide_on"].split(",")
64
- hiden_events.forEach(hide_event => matestackEventHub.$off(hide_event.trim(), self.hide));
65
- }
66
- },
67
- }
68
-
69
- let component = Vue.component('matestack-ui-core-toggle', componentDef)
70
-
71
- export default componentDef
@@ -1,38 +0,0 @@
1
- module Matestack
2
- module Ui
3
- module VueJs
4
- module Components
5
- class Toggle < Matestack::Ui::VueJs::Vue
6
- vue_name 'matestack-ui-core-toggle'
7
-
8
- optional :show_on, :hide_on, :hide_after, :init_show
9
-
10
- def response
11
- div toggle_attributes do
12
- yield
13
- end
14
- end
15
-
16
- def toggle_attributes
17
- options.merge({
18
- class: "matestack-toggle-component-root",
19
- 'v-if': 'showing'
20
- })
21
- end
22
-
23
- protected
24
-
25
- def vue_props
26
- {
27
- show_on: ctx.show_on,
28
- hide_on: ctx.hide_on,
29
- hide_after: ctx.hide_after,
30
- init_show: ctx.init_show,
31
- }
32
- end
33
-
34
- end
35
- end
36
- end
37
- end
38
- end
@@ -1,42 +0,0 @@
1
- import Vue from 'vue/dist/vue.esm'
2
- import Vuex from 'vuex'
3
- import componentMixin from './mixin'
4
- import matestackEventHub from '../event_hub'
5
-
6
- const componentDef = {
7
- mixins: [componentMixin],
8
- data: function(){
9
- return {}
10
- },
11
- computed: Vuex.mapState({
12
- isActive (state) {
13
- return (this.props["link_path"].split("?")[0]) === state.currentPathName
14
- },
15
- isChildActive (state) {
16
- return ((this.props["link_path"].split("?")[0]) !== state.currentPathName) && (state.currentPathName.indexOf(this.props["link_path"].split("?")[0]) !== -1)
17
- }
18
- }),
19
- methods: {
20
- navigateTo: function(url){
21
- const self = this
22
- matestackEventHub.$emit("page_loading_triggered", url);
23
- this.$store.commit('setPageLoading', true);
24
- if (self.props["delay"] != undefined) {
25
- setTimeout(function () {
26
- self.performNavigation(url)
27
- }, parseInt(self.props["delay"]));
28
- } else {
29
- this.performNavigation(url)
30
- }
31
- },
32
- performNavigation: function(url){
33
- this.$store.dispatch('navigateTo', {url: url, backwards: false}).then((response) => {
34
- // self.asyncTemplate = response;
35
- })
36
- }
37
- }
38
- }
39
-
40
- let component = Vue.component('matestack-ui-core-transition', componentDef)
41
-
42
- export default componentDef
@@ -1,40 +0,0 @@
1
- module Matestack
2
- module Ui
3
- module VueJs
4
- module Components
5
- class Transition < Matestack::Ui::VueJs::Vue
6
- vue_name 'matestack-ui-core-transition'
7
-
8
- optional :path, :delay
9
-
10
- def response
11
- a attributes do
12
- if block_given?
13
- yield
14
- end
15
- plain self.text if self.text
16
- end
17
- end
18
-
19
- protected
20
-
21
- def attributes
22
- options.merge({
23
- href: ctx.path,
24
- '@click.prevent': "navigateTo(\"#{ctx.path}\")",
25
- "v-bind:class": "{ active: isActive, 'active-child': isChildActive }"
26
- })
27
- end
28
-
29
- def vue_props
30
- {
31
- link_path: ctx.path,
32
- delay: ctx.delay,
33
- }
34
- end
35
-
36
- end
37
- end
38
- end
39
- end
40
- end
@@ -1,111 +0,0 @@
1
- module Matestack
2
- module Ui
3
- module VueJs
4
- module Components
5
-
6
- def toggle(text=nil, options=nil, &block)
7
- Matestack::Ui::VueJs::Components::Toggle.(text, options, &block)
8
- end
9
-
10
- def onclick(text=nil, options=nil, &block)
11
- Matestack::Ui::VueJs::Components::Onclick.(text, options, &block)
12
- end
13
-
14
- def transition(text=nil, options=nil, &block)
15
- Matestack::Ui::VueJs::Components::Transition.(text, options, &block)
16
- end
17
-
18
- def async(text=nil, options=nil, &block)
19
- Matestack::Ui::VueJs::Components::Async.(text, options, &block)
20
- end
21
-
22
- def action(text=nil, options=nil, &block)
23
- Matestack::Ui::VueJs::Components::Action.(text, options, &block)
24
- end
25
-
26
- def cable(text=nil, options=nil, &block)
27
- Matestack::Ui::VueJs::Components::Cable.(text, options, &block)
28
- end
29
-
30
- def matestack_form(text=nil, options=nil, &block)
31
- Matestack::Ui::VueJs::Components::Form::Form.(text, options, &block)
32
- end
33
-
34
- def form_fields_for(text=nil, options=nil, &block)
35
- # in order to provide a more intuitiv API while calling the default
36
- # form, we transform the arguments a bit:
37
- options[:for] = text
38
- options[:fields_for] = options.delete(:key)
39
- text = nil
40
- Matestack::Ui::VueJs::Components::Form::Form.(text, options, &block)
41
- end
42
-
43
- def form_fields_for_remove_item(text=nil, options=nil, &block)
44
- Matestack::Ui::VueJs::Components::Form::FieldsForRemoveItem.(text, options, &block)
45
- end
46
-
47
- def form_fields_for_add_item(text=nil, options=nil, &block)
48
- Matestack::Ui::VueJs::Components::Form::FieldsForAddItem.(text, options, &block)
49
- end
50
-
51
- def form_input(text=nil, options=nil, &block)
52
- Matestack::Ui::VueJs::Components::Form::Input.(text, options, &block)
53
- end
54
-
55
- def form_textarea(text=nil, options=nil, &block)
56
- Matestack::Ui::VueJs::Components::Form::Textarea.(text, options, &block)
57
- end
58
-
59
- def form_checkbox(text=nil, options=nil, &block)
60
- Matestack::Ui::VueJs::Components::Form::Checkbox.(text, options, &block)
61
- end
62
-
63
- def form_radio(text=nil, options=nil, &block)
64
- Matestack::Ui::VueJs::Components::Form::Radio.(text, options, &block)
65
- end
66
-
67
- def form_select(text=nil, options=nil, &block)
68
- Matestack::Ui::VueJs::Components::Form::Select.(text, options, &block)
69
- end
70
-
71
- def collection_content(text=nil, options=nil, &block)
72
- Matestack::Ui::VueJs::Components::Collection::Content.(text, options, &block)
73
- end
74
-
75
- def collection_filter(text=nil, options=nil, &block)
76
- Matestack::Ui::VueJs::Components::Collection::Filter.(text, options, &block)
77
- end
78
-
79
- def collection_filter_reset(text=nil, options=nil, &block)
80
- Matestack::Ui::VueJs::Components::Collection::FilterReset.(text, options, &block)
81
- end
82
-
83
- def collection_order(text=nil, options=nil, &block)
84
- Matestack::Ui::VueJs::Components::Collection::Order.(text, options, &block)
85
- end
86
-
87
- def collection_order_toggle(text=nil, options=nil, &block)
88
- Matestack::Ui::VueJs::Components::Collection::OrderToggle.(text, options, &block)
89
- end
90
-
91
- def collection_order_toggle_indicator(text=nil, options=nil, &block)
92
- Matestack::Ui::VueJs::Components::Collection::OrderToggleIndicator.(text, options, &block)
93
- end
94
-
95
- def collection_content_next(text=nil, options=nil, &block)
96
- Matestack::Ui::VueJs::Components::Collection::Next.(text, options, &block)
97
- end
98
-
99
- def collection_content_previous(text=nil, options=nil, &block)
100
- Matestack::Ui::VueJs::Components::Collection::Previous.(text, options, &block)
101
- end
102
-
103
- def collection_content_page_link(text=nil, options=nil, &block)
104
- Matestack::Ui::VueJs::Components::Collection::Page.(text, options, &block)
105
- end
106
-
107
-
108
- end
109
- end
110
- end
111
- end
@@ -1,5 +0,0 @@
1
- import Vue from 'vue/dist/vue.esm'
2
-
3
- const eventHub = new Vue();
4
-
5
- export default eventHub
@@ -1,56 +0,0 @@
1
- const updateQueryParams = (key, value, url) => {
2
- if (!url) url = window.location.href;
3
- let re = new RegExp(`([?&])${key}=.*?(&|#|$)(.*)`, "gi"), hash;
4
-
5
- if (re.test(url)) {
6
- if (typeof value !== 'undefined' && value !== null)
7
- return url.replace(re, `$1${key}=${value}$2$3`);
8
- else {
9
- hash = url.split('#');
10
- url = hash[0].replace(re, '$1$3').replace(/(&|\?)$/, '');
11
- if (typeof hash[1] !== 'undefined' && hash[1] !== null)
12
- url += `#${hash[1]}`;
13
- return url;
14
- }
15
- }
16
- else {
17
- if (typeof value !== 'undefined' && value !== null) {
18
- const separator = url.indexOf('?') !== -1 ? '&' : '?';
19
- hash = url.split('#');
20
- url = `${hash[0]}${separator}${key}=${value}`;
21
- if (typeof hash[1] !== 'undefined' && hash[1] !== null)
22
- url += `#${hash[1]}`;
23
- return url;
24
- }
25
- else
26
- return url;
27
- }
28
- };
29
-
30
- const getQueryParam = (name, url) => {
31
- if (!url) url = window.location.href;
32
- name = name.replace(/[\[\]]/g, '\\$&');
33
- const regex = new RegExp(`[?&]${name}(=([^&#]*)|&|#|$)`), results = regex.exec(url);
34
- if (!results) return null;
35
- if (!results[2]) return '';
36
- return decodeURIComponent(results[2].replace(/\+/g, ' '));
37
- };
38
-
39
- const queryParamsToObject = () => {
40
- const search = window.location.search.substring(1);
41
- if(search.length === 0){
42
- return {}
43
- } else {
44
- const result = JSON.parse(
45
- `{"${search.replace(/&/g, '","').replace(/=/g,'":"')}"}`,
46
- (key, value) => { return key===""?value:decodeURIComponent(value) }
47
- );
48
- return result;
49
- }
50
- };
51
-
52
- export default {
53
- updateQueryParams: updateQueryParams,
54
- getQueryParam: getQueryParam,
55
- queryParamsToObject: queryParamsToObject
56
- }
@@ -1,52 +0,0 @@
1
- // import Vue from 'vue/dist/vue.esm'
2
- // import Vuex from 'vuex'
3
- // import axios from 'axios'
4
-
5
- import eventHub from './event_hub'
6
-
7
- const matestackEventHub = eventHub // for compatibility with 1.x
8
-
9
- import componentMixin from './components/mixin'
10
-
11
- import app from './app/app'
12
- import store from './app/store'
13
-
14
- import pageContent from './page/content' //TODO Rename to page
15
-
16
- import collectionContent from './components/collection/content'
17
- import collectionFilter from './components/collection/filter'
18
- import collectionOrder from './components/collection/order'
19
-
20
- import toggle from './components/toggle'
21
- import onclick from './components/onclick'
22
- import transition from './components/transition'
23
- import async from './components/async'
24
- import action from './components/action'
25
- import cable from './components/cable'
26
- import isolate from './components/isolated'
27
- import form from './components/form/form'
28
- import formCheckbox from './components/form/checkbox'
29
- import formInput from './components/form/input'
30
- import formRadio from './components/form/radio'
31
- import formSelect from './components/form/select'
32
- import formTextarea from './components/form/textarea'
33
-
34
- import formInputMixin from './components/form/input_mixin'
35
- import formSelectMixin from './components/form/select_mixin'
36
- import formRadioMixin from './components/form/radio_mixin'
37
- import formCheckboxMixin from './components/form/checkbox_mixin'
38
- import formTextareaMixin from './components/form/textarea_mixin'
39
-
40
- const MatestackUiCore = {
41
- store,
42
- eventHub,
43
- matestackEventHub, // for compatibility with 1.x
44
- componentMixin,
45
- formInputMixin,
46
- formSelectMixin,
47
- formCheckboxMixin,
48
- formTextareaMixin,
49
- formRadioMixin
50
- }
51
-
52
- export default MatestackUiCore
@@ -1,5 +0,0 @@
1
- class Matestack::Ui::Core::Base
2
-
3
- include Matestack::Ui::VueJs::Components
4
-
5
- end
@@ -1,23 +0,0 @@
1
- import Vue from 'vue/dist/vue.esm'
2
- import Vuex from 'vuex'
3
- import componentMixin from '../components/mixin'
4
-
5
- import VRuntimeTemplate from "v-runtime-template"
6
-
7
- const componentDef = {
8
- mixins: [componentMixin],
9
- data: function(){
10
- return {}
11
- },
12
- computed: Vuex.mapState({
13
- asyncPageTemplate: state => state.pageTemplate,
14
- loading: state => state.pageLoading
15
- }),
16
- components: {
17
- VRuntimeTemplate: VRuntimeTemplate
18
- }
19
- }
20
-
21
- let component = Vue.component('matestack-ui-core-page-content', componentDef)
22
-
23
- export default componentDef
@@ -1,63 +0,0 @@
1
- module Matestack
2
- module Ui
3
- module VueJs
4
- class Vue < Matestack::Ui::Component
5
-
6
- def initialize(html_tag = nil, text = nil, options = {}, &block)
7
- extract_options(text, options)
8
- super(html_tag, text, options, &block)
9
- end
10
-
11
- def create_children(&block)
12
- vue_component do
13
- self.response do
14
- block.call if block_given?
15
- end
16
- end
17
- end
18
-
19
- def vue_component(&block)
20
- Matestack::Ui::Core::Base.new(:component, component_attributes, &block)
21
- end
22
-
23
- def component_attributes
24
- {
25
- is: vue_name,
26
- ref: component_id,
27
- ':params': params.to_json,
28
- ':props': self.vue_props.to_json,
29
- 'inline-template': true
30
- }
31
- end
32
-
33
- def component_id
34
- options[:id] || nil
35
- end
36
-
37
- def vue_props
38
- # raise "config needs to be overwritten by #{self.class}"
39
- end
40
- alias :config :vue_props
41
-
42
- def vue_props
43
- # raise "config needs to be overwritten by #{self.class}"
44
- end
45
-
46
- def self.vue_name(name = nil)
47
- name ? @vue_name = name : @vue_name
48
- end
49
-
50
- def vue_name
51
- raise "vue_name missing for #{self.class}" unless self.class.vue_name
52
- self.class.vue_name
53
- end
54
-
55
- def self.inherited(subclass)
56
- subclass.vue_name(self.vue_name)
57
- super
58
- end
59
-
60
- end
61
- end
62
- end
63
- end
@@ -1,2 +0,0 @@
1
- Matestack::Ui::VueJsComponent = Matestack::Ui::VueJs::Vue
2
- Matestack::Ui::IsolatedComponent = Matestack::Ui::VueJs::Components::Isolated