Merge branch 'shf_rename' of github.com:webnotes/erpnext into shf_rename

This commit is contained in:
Anand Doshi 2012-04-18 17:18:06 +05:30
commit 2d56115c08
3 changed files with 20 additions and 61 deletions

View File

@ -25,9 +25,9 @@ KBItemToolbar = function(args, kb) {
this.wrapper = $a(this.parent, 'div', '', {}); this.wrapper = $a(this.parent, 'div', '', {});
this.line1 = $a(this.wrapper, 'div', '', {color: '#888', fontSize:'11px', margin:'7px 0px'}); this.line1 = $a(this.wrapper, 'div', '', {color: '#888', fontSize:'11px', margin:'7px 0px'});
this.make_timestamp(); this.make_timestamp();
this.make_vote();
if(this.with_tags) if(this.with_tags)
this.make_tags(); this.make_tags();
this.setup_del();
} }
this.make_timestamp = function() { this.make_timestamp = function() {
@ -38,24 +38,11 @@ KBItemToolbar = function(args, kb) {
// allow system manager to delete questions / answers // allow system manager to delete questions / answers
if(has_common(user_roles, ['Administrator', 'System Manager'])) { if(has_common(user_roles, ['Administrator', 'System Manager'])) {
this.line1.innerHTML += ' | ' this.line1.innerHTML += ' | <a style="cursor:pointer;"\
$ln(this.line1, 'delete', me.del); class="del-link">delete</a>';
} }
} }
this.make_vote = function() {
this.line1.innerHTML += ' | '
new KBPoints(this.line1, this.det.points, this.det._users_voted, this.doctype, this.det.name, this.det.owner);
}
this.del = function() {
this.innerHTML = 'deleting...'; this.disabled = 1;
$c_page('knowledge_base', 'questions', 'delete', {dt:me.doctype, dn:me.det.name}, function(r,rt) {
// reload the list
kb.list.run()
});
}
this.make_tags = function() { this.make_tags = function() {
this.line1.innerHTML += ' | ' this.line1.innerHTML += ' | '
this.tags_area = $a(this.line1, 'span', 'kb-tags') this.tags_area = $a(this.line1, 'span', 'kb-tags')
@ -64,50 +51,23 @@ KBItemToolbar = function(args, kb) {
this.doctype, this.det.name, 0, kb.set_tag_filter) this.doctype, this.det.name, 0, kb.set_tag_filter)
} }
this.setup_del = function() {
$(this.line1).find('.del-link').click(function() {
console.log(1);
this.innerHTML = 'deleting...';
this.disabled = 1;
$c_page('knowledge_base', 'questions', 'delete', {
dt: me.doctype, dn: me.det.name}, function(r,rt) {
// reload the list
kb.list.run()
});
});
}
this.make(); this.make();
} }
// kb points
// x points | Vote Up | Vote Down (if not voted and not guest)
KBPoints = function(parent, points, voted, dt, dn, owner) {
var me = this;
voted = voted ? voted.split(',') : [];
this.wrapper = $a(parent, 'span', '', {fontSize: '11px', marginRight: '7px', marginLeft: '7px'});
this.render_points = function(p) {
if(!this.points_area)
this.points_area = $a(this.wrapper, 'span');
this.points_area.innerHTML = cint(p) + ' point' + (p>1 ? 's' : '');
}
this.render_points(points);
// vote up or down
// if user has not already voted
if(user!='Guest' && !in_list(voted, user) && user!=owner) {
this.vote_up = $a(this.wrapper, 'img', 'lib/images/ui/vote_up.gif', {margin:'0px 0px -2px 7px', cursor: 'pointer'});
this.vote_down = $a(this.wrapper, 'img', 'lib/images/ui/vote_down.gif', {margin:'0px 0px -3px 0px', cursor: 'pointer'});
this.vote_up.title = 'Vote Up'; this.vote_down.title = 'Vote Down';
var callback = function(r, rt) {
if(r.exc) { msgprint(r.exc); return; }
$dh(me.vote_up); $dh(me.vote_down);
me.render_points(r.message);
}
this.vote_up.onclick = function() {
$c_page('knowledge_base', 'questions', 'vote', {vote:'up', dn:dn, dt:dt}, callback);
}
this.vote_down.onclick = function() {
$c_page('knowledge_base', 'questions', 'vote', {vote:'down', dn:dn, dt:dt}, callback);
}
}
}
// displays an editable text, // displays an editable text,
// needs parent, text, disp_class, inp_class // needs parent, text, disp_class, inp_class
// dt, dn // dt, dn
@ -121,7 +81,7 @@ EditableText = function(args) {
<a class="ed-text-edit" style="cursor: pointer; float: right;">[edit]</a>\ <a class="ed-text-edit" style="cursor: pointer; float: right;">[edit]</a>\
<textarea class="ed-text-input %(inp_class)s hide"></textarea><br>\ <textarea class="ed-text-input %(inp_class)s hide"></textarea><br>\
<div class="help hide">Formatted as <a href="http://en.wikipedia.org/wiki/Markdown#Syntax_examples"\ <div class="help hide">Formatted as <a href="http://en.wikipedia.org/wiki/Markdown#Syntax_examples"\
target="_blank">markdown</div>\ target="_blank">markdown</a></div>\
<button class="btn btn-small btn-info hide ed-text-save">Save</button>\ <button class="btn btn-small btn-info hide ed-text-save">Save</button>\
<a class="ed-text-cancel hide" style="cursor: pointer;">Cancel</a>\ <a class="ed-text-cancel hide" style="cursor: pointer;">Cancel</a>\
</div>', args)).appendTo(me.parent); </div>', args)).appendTo(me.parent);

View File

@ -141,10 +141,10 @@ KBAnswerList = function(args) {
new KBAnswer(body, data, me) new KBAnswer(body, data, me)
}, },
get_query: function() { get_query: function() {
return repl("SELECT t1.name, t1.owner, t1.answer, t1.points, t1._users_voted, t2.first_name, " return repl("SELECT t1.name, t1.owner, t1.answer, t1._users_voted, t2.first_name, "
+"t2.last_name, t1.modified from tabAnswer t1, tabProfile t2 " +"t2.last_name, t1.modified from tabAnswer t1, tabProfile t2 "
+"where question='%(qid)s' and t1.owner = t2.name " +"where question='%(qid)s' and t1.owner = t2.name "
+"order by t1.points desc, t1.modified desc", {qid: me.qid}) +"order by t1.modified desc", {qid: me.qid})
} }
}); });
@ -159,7 +159,6 @@ KBAnswerList = function(args) {
// kb answer // kb answer
// answer // answer
// by xxx | on xxx // by xxx | on xxx
// points yyy
KBAnswer = function(body, data, ans_list) { KBAnswer = function(body, data, ans_list) {
body.className = 'qv-answer'; body.className = 'qv-answer';
var edtxt = new EditableText({ var edtxt = new EditableText({

View File

@ -126,7 +126,7 @@ function KnowledgeBase(w) {
cond += ' and t1.`_user_tags` like "%' + f + '%"' cond += ' and t1.`_user_tags` like "%' + f + '%"'
} }
} }
return repl('select t1.name, t1.owner, t1.question, t1.points, t1.modified, t1._user_tags, ' return repl('select t1.name, t1.owner, t1.question, t1.modified, t1._user_tags, '
+'t1._users_voted, t2.first_name, t2.last_name ' +'t1._users_voted, t2.first_name, t2.last_name '
+'from tabQuestion t1, tabProfile t2 ' +'from tabQuestion t1, tabProfile t2 '
+'where t1.docstatus!=2 ' +'where t1.docstatus!=2 '