[minor] fixes after cleanup

This commit is contained in:
Anand Doshi 2013-11-13 18:53:44 +05:30
parent 862bce0f33
commit d8ef72f01f
5 changed files with 65 additions and 37 deletions

View file

@ -483,7 +483,7 @@ def import_file_by_path(path, ignore_links=False, overwrite=False):
def export_csv(doctype, path):
with open(path, "w") as csvfile:
get_template(doctype=doctype, all_doctypes="Yes", with_data="Yes")
csvfile.write(webnotes.response.result)
csvfile.write(webnotes.response.result.encode("utf-8"))
def export_json(doctype, name, path):
from webnotes.handler import json_handler

View file

@ -170,17 +170,17 @@ div#freeze {
background-color: #e7e7e7;
}
.appframe-titlebar .container {
display: table;
}
.titlebar-item {
display: table-cell;
vertical-align: middle;
width: 33.3333%;
padding-top: 10px;
padding-bottom: 10px;
}
.titlebar-center-item {
padding-top: 0px;
padding-bottom: 0px;
}
.appframe-header {
margin-bottom: 20px;
}
@ -227,6 +227,7 @@ div#freeze {
.appframe-form input, .appframe-form select, .appframe-form label {
font-size: 90%;
padding: 4px;
}
.appframe-form .form-group {
@ -234,7 +235,7 @@ div#freeze {
}
.appframe-form .form-control {
height: 20px;
height: 28px;
}
.iconbar {
@ -541,8 +542,6 @@ textarea.form-control {
}
.toolbar-banner {
margin-top: -20px;
margin-bottom: 20px;
text-align: center;
background-color: #fcf8e3;
padding: 7px;

View file

@ -20,6 +20,7 @@ wn.ui.form.Toolbar = Class.extend({
} else {
this.appframe.iconbar.clear(1)
this.make_file_menu();
this.make_cancel_amend_button();
this.show_infobar();
if(this.frm.doc.__islocal) {
this.appframe.iconbar.hide(2);
@ -91,6 +92,25 @@ wn.ui.form.Toolbar = Class.extend({
me.frm.save('Save', null, this);}, 'icon-save');
}
// Submit
if(docstatus==0 && !this.frm.doc.__unsaved && p[SUBMIT] && !this.read_only) {
this.appframe.add_dropdown_button("File", wn._("Submit"), function() {
me.frm.savesubmit(this);}, 'icon-lock');
}
// Cancel
if(docstatus==1 && p[CANCEL] && !this.read_only) {
this.appframe.add_dropdown_button("File", wn._("Cancel"), function() {
me.frm.savecancel(this);}, 'icon-remove');
}
// Amend
if(docstatus==2 && p[AMEND] && !this.read_only) {
this.appframe.add_dropdown_button("File", wn._("Amend"), function() {
me.frm.amend_doc();}, 'icon-pencil');
this.appframe.set_title_right("Amend", function() { me.frm.amend_doc(); });
}
// Print
if(!(me.frm.doc.__islocal || me.frm.meta.allow_print)) {
this.appframe.add_dropdown_button("File", wn._("Print..."), function() {
@ -154,14 +174,22 @@ wn.ui.form.Toolbar = Class.extend({
else if(docstatus==0) {
this.make_save_button();
}
else if(docstatus==1 && p[CANCEL]) {
this.appframe.add_button('Cancel', function() {
me.frm.savecancel(this) }, 'icon-remove');
}
else if(docstatus==2 && p[AMEND]) {
this.appframe.add_button('Amend', function() {
me.frm.amend_doc() }, 'icon-pencil', true);
}
}
},
make_cancel_amend_button: function() {
var me = this;
var docstatus = cint(this.frm.doc.docstatus);
var p = this.frm.perm[0];
var has_workflow = wn.model.get("Workflow", {document_type: me.frm.doctype}).length;
if(has_workflow) {
return;
} else if(docstatus==1 && p[CANCEL]) {
this.appframe.add_button('Cancel', function() {
me.frm.savecancel(this) }, 'icon-remove');
} else if(docstatus==2 && p[AMEND]) {
this.appframe.add_button('Amend', function() {
me.frm.amend_doc() }, 'icon-pencil', true);
}
},
make_save_button: function() {
@ -190,10 +218,5 @@ wn.ui.form.Toolbar = Class.extend({
.toggleClass("text-warning", this.frm.doc.__unsaved ? true : false);
this.set_title();
this.set_title_button();
},
make_actions_menu: function() {
if(this.actions_setup) return;
var menu = this.get_dropdown_menu("Actions");
this.actions_setup = true;
}
}
})

View file

@ -34,8 +34,8 @@ wn.ui.set_user_background = function(src) {
if(!src) src = "lib/images/ui/field.jpg";
wn.dom.set_style(repl('#page-desktop { \
position: fixed;\
top: 0px; left: 0px; min-width: 100%; height: 100%; overflow: auto;\
padding-top: 50px; \
left: 0px; min-width: 100%; height: 100%; overflow: auto;\
padding-top: 14px; \
background: url("%(src)s") no-repeat center center fixed; \
-webkit-background-size: cover; -moz-background-size: cover; \
-o-background-size: cover; \

View file

@ -53,16 +53,19 @@ wn.ui.AppFrame = Class.extend({
},
set_title_right: function(txt, click, icon) {
this.primary_dropdown = null;
this.primary_action = null;
this.title_right = null;
var $right = this.parent.find(".titlebar-item.text-right").empty();
var $right = this.parent.find(".titlebar-item.text-right")
if(txt) {
this.title_right && this.title_right.remove();
this.title_right = $("<a>")
.html((icon ? '<i class="'+icon+'"></i> ' : "") + txt)
.click(click)
.appendTo($right);
return this.title_right;
} else {
$right.empty();
this.title_right = null;
this.primary_dropdown = null;
this.primary_action = null;
}
},
@ -81,9 +84,10 @@ wn.ui.AppFrame = Class.extend({
.attr("id", id)
.attr("data-toggle", "dropdown")
.addClass("dropdown-toggle")
.parent().addClass("dropdown");
.parent()
.addClass("dropdown")
this.primary_dropdown = $('<ul class="dropdown-menu pull-right" role="menu" \
aria-labelledby="dropdown-'+ id +'"></ul>')
aria-labelledby="'+ id +'"></ul>')
.appendTo(this.primary_action.parent()).dropdown();
}
@ -308,9 +312,11 @@ wn.ui.make_app_page = function(opts) {
$wrapper = $(opts.parent)
$('<div class="appframe-titlebar">\
<div class="container">\
<div class="titlebar-item text-left"></div>\
<div class="titlebar-item text-center"></div>\
<div class="titlebar-item text-right"></div>\
<div class="row">\
<div class="titlebar-item text-left col-xs-4"></div>\
<div class="titlebar-item titlebar-center-item text-center col-xs-4"></div>\
<div class="titlebar-item text-right col-xs-4"></div>\
</div>\
</div>\
</div>\
<div class="appframe-iconbar hide">\