Skip to content

Commit d677004

Browse files
committed
finalized preparation of repo/gem split, various refactorings, prepared version bumps
1 parent ea24a5b commit d677004

31 files changed

+164
-158
lines changed

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
matestack-ui-core (2.1.1)
4+
matestack-ui-core (3.0.0)
55
rails (>= 5.2)
66

77
GEM

lib/matestack/ui/app.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Matestack::Ui::App = Matestack::Ui::Core::App
1+
Matestack::Ui::App = Matestack::Ui::Core::Layout

lib/matestack/ui/core.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@ module Core
1414
require "#{base_path}/base"
1515
require "#{base_path}/component"
1616
require "#{base_path}/page"
17-
require "#{base_path}/app"
17+
require "#{base_path}/layout"
1818
require "#{base_path}/helper"
1919

2020
# require abbreveations for apps, pages and components
21-
require "matestack/ui/app"
21+
require "matestack/ui/app" # deprecated
22+
require "matestack/ui/layout"
2223
require "matestack/ui/page"
2324
require "matestack/ui/component"
2425

@@ -35,8 +36,8 @@ module VueJs
3536
require "#{vue_js_base_path}/utils"
3637
require "#{vue_js_base_path}/vue_attributes"
3738
require "#{vue_js_base_path}/vue"
38-
require "#{vue_js_base_path}/app"
39-
require "#{vue_js_base_path}/page"
39+
require "#{vue_js_base_path}/components/app"
40+
require "#{vue_js_base_path}/components/page_switch"
4041
require "#{vue_js_base_path}/components/toggle"
4142
require "#{vue_js_base_path}/components/onclick"
4243
require "#{vue_js_base_path}/components/transition"
@@ -70,3 +71,4 @@ module VueJs
7071

7172
# require abbreveations for apps, pages and components
7273
require "matestack/ui/vue_js_component"
74+
require "matestack/ui/isolated_component"

lib/matestack/ui/core/helper.rb

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,22 @@ module Matestack
22
module Ui
33
module Core
44
module Helper
5-
5+
66
def self.included(base)
77
base.extend ClassMethods
88
end
9-
9+
1010
module ClassMethods
1111
def inherited(subclass)
12-
subclass.matestack_app(@matestack_app)
12+
subclass.matestack_layout(@matestack_layout)
1313
super
1414
end
15-
16-
def matestack_app(app = nil)
17-
@matestack_app = app ? app : @matestack_app
15+
16+
def matestack_layout(layout = nil)
17+
@matestack_layout = layout ? layout : @matestack_layout
1818
end
1919
end
20-
20+
2121
def render(*args)
2222
setup_context
2323
if args.first.is_a?(Class) && args.first.ancestors.include?(Base)
@@ -30,62 +30,62 @@ def render(*args)
3030
end
3131

3232
options = args.second || {}
33-
app = options.delete(:matestack_app) || self.class.matestack_app
33+
layout = options.delete(:matestack_layout) || self.class.matestack_layout
3434
page = args.first
3535

3636
if controller_layout == false
37-
layout = app ? app.layout : false
37+
root_layout = layout ? layout.layout : false
3838
else
3939
if controller_layout.nil?
40-
layout = "application"
40+
root_layout = "application"
4141
else
42-
layout = controller_layout
42+
root_layout = controller_layout
4343
end
4444
end
45-
46-
if app && params[:only_page].nil? && params[:component_key].nil? && params[:component_class].nil?
47-
render_app app, page, options, layout
45+
46+
if layout && params[:only_page].nil? && params[:component_key].nil? && params[:component_class].nil?
47+
render_layout layout, page, options, root_layout
4848
else
4949
if params[:component_key] && params[:component_class].nil?
50-
render_component app, page, params[:component_key], options
50+
render_component layout, page, params[:component_key], options
5151
elsif params[:component_class]
5252
if params[:component_key]
5353
render_component nil, params[:component_class].constantize, params[:component_key], JSON.parse(params[:public_options] || '{}')
54-
else
54+
else
5555
render html: params[:component_class].constantize.(public_options: JSON.parse(params[:public_options] || '{}'))
5656
end
5757
else
5858
if params[:only_page]
5959
render_page page, options, false
6060
else
61-
render_page page, options, layout
61+
render_page page, options, root_layout
6262
end
6363
end
6464
end
6565
else
6666
super
6767
end
6868
end
69-
70-
def render_app(app, page, options, layout)
71-
render html: app.new(options) { page.new(options) }.render_content.html_safe, layout: layout
69+
70+
def render_layout(layout, page, options, root_layout)
71+
render html: layout.new(options) { page.new(options) }.render_content.html_safe, layout: root_layout
7272
end
73-
74-
def render_page(page, options, layout)
75-
render html: page.new(options).render_content.html_safe, layout: layout
73+
74+
def render_page(page, options, root_layout)
75+
render html: page.new(options).render_content.html_safe, layout: root_layout
7676
end
77-
78-
def render_component(app, page, component_key, options)
79-
app ? app.new(options) { page.new(options) } : page.new(options) # create page structure in order to later access registered async components
77+
78+
def render_component(layout, page, component_key, options)
79+
layout ? layout.new(options) { page.new(options) } : page.new(options) # create page structure in order to later access registered async components
8080
render html: Matestack::Ui::Core::Context.async_components[component_key].render_content.html_safe, layout: false
8181
end
82-
82+
8383
def setup_context
8484
Matestack::Ui::Core::Context.params = self.params
8585
Matestack::Ui::Core::Context.controller = (self.class <= ActionController::Base) ? self : @_controller
8686
end
87-
87+
8888
end
8989
end
9090
end
91-
end
91+
end

