-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed #31034 -- Added a navigation sidebar to the admin.
Co-authored-by: elky <[email protected]> Co-authored-by: Goetz <[email protected]>
- Loading branch information
Showing
17 changed files
with
337 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -884,6 +884,7 @@ answer newbie questions, and generally made Django that much better: | |
Tobias McNulty <https://www.caktusgroup.com/blog/> | ||
[email protected] | ||
Todd O'Bryan <[email protected]> | ||
Tom Carrick <https://www.carrick.eu> | ||
Tom Christie <[email protected]> | ||
Tom Forbes <[email protected]> | ||
Tom Insam | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
.sticky { | ||
position: sticky; | ||
top: 0; | ||
max-height: 100vh; | ||
} | ||
|
||
.toggle-nav-sidebar { | ||
z-index: 20; | ||
left: 0; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
flex: 0 0 23px; | ||
width: 23px; | ||
border-right: 1px solid #eaeaea; | ||
background-color: #ffffff; | ||
cursor: pointer; | ||
font-size: 20px; | ||
color: #447e9b; | ||
} | ||
|
||
[dir="rtl"] .toggle-nav-sidebar { | ||
border-left: 1px solid #eaeaea; | ||
border-right: 0; | ||
} | ||
|
||
.toggle-nav-sidebar:hover, | ||
.toggle-nav-sidebar:focus { | ||
background-color: #f6f6f6; | ||
} | ||
|
||
#nav-sidebar { | ||
z-index: 15; | ||
flex: 0 0 275px; | ||
left: -276px; | ||
margin-left: -276px; | ||
border-top: 1px solid transparent; | ||
border-right: 1px solid #eaeaea; | ||
background-color: #ffffff; | ||
overflow: auto; | ||
} | ||
|
||
[dir="rtl"] #nav-sidebar { | ||
border-left: 1px solid #eaeaea; | ||
border-right: 0; | ||
left: 0; | ||
margin-left: 0; | ||
right: -276px; | ||
margin-right: -276px; | ||
} | ||
|
||
.toggle-nav-sidebar::before { | ||
content: '\00BB'; | ||
} | ||
|
||
.main.shifted .toggle-nav-sidebar::before { | ||
content: '\00AB'; | ||
} | ||
|
||
.main.shifted > #nav-sidebar { | ||
left: 24px; | ||
margin-left: 0; | ||
} | ||
|
||
[dir="rtl"] .main.shifted > #nav-sidebar { | ||
left: 0; | ||
right: 24px; | ||
margin-right: 0; | ||
} | ||
|
||
#nav-sidebar .module th { | ||
width: 100%; | ||
} | ||
|
||
#nav-sidebar .module th, | ||
#nav-sidebar .module caption { | ||
padding-left: 16px; | ||
} | ||
|
||
[dir="rtl"] #nav-sidebar .module th, | ||
[dir="rtl"] #nav-sidebar .module caption { | ||
padding-left: 8px; | ||
padding-right: 16px; | ||
} | ||
|
||
#nav-sidebar .current-app .section:link, | ||
#nav-sidebar .current-app .section:visited { | ||
color: #ffc; | ||
font-weight: bold; | ||
} | ||
|
||
#nav-sidebar .current-model { | ||
background: #ffc; | ||
} | ||
|
||
@media (max-width: 767px) { | ||
#nav-sidebar, #toggle-nav-sidebar { | ||
display: none; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
'use strict'; | ||
{ | ||
const toggleNavSidebar = document.getElementById('toggle-nav-sidebar'); | ||
if (toggleNavSidebar !== null) { | ||
const main = document.getElementById('main'); | ||
let navSidebarIsOpen = localStorage.getItem('django.admin.navSidebarIsOpen'); | ||
if (navSidebarIsOpen === null) { | ||
navSidebarIsOpen = 'true'; | ||
} | ||
main.classList.toggle('shifted', navSidebarIsOpen === 'true'); | ||
|
||
toggleNavSidebar.addEventListener('click', function() { | ||
if (navSidebarIsOpen == 'true') { | ||
navSidebarIsOpen = 'false'; | ||
} else { | ||
navSidebarIsOpen = 'true'; | ||
} | ||
localStorage.setItem('django.admin.navSidebarIsOpen', navSidebarIsOpen); | ||
main.classList.toggle('shifted'); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{% load i18n %} | ||
|
||
{% if app_list %} | ||
{% for app in app_list %} | ||
<div class="app-{{ app.app_label }} module{% if app.app_url in request.path %} current-app{% endif %}"> | ||
<table> | ||
<caption> | ||
<a href="{{ app.app_url }}" class="section" title="{% blocktranslate with name=app.name %}Models in the {{ name }} application{% endblocktranslate %}">{{ app.name }}</a> | ||
</caption> | ||
{% for model in app.models %} | ||
<tr class="model-{{ model.object_name|lower }}{% if model.admin_url in request.path %} current-model{% endif %}"> | ||
{% if model.admin_url %} | ||
<th scope="row"><a href="{{ model.admin_url }}"{% if model.admin_url in request.path %} aria-current="page"{% endif %}>{{ model.name }}</a></th> | ||
{% else %} | ||
<th scope="row">{{ model.name }}</th> | ||
{% endif %} | ||
|
||
{% if model.add_url %} | ||
<td><a href="{{ model.add_url }}" class="addlink">{% translate 'Add' %}</a></td> | ||
{% else %} | ||
<td></td> | ||
{% endif %} | ||
|
||
{% if model.admin_url and show_changelinks %} | ||
{% if model.view_only %} | ||
<td><a href="{{ model.admin_url }}" class="viewlink">{% translate 'View' %}</a></td> | ||
{% else %} | ||
<td><a href="{{ model.admin_url }}" class="changelink">{% translate 'Change' %}</a></td> | ||
{% endif %} | ||
{% elif show_changelinks %} | ||
<td></td> | ||
{% endif %} | ||
</tr> | ||
{% endfor %} | ||
</table> | ||
</div> | ||
{% endfor %} | ||
{% else %} | ||
<p>{% translate 'You don’t have permission to view or edit anything.' %}</p> | ||
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<div class="sticky toggle-nav-sidebar" id="toggle-nav-sidebar"></div> | ||
<nav class="sticky" id="nav-sidebar"> | ||
{% include 'admin/app_list.html' with app_list=available_apps %} | ||
</nav> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
d24ba1b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Congrats! 👏
d24ba1b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this issue solved and committed? cause i can still see this issue on code.djangoproject.com and this save button overlapping is still happening in my latest fetch of django
d24ba1b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AtmegaBuzz As you can see on Trac, this ticket is not fixed. Feel-free to prepare a patch.
d24ba1b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@felixxm ok working on it