瀏覽代碼

[form] updated toolbars

version-14
Rushabh Mehta 12 年之前
父節點
當前提交
a46f2011d4
共有 7 個檔案被更改,包括 79 行新增77 行删除
  1. +6
    -0
      public/css/ui/common.css
  2. +1
    -1
      public/js/legacy/widgets/form/fields.js
  3. +1
    -2
      public/js/legacy/widgets/form/form.js
  4. +36
    -21
      public/js/wn/form/toolbar.js
  5. +4
    -2
      public/js/wn/model/perm.js
  6. +21
    -41
      public/js/wn/ui/appframe.js
  7. +10
    -10
      public/js/wn/ui/toolbar/toolbar.js

+ 6
- 0
public/css/ui/common.css 查看文件

@@ -107,6 +107,12 @@ a {
font-size: 12px; font-size: 12px;
} }


.slick-header * {
-webkit-box-sizing: content-box;
-moz-box-sizing: content-box;
box-sizing: content-box;
}

.slick-headerrow-column { .slick-headerrow-column {
background: #87ceeb; background: #87ceeb;
text-overflow: clip; text-overflow: clip;


+ 1
- 1
public/js/legacy/widgets/form/fields.js 查看文件

@@ -364,7 +364,7 @@ function HTMLField() {
this.set_input = function(val) { this.set_input = function(val) {
me.set_disp(val); me.set_disp(val);
} }
this.onrefresh = function() {
this.refresh = function() {
if(me.df.options) if(me.df.options)
me.set_disp(me.df.options); me.set_disp(me.df.options);
} }


+ 1
- 2
public/js/legacy/widgets/form/form.js 查看文件

@@ -316,8 +316,7 @@ _f.Frm.prototype.set_footnote = function(txt) {




_f.Frm.prototype.add_custom_button = function(label, fn, icon) { _f.Frm.prototype.add_custom_button = function(label, fn, icon) {
this.toolbar.make_actions_menu();
this.appframe.add_dropdown_button("Actions", label, fn, icon);
this.appframe.add_button(label, fn, icon, true);
} }
_f.Frm.prototype.clear_custom_buttons = function() { _f.Frm.prototype.clear_custom_buttons = function() {
this.toolbar.refresh() this.toolbar.refresh()


+ 36
- 21
public/js/wn/form/toolbar.js 查看文件

@@ -26,44 +26,45 @@ wn.ui.form.Toolbar = Class.extend({


// New // New
if(p[CREATE]) { if(p[CREATE]) {
this.appframe.add_dropdown_button("File", "New " + me.frm.doctype, function() {
this.appframe.add_dropdown_button("File", wn._("New") + " "
+ wn._(me.frm.doctype), function() {
new_doc(me.frm.doctype);}, 'icon-plus'); new_doc(me.frm.doctype);}, 'icon-plus');
} }


// Save // Save
if(docstatus==0 && p[WRITE] && !this.read_only) { if(docstatus==0 && p[WRITE] && !this.read_only) {
this.appframe.add_dropdown_button("File", "Save", function() {
this.appframe.add_dropdown_button("File", wn._("Save"), function() {
me.frm.save('Save', null, this);}, 'icon-save'); me.frm.save('Save', null, this);}, 'icon-save');
} }
// Print // Print
if(!(me.frm.doc.__islocal || me.frm.meta.allow_print)) { if(!(me.frm.doc.__islocal || me.frm.meta.allow_print)) {
this.appframe.add_dropdown_button("File", "Print...", function() {
this.appframe.add_dropdown_button("File", wn._("Print..."), function() {
me.frm.print_doc();}, 'icon-print'); me.frm.print_doc();}, 'icon-print');
} }


// email // email
if(!(me.frm.doc.__islocal || me.frm.meta.allow_email)) { if(!(me.frm.doc.__islocal || me.frm.meta.allow_email)) {
this.appframe.add_dropdown_button("File", "Email...", function() {
this.appframe.add_dropdown_button("File", wn._("Email..."), function() {
me.frm.email_doc();}, 'icon-envelope'); me.frm.email_doc();}, 'icon-envelope');
} }
// copy // copy
if(in_list(profile.can_create, me.frm.doctype) && !me.frm.meta.allow_copy) { if(in_list(profile.can_create, me.frm.doctype) && !me.frm.meta.allow_copy) {
this.appframe.add_dropdown_button("File", "Make Copy", function() {
this.appframe.add_dropdown_button("File", wn._("Make Copy"), function() {
me.frm.copy_doc();}, 'icon-file'); me.frm.copy_doc();}, 'icon-file');
} }
// rename // rename
if(me.frm.meta.allow_rename && me.frm.perm[0][WRITE]) { if(me.frm.meta.allow_rename && me.frm.perm[0][WRITE]) {
this.appframe.add_dropdown_button("File", "Rename...", function() {
this.appframe.add_dropdown_button("File", wn._("Rename..."), function() {
me.frm.rename_doc();}, 'icon-retweet'); me.frm.rename_doc();}, 'icon-retweet');
} }
// delete // delete
if((cint(me.frm.doc.docstatus) != 1) && !me.frm.doc.__islocal if((cint(me.frm.doc.docstatus) != 1) && !me.frm.doc.__islocal
&& wn.model.can_delete(me.frm.doctype)) { && wn.model.can_delete(me.frm.doctype)) {
this.appframe.add_dropdown_button("File", "Delete", function() {
this.appframe.add_dropdown_button("File", wn._("Delete"), function() {
me.frm.savetrash();}, 'icon-remove-sign'); me.frm.savetrash();}, 'icon-remove-sign');
} }
@@ -72,20 +73,20 @@ wn.ui.form.Toolbar = Class.extend({
var me = this; var me = this;
// Edit // Edit
if(this.frm.meta.read_only_onload && !this.frm.doc.__islocal) { if(this.frm.meta.read_only_onload && !this.frm.doc.__islocal) {
this.appframe.add_dropdown_button("View", 'Print View', function() {
this.appframe.add_dropdown_button("View", wn._('Print View'), function() {
me.frm.last_view_is_edit[me.frm.docname] = 0; me.frm.last_view_is_edit[me.frm.docname] = 0;
me.frm.refresh(); }, 'icon-print'); me.frm.refresh(); }, 'icon-print');
} }


if(this.frm.meta.read_only_onload && !this.frm.doc.__islocal) { if(this.frm.meta.read_only_onload && !this.frm.doc.__islocal) {
this.appframe.add_dropdown_button("View", 'Edit', function() {
this.appframe.add_dropdown_button("View", wn._('Edit'), function() {
me.frm.last_view_is_edit[me.frm.docname] = 1; me.frm.last_view_is_edit[me.frm.docname] = 1;
me.frm.refresh(); }, 'icon-edit'); me.frm.refresh(); }, 'icon-edit');
} }
// Linked With // Linked With
if(!me.frm.doc.__islocal && !me.frm.meta.issingle) { if(!me.frm.doc.__islocal && !me.frm.meta.issingle) {
this.appframe.add_dropdown_button("View", 'Linked With', function() {
this.appframe.add_dropdown_button("View", wn._('Linked With'), function() {
if(!me.frm.linked_with) { if(!me.frm.linked_with) {
me.frm.linked_with = new wn.ui.form.LinkedWith({ me.frm.linked_with = new wn.ui.form.LinkedWith({
frm: me.frm frm: me.frm
@@ -94,6 +95,20 @@ wn.ui.form.Toolbar = Class.extend({
me.frm.linked_with.show(); me.frm.linked_with.show();
}, "icon-link") }, "icon-link")
} }
if(!this.frm.meta.issingle) {
this.appframe.add_menu_divider("View");
this.appframe.add_dropdown_button("View",
wn._(this.frm.doctype) + ' ' + wn._('List'), function() {
wn.set_route("List", me.frm.doctype);
}, 'icon-list');

this.appframe.add_dropdown_button("View",
wn._(this.frm.doctype) + ' ' + wn._('Report View'), function() {
wn.set_route("Report2", me.frm.doctype);
}, 'icon-table');
}
}, },
set_title_button: function() { set_title_button: function() {
var me = this; var me = this;
@@ -103,20 +118,20 @@ wn.ui.form.Toolbar = Class.extend({


if(!wn.model.get("Workflow", {document_type: me.frm.doctype}).length) { if(!wn.model.get("Workflow", {document_type: me.frm.doctype}).length) {
if(docstatus==0 && p[SUBMIT] && (!me.frm.doc.__islocal)) { if(docstatus==0 && p[SUBMIT] && (!me.frm.doc.__islocal)) {
this.appframe.add_title_button('Submit', function() {
me.frm.savesubmit(this);}, 'icon-lock');
this.appframe.add_button('Submit', function() {
me.frm.savesubmit(this);}, 'icon-lock', true).addClass("btn-primary");
} }
else if(docstatus==0) { else if(docstatus==0) {
this.appframe.add_title_button('Save', function() {
me.frm.save('Save', null, this);}, 'icon-save');
this.appframe.add_button('Save', function() {
me.frm.save('Save', null, this);}, 'icon-save', true).addClass("btn-primary");
} }
else if(docstatus==1 && p[CANCEL]) { else if(docstatus==1 && p[CANCEL]) {
this.appframe.add_title_button('Cancel', function() {
this.appframe.add_dropdown_button("File", 'Cancel', function() {
me.frm.savecancel(this) }, 'icon-remove'); me.frm.savecancel(this) }, 'icon-remove');
} }
else if(docstatus==2 && p[AMEND]) { else if(docstatus==2 && p[AMEND]) {
this.appframe.add_title_button('Amend', function() {
me.frm.amend_doc() }, 'icon-pencil');
this.appframe.add_button('Amend', function() {
me.frm.amend_doc() }, 'icon-pencil', true);
} }
} }
}, },
@@ -127,11 +142,11 @@ wn.ui.form.Toolbar = Class.extend({
// show update button if unsaved // show update button if unsaved
var docstatus = cint(me.frm.doc.docstatus); var docstatus = cint(me.frm.doc.docstatus);
if(docstatus==1 && me.frm.perm[0][SUBMIT]) {
me.appframe.$w.find(".title-button-area").empty();
me.appframe.add_title_button("Update", function() {
if(docstatus==1 && me.frm.perm[0][SUBMIT]
&& !me.appframe.$w.find(".action-update").length) {
me.appframe.add_button("Update", function() {
me.frm.save('Update', null, me); me.frm.save('Update', null, me);
}, 'icon-save')
}, 'icon-save', true).addClass("btn-primary action-update");
} }
}) })
}, },


+ 4
- 2
public/js/wn/model/perm.js 查看文件

@@ -173,8 +173,10 @@ $.extend(wn.perm, {
if(explain) console.log("By Submit:" + ret) if(explain) console.log("By Submit:" + ret)


// allow on submit // allow on submit
var allow_on_submit = cint(df.allow_on_submit);

var allow_on_submit = df.fieldtype!= "Table" ?
cint(df.allow_on_submit) :
0;
// if(allow_on_submit && doc.parent) { // if(allow_on_submit && doc.parent) {
// parent_df = wn.model.get("DocField", { // parent_df = wn.model.get("DocField", {
// "parent": doc.parenttype, // "parent": doc.parenttype,


+ 21
- 41
public/js/wn/ui/appframe.js 查看文件

@@ -17,11 +17,13 @@ wn.ui.AppFrame = Class.extend({
</ul>\ </ul>\
</div>\ </div>\
<div class="toolbar-area"></div -->\ <div class="toolbar-area"></div -->\
<div class="title-button-area pull-right" style="margin-top: 10px;"></div>\
<div class="title-button-area btn-group pull-right" style="margin-top: 10px;"></div>\
<div class="title-area"><h3 style="display: inline-block">\ <div class="title-area"><h3 style="display: inline-block">\
<span class="title-icon"></span><span class="title-text"></span></h3></div>\ <span class="title-icon"></span><span class="title-text"></span></h3></div>\
<div class="sub-title-area text-muted small" \ <div class="sub-title-area text-muted small" \
style="margin-top: -10px;"></div>\ style="margin-top: -10px;"></div>\
<div class="btn-group appframe-toolbar" \
style="display: none; margin-top: 15px;"></div>\
<hr>\ <hr>\
').appendTo(this.$w); ').appendTo(this.$w);
@@ -29,6 +31,8 @@ wn.ui.AppFrame = Class.extend({
window.history.back(); window.history.back();
}) })
this.toolbar = this.$w.find(".appframe-toolbar");
if(title) if(title)
this.set_title(title); this.set_title(title);
@@ -154,7 +158,6 @@ wn.ui.AppFrame = Class.extend({
}, },
add_help_button: function(txt) { add_help_button: function(txt) {
this.add_toolbar();
$('<button class="btn" button-type="help">\ $('<button class="btn" button-type="help">\
<b>?</b></button>') <b>?</b></button>')
.data('help-text', txt) .data('help-text', txt)
@@ -163,59 +166,36 @@ wn.ui.AppFrame = Class.extend({
}, },


clear_buttons: function() { clear_buttons: function() {
this.toolbar && this.toolbar.empty();
this.toolbar && this.toolbar.empty().toggle(false);
$(".custom-menu").remove(); $(".custom-menu").remove();
}, },


add_toolbar: function() {
if(!this.toolbar) {
this.toolbar = $('<div class="navbar">\
<div class="navbar-inner">\
<ul class="nav">\
</ul>\
</div>\
</div>').appendTo(this.$w.find(".toolbar-area")).find(".nav");
}
},
add_button: function(label, click, icon) {
this.add_toolbar();
args = { label: label, icon:'' };
if(icon) {
args.icon = '<i class="'+icon+'"></i>';
}
this.buttons[label] = $(repl('<li><a>\
%(icon)s %(label)s</a></li>', args))
.appendTo(this.toolbar)
.find("a")
.click(click);
return this.buttons[label];
},
add_title_button: function(label, click, icon) {
add_button: function(label, click, icon, title_toolbar) {
!title_toolbar && this.toolbar.toggle(true);
args = { label: label, icon:'' }; args = { label: label, icon:'' };
if(icon) { if(icon) {
args.icon = '<i class="'+icon+'"></i>'; args.icon = '<i class="'+icon+'"></i>';
} }
this.buttons[label] = $(repl('<button class="btn btn-primary">\
this.buttons[label] = $(repl('<button class="btn">\
%(icon)s %(label)s</button>', args)) %(icon)s %(label)s</button>', args))
.appendTo(this.$w.find(".title-button-area"))
.appendTo(title_toolbar ? this.$w.find(".title-button-area") : this.toolbar)
.click(click); .click(click);
return this.buttons[label]; return this.buttons[label];
}, },
add_dropdown: function(label) {
this.add_toolbar();
this.buttons[label] = $('<li class="dropdown">\
<a href="#" class="dropdown-toggle" data-toggle="dropdown">'
+label+' <b class="caret"></b></a>\
<ul class="dropdown-menu"></ul>')
.appendTo(this.toolbar);
this.buttons[label].find(".dropdown-toggle").dropdown();
return this.buttons[label];
get_menu: function(label) {
return $("#navbar-" + label.toLowerCase());
},
add_menu_divider: function(menu) {
menu = typeof menu == "string" ?
this.get_menu(menu) : menu;
$('<li class="divider custom-menu"></li>').appendTo(menu);
}, },
add_dropdown_button: function(parent, label, click, icon) { add_dropdown_button: function(parent, label, click, icon) {
var menu = $("#navbar-" + parent.toLowerCase());
var menu = this.get_menu(parent);
if(menu.find("li:not(.custom-menu)").length && !menu.find(".divider").length) { if(menu.find("li:not(.custom-menu)").length && !menu.find(".divider").length) {
$('<li class="divider custom-menu"></li>').appendTo(menu);
this.add_menu_divider(menu);
} }


return $('<li class="custom-menu"><a><i class="' return $('<li class="custom-menu"><a><i class="'


+ 10
- 10
public/js/wn/ui/toolbar/toolbar.js 查看文件

@@ -27,7 +27,7 @@ wn.ui.toolbar.Toolbar = Class.extend({
this.make_erpnext(); this.make_erpnext();
this.make_file(); this.make_file();
this.make_view(); this.make_view();
this.make_actions();
//this.make_actions();
wn.ui.toolbar.recent = new wn.ui.toolbar.RecentDocs(); wn.ui.toolbar.recent = new wn.ui.toolbar.RecentDocs();
wn.ui.toolbar.bookmarks = new wn.ui.toolbar.Bookmarks(); wn.ui.toolbar.bookmarks = new wn.ui.toolbar.Bookmarks();
this.make_tools(); this.make_tools();
@@ -144,15 +144,15 @@ wn.ui.toolbar.Toolbar = Class.extend({
</li>'); </li>');
}, },


make_actions: function() {
$('.navbar .nav:first').append('<li class="dropdown">\
<a class="dropdown-toggle" data-toggle="dropdown" href="#" \
title="'+wn._("Actions")+'"\
onclick="return false;">'+wn._("Actions")+'</a>\
<ul class="dropdown-menu" id="navbar-actions">\
</ul>\
</li>');
},
// make_actions: function() {
// $('.navbar .nav:first').append('<li class="dropdown">\
// <a class="dropdown-toggle" data-toggle="dropdown" href="#" \
// title="'+wn._("Actions")+'"\
// onclick="return false;">'+wn._("Actions")+'</a>\
// <ul class="dropdown-menu" id="navbar-actions">\
// </ul>\
// </li>');
// },


make_tools: function() { make_tools: function() {
$('.navbar .nav:first').append('<li class="dropdown">\ $('.navbar .nav:first').append('<li class="dropdown">\


Loading…
取消
儲存