From 3ef7d5ba78d2ff24ec9f6f2404d2c87a70dd1851 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Sat, 25 Jun 2016 18:00:38 +0530 Subject: [PATCH] [minor] make route only if published --- frappe/public/js/frappe/form/footer/attachments.js | 6 ++++-- frappe/public/js/frappe/ui/dialog.js | 1 + frappe/website/website_generator.py | 7 ++++--- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/frappe/public/js/frappe/form/footer/attachments.js b/frappe/public/js/frappe/form/footer/attachments.js index 0fddbeda21..9aeabaad22 100644 --- a/frappe/public/js/frappe/form/footer/attachments.js +++ b/frappe/public/js/frappe/form/footer/attachments.js @@ -209,9 +209,10 @@ frappe.ui.form.Attachments = Class.extend({ frappe.ui.get_upload_dialog = function(opts){ dialog = new frappe.ui.Dialog({ title: __('Upload Attachment'), + no_focus: true, fields: [ {fieldtype: "Section Break"}, - {"fieldtype": "Link" , "fieldname": "file" , "label": "File", "options": "File"}, + {"fieldtype": "Link" , "fieldname": "file" , "label": __("Select uploaded file"), "options": "File"}, ], }); @@ -219,6 +220,7 @@ frappe.ui.get_upload_dialog = function(opts){ btn.removeClass("btn-primary").addClass("btn-default"); dialog.show(); + var upload_area = $('
').prependTo(dialog.body); var fd = dialog.fields_dict; $(fd.file.input).change(function() { @@ -237,7 +239,7 @@ frappe.ui.get_upload_dialog = function(opts){ }); }); frappe.upload.make({ - parent: dialog.body, + parent: upload_area, args: opts.args, callback: function(attachment, r) { dialog.hide(); diff --git a/frappe/public/js/frappe/ui/dialog.js b/frappe/public/js/frappe/ui/dialog.js index 7bb2fbfb01..3c381f1f25 100644 --- a/frappe/public/js/frappe/ui/dialog.js +++ b/frappe/public/js/frappe/ui/dialog.js @@ -67,6 +67,7 @@ frappe.ui.Dialog = frappe.ui.FieldGroup.extend({ }, focus_on_first_input: function() { + if(this.no_focus) return; $.each(this.fields_list, function(i, f) { if(!in_list(['Date', 'Datetime', 'Time'], f.df.fieldtype) && f.set_focus) { f.set_focus(); diff --git a/frappe/website/website_generator.py b/frappe/website/website_generator.py index 775eb36153..5aa26a04c5 100644 --- a/frappe/website/website_generator.py +++ b/frappe/website/website_generator.py @@ -23,11 +23,11 @@ class WebsiteGenerator(Document): def onload(self): self.get("__onload").update({ "is_website_generator": True, - "published": self.website_published() + "published": self.is_website_published() }) def validate(self): - if not self.route: + if self.is_website_published() and not self.route: self.route = self.make_route() self.route = self.route.strip('/.') @@ -53,7 +53,8 @@ class WebsiteGenerator(Document): def on_trash(self): self.clear_cache() - def website_published(self): + def is_website_published(self): + """Return true if published in website""" if self.website.condition_field: return self.get(self.website.condition_field) and True or False else: