Skip to content

Commit

Permalink
Merge 6fbaccb into 7b30ab7
Browse files Browse the repository at this point in the history
  • Loading branch information
javierm committed Jan 16, 2023
2 parents 7b30ab7 + 6fbaccb commit d9af8ce
Show file tree
Hide file tree
Showing 27 changed files with 293 additions and 257 deletions.
88 changes: 0 additions & 88 deletions app/assets/stylesheets/admin.scss
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,6 @@ $table-header: #ecf1f6;
.admin {
@include admin-layout;

> header {
border-bottom: 1px solid #eee;

> * {
@include full-width-background($adjust-margin: false, $adjust-padding: true);
}
}

h2 {
font-weight: 100;
margin-bottom: $line-height;
Expand All @@ -60,86 +52,6 @@ $table-header: #ecf1f6;
float: none;
}

.top-links {

a {
line-height: rem-calc($line-height * 1.5);
}
}

.top-bar {
height: auto;
padding-top: $line-height / 2;

@include breakpoint(small only) {

.top-bar-left ul {
display: inline-block;
}

.top-bar-right {

> ul {
border-bottom: 0;
padding-bottom: 0;
margin-bottom: 0;
}

.submenu {
position: initial;
}

a {
font-weight: normal;
}
}

[class^="icon-"] {
display: none;
}
}

[class^="icon-"] {
font-size: $base-font-size;
}

h1 {
margin-top: $line-height / 2;
margin-bottom: 0;

@include breakpoint(medium) {
margin-top: 0;
}

small {
color: inherit;
text-transform: uppercase;
}

a {
color: inherit;
display: inline-block;
font-family: "Lato" !important;
font-size: rem-calc(24);
font-weight: lighter;
line-height: 1;
}
}
}

.top-bar .menu > li {

@include breakpoint(medium) {
height: auto !important;
}
}

.title-bar {
color: inherit;
position: absolute;
right: 12px;
}

.notifications.unread-notifications::after {
color: $admin-color;
}
Expand Down
89 changes: 89 additions & 0 deletions app/assets/stylesheets/layout/admin_header.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
.admin {
> header {
border-bottom: 1px solid #eee;

> * {
@include full-width-background($adjust-margin: false, $adjust-padding: true);
}
}

.top-links {

a {
line-height: rem-calc($line-height * 1.5);
}
}

.top-bar {
height: auto;
padding-top: $line-height / 2;

@include breakpoint(small only) {

.top-bar-left ul {
display: inline-block;
}

.top-bar-right {

> ul {
border-bottom: 0;
padding-bottom: 0;
margin-bottom: 0;
}

.submenu {
position: initial;
}

a {
font-weight: normal;
}
}

[class^="icon-"] {
display: none;
}
}

[class^="icon-"] {
font-size: $base-font-size;
}

h1 {
margin-top: $line-height / 2;
margin-bottom: 0;

@include breakpoint(medium) {
margin-top: 0;
}

small {
color: inherit;
text-transform: uppercase;
}

a {
color: inherit;
display: inline-block;
font-family: "Lato" !important;
font-size: rem-calc(24);
font-weight: lighter;
line-height: 1;
}
}
}

.top-bar .menu > li {

@include breakpoint(medium) {
height: auto !important;
}
}

.title-bar {
color: inherit;
position: absolute;
right: 12px;
}
}
5 changes: 5 additions & 0 deletions app/components/layout/account_menu_component.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<ul class="menu" data-responsive-menu="medium-dropdown">
<%= render Layout::AdminLoginItemsComponent.new(user) %>
<%= render Layout::NotificationItemComponent.new(user) %>
<%= render Layout::LoginItemsComponent.new(user) %>
</ul>
7 changes: 7 additions & 0 deletions app/components/layout/account_menu_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class Layout::AccountMenuComponent < ApplicationComponent
attr_reader :user

def initialize(user)
@user = user
end
end
39 changes: 39 additions & 0 deletions app/components/layout/admin_header_component.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<header class="header">
<div class="top-links">
<%= render "shared/locale_switcher" %>
<%= link_to root_path do %>
<%= t("admin.dashboard.index.back", org: setting["org_name"]) %>
<% end %>
</div>

<div class="expanded row admin-top-bar">
<% if show_admin_menu?(user) || namespace != "management" %>
<div class="title-bar" data-responsive-toggle="responsive_menu" data-hide-for="medium">
<button class="menu-button" type="button" data-toggle="responsive_menu">
<span class="menu-icon"></span>
<span class="title-bar-title"><%= t("application.menu") %></span>
</button>
</div>
<% end %>

<div class="top-bar">
<div class="top-bar-left">
<h1>
<%= link_to namespace_path do %>
<%= setting["org_name"] %>
<br><small><%= namespaced_header_title %></small>
<% end %>
</h1>
</div>

<% if show_admin_menu?(user) || namespace != "management" %>
<div id="responsive_menu">
<div class="top-bar-right">
<%= render Layout::AccountMenuComponent.new(user) %>
</div>
</div>
<% end %>
</div>
</div>
</header>
28 changes: 28 additions & 0 deletions app/components/layout/admin_header_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
class Layout::AdminHeaderComponent < ApplicationComponent
attr_reader :user
delegate :namespace, :namespaced_root_path, :show_admin_menu?, to: :helpers

def initialize(user)
@user = user
end

private

def namespaced_header_title
if namespace == "moderation/budgets"
t("moderation.header.title")
elsif namespace == "management"
t("management.dashboard.index.title")
else
t("#{namespace}.header.title")
end
end

def namespace_path
if namespace == "officing"
"#"
else
namespaced_root_path
end
end
end
4 changes: 4 additions & 0 deletions app/components/layout/admin_login_items_component.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<li class="has-submenu">
<%= link_to t("layouts.header.administration_menu"), "#", rel: "nofollow", class: "hide-for-small-only" %>
<%= link_list(*admin_links, class: "submenu menu", data: { submenu: true }) %>
</li>
49 changes: 49 additions & 0 deletions app/components/layout/admin_login_items_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
class Layout::AdminLoginItemsComponent < ApplicationComponent
attr_reader :user
delegate :link_list, :show_admin_menu?, to: :helpers

def initialize(user)
@user = user
end

def render?
show_admin_menu?(user)
end

private

def admin_links
[
(admin_link if user.administrator?),
(moderation_link if user.administrator? || user.moderator?),
(valuation_link if feature?(:budgets) && (user.administrator? || user.valuator?)),
(management_link if user.administrator? || user.manager?),
(officing_link if user.poll_officer? && Poll.current.any?),
(sdg_management_link if feature?(:sdg) && (user.administrator? || user.sdg_manager?))
]
end

def admin_link
[t("layouts.header.administration"), admin_root_path]
end

def moderation_link
[t("layouts.header.moderation"), moderation_root_path]
end

def valuation_link
[t("layouts.header.valuation"), valuation_root_path]
end

def management_link
[t("layouts.header.management"), management_sign_in_path]
end

def officing_link
[t("layouts.header.officing"), officing_root_path]
end

def sdg_management_link
[t("sdg_management.header.title"), sdg_management_root_path]
end
end
File renamed without changes.
2 changes: 2 additions & 0 deletions app/components/layout/footer_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class Layout::FooterComponent < ApplicationComponent
end
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<% if user_signed_in? %>
<% if user %>
<li>
<%= layout_menu_link_to t("layouts.header.my_activity_link"),
user_path(current_user),
user_path(user),
controller_name == "users",
rel: "nofollow",
title: t("shared.go_to_page") +
Expand Down
8 changes: 8 additions & 0 deletions app/components/layout/login_items_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class Layout::LoginItemsComponent < ApplicationComponent
attr_reader :user
delegate :layout_menu_link_to, to: :helpers

def initialize(user)
@user = user
end
end
File renamed without changes.
3 changes: 3 additions & 0 deletions app/components/layout/subnavigation_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Layout::SubnavigationComponent < ApplicationComponent
delegate :content_block, :layout_menu_link_to, to: :helpers
end
10 changes: 0 additions & 10 deletions app/helpers/admin_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,6 @@ def namespaced_root_path
"/#{namespace}"
end

def namespaced_header_title
if namespace == "moderation/budgets"
t("moderation.header.title")
elsif namespace == "management"
t("management.dashboard.index.title")
else
t("#{namespace}.header.title")
end
end

def official_level_options
options = [["", 0]]
(1..5).each do |i|
Expand Down
Loading

0 comments on commit d9af8ce

Please sign in to comment.