Merge branch 'customer-login'
This commit is contained in:
commit
d76d8d3b7e
16 changed files with 84 additions and 36 deletions
|
|
@ -63,9 +63,9 @@ cur_frm.cscript.refresh = function() {
|
|||
|
||||
if(!cur_frm.doc.doc_type) {
|
||||
var frm_head = cur_frm.frm_head.appframe;
|
||||
$(frm_head.buttons['Update']).attr('disabled', true);
|
||||
$(frm_head.buttons['Refresh Form']).attr('disabled', true);
|
||||
$(frm_head.buttons['Reset to defaults']).attr('disabled', true);
|
||||
$(frm_head.buttons['Update']).prop('disabled', true);
|
||||
$(frm_head.buttons['Refresh Form']).prop('disabled', true);
|
||||
$(frm_head.buttons['Reset to defaults']).prop('disabled', true);
|
||||
}
|
||||
|
||||
cur_frm.cscript.hide_allow_attach(cur_frm.doc);
|
||||
|
|
|
|||
|
|
@ -341,11 +341,11 @@ wn.PermissionEngine = Class.extend({
|
|||
});
|
||||
if(me.get_doctype()) {
|
||||
d.set_value("parent", me.get_doctype());
|
||||
d.get_input("parent").attr("disabled", true);
|
||||
d.get_input("parent").prop("disabled", true);
|
||||
}
|
||||
if(me.get_role()) {
|
||||
d.set_value("role", me.get_role());
|
||||
d.get_input("role").attr("disabled", true);
|
||||
d.get_input("role").prop("disabled", true);
|
||||
}
|
||||
d.set_value("permlevel", "0");
|
||||
d.get_input("add").click(function() {
|
||||
|
|
|
|||
|
|
@ -185,11 +185,11 @@ wn.UserProperties = Class.extend({
|
|||
});
|
||||
if(me.get_user()) {
|
||||
d.set_value("parent", me.get_user());
|
||||
d.get_input("parent").attr("disabled", true);
|
||||
d.get_input("parent").prop("disabled", true);
|
||||
}
|
||||
if(me.get_property()) {
|
||||
d.set_value("defkey", me.get_property());
|
||||
d.get_input("defkey").attr("disabled", true);
|
||||
d.get_input("defkey").prop("disabled", true);
|
||||
}
|
||||
|
||||
d.fields_dict["defvalue"].get_query = function(txt) {
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@
|
|||
{
|
||||
"public/js/all-web.min.js": [
|
||||
"lib/public/js/lib/bootstrap.min.js",
|
||||
"lib/public/js/wn/misc/number_format.js"
|
||||
]
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -231,7 +231,7 @@ wn.dom.set_box_shadow = function(ele, spread) {
|
|||
}
|
||||
$.fn.set_working = function() {
|
||||
var ele = this.get(0);
|
||||
$(ele).attr('disabled', 'disabled');
|
||||
$(ele).prop('disabled', true);
|
||||
if(ele.loading_img) {
|
||||
$(ele.loading_img).toggle(true);
|
||||
} else {
|
||||
|
|
@ -242,7 +242,7 @@ wn.dom.set_box_shadow = function(ele, spread) {
|
|||
}
|
||||
$.fn.done_working = function() {
|
||||
var ele = this.get(0);
|
||||
$(ele).attr('disabled', null);
|
||||
$(ele).prop('disabled', false);
|
||||
if(ele.loading_img) {
|
||||
$(ele.loading_img).toggle(false);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -152,23 +152,23 @@ wn.editors.BootstrapWYSIWYG = Class.extend({
|
|||
|
||||
this.current_editor = this.$editor;
|
||||
this.$parent.find(".btn-html").click(function() {
|
||||
if($(this).attr("disabled")=="disabled") return;
|
||||
if($(this).prop("disabled")==true) return;
|
||||
wn.require("lib/js/lib/beautify-html.js");
|
||||
me.$textarea.val(html_beautify(me.$editor.cleanHtml()));
|
||||
me.$parent.find(".for-rich-text").toggle(false);
|
||||
me.$parent.find(".for-html").toggle(true);
|
||||
me.$parent.find(".btn-html").addClass("btn-info").attr("disabled", "disabled");
|
||||
me.$parent.find(".btn-rich-text").removeClass("btn-info").attr("disabled", false);
|
||||
me.$parent.find(".btn-html").addClass("btn-info").prop("disabled", true);
|
||||
me.$parent.find(".btn-rich-text").removeClass("btn-info").prop("disabled", false);
|
||||
me.current_editor = me.$textarea;
|
||||
});
|
||||
|
||||
this.$parent.find(".btn-rich-text").click(function() {
|
||||
if($(this).attr("disabled")=="disabled") return;
|
||||
if($(this).prop("disabled")==true) return;
|
||||
me.$editor.html(me.$textarea.val());
|
||||
me.$parent.find(".for-rich-text").toggle(true);
|
||||
me.$parent.find(".for-html").toggle(false);
|
||||
me.$parent.find(".btn-html").removeClass("btn-info").attr("disabled", false);
|
||||
me.$parent.find(".btn-rich-text").addClass("btn-info").attr("disabled", "disabled");
|
||||
me.$parent.find(".btn-html").removeClass("btn-info").prop("disabled", false);
|
||||
me.$parent.find(".btn-rich-text").addClass("btn-info").prop("disabled", true);
|
||||
me.current_editor = me.$editor;
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ wn.ui.form.States = Class.extend({
|
|||
this.show_actions(state);
|
||||
|
||||
if(this.frm.doc.__islocal) {
|
||||
this.workflow_button.attr('disabled', true);
|
||||
this.workflow_button.prop('disabled', true);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
@ -119,7 +119,7 @@ wn.ui.form.States = Class.extend({
|
|||
// disable the button if user cannot change state
|
||||
var is_final = !$ul.find("li").length;
|
||||
this.workflow_button
|
||||
.attr('disabled', is_final);
|
||||
.prop('disabled', is_final);
|
||||
this.workflow_button.find(".caret").toggle(is_final ? false : true)
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
|
||||
// MIT License. See license.txt
|
||||
|
||||
if(!window.wn) wn = {};
|
||||
|
||||
function flt(v, decimals, number_format) {
|
||||
if(v==null || v=='')return 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ wn.utils = {
|
|||
},
|
||||
disable_export_btn: function(btn) {
|
||||
if(!wn.user.is_report_manager()) {
|
||||
btn.attr("disabled", "disabled").attr("title",
|
||||
btn.prop("disabled", true).attr("title",
|
||||
wn._("Can only be exported by users with role 'Report Manager'"));
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -104,13 +104,13 @@ wn.model.DocList = Class.extend({
|
|||
// callback: callback,
|
||||
// btn: btn
|
||||
// }
|
||||
$(opts.btn).attr("disabled", true);
|
||||
$(opts.btn).prop("disabled", true);
|
||||
return wn.call({
|
||||
freeze: true,
|
||||
method: opts.method,
|
||||
args: opts.args,
|
||||
callback: function(r) {
|
||||
$(opts.btn).attr("disabled", false);
|
||||
$(opts.btn).prop("disabled", false);
|
||||
opts.callback && opts.callback(r);
|
||||
}
|
||||
})
|
||||
|
|
|
|||
|
|
@ -288,7 +288,8 @@ wn.views.CommunicationComposer = Class.extend({
|
|||
? cur_frm.communication_view.list
|
||||
: [];
|
||||
var signature = wn.boot.profile.email_signature || "";
|
||||
|
||||
var portal_link = this.setup_portal_link();
|
||||
|
||||
if(!wn.utils.is_html(signature)) {
|
||||
signature = signature.replace(/\n/g, "<br>");
|
||||
}
|
||||
|
|
@ -297,18 +298,44 @@ wn.views.CommunicationComposer = Class.extend({
|
|||
this.message = '<p>'+wn._('Dear') +' ' + this.real_name + ",</p>" + (this.message || "");
|
||||
}
|
||||
|
||||
var reply = (this.message || "")
|
||||
+ "<p></p>" + signature
|
||||
+ "<p></p>" + portal_link;
|
||||
|
||||
if(comm_list.length > 0) {
|
||||
fields.content.set_input((this.message || "") +
|
||||
"<p></p>"
|
||||
+ signature
|
||||
+"<p></p>"
|
||||
fields.content.set_input(reply
|
||||
+ "<p></p>"
|
||||
+"-----"+wn._("In response to")+"-----<p></p>"
|
||||
+ comm_list[0].content);
|
||||
} else {
|
||||
fields.content.set_input((this.message || "")
|
||||
+ "<p></p>" + signature)
|
||||
fields.content.set_input(reply);
|
||||
}
|
||||
},
|
||||
setup_portal_link: function() {
|
||||
var me = this;
|
||||
var portal_link = "";
|
||||
var show_portal_link = wn.boot.portal_links[this.doc.doctype] &&
|
||||
!(wn.boot.website_settings && cint(wn.boot.website_settings.disable_signup));
|
||||
if(show_portal_link) {
|
||||
var portal_args = wn.boot.portal_links[this.doc.doctype];
|
||||
var valid = true;
|
||||
if(portal_args.conditions) {
|
||||
$.each(portal_args.conditions, function(k, v) {
|
||||
if(me.doc[k] !== v) valid = false;
|
||||
});
|
||||
}
|
||||
if(valid) {
|
||||
// set portal link
|
||||
portal_link = repl("%(location)s/%(page)s?name=%(name)s", {
|
||||
location: window.location.origin,
|
||||
page: portal_args["page"],
|
||||
name: encodeURIComponent(this.doc.name)
|
||||
});
|
||||
portal_link = '--<br><a href="'+portal_link+'" target="_blank">View this on our website</a>';
|
||||
}
|
||||
}
|
||||
return portal_link;
|
||||
},
|
||||
setup_autosuggest: function() {
|
||||
var me = this;
|
||||
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ wn.views.QueryReport = Class.extend({
|
|||
}, "icon-edit");
|
||||
|
||||
if(!in_list(user_roles, "System Manager")) {
|
||||
edit_btn.attr("disabled", "disabled")
|
||||
edit_btn.prop("disabled", true)
|
||||
.attr("title", wn._("Only System Manager can create / edit reports"));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ login.do_login = function(){
|
|||
}
|
||||
}
|
||||
|
||||
$('#login_btn').attr("disabled", "disabled");
|
||||
$('#login_btn').prop("disabled", true);
|
||||
$("#login-spinner").toggle(true);
|
||||
$('#login_message').toggle(false);
|
||||
|
||||
|
|
@ -57,13 +57,14 @@ login.do_login = function(){
|
|||
dataType: "json",
|
||||
success: function(data) {
|
||||
$("#login-spinner").toggle(false);
|
||||
$('#login_btn').attr("disabled", false);
|
||||
$('#login_btn').prop("disabled", false);
|
||||
if(data.message=="Logged In") {
|
||||
window.location.href = "app.html";
|
||||
} else if(data.message=="No App") {
|
||||
if(localStorage) {
|
||||
window.location.href = localStorage.getItem("last_visited") || "index";
|
||||
var last_visited = localStorage.getItem("last_visited") || "index";
|
||||
localStorage.removeItem("last_visited");
|
||||
window.location.href = last_visited;
|
||||
} else {
|
||||
window.location.href = "index";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import webnotes.defaults
|
|||
import webnotes.model.doc
|
||||
import webnotes.widgets.page
|
||||
import json
|
||||
import webnotes.webutils
|
||||
|
||||
def get_bootinfo():
|
||||
"""build and return boot info"""
|
||||
|
|
@ -42,6 +43,9 @@ def get_bootinfo():
|
|||
tabDocType where ifnull(icon,'')!=''"""))
|
||||
bootinfo.doctype_icons.update(dict(webnotes.conn.sql("""select name, icon from
|
||||
tabPage where ifnull(icon,'')!=''""")))
|
||||
|
||||
# portal links for sending in email
|
||||
bootinfo.portal_links = webnotes.webutils.get_portal_links()
|
||||
|
||||
add_home_page(bootinfo, doclist)
|
||||
add_allowed_pages(bootinfo)
|
||||
|
|
|
|||
|
|
@ -664,6 +664,14 @@ def unesc(s, esc_chars):
|
|||
s = s.replace(esc_str, c)
|
||||
return s
|
||||
|
||||
def is_html(text):
|
||||
out = False
|
||||
for key in ["<br>", "<p", "<img", "<div"]:
|
||||
if key in text:
|
||||
out = True
|
||||
break
|
||||
return out
|
||||
|
||||
def strip_html(text):
|
||||
"""
|
||||
removes anything enclosed in and including <>
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import os
|
||||
import conf
|
||||
import webnotes
|
||||
import webnotes.utils
|
||||
|
|
@ -113,9 +112,6 @@ def build_html(args):
|
|||
|
||||
return html
|
||||
|
||||
def get_standard_pages():
|
||||
return webnotes.get_config()["web"]["pages"].keys()
|
||||
|
||||
def prepare_args(page_name):
|
||||
|
||||
has_app = True
|
||||
|
|
@ -239,4 +235,13 @@ def get_generators():
|
|||
def get_page_settings():
|
||||
return webnotes.get_config()["web"]["pages"]
|
||||
|
||||
|
||||
def get_portal_links():
|
||||
portal_args = {}
|
||||
for page, opts in webnotes.get_config()["web"]["pages"].items():
|
||||
if opts.get("portal"):
|
||||
portal_args[opts["portal"]["doctype"]] = {
|
||||
"page": page,
|
||||
"conditions": opts["portal"].get("conditions")
|
||||
}
|
||||
|
||||
return portal_args
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue