feat: set app as default from apps page
This commit is contained in:
parent
11b699c60d
commit
5ec4001340
4 changed files with 52 additions and 1 deletions
|
|
@ -64,3 +64,9 @@ def get_default_path():
|
|||
elif is_desk_apps(_apps):
|
||||
return "/app"
|
||||
return "/apps"
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
def set_app_as_default(app_name):
|
||||
frappe.db.set_value("User", frappe.session.user, "default_app", app_name)
|
||||
return True
|
||||
|
|
|
|||
|
|
@ -41,6 +41,17 @@
|
|||
align-items: center;
|
||||
justify-content: center;
|
||||
text-decoration: none;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.app-icon:hover .set-default {
|
||||
display: block !important;
|
||||
}
|
||||
|
||||
.set-default {
|
||||
position: absolute;
|
||||
top: -20px;
|
||||
right: -20px;
|
||||
}
|
||||
|
||||
.app-logo {
|
||||
|
|
|
|||
|
|
@ -14,6 +14,15 @@ endblock -%} {%- block footer -%} {%- endblock -%} {% block content %}
|
|||
<a href="{{ app.route }}" class="app-icon">
|
||||
<img class="app-logo" src="{{ app.logo }}" />
|
||||
<div class="app-title">{{ app.title }}</div>
|
||||
<div
|
||||
app-name="{{ app.name }}"
|
||||
class="set-default btn btn-xs {{ '' if app.is_default else 'hidden'}}"
|
||||
title="set app as default"
|
||||
>
|
||||
<svg class="icon icon-sm">
|
||||
<use href="#icon-solid-success"></use>
|
||||
</svg>
|
||||
</div>
|
||||
</a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
|
@ -39,3 +48,19 @@ endblock -%} {%- block footer -%} {%- endblock -%} {% block content %}
|
|||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block script %}
|
||||
<script>
|
||||
$('.set-default').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
var appName = $(this).attr('app-name');
|
||||
frappe.call({
|
||||
method: 'frappe.apps.set_app_as_default',
|
||||
args: { app_name: appName },
|
||||
callback: function() {
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
|
|
|||
|
|
@ -13,4 +13,13 @@ def get_context():
|
|||
if frappe.session.data.user_type == "Website User":
|
||||
frappe.throw(_("You are not permitted to access this page."), frappe.PermissionError)
|
||||
|
||||
return {"apps": get_apps()}
|
||||
system_default_app = frappe.get_system_settings("default_app")
|
||||
user_default_app = frappe.db.get_value("User", frappe.session.user, "default_app")
|
||||
default_app = user_default_app if user_default_app else system_default_app
|
||||
|
||||
all_apps = get_apps()
|
||||
|
||||
for app in all_apps:
|
||||
app["is_default"] = True if app.get("name") == default_app else False
|
||||
|
||||
return {"apps": all_apps}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue