Class: ActsAsContentHighlightable::ContentHighlightsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ActsAsContentHighlightable::ContentHighlightsController
- Defined in:
- app/controller/acts_as_content_highlightable/content_highlights_controller.rb
Instance Method Summary collapse
Instance Method Details
#add ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/controller/acts_as_content_highlightable/content_highlights_controller.rb', line 6 def add if @highlightable.present? content_highlight = @highlightable.content_highlights.new({ :user => @highlighter_user, :highlightable_column => @highlightable.highlightable_column, :content => params[:content], :container_node_identifier_key => params[:common_ancestor_identifier_key], :container_node_identifier => params[:common_ancestor_identifier], :container_node_type => params[:common_ancestor_node_type], :startnode_offset => params[:start_offset], :endnode_offset => params[:end_offset], :selection_backward => params[:backward] }) content_highlight.save show_highlights = ContentHighlight.highlights_to_show(@highlightable, @highlighter_user, {request: request}).enrich_highlights(@highlighter_user) else show_highlights = Array.new end render :json => show_highlights.as_json end |
#remove ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'app/controller/acts_as_content_highlightable/content_highlights_controller.rb', line 27 def remove content_highlight = @highlightable.content_highlights.where(:id => params[:content_highlight_id]).first if content_highlight.present? and (content_highlight.user == @highlighter_user) remove_highlights = @highlightable.content_highlights.where(:id => content_highlight.id).enrich_highlights(@highlighter_user).as_json content_highlight.destroy else remove_highlights = Array.new end render :json => remove_highlights end |