Skip to content

Commit a0bef79

Browse files
author
Nils Henning
committed
[REFACTOR] rename isolate to isolated, fix skip children rendering, add legacy view spec
1 parent 72f4ebe commit a0bef79

File tree

20 files changed

+64
-36
lines changed

20 files changed

+64
-36
lines changed

app/concepts/matestack/ui/core/component/base.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,23 +231,23 @@ def add_child(child_class, *args, &block)
231231
# the childs content in order to respond to the subsequent component rendering call with
232232
# the childs content. In this case: "I should be deferred"
233233
skip_deferred_child_response = false
234-
if child_class <= Matestack::Ui::Core::Async::Async || child_class < Matestack::Ui::Core::Isolate::Isolate
234+
if child_class <= Matestack::Ui::Core::Async::Async || child_class < Matestack::Ui::Core::Isolated::Isolated
235235
if args.any? { |arg| arg[:defer].present? } && @matestack_skip_defer == true
236236
skip_deferred_child_response = true
237237
end
238238
end
239239

240240
# check only allowed keys are passed to isolated components
241-
if child_class < Matestack::Ui::Core::Isolate::Isolate
242-
unless args.empty? || args[0].keys.all? { |key| [:defer, :public_options, :rerender_on, :init_on, :rerender_delay].include? key }
241+
if child_class < Matestack::Ui::Core::Isolated::Isolated
242+
unless args.empty? || args[0].keys.all? { |key| [:defer, :public_options, :rerender_on, :init_on, :rerender_delay, :matestack_context].include? key }
243243
raise "isolated components can only take params in a public_options hash, which will be exposed to the client side in order to perform an async request with these params."
244244
end
245245
if args.any? { |arg| arg[:init_on].present? } && @matestack_skip_defer == true
246246
skip_deferred_child_response = true
247247
end
248248
end
249249

250-
if self.class < Matestack::Ui::Core::Isolate::Isolate
250+
if self.class < Matestack::Ui::Core::Isolated::Isolated
251251
parent_context_included_config = @current_parent_context.get_included_config || {}
252252
parent_context_included_config.merge!({ isolated_parent_class: self.class.name })
253253
args_with_context = add_context_to_options(args,parent_context_included_config)

app/concepts/matestack/ui/core/isolate/isolate.js renamed to app/concepts/matestack/ui/core/isolated/isolated.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,21 +71,15 @@ const componentDef = {
7171
},
7272
mounted: function (){
7373
const self = this
74-
console.log('mounted isolated component')
7574
if(this.componentConfig["init_on"] === undefined || this.componentConfig["init_on"] === null){
76-
console.log('Its me')
7775
if(self.componentConfig["defer"] == true || Number.isInteger(self.componentConfig["defer"])){
78-
console.log('I should render deferred')
7976
if(!isNaN(self.componentConfig["defer"])){
8077
self.startDefer()
8178
}
8279
else{
8380
self.renderIsolatedContent();
8481
}
8582
}
86-
else {
87-
console.log('I should NOT render deferred')
88-
}
8983
}else{
9084
if(self.componentConfig["defer"] != undefined){
9185
if(!isNaN(self.componentConfig["defer"])){

app/concepts/matestack/ui/core/isolate/isolate.rb renamed to app/concepts/matestack/ui/core/isolated/isolated.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
module Matestack::Ui::Core::Isolate
2-
class Isolate < Matestack::Ui::Core::Component::Dynamic
1+
module Matestack::Ui::Core::Isolated
2+
class Isolated < Matestack::Ui::Core::Component::Dynamic
33
vue_js_component_name "matestack-ui-core-isolate"
44

55
def initialize(*args)
@@ -11,9 +11,9 @@ def public_options
1111
@public_options ||= {}
1212
end
1313

14-
def params
15-
context[:params] ||= {}
16-
end
14+
# def params
15+
# context[:params] || matestack_context[:params]
16+
# end
1717

1818
def setup
1919
@component_config[:component_class] = self.class.name
@@ -35,7 +35,7 @@ def render_content
3535

3636
# only render vuejs component wrapper on show
3737
def show
38-
render :isolate
38+
render :isolated
3939
end
4040

4141
# this method gets called when the isolate vuejs component requests isolated content

app/concepts/matestack/ui/core/js/core.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import onclick from '../onclick/onclick'
1616
import collectionContent from '../collection/content/content'
1717
import collectionFilter from '../collection/filter/filter'
1818
import collectionOrder from '../collection/order/order'
19-
import isolate from '../isolate/isolate'
19+
import isolate from '../isolated/isolated'
2020

2121
let matestackUiApp = undefined
2222

app/lib/matestack/ui/core/rendering/main_renderer.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def resolve_component(name)
153153

154154
def resolve_isolated_component(name)
155155
constant = const_get(name)
156-
if constant < Matestack::Ui::Core::Isolate::Isolate
156+
if constant < Matestack::Ui::Core::Isolated::Isolated
157157
constant
158158
else
159159
nil
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Matestack::Ui::IsolatedComponent = Matestack::Ui::Core::Isolate::Isolate
1+
Matestack::Ui::IsolatedComponent = Matestack::Ui::Core::Isolated::Isolated

docs/api/base/backend/isolate.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Matestack Core Component: Isolate
22

3-
Feel free to check out the [component specs](/spec/usage/components/dynamic/isolate).
3+
Feel free to check out the [component specs](/spec/test/components/dynamic/isolated).
44

55
The isolate component allows you to create components, which can be rendered independently. It means that isolate components are rendered without calling the response method of your page, which gives you the possibility to rerender components dynamically without rerendering the whole UI.
66

lib/matestack/ui/core/components.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def self.require_core_component(name)
8585
require_core_component "img"
8686
require_core_component "input"
8787
require_core_component "ins"
88-
require_core_component "isolate"
88+
require_core_component "isolated"
8989
require_core_component "kbd"
9090
require_core_component "label"
9191
require_core_component "legend"

spec/dummy/app/controllers/legacy_views/pages_controller.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ def form_custom_component
4545
def onclick_custom_component
4646
end
4747

48+
def isolated_custom_component
49+
render 'isolated_custom_component'
50+
end
51+
4852
def success
4953
render json: params.to_unsafe_h, status: :ok
5054
end

0 commit comments

Comments
 (0)