From e3393bead94bb9ed0a0953f7a1b0fdcddd2e4b60 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Tue, 30 Aug 2011 15:37:46 +0530 Subject: [PATCH] fix to kb, delete question, ans --- home/page/event_updates/event_updates.js | 16 +++++++++++----- knowledge_base/page/kb_common/kb_common.js | 17 +++++++++++++++-- .../page/question_view/question_view.js | 6 +++--- knowledge_base/page/questions/questions.py | 8 ++++++++ 4 files changed, 37 insertions(+), 10 deletions(-) diff --git a/home/page/event_updates/event_updates.js b/home/page/event_updates/event_updates.js index 834e887a1c..9aa3da244a 100644 --- a/home/page/event_updates/event_updates.js +++ b/home/page/event_updates/event_updates.js @@ -431,8 +431,8 @@ FeedList.prototype.make_head = function() { // head $a(this.head,'h1','', {display:'inline'}, 'Home'); - $a(this.head,'span','link_type', {marginLeft:'7px'}, '[?]', function() { - msgprint('What appears here? This is where you get updates of everything you are allowed to access and generates an update') + $a(this.head,'span','link_type', {marginLeft:'7px'}, 'help', function() { + msgprint('What appears here? This is where you get updates of everything you are permitted to follow') }) // refresh @@ -440,6 +440,11 @@ FeedList.prototype.make_head = function() { {cursor:'pointer', marginLeft:'7px', fontSize:'11px'}, 'refresh', function() { me.run(); } ); + + if(has_common(user_roles, ['System Manager','Accounts Manager'])) { + $btn(this.head, 'Dashboard', function() {loadpage('dashboard'); }, {marginLeft:'7px'}) + + } } FeedList.prototype.run = function() { @@ -589,14 +594,15 @@ HomeStatusBar = function() { this.render = function(r) { this.wrapper.innerHTML = ''; - this.span = $a(this.wrapper, 'span', 'home-status-link') + this.span = $a(this.wrapper, 'span', 'link_type', {fontWeight:'bold'}); this.span.onclick = function() { loadpage('My Company') } if(r.unread_messages) { - this.span.innerHTML = '' + r.unread_messages + ' unread message' + (cint(r.unread_messages) > 1 ? 's' : ''); + this.span.innerHTML = '' + r.unread_messages + ' unread'; } else { - this.span.innerHTML = 'No unread messages.'; + this.span.innerHTML = 'Team / Messages'; } + } } diff --git a/knowledge_base/page/kb_common/kb_common.js b/knowledge_base/page/kb_common/kb_common.js index 1826f05cc0..3e17b6f7b9 100644 --- a/knowledge_base/page/kb_common/kb_common.js +++ b/knowledge_base/page/kb_common/kb_common.js @@ -19,12 +19,25 @@ KBItemToolbar = function(args, kb) { this.line1.innerHTML = repl('By %(name)s | %(when)s', { name: wn.utils.full_name(this.det.first_name, this.det.last_name), when: wn.datetime.comment_when(this.det.modified) - }) + }); + + // 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.make_vote = function() { new KBPoints(this.line2, 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() { diff --git a/knowledge_base/page/question_view/question_view.js b/knowledge_base/page/question_view/question_view.js index ed11efce8b..422fb30229 100644 --- a/knowledge_base/page/question_view/question_view.js +++ b/knowledge_base/page/question_view/question_view.js @@ -128,7 +128,7 @@ KBAnswerList = function(args) { as_dict: 1, no_results_message: 'No answers yet, be the first one to answer!', render_row: function(body, data) { - new KBAnswer(body, data) + 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, " @@ -150,7 +150,7 @@ KBAnswerList = function(args) { // answer // by xxx | on xxx // points yyy -KBAnswer = function(body, data) { +KBAnswer = function(body, data, ans_list) { body.className = 'qv-answer'; new EditableText({ parent: body, @@ -169,7 +169,7 @@ KBAnswer = function(body, data) { det: data, with_tags: 0, doctype: 'Answer' - }, null) + }, ans_list) } diff --git a/knowledge_base/page/questions/questions.py b/knowledge_base/page/questions/questions.py index cbb6a252cf..5f8b209fe2 100644 --- a/knowledge_base/page/questions/questions.py +++ b/knowledge_base/page/questions/questions.py @@ -35,3 +35,11 @@ def vote(arg): (p, cstr(res[1]) + ',' + webnotes.user.name, args['dn'])) return p + +def delete(arg): + """ + delete a question or answer (called from kb toolbar) + """ + args = load_json(arg) + from webnotes.model import delete_doc + delete_doc(args['dt'], args['dn']) \ No newline at end of file