Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

E1786. Bookmark Code Fix #1039

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 9 additions & 5 deletions app/controllers/bookmarks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,16 @@ def create
params[:url] = params[:url].gsub!(/http:\/\//, "") if params[:url].start_with?('http://')
params[:url] = params[:url].gsub!(/https:\/\//, "") if params[:url].start_with?('https://')
begin
Bookmark.create(url: params[:url], title: params[:title], description: params[:description], user_id: session[:user].id, topic_id: params[:topic_id])
flash[:success] = 'Your bookmark has been successfully created!'
rescue
flash[:error] = $ERROR_INFO
@bookmark = Bookmark.create(url: params[:url], title: params[:title], description: params[:description],
user_id: session[:user].id, topic_id: params[:topic_id])
if @bookmark.save # we are making sure its gets saved else we display the error
flash[:success] = 'Your bookmark has been successfully created!'
redirect_to action: 'list', id: params[:topic_id]
else
flash[:error] = 'Error while creating the bookmark. Please make sure you entered data in all Fields'
redirect_to action: 'new', id: params[:topic_id]
end
end
redirect_to action: 'list', id: params[:topic_id]
end

def edit
Expand Down
4 changes: 1 addition & 3 deletions app/views/bookmarks/list.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,7 @@

<br />

<%= link_to 'New bookmark', :action => 'new', :id => @topic.id %> |
<%= link_to 'Back', :controller=> 'sign_up_sheet', :action=>'list', :assignment_id => @topic.assignment_id %>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain why you remove the back link?


<%= link_to 'New bookmark', :action => 'new', :id => @topic.id %> |<a href="javascript:history.back()">Back</a>
<script>
var bookmark_ids = <%=@bookmark_ids%>;
bookmark_ids.forEach(function(bookmark_id){
Expand Down
3 changes: 1 addition & 2 deletions app/views/bookmarks/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
<%= text_area_tag :description %><br/>
</p>
<p>
<td> <%= submit_tag "Add new bookmark" %> |
<%= link_to 'Back', :controller=> 'sign_up_sheet', :action=>'list', :assignment_id => @topic.assignment_id %></td>
<td> <%= submit_tag "Add new bookmark" %> | <a href="javascript:history.back()">Back</a></td>
</p>
<% end %>

Expand Down
12 changes: 7 additions & 5 deletions app/views/sign_up_sheet/_actions.html.erb
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
<%= link_to :controller=>'bookmarks', :action=> 'list', :id => topic.id do %>
<span class="fa-stack fa-md" title='View topic bookmarks'>
<% if @assignment.use_bookmark == true %> # checking whether to display bookmark actions or not
<%= link_to :controller=>'bookmarks', :action=> 'list', :id => topic.id do %>
<span class="fa-stack fa-md" title='View topic bookmarks'>
<i class="fa fa-bookmark fa-stack-1x fa-2x"></i>
</span>
<% end %>
<%= link_to :controller=>'bookmarks', :action=> 'new', :id => topic.id , :assignment_id => params[:assignment_id] do %>
<span class="fa-stack fa-md" title='Add bookmark to topic'>
<% end %>
<%= link_to :controller=>'bookmarks', :action=> 'new', :id => topic.id , :assignment_id => params[:assignment_id] do %>
<span class="fa-stack fa-md" title='Add bookmark to topic'>
<i class="fa fa-bookmark fa-stack-1x fa-2x"></i>
<i class="fa fa-plus fa-stack-1x fa-inverse" style='font-size: .5em'></i>
</span>
<% end %>
<% end %>

<%= render :partial => '/sign_up_sheet/all_actions', :locals => {:i=>i, :topic=>topic, :is_suggested_topic=>is_suggested_topic} %>
Expand Down