Skip to content

Commit 6fc8032

Browse files
committed
Merge branch 'develop' into 232
2 parents 4eea2d6 + 61142d4 commit 6fc8032

File tree

16 files changed

+119
-54
lines changed

16 files changed

+119
-54
lines changed

Gemfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ 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'

Gemfile.lock

Lines changed: 3 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)

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: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,18 @@ 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
1923
}
2024
},
2125
actions: {
@@ -46,7 +50,7 @@ const store = new Vuex.Store({
4650
setTimeout(function () {
4751
resolve(response["data"])
4852
commit('setPageTemplate', response["data"])
49-
commit('setCurrentPath', url)
53+
commit('setCurrentLocation', { path: url, search: document.location.search, origin: document.location.origin })
5054
matestackEventHub.$emit("page_loaded", url);
5155
if (typeof matestackUiCoreTransitionSuccess !== 'undefined') {
5256
matestackUiCoreTransitionSuccess(url);

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
}

app/lib/matestack/ui/core/has_view_context.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ def initialize(model = nil, options = {})
55
end
66

77
def method_missing(*args, &block)
8-
@view_context.send(*args, &block)
8+
if @view_context.respond_to? args.first
9+
@view_context.send(*args, &block)
10+
else
11+
super
12+
end
913
end
1014
end

builder/Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ruby '2.6.5'
66
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
77
gem 'rails', '~> 5.2.0'
88
# Use Puma as the app server
9-
gem 'puma', '~> 3.11'
9+
gem 'puma', '~> 3.12'
1010
# Use SCSS for stylesheets
1111
gem 'sass-rails', '~> 5.0'
1212
# Use Uglifier as compressor for JavaScript assets

builder/Gemfile.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ GEM
8484
minitest (5.14.0)
8585
msgpack (1.3.1)
8686
nio4r (2.5.2)
87-
nokogiri (1.10.7)
87+
nokogiri (1.10.8)
8888
mini_portile2 (~> 2.4.0)
89-
puma (3.12.2)
89+
puma (3.12.4)
9090
rack (2.1.2)
9191
rack-proxy (0.6.5)
9292
rack
@@ -168,7 +168,7 @@ DEPENDENCIES
168168
coffee-rails (~> 4.2)
169169
jbuilder (~> 2.5)
170170
listen (>= 3.0.5, < 3.2)
171-
puma (~> 3.11)
171+
puma (~> 3.12)
172172
rails (~> 5.2.0)
173173
sass-rails (~> 5.0)
174174
tzinfo-data

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"v-runtime-template": "^1.5.2",
1010
"vue": "^2.5.17",
1111
"vuex": "^3.0.1",
12-
"yarn": "^1.17.3"
12+
"yarn": "^1.22.0"
1313
},
1414
"exports": {
1515
"./concepts/": "./app/concepts/matestack/ui/core/"

spec/dummy/yarn.lock

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4023,22 +4023,14 @@ js-base64@^2.1.8:
40234023
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499"
40244024
integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==
40254025

4026-
js-yaml@^3.13.1:
4026+
js-yaml@^3.13.1, js-yaml@^3.9.0:
40274027
version "3.13.1"
40284028
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.13.1.tgz#aff151b30bfdfa8e49e05da22e7415e9dfa37847"
40294029
integrity sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==
40304030
dependencies:
40314031
argparse "^1.0.7"
40324032
esprima "^4.0.0"
40334033

4034-
js-yaml@^3.9.0:
4035-
version "3.12.0"
4036-
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.12.0.tgz#eaed656ec8344f10f527c6bfa1b6e2244de167d1"
4037-
integrity sha512-PIt2cnwmPfL4hKNwqeiuz4bKfnzHTBv6HyVgjahA6mPLwPDzjDWrplJBMjHUFxku/N3FlmrbyPclad+I+4mJ3A==
4038-
dependencies:
4039-
argparse "^1.0.7"
4040-
esprima "^4.0.0"
4041-
40424034
jsbn@~0.1.0:
40434035
version "0.1.1"
40444036
resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513"
@@ -4372,7 +4364,7 @@ map-visit@^1.0.0:
43724364
object-visit "^1.0.0"
43734365

43744366
matestack-ui-core@../../:
4375-
version "0.7.3"
4367+
version "0.7.4"
43764368
dependencies:
43774369
axios "^0.18.1"
43784370
link-module-alias "^1.2.0"

spec/usage/components/transition_spec.rb

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
describe "Transition Component", type: :feature, js: true do
55

6-
it "Example 1 - Perform transition from one page to another without page reload if related to app" do
6+
before :all do
77

88
class Apps::ExampleApp < Matestack::Ui::App
99

@@ -78,6 +78,10 @@ def page2
7878
end
7979
Rails.application.reload_routes!
8080

81+
end
82+
83+
it "Example 1 - Perform transition from one page to another without page reload if related to app" do
84+
8185
visit "/my_example_app/page1"
8286

8387
expect(page).to have_content("My Example App Layout")
@@ -113,6 +117,46 @@ def page2
113117
expect(first_content_on_page_1).not_to eq(refreshed_content_on_page_1)
114118
end
115119

120+
it "Example 2 - Perform transition from one page to another without page reload when using page history buttons" do
121+
122+
visit "/my_example_app/page1"
123+
124+
expect(page).to have_content("My Example App Layout")
125+
expect(page).to have_button("Page 1")
126+
expect(page).to have_button("Page 2")
127+
128+
expect(page).to have_content("This is Page 1")
129+
expect(page).not_to have_content("This is Page 2")
130+
131+
element = page.find("#my-div-on-page-1")
132+
first_content_on_page_1 = element.text
133+
134+
page.evaluate_script('document.body.classList.add("not-reloaded")')
135+
expect(page).to have_selector("body.not-reloaded")
136+
137+
click_button("Page 2")
138+
139+
expect(page).to have_content("My Example App Layout")
140+
expect(page).not_to have_content("This is Page 1")
141+
expect(page).to have_content("This is Page 2")
142+
expect(page).to have_selector("body.not-reloaded")
143+
144+
page.go_back
145+
146+
expect(page).to have_content("My Example App Layout")
147+
expect(page).to have_content("This is Page 1")
148+
expect(page).not_to have_content("This is Page 2")
149+
expect(page).to have_selector("body.not-reloaded")
150+
expect(page).to have_no_content(first_content_on_page_1)
151+
152+
page.go_forward
153+
154+
expect(page).to have_content("My Example App Layout")
155+
expect(page).not_to have_content("This is Page 1")
156+
expect(page).to have_content("This is Page 2")
157+
expect(page).to have_selector("body.not-reloaded")
158+
end
159+
116160
# supposed to work, but doesn't. Suspect Vue is the culprint here
117161
# it "Example 2 - Perform transition from one page to another by providing route as string (not recommended)" do
118162
#

vendor/assets/javascripts/dist/manifest.json

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,21 @@
22
"entrypoints": {
33
"matestack-ui-core": {
44
"css": [
5-
"/dist/matestack-ui-core.min.css"
5+
"/dist/matestack-ui-core.css"
66
],
77
"js": [
8-
"/dist/matestack-ui-core.min.js"
8+
"/dist/matestack-ui-core.js"
9+
],
10+
"css.map": [
11+
"/dist/matestack-ui-core.css.map"
912
],
1013
"js.map": [
11-
"/dist/matestack-ui-core.min.js.map"
14+
"/dist/matestack-ui-core.js.map"
1215
]
1316
}
1417
},
15-
"matestack-ui-core.css": "/dist/matestack-ui-core.min.css",
16-
"matestack-ui-core.js": "/dist/matestack-ui-core.min.js",
17-
"matestack-ui-core.js.map": "/dist/matestack-ui-core.min.js.map"
18+
"matestack-ui-core.css": "/dist/matestack-ui-core.css",
19+
"matestack-ui-core.css.map": "/dist/matestack-ui-core.css.map",
20+
"matestack-ui-core.js": "/dist/matestack-ui-core.js",
21+
"matestack-ui-core.js.map": "/dist/matestack-ui-core.js.map"
1822
}

vendor/assets/javascripts/dist/matestack-ui-core.js

Lines changed: 22 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/assets/javascripts/dist/matestack-ui-core.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ vuex@^3.0.1:
101101
resolved "https://registry.yarnpkg.com/vuex/-/vuex-3.1.1.tgz#0c264bfe30cdbccf96ab9db3177d211828a5910e"
102102
integrity sha512-ER5moSbLZuNSMBFnEBVGhQ1uCBNJslH9W/Dw2W7GZN23UQA69uapP5GTT9Vm8Trc0PzBSVt6LzF3hGjmv41xcg==
103103

104-
yarn@^1.17.3:
105-
version "1.19.1"
106-
resolved "https://registry.yarnpkg.com/yarn/-/yarn-1.19.1.tgz#14b92410dd1ba5bab87a12b4a3d807f4569bea97"
107-
integrity sha512-gBnfbL9rYY05Gt0cjJhs/siqQXHYlZalTjK3nXn2QO20xbkIFPob+LlH44ML47GcR4VU9/2dYck1BWFM0Javxw==
104+
yarn@^1.22.0:
105+
version "1.22.0"
106+
resolved "https://registry.yarnpkg.com/yarn/-/yarn-1.22.0.tgz#acf82906e36bcccd1ccab1cfb73b87509667c881"
107+
integrity sha512-KMHP/Jq53jZKTY9iTUt3dIVl/be6UPs2INo96+BnZHLKxYNTfwMmlgHTaMWyGZoO74RI4AIFvnWhYrXq2USJkg==

0 commit comments

Comments
 (0)