Skip to content

Commit 2337d87

Browse files
authored
Merge pull request #314 from matestack/sf/fix-form-reset-on-update-issue-304
Fixing form-reset issue #304
2 parents f42974e + 941cc3c commit 2337d87

File tree

9 files changed

+605
-88
lines changed

9 files changed

+605
-88
lines changed

Gemfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ group :development, :test do
2828
gem 'byebug'
2929
gem 'pry-byebug'
3030
gem 'webmock'
31-
# gem 'webdrivers', '~> 4.1'
31+
gem 'pry-rails'
32+
gem 'pry-byebug'
3233
end
3334

3435
group :test do

Gemfile.lock

Lines changed: 81 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -5,60 +5,60 @@ PATH
55
cells-haml
66
cells-rails
77
haml
8-
rails (>= 5.0.0)
8+
rails (~> 5.0)
99
trailblazer
1010
trailblazer-cells
1111
trailblazer-rails (= 1.0.9)
1212

1313
GEM
1414
remote: https://rubygems.org/
1515
specs:
16-
actioncable (5.2.3)
17-
actionpack (= 5.2.3)
16+
actioncable (5.2.4.1)
17+
actionpack (= 5.2.4.1)
1818
nio4r (~> 2.0)
1919
websocket-driver (>= 0.6.1)
20-
actionmailer (5.2.3)
21-
actionpack (= 5.2.3)
22-
actionview (= 5.2.3)
23-
activejob (= 5.2.3)
20+
actionmailer (5.2.4.1)
21+
actionpack (= 5.2.4.1)
22+
actionview (= 5.2.4.1)
23+
activejob (= 5.2.4.1)
2424
mail (~> 2.5, >= 2.5.4)
2525
rails-dom-testing (~> 2.0)
26-
actionpack (5.2.3)
27-
actionview (= 5.2.3)
28-
activesupport (= 5.2.3)
29-
rack (~> 2.0)
26+
actionpack (5.2.4.1)
27+
actionview (= 5.2.4.1)
28+
activesupport (= 5.2.4.1)
29+
rack (~> 2.0, >= 2.0.8)
3030
rack-test (>= 0.6.3)
3131
rails-dom-testing (~> 2.0)
3232
rails-html-sanitizer (~> 1.0, >= 1.0.2)
33-
actionview (5.2.3)
34-
activesupport (= 5.2.3)
33+
actionview (5.2.4.1)
34+
activesupport (= 5.2.4.1)
3535
builder (~> 3.1)
3636
erubi (~> 1.4)
3737
rails-dom-testing (~> 2.0)
3838
rails-html-sanitizer (~> 1.0, >= 1.0.3)
39-
activejob (5.2.3)
40-
activesupport (= 5.2.3)
39+
activejob (5.2.4.1)
40+
activesupport (= 5.2.4.1)
4141
globalid (>= 0.3.6)
42-
activemodel (5.2.3)
43-
activesupport (= 5.2.3)
44-
activerecord (5.2.3)
45-
activemodel (= 5.2.3)
46-
activesupport (= 5.2.3)
42+
activemodel (5.2.4.1)
43+
activesupport (= 5.2.4.1)
44+
activerecord (5.2.4.1)
45+
activemodel (= 5.2.4.1)
46+
activesupport (= 5.2.4.1)
4747
arel (>= 9.0)
48-
activestorage (5.2.3)
49-
actionpack (= 5.2.3)
50-
activerecord (= 5.2.3)
48+
activestorage (5.2.4.1)
49+
actionpack (= 5.2.4.1)
50+
activerecord (= 5.2.4.1)
5151
marcel (~> 0.3.1)
52-
activesupport (5.2.3)
52+
activesupport (5.2.4.1)
5353
concurrent-ruby (~> 1.0, >= 1.0.2)
5454
i18n (>= 0.7, < 2)
5555
minitest (~> 5.1)
5656
tzinfo (~> 1.1)
5757
addressable (2.7.0)
5858
public_suffix (>= 2.0.2, < 5.0)
5959
arel (9.0.0)
60-
builder (3.2.3)
61-
byebug (11.0.0)
60+
builder (3.2.4)
61+
byebug (11.1.1)
6262
capybara (3.31.0)
6363
addressable
6464
mini_mime (>= 0.1.3)
@@ -75,51 +75,51 @@ GEM
7575
cells-haml (0.0.10)
7676
cells (>= 4.0.1, <= 6.0.0)
7777
haml (>= 4.1.0.beta.1)
78-
cells-rails (0.0.9)
79-
actionpack (>= 3.0)
78+
cells-rails (0.1.0)
79+
actionpack (>= 5.0)
8080
cells (>= 4.1.6, < 5.0.0)
8181
childprocess (3.0.0)
8282
coderay (1.1.2)
8383
concurrent-ruby (1.1.5)
8484
crack (0.4.3)
8585
safe_yaml (~> 1.0.0)
86-
crass (1.0.5)
86+
crass (1.0.6)
8787
declarative (0.0.10)
8888
declarative-builder (0.1.0)
8989
declarative-option (< 0.2.0)
9090
declarative-option (0.1.0)
9191
diff-lcs (1.3)
92-
disposable (0.4.4)
92+
disposable (0.4.7)
9393
declarative (>= 0.0.9, < 1.0.0)
9494
declarative-builder (< 0.2.0)
9595
declarative-option (< 0.2.0)
9696
representable (>= 2.4.0, <= 3.1.0)
9797
uber (< 0.2.0)
9898
docile (1.3.2)
99-
erubi (1.8.0)
99+
erubi (1.9.0)
100100
generator_spec (0.9.4)
101101
activesupport (>= 3.0.0)
102102
railties (>= 3.0.0)
103103
globalid (0.4.2)
104104
activesupport (>= 4.2.0)
105-
haml (5.0.4)
105+
haml (5.1.2)
106106
temple (>= 0.8.0)
107107
tilt
108-
hashdiff (0.3.8)
109-
i18n (1.6.0)
108+
hashdiff (1.0.0)
109+
i18n (1.8.2)
110110
concurrent-ruby (~> 1.0)
111-
loofah (2.3.1)
111+
loofah (2.4.0)
112112
crass (~> 1.0.2)
113113
nokogiri (>= 1.5.9)
114114
mail (2.7.1)
115115
mini_mime (>= 0.1.1)
116116
marcel (0.3.3)
117117
mimemagic (~> 0.3.2)
118118
method_source (0.9.2)
119-
mimemagic (0.3.3)
119+
mimemagic (0.3.4)
120120
mini_mime (1.0.2)
121121
mini_portile2 (2.4.0)
122-
minitest (5.11.3)
122+
minitest (5.14.0)
123123
nio4r (2.5.2)
124124
nokogiri (1.10.7)
125125
mini_portile2 (~> 2.4.0)
@@ -130,39 +130,41 @@ GEM
130130
pry-byebug (3.8.0)
131131
byebug (~> 11.0)
132132
pry (~> 0.10)
133+
pry-rails (0.3.9)
134+
pry (>= 0.10.4)
133135
public_suffix (4.0.3)
134136
puma (4.3.1)
135137
nio4r (~> 2.0)
136-
rack (2.1.2)
138+
rack (2.2.1)
137139
rack-proxy (0.6.5)
138140
rack
139141
rack-test (1.1.0)
140142
rack (>= 1.0, < 3)
141-
rails (5.2.3)
142-
actioncable (= 5.2.3)
143-
actionmailer (= 5.2.3)
144-
actionpack (= 5.2.3)
145-
actionview (= 5.2.3)
146-
activejob (= 5.2.3)
147-
activemodel (= 5.2.3)
148-
activerecord (= 5.2.3)
149-
activestorage (= 5.2.3)
150-
activesupport (= 5.2.3)
143+
rails (5.2.4.1)
144+
actioncable (= 5.2.4.1)
145+
actionmailer (= 5.2.4.1)
146+
actionpack (= 5.2.4.1)
147+
actionview (= 5.2.4.1)
148+
activejob (= 5.2.4.1)
149+
activemodel (= 5.2.4.1)
150+
activerecord (= 5.2.4.1)
151+
activestorage (= 5.2.4.1)
152+
activesupport (= 5.2.4.1)
151153
bundler (>= 1.3.0)
152-
railties (= 5.2.3)
154+
railties (= 5.2.4.1)
153155
sprockets-rails (>= 2.0.0)
154156
rails-dom-testing (2.0.3)
155157
activesupport (>= 4.2.0)
156158
nokogiri (>= 1.6)
157-
rails-html-sanitizer (1.0.4)
158-
loofah (~> 2.2, >= 2.2.2)
159-
railties (5.2.3)
160-
actionpack (= 5.2.3)
161-
activesupport (= 5.2.3)
159+
rails-html-sanitizer (1.3.0)
160+
loofah (~> 2.3)
161+
railties (5.2.4.1)
162+
actionpack (= 5.2.4.1)
163+
activesupport (= 5.2.4.1)
162164
method_source
163165
rake (>= 0.8.7)
164166
thor (>= 0.19.0, < 2.0)
165-
rake (12.3.3)
167+
rake (13.0.1)
166168
reform (2.2.4)
167169
disposable (>= 0.4.1)
168170
representable (>= 2.4.0, < 3.1.0)
@@ -174,37 +176,37 @@ GEM
174176
declarative (< 0.1.0)
175177
declarative-option (< 0.2.0)
176178
uber (< 0.2.0)
177-
rspec (3.8.0)
178-
rspec-core (~> 3.8.0)
179-
rspec-expectations (~> 3.8.0)
180-
rspec-mocks (~> 3.8.0)
181-
rspec-core (3.8.0)
182-
rspec-support (~> 3.8.0)
183-
rspec-expectations (3.8.2)
179+
rspec (3.9.0)
180+
rspec-core (~> 3.9.0)
181+
rspec-expectations (~> 3.9.0)
182+
rspec-mocks (~> 3.9.0)
183+
rspec-core (3.9.1)
184+
rspec-support (~> 3.9.1)
185+
rspec-expectations (3.9.0)
184186
diff-lcs (>= 1.2.0, < 2.0)
185-
rspec-support (~> 3.8.0)
186-
rspec-mocks (3.8.0)
187+
rspec-support (~> 3.9.0)
188+
rspec-mocks (3.9.1)
187189
diff-lcs (>= 1.2.0, < 2.0)
188-
rspec-support (~> 3.8.0)
189-
rspec-rails (3.8.1)
190+
rspec-support (~> 3.9.0)
191+
rspec-rails (3.9.0)
190192
actionpack (>= 3.0)
191193
activesupport (>= 3.0)
192194
railties (>= 3.0)
193-
rspec-core (~> 3.8.0)
194-
rspec-expectations (~> 3.8.0)
195-
rspec-mocks (~> 3.8.0)
196-
rspec-support (~> 3.8.0)
195+
rspec-core (~> 3.9.0)
196+
rspec-expectations (~> 3.9.0)
197+
rspec-mocks (~> 3.9.0)
198+
rspec-support (~> 3.9.0)
197199
rspec-retry (0.6.2)
198200
rspec-core (> 3.3)
199-
rspec-support (3.8.0)
201+
rspec-support (3.9.2)
200202
rspec-wait (0.0.9)
201203
rspec (>= 3, < 4)
202204
rubyzip (2.2.0)
203205
safe_yaml (1.0.5)
204206
selenium-webdriver (3.142.7)
205207
childprocess (>= 0.5, < 4.0)
206208
rubyzip (>= 1.2.2)
207-
simplecov (0.18.0)
209+
simplecov (0.18.1)
208210
docile (~> 1.1)
209211
simplecov-html (~> 0.11.0)
210212
simplecov-html (0.11.0)
@@ -216,10 +218,10 @@ GEM
216218
activesupport (>= 4.0)
217219
sprockets (>= 3.0.0)
218220
sqlite3 (1.3.13)
219-
temple (0.8.0)
220-
thor (0.20.3)
221+
temple (0.8.2)
222+
thor (1.0.1)
221223
thread_safe (0.3.6)
222-
tilt (2.0.8)
224+
tilt (2.0.10)
223225
trailblazer (2.0.7)
224226
declarative
225227
reform (>= 2.2.0, < 3.0.0)
@@ -235,13 +237,13 @@ GEM
235237
reform-rails (>= 0.1.4, < 0.2.0)
236238
trailblazer (~> 2.0.0)
237239
trailblazer-loader (>= 0.1.0)
238-
tzinfo (1.2.5)
240+
tzinfo (1.2.6)
239241
thread_safe (~> 0.1)
240242
uber (0.1.0)
241-
webmock (3.5.1)
243+
webmock (3.8.1)
242244
addressable (>= 2.3.6)
243245
crack (>= 0.3.2)
244-
hashdiff
246+
hashdiff (>= 0.4.0, < 2.0.0)
245247
webpacker (4.2.2)
246248
activesupport (>= 4.2)
247249
rack-proxy (>= 0.6.1)
@@ -263,6 +265,7 @@ DEPENDENCIES
263265
generator_spec
264266
matestack-ui-core!
265267
pry-byebug
268+
pry-rails
266269
puma
267270
rspec-rails (~> 3.8)
268271
rspec-retry

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

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,22 @@ const componentDef = {
8787
}
8888
self.data = data;
8989
},
90+
shouldResetFormOnSuccessfulSubmit() {
91+
const self = this
92+
if (self.componentConfig['success'] != undefined && self.componentConfig['success']['reset'] != undefined) {
93+
return self.componentConfig['success']['reset']
94+
} else {
95+
return self.shouldResetFormOnSuccessfulSubmitByDefault()
96+
}
97+
},
98+
shouldResetFormOnSuccessfulSubmitByDefault() {
99+
const self = this
100+
if (self.componentConfig["method"] == "put") {
101+
return false
102+
} else {
103+
return true
104+
}
105+
},
90106
perform: function(){
91107
const self = this
92108
let payload = {}
@@ -125,8 +141,11 @@ const componentDef = {
125141
self.$store.dispatch('navigateTo', {url: path, backwards: false})
126142
return;
127143
}
128-
self.setProps(self.data, null);
129-
self.initValues()
144+
if (self.shouldResetFormOnSuccessfulSubmit())
145+
{
146+
self.setProps(self.data, null);
147+
self.initValues();
148+
}
130149
self.showInlineForm = false;
131150
})
132151
.catch(function(error){

0 commit comments

Comments
 (0)