lib/matestack/ui/core/app.rb renamed to lib/matestack/ui/core/layout.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module Matestack
22
module Ui
33
module Core
4-
class App < Base
4+
class Layout < Base
55

66
def initialize(options = {})
77
@controller = Context.controller

lib/matestack/ui/core/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module Matestack
22
module Ui
33
module Core
4-
VERSION = '2.1.1'
4+
VERSION = '3.0.0'
55
end
66
end
77
end
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Matestack::Ui::IsolatedComponent = Matestack::Ui::VueJs::Components::Isolated

lib/matestack/ui/layout.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Matestack::Ui::Layout = Matestack::Ui::Core::Layout

lib/matestack/ui/page.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Matestack::Ui::Page = Matestack::Ui::Core::Page
1+
Matestack::Ui::Page = Matestack::Ui::Core::Page

lib/matestack/ui/vue_js/app.rb

Lines changed: 0 additions & 28 deletions
This file was deleted.

lib/matestack/ui/vue_js/app/location.js

Lines changed: 0 additions & 9 deletions
This file was deleted.

lib/matestack/ui/vue_js/components.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@ module Ui
33
module VueJs
44
module Components
55

6+
def matestack_vue_js_app(text=nil, options=nil, &block)
7+
Matestack::Ui::VueJs::Components::App.(text, options, &block)
8+
end
9+
10+
def page_switch(text=nil, options=nil, &block)
11+
Matestack::Ui::VueJs::Components::PageSwitch.(text, options, &block)
12+
end
13+
614
def toggle(text=nil, options=nil, &block)
715
Matestack::Ui::VueJs::Components::Toggle.(text, options, &block)
816
end
@@ -104,7 +112,6 @@ def collection_content_page_link(text=nil, options=nil, &block)
104112
Matestack::Ui::VueJs::Components::Collection::Page.(text, options, &block)
105113
end
106114

107-
108115
end
109116
end
110117
end

lib/matestack/ui/vue_js/app/app.js renamed to lib/matestack/ui/vue_js/components/app.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import { computed } from 'vue'
22
import axios from 'axios'
33

4-
import isNavigatingToAnotherPage from "./location"
54
import matestackEventHub from '../event_hub'
65

7-
import componentMixin from '../components/mixin'
8-
import componentHelpers from '../components/helpers'
6+
import componentMixin from './mixin'
7+
import componentHelpers from './helpers'
98

