Skip to content

Commit 231a4a0

Browse files
author
Nils Henning
committed
[WIP][FEATURE] cable component
1 parent fd01222 commit 231a4a0

28 files changed

+133
-17493
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import Vue from 'vue/dist/vue.esm'
22
import matestackEventHub from '../../js/event-hub'
33
import queryParamsHelper from '../../js/helpers/query-params-helper'
44
import componentMixin from '../../component/component'
5-
import asyncMixin from '../../async/async'
5+
// import asyncMixin from '../../async/async'
66

77
const componentDef = {
8-
mixins: [componentMixin, asyncMixin],
8+
mixins: [componentMixin],
99
data: function(){
1010
return {
1111
currentLimit: null,

app/concepts/matestack/ui/core/collection/content/content.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module Matestack::Ui::Core::Collection::Content
2-
class Content < Matestack::Ui::Core::Component::Rerender
2+
class Content < Matestack::Ui::Core::Component::Dynamic
33
vue_js_component_name 'matestack-ui-core-collection-content'
44

55
def setup

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@ class Base < Trailblazer::Cell
44
include Matestack::Ui::Core::HasViewContext
55
include Matestack::Ui::Core::HtmlAttributes
66
include Matestack::Ui::Core::Properties
7+
include Matestack::Ui::Core::DSL
78

89
# define html global attributes
910
html_attributes *HTML_GLOBAL_ATTRIBUTES, *HTML_EVENT_ATTRIBUTES
1011

11-
# probably need to remove for other tests to be green again
12-
include Matestack::Ui::Core::DSL
1312

1413
view_paths << "#{Matestack::Ui::Core::Engine.root}/app/concepts"
1514
view_paths << "#{::Rails.root}#{'/' unless ::Rails.root.nil?}app/matestack"

app/helpers/matestack/ui/core/application_helper.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ def responder_for(*args)
100100

101101
def matestack_component(component, options = {}, &block)
102102
context = (options[:matestack_context] ||= {}).merge(controller: @_controller || self)
103-
Matestack::Ui::Core::Component::Base.new(options.merge(matestack_context: context)).send(component, options.merge(matestack_context: context), &block)
103+
Matestack::Ui::Core::Component::Base
104+
.new(options.merge(matestack_context: context))
105+
.send(component, options.merge(matestack_context: context), &block).to_s
104106
end
105107
end
106108
end

docker-compose.yml

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -71,18 +71,7 @@ services:
7171
POSTGRES_DB: test
7272
volumes:
7373
- test-data-volume:/var/lib/postgresql/data
74-
75-
postgres_dummy:
76-
image: postgres
77-
expose:
78-
- 5432
79-
environment:
80-
POSTGRES_USER: postgres
81-
POSTGRES_PASSWORD: postgres
82-
POSTGRES_DB: dummy
83-
volumes:
84-
- test-data-volume:/var/lib/postgresql/data
85-
74+
8675
volumes:
8776
test-data-volume:
8877
dummy-data-volume:

spec/dummy/.byebug_history

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

spec/dummy/app/controllers/my_app_controller.rb

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
class MyAppController < ApplicationController
22

33
include Matestack::Ui::Core::ApplicationHelper
4-
54
include Components::Registry
65
include Demo::Components::Registry
76

@@ -49,16 +48,16 @@ def some_action
4948
end
5049

5150
def form_action
52-
@dummy_model = DummyModel.create(dummy_model_params)
53-
if @dummy_model.errors.any?
51+
dummy_model = DummyModel.create(dummy_model_params)
52+
if dummy_model.errors.any?
5453
render json: {
55-
errors: @dummy_model.errors,
54+
errors: dummy_model.errors,
5655
message: "Test Model could not be saved!"
5756
}, status: :unprocessable_entity
5857
else
5958
ActionCable.server.broadcast("matestack_ui_core", {
6059
message: "test_model_created",
61-
new_element: matestack_component(:my_list_item, item: @dummy_model).to_s
60+
new_element: matestack_component(:my_list_item, item: dummy_model)
6261
})
6362
render json: { transition_to: my_second_page_path }, status: :created
6463
end
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
class Demo::Components::Card < Matestack::Ui::StaticComponent
22

33
def response
4-
components {
5-
div class: "my-component" do
6-
plain "demo card!"
7-
end
8-
}
4+
div class: "my-component" do
5+
plain "demo card!"
6+
end
97
end
108

119
end

spec/dummy/app/matestack/demo/pages/collection.rb

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,10 @@ def prepare
2727

2828
def response
2929
heading size: 2, text: "Collection"
30-
31-
partial :filter
32-
partial :ordering
33-
30+
filter
31+
ordering
3432
async rerender_on: "my-first-collection-update", id: "my-collection" do
35-
partial :content
33+
content
3634
end
3735
end
3836

@@ -66,8 +64,8 @@ def ordering
6664

6765
def content
6866
collection_content @my_collection.config do
69-
partial :list
70-
partial :paginator
67+
list
68+
paginator
7169
end
7270
end
7371

0 commit comments

Comments
 (0)