[minor] removed the email inbox selector, deleted user from locals on create email account
This commit is contained in:
parent
d1857015db
commit
c8db0b292c
9 changed files with 63 additions and 103 deletions
|
|
@ -3,6 +3,16 @@ from frappe import _
|
|||
|
||||
def get_data():
|
||||
return [
|
||||
{
|
||||
"module_name": 'Communication',
|
||||
"label": _('Email Inbox'),
|
||||
"_label": _('Email Inbox'),
|
||||
"_id": 'Email Inbox',
|
||||
"_doctype": 'Communication',
|
||||
"icon": 'fa fa-envelope-o',
|
||||
"color": '#589494',
|
||||
"link": 'List/Communication/Inbox'
|
||||
},
|
||||
{
|
||||
"module_name": "Desk",
|
||||
"label": _("Tools"),
|
||||
|
|
|
|||
|
|
@ -84,7 +84,9 @@ frappe.ui.form.on('User', {
|
|||
}
|
||||
}
|
||||
if (!found){
|
||||
frm.add_custom_button("Create User Email",frm.events.create_user_email)
|
||||
frm.add_custom_button("Create User Email", function() {
|
||||
frm.events.create_user_email(frm)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -113,25 +115,29 @@ frappe.ui.form.on('User', {
|
|||
frm.toggle_enable('email', doc.__islocal);
|
||||
}
|
||||
},
|
||||
|
||||
create_user_email:function(frm) {
|
||||
frappe.call({
|
||||
method: 'frappe.core.doctype.user.user.has_email_account',
|
||||
args: {email:cur_frm.doc.email},
|
||||
args: {
|
||||
email: frm.doc.email
|
||||
},
|
||||
callback: function(r) {
|
||||
if (r["message"]== undefined){
|
||||
if (r.message == undefined) {
|
||||
frappe.route_options = {
|
||||
"email_id": cur_frm.doc.email,
|
||||
"awaiting_password":1,
|
||||
"enable_incoming":1
|
||||
"email_id": frm.doc.email,
|
||||
"awaiting_password": 1,
|
||||
"enable_incoming": 1
|
||||
};
|
||||
frappe.model.with_doctype("Email Account", function (doc) {
|
||||
var doc = frappe.model.get_new_doc("Email Account");
|
||||
frappe.route_flags.create_user_account=cur_frm.doc.name;
|
||||
frappe.set_route("Form", "Email Account", doc.name);
|
||||
frappe.route_flags.linked_user = frm.doc.name;
|
||||
frappe.route_flags.delete_user_from_locals = true;
|
||||
frappe.set_route("Form", "Email Account", doc.name);
|
||||
})
|
||||
}else{
|
||||
frappe.route_flags.create_user_account=cur_frm.doc.name;
|
||||
frappe.set_route("Form", "Email Account", r["message"][0]["name"]);
|
||||
} else {
|
||||
frappe.route_flags.create_user_account = frm.doc.name;
|
||||
frappe.set_route("Form", "Email Account", r.message[0]["name"]);
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
|
|||
|
|
@ -45,21 +45,6 @@ $.extend(frappe.desktop, {
|
|||
explore_icon.app_icon = frappe.ui.app_icon.get_html(explore_icon);
|
||||
all_icons.push(explore_icon);
|
||||
|
||||
if(frappe.boot.email_accounts.length && frappe.model.can_read("Communication")) {
|
||||
var inbox_icon = {
|
||||
module_name: 'Communication',
|
||||
label: 'Email Inbox',
|
||||
_label: __('Email Inbox'),
|
||||
_id: 'Email Inbox',
|
||||
_doctype: 'Communication',
|
||||
icon: 'fa fa-envelope-o',
|
||||
color: '#589494',
|
||||
link: 'List/Communication/Inbox'
|
||||
}
|
||||
inbox_icon.app_icon = frappe.ui.app_icon.get_html(inbox_icon)
|
||||
all_icons.push(inbox_icon);
|
||||
}
|
||||
|
||||
frappe.desktop.wrapper.html(frappe.render_template(template, {
|
||||
// all visible icons
|
||||
desktop_items: all_icons,
|
||||
|
|
|
|||
|
|
@ -109,6 +109,11 @@ frappe.ui.form.on("Email Account", {
|
|||
frm.events.enable_incoming(frm);
|
||||
frm.events.notify_if_unreplied(frm);
|
||||
frm.events.show_gmail_message_for_less_secure_apps(frm);
|
||||
|
||||
if(frappe.route_flags.delete_user_from_locals && frappe.route_flags.linked_user) {
|
||||
delete frappe.route_flags.delete_user_from_locals
|
||||
delete locals['User'][frappe.route_flags.linked_user]
|
||||
}
|
||||
},
|
||||
|
||||
show_gmail_message_for_less_secure_apps: function(frm) {
|
||||
|
|
@ -125,8 +130,9 @@ frappe.ui.form.on("Email Account", {
|
|||
},
|
||||
|
||||
update_domain: function(frm){
|
||||
if (!frm.doc.email_id && !frm.doc.service)
|
||||
if (!frm.doc.email_id && !frm.doc.service){
|
||||
return
|
||||
}
|
||||
|
||||
frappe.call({
|
||||
method: 'get_domain',
|
||||
|
|
@ -155,11 +161,13 @@ frappe.ui.form.on("Email Account", {
|
|||
},
|
||||
|
||||
set_domain_fields: function(frm, args) {
|
||||
if(!args)
|
||||
if(!args){
|
||||
args = frappe.route_flags.set_domain_values? frappe.route_options: {}
|
||||
}
|
||||
|
||||
for(field in args)
|
||||
for(field in args) {
|
||||
frm.set_value(field, args[field]);
|
||||
}
|
||||
|
||||
delete frappe.route_flags.set_domain_values
|
||||
frappe.route_options = {}
|
||||
|
|
|
|||
|
|
@ -255,7 +255,6 @@
|
|||
"public/js/frappe/views/image/photoswipe_dom.html",
|
||||
|
||||
"public/js/frappe/views/inbox/inbox_no_result.html",
|
||||
"public/js/frappe/views/inbox/select_email_inbox.html",
|
||||
"public/js/frappe/views/inbox/inbox_view_item_row.html",
|
||||
"public/js/frappe/views/inbox/inbox_view_item_main_head.html",
|
||||
|
||||
|
|
|
|||
|
|
@ -239,8 +239,9 @@ frappe.views.ListView = frappe.ui.BaseList.extend({
|
|||
route.push(us['Kanban'].last_kanban_board);
|
||||
}
|
||||
|
||||
if (us.last_view === 'Inbox')
|
||||
if (us.last_view === 'Inbox') {
|
||||
route.push(us['Inbox'].last_email_account)
|
||||
}
|
||||
} else {
|
||||
route.push('List');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,14 @@
|
|||
<div class="msg-box no-border">
|
||||
{% if(!frappe.model.can_create(doctype) && doctype == "Email Account") { %}
|
||||
<p>Email Account is not assigned, Please contact System Manager</p>
|
||||
{% } else { %}
|
||||
<p>{{ __("No {} found", [doctype]) }}</p>
|
||||
<p>
|
||||
<button class="btn btn-primary btn-sm btn-no-result" list_view_doc="{{ doctype }}">
|
||||
{{__(label) }}
|
||||
</button>
|
||||
</p>
|
||||
{% } %}
|
||||
<div class="no-result">
|
||||
<div class="msg-box no-border">
|
||||
{% if(!frappe.model.can_create(doctype) && doctype == "Email Account") { %}
|
||||
<p>{{ __("No Email Accounts Assigned") }}</p>
|
||||
{% } else { %}
|
||||
<p>{{ msg }}</p>
|
||||
<p>
|
||||
<button class="btn btn-primary btn-sm btn-no-result" list_view_doc="{{ doctype }}">
|
||||
{{ label }}
|
||||
</button>
|
||||
</p>
|
||||
{% } %}
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -24,15 +24,12 @@ frappe.views.InboxView = frappe.views.ListRenderer.extend({
|
|||
if(email_account)
|
||||
html = this.emails.map(this.render_email_row.bind(this)).join("");
|
||||
else
|
||||
html = this.get_inbox_selector_html()
|
||||
html = this.make_no_result()
|
||||
|
||||
this.container = $('<div>')
|
||||
.addClass('inbox-container')
|
||||
.appendTo(this.wrapper);
|
||||
this.container.append(html);
|
||||
|
||||
if(!this.current_email_account)
|
||||
this.bind_email_inbox_selector()
|
||||
},
|
||||
render_email_row: function(email) {
|
||||
if(!email.css_seen && email.seen)
|
||||
|
|
@ -112,9 +109,11 @@ frappe.views.InboxView = frappe.views.ListRenderer.extend({
|
|||
},
|
||||
get_current_email_account: function() {
|
||||
var route = frappe.get_route();
|
||||
if(!route[3] || !frappe.boot.email_accounts.find(b => b.email_account === route[3])) {
|
||||
if(!route[3] && frappe.boot.email_accounts.length) {
|
||||
frappe.set_route("List", "Communication", "Inbox", frappe.boot.email_accounts[0].email_account);
|
||||
} else if(route[3] && !frappe.boot.email_accounts.find(b => b.email_account === route[3])) {
|
||||
// frappe.throw(__(`Email Account <b>${route[3] || ''}</b> not found`));
|
||||
return "";
|
||||
return ''
|
||||
}
|
||||
return route[3];
|
||||
},
|
||||
|
|
@ -128,51 +127,28 @@ frappe.views.InboxView = frappe.views.ListRenderer.extend({
|
|||
this.no_result_doctype = "Email Account"
|
||||
args = {
|
||||
doctype: "Email Account",
|
||||
label: "New Email Account",
|
||||
msg: __("No Email Account"),
|
||||
label: __("New Email Account"),
|
||||
}
|
||||
} else {
|
||||
// no sent mail
|
||||
this.no_result_doctype = "Communication";
|
||||
args = {
|
||||
doctype: "Communication",
|
||||
label: "Compose Email"
|
||||
msg: __("No Emails"),
|
||||
label: __("Compose Email")
|
||||
}
|
||||
}
|
||||
var no_result_message = frappe.render_template("inbox_no_result", args)
|
||||
return no_result_message;
|
||||
},
|
||||
|
||||
get_inbox_selector_html: function() {
|
||||
email_account_map = {}
|
||||
$.each(frappe.boot.email_accounts, function(idx, account){
|
||||
email_account_map[account.email_id] = account.email_account
|
||||
});
|
||||
html = frappe.render_template("select_email_inbox", {
|
||||
email_accounts: email_account_map,
|
||||
is_inbox_configured: Object.keys(email_account_map).length
|
||||
})
|
||||
|
||||
if(!Object.keys(email_account_map).length)
|
||||
this.no_result_doctype = "Email Account"
|
||||
|
||||
return html
|
||||
},
|
||||
|
||||
bind_email_inbox_selector: function() {
|
||||
// bind email_account on_change event
|
||||
var me = this;
|
||||
this.container.find('select[data-fieldname="email_inbox"]').on("change", function(event) {
|
||||
inbox = $(event.target).val();
|
||||
frappe.set_route("List", "Communication", "Inbox", inbox)
|
||||
})
|
||||
},
|
||||
|
||||
make_new_doc: function() {
|
||||
if (this.no_result_doctype == "Communication") {
|
||||
new frappe.views.CommunicationComposer({
|
||||
doc: {}
|
||||
})
|
||||
} else {
|
||||
frappe.route_options = { 'email_id': user_email }
|
||||
frappe.new_doc(this.no_result_doctype)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,27 +0,0 @@
|
|||
<div class="no-result">
|
||||
{% if(is_inbox_configured) { %}
|
||||
<div class="select-inbox no-border">
|
||||
<div class="form-group">
|
||||
<div class="clearfix">
|
||||
<label class="control-label" style="padding-right: 0px;">Email Inbox</label>
|
||||
</div>
|
||||
<div class="control-input-wrapper">
|
||||
<div class="control-input">
|
||||
<select type="text" autocomplete="off" class="input-with-feedback form-control bold" maxlength="140" data-fieldtype="Select" data-fieldname="email_inbox" placeholder="">
|
||||
<option value=""></option>
|
||||
{% for(var email_id in email_accounts) { %}
|
||||
<option value="{%= email_accounts[email_id] %}">{%= email_id %}</option>
|
||||
{% } %}
|
||||
</select>
|
||||
</div>
|
||||
<p class="help-box small text-muted hidden-xs">Please Select Email Inbox</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% } else { %}
|
||||
{%= frappe.render_template("inbox_no_result", {
|
||||
doctype: "Email Account",
|
||||
label: "Email Account",
|
||||
}) %}
|
||||
{% } %}
|
||||
</div>
|
||||
Loading…
Add table
Reference in a new issue