knowledge base cleanup
This commit is contained in:
parent
46162c4e35
commit
81c8ec2b89
@ -25,9 +25,9 @@ KBItemToolbar = function(args, kb) {
|
||||
this.wrapper = $a(this.parent, 'div', '', {});
|
||||
this.line1 = $a(this.wrapper, 'div', '', {color: '#888', fontSize:'11px', margin:'7px 0px'});
|
||||
this.make_timestamp();
|
||||
this.make_vote();
|
||||
if(this.with_tags)
|
||||
this.make_tags();
|
||||
this.setup_del();
|
||||
}
|
||||
|
||||
this.make_timestamp = function() {
|
||||
@ -38,24 +38,11 @@ KBItemToolbar = function(args, kb) {
|
||||
|
||||
// allow system manager to delete questions / answers
|
||||
if(has_common(user_roles, ['Administrator', 'System Manager'])) {
|
||||
this.line1.innerHTML += ' | '
|
||||
$ln(this.line1, 'delete', me.del);
|
||||
this.line1.innerHTML += ' | <a style="cursor:pointer;"\
|
||||
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.line1.innerHTML += ' | '
|
||||
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.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();
|
||||
}
|
||||
|
||||
|
||||
// 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,
|
||||
// needs parent, text, disp_class, inp_class
|
||||
// dt, dn
|
||||
|
@ -141,10 +141,10 @@ KBAnswerList = function(args) {
|
||||
new KBAnswer(body, data, me)
|
||||
},
|
||||
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 "
|
||||
+"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
|
||||
// answer
|
||||
// by xxx | on xxx
|
||||
// points yyy
|
||||
KBAnswer = function(body, data, ans_list) {
|
||||
body.className = 'qv-answer';
|
||||
var edtxt = new EditableText({
|
||||
|
@ -126,7 +126,7 @@ function KnowledgeBase(w) {
|
||||
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 '
|
||||
+'from tabQuestion t1, tabProfile t2 '
|
||||
+'where t1.docstatus!=2 '
|
||||
|
Loading…
x
Reference in New Issue
Block a user