Skip to content

Commit ea24a5b

Browse files
committed
preparing repo split into core and vue via moving vue related code to vue module, refactored app and page component
1 parent 294d109 commit ea24a5b

File tree

12 files changed

+244
-84
lines changed

12 files changed

+244
-84
lines changed

lib/matestack/ui/core.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ module Core
1212
require "#{base_path}/context"
1313
require "#{base_path}/properties"
1414
require "#{base_path}/base"
15-
require "#{base_path}/vue_attributes"
1615
require "#{base_path}/component"
1716
require "#{base_path}/page"
1817
require "#{base_path}/app"
@@ -33,7 +32,11 @@ module VueJs
3332
end
3433
end
3534

35+
require "#{vue_js_base_path}/utils"
36+
require "#{vue_js_base_path}/vue_attributes"
3637
require "#{vue_js_base_path}/vue"
38+
require "#{vue_js_base_path}/app"
39+
require "#{vue_js_base_path}/page"
3740
require "#{vue_js_base_path}/components/toggle"
3841
require "#{vue_js_base_path}/components/onclick"
3942
require "#{vue_js_base_path}/components/transition"

lib/matestack/ui/core/app.rb

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,30 @@ def initialize(options = {})
99
super(nil, nil, options)
1010
end
1111

12-
def create_children &block
13-
self.app_wrapper do
14-
self.response &block
15-
end
16-
end
17-
18-
def app_wrapper(&block)
19-
Base.new(:component, component_attributes) do
20-
div(class: 'matestack-app-wrapper', &block)
21-
end
22-
end
23-
24-
def component_attributes
25-
{
26-
is: 'matestack-ui-core-app',
27-
':params': params.to_json,
28-
'v-slot': "{ vc, vueComponent }"
29-
}
30-
end
31-
32-
def loading_state_element
33-
end
12+
# MOVED TO VUE MODULE:
13+
#
14+
# def create_children &block
15+
# self.app_wrapper do
16+
# self.response &block
17+
# end
18+
# end
19+
#
20+
# def app_wrapper(&block)
21+
# Base.new(:component, component_attributes) do
22+
# div(class: 'matestack-app-wrapper', &block)
23+
# end
24+
# end
25+
#
26+
# def component_attributes
27+
# {
28+
# is: 'matestack-ui-core-app',
29+
# ':params': params.to_json,
30+
# 'v-slot': "{ vc, vueComponent }"
31+
# }
32+
# end
33+
#
34+
# def loading_state_element
35+
# end
3436

3537

3638
# layout class method to specify if a rails layout should be used

lib/matestack/ui/core/base.rb

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def initialize(html_tag = nil, text = nil, options = {}, &block)
2828
self
2929
end
3030

31-
# can be optionally overwritten in subclass
31+
# can be optionally overwritten in subclass
3232
# in order to conditionally render the component
3333
def render?
3434
true
@@ -106,10 +106,12 @@ def method_missing(name, *args, &block)
106106
return raise NameError, "#{name} is not defined for #{self.class}", caller
107107
end
108108

109-
# give easy access to vue data attributes
110-
def vue
111-
Matestack::Ui::Core::VueAttributes
112-
end
109+
# MOVED TO VUE MODULE
110+
#
111+
# # give easy access to vue data attributes
112+
# def vue
113+
# Matestack::Ui::Core::VueAttributes
114+
# end
113115

114116
end
115117
end

lib/matestack/ui/core/page.rb

Lines changed: 45 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -7,49 +7,51 @@ def initialize(options = {})
77
super(nil, nil, options)
88
end
99

10-
def create_children
11-
self.page do
12-
self.response
13-
end
14-
end
15-
16-
def page
17-
if params[:only_page]
18-
div class: 'matestack-page-root' do
19-
yield
20-
end
21-
else
22-
Base.new(:component, component_attributes) do
23-
div class: 'matestack-page-container', 'v-bind:class': '{ "loading": vc.loading === true }' do
24-
if Matestack::Ui::Core::Context.app.respond_to? :loading_state_element
25-
div class: 'loading-state-element-wrapper', 'v-bind:class': '{ "loading": vc.loading === true }' do
26-
Matestack::Ui::Core::Context.app.loading_state_element
27-
end
28-
end
29-
div class: 'matestack-page-wrapper', 'v-bind:class': '{ "loading": vc.loading === true }' do
30-
div 'v-if': 'vc.asyncPageTemplate == null' do
31-
div class: 'matestack-page-root' do
32-
yield
33-
end
34-
end
35-
div 'v-if': 'vc.asyncPageTemplate != null' do
36-
div class: 'matestack-page-root' do
37-
Matestack::Ui::Core::Base.new('matestack-ui-core-runtime-render', ':template': 'vc.asyncPageTemplate', ':vc': 'vc', ':vue-component': 'vueComponent')
38-
end
39-
end
40-
end
41-
end
42-
end
43-
end
44-
end
45-
46-
def component_attributes
47-
{
48-
is: 'matestack-ui-core-page-content',
49-
':params': params.to_json,
50-
'v-slot': "{ vc, vueComponent }"
51-
}
52-
end
10+
# MOVED TO VUE MODULE
11+
#
12+
# def create_children
13+
# self.page do
14+
# self.response
15+
# end
16+
# end
17+
#
18+
# def page
19+
# if params[:only_page]
20+
# div class: 'matestack-page-root' do
21+
# yield
22+
# end
23+
# else
24+
# Base.new(:component, component_attributes) do
25+
# div class: 'matestack-page-container', 'v-bind:class': '{ "loading": vc.loading === true }' do
26+
# if Matestack::Ui::Core::Context.app.respond_to? :loading_state_element
27+
# div class: 'loading-state-element-wrapper', 'v-bind:class': '{ "loading": vc.loading === true }' do
28+
# Matestack::Ui::Core::Context.app.loading_state_element
29+
# end
30+
# end
31+
# div class: 'matestack-page-wrapper', 'v-bind:class': '{ "loading": vc.loading === true }' do
32+
# div 'v-if': 'vc.asyncPageTemplate == null' do
33+
# div class: 'matestack-page-root' do
34+
# yield
35+
# end
36+
# end
37+
# div 'v-if': 'vc.asyncPageTemplate != null' do
38+
# div class: 'matestack-page-root' do
39+
# Matestack::Ui::Core::Base.new('matestack-ui-core-runtime-render', ':template': 'vc.asyncPageTemplate', ':vc': 'vc', ':vue-component': 'vueComponent')
40+
# end
41+
# end
42+
# end
43+
# end
44+
# end
45+
# end
46+
# end
47+
#
48+
# def component_attributes
49+
# {
50+
# is: 'matestack-ui-core-page-content',
51+
# ':params': params.to_json,
52+
# 'v-slot': "{ vc, vueComponent }"
53+
# }
54+
# end
5355

