matestack-ui-core 0.7.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of matestack-ui-core might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/README.md +1 -9
- data/app/concepts/matestack/ui/core/async/async.js +20 -2
- data/app/concepts/matestack/ui/core/blockquote/blockquote.haml +5 -0
- data/app/concepts/matestack/ui/core/blockquote/blockquote.rb +9 -0
- data/app/concepts/matestack/ui/core/button/button.rb +6 -0
- data/app/concepts/matestack/ui/core/caption/caption.haml +6 -0
- data/app/concepts/matestack/ui/core/caption/caption.rb +5 -0
- data/app/concepts/matestack/ui/core/collection/content/content.js +100 -0
- data/app/concepts/matestack/ui/core/collection/content/content.rb +18 -0
- data/app/concepts/matestack/ui/core/collection/content/next/next.haml +3 -0
- data/app/concepts/matestack/ui/core/collection/content/next/next.rb +5 -0
- data/app/concepts/matestack/ui/core/collection/content/page/link/link.haml +3 -0
- data/app/concepts/matestack/ui/core/collection/content/page/link/link.rb +5 -0
- data/app/concepts/matestack/ui/core/collection/content/previous/previous.haml +3 -0
- data/app/concepts/matestack/ui/core/collection/content/previous/previous.rb +5 -0
- data/app/concepts/matestack/ui/core/collection/filter/filter.js +50 -0
- data/app/concepts/matestack/ui/core/collection/filter/filter.rb +17 -0
- data/app/concepts/matestack/ui/core/collection/filter/input/input.haml +8 -0
- data/app/concepts/matestack/ui/core/collection/filter/input/input.rb +13 -0
- data/app/concepts/matestack/ui/core/collection/filter/reset/reset.haml +3 -0
- data/app/concepts/matestack/ui/core/collection/filter/reset/reset.rb +5 -0
- data/app/concepts/matestack/ui/core/collection/filter/submit/submit.haml +3 -0
- data/app/concepts/matestack/ui/core/collection/filter/submit/submit.rb +5 -0
- data/app/concepts/matestack/ui/core/collection/helper.rb +114 -0
- data/app/concepts/matestack/ui/core/collection/order/order.js +58 -0
- data/app/concepts/matestack/ui/core/collection/order/order.rb +17 -0
- data/app/concepts/matestack/ui/core/collection/order/toggle/indicator/indicator.rb +11 -0
- data/app/concepts/matestack/ui/core/collection/order/toggle/toggle.haml +3 -0
- data/app/concepts/matestack/ui/core/collection/order/toggle/toggle.rb +6 -0
- data/app/concepts/matestack/ui/core/component/component.js +2 -2
- data/app/concepts/matestack/ui/core/details/details.haml +3 -0
- data/app/concepts/matestack/ui/core/details/details.rb +4 -0
- data/app/concepts/matestack/ui/core/js/core.js +3 -0
- data/app/concepts/matestack/ui/core/js/helpers/query-params-helper.js +56 -0
- data/app/concepts/matestack/ui/core/link/link.haml +5 -6
- data/app/concepts/matestack/ui/core/link/link.rb +4 -2
- data/app/concepts/matestack/ui/core/page/page.rb +19 -18
- data/app/concepts/matestack/ui/core/small/small.haml +5 -0
- data/app/concepts/matestack/ui/core/small/small.rb +5 -0
- data/app/concepts/matestack/ui/core/span/span.haml +3 -1
- data/app/concepts/matestack/ui/core/strong/strong.haml +5 -0
- data/app/concepts/matestack/ui/core/strong/strong.rb +5 -0
- data/app/concepts/matestack/ui/core/summary/summary.haml +6 -0
- data/app/concepts/matestack/ui/core/summary/summary.rb +4 -0
- data/app/concepts/matestack/ui/core/video/video.haml +1 -0
- data/app/concepts/matestack/ui/core/video/video.rb +7 -0
- data/app/lib/matestack/ui/core/page_node.rb +14 -5
- data/lib/generators/matestack_app/USAGE +21 -0
- data/lib/generators/matestack_app/matestack_app_generator.rb +26 -0
- data/lib/generators/matestack_app/templates/matestack_app.erb +26 -0
- data/lib/generators/matestack_app/templates/matestack_app_controller.erb +7 -0
- data/lib/generators/matestack_component/USAGE +20 -0
- data/lib/generators/matestack_component/matestack_component_generator.rb +30 -0
- data/lib/generators/matestack_component/templates/matestack_component.haml.erb +5 -0
- data/lib/generators/matestack_component/templates/matestack_component.js.erb +17 -0
- data/lib/generators/matestack_component/templates/matestack_component.rb.erb +13 -0
- data/lib/generators/matestack_component/templates/matestack_component.scss.erb +1 -0
- data/lib/generators/matestack_page/USAGE +28 -0
- data/lib/generators/matestack_page/matestack_page_generator.rb +41 -0
- data/lib/generators/matestack_page/templates/matestack_page.erb +15 -0
- data/lib/matestack/ui/core/version.rb +1 -1
- data/vendor/assets/javascripts/matestack-ui-core.js +588 -251
- data/vendor/assets/javascripts/matestack-ui-core.js.map +1 -1
- metadata +53 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1b357485aaf4b5a49cc255719c7113ffc12b0d65f540130bfa04d64e8fd9afc9
|
4
|
+
data.tar.gz: e2c691da1526db9e715eecb9609b283d49f7d7edaf30b7fe537d430cca0a7c88
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 224bb5440913ee5d88d67a9b118652e278a72d1f42d064f9ff89593f35922310533978f3014a86022bca3ec3b6a7f1220f1e5e303d4a771c5cd011792d6aedf7
|
7
|
+
data.tar.gz: b203163b2a42cdc4aa31849f799fa061826dc42509033cfb2fc9aed61f1f101d163bf0bfcf6d18e2a485448bd1b149b3b4e0fd92b6d8627c0d2e71be600292d2
|
data/README.md
CHANGED
@@ -213,15 +213,7 @@ Changelog can be found [here](./CHANGELOG.md)
|
|
213
213
|
|
214
214
|
### Roadmap
|
215
215
|
|
216
|
-
|
217
|
-
- Better naming conventions
|
218
|
-
- Webpacker/Yarn Integration
|
219
|
-
- Advanced Websockets Integration
|
220
|
-
- 1:n Relations in Form components
|
221
|
-
- More Form Components (Multi Select Components)
|
222
|
-
- Component Based Caching
|
223
|
-
- Rails View Integration
|
224
|
-
- Dockerized Core Development
|
216
|
+
We're currently finalizing the roadmap towards to a stable 1.0 release, supposed to happen towards the end of the year! For details make sure to check the [release management project](https://github.com/basemate/matestack-ui-core/projects/2) and get in touch via our [chat](https://gitter.im/basemate/community) for feedback!
|
225
217
|
|
226
218
|
### Community
|
227
219
|
|
@@ -18,8 +18,16 @@ const componentDef = {
|
|
18
18
|
methods: {
|
19
19
|
show: function(event_data){
|
20
20
|
const self = this
|
21
|
+
if (this.showing === true){
|
22
|
+
return
|
23
|
+
}
|
21
24
|
this.showing = true
|
22
25
|
this.event.data = event_data
|
26
|
+
if(this.componentConfig["defer"] != undefined){
|
27
|
+
if(!isNaN(this.componentConfig["defer"])){
|
28
|
+
this.startDefer()
|
29
|
+
}
|
30
|
+
}
|
23
31
|
if(this.componentConfig["hide_after"] != undefined){
|
24
32
|
self.hide_after_timeout = setTimeout(function () {
|
25
33
|
self.hide()
|
@@ -29,6 +37,12 @@ const componentDef = {
|
|
29
37
|
hide: function(){
|
30
38
|
this.showing = false
|
31
39
|
this.event.data = {}
|
40
|
+
},
|
41
|
+
startDefer: function(){
|
42
|
+
const self = this
|
43
|
+
setTimeout(function () {
|
44
|
+
self.rerender()
|
45
|
+
}, parseInt(this.componentConfig["defer"]));
|
32
46
|
}
|
33
47
|
},
|
34
48
|
created: function () {
|
@@ -39,8 +53,12 @@ const componentDef = {
|
|
39
53
|
if(this.componentConfig["show_on"] != undefined){
|
40
54
|
this.showing = false
|
41
55
|
}
|
42
|
-
if(this.componentConfig["
|
43
|
-
this.
|
56
|
+
if(this.componentConfig["defer"] != undefined){
|
57
|
+
if(!isNaN(this.componentConfig["defer"])){
|
58
|
+
if (this.componentConfig["show_on"] == undefined){
|
59
|
+
this.startDefer()
|
60
|
+
}
|
61
|
+
}
|
44
62
|
}
|
45
63
|
},
|
46
64
|
beforeDestroy: function() {
|
@@ -0,0 +1,100 @@
|
|
1
|
+
import Vue from 'vue/dist/vue.esm'
|
2
|
+
|
3
|
+
import matestackEventHub from 'js/event-hub'
|
4
|
+
import queryParamsHelper from 'js/helpers/query-params-helper'
|
5
|
+
|
6
|
+
import componentMixin from 'component/component'
|
7
|
+
import asyncMixin from 'async/async'
|
8
|
+
|
9
|
+
const componentDef = {
|
10
|
+
mixins: [componentMixin, asyncMixin],
|
11
|
+
data: function(){
|
12
|
+
return {
|
13
|
+
currentLimit: null,
|
14
|
+
currentOffset: null,
|
15
|
+
currentFilteredCount: null,
|
16
|
+
currentBaseCount: null
|
17
|
+
}
|
18
|
+
},
|
19
|
+
methods: {
|
20
|
+
next: function(){
|
21
|
+
if (this.currentTo() < this.currentCount()){
|
22
|
+
this.currentOffset += this.currentLimit
|
23
|
+
var url = queryParamsHelper.updateQueryParams(this.componentConfig["id"] + "-offset", this.currentOffset)
|
24
|
+
window.history.pushState({matestackApp: true, url: url}, null, url);
|
25
|
+
matestackEventHub.$emit(this.componentConfig["id"] + "-update")
|
26
|
+
}
|
27
|
+
},
|
28
|
+
previous: function(){
|
29
|
+
if ((this.currentOffset - this.currentLimit)*-1 != this.currentLimit){
|
30
|
+
if((this.currentOffset - this.currentLimit) < 0){
|
31
|
+
this.currentOffset = 0
|
32
|
+
} else {
|
33
|
+
this.currentOffset -= this.currentLimit
|
34
|
+
}
|
35
|
+
var url = queryParamsHelper.updateQueryParams(this.componentConfig["id"] + "-offset", this.currentOffset)
|
36
|
+
window.history.pushState({matestackApp: true, url: url}, null, url);
|
37
|
+
matestackEventHub.$emit(this.componentConfig["id"] + "-update")
|
38
|
+
}
|
39
|
+
},
|
40
|
+
currentTo: function(){
|
41
|
+
var to = parseInt(this.currentOffset) + parseInt(this.currentLimit)
|
42
|
+
if (to > parseInt(this.currentCount())){
|
43
|
+
return this.currentCount();
|
44
|
+
} else {
|
45
|
+
return to;
|
46
|
+
}
|
47
|
+
},
|
48
|
+
currentCount: function(){
|
49
|
+
if (this.currentFilteredCount != null || this.currentFilteredCount != undefined){
|
50
|
+
return this.currentFilteredCount;
|
51
|
+
} else {
|
52
|
+
return this.currentBaseCount;
|
53
|
+
}
|
54
|
+
},
|
55
|
+
goToPage: function(page){
|
56
|
+
this.currentOffset = parseInt(this.currentLimit) * (parseInt(page)-1)
|
57
|
+
var url = queryParamsHelper.updateQueryParams(this.componentConfig["id"] + "-offset", this.currentOffset)
|
58
|
+
window.history.pushState({matestackApp: true, url: url}, null, url);
|
59
|
+
matestackEventHub.$emit(this.componentConfig["id"] + "-update")
|
60
|
+
}
|
61
|
+
},
|
62
|
+
mounted: function(){
|
63
|
+
if(queryParamsHelper.getQueryParam(this.componentConfig["id"] + "-offset") != null){
|
64
|
+
this.currentOffset = parseInt(queryParamsHelper.getQueryParam(this.componentConfig["id"] + "-offset"))
|
65
|
+
} else {
|
66
|
+
if(this.componentConfig["init_offset"] != undefined){
|
67
|
+
this.currentOffset = this.componentConfig["init_offset"]
|
68
|
+
} else {
|
69
|
+
this.currentOffset = 0
|
70
|
+
}
|
71
|
+
}
|
72
|
+
|
73
|
+
if(queryParamsHelper.getQueryParam(this.componentConfig["id"] + "-limit") != null){
|
74
|
+
this.currentOffset = parseInt(queryParamsHelper.getQueryParam(this.componentConfig["id"] + "-limit"))
|
75
|
+
} else {
|
76
|
+
if(this.componentConfig["init_limit"] != undefined){
|
77
|
+
this.currentLimit = this.componentConfig["init_limit"]
|
78
|
+
} else {
|
79
|
+
this.currentLimit = 10
|
80
|
+
}
|
81
|
+
}
|
82
|
+
|
83
|
+
if(this.componentConfig["filtered_count"] != undefined){
|
84
|
+
this.currentFilteredCount = this.componentConfig["filtered_count"]
|
85
|
+
if(this.currentOffset >= this.currentFilteredCount){
|
86
|
+
this.previous()
|
87
|
+
}
|
88
|
+
}
|
89
|
+
if(this.componentConfig["base_count"] != undefined){
|
90
|
+
this.currentBaseCount = this.componentConfig["base_count"]
|
91
|
+
if(this.currentOffset >= this.currentBaseCount){
|
92
|
+
this.previous()
|
93
|
+
}
|
94
|
+
}
|
95
|
+
}
|
96
|
+
}
|
97
|
+
|
98
|
+
let component = Vue.component('matestack-ui-core-collection-content', componentDef)
|
99
|
+
|
100
|
+
export default componentDef
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Matestack::Ui::Core::Collection::Content
|
2
|
+
class Content < Matestack::Ui::Core::Component::Dynamic
|
3
|
+
|
4
|
+
def setup
|
5
|
+
@rerender = true
|
6
|
+
@component_config = @component_config.except(:data, :paginated_data)
|
7
|
+
end
|
8
|
+
|
9
|
+
def response
|
10
|
+
components {
|
11
|
+
div do
|
12
|
+
yield_components
|
13
|
+
end
|
14
|
+
}
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
import Vue from 'vue/dist/vue.esm'
|
2
|
+
|
3
|
+
import matestackEventHub from 'js/event-hub'
|
4
|
+
import queryParamsHelper from 'js/helpers/query-params-helper'
|
5
|
+
|
6
|
+
import componentMixin from 'component/component'
|
7
|
+
|
8
|
+
const componentDef = {
|
9
|
+
mixins: [componentMixin],
|
10
|
+
data: function(){
|
11
|
+
return {
|
12
|
+
filter: {}
|
13
|
+
}
|
14
|
+
},
|
15
|
+
methods: {
|
16
|
+
submitFilter: function(){
|
17
|
+
var url;
|
18
|
+
var filter = this.filter
|
19
|
+
for (var key in this.filter) {
|
20
|
+
url = queryParamsHelper.updateQueryParams(this.componentConfig["id"] + "-filter-" + key, this.filter[key], url)
|
21
|
+
}
|
22
|
+
url = queryParamsHelper.updateQueryParams(this.componentConfig["id"] + "-offset", 0, url)
|
23
|
+
window.history.pushState({matestackApp: true, url: url}, null, url);
|
24
|
+
matestackEventHub.$emit(this.componentConfig["id"] + "-update")
|
25
|
+
},
|
26
|
+
resetFilter: function(){
|
27
|
+
var url;
|
28
|
+
for (var key in this.filter) {
|
29
|
+
url = queryParamsHelper.updateQueryParams(this.componentConfig["id"] + "-filter-" + key, null, url)
|
30
|
+
this.filter[key] = null;
|
31
|
+
this.$forceUpdate();
|
32
|
+
}
|
33
|
+
window.history.pushState({matestackApp: true, url: url}, null, url);
|
34
|
+
matestackEventHub.$emit(this.componentConfig["id"] + "-update")
|
35
|
+
}
|
36
|
+
},
|
37
|
+
created: function(){
|
38
|
+
var self = this;
|
39
|
+
var queryParamsObject = queryParamsHelper.queryParamsToObject()
|
40
|
+
Object.keys(queryParamsObject).forEach(function(key){
|
41
|
+
if (key.startsWith(self.componentConfig["id"] + "-filter-")){
|
42
|
+
self.filter[key.replace(self.componentConfig["id"] + "-filter-", "")] = queryParamsObject[key]
|
43
|
+
}
|
44
|
+
})
|
45
|
+
}
|
46
|
+
}
|
47
|
+
|
48
|
+
let component = Vue.component('matestack-ui-core-collection-filter', componentDef)
|
49
|
+
|
50
|
+
export default componentDef
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Matestack::Ui::Core::Collection::Filter
|
2
|
+
class Filter < Matestack::Ui::Core::Component::Dynamic
|
3
|
+
|
4
|
+
def setup
|
5
|
+
@component_config = @component_config.except(:data, :paginated_data)
|
6
|
+
end
|
7
|
+
|
8
|
+
def response
|
9
|
+
components {
|
10
|
+
div do
|
11
|
+
yield_components
|
12
|
+
end
|
13
|
+
}
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
- if [:text, :number, :email, :date, :password].include?(options[:type])
|
2
|
+
%input{"v-model#{'.number' if options[:type] == :number}": input_key,
|
3
|
+
type: options[:type],
|
4
|
+
class: options[:class],
|
5
|
+
id: component_id,
|
6
|
+
"@keyup.enter": "submitFilter()",
|
7
|
+
ref: "filter.#{attr_key}",
|
8
|
+
placeholder: options[:placeholder]}
|
@@ -0,0 +1,114 @@
|
|
1
|
+
module Matestack::Ui::Core::Collection
|
2
|
+
|
3
|
+
CollectionConfig = Struct.new(:id, :init_offset, :init_limit, :filtered_count, :base_count, :data, :context) do
|
4
|
+
|
5
|
+
def paginated_data
|
6
|
+
resulting_data = data
|
7
|
+
resulting_data = resulting_data.offset(get_collection_offset) unless get_collection_offset == 0
|
8
|
+
resulting_data = resulting_data.limit(get_collection_limit) unless get_collection_limit == 0
|
9
|
+
|
10
|
+
return resulting_data
|
11
|
+
end
|
12
|
+
|
13
|
+
def get_collection_offset
|
14
|
+
(context[:params]["#{id}-offset".to_sym] ||= init_offset).to_i
|
15
|
+
end
|
16
|
+
|
17
|
+
def get_collection_limit
|
18
|
+
(context[:params]["#{id}-limit".to_sym] ||= init_limit).to_i
|
19
|
+
end
|
20
|
+
|
21
|
+
def pages
|
22
|
+
offset = get_collection_offset
|
23
|
+
limit = get_collection_limit
|
24
|
+
if filtered_count.present?
|
25
|
+
count = filtered_count
|
26
|
+
else
|
27
|
+
count = base_count
|
28
|
+
end
|
29
|
+
page_count = count/limit
|
30
|
+
page_count += 1 if count%limit > 0
|
31
|
+
return (1..page_count).to_a
|
32
|
+
end
|
33
|
+
|
34
|
+
def from
|
35
|
+
return get_collection_offset + 1 if to > 0
|
36
|
+
return 0 if to == 0
|
37
|
+
end
|
38
|
+
|
39
|
+
def to
|
40
|
+
current_to = get_collection_offset + get_collection_limit
|
41
|
+
if filtered_count.present?
|
42
|
+
if current_to > filtered_count
|
43
|
+
return filtered_count
|
44
|
+
else
|
45
|
+
return current_to
|
46
|
+
end
|
47
|
+
else
|
48
|
+
if current_to > base_count
|
49
|
+
return base_count
|
50
|
+
else
|
51
|
+
return current_to
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def config
|
57
|
+
self.to_h.except(:context)
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
|
63
|
+
module Helper
|
64
|
+
|
65
|
+
def get_collection_filter collection_id, key=nil
|
66
|
+
filter_hash = {}
|
67
|
+
context[:params].each do |param_key, param_value|
|
68
|
+
if param_key.start_with?("#{collection_id}-filter-")
|
69
|
+
param_key.gsub("#{collection_id}-filter-", "")
|
70
|
+
filter_hash[param_key.gsub("#{collection_id}-filter-", "").to_sym] = param_value
|
71
|
+
end
|
72
|
+
end
|
73
|
+
if key.nil?
|
74
|
+
return filter_hash
|
75
|
+
else
|
76
|
+
return filter_hash[key]
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def get_collection_order collection_id, key=nil
|
81
|
+
order_hash = {}
|
82
|
+
context[:params].each do |param_key, param_value|
|
83
|
+
if param_key.start_with?("#{collection_id}-order-")
|
84
|
+
param_key.gsub("#{collection_id}-order-", "")
|
85
|
+
order_hash[param_key.gsub("#{collection_id}-order-", "").to_sym] = param_value
|
86
|
+
end
|
87
|
+
end
|
88
|
+
if key.nil?
|
89
|
+
return order_hash
|
90
|
+
else
|
91
|
+
return order_hash[key]
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def set_collection id: nil, init_offset: 0, init_limit: nil, base_count: nil, filtered_count: nil, data: nil
|
96
|
+
@collections = {} if @collections.nil?
|
97
|
+
|
98
|
+
collection_config = CollectionConfig.new(
|
99
|
+
id,
|
100
|
+
init_offset,
|
101
|
+
init_limit,
|
102
|
+
filtered_count,
|
103
|
+
base_count,
|
104
|
+
data,
|
105
|
+
context
|
106
|
+
)
|
107
|
+
|
108
|
+
@collections[id.to_sym] = collection_config
|
109
|
+
|
110
|
+
return collection_config
|
111
|
+
end
|
112
|
+
|
113
|
+
end
|
114
|
+
end
|