109
const componentDef = {
1110
mixins: [componentMixin],
@@ -34,7 +33,7 @@ const componentDef = {
3433
mounted: function(){
3534
const self = this;
3635
window.addEventListener("popstate", (event) => {
37-
if (isNavigatingToAnotherPage({
36+
if (this.isNavigatingToAnotherPage({
3837
origin: self.currentOrigin,
3938
pathName: self.currentPathName,
4039
search: self.currentSearch
@@ -73,7 +72,7 @@ const componentDef = {
7372
resolve(response["data"]);
7473
self.pageTemplate = response["data"]
7574
self.setCurrentLocation({ path: url.split("?")[0], search: document.location.search, origin: document.location.origin })
76-
self.pageLoading = true
75+
self.pageLoading = false
7776
self.pageScrollTop()
7877
matestackEventHub.$emit("page_loaded", url);
7978
}, 5);
@@ -110,6 +109,12 @@ const componentDef = {
110109
if(scrollParent){
111110
scrollParent.scrollTop = 0;
112111
}
112+
},
113+
isNavigatingToAnotherPage(currentLocation, targetLocation) {
114+
// omits hash by design
115+
return currentLocation.pathName !== targetLocation.pathname ||
116+
currentLocation.origin !== targetLocation.origin ||
117+
currentLocation.search !== targetLocation.search
113118
}
114119
}
115120
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
module Matestack
2+
module Ui
3+
module VueJs
4+
module Components
5+
class App < Matestack::Ui::VueJs::Vue
6+
7+
optional :id
8+
9+
vue_name "matestack-ui-core-app"
10+
11+
# def create_children &block
12+
# div id: context.id || "matestack-ui" do
13+
# vue_component do
14+
# self.response &block
15+
# end
16+
# end
17+
# end
18+
19+
def response
20+
div class: 'matestack-app-wrapper' do
21+
yield
22+
end
23+
end
24+
25+
#
26+
# # def create_children &block
27+
# # self.app_wrapper do
28+
# # self.response &block
29+
# # end
30+
# # end
31+
#
32+
# def app_wrapper
33+
# vue_component do
34+
# div class: 'matestack-app-wrapper' do
35+
# yield
36+
# end
37+
# end
38+
# end
39+
40+
def loading_state_element
41+
end
42+
end
43+
end
44+
end
45+
end
46+
end

lib/matestack/ui/vue_js/components/async.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ const componentDef = {
6969
self.asyncTemplate = template;
7070
})
7171
.catch(function(error){
72-
console.log(error)
7372
matestackEventHub.$emit('async_rerender_error', { id: self.props["component_key"] })
7473
})
7574
}

lib/matestack/ui/vue_js/components/async.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def response
3939
end
4040
end
4141
div class: 'matestack-async-component-wrapper', 'v-if': 'vc.asyncTemplate != null', 'v-bind:class': '{ "loading": vc.loading === true }' do
42-
Matestack::Ui::Core::Base.new('matestack-ui-core-runtime-render', ':template': 'vc.asyncTemplate', ':vc': 'vc', ':vue-component': 'vueComponent')
42+
Matestack::Ui::Core::Base.new('matestack-ui-core-runtime-render', ':template': 'vc.asyncTemplate', ':vc': 'vc')
4343
end
4444
end
4545
end

lib/matestack/ui/vue_js/components/cable.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def component_attributes
2929
def response
3030
div container_attributes do
3131
div wrapper_attributes do
32-
Matestack::Ui::Core::Base.new('matestack-ui-core-runtime-render', ':template': 'vc.cableTemplate', ':vc': 'vc', ':vue-component': 'vueComponent')
32+
Matestack::Ui::Core::Base.new('matestack-ui-core-runtime-render', ':template': 'vc.cableTemplate', ':vc': 'vc')
3333
end
3434
end
3535
end

lib/matestack/ui/vue_js/components/form/fields_for_add_item.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def create_children(&block)
2121

2222
def response
2323
div id: "prototype-template-for-#{context.key}", "v-pre": true, data: { ":template": self.prototype_template_json }
24-
Matestack::Ui::Core::Base.new('matestack-ui-core-runtime-render', ':template': "vc.parentNestedFormRuntimeTemplates['#{context.key}']", ':vc': 'vc', ':vue-component': 'vueComponent')
24+
Matestack::Ui::Core::Base.new('matestack-ui-core-runtime-render', ':template': "vc.parentNestedFormRuntimeTemplates['#{context.key}']", ':vc': 'vc')
2525
a class: 'matestack-ui-core-form-fields-for-add-item', "@click.prevent": "vc.addItem('#{context.key}')" do
2626
yield if block_given?
2727
end
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const componentHelpers = {
2-
inlineTemplate: '<slot :vc="vc" :vue-component="vueComponent"></slot>' // can not be mixed in
2+
inlineTemplate: '<slot :vc="vc"></slot>' // can not be mixed in
33
}
44

55
export default componentHelpers

lib/matestack/ui/vue_js/components/isolated.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def isolated
4545
end
4646
div class: 'matestack-isolated-component-wrapper', 'v-if': 'vc.isolatedTemplate != null', 'v-bind:class': '{ loading: vc.loading === true }' do
4747
div class: 'matestack-isolated-component-root' do
48-
Matestack::Ui::Core::Base.new('matestack-ui-core-runtime-render', ':template': 'vc.isolatedTemplate', ':vc': 'vc', ':vue-component': 'vueComponent')
48+
Matestack::Ui::Core::Base.new('matestack-ui-core-runtime-render', ':template': 'vc.isolatedTemplate', ':vc': 'vc')
4949
end
5050
end
5151
end

0 commit comments

Comments
 (0)