From b8e91e91a1bbeb271e0abe693ce298bbfad800aa Mon Sep 17 00:00:00 2001 From: mlorb Date: Thu, 5 Apr 2018 16:30:02 +0200 Subject: [PATCH 1/5] refactor settings into the new navigation bar --- .../javascripts/users/settings/list_toggle.js | 11 +++ .../users/registrations_controller.rb | 1 + .../settings/account/addons_controller.rb | 1 + .../account/preferences_controller.rb | 1 + .../users/settings/teams_controller.rb | 2 + app/views/users/registrations/edit.html.erb | 7 +- app/views/users/settings/_sidebar.html.erb | 95 +++++++++++++++++++ .../settings/account/addons/index.html.erb | 7 +- .../account/preferences/index.html.erb | 7 +- app/views/users/settings/teams/index.html.erb | 2 +- app/views/users/settings/teams/new.html.erb | 2 +- app/views/users/settings/teams/show.html.erb | 2 +- config/initializers/assets.rb | 1 + config/locales/en.yml | 8 ++ 14 files changed, 129 insertions(+), 18 deletions(-) create mode 100644 app/assets/javascripts/users/settings/list_toggle.js create mode 100644 app/views/users/settings/_sidebar.html.erb diff --git a/app/assets/javascripts/users/settings/list_toggle.js b/app/assets/javascripts/users/settings/list_toggle.js new file mode 100644 index 000000000..38d2c8610 --- /dev/null +++ b/app/assets/javascripts/users/settings/list_toggle.js @@ -0,0 +1,11 @@ +function listToggleShow() { + $('#triangleDown').show(); + $('#triangleRight').hide(); + $('#accountNavigation').show(); +} + +function listToggleHide() { + $('#triangleDown').hide(); + $('#triangleRight').show(); + $('#accountNavigation').hide(); +} diff --git a/app/controllers/users/registrations_controller.rb b/app/controllers/users/registrations_controller.rb index 9adfc5e6c..501526f4e 100644 --- a/app/controllers/users/registrations_controller.rb +++ b/app/controllers/users/registrations_controller.rb @@ -4,6 +4,7 @@ class Users::RegistrationsController < Devise::RegistrationsController only: %i(new create new_with_provider create_with_provider) before_action :sign_up_with_provider_enabled?, only: %i(new_with_provider create_with_provider) + layout 'fluid' def avatar user = User.find_by_id(params[:id]) || current_user diff --git a/app/controllers/users/settings/account/addons_controller.rb b/app/controllers/users/settings/account/addons_controller.rb index 9b18d556a..aa4412a78 100644 --- a/app/controllers/users/settings/account/addons_controller.rb +++ b/app/controllers/users/settings/account/addons_controller.rb @@ -2,6 +2,7 @@ module Users module Settings module Account class AddonsController < ApplicationController + layout 'fluid' end end end diff --git a/app/controllers/users/settings/account/preferences_controller.rb b/app/controllers/users/settings/account/preferences_controller.rb index 723641a49..ef983b4c9 100644 --- a/app/controllers/users/settings/account/preferences_controller.rb +++ b/app/controllers/users/settings/account/preferences_controller.rb @@ -9,6 +9,7 @@ module Users :reset_tutorial, :notifications_settings ] + layout 'fluid' def index end diff --git a/app/controllers/users/settings/teams_controller.rb b/app/controllers/users/settings/teams_controller.rb index 620fcd3c5..8917cd25b 100644 --- a/app/controllers/users/settings/teams_controller.rb +++ b/app/controllers/users/settings/teams_controller.rb @@ -22,6 +22,8 @@ module Users before_action :check_create_team_permission, only: %i(new create) + layout 'fluid' + def index @user_teams = @user diff --git a/app/views/users/registrations/edit.html.erb b/app/views/users/registrations/edit.html.erb index 6ac1bd0d9..5f99d1fbd 100644 --- a/app/views/users/registrations/edit.html.erb +++ b/app/views/users/registrations/edit.html.erb @@ -1,14 +1,11 @@ <% provide(:head_title, t("users.registrations.edit.head_title")) %> -<%= render partial: "users/settings/navigation.html.erb" %> +<%= render partial: "users/settings/sidebar" %>
-
- <%= render partial: 'users/settings/account/navigation.html.erb' %> -
-
+

