matestack-ui-core 0.6.0
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.
Potentially problematic release.
This version of matestack-ui-core might be problematic. Click here for more details.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +230 -0
- data/Rakefile +34 -0
- data/app/assets/config/basemate_ui_core_manifest.js +2 -0
- data/app/assets/javascripts/basemate/ui/core/application.js +15 -0
- data/app/assets/stylesheets/basemate/ui/core/application.css +15 -0
- data/app/concepts/absolute/cell/absolute.rb +17 -0
- data/app/concepts/absolute/view/absolute.haml +3 -0
- data/app/concepts/action/cell/action.rb +52 -0
- data/app/concepts/action/js/action.js +49 -0
- data/app/concepts/action/view/action.haml +3 -0
- data/app/concepts/app/cell/app.rb +76 -0
- data/app/concepts/app/js/app.js +27 -0
- data/app/concepts/app/js/store.js +71 -0
- data/app/concepts/app/utils/app_node.rb +53 -0
- data/app/concepts/app/view/app.haml +4 -0
- data/app/concepts/async/cell/async.rb +10 -0
- data/app/concepts/async/js/async.js +57 -0
- data/app/concepts/async/view/async.haml +2 -0
- data/app/concepts/br/cell/br.rb +5 -0
- data/app/concepts/br/view/br.haml +5 -0
- data/app/concepts/button/cell/button.rb +5 -0
- data/app/concepts/button/view/button.haml +7 -0
- data/app/concepts/component/cell/dynamic.rb +226 -0
- data/app/concepts/component/cell/static.rb +16 -0
- data/app/concepts/component/js/anonym-dynamic-component.js +10 -0
- data/app/concepts/component/js/component.js +60 -0
- data/app/concepts/component/utils/component_node.rb +69 -0
- data/app/concepts/component/view/children.haml +2 -0
- data/app/concepts/component/view/dynamic.haml +6 -0
- data/app/concepts/component/view/dynamic_without_rerender.haml +2 -0
- data/app/concepts/component/view/response.haml +2 -0
- data/app/concepts/component/view/response_dynamic.haml +7 -0
- data/app/concepts/component/view/response_dynamic_without_rerender.haml +3 -0
- data/app/concepts/component/view/static.haml +1 -0
- data/app/concepts/core/js/core.js +27 -0
- data/app/concepts/core/js/event-hub.js +5 -0
- data/app/concepts/div/cell/div.rb +6 -0
- data/app/concepts/div/view/div.haml +3 -0
- data/app/concepts/footer/cell/footer.rb +5 -0
- data/app/concepts/footer/view/footer.haml +3 -0
- data/app/concepts/form/cell/form.rb +71 -0
- data/app/concepts/form/cell/inline.rb +9 -0
- data/app/concepts/form/cell/input.rb +74 -0
- data/app/concepts/form/cell/select.rb +73 -0
- data/app/concepts/form/cell/submit.rb +9 -0
- data/app/concepts/form/js/form.js +136 -0
- data/app/concepts/form/view/form.haml +2 -0
- data/app/concepts/form/view/inline.haml +6 -0
- data/app/concepts/form/view/input.haml +29 -0
- data/app/concepts/form/view/select.haml +72 -0
- data/app/concepts/form/view/submit.haml +3 -0
- data/app/concepts/header/cell/header.rb +5 -0
- data/app/concepts/header/view/header.haml +3 -0
- data/app/concepts/heading/cell/heading.rb +5 -0
- data/app/concepts/heading/view/heading.haml +50 -0
- data/app/concepts/html/cell/html.rb +17 -0
- data/app/concepts/html/js/html.js +10 -0
- data/app/concepts/html/view/html.haml +3 -0
- data/app/concepts/icon/cell/icon.rb +5 -0
- data/app/concepts/icon/view/icon.haml +6 -0
- data/app/concepts/img/cell/img.rb +5 -0
- data/app/concepts/img/view/img.haml +1 -0
- data/app/concepts/input/cell/input.rb +5 -0
- data/app/concepts/input/view/input.haml +3 -0
- data/app/concepts/label/cell/label.rb +5 -0
- data/app/concepts/label/view/label.haml +7 -0
- data/app/concepts/li/cell/li.rb +5 -0
- data/app/concepts/li/view/li.haml +6 -0
- data/app/concepts/link/cell/link.rb +24 -0
- data/app/concepts/link/view/link.haml +6 -0
- data/app/concepts/main/cell/main.rb +5 -0
- data/app/concepts/main/view/main.haml +3 -0
- data/app/concepts/nav/cell/nav.rb +5 -0
- data/app/concepts/nav/view/nav.haml +3 -0
- data/app/concepts/ol/cell/ol.rb +5 -0
- data/app/concepts/ol/view/ol.haml +3 -0
- data/app/concepts/onclick/cell/onclick.rb +6 -0
- data/app/concepts/onclick/js/onclick.js +21 -0
- data/app/concepts/onclick/view/onclick.haml +2 -0
- data/app/concepts/page/cell/content.rb +5 -0
- data/app/concepts/page/cell/page.rb +128 -0
- data/app/concepts/page/js/content.js +17 -0
- data/app/concepts/page/utils/page_node.rb +66 -0
- data/app/concepts/page/view/content.haml +7 -0
- data/app/concepts/page/view/page.haml +9 -0
- data/app/concepts/partial/cell/partial.rb +5 -0
- data/app/concepts/partial/view/partial.haml +2 -0
- data/app/concepts/pg/cell/pg.rb +5 -0
- data/app/concepts/pg/view/pg.haml +8 -0
- data/app/concepts/plain/cell/plain.rb +10 -0
- data/app/concepts/progress/cell/progress.rb +5 -0
- data/app/concepts/progress/view/progress.haml +3 -0
- data/app/concepts/section/cell/section.rb +5 -0
- data/app/concepts/section/view/section.haml +3 -0
- data/app/concepts/shared/utils/to_cell.rb +126 -0
- data/app/concepts/slot/cell/slot.rb +10 -0
- data/app/concepts/slot/view/slot.haml +2 -0
- data/app/concepts/span/cell/span.rb +5 -0
- data/app/concepts/span/view/span.haml +3 -0
- data/app/concepts/table/cell/table.rb +5 -0
- data/app/concepts/table/view/table.haml +3 -0
- data/app/concepts/td/cell/td.rb +5 -0
- data/app/concepts/td/view/td.haml +8 -0
- data/app/concepts/th/cell/th.rb +5 -0
- data/app/concepts/th/view/th.haml +8 -0
- data/app/concepts/tr/cell/tr.rb +5 -0
- data/app/concepts/tr/view/tr.haml +3 -0
- data/app/concepts/transition/cell/transition.rb +31 -0
- data/app/concepts/transition/js/transition.js +26 -0
- data/app/concepts/transition/view/transition.haml +7 -0
- data/app/concepts/ul/cell/ul.rb +5 -0
- data/app/concepts/ul/view/ul.haml +3 -0
- data/app/concepts/view/cell/view.rb +7 -0
- data/app/concepts/view/js/view.js +42 -0
- data/app/concepts/view/view/view.haml +2 -0
- data/app/controllers/basemate/ui/core/application_controller.rb +9 -0
- data/app/controllers/basemate/ui/core/docs_controller.rb +17 -0
- data/app/helpers/matestack/ui/core/application_helper.rb +35 -0
- data/config/routes.rb +3 -0
- data/lib/matestack/ui/core.rb +15 -0
- data/lib/matestack/ui/core/engine.rb +19 -0
- data/lib/matestack/ui/core/version.rb +7 -0
- data/lib/tasks/matestack/ui/core_tasks.rake +4 -0
- data/vendor/assets/javascripts/manifest.json +4 -0
- data/vendor/assets/javascripts/matestack-ui-core.js +15055 -0
- data/vendor/assets/javascripts/matestack-ui-core.js.map +1 -0
- metadata +277 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 6e54bd9269c669fa0d87f2052258961731162454a99417077e2102e5d391aee2
|
4
|
+
data.tar.gz: dbfb0a72d64c215d714c0340667e5f61c19fc0908875b5e1150be97c0c364f61
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b15dcdaa3f71f73c99adf5971ded4c558968c8e93f555e7b8593bf40a074ff7e72fbbff295ac939556aff71c29a1f439588445e01e74fc8af3406726139fb674
|
7
|
+
data.tar.gz: 767db8f8b1757b356178db83bba45da3427ba2195425670be4a0cc4912382ed2df6d9a19464d7d2d8dcfb805a000c2dca9962761de3966f525580839b06de77f
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2018 Jonas Jabari
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,230 @@
|
|
1
|
+
[](https://circleci.com/gh/basemate/matestack-ui-core/tree/master)
|
2
|
+
|
3
|
+

|
4
|
+
|
5
|
+
# Matestack: Escape the frontend hustle
|
6
|
+
|
7
|
+
## Create maintainable, dynamic and beautiful UIs easily
|
8
|
+
|
9
|
+
As a Rails Engine, matestack deeply integrates a Vue.js based UI into Rails, offering optional prebuilt components. Use it to write dynamic Web-UIs with minimum effort and maximum dev happiness in pure Ruby. The main goals are:
|
10
|
+
|
11
|
+
- Reduction of complexity of modern web development, moving front and backend closer together
|
12
|
+
- More maintainable UI code, using a component-based structure written in Ruby
|
13
|
+
- Increased development speed and happiness, offering prebuilt UI-Components for classic requirements
|
14
|
+
- Modern, dynamic UI feeling without the need to implement a separate JavaScript Application
|
15
|
+
|
16
|
+
matestack can progressively replace the classic Rails-View-Layer. You are able to use
|
17
|
+
it alongside your classic views and incrementally turn your Rails-App into a
|
18
|
+
dynamic Web-App.
|
19
|
+
|
20
|
+
### Features:
|
21
|
+
|
22
|
+
#### Define your UI in a Ruby Class
|
23
|
+
```ruby
|
24
|
+
class Pages::MyPage < Page::Cell::Page
|
25
|
+
|
26
|
+
def prepare
|
27
|
+
@technologies = ["Rails", "Vue.js", "Trailblazer", "Rspec", "Capybara"]
|
28
|
+
end
|
29
|
+
|
30
|
+
def response
|
31
|
+
components{
|
32
|
+
div id: "technologies" do
|
33
|
+
@technologies.each do |technology|
|
34
|
+
plain "matestack uses #{technology}"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
}
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
```
|
42
|
+
#### Create a Single Page Application without JavaScript
|
43
|
+
|
44
|
+
```ruby
|
45
|
+
class Apps::MyApp < App::Cell::App
|
46
|
+
|
47
|
+
def response
|
48
|
+
components{
|
49
|
+
header do
|
50
|
+
heading size: 1, text: "My App"
|
51
|
+
end
|
52
|
+
nav do
|
53
|
+
transition path: :my_first_page_path do
|
54
|
+
button "Page 1"
|
55
|
+
end
|
56
|
+
transition path: :my_second_page_path do
|
57
|
+
button "Page 2"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
main do
|
61
|
+
page_content #pages are dynamically yielded here, when buttons are clicked!
|
62
|
+
end
|
63
|
+
footer do
|
64
|
+
plain "That's it!"
|
65
|
+
end
|
66
|
+
}
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
```
|
71
|
+
|
72
|
+
```ruby
|
73
|
+
class Pages::MyApp::MyFirstPage < Page::Cell::Page
|
74
|
+
|
75
|
+
def response
|
76
|
+
components{
|
77
|
+
div id: "div-on-page-1" do
|
78
|
+
plain "My First Page"
|
79
|
+
end
|
80
|
+
}
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
84
|
+
```
|
85
|
+
```ruby
|
86
|
+
class Pages::MyApp::MySecondPage < Page::Cell::Page
|
87
|
+
|
88
|
+
def response
|
89
|
+
components{
|
90
|
+
div id: "div-on-page-2" do
|
91
|
+
plain "My Second Page"
|
92
|
+
end
|
93
|
+
}
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
97
|
+
```
|
98
|
+
#### Handle User Interaction dynamically without JavaScript
|
99
|
+
```ruby
|
100
|
+
class Pages::MyPage < Page::Cell::Page
|
101
|
+
|
102
|
+
def response
|
103
|
+
components {
|
104
|
+
action my_action_config do
|
105
|
+
button text: "Click me!"
|
106
|
+
end
|
107
|
+
#content gets rerendered without page reload if action succeeded
|
108
|
+
async rerender_on: "my_action_succeeded" do
|
109
|
+
div id: "my-div" do
|
110
|
+
plain DateTime.now
|
111
|
+
end
|
112
|
+
end
|
113
|
+
}
|
114
|
+
end
|
115
|
+
|
116
|
+
def my_action_config
|
117
|
+
{
|
118
|
+
method: :post,
|
119
|
+
path: :some_rails_routing_path,
|
120
|
+
success: {
|
121
|
+
emit: "my_action_succeeded"
|
122
|
+
}
|
123
|
+
}
|
124
|
+
end
|
125
|
+
|
126
|
+
end
|
127
|
+
```
|
128
|
+
#### Handle User Input dynamically without JavaScript
|
129
|
+
```ruby
|
130
|
+
class Pages::MyApp::MyFirstPage < Page::Cell::Page
|
131
|
+
|
132
|
+
def prepare
|
133
|
+
@my_model = MyModel.new
|
134
|
+
end
|
135
|
+
|
136
|
+
def response
|
137
|
+
components {
|
138
|
+
form my_form_config, :include do
|
139
|
+
form_input key: :some_model_attribute, type: :text
|
140
|
+
form_submit do
|
141
|
+
button text: "Submit me!"
|
142
|
+
end
|
143
|
+
end
|
144
|
+
async show_on: "form_has_errors", hide_after: 5000 do
|
145
|
+
plain "Data could not be submitted, please check form"
|
146
|
+
end
|
147
|
+
}
|
148
|
+
end
|
149
|
+
|
150
|
+
def my_form_config
|
151
|
+
{
|
152
|
+
for: @my_model,
|
153
|
+
method: :post,
|
154
|
+
path: :some_action_path,
|
155
|
+
success: {
|
156
|
+
transition: {
|
157
|
+
path: :my_second_page_path,
|
158
|
+
}
|
159
|
+
},
|
160
|
+
failure: {
|
161
|
+
emit: "form_has_errors"
|
162
|
+
}
|
163
|
+
}
|
164
|
+
end
|
165
|
+
|
166
|
+
end
|
167
|
+
```
|
168
|
+
#### Websocket Integration without JavaScript
|
169
|
+
```ruby
|
170
|
+
class Pages::MyPage < Page::Cell::Page
|
171
|
+
|
172
|
+
def prepare
|
173
|
+
@comments = Comment.last(5)
|
174
|
+
end
|
175
|
+
|
176
|
+
def response
|
177
|
+
components {
|
178
|
+
#content gets rerendered without page reload when
|
179
|
+
#websocket event is received
|
180
|
+
async rerender_on: "comments_changed" do
|
181
|
+
@comments.each do |comment|
|
182
|
+
div do
|
183
|
+
plain comment.content
|
184
|
+
end
|
185
|
+
end
|
186
|
+
end
|
187
|
+
}
|
188
|
+
end
|
189
|
+
|
190
|
+
end
|
191
|
+
```
|
192
|
+
somewhere else on the backend:
|
193
|
+
|
194
|
+
```ruby
|
195
|
+
ActionCable.server.broadcast("matestack_ui_core", {
|
196
|
+
message: "comments_changed"
|
197
|
+
})
|
198
|
+
```
|
199
|
+
|
200
|
+
### Documentation
|
201
|
+
|
202
|
+
Documentation can be found [here](./docs)
|
203
|
+
|
204
|
+
### Changelog
|
205
|
+
|
206
|
+
Changelog can be found [here](./CHANGELOG.md)
|
207
|
+
|
208
|
+
### Roadmap
|
209
|
+
|
210
|
+
Scheduled for 0.7.0:
|
211
|
+
- Webpacker/Yarn Integration
|
212
|
+
- Advanced Websockets Integration
|
213
|
+
- 1:n Relations in Form components
|
214
|
+
- More Form Components (Multi Select Components)
|
215
|
+
- Component Based Caching
|
216
|
+
- Rails View Integration
|
217
|
+
- Dockerized Core Development
|
218
|
+
|
219
|
+
|
220
|
+
### Community
|
221
|
+
|
222
|
+
TODO: Gitter
|
223
|
+
|
224
|
+
### Contribution
|
225
|
+
|
226
|
+
We are happy to accept contributors of any kind. Please refer to the [Contribution Guide](./docs/contribute)
|
227
|
+
|
228
|
+
### License
|
229
|
+
The gem is available as open source under the terms of the
|
230
|
+
[MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'Matestack::Ui::Core'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.md')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
APP_RAKEFILE = File.expand_path("spec/dummy/Rakefile", __dir__)
|
18
|
+
load 'rails/tasks/engine.rake'
|
19
|
+
|
20
|
+
load 'rails/tasks/statistics.rake'
|
21
|
+
|
22
|
+
load 'lib/tasks/matestack/ui/core_tasks.rake'
|
23
|
+
|
24
|
+
require 'bundler/gem_tasks'
|
25
|
+
|
26
|
+
require 'rake/testtask'
|
27
|
+
|
28
|
+
# Rake::TestTask.new(:test) do |t|
|
29
|
+
# t.libs << 'test'
|
30
|
+
# t.pattern = 'test/**/*_test.rb'
|
31
|
+
# t.verbose = false
|
32
|
+
# end
|
33
|
+
#
|
34
|
+
# task default: :test
|
@@ -0,0 +1,15 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file. JavaScript code in this file should be added after the last require_* statement.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require rails-ujs
|
14
|
+
//= require activestorage
|
15
|
+
//= require_tree .
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
|
10
|
+
* files in this directory. Styles in this file should be added after the last require_* statement.
|
11
|
+
* It is generally better to create a new file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*/
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Absolute::Cell
|
2
|
+
class Absolute < Component::Cell::Static
|
3
|
+
|
4
|
+
def setup
|
5
|
+
style = "position: absolute;"
|
6
|
+
style << " top: #{options[:top]}px;" if options[:top]
|
7
|
+
style << " left: #{options[:left]}px;" if options[:left]
|
8
|
+
style << " right: #{options[:right]}px;" if options[:right]
|
9
|
+
style << " bottom: #{options[:bottom]}px;" if options[:bottom]
|
10
|
+
style << " z-index: #{options[:z]};" if options[:z]
|
11
|
+
@tag_attributes.merge!({
|
12
|
+
style: style
|
13
|
+
})
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module Action::Cell
|
2
|
+
class Action < Component::Cell::Dynamic
|
3
|
+
|
4
|
+
def setup
|
5
|
+
@component_config[:action_path] = action_path
|
6
|
+
@component_config[:method] = options[:method]
|
7
|
+
@component_config[:success] = options[:success]
|
8
|
+
unless options[:success].nil?
|
9
|
+
unless options[:success][:transition].nil?
|
10
|
+
@component_config[:success][:transition][:path] = transition_path options[:success]
|
11
|
+
end
|
12
|
+
end
|
13
|
+
@component_config[:failure] = options[:failure]
|
14
|
+
unless options[:failure].nil?
|
15
|
+
unless options[:failure][:transition].nil?
|
16
|
+
@component_config[:failure][:transition][:path] = transition_path options[:failure]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
if options[:notify].nil?
|
20
|
+
@component_config[:notify] = true
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def action_path
|
25
|
+
begin
|
26
|
+
if options[:path].is_a?(Symbol)
|
27
|
+
return ::Rails.application.routes.url_helpers.send(options[:path], options[:params])
|
28
|
+
else
|
29
|
+
return options[:path]
|
30
|
+
end
|
31
|
+
rescue
|
32
|
+
raise "Action path not found"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def transition_path callback_options
|
37
|
+
begin
|
38
|
+
if callback_options[:transition][:path].is_a?(Symbol)
|
39
|
+
return ::Rails.application.routes.url_helpers.send(
|
40
|
+
callback_options[:transition][:path],
|
41
|
+
callback_options[:transition][:params]
|
42
|
+
)
|
43
|
+
else
|
44
|
+
return callback_options[:transition][:path]
|
45
|
+
end
|
46
|
+
rescue
|
47
|
+
raise "Transition path not found"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
import Vue from 'vue/dist/vue.esm'
|
2
|
+
import Vuex from 'vuex'
|
3
|
+
import axios from 'axios'
|
4
|
+
|
5
|
+
import matestackEventHub from 'core/js/event-hub'
|
6
|
+
|
7
|
+
import componentMixin from 'component/js/component'
|
8
|
+
|
9
|
+
const componentDef = {
|
10
|
+
mixins: [componentMixin],
|
11
|
+
data: function(){
|
12
|
+
return {}
|
13
|
+
},
|
14
|
+
methods: {
|
15
|
+
perform: function(){
|
16
|
+
const self = this
|
17
|
+
axios({
|
18
|
+
method: self.componentConfig["method"],
|
19
|
+
url: self.componentConfig["action_path"],
|
20
|
+
data: self.componentConfig["data"],
|
21
|
+
headers: {
|
22
|
+
'X-CSRF-Token': document.getElementsByName("csrf-token")[0].getAttribute('content')
|
23
|
+
}
|
24
|
+
})
|
25
|
+
.then(function(response){
|
26
|
+
if (self.componentConfig["success"] != undefined && self.componentConfig["success"]["emit"] != undefined) {
|
27
|
+
matestackEventHub.$emit(self.componentConfig["success"]["emit"], response.data);
|
28
|
+
}
|
29
|
+
if (self.componentConfig["success"] != undefined && self.componentConfig["success"]["transition"] != undefined && self.$store != undefined) {
|
30
|
+
let path = self.componentConfig["success"]["transition"]["path"]
|
31
|
+
self.$store.dispatch('navigateTo', {url: path, backwards: false})
|
32
|
+
}
|
33
|
+
})
|
34
|
+
.catch(function(error){
|
35
|
+
if (self.componentConfig["failure"] != undefined && self.componentConfig["failure"]["emit"] != undefined) {
|
36
|
+
matestackEventHub.$emit(self.componentConfig["failure"]["emit"], error.response.data);
|
37
|
+
}
|
38
|
+
if (self.componentConfig["failure"] != undefined && self.componentConfig["failure"]["transition"] != undefined && self.$store != undefined) {
|
39
|
+
let path = self.componentConfig["failure"]["transition"]["path"]
|
40
|
+
self.$store.dispatch('navigateTo', {url: path, backwards: false})
|
41
|
+
}
|
42
|
+
})
|
43
|
+
}
|
44
|
+
}
|
45
|
+
}
|
46
|
+
|
47
|
+
let component = Vue.component('action-cell', componentDef)
|
48
|
+
|
49
|
+
export default componentDef
|