From 2f926f0136b3025644fc7656be235871c3ff2a6b Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Tue, 6 May 2014 17:17:40 +0530 Subject: [PATCH] fix to boilerplate, added Core module for Administrator and fixed layout in ControlImage in control.js --- frappe/config/desktop.py | 52 ++++++++++++--------- frappe/core/doctype/doctype/doctype.py | 4 +- frappe/core/page/desktop/desktop.js | 5 +- frappe/middlewares.py | 4 +- frappe/public/css/desk.css | 4 ++ frappe/public/js/frappe/form/control.js | 11 +++-- frappe/public/js/frappe/views/reportview.js | 2 +- frappe/utils/boilerplate.py | 1 + frappe/widgets/search.py | 7 ++- 9 files changed, 55 insertions(+), 35 deletions(-) diff --git a/frappe/config/desktop.py b/frappe/config/desktop.py index deb56d3310..e1b2f7149a 100644 --- a/frappe/config/desktop.py +++ b/frappe/config/desktop.py @@ -2,42 +2,48 @@ from frappe import _ data = { "Calendar": { - "color": "#2980b9", - "icon": "icon-calendar", - "label": _("Calendar"), - "link": "Calendar/Event", + "color": "#2980b9", + "icon": "icon-calendar", + "label": _("Calendar"), + "link": "Calendar/Event", "type": "view" - }, + }, "Messages": { - "color": "#9b59b6", - "icon": "icon-comments", - "label": _("Messages"), - "link": "messages", + "color": "#9b59b6", + "icon": "icon-comments", + "label": _("Messages"), + "link": "messages", "type": "page" - }, + }, "To Do": { - "color": "#f1c40f", - "icon": "icon-check", - "label": _("To Do"), + "color": "#f1c40f", + "icon": "icon-check", + "label": _("To Do"), "link": "List/ToDo", "doctype": "ToDo", "type": "list" - }, + }, "Website": { - "color": "#16a085", - "icon": "icon-globe", + "color": "#16a085", + "icon": "icon-globe", "type": "module" }, "Installer": { - "color": "#888", - "icon": "icon-download", - "link": "applications", + "color": "#888", + "icon": "icon-download", + "link": "applications", "type": "page", "label": _("Installer") }, "Setup": { - "color": "#bdc3c7", - "icon": "icon-wrench", + "color": "#bdc3c7", + "icon": "icon-wrench", "type": "module" - }, -} \ No newline at end of file + }, + "Core": { + "color": "#589494", + "icon": "icon-cog", + "type": "module", + "system_manager": 1 + }, +} diff --git a/frappe/core/doctype/doctype/doctype.py b/frappe/core/doctype/doctype/doctype.py index d8177e5b33..aeeff43c85 100644 --- a/frappe/core/doctype/doctype/doctype.py +++ b/frappe/core/doctype/doctype/doctype.py @@ -10,6 +10,7 @@ import os from frappe.utils import now, cint from frappe.model import no_value_fields from frappe.model.document import Document +from frappe.model.db_schema import type_map class DocType(Document): def validate(self): @@ -198,7 +199,8 @@ def validate_fields(fields): def check_min_items_in_list(fields): if len(filter(lambda d: d.in_list_view, fields))==0: for d in fields[:5]: - d.in_list_view = 1 + if d.fieldtype in type_map: + d.in_list_view = 1 def check_width(d): if d.fieldtype == "Currency" and cint(d.width) < 100: diff --git a/frappe/core/page/desktop/desktop.js b/frappe/core/page/desktop/desktop.js index 411b9c0ce1..78012c9fec 100644 --- a/frappe/core/page/desktop/desktop.js +++ b/frappe/core/page/desktop/desktop.js @@ -73,7 +73,7 @@ frappe.desktop.render = function() { $.each(modules_list, function(i, m) { var module = frappe.modules[m]; if(module) { - if(m!="Setup" && user_list.indexOf(m)!==-1) + if(!in_list(["Setup", "Core"], m) && user_list.indexOf(m)!==-1) add_icon(m); } }) @@ -82,6 +82,9 @@ frappe.desktop.render = function() { if(user_roles.indexOf('System Manager')!=-1) add_icon('Setup') + if(user_roles.indexOf('Administrator')!=-1) + add_icon('Core') + // all applications frappe.modules["All Applications"] = { icon: "icon-th", diff --git a/frappe/middlewares.py b/frappe/middlewares.py index 6d5d61cb0e..cb84326249 100644 --- a/frappe/middlewares.py +++ b/frappe/middlewares.py @@ -1,5 +1,5 @@ # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors -# MIT License. See license.txt +# MIT License. See license.txt from __future__ import unicode_literals @@ -16,7 +16,7 @@ class StaticDataMiddleware(SharedDataMiddleware): def get_directory_loader(self, directory): def loader(path): - site = get_site_name(self.environ.get('HTTP_HOST')) + site = get_site_name(frappe.app._site or self.environ.get('HTTP_HOST')) path = os.path.join(directory, site, 'public', 'files', cstr(path)) if os.path.isfile(path): return os.path.basename(path), self._opener(path) diff --git a/frappe/public/css/desk.css b/frappe/public/css/desk.css index 0ed2b89c01..4668115949 100644 --- a/frappe/public/css/desk.css +++ b/frappe/public/css/desk.css @@ -106,6 +106,10 @@ div#freeze { /*margin-top: -15px;*/ } +.form-control { + padding: 6px 8px; +} + .form-headline { margin-bottom: 10px; font-size: 120%; diff --git a/frappe/public/js/frappe/form/control.js b/frappe/public/js/frappe/form/control.js index 8d0f13ddb2..80a60add10 100644 --- a/frappe/public/js/frappe/form/control.js +++ b/frappe/public/js/frappe/form/control.js @@ -103,14 +103,15 @@ frappe.ui.form.ControlImage = frappe.ui.form.Control.extend({ make: function() { this._super(); var me = this; - this.$wrapper = $("
").appendTo(this.parent); - this.$body = $("
").appendTo(this.$wrapper) - .css({"margin-bottom": "10px", "margin-right": "15px", "float": "right", - "text-align": "right", "max-width": "100%"}) + this.$wrapper = $("
") + .appendTo(this.parent) + .css({"max-width": "600px", "margin": "0px"}); + this.$body = $("
").appendTo(this.$wrapper) + .css({"margin-bottom": "10px", "max-width": "100%"}) this.$wrapper.on("refresh", function() { me.$body.empty(); if(me.df.options && me.frm.doc[me.df.options]) { - me.$img = $("") + me.$img = $("") .appendTo(me.$body); } else { me.$buffer = $("
") diff --git a/frappe/public/js/frappe/views/reportview.js b/frappe/public/js/frappe/views/reportview.js index b1e5bad10b..07960f6bc0 100644 --- a/frappe/public/js/frappe/views/reportview.js +++ b/frappe/public/js/frappe/views/reportview.js @@ -117,7 +117,7 @@ frappe.views.ReportView = frappe.ui.Listing.extend({ if(!columns) { var columns = [['name', this.doctype],]; $.each(frappe.meta.docfield_list[this.doctype], function(i, df) { - if(df.in_filter && df.fieldname!='naming_series' + if((df.in_filter || df.in_list_view) && df.fieldname!='naming_series' && !in_list(frappe.model.no_value_type, df.fieldname)) { columns.push([df.fieldname, df.parent]); } diff --git a/frappe/utils/boilerplate.py b/frappe/utils/boilerplate.py index 519100c08f..035525ec55 100644 --- a/frappe/utils/boilerplate.py +++ b/frappe/utils/boilerplate.py @@ -185,6 +185,7 @@ data = {{ "{app_title}": {{ "color": "{app_color}", "icon": "{app_icon}", + "type": "module", "label": _("{app_title}") }} }} diff --git a/frappe/widgets/search.py b/frappe/widgets/search.py index ba047abc35..9e67c67ae9 100644 --- a/frappe/widgets/search.py +++ b/frappe/widgets/search.py @@ -9,14 +9,14 @@ from frappe.utils import cstr # this is called by the Link Field @frappe.whitelist() -def search_link(doctype, txt, query=None, filters=None, page_len=20, searchfield="name"): +def search_link(doctype, txt, query=None, filters=None, page_len=20, searchfield=None): search_widget(doctype, txt, query, searchfield=searchfield, page_len=page_len, filters=filters) frappe.response['results'] = build_for_autosuggest(frappe.response["values"]) del frappe.response["values"] # this is called by the search box @frappe.whitelist() -def search_widget(doctype, txt, query=None, searchfield="name", start=0, +def search_widget(doctype, txt, query=None, searchfield=None, start=0, page_len=50, filters=None): if isinstance(filters, basestring): import json @@ -24,6 +24,9 @@ def search_widget(doctype, txt, query=None, searchfield="name", start=0, meta = frappe.get_meta(doctype) + if not searchfield: + searchfield = "name" + standard_queries = frappe.get_hooks().standard_queries or [] if standard_queries: standard_queries = dict([v.split(":") for v in standard_queries])