<%=t "users.registrations.edit.title" %>

diff --git a/app/views/users/settings/_sidebar.html.erb b/app/views/users/settings/_sidebar.html.erb new file mode 100644 index 000000000..6da85e95a --- /dev/null +++ b/app/views/users/settings/_sidebar.html.erb @@ -0,0 +1,95 @@ +<%= content_for :sidebar do %> +
+
+
    +
  • + + <%= t('users.settings.sidebar.title') %> + +
  • + +
  • + + + + <% style = 'font-weight: bold;' if on_settings_account_page? %> + <%= link_to t("users.settings.sidebar.account"), + edit_user_registration_path, + style: style, + data: { 'no-turbolink' => 'true' } %> + + +
      + + + +
    +
  • + + +
  • + + <% if on_settings_team_page? %> + "><%= t("users.settings.sidebar.teams") %> + <% else %> + <%= link_to t("users.settings.sidebar.teams"), + teams_path, + data: { 'no-turbolink' => 'true' } %> + <% end %> + +
  • + +
+
+
+<% end %> + + + +<%= javascript_include_tag("users/settings/list_toggle") %> diff --git a/app/views/users/settings/account/addons/index.html.erb b/app/views/users/settings/account/addons/index.html.erb index de7c58a21..6022900b6 100644 --- a/app/views/users/settings/account/addons/index.html.erb +++ b/app/views/users/settings/account/addons/index.html.erb @@ -1,14 +1,11 @@ <% provide(:head_title, t('users.settings.account.addons.head_title')) %> -<%= render partial: 'users/settings/navigation.html.erb' %> +<%= render partial: 'users/settings/sidebar.html.erb' %>
-
- <%= render partial: 'users/settings/account/navigation.html.erb' %> -
-
+

<%= t('users.settings.account.addons.title') %>

