Prepare UI for notification settings
This commit is contained in:
parent
d55ade1686
commit
ba59912072
8 changed files with 81 additions and 20 deletions
|
@ -3,3 +3,11 @@ $ ->
|
||||||
container = $(@).closest(".js-toggler-container")
|
container = $(@).closest(".js-toggler-container")
|
||||||
|
|
||||||
container.toggleClass("on")
|
container.toggleClass("on")
|
||||||
|
|
||||||
|
$("body").on "click", ".js-toggle-visibility-link", (e) ->
|
||||||
|
$(@).find('i').
|
||||||
|
toggleClass('icon-chevron-down').
|
||||||
|
toggleClass('icon-chevron-up')
|
||||||
|
container = $(".js-toggle-visibility-container")
|
||||||
|
container.toggleClass("hide")
|
||||||
|
e.preventDefault()
|
||||||
|
|
9
app/assets/javascripts/extensions/jquery.js.coffee
Normal file
9
app/assets/javascripts/extensions/jquery.js.coffee
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
$.fn.showAndHide = ->
|
||||||
|
$(@).show().
|
||||||
|
delay(3000).
|
||||||
|
fadeOut()
|
||||||
|
|
||||||
|
$.fn.enableButton = ->
|
||||||
|
$(@).removeAttr('disabled').
|
||||||
|
removeClass('disabled')
|
||||||
|
|
|
@ -7,6 +7,8 @@ window.slugify = (text) ->
|
||||||
window.ajaxGet = (url) ->
|
window.ajaxGet = (url) ->
|
||||||
$.ajax({type: "GET", url: url, dataType: "script"})
|
$.ajax({type: "GET", url: url, dataType: "script"})
|
||||||
|
|
||||||
|
window.showAndHide = (selector) ->
|
||||||
|
|
||||||
window.errorMessage = (message) ->
|
window.errorMessage = (message) ->
|
||||||
ehtml = $("<p>")
|
ehtml = $("<p>")
|
||||||
ehtml.addClass("error_message")
|
ehtml.addClass("error_message")
|
||||||
|
|
|
@ -15,6 +15,8 @@ $ ->
|
||||||
$(this).find('.update-failed').hide()
|
$(this).find('.update-failed').hide()
|
||||||
|
|
||||||
$('.update-username form').on 'ajax:complete', ->
|
$('.update-username form').on 'ajax:complete', ->
|
||||||
$(this).find('.save-btn').removeAttr('disabled')
|
$(this).find('.btn-save').enableButton()
|
||||||
$(this).find('.save-btn').removeClass('disabled')
|
|
||||||
$(this).find('.loading-gif').hide()
|
$(this).find('.loading-gif').hide()
|
||||||
|
|
||||||
|
$('.update-notifications').on 'ajax:complete', ->
|
||||||
|
$(this).find('.btn-save').enableButton()
|
||||||
|
|
|
@ -3,9 +3,11 @@ class NotificationsController < ApplicationController
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@notification = current_user.notification
|
@notification = current_user.notification
|
||||||
|
@projects = current_user.authorized_projects
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@notification = current_user.notification
|
current_user.notification_level = params[:notification_level]
|
||||||
|
@saved = current_user.save
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,15 +1,25 @@
|
||||||
%h3.page_title Setup your notification level
|
%h3.page_title Setup your notification level
|
||||||
|
|
||||||
|
%br
|
||||||
|
|
||||||
|
%p.light
|
||||||
|
%strong Disabled
|
||||||
|
– You will not get any notifications via email
|
||||||
|
%p.light
|
||||||
|
%strong Participating
|
||||||
|
– You will receive only notifications from related resources(ex. from assigned issue or your commit)
|
||||||
|
%p.light
|
||||||
|
%strong Watch
|
||||||
|
– You will receive all notifications from projects in which you participate
|
||||||
%hr
|
%hr
|
||||||
|
|
||||||
|
= form_tag profile_notifications_path, method: :put, remote: true, class: 'update-notifications' do
|
||||||
= form_tag profile_notifications_path do
|
%ul.well-list
|
||||||
|
|
||||||
%ul.unstyled
|
|
||||||
%li
|
%li
|
||||||
.row
|
.row
|
||||||
.span3
|
.span4
|
||||||
%h5 Global
|
%h5 Global
|
||||||
.span9
|
.span7
|
||||||
= label_tag do
|
= label_tag do
|
||||||
= radio_button_tag :notification_level, Notification::N_DISABLED, @notification.disabled?
|
= radio_button_tag :notification_level, Notification::N_DISABLED, @notification.disabled?
|
||||||
%span Disabled
|
%span Disabled
|
||||||
|
@ -22,5 +32,37 @@
|
||||||
= radio_button_tag :notification_level, Notification::N_WATCH, @notification.watch?
|
= radio_button_tag :notification_level, Notification::N_WATCH, @notification.watch?
|
||||||
%span Watch
|
%span Watch
|
||||||
|
|
||||||
|
|
||||||
|
= link_to '#', class: 'js-toggle-visibility-link' do
|
||||||
|
%h6.btn.btn-tiny
|
||||||
|
%i.icon-chevron-down
|
||||||
|
%span Per project notifications settings
|
||||||
|
%ul.well-list.js-toggle-visibility-container.hide
|
||||||
|
- @projects.each do |project|
|
||||||
|
%li
|
||||||
|
.row
|
||||||
|
.span4
|
||||||
|
%span
|
||||||
|
= project.name_with_namespace
|
||||||
|
.span7
|
||||||
|
= label_tag do
|
||||||
|
= radio_button_tag :"notification_level[#{project.id}]", Notification::N_DISABLED, @notification.disabled?, disabled: true
|
||||||
|
%span Disabled
|
||||||
|
|
||||||
|
= label_tag do
|
||||||
|
= radio_button_tag :"notification_level[#{project.id}]", Notification::N_PARTICIPATING, @notification.participating?, disabled: true
|
||||||
|
%span Participating
|
||||||
|
|
||||||
|
= label_tag do
|
||||||
|
= radio_button_tag :"notification_level[#{project.id}]", Notification::N_WATCH, @notification.watch?, disabled: true
|
||||||
|
%span Watch
|
||||||
|
|
||||||
|
|
||||||
.form-actions
|
.form-actions
|
||||||
= submit_tag 'Save', class: 'btn btn-save'
|
= submit_tag 'Save', class: 'btn btn-save'
|
||||||
|
%span.update-success.cgreen.hide
|
||||||
|
%i.icon-ok
|
||||||
|
Saved
|
||||||
|
%span.update-failed.cred.hide
|
||||||
|
%i.icon-remove
|
||||||
|
Failed
|
||||||
|
|
7
app/views/notifications/update.js.haml
Normal file
7
app/views/notifications/update.js.haml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
- if @saved
|
||||||
|
:plain
|
||||||
|
$('.update-notifications .update-success').showAndHide();
|
||||||
|
- else
|
||||||
|
:plain
|
||||||
|
$('.update-notifications .update-failed').showAndHide();
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
require 'spec_helper'
|
|
||||||
|
|
||||||
describe "Notifications" do
|
|
||||||
describe "GET /notifications" do
|
|
||||||
it "works! (now write some real specs)" do
|
|
||||||
# Run the generator again with the --webrat flag if you want to use webrat methods/matchers
|
|
||||||
get notifications_path
|
|
||||||
response.status.should be(200)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
Loading…
Reference in a new issue