Carga anotaciones de la propuesta

This commit is contained in:
Abigail Sosa
2015-11-18 09:01:56 -07:00
committed by rgarcia
parent cf8a952b0b
commit e2f6950dc4
3 changed files with 19 additions and 5 deletions

View File

@@ -8,8 +8,12 @@ proposalId = ->
App.annotations =
initialize: ->
new annotator.App()
.include(annotator.ui.main, {element: $(proposalSelector)[0]})
.include(annotator.storage.http, {id: 1, prefix: ""})
app = new annotator.App()
.include(annotator.ui.main, { element: $(proposalSelector)[0] })
.include(annotator.storage.http, { prefix: "", urls: { search: "/annotations/search" } })
.include(proposalId)
.start();
app.start()
.then( ->
app.annotations.load( { proposal_id: $(proposalSelector).data("id") } )
)

View File

@@ -22,6 +22,12 @@ class AnnotationsController < ApplicationController
render json: { status: :ok }
end
def search
@annotations = Annotation.where(proposal_id: params[:proposal_id])
annotations_hash = { total: @annotations.size, rows: @annotations }
render json: annotations_hash.to_json
end
private
def annotation_params

View File

@@ -61,7 +61,11 @@ Rails.application.routes.draw do
end
end
resources :annotations
resources :annotations do
collection do
get :search
end
end
resources :users, only: [:show]