Skip to content

Commit

Permalink
Merge pull request #350 from pratikb64/app-switcher-improvements
Browse files Browse the repository at this point in the history
App switcher improvements
  • Loading branch information
pratikb64 authored Feb 19, 2025
2 parents d08e4e8 + ae7ab79 commit 85e7f45
Show file tree
Hide file tree
Showing 9 changed files with 93 additions and 25 deletions.
8 changes: 8 additions & 0 deletions wiki/public/js/wiki.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,11 @@ $("#navbar-dropdown").on("click", function (e) {
e.stopPropagation();
$("#navbar-dropdown-content").toggleClass("hide");
});

$(document).on("click", function (e) {
if (
!$(e.target).closest("#navbar-dropdown, #navbar-dropdown-content").length
) {
$("#navbar-dropdown-content").addClass("hide");
}
});
1 change: 1 addition & 0 deletions wiki/public/scss/markdown.scss
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@

.wiki-page-content {
margin: 0.5rem auto;
width: 650px;

@include media-breakpoint-down(md) {
width: auto;
Expand Down
10 changes: 1 addition & 9 deletions wiki/public/scss/navbar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
z-index: 5;
height: 60px;
position: relative;
border-bottom: 1px solid var(--border-color);

@include media-breakpoint-down(md) {
max-width: 14rem;
Expand Down Expand Up @@ -131,7 +130,6 @@
padding-right: 1rem;
height: 60px;
align-items: center;
border-bottom: 1px solid var(--border-color);
background-color: var(--background-color);

@include media-breakpoint-down(md) {
Expand Down Expand Up @@ -209,7 +207,7 @@

.navbar-toggler {
border-color: transparent;
padding: 18px;
padding: 8px;

&:focus {
outline: unset;
Expand Down Expand Up @@ -240,9 +238,3 @@
}
}
}

@include media-breakpoint-up(md) {
.navbar-light {
border-bottom: 0;
}
}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"actions": [],
"allow_rename": 1,
"creation": "2025-02-19 15:39:10.706506",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"app_title",
"wiki_space"
],
"fields": [
{
"fetch_from": "wiki_space.space_name",
"fieldname": "app_title",
"fieldtype": "Data",
"in_list_view": 1,
"label": "App Title",
"placeholder": "Select Wiki Space to see title",
"read_only": 1
},
{
"fieldname": "wiki_space",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Wiki Space",
"options": "Wiki Space"
}
],
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2025-02-19 15:42:44.734010",
"modified_by": "Administrator",
"module": "Wiki",
"name": "Wiki App Switcher List Table",
"owner": "Administrator",
"permissions": [],
"sort_field": "creation",
"sort_order": "DESC",
"states": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright (c) 2025, Frappe and contributors
# For license information, please see license.txt

# import frappe
from frappe.model.document import Document


class WikiAppSwitcherListTable(Document):
pass
30 changes: 23 additions & 7 deletions wiki/wiki/doctype/wiki_page/wiki_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,15 +206,31 @@ def get_context(self, context):
self.verify_permission()
self.set_breadcrumbs(context)

allSpaces = frappe.get_all(
"Wiki Space",
fields=["route", "space_name", "app_switcher_logo"],
filters={"show_in_navbar_app_switcher": 1},
)
wiki_settings = frappe.get_single("Wiki Settings")

context.spaces = allSpaces
# Extract wiki_space names in the original order
wiki_space_names = [entry.wiki_space for entry in wiki_settings.app_switcher_list]

# Fetch all linked Wiki Space documents
if wiki_space_names:
wiki_spaces = frappe.get_all(
"Wiki Space",
filters={"name": ["in", wiki_space_names]},
fields=["name", "space_name", "app_switcher_logo", "route"],
)

# Create a dictionary for quick lookup
wiki_spaces_dict = {doc.name: doc for doc in wiki_spaces}

# Reorder the documents based on the original list's order
ordered_wiki_spaces = [
wiki_spaces_dict[name] for name in wiki_space_names if name in wiki_spaces_dict
]
else:
ordered_wiki_spaces = []

context.spaces = ordered_wiki_spaces

wiki_settings = frappe.get_single("Wiki Settings")
wiki_space_name = frappe.get_value("Wiki Group Item", {"wiki_page": self.name}, "parent")
wiki_space = (
frappe.get_cached_doc("Wiki Space", wiki_space_name) if wiki_space_name else frappe._dict()
Expand Down
9 changes: 8 additions & 1 deletion wiki/wiki/doctype/wiki_settings/wiki_settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"navbar_tab",
"navbar_column",
"navbar",
"app_switcher_list",
"section_break_skhp",
"search_column",
"add_search_bar",
Expand Down Expand Up @@ -158,12 +159,18 @@
"fieldtype": "Int",
"label": "Feedback Submission Limit",
"non_negative": 1
},
{
"fieldname": "app_switcher_list",
"fieldtype": "Table",
"label": "App Switcher List",
"options": "Wiki App Switcher List Table"
}
],
"index_web_pages_for_search": 1,
"issingle": 1,
"links": [],
"modified": "2024-09-29 14:05:32.587922",
"modified": "2025-02-19 15:41:34.635439",
"modified_by": "Administrator",
"module": "Wiki",
"name": "Wiki Settings",
Expand Down
9 changes: 1 addition & 8 deletions wiki/wiki/doctype/wiki_space/wiki_space.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"general_tab",
"space_name",
"route",
"show_in_navbar_app_switcher",
"app_switcher_logo",
"wiki_sidebars",
"navbar_tab",
Expand Down Expand Up @@ -71,12 +70,6 @@
"fieldname": "section_break_fhui",
"fieldtype": "Section Break"
},
{
"default": "0",
"fieldname": "show_in_navbar_app_switcher",
"fieldtype": "Check",
"label": "Show in navbar app switcher"
},
{
"fieldname": "space_name",
"fieldtype": "Data",
Expand All @@ -92,7 +85,7 @@
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2025-02-18 14:09:29.088972",
"modified": "2025-02-19 16:11:08.336359",
"modified_by": "Administrator",
"module": "Wiki",
"name": "Wiki Space",
Expand Down

0 comments on commit 85e7f45

Please sign in to comment.