summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2015-10-30 14:22:26 +0100
committerHarald Eilertsen <haraldei@anduin.net>2015-10-30 14:22:26 +0100
commit90f4ed34c62f5d90b536cac97265d323d0c1c136 (patch)
treeb9c6f3c9494d21804b1cdab73daf5b57286a3ff7
parentf67121a270a345f718dd8e146b13a0fe84da1885 (diff)
downloadnorsk-urskog-registrations-90f4ed34c62f5d90b536cac97265d323d0c1c136.tar.gz
norsk-urskog-registrations-90f4ed34c62f5d90b536cac97265d323d0c1c136.tar.bz2
norsk-urskog-registrations-90f4ed34c62f5d90b536cac97265d323d0c1c136.zip
Simplify form: Just use a textarea for members.
-rw-r--r--lib/band.rb9
-rw-r--r--public/regform.js8
-rw-r--r--spec/features/register_band_spec.rb7
-rw-r--r--spec/registration_spec.rb4
-rw-r--r--spec/support/band_factory.rb15
-rw-r--r--spec/support/submit_form_helper.rb9
-rw-r--r--views/index.erb20
-rw-r--r--views/submitted.erb8
8 files changed, 13 insertions, 67 deletions
diff --git a/lib/band.rb b/lib/band.rb
index 8cd3535..54775f4 100644
--- a/lib/band.rb
+++ b/lib/band.rb
@@ -9,7 +9,7 @@ class Band
def initialize(params = nil)
@errors = []
@contact = Contact.new
- @members = []
+ @members = ""
@songs = []
if params
@@ -18,15 +18,10 @@ class Band
@website = params['website']
@label = params['label']
@short_bio = params['shortbio']
+ @members = params['members'] || ""
@contact = Contact.new(params['contact'])
- if params['members']
- params['members'].each do |k, m|
- @members << Member.new(m)
- end
- end
-
if params['songs']
params['songs'].each do |k, s|
@songs << Song.new(s)
diff --git a/public/regform.js b/public/regform.js
index 98b4b8e..197034e 100644
--- a/public/regform.js
+++ b/public/regform.js
@@ -11,17 +11,9 @@ function fetch(url, id) {
}
window.onload = function() {
- var num_members = 0;
var num_songs = 0;
-
- var add_member_button = document.getElementById('add-member-button');
var add_song_button = document.getElementById('add-song-button');
- add_member_button.onclick = function() {
- num_members += 1;
- fetch(window.location + '/member/new/' + num_members, 'form-members');
- };
-
add_song_button.onclick = function() {
num_songs += 1;
fetch(window.location + '/song/new/' + num_songs, 'form-songs');
diff --git a/spec/features/register_band_spec.rb b/spec/features/register_band_spec.rb
index 625cb20..249bf3f 100644
--- a/spec/features/register_band_spec.rb
+++ b/spec/features/register_band_spec.rb
@@ -38,6 +38,7 @@ feature "Submit registration form" do
expect(find_field('Webside:').value).to eql(@band_params['website'])
expect(find_field('Plateselskap:').value).to eql(@band_params['label'])
expect(find_field('Kort bio:').value).to eql(@band_params['shortbio'])
+ expect(find_field('Medlemmer:').value).to eql(@band_params['members'])
within ('#form-contact-info') do
expect(find_field('Navn:').value).to eql(@band_params['contact']['name'])
@@ -46,12 +47,6 @@ feature "Submit registration form" do
expect(find_field('E-post:').value).to eql(@band_params['contact']['email'])
end
- within '#form-members .member-info' do
- expect(find_field('Navn:').value).to eql(@band_params['members']['1']['name'])
- expect(find_field('Instrument:').value).to eql(@band_params['members']['1']['instrument'])
- expect(find_field('Alder:').value).to eql(@band_params['members']['1']['age'])
- end
-
within '#form-songs #song-1-info' do
expect(find_field('Tittel:').value).to eql(@band_params['songs']['1']['title'])
expect(find_field('Lengde:').value).to eql(@band_params['songs']['1']['time'])
diff --git a/spec/registration_spec.rb b/spec/registration_spec.rb
index 7e4ca3a..fbd2016 100644
--- a/spec/registration_spec.rb
+++ b/spec/registration_spec.rb
@@ -21,10 +21,6 @@ describe RegistrationApp do
expect(last_response.body).to match(/form id="registration-form"/)
end
- it 'displays the add member button' do
- expect(last_response.body).to match(/id="add-member-button"/)
- end
-
it 'displays the add song button' do
expect(last_response.body).to match(/id="add-song-button"/)
end
diff --git a/spec/support/band_factory.rb b/spec/support/band_factory.rb
index 56993fa..3ae2589 100644
--- a/spec/support/band_factory.rb
+++ b/spec/support/band_factory.rb
@@ -11,11 +11,7 @@ module BandFactory
:contact_addr => "Streetname 666\n1234Someplace Nice",
:contact_phone => '98765432',
:contact_email => 'band@example.com',
- :members => [
- { :name => 'Member 1', :instrument => 'Instrument 1', :age => '24' },
- { :name => 'Member 2', :instrument => 'Instrument 2', :age => '0' },
- { :name => 'Member 3', :instrument => '', :age => '' },
- ],
+ :members => "Member 1 (Instrument 1, 24\nMember 2 (Instrument 2)\nMember 3",
}.merge(options)
num_songs = opts.delete(:songs)
@@ -32,17 +28,10 @@ module BandFactory
'phone' => opts[:contact_phone],
'email' => opts[:contact_email]
},
- 'members' => {},
+ 'members' => opts[:members],
'songs' => {}
}
- (1..opts[:members].length).each do |i|
- params['members'][i.to_s] = {}
- params['members'][i.to_s]['name'] = opts[:members][i-1][:name]
- params['members'][i.to_s]['instrument'] = opts[:members][i-1][:instrument]
- params['members'][i.to_s]['age'] = opts[:members][i-1][:age]
- end
-
(1..num_songs).each do |i|
num = i.to_s
params['songs'][num] = create_song_params
diff --git a/spec/support/submit_form_helper.rb b/spec/support/submit_form_helper.rb
index 80d06bf..45e7d67 100644
--- a/spec/support/submit_form_helper.rb
+++ b/spec/support/submit_form_helper.rb
@@ -5,6 +5,7 @@ module SubmitFormHelper
fill_in 'Webside:', with: params['website']
fill_in 'Plateselskap:', with: params['label']
fill_in 'Kort bio:', with: params['shortbio']
+ fill_in 'Medlemmer:', with: params['members']
within '#form-contact-info' do
fill_in 'Navn:', with: params['contact']['name']
@@ -13,14 +14,6 @@ module SubmitFormHelper
fill_in 'E-post:', with: params['contact']['email']
end
- click_on 'Legg til medlem'
-
- within '#form-members .member-info' do
- fill_in 'Navn:', with: params['members']['1']['name']
- fill_in 'Instrument:', with: params['members']['1']['instrument']
- fill_in 'Alder:', with: params['members']['1']['age']
- end
-
if params['songs']
click_on 'Legg til låt'
diff --git a/views/index.erb b/views/index.erb
index 52823db..ab3a762 100644
--- a/views/index.erb
+++ b/views/index.erb
@@ -27,7 +27,12 @@
<div class="field text required">
<label for="band_shortbio">Kort bio:</label>
- <textarea cols="40" rows="5" id="band_shortbio" name="band[shortbio]"><%= @band.short_bio %></textarea>
+ <textarea id="band_shortbio" name="band[shortbio]"><%= @band.short_bio %></textarea>
+ </div>
+
+ <div class="field textarea">
+ <label for="band_members">Medlemmer:</label>
+ <textarea id="band_members" name="band[members]"><%= @band.members %></textarea>
</div>
</div>
@@ -54,19 +59,6 @@
</div>
</div>
- <div id="form-members" class="fieldgroup">
- <h3>Medlemmer</h3>
- <p>Klikk på knappen under for å legge til medlemmene som er med i bandet. Dette er kun til
- informasjon for websider, promomateriale og lignende. Har bandmedlemene pseudonymer de
- foretrekker å bruke, så kan du bruke dem her.</p>
-
- <input type="button" name="add_member" value="Legg til medlem" id="add-member-button">
-
- <% @band.members.each do |m| %>
- <%= erb :member, layout: false, locals: { member_number: 1, member: m } %>
- <% end %>
- </div>
-
<div id="form-songs" class="fieldgroup">
<h3>Låter</h3>
<p>Klikk på knappen under for å legge til låten(e) dere vil ha med på samle-cden. Du kan oppgi
diff --git a/views/submitted.erb b/views/submitted.erb
index 7f2950f..d085b82 100644
--- a/views/submitted.erb
+++ b/views/submitted.erb
@@ -9,6 +9,7 @@
<li>Webside: <%= @band.website %></li>
<li>Plateselskap: <%= @band.label %></li>
<li>Kort bio: <%= @band.short_bio %></li>
+ <li>Medlemmer: <%= @band.members %></li>
</ul>
<p>Kontakt:</p>
@@ -19,13 +20,6 @@
<li>Epost: <%= @band.contact.email %></li>
</ul>
-<p>Medlemmer:</p>
-<ul>
- <% @band.members.each do |m| %>
- <li><%= [m.name, m.instrument, m.age].join(', ') %></li>
- <% end %>
-</ul>
-
<p>Låter:</p>
<ul>
<% @band.songs.each do |s| %>