Skip to content

Commit 3d0d618

Browse files
authored
Merge pull request #101 from basemate/develop
0.7.1 Release
2 parents 6c6668b + cf82a65 commit 3d0d618

File tree

102 files changed

+4747
-342
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+4747
-342
lines changed

CHANGELOG.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,28 @@
11
# Changelog
22

3+
## v0.7.1
4+
5+
[Merged PRs](https://github.com/basemate/matestack-ui-core/milestone/3?closed=1)
6+
7+
### Improvements
8+
9+
- Introduce scaffolder #72 by PasWen
10+
- Make buttons disableable enhancement by PasWen
11+
- Collection Component #98 by jonasjabari
12+
- Added Async Defer Feature #100 by jonasjabari
13+
- Added blockquote tag to main component #88 by cameronnorman
14+
- Added small tags #87 by cameronnorman
15+
- Added strong tag #93 by cameronnorman
16+
- Added Infos that async component can currently only be used on page leve #85 by jonasjabari was merged 10
17+
- Update span component in 0.7.0 #74 by PasWen
18+
- Add documented, untested video component #70 by PasWen
19+
- Added summary details components #76 by bdlb77
20+
- Add caption with doc and specs enhancement #68 by michaelrevans
21+
22+
### Bugfixes
23+
24+
- Fixed Link Component #84 by jonasjabari
25+
326
## v0.7.0
427

528
### Breaking changes for users

Gemfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,7 @@ group :development, :test do
3232
gem 'byebug'
3333
gem 'webmock'
3434
end
35+
36+
group :test do
37+
gem "generator_spec"
38+
end

Gemfile.lock

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
matestack-ui-core (0.6.0)
4+
matestack-ui-core (0.7.0)
55
cells-haml
66
cells-rails
77
haml
@@ -99,6 +99,9 @@ GEM
9999
docile (1.3.1)
100100
erubi (1.7.1)
101101
ffi (1.9.25)
102+
generator_spec (0.9.4)
103+
activesupport (>= 3.0.0)
104+
railties (>= 3.0.0)
102105
globalid (0.4.2)
103106
activesupport (>= 4.2.0)
104107
haml (5.0.4)
@@ -250,6 +253,7 @@ DEPENDENCIES
250253
capybara
251254
cells-haml
252255
cells-rails
256+
generator_spec
253257
matestack-ui-core!
254258
poltergeist
255259
puma

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

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,16 @@ const componentDef = {
1818
methods: {
1919
show: function(event_data){
2020
const self = this
21+
if (this.showing === true){
22+
return
23+
}
2124
this.showing = true
2225
this.event.data = event_data
26+
if(this.componentConfig["defer"] != undefined){
27+
if(!isNaN(this.componentConfig["defer"])){
28+
this.startDefer()
29+
}
30+
}
2331
if(this.componentConfig["hide_after"] != undefined){
2432
self.hide_after_timeout = setTimeout(function () {
2533
self.hide()
@@ -29,6 +37,12 @@ const componentDef = {
2937
hide: function(){
3038
this.showing = false
3139
this.event.data = {}
40+
},
41+
startDefer: function(){
42+
const self = this
43+
setTimeout(function () {
44+
self.rerender()
45+
}, parseInt(this.componentConfig["defer"]));
3246
}
3347
},
3448
created: function () {
@@ -39,8 +53,12 @@ const componentDef = {
3953
if(this.componentConfig["show_on"] != undefined){
4054
this.showing = false
4155
}
42-
if(this.componentConfig["hide_on"] != undefined){
43-
this.showing = true
56+
if(this.componentConfig["defer"] != undefined){
57+
if(!isNaN(this.componentConfig["defer"])){
58+
if (this.componentConfig["show_on"] == undefined){
59+
this.startDefer()
60+
}
61+
}
4462
}
4563
},
4664
beforeDestroy: function() {
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
%blockquote{@tag_attributes}
2+
- if options[:text].nil? && block_given?
3+
= yield
4+
- else
5+
= options[:text]
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module Matestack::Ui::Core::Blockquote
2+
class Blockquote < Matestack::Ui::Core::Component::Static
3+
def setup
4+
@tag_attributes.merge!({
5+
"cite": options[:cite]
6+
})
7+
end
8+
end
9+
end
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
module Matestack::Ui::Core::Button
22
class Button < Matestack::Ui::Core::Component::Static
33

4+
def setup
5+
@tag_attributes.merge!({
6+
"disabled": options[:disabled] ||= nil
7+
})
8+
end
9+
410
end
511
end
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
%caption{@tag_attributes}
2+
- if options[:text].nil?
3+
- if block_given?
4+
= yield
5+
- else
6+
= options[:text]
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module Matestack::Ui::Core::Caption
2+
class Caption < Matestack::Ui::Core::Component::Static
3+
4+
end
5+
end
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
%a{@tag_attributes, "@click": "next()"}
2+
- if block_given?
3+
= yield
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module Matestack::Ui::Core::Collection::Content::Next
2+
class Next < Matestack::Ui::Core::Component::Static
3+
4+
end
5+
end
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
%a{@tag_attributes, "@click": "goToPage(#{@options[:page]})"}
2+
- if block_given?
3+
= yield
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module Matestack::Ui::Core::Collection::Content::Page::Link
2+
class Link < Matestack::Ui::Core::Component::Static
3+
4+
end
5+
end
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
%a{@tag_attributes, "@click": "previous()"}
2+
- if block_given?
3+
= yield
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module Matestack::Ui::Core::Collection::Content::Previous
2+
class Previous < Matestack::Ui::Core::Component::Static
3+
4+
end
5+
end
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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]}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module Matestack::Ui::Core::Collection::Filter::Input
2+
class Input < Matestack::Ui::Core::Component::Static
3+
4+
def input_key
5+
'filter["' + options[:key].to_s + '"]'
6+
end
7+
8+
def attr_key
9+
return options[:key].to_s
10+
end
11+
12+
end
13+
end
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
%a{@tag_attributes, "@click": "resetFilter()"}
2+
- if block_given?
3+
= yield

0 commit comments

Comments
 (0)