editing of posts using new post window

v1.18.x
Julian Lam 12 years ago
parent 061c7a9e66
commit 82736d8780

@ -43,14 +43,14 @@ define(function() {
socket.on('api:composer.push', function(threadData) { socket.on('api:composer.push', function(threadData) {
var uuid = utils.generateUUID(), var uuid = utils.generateUUID(),
btnEl = document.createElement('li'); btnEl = document.createElement('li');
btnEl.innerHTML = '<a href="#"><img src="/graph/users/' + threadData.username + '/picture" /><span>' + threadData.title + '</span></a>'; btnEl.innerHTML = '<a href="#"><img src="/graph/users/' + threadData.username + '/picture" /><span>' + (!threadData.cid ? (threadData.title || '') : 'New Topic') + '</span></a>';
btnEl.setAttribute('data-uuid', uuid); btnEl.setAttribute('data-uuid', uuid);
composer.listEl.appendChild(btnEl); composer.listEl.appendChild(btnEl);
composer.posts[uuid] = { composer.posts[uuid] = {
tid: threadData.tid, tid: threadData.tid,
cid: threadData.cid, cid: threadData.cid,
pid: threadData.pid, pid: threadData.pid,
title: threadData.tid ? threadData.title : '', title: threadData.title || '',
body: threadData.body || '' body: threadData.body || ''
}; };
composer.active++; composer.active++;
@ -170,6 +170,7 @@ define(function() {
titleEl.value = 'Replying to: ' + post_data.title; titleEl.value = 'Replying to: ' + post_data.title;
titleEl.readonly = true; titleEl.readonly = true;
} else if (post_data.pid > 0) { } else if (post_data.pid > 0) {
console.log(post_data);
titleEl.value = 'Editing: ' + post_data.title; titleEl.value = 'Editing: ' + post_data.title;
titleEl.readonly = true; titleEl.readonly = true;
} else { } else {
@ -180,6 +181,8 @@ define(function() {
// Highlight the button // Highlight the button
$('.posts-bar li').removeClass('active'); $('.posts-bar li').removeClass('active');
composer.btnContainer.querySelector('[data-uuid="' + post_uuid + '"]').className += ' active'; composer.btnContainer.querySelector('[data-uuid="' + post_uuid + '"]').className += ' active';
//
} }
composer.post = function(post_uuid) { composer.post = function(post_uuid) {
@ -198,7 +201,7 @@ define(function() {
} }
// Still here? Let's post. // Still here? Let's post.
if (postData.tid === 0 || postData.cid) { if (parseInt(postData.cid) > 0) {
socket.emit('api:topics.post', { socket.emit('api:topics.post', {
'title' : titleEl.value, 'title' : titleEl.value,
'content' : bodyEl.value, 'content' : bodyEl.value,
@ -209,6 +212,12 @@ define(function() {
'topic_id' : postData.tid, 'topic_id' : postData.tid,
'content' : bodyEl.value 'content' : bodyEl.value
}); });
} else if (parseInt(postData.pid) > 0) {
socket.emit('api:posts.edit', {
pid: postData.pid,
content: bodyEl.value,
title: titleEl.value
});
} }
composer.discard(post_uuid); composer.discard(post_uuid);

@ -319,7 +319,7 @@ var SocketIO = require('socket.io').listen(global.server, { log:false }),
tid: 0, tid: 0,
cid: data.cid, cid: data.cid,
username: username, username: username,
title: 'New Topic' title: undefined
}); });
}); });
} else if (parseInt(data.pid) > 0) { } else if (parseInt(data.pid) > 0) {

Loading…
Cancel
Save