Skip to content

Commit ca8054d

Browse files
authored
Merge pull request #398 from matestack/develop
0.7.5 Release
2 parents 5812a76 + f70638f commit ca8054d

File tree

43 files changed

+897
-295
lines changed

Some content is hidden

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

43 files changed

+897
-295
lines changed

.github/workflows/dockerpush.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ jobs:
1212
- name: Run tests
1313
run: |
1414
docker-compose run --rm test bundle exec rake db:schema:load
15-
docker-compose run --rm test bundle exec rspec spec/usage
15+
docker-compose run --rm test bundle exec rspec spec/usage spec/lib

CHANGELOG.md

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

3+
## v0.7.5
4+
5+
[Merged PRs](https://github.com/basemate/matestack-ui-core/pulls?q=is%3Apr+is%3Aclosed+milestone%3A0.7.5)
6+
7+
[Solved Issues](https://github.com/basemate/matestack-ui-core/issues?q=is%3Aissue+is%3Aclosed+milestone%3A0.7.5)
8+
9+
### Security Fixes
10+
11+
* Various dependency version bumps by dependabot
12+
13+
### Improvements
14+
15+
* Added `datalist` component
16+
* Added `range` type for `form_input`
17+
* Integrated generator specs in CI spec run
18+
* Added `turbolinks` support
19+
* Form component: Add support for `redirect_to` in the controller
20+
* HasViewContext: Check in advance whether the view context would respond to a missing method.
21+
22+
### Bugfixes
23+
24+
* Fixed broken history button behavior introduced in `0.7.4` #386
25+
326
## v0.7.4
427

528
[Merged PRs](https://github.com/basemate/matestack-ui-core/pulls?q=is%3Apr+is%3Aclosed+milestone%3A0.7.4)
@@ -10,7 +33,7 @@
1033

1134
XSS/Script injection vulnerablilty fixed in 0.7.4
1235

13-
* matestack-ui-core was vulnerable to XSS/Script injection
36+
* matestack-ui-core was vulnerable to XSS/Script injection
1437
* matestack-ui-core did not excape strings by default and did not cover this in the docs
1538
* matestack-ui-core should have escaped strings by default in order to prevent XSS/Script injection vulnerability
1639
* 0.7.4 fixes that by performing string escaping by default now
@@ -88,9 +111,9 @@ reported by @PragTob
88111
* New webpacker features by fiedl
89112

90113
* make webpacker create es5 code instead of es6 code
91-
114+
92115
* Switch to Vue Production Mode if RAILS_ENV=staging or production
93-
116+
94117
* Establish webpack(er) and asset-pipeline workflows
95118

96119
--> webpacker now builds assets for asset pipline usage AND webpacker usage (both usage approaches are described in the installation docs)
@@ -101,22 +124,22 @@ reported by @PragTob
101124

102125
--> when used via asset pipeline, the minified version of matestack-ui-core together with the production build of vue.js is automatically required
103126

104-
--> when used via webpacker, matestack-ui-core can be used within a modern javascript workflow, importing and extending
127+
--> when used via webpacker, matestack-ui-core can be used within a modern javascript workflow, importing and extending
105128
single matestack module for example
106129

107130
* New components
108131
* Add HTML `<picture>` tag to core components by pascalwengerter
109132
* Add HTML `<option>` tag to core components by pascalwengerter
110133
* Add HTML `<optgroup>` tag to core components by pascalwengerter
111-
* Add HTML `<iframe>` tag to core components by pascalwengerter
112-
* Add HTML `<dfn>` tag to core components by pascalwengerter
134+
* Add HTML `<iframe>` tag to core components by pascalwengerter
135+
* Add HTML `<dfn>` tag to core components by pascalwengerter
113136
* Add HTML `<del>` tag to core components by pascalwengerter
114137
* Add HTML `<data>` tag to core components by pascalwengerter
115138
* Add HTML `<bdo>` tag to core components by pascalwengerter
116139
* Add HTML `<bdi>` tag to core components by pascalwengerter
117140
* Add HTML `<wbr>` tag to core components by pascalwengerter
118141
* Add HTML `<samp>` tag to core components by pascalwengerter
119-
* Add HTML `<u>` tag to core components by pascalwengerter
142+
* Add HTML `<u>` tag to core components by pascalwengerter
120143
* Add HTML `<template>` tag to core components by pascalwengerter
121144

122145

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ group :development, :test do
2626
gem 'puma'
2727
gem 'simplecov', require: false, group: :test
2828
gem 'byebug'
29-
gem 'pry-byebug'
3029
gem 'webmock'
3130
gem 'pry-rails'
3231
gem 'pry-byebug'
32+
gem 'turbolinks'
3333
end
3434

3535
group :test do

Gemfile.lock

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
matestack-ui-core (0.7.3)
4+
matestack-ui-core (0.7.4)
55
cells-haml
66
cells-rails
77
haml
@@ -121,7 +121,7 @@ GEM
121121
mini_portile2 (2.4.0)
122122
minitest (5.14.0)
123123
nio4r (2.5.2)
124-
nokogiri (1.10.7)
124+
nokogiri (1.10.8)
125125
mini_portile2 (~> 2.4.0)
126126
pipetree (0.1.1)
127127
pry (0.12.2)
@@ -133,7 +133,7 @@ GEM
133133
pry-rails (0.3.9)
134134
pry (>= 0.10.4)
135135
public_suffix (4.0.3)
136-
puma (4.3.1)
136+
puma (4.3.3)
137137
nio4r (~> 2.0)
138138
rack (2.2.1)
139139
rack-proxy (0.6.5)
@@ -237,6 +237,9 @@ GEM
237237
reform-rails (>= 0.1.4, < 0.2.0)
238238
trailblazer (~> 2.0.0)
239239
trailblazer-loader (>= 0.1.0)
240+
turbolinks (5.2.1)
241+
turbolinks-source (~> 5.2)
242+
turbolinks-source (5.2.0)
240243
tzinfo (1.2.6)
241244
thread_safe (~> 0.1)
242245
uber (0.1.0)
@@ -276,6 +279,7 @@ DEPENDENCIES
276279
trailblazer
277280
trailblazer-cells
278281
trailblazer-rails
282+
turbolinks
279283
webmock
280284
webpacker (~> 4.0)
281285

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,20 @@ const componentDef = {
1010
},
1111
computed: Vuex.mapState({
1212
asyncTemplate: state => state.pageTemplate,
13+
currentPathName: state => state.currentPathName,
14+
currentSearch: state => state.currentSearch,
15+
currentOrigin: state => state.currentOrigin,
1316
}),
1417
mounted: function(){
18+
const self = this;
1519
window.onpopstate = (event) => {
16-
if (isNavigatingToAnotherPage(document.location, event)) {
17-
this.$store.dispatch("navigateTo", {url: document.location.pathname, backwards: true} );
18-
};
20+
if (isNavigatingToAnotherPage({
21+
origin: self.currentOrigin,
22+
pathName: self.currentPathName,
23+
search: self.currentSearch
24+
}, document.location)){
25+
self.$store.dispatch("navigateTo", {url: document.location.pathname, backwards: true} );
26+
}
1927
}
2028
},
2129
components: {

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
const isNavigatingToAnotherPage = function(currentLocation, popstateEvent) {
2-
const targetLocation = popstateEvent.target.location;
1+
const isNavigatingToAnotherPage = function(currentLocation, targetLocation) {
32

43
// omits hash by design
5-
return currentLocation.pathname !== targetLocation.pathname ||
4+
return currentLocation.pathName !== targetLocation.pathname ||
65
currentLocation.origin !== targetLocation.origin ||
76
currentLocation.search !== targetLocation.search
87
}

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,21 @@ Vue.use(Vuex)
88
const store = new Vuex.Store({
99
state: {
1010
pageTemplate: null,
11-
currentPath: document.location.pathname
11+
currentPathName: document.location.pathname,
12+
currentSearch: document.location.search,
13+
currentOrigin: document.location.origin
1214
},
1315
mutations: {
1416
setPageTemplate (state, serverResponse){
1517
state.pageTemplate = serverResponse
1618
},
17-
setCurrentPath (state, path){
18-
state.currentPath = path
19+
setCurrentLocation (state, current){
20+
state.currentPathName = current.path
21+
state.currentSearch = current.search
22+
state.currentOrigin = current.origin
23+
},
24+
resetPageTemplate (state) {
25+
state.pageTemplate = null;
1926
}
2027
},
2128
actions: {
@@ -46,7 +53,7 @@ const store = new Vuex.Store({
4653
setTimeout(function () {
4754
resolve(response["data"])
4855
commit('setPageTemplate', response["data"])
49-
commit('setCurrentPath', url)
56+
commit('setCurrentLocation', { path: url, search: document.location.search, origin: document.location.origin })
5057
matestackEventHub.$emit("page_loaded", url);
5158
if (typeof matestackUiCoreTransitionSuccess !== 'undefined') {
5259
matestackUiCoreTransitionSuccess(url);
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
%datalist{@tag_attributes}
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::Datalist
2+
class Datalist < Matestack::Ui::Core::Component::Static
3+
4+
end
5+
end

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ const componentDef = {
137137
&& self.componentConfig["success"]["transition"]["follow_response"] === true
138138
&& self.$store != undefined
139139
) {
140-
let path = response.data["transition_to"]
140+
let path = response.data["transition_to"] || response.request.responseURL
141141
self.$store.dispatch('navigateTo', {url: path, backwards: false})
142142
return;
143143
}
Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,38 @@
1-
- if options[:label]
2-
%label=options[:label]
1+
- if label
2+
%label=label
33

4-
- if [:text, :number, :email, :date, :password].include?(options[:type])
5-
%input{@tag_attributes,
6-
"v-model#{'.number' if options[:type] == :number}": input_key,
7-
type: options[:type],
4+
- if [:text, :number, :email, :date, :password].include?(type)
5+
%input{ @tag_attributes,
6+
"v-model#{'.number' if type == :number}": input_key,
7+
type: type,
88
"@change": "inputChanged(\"#{attr_key}\")",
99
ref: "input.#{attr_key}",
10-
placeholder: options[:placeholder],
11-
"init-value": init_value}
12-
%span{class: "errors", "v-if": error_key }
13-
%span{class: "error", "v-for": "error in #{error_key}"}
14-
{{ error }}
10+
placeholder: placeholder,
11+
"init-value": init_value }
1512

16-
- if options[:type] == :textarea
17-
%textarea{@tag_attributes,
13+
- if type == :textarea
14+
%textarea{ @tag_attributes,
1815
"v-model": input_key,
1916
"@change": "inputChanged(\"#{attr_key}\")",
2017
ref: "input.#{attr_key}",
21-
placeholder: options[:placeholder],
18+
placeholder: placeholder,
2219
"init-value": init_value,
2320
rows: options[:rows],
24-
cols: options[:cols]}
25-
%span{class: "errors", "v-if": error_key }
26-
%span{class: "error", "v-for": "error in #{error_key}"}
27-
{{ error }}
21+
cols: options[:cols] }
22+
23+
- if type == :range
24+
%input{ @tag_attributes,
25+
"v-model": input_key,
26+
type: :range,
27+
"@change": "inputChanged(\"#{attr_key}\")",
28+
ref: "input.#{attr_key}",
29+
placeholder: placeholder,
30+
"init-value": init_value,
31+
min: options[:min],
32+
max: options[:max],
33+
step: options[:step],
34+
list: options[:list] }
35+
36+
%span{ class: "errors", "v-if": error_key }
37+
%span{ class: "error", "v-for": "error in #{error_key}" }
38+
{{ error }}

app/concepts/matestack/ui/core/form/input/input.rb

Lines changed: 36 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,35 @@ def custom_options_validation
77
raise "included form config is missing, please add ':include' to parent form component" if @included_config.nil?
88
end
99

10+
def key
11+
options[:key]
12+
end
13+
14+
def label
15+
options[:label]
16+
end
17+
18+
def type
19+
options[:type]
20+
end
21+
22+
def placeholder
23+
options[:placeholder]
24+
end
25+
1026
def input_key
11-
'data["' + options[:key].to_s + '"]'
27+
"data['#{key.to_s}']"
1228
end
1329

1430
def error_key
15-
'errors["' + options[:key].to_s + '"]'
31+
"errors['#{key.to_s}']"
1632
end
1733

1834
def input_wrapper
1935
case options[:for]
2036
when nil
2137
return nil
22-
when Symbol
23-
return options[:for]
24-
when String
38+
when Symbol, String
2539
return options[:for]
2640
end
2741
if options[:for].respond_to?(:model_name)
@@ -31,44 +45,37 @@ def input_wrapper
3145

3246
def attr_key
3347
if input_wrapper.nil?
34-
return options[:key].to_s
48+
return key.to_s
3549
else
36-
return "#{input_wrapper}.#{options[:key].to_s}"
50+
return "#{input_wrapper}.#{key.to_s}"
3751
end
3852
end
3953

4054
def init_value
41-
unless options[:init].nil?
42-
return options[:init]
43-
end
55+
return options[:init] unless options[:init].nil?
4456

4557
unless options[:for].nil?
46-
value = options[:for].send(options[:key])
47-
if [true, false].include? value
48-
value ? 1 : 0
49-
else
50-
return value
51-
end
58+
value = parse_value(options[:for].send key)
5259
else
5360
unless @included_config.nil? && @included_config[:for].nil?
54-
if @included_config[:for].respond_to?(options[:key])
55-
value = @included_config[:for].send(options[:key])
56-
if [true, false].include? value
57-
value ? 1 : 0
58-
else
59-
return value
60-
end
61+
if @included_config[:for].respond_to?(key)
62+
value = parse_value(@included_config[:for].send key)
6163
else
62-
if @included_config[:for].is_a?(Symbol) || @included_config[:for].is_a?(String)
63-
return nil
64-
end
65-
if @included_config[:for].is_a?(Hash)
66-
return @included_config[:for][options[:key]]
67-
end
64+
@included_config[:for][key] if @included_config[:for].is_a?(Hash)
6865
end
6966
end
7067
end
7168
end
7269

70+
private
71+
72+
def parse_value(value)
73+
if [true, false].include? value
74+
value ? 1 : 0
75+
else
76+
return value
77+
end
78+
end
79+
7380
end
7481
end
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
%input{@tag_attributes}
2-
- if block_given?
3-
= yield
1+
%input{ @tag_attributes,
2+
type: type }

0 commit comments

Comments
 (0)