updated items controller and graphsettings to allow in-place editing of the description on cards. Pretty cool

This commit is contained in:
Devin Howard 2013-01-01 23:57:32 -05:00
parent 72b904b3f0
commit 4c8c7d272a
2 changed files with 28 additions and 20 deletions

View file

@ -116,7 +116,8 @@ function graphSettings(type) {
'<img alt="' + node.getData("metacode") + '" class="icon" height="50" src="' + imgArray[node.getData("metacode")].src + '" width="50" />' +
'<div class="scroll"><a href="/topics/' + node.id + '" class="title">' + node.name + '</a>' +
'<div class="contributor">Added by: <a href="/users/' + node.getData('userid') + '">' + node.getData('username') + '</a></div>' +
'<div class="desc"><p>' + node.getData('desc') + '</p></div></div>' +
//'<div class="desc"><p>' + node.getData('desc') + '</p></div></div>' +
'<div class="desc best_in_place" id="best_in_place_desc" data-url="/topics/' + node.id + '" data-object="topic" data-attribute="desc" data-type="input">' + node.getData('desc') + '.' + '</div></div>' +
'<a href="' + node.getData('link') + '" class="link" target="_blank">' + node.getData('link') + '</a></div>';
var showCard = document.createElement('div');
showCard.className = 'showcard topic_' + node.id;
@ -139,10 +140,10 @@ function graphSettings(type) {
modes: ['edge-property:lineWidth:color'],
duration: 500
});
$('.showcard.topic_' + node.id).fadeOut('fast', function(){
$('.name').css('display','block');
Mconsole.plot();
});
// $('.showcard.topic_' + node.id).fadeOut('fast', function(){
// $('.name').css('display','block');
// Mconsole.plot();
// });
}
// Create a 'name' button and add it
@ -298,7 +299,8 @@ function graphSettings(type) {
'<img alt="' + node.getData("metacode") + '" class="icon" height="50" src="' + imgArray[node.getData("metacode")].src + '" width="50" />' +
'<div class="scroll"><a href="/topics/' + node.id + '" class="title">' + node.name + '</a>' +
'<div class="contributor">Added by: <a href="/users/' + node.getData('userid') + '">' + node.getData('username') + '</a></div>' +
'<div class="desc"><p>' + node.getData('desc') + '</p></div></div>' +
//'<div class="desc"><p>' + node.getData('desc') + '</p></div></div>' +
'<div class="desc best_in_place" id="best_in_place_desc" data-url="/topics/' + node.id + '" data-object="topic" data-attribute="desc" data-type="input">' + node.getData('desc') + '.' + '</div></div>' +
'<a href="' + node.getData('link') + '" class="link" target="_blank">' + node.getData('link') + '</a></div>';
var showCard = document.createElement('div');
showCard.className = 'showcard topic_' + node.id;
@ -322,10 +324,10 @@ function graphSettings(type) {
modes: ['edge-property:lineWidth:color'],
duration: 500
});
$('.showcard.topic_' + node.id).fadeOut('fast', function(){
$('.name').css('display','block');
Mconsole.plot();
});
// $('.showcard.topic_' + node.id).fadeOut('fast', function(){
// $('.name').css('display','block');
// Mconsole.plot();
// });
}
}
@ -623,4 +625,4 @@ function clickDragOnTopic(node, eventInfo, e) {
}
}
}
}
}

View file

@ -124,18 +124,24 @@ class TopicsController < ApplicationController
@topic = Topic.find(params[:id]).authorize_to_edit(@current)
if @topic
@topic.name = params[:topic][:name]
@topic.desc = params[:topic][:desc]
@topic.link = params[:topic][:link]
@topic.permission = params[:topic][:permission]
@topic.metacode = Metacode.find(params[:category][:metacode_id])
if params[:topic]
@topic.name = params[:topic][:name] if params[:topic][:name]
@topic.desc = params[:topic][:desc] if params[:topic][:desc]
@topic.link = params[:topic][:link] if params[:topic][:link]
@topic.permission = params[:topic][:permission] if params[:topic][:permission]
end
if params[:category]
@topic.metacode = Metacode.find(params[:category][:metacode_id]) if params[:category][:metacode_id]
end
@topic.save
end
end
respond_with @topic
respond_with(@user, location: topic_url(@topic)) do |format|
end
# respond_with(@user, location: topic_url(@topic)) do |format|
# end
end
# DELETE topics/:id
def destroy
@current = current_user