Commit cf79a291c720525457422b2522106b523080d7ad
1 parent
c54c7abf
Exists in
master
and in
1 other branch
added new notification partial, model tweaks to get fields working
Showing
5 changed files
with
33 additions
and
3 deletions
Show diff stats
app/models/app.rb
... | ... | @@ -35,7 +35,8 @@ class App |
35 | 35 | :reject_if => proc { |attrs| attrs[:user_id].blank? && attrs[:email].blank? } |
36 | 36 | accepts_nested_attributes_for :issue_tracker, :allow_destroy => true, |
37 | 37 | :reject_if => proc { |attrs| !IssueTracker.subclasses.map(&:to_s).include?(attrs[:type].to_s) } |
38 | - | |
38 | + accepts_nested_attributes_for :notification_service, :allow_destroy => true, | |
39 | + :reject_if => proc { |attrs| !NotificationService.subclasses.map(&:to_s).include?(attrs[:type].to_s) } | |
39 | 40 | |
40 | 41 | # Processes a new error report. |
41 | 42 | # |
... | ... | @@ -139,7 +140,7 @@ class App |
139 | 140 | self.send("#{k}=", copy_app.send(k)) |
140 | 141 | end |
141 | 142 | # Clone the embedded objects that can be changed via apps/edit (ignore errs & deploys, etc.) |
142 | - %w(watchers issue_tracker).each do |relation| | |
143 | + %w(watchers issue_tracker notification_service).each do |relation| | |
143 | 144 | if obj = copy_app.send(relation) |
144 | 145 | self.send("#{relation}=", obj.is_a?(Array) ? obj.map(&:clone) : obj.clone) |
145 | 146 | end | ... | ... |
app/models/notification_service.rb
app/models/notification_services/campfire_service.rb
app/views/apps/_fields.html.haml
... | ... | @@ -0,0 +1,26 @@ |
1 | +%fieldset | |
2 | + %legend Notification Service | |
3 | + = f.fields_for :notification_service do |w| | |
4 | + %div.notification.nested | |
5 | + %div.choose | |
6 | + = label_tag :type_none, :for => label_for_attr(w, 'type_notificationservice'), :class => "label_radio none" do | |
7 | + = w.radio_button :type, "NotificationService", 'data-section' => 'none' | |
8 | + (None) | |
9 | + - NotificationService.subclasses.each do |notification_service| | |
10 | + = label_tag "type_#{notification_service.label}:", :for => label_for_attr(w, "type_#{notification_service.name.downcase.gsub(':','')}"), :class => "label_radio #{notification_service.label}" do | |
11 | + = w.radio_button :type, notification_service.name, 'data-section' => notification_service.label | |
12 | + = notification_service.name[/::(.*)Service/,1].titleize | |
13 | + | |
14 | + %div.notification_params.none{:class => (w.object && !(w.object.class < NotificationService)) ? 'chosen' : nil} | |
15 | + %p When no issue tracker has been configured, you will be able to leave comments on errors. | |
16 | + - NotificationService.subclasses.each do |notification_service| | |
17 | + %div.notification_params{:class => (w.object.is_a?(notification_service) ? 'chosen ' : '') << notification_service.label} | |
18 | + - notification_service::Fields.each do |field, field_info| | |
19 | + = w.label field, field_info[:label] || field.to_s.titleize | |
20 | + - field_type = field == :password ? :password_field : :text_field | |
21 | + = w.send field_type, field, :placeholder => field_info[:placeholder], :value => w.object.send(field) | |
22 | + | |
23 | + .image_preloader | |
24 | + - (NotificationService.subclasses.map{|t| t.label } << 'none').each do |notification_service| | |
25 | + = image_tag "#{notification_service}_inactive.png" | |
26 | + = image_tag "#{notification_service}_create.png" | ... | ... |