Commit ba59912072efb1e648e94d4c2cc2c2d0625f74db
1 parent
d55ade16
Exists in
master
and in
4 other branches
Prepare UI for notification settings
Showing
8 changed files
with
80 additions
and
19 deletions
Show diff stats
app/assets/javascripts/behaviors/toggler_behavior.coffee
| ... | ... | @@ -3,3 +3,11 @@ $ -> |
| 3 | 3 | container = $(@).closest(".js-toggler-container") |
| 4 | 4 | |
| 5 | 5 | container.toggleClass("on") |
| 6 | + | |
| 7 | + $("body").on "click", ".js-toggle-visibility-link", (e) -> | |
| 8 | + $(@).find('i'). | |
| 9 | + toggleClass('icon-chevron-down'). | |
| 10 | + toggleClass('icon-chevron-up') | |
| 11 | + container = $(".js-toggle-visibility-container") | |
| 12 | + container.toggleClass("hide") | |
| 13 | + e.preventDefault() | ... | ... |
app/assets/javascripts/main.js.coffee
app/assets/javascripts/profile.js.coffee
| ... | ... | @@ -15,6 +15,8 @@ $ -> |
| 15 | 15 | $(this).find('.update-failed').hide() |
| 16 | 16 | |
| 17 | 17 | $('.update-username form').on 'ajax:complete', -> |
| 18 | - $(this).find('.save-btn').removeAttr('disabled') | |
| 19 | - $(this).find('.save-btn').removeClass('disabled') | |
| 18 | + $(this).find('.btn-save').enableButton() | |
| 20 | 19 | $(this).find('.loading-gif').hide() |
| 20 | + | |
| 21 | + $('.update-notifications').on 'ajax:complete', -> | |
| 22 | + $(this).find('.btn-save').enableButton() | ... | ... |
app/controllers/notifications_controller.rb
| ... | ... | @@ -3,9 +3,11 @@ class NotificationsController < ApplicationController |
| 3 | 3 | |
| 4 | 4 | def show |
| 5 | 5 | @notification = current_user.notification |
| 6 | + @projects = current_user.authorized_projects | |
| 6 | 7 | end |
| 7 | 8 | |
| 8 | 9 | def update |
| 9 | - @notification = current_user.notification | |
| 10 | + current_user.notification_level = params[:notification_level] | |
| 11 | + @saved = current_user.save | |
| 10 | 12 | end |
| 11 | 13 | end | ... | ... |
app/views/notifications/show.html.haml
| 1 | 1 | %h3.page_title Setup your notification level |
| 2 | -%hr | |
| 3 | 2 | |
| 3 | +%br | |
| 4 | 4 | |
| 5 | -= form_tag profile_notifications_path do | |
| 5 | +%p.light | |
| 6 | + %strong Disabled | |
| 7 | + – You will not get any notifications via email | |
| 8 | +%p.light | |
| 9 | + %strong Participating | |
| 10 | + – You will receive only notifications from related resources(ex. from assigned issue or your commit) | |
| 11 | +%p.light | |
| 12 | + %strong Watch | |
| 13 | + – You will receive all notifications from projects in which you participate | |
| 14 | +%hr | |
| 6 | 15 | |
| 7 | - %ul.unstyled | |
| 16 | += form_tag profile_notifications_path, method: :put, remote: true, class: 'update-notifications' do | |
| 17 | + %ul.well-list | |
| 8 | 18 | %li |
| 9 | 19 | .row |
| 10 | - .span3 | |
| 20 | + .span4 | |
| 11 | 21 | %h5 Global |
| 12 | - .span9 | |
| 22 | + .span7 | |
| 13 | 23 | = label_tag do |
| 14 | 24 | = radio_button_tag :notification_level, Notification::N_DISABLED, @notification.disabled? |
| 15 | 25 | %span Disabled |
| ... | ... | @@ -22,5 +32,37 @@ |
| 22 | 32 | = radio_button_tag :notification_level, Notification::N_WATCH, @notification.watch? |
| 23 | 33 | %span Watch |
| 24 | 34 | |
| 35 | + | |
| 36 | + = link_to '#', class: 'js-toggle-visibility-link' do | |
| 37 | + %h6.btn.btn-tiny | |
| 38 | + %i.icon-chevron-down | |
| 39 | + %span Per project notifications settings | |
| 40 | + %ul.well-list.js-toggle-visibility-container.hide | |
| 41 | + - @projects.each do |project| | |
| 42 | + %li | |
| 43 | + .row | |
| 44 | + .span4 | |
| 45 | + %span | |
| 46 | + = project.name_with_namespace | |
| 47 | + .span7 | |
| 48 | + = label_tag do | |
| 49 | + = radio_button_tag :"notification_level[#{project.id}]", Notification::N_DISABLED, @notification.disabled?, disabled: true | |
| 50 | + %span Disabled | |
| 51 | + | |
| 52 | + = label_tag do | |
| 53 | + = radio_button_tag :"notification_level[#{project.id}]", Notification::N_PARTICIPATING, @notification.participating?, disabled: true | |
| 54 | + %span Participating | |
| 55 | + | |
| 56 | + = label_tag do | |
| 57 | + = radio_button_tag :"notification_level[#{project.id}]", Notification::N_WATCH, @notification.watch?, disabled: true | |
| 58 | + %span Watch | |
| 59 | + | |
| 60 | + | |
| 25 | 61 | .form-actions |
| 26 | 62 | = submit_tag 'Save', class: 'btn btn-save' |
| 63 | + %span.update-success.cgreen.hide | |
| 64 | + %i.icon-ok | |
| 65 | + Saved | |
| 66 | + %span.update-failed.cred.hide | |
| 67 | + %i.icon-remove | |
| 68 | + Failed | ... | ... |
spec/requests/notifications_spec.rb
| ... | ... | @@ -1,11 +0,0 @@ |
| 1 | -require 'spec_helper' | |
| 2 | - | |
| 3 | -describe "Notifications" do | |
| 4 | - describe "GET /notifications" do | |
| 5 | - it "works! (now write some real specs)" do | |
| 6 | - # Run the generator again with the --webrat flag if you want to use webrat methods/matchers | |
| 7 | - get notifications_path | |
| 8 | - response.status.should be(200) | |
| 9 | - end | |
| 10 | - end | |
| 11 | -end |