Skip to content

Commit

Permalink
Merge pull request #8341 from vpereira/users_subscriptions_to_bootstrap
Browse files Browse the repository at this point in the history
Move Webui::Users::SubscriptionsController to boostrap
  • Loading branch information
vpereira committed Sep 13, 2019
2 parents adb9225 + d31ccc6 commit c30ccab
Show file tree
Hide file tree
Showing 12 changed files with 40 additions and 77 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def update
ensure
respond_to do |format|
format.html { redirect_to action: :index }
format.js { render 'webui2/webui/users/subscriptions/update' }
format.js { render 'webui/users/subscriptions/update' }
end
end

Expand Down
1 change: 0 additions & 1 deletion src/api/app/views/webui/subscriptions/update.js.erb

This file was deleted.

1 change: 1 addition & 0 deletions src/api/app/views/webui/subscriptions/update.js.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$('#flash').html("#{escape_javascript(render(layout: false, partial: 'layouts/webui2/flash', object: flash))}");
64 changes: 35 additions & 29 deletions src/api/app/views/webui/users/subscriptions/index.html.haml
Original file line number Diff line number Diff line change
@@ -1,35 +1,41 @@
- @layouttype = 'custom'
- @pagetitle = "Notifications"
- @crumb_list = [@pagetitle]
.grid_16.alpha.omega.box.box-shadow
%h2= @pagetitle
- @pagetitle = 'Notifications'

= form_tag(user_notifications_path, method: :put, id: 'notification_form') do
- unless @groups_users.empty?
%h3 Groups
%p.description You will receive emails from the checked groups
.box
.row
%ul
- @groups_users.each do |group_user|
%li
= check_box_tag group_user.group, '1', group_user.email
= label_tag group_user.group.title

%h3 Events
%p.description Choose from which events you want to get an email
.card
.card-header.d-flex.justify-content-between
%h5 Notifications
- unless @groups_users.empty?
.card-body
%h4.card-title Groups
.card-text#notifications-groups
%p You will receive emails from the checked groups
- @groups_users.each do |group_user|
.custom-control.custom-checkbox.custom-control-inline
= check_box_tag group_user.group, '1', group_user.email, class: 'custom-control-input', id: "checkbox-#{group_user.group}",
data: { url: user_notifications_path, method: :put, remote: true }
= label_tag group_user.group.title, nil, class: 'custom-control-label', for: "checkbox-#{group_user.group}"
%i.fas.fa-spinner.invisible
.card-body
%h4.card-title Events
%p Choose from which events you want to get an email
#subscriptions-form
= render partial: 'webui/subscriptions/subscriptions_form'
%p
= submit_tag 'Update'
= link_to('Reset to default', user_notifications_path(default_form: true), remote: true)
.grid_16.alpha.omega.box.box-shadow
%h2 RSS Feed
= form_tag(user_rss_token_path, id: 'generate_rss_token_form', method: :post) do
%p
= render partial: 'webui/subscriptions/subscriptions_form', locals: { path: user_notifications_path, subscriptions_form: @subscriptions_form }

.card.mt-3
.card-body
%h4.card-title RSS Feed
= form_tag(user_rss_token_path, id: 'generate_rss_token_form', method: :post) do
%p
- if @user.rss_token
To access your RSS feeds, use the following url:
= link_to(user_rss_notifications_url(token: @user.rss_token.string, format: 'rss'), user_rss_notifications_url(token: @user.rss_token.string, format: 'rss'), target: '_blank')
= link_to(user_rss_notifications_url(token: @user.rss_token.string, format: 'rss'),
user_rss_notifications_url(token: @user.rss_token.string, format: 'rss'), target: '_blank', rel: 'noopener')
- else
No feed url exists for your notifications.
%p= submit_tag "#{@user.rss_token ? 'Regenerate Url' : 'Generate Url'}"
.card-body
= submit_tag "#{@user.rss_token ? 'Regenerate Url' : 'Generate Url'}", class: 'btn btn-primary'

- content_for :ready_function do
:plain
$('#notifications-groups, #subscriptions-form').on('ajax:before ajax:complete', '.custom-control-input', function() {
$(this).siblings('i.fa-spinner').toggleClass('fa-spin invisible');
});
2 changes: 0 additions & 2 deletions src/api/app/views/webui/users/subscriptions/index.js.erb

This file was deleted.

1 change: 1 addition & 0 deletions src/api/app/views/webui/users/subscriptions/index.js.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$('#subscriptions-form').replaceWith("#{escape_javascript(render(partial: 'webui/subscriptions/subscriptions_form'))}");
1 change: 1 addition & 0 deletions src/api/app/views/webui/users/subscriptions/update.js.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$('#flash').html("#{escape_javascript(render(layout: false, partial: 'layouts/webui2/flash', object: flash))}");
41 changes: 0 additions & 41 deletions src/api/app/views/webui2/webui/users/subscriptions/index.html.haml

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
it { is_expected.to use_before_action(:require_login) }
end

describe 'PUT #index' do
describe 'PUT #update' do
include_context 'a user and subscriptions with defaults'

let(:params) { { subscriptions: subscription_params } }
Expand Down

0 comments on commit c30ccab

Please sign in to comment.