rails_view_component 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/generators/rails_view_component/erb/model.rb.erb +1 -1
- data/lib/generators/rails_view_component/install_generator.rb +8 -7
- data/lib/generators/rails_view_component/templates/{view_component/haxe/ViewComponent.hx → RailsViewComponent.hx} +2 -2
- data/lib/generators/rails_view_component/templates/{view_component/view_component_builder.rb → rails_view_component_builder.rb} +1 -1
- data/lib/generators/rails_view_component/templates/rails_view_component_helper.rb +14 -0
- data/lib/generators/rails_view_component/templates/{view_component/view_component_model.rb → rails_view_component_model.rb} +4 -3
- data/lib/rails_view_component/version.rb +1 -1
- metadata +5 -5
- data/lib/generators/rails_view_component/templates/view_component/view_component_helper.rb +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d1933c6f5a312777557bc3dd7b1e8eb6d06dcb00
|
4
|
+
data.tar.gz: 5c0b4831cfcfd1cd89ffe61c8fa1a17879a04451
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f75ddf55fd041e32003b26a04c36985275a0fc80b76d3ae6deb7e794354f7b1ac35e9961b23ce677e4c008fb029ac3f1e6b1e1b2393b792888483adc2372730d
|
7
|
+
data.tar.gz: 90200e25caeebd6c637761267099783f28f44689a5c3ba944c99a0bac7df54c2edd9a5c565b1008fedb9c85a08a90e14da274b264ebec7982b27a5cf8d0bd104
|
@@ -4,14 +4,15 @@ module RailsViewComponent
|
|
4
4
|
|
5
5
|
source_root File.expand_path('../templates', __FILE__)
|
6
6
|
def copy
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
7
|
+
{
|
8
|
+
"rails_view_component_builder.rb" => "lib",
|
9
|
+
"rails_view_component_helper.rb" => "lib",
|
10
|
+
"rails_view_component_model.rb" => "lib",
|
11
|
+
"RailsViewComponent.hx" => "lib/haxe",
|
12
|
+
"haxe_compile.hxml" => "./",
|
13
|
+
}.each{|file,dir|
|
14
|
+
copy_file file, "#{dir}/#{file}"
|
13
15
|
}
|
14
|
-
copy_file "haxe_compile.hxml", "hax_compile.hxml"
|
15
16
|
end
|
16
17
|
|
17
18
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import jQuery.*;
|
2
2
|
|
3
|
-
class
|
3
|
+
class RailsViewComponent{
|
4
4
|
public var callbacks = new Map<String, Dynamic->Dynamic->Dynamic->Void>();
|
5
5
|
public function addCallback(method:String, fun:Dynamic->Dynamic->Dynamic->Void){
|
6
6
|
this.callbacks.set(method, fun);
|
@@ -11,7 +11,7 @@ class ViewComponent{
|
|
11
11
|
}
|
12
12
|
public function sendRequest(method:String, params){
|
13
13
|
JQueryStatic.post(
|
14
|
-
"/
|
14
|
+
"/rails_view_component/"+ this.componentName +"/"+ method,
|
15
15
|
params,
|
16
16
|
function(data, status, xhr){
|
17
17
|
var func = this.callbacks.get(method);
|
@@ -0,0 +1,14 @@
|
|
1
|
+
|
2
|
+
module RailsViewComponent::RailsViewComponentHelper
|
3
|
+
|
4
|
+
def rails_view_components &block
|
5
|
+
builder = RailsViewComponent::RailsViewComponentBuilder.new
|
6
|
+
block.call builder
|
7
|
+
footer = builder.refer_to_javascripts
|
8
|
+
footer += builder.refer_to_stylesheets
|
9
|
+
raw footer
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
end
|
14
|
+
|
@@ -1,9 +1,9 @@
|
|
1
|
-
class
|
1
|
+
class RailsViewComponent::RalsViewComponentModel
|
2
2
|
attr_reader :component_name, :html_identifier, :html_classes
|
3
3
|
def initialize id
|
4
4
|
@component_name = self.class.name.match(/^(?<name>[^:]+)::/)[:name].underscore
|
5
5
|
@html_identifier = "#{@component_name}_#{id}"
|
6
|
-
@html_classes = ["
|
6
|
+
@html_classes = ["rails_view_component", "#{@component_name}_view_component"]
|
7
7
|
end
|
8
8
|
|
9
9
|
def responsibility
|
@@ -18,7 +18,8 @@ class ViewComponent::ViewComponentModel
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def html erb_params={}, ajax_params={}
|
21
|
-
action_view = ActionView::Base.new
|
21
|
+
action_view = ActionView::Base.new
|
22
|
+
"#{Rails.root}/app/rails_view_components/#{@component_name}/views"
|
22
23
|
erb_params.each{|k,v| action_view.assign(k=>v) }
|
23
24
|
data = ajax_params.map{|k,v| "data-#{k}='#{v}'" }.join(' ')
|
24
25
|
return <<HTML
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_view_component
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Takeshi Kojima
|
@@ -42,11 +42,11 @@ files:
|
|
42
42
|
- lib/generators/rails_view_component/erb/views/rails_view_component.html.erb.erb
|
43
43
|
- lib/generators/rails_view_component/install_generator.rb
|
44
44
|
- lib/generators/rails_view_component/rails_view_component_generator.rb
|
45
|
+
- lib/generators/rails_view_component/templates/RailsViewComponent.hx
|
45
46
|
- lib/generators/rails_view_component/templates/haxe_compile.hxml
|
46
|
-
- lib/generators/rails_view_component/templates/
|
47
|
-
- lib/generators/rails_view_component/templates/
|
48
|
-
- lib/generators/rails_view_component/templates/
|
49
|
-
- lib/generators/rails_view_component/templates/view_component/view_component_model.rb
|
47
|
+
- lib/generators/rails_view_component/templates/rails_view_component_builder.rb
|
48
|
+
- lib/generators/rails_view_component/templates/rails_view_component_helper.rb
|
49
|
+
- lib/generators/rails_view_component/templates/rails_view_component_model.rb
|
50
50
|
- lib/rails_view_component.rb
|
51
51
|
- lib/rails_view_component/engine.rb
|
52
52
|
- lib/rails_view_component/haxe/RailsViewComponent.hx
|
@@ -1,14 +0,0 @@
|
|
1
|
-
|
2
|
-
module ViewComponent::ViewComponentHelper
|
3
|
-
|
4
|
-
def view_components &block
|
5
|
-
builder = ViewComponent::ViewComponentBuilder.new
|
6
|
-
block.call builder
|
7
|
-
footer = builder.refer_to_javascripts
|
8
|
-
footer += builder.refer_to_stylesheets
|
9
|
-
raw footer
|
10
|
-
end
|
11
|
-
|
12
|
-
|
13
|
-
end
|
14
|
-
|