diff --git a/app/views/users/settings/account/preferences/index.html.erb b/app/views/users/settings/account/preferences/index.html.erb index 662caf09f..2aa0d334c 100644 --- a/app/views/users/settings/account/preferences/index.html.erb +++ b/app/views/users/settings/account/preferences/index.html.erb @@ -1,14 +1,11 @@ <% provide(:head_title, t("users.settings.account.preferences.head_title")) %> -<%= render partial: "users/settings/navigation.html.erb" %> +<%= render partial: "users/settings/sidebar.html.erb" %>
-
- <%= render partial: 'users/settings/account/navigation.html.erb' %> -
-
+
<%= form_for(@user, url: update_preferences_path(format: :json), remote: true, diff --git a/app/views/users/settings/teams/index.html.erb b/app/views/users/settings/teams/index.html.erb index 13c749e0b..f2508f7ff 100644 --- a/app/views/users/settings/teams/index.html.erb +++ b/app/views/users/settings/teams/index.html.erb @@ -1,6 +1,6 @@ <% provide(:head_title, t("users.settings.teams.head_title")) %> -<%= render partial: "users/settings/navigation.html.erb" %> +<%= render partial: "users/settings/sidebar.html.erb" %>
diff --git a/app/views/users/settings/teams/new.html.erb b/app/views/users/settings/teams/new.html.erb index 72b9967ce..9c95922c7 100644 --- a/app/views/users/settings/teams/new.html.erb +++ b/app/views/users/settings/teams/new.html.erb @@ -1,6 +1,6 @@ <% provide(:head_title, t("users.settings.teams.head_title")) %> -<%= render partial: "users/settings/navigation.html.erb" %> +<%= render partial: "users/settings/sidebar.html.erb" %>
diff --git a/app/views/users/settings/teams/show.html.erb b/app/views/users/settings/teams/show.html.erb index f4cc608a2..64559af9b 100644 --- a/app/views/users/settings/teams/show.html.erb +++ b/app/views/users/settings/teams/show.html.erb @@ -2,7 +2,7 @@
-<%= render partial: "users/settings/navigation.html.erb" %> +<%= render partial: "users/settings/sidebar.html.erb" %>
diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index 537dbec35..ee0ee4892 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -17,6 +17,7 @@ Rails.application.config.assets.precompile += %w(underscore.js) Rails.application.config.assets.precompile += %w(jsPlumb-2.0.4-min.js) Rails.application.config.assets.precompile += %w(jsnetworkx.js) Rails.application.config.assets.precompile += %w(handsontable.full.min.js) +Rails.application.config.assets.precompile += %w(users/settings/list_toggle.js) Rails.application.config.assets.precompile += %w(users/settings/account/preferences/index.js) Rails.application.config.assets.precompile += %w(users/settings/teams/index.js) diff --git a/config/locales/en.yml b/config/locales/en.yml index 027a0db44..a43348261 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1329,6 +1329,14 @@ en: navigation: account: "Account" teams: "Teams" + sidebar: + title: "Settings" + account: "Account" + teams: "Teams" + account_nav: + profile: "Profile" + preferences: "Preferences" + addons: "Add-ons" account: navigation: profile: "Profile" From 70dfe66b2ddd14c8e5bf6ab1039a83e84e3ee248 Mon Sep 17 00:00:00 2001 From: mlorb Date: Fri, 6 Apr 2018 14:20:40 +0200 Subject: [PATCH 2/5] refactoring --- .../javascripts/users/settings/list_toggle.js | 11 -------- .../users/settings/list_toggle.js.erb | 18 +++++++++++++ app/views/users/settings/_navigation.html.erb | 9 ------- app/views/users/settings/_sidebar.html.erb | 26 ++++++++----------- .../settings/account/_navigation.html.erb | 11 -------- config/initializers/assets.rb | 2 +- 6 files changed, 30 insertions(+), 47 deletions(-) delete mode 100644 app/assets/javascripts/users/settings/list_toggle.js create mode 100644 app/assets/javascripts/users/settings/list_toggle.js.erb delete mode 100644 app/views/users/settings/_navigation.html.erb delete mode 100644 app/views/users/settings/account/_navigation.html.erb diff --git a/app/assets/javascripts/users/settings/list_toggle.js b/app/assets/javascripts/users/settings/list_toggle.js deleted file mode 100644 index 38d2c8610..000000000 --- a/app/assets/javascripts/users/settings/list_toggle.js +++ /dev/null @@ -1,11 +0,0 @@ -function listToggleShow() { - $('#triangleDown').show(); - $('#triangleRight').hide(); - $('#accountNavigation').show(); -} - -function listToggleHide() { - $('#triangleDown').hide(); - $('#triangleRight').show(); - $('#accountNavigation').hide(); -} diff --git a/app/assets/javascripts/users/settings/list_toggle.js.erb b/app/assets/javascripts/users/settings/list_toggle.js.erb new file mode 100644 index 000000000..a006dde1b --- /dev/null +++ b/app/assets/javascripts/users/settings/list_toggle.js.erb @@ -0,0 +1,18 @@ +(function() { + 'use strict'; + + $(".tree li.parent_li ").find("> span i").on("click", function (e) { + e.stopPropagation(); + var el = $(this).closest("li.parent_li"); + + if (el.find(" > ul.accountNavigation").is(":visible")) { + el.find(" > span > i.triangleDown").hide(); + el.find(" > span > i.triangleRight").show(); + el.find(" > ul.accountNavigation").hide(); + } else { + el.find(" > span > i.triangleDown").show(); + el.find(" > span > i.triangleRight").hide(); + el.find(" > ul.accountNavigation").show(); + } + }); +})(); diff --git a/app/views/users/settings/_navigation.html.erb b/app/views/users/settings/_navigation.html.erb deleted file mode 100644 index a5f481cd3..000000000 --- a/app/views/users/settings/_navigation.html.erb +++ /dev/null @@ -1,9 +0,0 @@ - diff --git a/app/views/users/settings/_sidebar.html.erb b/app/views/users/settings/_sidebar.html.erb index 6da85e95a..de9c3c67a 100644 --- a/app/views/users/settings/_sidebar.html.erb +++ b/app/views/users/settings/_sidebar.html.erb @@ -10,29 +10,25 @@
  • - - - <% style = 'font-weight: bold;' if on_settings_account_page? %> + <% account_style = 'font-weight: bold;' if on_settings_account_page? %> <%= link_to t("users.settings.sidebar.account"), edit_user_registration_path, - style: style, + style: account_style, data: { 'no-turbolink' => 'true' } %> -
      -