Pārlūkot izejas kodu

refactor(desk_icon): remove patches and references to desk icons

version-14
Prateeksha Singh pirms 6 gadiem
vecāks
revīzija
34fd318c25
14 mainītis faili ar 4 papildinājumiem un 252 dzēšanām
  1. +0
    -4
      frappe/core/doctype/user/user.js
  2. +1
    -4
      frappe/installer.py
  3. +0
    -6
      frappe/patches.txt
  4. +0
    -44
      frappe/patches/v6_24/sync_desktop_icons.py
  5. +0
    -12
      frappe/patches/v7_0/desktop_icons_hidden_by_admin_as_blocked.py
  6. +0
    -6
      frappe/patches/v7_2/merge_knowledge_base.py
  7. +0
    -14
      frappe/patches/v8_0/fix_non_english_desktop_icons.py
  8. +3
    -16
      frappe/patches/v8_0/setup_email_inbox.py
  9. +0
    -25
      frappe/patches/v8_0/update_desktop_icons.py
  10. +0
    -1
      frappe/public/build.json
  11. +0
    -108
      frappe/public/js/frappe/ui/toolbar/modules_select.js
  12. +0
    -2
      frappe/public/js/frappe/ui/toolbar/navbar.html
  13. +0
    -9
      frappe/public/js/frappe/ui/toolbar/toolbar.js
  14. +0
    -1
      frappe/translate.py

+ 0
- 4
frappe/core/doctype/user/user.js Parādīt failu

