Skip to content

Commit 59423a7

Browse files
author
Nils Henning
committed
update form components and specs, removed inline form component
1 parent 3bf2289 commit 59423a7

File tree

10 files changed

+79
-211
lines changed

10 files changed

+79
-211
lines changed

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

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ const componentDef = {
1010
data: function () {
1111
return {
1212
data: {},
13-
showInlineForm: false,
1413
errors: {},
1514
};
1615
},
@@ -29,17 +28,6 @@ const componentDef = {
2928
this.errors[key] = null;
3029
}
3130
},
32-
launchInlineForm: function (key, value) {
33-
this.showInlineForm = true;
34-
this.data[key] = value;
35-
const self = this;
36-
setTimeout(function () {
37-
self.$refs.inlineinput.focus();
38-
}, 300);
39-
},
40-
closeInlineForm: function () {
41-
this.showInlineForm = false;
42-
},
4331
setProps: function (flat, newVal) {
4432
for (var i in flat) {
4533
if (flat[i] === null){
@@ -233,7 +221,6 @@ const componentDef = {
233221
self.setProps(self.data, null);
234222
self.initValues();
235223
}
236-
self.showInlineForm = false;
237224
})
238225
.catch(function (error) {
239226
if (error.response && error.response.data && error.response.data.errors) {

app/concepts/matestack/ui/core/form/inline/inline.haml

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

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

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

lib/matestack/ui/core/components.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ def self.require_core_component(name)
8989
require_core_component "noscript"
9090
require_core_component "object"
9191
require_core_component "ol"
92+
require_core_component "onclick"
9293
require_core_component "optgroup"
9394
require_core_component "option"
9495
require_core_component "output"
@@ -132,7 +133,6 @@ def self.require_core_component(name)
132133
require_core_component "form/input"
133134
require_core_component "form/select"
134135
require_core_component "form/submit"
135-
require_core_component "onclick"
136136
end
137137

138138
Matestack::Ui::Core::Component::Registry.register_components(
@@ -177,6 +177,10 @@ def self.require_core_component(name)
177177
fieldset: Matestack::Ui::Core::Fieldset::Fieldset,
178178
figure: Matestack::Ui::Core::Figure::Figure,
179179
footer: Matestack::Ui::Core::Footer::Footer,
180+
form: Matestack::Ui::Core::Form::Form,
181+
form_input: Matestack::Ui::Core::Form::Input::Input,
182+
form_select: Matestack::Ui::Core::Form::Select::Select,
183+
form_submit: Matestack::Ui::Core::Form::Submit::Submit,
180184
header: Matestack::Ui::Core::Header::Header,
181185
heading: Matestack::Ui::Core::Heading::Heading,
182186
hr: Matestack::Ui::Core::Hr::Hr,
@@ -199,6 +203,7 @@ def self.require_core_component(name)
199203
noscript: Matestack::Ui::Core::Noscript::Noscript,
200204
object: Matestack::Ui::Core::Object::Object,
201205
ol: Matestack::Ui::Core::Ol::Ol,
206+
onclick: Matestack::Ui::Core::Onclick::Onclick,
202207
optgroup: Matestack::Ui::Core::Optgroup::Optgroup,
203208
option: Matestack::Ui::Core::Option::Option,
204209
output: Matestack::Ui::Core::Output::Output,
@@ -239,9 +244,4 @@ def self.require_core_component(name)
239244
video: Matestack::Ui::Core::Video::Video,
240245
wbr: Matestack::Ui::Core::Wbr::Wbr,
241246
youtube: Matestack::Ui::Core::Youtube::Youtube,
242-
form: Matestack::Ui::Core::Form::Form,
243-
form_input: Matestack::Ui::Core::Form::Input::Input,
244-
form_select: Matestack::Ui::Core::Form::Select::Select,
245-
form_submit: Matestack::Ui::Core::Form::Submit::Submit,
246-
onclick: Matestack::Ui::Core::Onclick::Onclick,
247247
)

spec/0.8/components/dynamic/form/delay_spec.rb

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,19 @@ def success_submit
2626
describe "delay attribute" do
2727

2828
it "if set, delays form submit" do
29-
3029
class ExamplePage < Matestack::Ui::Page
31-
3230
def response
33-
components {
34-
form form_config, :include do
35-
form_input key: :foo, type: :text, id: "my-test-input"
36-
form_submit do
37-
button text: 'Submit me!'
38-
end
31+
form form_config, :include do
32+
form_input key: :foo, type: :text, id: "my-test-input"
33+
form_submit do
34+
button text: 'Submit me!'
3935
end
40-
div id: "timestamp" do
41-
async show_on: "form_submitted_successfully" do
42-
plain "{{event.data.received_at}}"
43-
end
36+
end
37+
div id: "timestamp" do
38+
async show_on: "form_submitted_successfully" do
39+
paragraph id: 'received_timestamp', text: "{{event.data.received_at}}"
4440
end
45-
}
41+
end
4642
end
4743

4844
def form_config
@@ -56,24 +52,17 @@ def form_config
5652
}
5753
}
5854
end
59-
6055
end
6156

6257
visit '/example'
63-
6458
submit_timestamp = DateTime.now.strftime('%Q').to_i
6559
fill_in "my-test-input", with: submit_timestamp
6660
click_button "Submit me!"
67-
68-
sleep 1.5
69-
70-
element = page.find("#timestamp")
61+
expect(page).to have_selector(:css, '#received_timestamp', wait: 2)
62+
element = page.find("#received_timestamp")
7163
receive_timestamp = element.text.to_i
72-
7364
expect(receive_timestamp - submit_timestamp).to be > 1000
74-
7565
end
76-
7766
end
7867

7968
end

spec/0.8/components/dynamic/form/emit_spec.rb

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,11 @@ def success_submit
2121
allow_any_instance_of(FormTestController).to receive(:expect_params)
2222
end
2323

24-
2524
describe "emit attribute" do
2625

2726
it "if set, emits event directly when form is submitted (not waiting for success or failure)" do
28-
2927
class ExamplePage < Matestack::Ui::Page
30-
3128
def response
32-
components {
3329
form form_config, :include do
3430
form_input key: :foo, type: :text, id: "my-test-input"
3531
form_submit do
@@ -39,7 +35,6 @@ def response
3935
async show_on: "form_submitted" do
4036
plain "form submitted!"
4137
end
42-
}
4338
end
4439

4540
def form_config
@@ -50,22 +45,16 @@ def form_config
5045
emit: "form_submitted"
5146
}
5247
end
53-
5448
end
5549

5650
visit '/example'
57-
5851
fill_in "my-test-input", with: "bar"
59-
6052
expect_any_instance_of(FormTestController).to receive(:expect_params)
6153
.with(hash_including(my_object: { foo: "bar" }))
6254

6355
click_button "Submit me!"
64-
6556
expect(page).to have_content("form submitted!")
66-
6757
end
68-
6958
end
7059

7160
end

0 commit comments

Comments
 (0)