Skip to content

Commit e920e72

Browse files
committed
Merge branch 'develop' into sf/form-transition-redirect-to
2 parents 41c749c + 65dbddd commit e920e72

File tree

8 files changed

+60
-50
lines changed

8 files changed

+60
-50
lines changed

Gemfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import Vue from 'vue/dist/vue.esm'
22
import VRuntimeTemplate from "v-runtime-template"
33
import Vuex from 'vuex'
4-
import isNavigatingToAnotherPage from "./location"
54

65
const componentDef = {
76
props: ['appConfig', 'params'],
@@ -10,12 +9,14 @@ const componentDef = {
109
},
1110
computed: Vuex.mapState({
1211
asyncTemplate: state => state.pageTemplate,
12+
currentPath: state => state.currentPath
1313
}),
1414
mounted: function(){
15+
const self = this;
1516
window.onpopstate = (event) => {
16-
if (isNavigatingToAnotherPage(document.location, event)) {
17-
this.$store.dispatch("navigateTo", {url: document.location.pathname, backwards: true} );
18-
};
17+
if (self.currentPath != document.location.pathname){
18+
self.$store.dispatch("navigateTo", {url: document.location.pathname, backwards: true} );
19+
}
1920
}
2021
},
2122
components: {

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

Lines changed: 0 additions & 10 deletions
This file was deleted.

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

spec/usage/components/transition_spec.rb

Lines changed: 43 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,44 @@ 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.evaluate_script('window.history.back()')
145+
page.go_back
146+
147+
element = page.find("#my-div-on-page-1")
148+
refreshed_content_on_page_1 = element.text
149+
150+
expect(page).to have_content("My Example App Layout")
151+
expect(page).to have_content("This is Page 1")
152+
expect(page).not_to have_content("This is Page 2")
153+
expect(page).to have_selector("body.not-reloaded")
154+
155+
expect(first_content_on_page_1).not_to eq(refreshed_content_on_page_1)
156+
end
157+
116158
# supposed to work, but doesn't. Suspect Vue is the culprint here
117159
# it "Example 2 - Perform transition from one page to another by providing route as string (not recommended)" do
118160
#

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

Lines changed: 5 additions & 28 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.

0 commit comments

Comments
 (0)