fix to kb, delete question, ans

This commit is contained in:
Rushabh Mehta 2011-08-30 15:37:46 +05:30
parent 385a3792e1
commit e3393bead9
4 changed files with 37 additions and 10 deletions

View File

@ -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('<b>What appears here?</b> 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('<b>What appears here?</b> 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 = '<span class="home-status-unread">' + r.unread_messages + '</span> unread message' + (cint(r.unread_messages) > 1 ? 's' : '');
this.span.innerHTML = '<span class="home-status-unread">' + r.unread_messages + '</span> unread';
} else {
this.span.innerHTML = 'No unread messages.';
this.span.innerHTML = 'Team / Messages';
}
}
}

View File

@ -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() {

View File

@ -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)
}

View File

@ -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'])