Commit 6ae0945a2634c1cefd31af105fdef5c1847fa4a6

Authored by Jared Pace
1 parent fed22b92
Exists in master and in 1 other branch production

Allow the nested forms for watchers to have a user watcher.

app/models/watcher.rb
... ... @@ -9,6 +9,10 @@ class Watcher
9 9  
10 10 validate :ensure_user_or_email
11 11  
  12 + def label
  13 + user ? user.name : email
  14 + end
  15 +
12 16 protected
13 17  
14 18 def ensure_user_or_email
... ...
app/views/apps/_fields.html.haml
... ... @@ -10,5 +10,10 @@
10 10 %legend Watchers
11 11 - f.fields_for :watchers do |w|
12 12 %div.nested
13   - = w.label :email
14   - = w.text_field :email
15 13 \ No newline at end of file
  14 + %div
  15 + = w.label :user
  16 + = w.select :user_id, User.all.map{|u| [u.name,u.id]}, :include_blank => '-- Select a User --'
  17 + %strong.option - OR -
  18 + %div
  19 + = w.label :email
  20 + = w.text_field :email
16 21 \ No newline at end of file
... ...
app/views/apps/show.html.haml
... ... @@ -17,11 +17,11 @@
17 17 %table.watchers
18 18 %thead
19 19 %tr
20   - %th Email
  20 + %th User or Email
21 21 %tbody
22 22 - @app.watchers.each do |watcher|
23 23 %tr
24   - %td= watcher.email
  24 + %td= watcher.label
25 25 - if @app.watchers.none?
26 26 %tr
27 27 %td
... ...
public/stylesheets/application.css
... ... @@ -257,6 +257,23 @@ form > div > span {
257 257 font-size: 0.85em;
258 258 color: #787878;
259 259 }
  260 +form strong.option {
  261 + display: block;
  262 + margin: 0.7em 0;
  263 + color: #999;
  264 +}
  265 +
  266 +form .nested {
  267 + border-top: 1px dotted #BBB;
  268 + margin-top: 1.5em;
  269 + padding-top: 1.5em;
  270 +}
  271 +
  272 +form legend + .nested {
  273 + border: none;
  274 + margin-top: 0;
  275 + padding-top: 0;
  276 +}
260 277  
261 278 /* Tables */
262 279 table {
... ...