5456
end
5557
end

lib/matestack/ui/core/tag_helper.rb

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,15 @@ def unescape(text)
3333
end
3434
alias unescaped unescape
3535

36-
def matestack(&block)
37-
div(id: 'matestack-ui') do
38-
Base.new(:component, component_attributes) do
39-
div(class: 'matestack-app-wrapper', &block)
40-
end
41-
end
42-
end
36+
# REMOVED
37+
#
38+
# def matestack(&block)
39+
# div(id: 'matestack-ui') do
40+
# Base.new(:component, component_attributes) do
41+
# div(class: 'matestack-app-wrapper', &block)
42+
# end
43+
# end
44+
# end
4345

4446
# override image in order to implement automatically using rails assets path
4547
def img(text = nil, options = {}, &block)

lib/matestack/ui/vue_js/app.rb

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
module Matestack
2+
module Ui
3+
module VueJs
4+
class App < Matestack::Ui::Core::App
5+
6+
include Matestack::Ui::VueJs::Utils
7+
8+
vue_name "matestack-ui-core-app"
9+
10+
def create_children &block
11+
self.app_wrapper do
12+
self.response &block
13+
end
14+
end
15+
16+
def app_wrapper(&block)
17+
vue_component do
18+
div(class: 'matestack-app-wrapper', &block)
19+
end
20+
end
21+
22+
def loading_state_element
23+
end
24+
25+
end
26+
end
27+
end
28+
end

lib/matestack/ui/vue_js/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import componentHelpers from './components/helpers'
88

99
import app from './app/app'
1010

11-
import pageContent from './page/content' //TODO Rename to page
11+
import page from './page/page'
1212

1313
import runtimeRender from './components/runtime_render'
1414

@@ -46,7 +46,7 @@ const registerComponents = function(appInstance){
4646
appInstance.component('matestack-ui-core-runtime-render', runtimeRender)
4747

4848
appInstance.component('matestack-ui-core-app', app)
49-
appInstance.component('matestack-ui-core-page-content', pageContent)
49+
appInstance.component('matestack-ui-core-page', page)
5050
appInstance.component('matestack-ui-core-collection-content', collectionContent)
5151
appInstance.component('matestack-ui-core-collection-filter', collectionFilter)
5252
appInstance.component('matestack-ui-core-collection-order', collectionOrder)

lib/matestack/ui/vue_js/initialize.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,9 @@ class Matestack::Ui::Core::Base
22

33
include Matestack::Ui::VueJs::Components
44

5-
end
5+
# give easy access to vue data attributes
6+
def vue
7+
Matestack::Ui::VueJs::VueAttributes
8+
end
9+
10+
end

lib/matestack/ui/vue_js/page.rb

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
module Matestack
2+
module Ui
3+
module VueJs
4+
class Page < Matestack::Ui::Core::Page
5+
6+
include Matestack::Ui::VueJs::Utils
7+
8+
vue_name "matestack-ui-core-page"
9+
10+
def create_children
11+
self.page do
12+
self.response
13+
end
14+
end
15+
16+
def page
17+
if params[:only_page]
18+
div class: 'matestack-page-root' do
19+
yield
20+
end
21+
else
22+
vue_component do
23+
div class: 'matestack-page-container', 'v-bind:class': '{ "loading": vc.loading === true }' do
24+
if Matestack::Ui::Core::Context.app.respond_to? :loading_state_element
25+
div class: 'loading-state-element-wrapper', 'v-bind:class': '{ "loading": vc.loading === true }' do
26+
Matestack::Ui::Core::Context.app.loading_state_element
27+
end
28+
end
29+
div class: 'matestack-page-wrapper', 'v-bind:class': '{ "loading": vc.loading === true }' do
30+
div 'v-if': 'vc.asyncPageTemplate == null' do
31+
div class: 'matestack-page-root' do
32+
yield
33+
end
34+
end
35+
div 'v-if': 'vc.asyncPageTemplate != null' do
36+
div class: 'matestack-page-root' do
37+
Matestack::Ui::Core::Base.new('matestack-ui-core-runtime-render', ':template': 'vc.asyncPageTemplate', ':vc': 'vc', ':vue-component': 'vueComponent')
38+
end
39+
end
40+
end
41+
end
42+
end
43+
end
44+
end
45+
46+
end
47+
end
48+
end
49+
end

0 commit comments

Comments
 (0)