@@ -71,10 +71,6 @@ frappe.ui.form.on('User', {
frm.toggle_display(['sb1', 'sb3', 'modules_access'], false);

if(!frm.is_new()) {
frm.add_custom_button(__("Set Desktop Icons"), function() {
frappe.frappe_toolbar.modules_select.show(doc.name);
}, null, "btn-default")

if(has_access_to_edit_user()) {

frm.add_custom_button(__("Set User Permissions"), function() {


+ 1
- 4
frappe/installer.py Parādīt failu

@@ -23,7 +23,7 @@ from frappe.database import setup_database
def install_db(root_login="root", root_password=None, db_name=None, source_sql=None,
admin_password=None, verbose=True, force=0, site_config=None, reinstall=False,
db_type=None):
if not db_type:
db_type = frappe.conf.db_type or 'mariadb'

@@ -158,9 +158,6 @@ def remove_app(app_name, dry_run=False, yes=False):
if not dry_run:
frappe.delete_doc("Module Def", module_name)

# delete desktop icons
frappe.db.sql('delete from `tabDesktop Icon` where app=%s', app_name)

remove_from_installed_apps(app_name)

if not dry_run:


+ 0
- 6
frappe/patches.txt Parādīt failu

@@ -145,11 +145,9 @@ frappe.patches.v6_16.feed_doc_owner
frappe.patches.v6_21.print_settings_repeat_header_footer
frappe.patches.v6_24.set_language_as_code
frappe.patches.v6_20x.update_insert_after
finally:frappe.patches.v6_24.sync_desktop_icons
frappe.patches.v6_20x.set_allow_draft_for_print
frappe.patches.v6_20x.remove_roles_from_website_user
frappe.patches.v7_0.set_user_fullname
frappe.patches.v7_0.desktop_icons_hidden_by_admin_as_blocked
frappe.patches.v7_0.add_communication_in_doc
frappe.patches.v7_0.update_send_after_in_bulk_email
execute:frappe.db.sql('''delete from `tabSingles` where doctype="Email Settings"''') # 2016-06-13
@@ -183,15 +181,11 @@ frappe.patches.v8_0.deprecate_integration_broker
frappe.patches.v8_0.update_gender_and_salutation
frappe.patches.v8_0.setup_email_inbox #2017-03-29
frappe.patches.v8_0.newsletter_childtable_migrate
execute:frappe.db.sql("delete from `tabDesktop Icon` where module_name='Communication'")
execute:frappe.db.sql("update `tabDesktop Icon` set type='list' where _doctype='Communication'")
frappe.patches.v8_0.fix_non_english_desktop_icons # 2017-04-12
frappe.patches.v8_0.set_doctype_values_in_custom_role
frappe.patches.v8_0.install_new_build_system_requirements
frappe.patches.v8_0.set_currency_field_precision # 2017-05-09
frappe.patches.v8_0.rename_print_to_printing
frappe.patches.v7_1.disabled_print_settings_for_custom_print_format
frappe.patches.v8_0.update_desktop_icons
execute:frappe.db.sql('update tabReport set module="Desk" where name="ToDo"')
frappe.patches.v8_1.enable_allow_error_traceback_in_system_settings
frappe.patches.v8_1.update_format_options_in_auto_email_report


+ 0
- 44
frappe/patches/v6_24/sync_desktop_icons.py Parādīt failu

@@ -1,44 +0,0 @@
from __future__ import unicode_literals
import frappe, json

from frappe.desk.doctype.desktop_icon.desktop_icon import sync_from_app, get_user_copy
import frappe.defaults

def execute():
frappe.reload_doc('desk', 'doctype', 'desktop_icon')

frappe.db.sql('delete from `tabDesktop Icon`')

modules_list = []
for app in frappe.get_installed_apps():
modules_list += sync_from_app(app)

# sync hidden modules
hidden_modules = frappe.db.get_global('hidden_modules')
if hidden_modules:
for m in json.loads(hidden_modules):
try:
desktop_icon = frappe.get_doc('Desktop Icon', {'module_name': m, 'standard': 1, 'app': app})
desktop_icon.db_set('hidden', 1)
except frappe.DoesNotExistError:
pass

# sync user sort
for user in frappe.get_all('User', filters={'user_type': 'System User'}):
user_list = frappe.defaults.get_user_default('_user_desktop_items', user=user.name)
if user_list:
user_list = json.loads(user_list)
for i, module_name in enumerate(user_list):
try:
desktop_icon = get_user_copy(module_name, user=user.name)
desktop_icon.db_set('idx', i)
except frappe.DoesNotExistError:
pass

# set remaining icons as hidden
for module_name in list(set([m['module_name'] for m in modules_list]) - set(user_list)):
try:
desktop_icon = get_user_copy(module_name, user=user.name)
desktop_icon.db_set('hidden', 1)
except frappe.DoesNotExistError:
pass

+ 0
- 12
frappe/patches/v7_0/desktop_icons_hidden_by_admin_as_blocked.py Parādīt failu

@@ -1,12 +0,0 @@
from __future__ import unicode_literals
import frappe

def execute():
# all icons hidden in standard are "blocked"
# this is for the use case where the admin wants to remove icon for everyone

# in 7.0, icons may be hidden by default, but still can be shown to the user
# e.g. Accounts, Stock etc, so we need a new property for blocked

if frappe.db.table_exists('Desktop Icon'):
frappe.db.sql('update `tabDesktop Icon` set blocked = 1 where standard=1 and hidden=1')

+ 0
- 6
frappe/patches/v7_2/merge_knowledge_base.py Parādīt failu

@@ -11,12 +11,6 @@ def execute():
update_routes(['Help Category', 'Help Article'])
remove_from_installed_apps('knowledge_base')

# remove desktop icon
desktop_icon_name = frappe.db.get_value('Desktop Icon',
dict(module_name='Knowledge Base', type='module'))
if desktop_icon_name:
frappe.delete_doc('Desktop Icon', desktop_icon_name)

# remove module def
if frappe.db.exists('Module Def', 'Knowledge Base'):
frappe.delete_doc('Module Def', 'Knowledge Base')


+ 0
- 14
frappe/patches/v8_0/fix_non_english_desktop_icons.py Parādīt failu

@@ -1,14 +0,0 @@
# Copyright (c) 2017, Frappe and Contributors
# License: GNU General Public License v3. See license.txt
# -*- coding: utf-8 -*-

from __future__ import unicode_literals
import frappe
from frappe.desk.doctype.desktop_icon.desktop_icon import clear_desktop_icons_cache

def execute():
frappe.db.sql("""
update `tabDesktop Icon`
set module_name=_doctype, label=_doctype
where type = 'link' and _doctype != label and link like 'List/%'
""")

+ 3
- 16
frappe/patches/v8_0/setup_email_inbox.py Parādīt failu

@@ -3,31 +3,18 @@ import frappe, json
from frappe.core.doctype.user.user import ask_pass_update, setup_user_email_inbox

def execute():
"""
"""
depricate email inbox page if exists
remove desktop icon for email inbox page if exists
patch to remove Custom DocPerm for communication
add user inbox child table entry for existing email account in not exists
"""

if frappe.db.exists("Page", "email_inbox"):
frappe.delete_doc("Page", "email_inbox")

desktop_icon = frappe.db.get_value("Desktop Icon", {
"module_name": "Email",
"type": "Page",
"link": "email_inbox"
})

if desktop_icon:
frappe.delete_doc("Desktop Icon", desktop_icon)

frappe.db.sql("""update `tabCustom DocPerm` set `write`=0, email=1 where parent='Communication'""")

setup_inbox_from_email_account()

def setup_inbox_from_email_account():
""" add user inbox child table entry for existing email account in not exists """

frappe.reload_doc("core", "doctype", "user_email")
frappe.reload_doc("email", "doctype", "email_account")

@@ -36,4 +23,4 @@ def setup_inbox_from_email_account():

for email_account in email_accounts:
setup_user_email_inbox(email_account.get("name"), email_account.get("awaiting_password"),
email_account.get("email_id"), email_account.get("enabled_outgoing"))
email_account.get("email_id"), email_account.get("enabled_outgoing"))

+ 0
- 25
frappe/patches/v8_0/update_desktop_icons.py Parādīt failu

@@ -1,25 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt

from __future__ import unicode_literals
import frappe
from frappe.utils import cstr

def execute():
""" update the desktop icons """

frappe.reload_doc('desk', 'doctype', 'desktop_icon')

icons = frappe.get_all("Desktop Icon", filters={ "type": "link" }, fields=["link", "name"])

for icon in icons:
# check if report exists
icon_link = icon.get("link", "") or ""
parts = icon_link.split("/")
if not parts:
continue

report_name = parts[-1]
if "report" in parts[0] and frappe.db.get_value("Report", report_name):
frappe.db.sql(""" update `tabDesktop Icon` set _report='{report_name}'
where name='{name}'""".format(report_name=report_name, name=icon.get("name")))

+ 0
- 1
frappe/public/build.json Parādīt failu

@@ -230,7 +230,6 @@
"public/js/frappe/ui/toolbar/about.js",
"public/js/frappe/ui/toolbar/navbar.html",
"public/js/frappe/ui/toolbar/toolbar.js",
"public/js/frappe/ui/toolbar/modules_select.js",
"public/js/frappe/ui/toolbar/notifications.js",
"public/js/frappe/views/communication.js",
"public/js/frappe/views/translation_manager.js",


+ 0
- 108
frappe/public/js/frappe/ui/toolbar/modules_select.js Parādīt failu

@@ -1,108 +0,0 @@
frappe.provide('frappe.ui.toolbar');

frappe.ui.toolbar.ModulesSelect = class {
constructor() {
this.user = frappe.boot.user.name;
this.setup();
}

setup() {
this.dialog = new frappe.ui.Dialog({
title: __('Set Desktop Icons'),
fields: [
{
label: __('Setup for'),
fieldname: 'setup_for',
fieldtype: 'Select',
options: [
{label: __('User'), value: 'user'},
{label: __('Everyone'), value: 'everyone'}
],
default: 'user',
onchange: () => {
let field = this.$setup_for;
if(field.get_value() === 'everyone') {
this.$user.$wrapper.hide();
this.user = undefined;
field.set_description(__('Limit icon choices for all users.'));
} else {
this.$user.$wrapper.show();
this.user = this.$user.get_value();
field.set_description('');
}
this.$icons_list.refresh();
}
},
{ fieldtype: 'Column Break' },
{
label: __('User'),
fieldname: 'user',
fieldtype: 'Link',
options: 'User',
default: frappe.boot.user.name,
onchange: () => {
this.user = this.get_value() || frappe.boot.user.name;
this.$icons_list.refresh();
}
},
{ fieldtype: 'Section Break' },
{
// label: __('Icons'),
fieldname: 'icons',
fieldtype: 'MultiCheck',
select_all: 1,
columns: 2,
get_data: () => {
return new Promise((resolve) => {
frappe.call({
method: 'frappe.desk.doctype.desktop_icon.desktop_icon.get_module_icons',
args: {user: this.user},
freeze: true,
callback: (r) => {
const icons = r.message.icons;
const user = r.message.user;
resolve(icons
.map(icon => {
const uncheck = user ? icon.hidden : icon.blocked;
return { label: icon.label, value: icon.module_name, checked:!uncheck };
}).sort(function(a, b){
if(a.label < b.label) return -1;
if(a.label > b.label) return 1;
return 0;
})
);
}
});
});
}
}
]
});

this.dialog.set_primary_action(__('Save'), () => {
frappe.call({
method: 'frappe.desk.doctype.desktop_icon.desktop_icon.update_icons',
args: {
hidden_list: this.$icons_list.get_unchecked_options(),
user: this.user
},
freeze: true,
callback: () => {
window.location.href = '';
}
});
});

this.$icons_list = this.dialog.fields_dict.icons;
this.$setup_for = this.dialog.fields_dict.setup_for;
this.$user = this.dialog.fields_dict.user;
}

show(user) {
if(user) {
this.user = user || frappe.boot.user.name;
this.$icons_list.refresh();
}
this.dialog.show();
}
};

+ 0
- 2
frappe/public/js/frappe/ui/toolbar/navbar.html Parādīt failu

@@ -24,8 +24,6 @@
{%= frappe.user.full_name() %}</span>
<b class="caret hidden-xs hidden-sm"></b></a>
<ul class="dropdown-menu" id="toolbar-user" role="menu">
<li class="navbar-set-desktop-icons"><a>
{%= __("Set Desktop Icons") %}</a></li>
<li><a href="#Form/User/{%= encodeURIComponent(frappe.session.user) %}">
{%= __("My Settings") %}</a></li>
<li class="navbar-reload">


+ 0
- 9
frappe/public/js/frappe/ui/toolbar/toolbar.js Parādīt failu

@@ -21,21 +21,12 @@ frappe.ui.toolbar.Toolbar = Class.extend({
make: function() {
this.setup_sidebar();
this.setup_help();
this.setup_modules_dialog();

this.bind_events();

$(document).trigger('toolbar_setup');
},


setup_modules_dialog() {
this.modules_select = new frappe.ui.toolbar.ModulesSelect();
$('.navbar-set-desktop-icons').on('click', () => {
this.modules_select.show();
});
},

bind_events: function() {
$(document).on("notification-update", function() {
frappe.ui.notifications.update_notifications();


+ 0
- 1
frappe/translate.py Parādīt failu

@@ -116,7 +116,6 @@ def get_dict(fortype, name=None):
messages += frappe.db.sql("select 'DocType:', name from tabDocType")
messages += frappe.db.sql("select 'Role:', name from tabRole")
messages += frappe.db.sql("select 'Module:', name from `tabModule Def`")
messages += frappe.db.sql("select 'Module:', label from `tabDesktop Icon` where standard=1 or owner=%s",
frappe.session.user)

message_dict = make_dict_from_messages(messages)


Notiek ielāde…
Atcelt
Saglabāt