You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Given a thread with 4 topics (A, B, C, D) when the first topic (A) while editing-updating a thread:
Also the last topic (D) is removed.
Areas in topic A and B are removed.
Areas in topic C are converted to topic B; Areas in topic D are converted to topic C.
I made a test thread to see this behavior. To make it easier the thread I have just one day coded, where the full front page is assigned to a topic that has the name of that very same newspaper.
Original thread:
Thread after removing first topic:
I repeated the process with 5 topics with the same results:
When the first topic (A) is removed while editing-updating a thread, also the last one (E) is removed.
Areas in topic A and B are removed.
Areas in topic C are converted to topic B; Areas in topic D are converted to topic C; Areas in topic E are converted to topic D.
It is used with this javascript /app/assets/javascripts/topic_form.js script to detect where the click happens and change the id of the topic with a particular index:
var initDelete = function () {
$('.delete_topic').unbind('click');
$('.delete_topic').click(function () {
var index = $(this).attr('id').substr('delete_topic_'.length);
$("#topic_deleted_" + index).val('1');
$("#topic_" + index).hide();
});
}
When you click in a delete topic button value="1" is added: <input id="topic_deleted_0" name="topic_deleted_0" type="hidden" value="1">
# Fetch existing code from database by id and update
code = @thread.codes.find_by_id(id)
if params["topic_deleted_#{index}"] == '1'
code.destroy()
else
It seems there is a problem with the selection of these topics ids.
The text was updated successfully, but these errors were encountered:
# New code
else
# Fetch existing code from database by id and update
code = @thread.codes.find_by_id(id)
if params["topic_deleted_#{index}"] == '1'
code.destroy()
else
unless code_name.empty?
code.update_attributes({code_text: code_name,
color: params["topic_color_#{index}"],
code_description: params["topic_description_#{index}"]})
end
end
@thread.codes.to_enum.with_index.each do |code,index|
code_name = params["topic_name_#{index}"]
if params["topic_deleted_#{index}"] == '1'
code.destroy()
else #To Do: it should save the new codes created
unless code_name.empty?
code.update_attributes({code_text: code_name,
color: params["topic_color_#{index}"],
code_description: params["topic_description_#{index}"]})
end
end
end
fixes it. It seems there are two codes making a similar/same thing and causes the removal of two codes (not clear to me exactly why). Check #61, maybe relevant related info.
I had forked a thread (http://pageonex.com/numeroteca/partidos-y-elecciones-20d/ to http://pageonex.com/numeroteca/partidos-y-elecciones-20d/) to rework one of the topics. I needed to erase all but one of the topics and I discover these bugs (I'll update this when I find more problems or can give specifics):
Given a thread with 4 topics (A, B, C, D) when the first topic (A) while editing-updating a thread:
I made a test thread to see this behavior. To make it easier the thread I have just one day coded, where the full front page is assigned to a topic that has the name of that very same newspaper.
Original thread:
Thread after removing first topic:
I repeated the process with 5 topics with the same results:
What is causing this problem?
From the topic template (/app/views/threads/_topic_form.html.erb) the delete topic button is formed with the class
.delete_topic
:It is used with this javascript /app/assets/javascripts/topic_form.js script to detect where the click happens and change the id of the topic with a particular index:
When you click in a delete topic button
value="1"
is added:<input id="topic_deleted_0" name="topic_deleted_0" type="hidden" value="1">
so the ruby script /app/controllers/threads_controller.rb is able to detect this and destroy the Topic (called
code
in the project):It seems there is a problem with the selection of these topics ids.
The text was updated successfully, but these errors were encountered: