Browse Source

[magic] frappe.emit_js

version-14
Rushabh Mehta 9 years ago
parent
commit
5a35548c6a
6 changed files with 43 additions and 9 deletions
  1. +6
    -0
      frappe/__init__.py
  2. +7
    -6
      frappe/public/css/form.css
  3. +15
    -0
      frappe/public/js/frappe/form/dashboard.js
  4. +4
    -0
      frappe/public/js/frappe/socketio_client.js
  5. +1
    -1
      frappe/public/js/frappe/ui/messages.js
  6. +10
    -2
      frappe/public/less/form.less

+ 6
- 0
frappe/__init__.py View File

@@ -283,6 +283,12 @@ def throw(msg, exc=ValidationError):
:param exc: Exception class. Default `frappe.ValidationError`"""
msgprint(msg, raise_exception=exc)

def emit_js(js, user=False, **kwargs):
from frappe.async import publish_realtime
if user == False:
user = session.user
publish_realtime('eval_js', js, user=user, **kwargs)

def create_folder(path, with_init=False):
"""Create a folder in the given path and add an `__init__.py` file (optional).



+ 7
- 6
frappe/public/css/form.css View File

@@ -71,17 +71,11 @@
display: none;
}
}
.form-dashboard {
border-bottom: 1px solid #EBEFF2;
}
.form-dashboard-section {
padding: 15px 30px;
margin: 0px;
border-bottom: 1px solid #EBEFF2;
}
.form-dashboard-section:last-child {
border-bottom: none;
}
.form-heatmap {
padding-top: 30px;
}
@@ -427,11 +421,18 @@ select.form-control {
font-weight: bold;
background-color: #fffdf4;
}
.form-headline {
padding: 0px 15px;
}
.form-headline .alert {
font-size: 12px;
background-color: #fffce7;
font-weight: normal !important;
border: 0px;
border-radius: 0px;
margin-bottom: 0px;
margin: 0px -15px;
padding: 10px 30px;
}
.delivery-status-indicator {
display: inline-block;


+ 15
- 0
frappe/public/js/frappe/form/dashboard.js View File

@@ -42,6 +42,21 @@ frappe.ui.form.Dashboard = Class.extend({
this.headline.empty().addClass('hidden');
}
},

add_comment: function(text, permanent) {
var me = this;
this.set_headline_alert(text);
if(!permanent) {
setTimeout(function() {
me.clear_headline();
}, 10000);
}
},

clear_comment: function() {
this.clear_headline();
},

set_headline_alert: function(text, alert_class) {
if(text) {
if(!alert_class) alert_class = "alert-warning";


+ 4
- 0
frappe/public/js/frappe/socketio_client.js View File

@@ -27,6 +27,10 @@ frappe.socket = {
frappe.msgprint(message);
});

frappe.socket.socket.on('eval_js', function(message) {
eval(message);
});

frappe.socket.setup_listeners();
frappe.socket.setup_reconnect();



+ 1
- 1
frappe/public/js/frappe/ui/messages.js View File

@@ -230,7 +230,7 @@ frappe.show_alert = function(txt, seconds) {
return false;
});

div.delay(seconds ? seconds * 1000 : 3000).fadeOut(300);
div.delay(seconds ? seconds * 1000 : 7000).fadeOut(300);
return div;
}



+ 10
- 2
frappe/public/less/form.less View File

@@ -101,7 +101,7 @@
}

.form-dashboard {
border-bottom: 1px solid @light-border-color;
//border-bottom: 1px solid @light-border-color;
}

.form-dashboard-section {
@@ -111,7 +111,7 @@
}

.form-dashboard-section:last-child {
border-bottom: none;
// border-bottom: none;
}

.form-heatmap {
@@ -540,11 +540,19 @@ select.form-control {
background-color: @extra-light-yellow;
}

.form-headline {
padding: 0px 15px;
}

.form-headline .alert {
font-size: @text-medium;
background-color: @light-yellow;
font-weight: normal !important;
border: 0px;
border-radius: 0px;
margin-bottom: 0px;
margin: 0px -15px;
padding: 10px 30px;
}

.delivery-status-indicator {


Loading…
Cancel
Save