From cdfcf10e089e48f8b653f1456882ae3d1b49025e Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Tue, 8 Aug 2017 11:42:01 +0530 Subject: [PATCH] [fixes] bunch of ui fixes --- frappe/build.js | 26 +++++++++++-------- frappe/desk/doctype/note/note.js | 6 ++--- frappe/public/css/email.css | 2 +- frappe/public/css/list.css | 19 ++++++++++++++ frappe/public/js/frappe/desk.js | 2 +- .../public/js/frappe/form/footer/timeline.js | 1 + frappe/public/js/frappe/ui/base_list.js | 18 ++++++++++--- frappe/public/js/frappe/ui/page.js | 7 ++++- .../public/js/frappe/views/communication.js | 11 ++++---- frappe/public/less/email.less | 2 +- frappe/public/less/list.less | 23 ++++++++++++++-- frappe/www/desk.html | 4 +-- frappe/www/desk.py | 10 +++---- frappe/www/login.html | 8 +++--- package.json | 3 ++- 15 files changed, 100 insertions(+), 42 deletions(-) diff --git a/frappe/build.js b/frappe/build.js index 707708236b..45ab9bc9cf 100644 --- a/frappe/build.js +++ b/frappe/build.js @@ -10,6 +10,7 @@ const path_join = path.resolve; const app = require('express')(); const http = require('http').Server(app); const io = require('socket.io')(http); +const touch = require("touch"); // basic setup const sites_path = path_join(__dirname, '..', '..', '..', 'sites'); @@ -42,6 +43,7 @@ function build(minify) { for (const output_path in build_map) { pack(output_path, build_map[output_path], minify); } + touch(path_join(sites_path, '.build'), {force:true}); } let socket_connection = false; @@ -228,7 +230,7 @@ function watch_less(ondirty) { const less_paths = app_paths.map(path => path_join(path, 'public', 'less')); const to_watch = filter_valid_paths(less_paths); - chokidar.watch(to_watch).on('change', (filename, stats) => { + chokidar.watch(to_watch).on('change', (filename) => { console.log(filename, 'dirty'); var last_index = filename.lastIndexOf('/'); const less_path = filename.slice(0, last_index); @@ -236,17 +238,18 @@ function watch_less(ondirty) { filename = filename.split('/').pop(); compile_less_file(filename, less_path, public_path) - .then(css_file_path => { - // build the target css file for which this css file is input - for (const target in build_map) { - const sources = build_map[target]; - if (sources.includes(css_file_path)) { - pack(target, sources); - ondirty && ondirty(target); - break; + .then(css_file_path => { + // build the target css file for which this css file is input + for (const target in build_map) { + const sources = build_map[target]; + if (sources.includes(css_file_path)) { + pack(target, sources); + ondirty && ondirty(target); + break; + } } - } - }) + }); + touch(path_join(sites_path, '.build'), {force:true}); }); } @@ -265,6 +268,7 @@ function watch_js(ondirty) { // break; } } + touch(path_join(sites_path, '.build'), {force:true}); }); } diff --git a/frappe/desk/doctype/note/note.js b/frappe/desk/doctype/note/note.js index d905b7ad27..c237998ccf 100644 --- a/frappe/desk/doctype/note/note.js +++ b/frappe/desk/doctype/note/note.js @@ -10,7 +10,7 @@ frappe.ui.form.on("Note", { // toggle edit frm.add_custom_button("Edit", function() { frm.events.set_editable(frm, !frm.is_note_editable); - }) + }); frm.events.set_editable(frm, false); } }, @@ -24,12 +24,12 @@ frappe.ui.form.on("Note", { frm.set_df_property("content", "read_only", editable ? 0: 1); // hide all other fields - $.each(frm.fields_dict, function(fieldname, field) { + $.each(frm.fields_dict, function(fieldname) { if(fieldname !== "content") { frm.set_df_property(fieldname, "hidden", editable ? 0: 1); } - }) + }); // no label, description for content either frm.get_field("content").toggle_label(editable); diff --git a/frappe/public/css/email.css b/frappe/public/css/email.css index 4e9dfbaa6e..ccedde274d 100644 --- a/frappe/public/css/email.css +++ b/frappe/public/css/email.css @@ -49,7 +49,7 @@ hr { border-top: none; } .email-footer-container { - margin-top: 10px; + margin-top: 30px; } .email-footer-container > div:not(:last-child) { margin-bottom: 5px; diff --git a/frappe/public/css/list.css b/frappe/public/css/list.css index 05cb1d07b6..49ecce16de 100644 --- a/frappe/public/css/list.css +++ b/frappe/public/css/list.css @@ -183,6 +183,25 @@ .listview-main-section .octicon-heart { cursor: pointer; } +.listview-main-section .page-form { + padding-left: 17px; +} +@media (max-width: 991px) { + .listview-main-section .page-form { + padding-left: 25px; + } +} +.listview-main-section .page-form .octicon-search { + float: left; + padding-top: 7px; + margin-left: -4px; + margin-right: -4px; +} +@media (max-width: 991px) { + .listview-main-section .page-form .octicon-search { + margin-left: -12px; + } +} .like-action.octicon-heart { color: #ff5858; } diff --git a/frappe/public/js/frappe/desk.js b/frappe/public/js/frappe/desk.js index 820796e0d9..308dae4357 100644 --- a/frappe/public/js/frappe/desk.js +++ b/frappe/public/js/frappe/desk.js @@ -486,7 +486,7 @@ frappe.Application = Class.extend({ return; } window.onbeforeunload = function () { - if (frappe.flags.in_test) return false; + if (frappe.flags.in_test) return null; var unsaved_docs = []; for (doctype in locals) { for (name in locals[doctype]) { diff --git a/frappe/public/js/frappe/form/footer/timeline.js b/frappe/public/js/frappe/form/footer/timeline.js index 2937d4f9e7..2652f36079 100644 --- a/frappe/public/js/frappe/form/footer/timeline.js +++ b/frappe/public/js/frappe/form/footer/timeline.js @@ -233,6 +233,7 @@ frappe.ui.form.Timeline = Class.extend({ new frappe.views.CommunicationComposer({ doc: me.frm.doc, txt: "", + subject: __('Reply'), frm: me.frm, last_email: last_email }); diff --git a/frappe/public/js/frappe/ui/base_list.js b/frappe/public/js/frappe/ui/base_list.js index f320be9699..13a54a104f 100644 --- a/frappe/public/js/frappe/ui/base_list.js +++ b/frappe/public/js/frappe/ui/base_list.js @@ -185,6 +185,9 @@ frappe.ui.BaseList = Class.extend({ } if (this.meta) { + var filter_count = 1; + $(``) + .appendTo(this.page.page_form); this.page.add_field({ fieldtype: 'Data', label: 'ID', @@ -193,14 +196,14 @@ frappe.ui.BaseList = Class.extend({ onchange: () => { me.refresh(true); } }); - this.meta.fields.forEach(function(df) { + this.meta.fields.forEach(function(df, i) { if(df.in_standard_filter && !frappe.model.no_value_type.includes(df.fieldtype)) { let options = df.options; let condition = '='; let fieldtype = df.fieldtype; if (['Text', 'Small Text', 'Text Editor', 'Data'].includes(fieldtype)) { - fieldtype = 'Data', - condition = 'like' + fieldtype = 'Data'; + condition = 'like'; } if(df.fieldtype == "Select" && df.options) { options = df.options.split("\n"); @@ -209,7 +212,7 @@ frappe.ui.BaseList = Class.extend({ options = options.join("\n"); } } - me.page.add_field({ + let f = me.page.add_field({ fieldtype: fieldtype, label: __(df.label), options: options, @@ -217,6 +220,13 @@ frappe.ui.BaseList = Class.extend({ condition: condition, onchange: () => {me.refresh(true);} }); + filter_count ++; + if (filter_count > 3) { + $(f.wrapper).addClass('hidden-sm').addClass('hidden-xs'); + } + if (filter_count > 5) { + return false; + } } }); } diff --git a/frappe/public/js/frappe/ui/page.js b/frappe/public/js/frappe/ui/page.js index 6ed3037e4b..7844c1ee89 100644 --- a/frappe/public/js/frappe/ui/page.js +++ b/frappe/public/js/frappe/ui/page.js @@ -400,8 +400,13 @@ frappe.ui.Page = Class.extend({ .addClass('col-md-2') .attr("title", __(df.label)).tooltip(); + // html fields in toolbar are only for display + if (df.fieldtype=='HTML') { + return; + } + // hidden fields dont have $input - if(!f.$input) f.make_input(); + if (!f.$input) f.make_input(); f.$input.addClass("input-sm").attr("placeholder", __(df.label)); diff --git a/frappe/public/js/frappe/views/communication.js b/frappe/public/js/frappe/views/communication.js index 8c6d5ce4fd..aa3cc726a0 100755 --- a/frappe/public/js/frappe/views/communication.js +++ b/frappe/public/js/frappe/views/communication.js @@ -12,7 +12,7 @@ frappe.views.CommunicationComposer = Class.extend({ make: function() { var me = this; this.dialog = new frappe.ui.Dialog({ - title: (this.subject || ""), + title: (this.subject || __("New Email")), no_submit_on_enter: true, fields: this.get_fields(), primary_action_label: __("Send"), @@ -444,6 +444,7 @@ frappe.views.CommunicationComposer = Class.extend({ send_email: function(btn, form_values, selected_attachments, print_html, print_format) { var me = this; + me.dialog.hide(); if((form_values.send_email || form_values.communication_medium === "Email") && !form_values.recipients) { frappe.msgprint(__("Enter Email Recipient(s)")); @@ -496,8 +497,6 @@ frappe.views.CommunicationComposer = Class.extend({ [ frappe.utils.escape_html(r.message["emails_not_sent_to"]) ]) ); } - me.dialog.hide(); - if ((frappe.last_edited_communication[me.doc] || {})[me.key]) { delete frappe.last_edited_communication[me.doc][me.key]; } @@ -506,7 +505,7 @@ frappe.views.CommunicationComposer = Class.extend({ cur_frm.timeline.input.val(""); cur_frm.reload_doc(); } - + // try the success callback if it exists if (me.success) { try { @@ -515,10 +514,10 @@ frappe.views.CommunicationComposer = Class.extend({ console.log(e); } } - + } else { frappe.msgprint(__("There were errors while sending email. Please try again.")); - + // try the error callback if it exists if (me.error) { try { diff --git a/frappe/public/less/email.less b/frappe/public/less/email.less index f07107891a..b7f9ee90fc 100644 --- a/frappe/public/less/email.less +++ b/frappe/public/less/email.less @@ -64,7 +64,7 @@ hr { } .email-footer-container { - margin-top: 10px; + margin-top: 30px; & > div:not(:last-child) { margin-bottom: 5px; diff --git a/frappe/public/less/list.less b/frappe/public/less/list.less index 517c6e4059..d14a533ea9 100644 --- a/frappe/public/less/list.less +++ b/frappe/public/less/list.less @@ -226,8 +226,27 @@ padding: 5px 15px; } -.listview-main-section .octicon-heart { - cursor: pointer; +.listview-main-section { + .octicon-heart { + cursor: pointer; + } + .page-form { + padding-left: 17px; + + @media (max-width: @screen-sm) { + padding-left: 25px; + } + + .octicon-search { + float: left; + padding-top: 7px; + margin-left: -4px; + margin-right: -4px; + @media (max-width: @screen-sm) { + margin-left: -12px; + } + } + } } .like-action.octicon-heart { diff --git a/frappe/www/desk.html b/frappe/www/desk.html index e95739be55..841b82bf99 100644 --- a/frappe/www/desk.html +++ b/frappe/www/desk.html @@ -20,7 +20,7 @@ {% for include in include_css -%} - + {%- endfor -%} @@ -55,7 +55,7 @@ {% for include in include_js %} - + {% endfor %} {% include "templates/includes/app_analytics/google_analytics.html" %} {% include "templates/includes/app_analytics/mixpanel_analytics.html" %} diff --git a/frappe/www/desk.py b/frappe/www/desk.py index ccc9577b34..7dbaaf41c6 100644 --- a/frappe/www/desk.py +++ b/frappe/www/desk.py @@ -35,7 +35,8 @@ def get_context(context): # remove script tags from boot boot_json = re.sub("\[^<]*\", "", boot_json) - return { + context.update({ + "no_cache": 1, "build_version": get_build_version(), "include_js": hooks["app_include_js"], "include_css": hooks["app_include_css"], @@ -46,7 +47,7 @@ def get_context(context): (boot.user.background_image or boot.default_background_image) or None), "google_analytics_id": frappe.conf.get("google_analytics_id"), "mixpanel_id": frappe.conf.get("mixpanel_id") - } + }) @frappe.whitelist() def get_desk_assets(build_version): @@ -64,7 +65,7 @@ def get_desk_assets(build_version): try: with open(os.path.join(frappe.local.sites_path, path) ,"r") as f: assets[0]["data"] = assets[0]["data"] + "\n" + text_type(f.read(), "utf-8") - except IOError as e: + except IOError: pass for path in data["include_css"]: @@ -78,5 +79,4 @@ def get_desk_assets(build_version): } def get_build_version(): - return str(os.path.getmtime(os.path.join(frappe.local.sites_path, "assets", "js", - "desk.min.js"))) + return str(os.path.getmtime(os.path.join(frappe.local.sites_path, '.build'))) diff --git a/frappe/www/login.html b/frappe/www/login.html index e95f0fe63b..912d65ad8e 100644 --- a/frappe/www/login.html +++ b/frappe/www/login.html @@ -9,16 +9,16 @@ {% block page_content %}
-