Merge branch 'master' of github.com:webnotes/wnframework

This commit is contained in:
Nabin Hait 2013-07-25 15:59:56 +05:30
commit d2d576fb03
4 changed files with 117 additions and 96 deletions

View file

@ -113,6 +113,7 @@
"lib/public/js/legacy/widgets/form/clientscriptAPI.js",
"lib/public/js/wn/form/toolbar.js",
"lib/public/js/wn/form/infobar.js",
"lib/public/js/wn/form/layout.js",
"lib/public/js/wn/form/dashboard.js",
"lib/public/js/wn/form/script_manager.js",

View file

@ -26,7 +26,7 @@ ul.tagit li.tagit-choice {
border: none;
box-shadow: none;
border-radius: 4px;
background-color: #ddd;
background-color: #bbb;
}
ul.tagit li.tagit-new {
@ -76,14 +76,6 @@ ul.tagit input[type="text"] {
/* in list */
.list-tag ul.tagit li.tagit-choice {
background-color: transparent;
text-decoration: underline;
color: #aaa;
cursor: pointer;
font-size: 90%;
}
.list-tag ul.tagit {
margin-top: -5px;
margin-left: -4px;

View file

@ -0,0 +1,111 @@
wn.ui.form.InfoBar = Class.extend({
init: function(opts) {
$.extend(this, opts);
this.refresh();
},
refresh: function() {
var me = this;
this.appframe.clear_infobar();
if(this.frm.doc.__islocal)
return;
this.appframe.add_infobar(
wn.user.full_name(this.frm.doc.modified_by) + " / " + comment_when(this.frm.doc.modified), function() {
msgprint("Created By: " + wn.user.full_name(me.frm.doc.owner) + "<br>" +
"Created On: " + dateutil.str_to_user(me.frm.doc.creation) + "<br>" +
"Last Modified By: " + wn.user.full_name(me.frm.doc.modified_by) + "<br>" +
"Last Modifed On: " + dateutil.str_to_user(me.frm.doc.modified), "History");
})
this.make_links();
this.make_side_icons();
},
make_links: function() {
var me = this,
docinfo = wn.model.docinfo[this.frm.doctype][this.frm.docname],
comments = docinfo.comments.length,
attachments = keys(docinfo.attachments).length,
assignments = docinfo.assignments.length;
var $li1 = this.appframe.add_infobar(
(comments ? '<i class="icon-comments" style="font-size: 120%; color: orange"></i> ' : '')
+ '<span class="comment-text">' + comments + " "
+ (comments===1 ? wn._("Comment") : wn._("Comments")) + '</span>',
function() {
$('html, body').animate({
scrollTop: $(me.frm.wrapper).find(".form-comments").offset().top
}, 2000);
});
if(comments) {
$li1.addClass("bold");
var last = docinfo.comments[0];
$li1.find(".comment-text")
.popover({
title: "Last Comment",
content: last.comment
+ '<p class="text-muted small">By '
+ wn.user_info(last.comment_by).fullname
+ " / " + comment_when(last.creation)
+ '</p>',
trigger:"hover",
html: true
});
}
var $li2 = this.appframe.add_infobar(attachments + " " + (attachments===1 ?
wn._("Attachment") : wn._("Attachments")),
function() {
$('html, body').animate({
scrollTop: $(me.frm.wrapper).find(".form-attachments").offset().top
}, 2000);
});
attachments > 0 && $li2.addClass("bold");
var $li3 = this.appframe.add_infobar(assignments + " " + (assignments===1 ?
wn._("Assignment") : wn._("Assignments")),
function() {
$('html, body').animate({
scrollTop: $(me.frm.wrapper).find(".form-assignments").offset().top
}, 2000);
})
assignments > 0 && $li3.addClass("bold");
},
make_side_icons: function() {
var me = this;
this.appframe.$w.find(".form-icon").remove();
if(!this.frm.meta.issingle) {
$('<i class="icon-arrow-right pull-right form-icon" title="Next Record"></i>')
.click(function() {
me.go_prev_next(false);
})
.appendTo(this.appframe.$w.find(".info-bar"));
$('<i class="icon-arrow-left pull-right form-icon" title="Previous Record"></i>')
.click(function() {
me.go_prev_next(true);
})
.appendTo(this.appframe.$w.find(".info-bar"));
}
if(!me.frm.meta.allow_print) {
$('<i class="icon-print pull-right form-icon" title="Print"></i>')
.click(function() {
me.frm.print_doc();
})
.appendTo(this.appframe.$w.find(".info-bar"));
}
if(!me.frm.meta.allow_email) {
$('<i class="icon-envelope pull-right form-icon" title="Email"></i>')
.click(function() {
me.frm.email_doc();
})
.appendTo(this.appframe.$w.find(".info-bar"));
}
},
})

View file

@ -41,93 +41,10 @@ wn.ui.form.Toolbar = Class.extend({
Render info bar that shows timestamp, # of comments, # of attachments etc.
only if saved doc. (doc.__islocal is falsy)
*/
var me = this;
this.appframe.clear_infobar();
if(this.frm.doc.__islocal)
return;
this.appframe.add_infobar(
wn.user.full_name(this.frm.doc.modified_by) + " / " + comment_when(this.frm.doc.modified), function() {
msgprint("Created By: " + wn.user.full_name(me.frm.doc.owner) + "<br>" +
"Created On: " + dateutil.str_to_user(me.frm.doc.creation) + "<br>" +
"Last Modified By: " + wn.user.full_name(me.frm.doc.modified_by) + "<br>" +
"Last Modifed On: " + dateutil.str_to_user(me.frm.doc.modified), "History");
})
this.make_infobar_docinfo_links();
this.make_infobar_side_icons();
},
make_infobar_docinfo_links: function() {
var me = this,
docinfo = wn.model.docinfo[this.frm.doctype][this.frm.docname],
comments = docinfo.comments.length,
attachments = keys(docinfo.attachments).length,
assignments = docinfo.assignments.length;
var $li1 = this.appframe.add_infobar(
(comments ? '<i class="icon-comments" style="font-size: 120%; color: orange"></i> ' : '')
+ comments + " "
+ (comments===1 ? wn._("Comment") : wn._("Comments")),
function() {
$('html, body').animate({
scrollTop: $(me.frm.wrapper).find(".form-comments").offset().top
}, 2000);
});
comments > 0 && $li1.addClass("bold");
var $li2 = this.appframe.add_infobar(attachments + " " + (attachments===1 ?
wn._("Attachment") : wn._("Attachments")),
function() {
$('html, body').animate({
scrollTop: $(me.frm.wrapper).find(".form-attachments").offset().top
}, 2000);
});
attachments > 0 && $li2.addClass("bold");
var $li3 = this.appframe.add_infobar(assignments + " " + (assignments===1 ?
wn._("Assignment") : wn._("Assignments")),
function() {
$('html, body').animate({
scrollTop: $(me.frm.wrapper).find(".form-assignments").offset().top
}, 2000);
})
assignments > 0 && $li3.addClass("bold");
},
make_infobar_side_icons: function() {
var me = this;
this.appframe.$w.find(".form-icon").remove();
if(!this.frm.meta.issingle) {
$('<i class="icon-arrow-right pull-right form-icon" title="Next Record"></i>')
.click(function() {
me.go_prev_next(false);
})
.appendTo(this.appframe.$w.find(".info-bar"));
$('<i class="icon-arrow-left pull-right form-icon" title="Previous Record"></i>')
.click(function() {
me.go_prev_next(true);
})
.appendTo(this.appframe.$w.find(".info-bar"));
}
if(!me.frm.meta.allow_print) {
$('<i class="icon-print pull-right form-icon" title="Print"></i>')
.click(function() {
me.frm.print_doc();
})
.appendTo(this.appframe.$w.find(".info-bar"));
}
if(!me.frm.meta.allow_email) {
$('<i class="icon-envelope pull-right form-icon" title="Email"></i>')
.click(function() {
me.frm.email_doc();
})
.appendTo(this.appframe.$w.find(".info-bar"));
}
if(this.infobar)
this.infobar.refresh();
else
this.infobar = new wn.ui.form.InfoBar({appframe:this.appframe, frm:this.frm});
},
show_print_toolbar: function() {
var me = this;