Commit dd678d00 authored by hh1966's avatar hh1966
Browse files

Fix tables schemas in research plan detail

parent 0b16e22d
......@@ -69,6 +69,41 @@ module Chemotion
research_plan
end
namespace :table_schemas do
desc "Return serialized table schemas of current user"
get do
{ table_schemas: ResearchPlanTableSchema.where( creator: current_user)}
end
desc "Save table schema"
params do
requires :name, type: String
requires :value, type: Hash
end
post do
attributes = {
name: params[:name],
value: params[:value]
}
table_schema = ResearchPlanTableSchema.new attributes
table_schema.creator = current_user
table_schema.save!
table_schema
end
desc "Delete table schema"
route_param :id do
before do
error!('401 Unauthorized', 401) unless TableSchemaPolicy.new(current_user, ResearchPlanTableSchema.find(params[:id])).destroy?
end
delete do
ResearchPlanTableSchema.find(params[:id]).destroy
end
end
end
desc "Return serialized research plan by id"
params do
requires :id, type: Integer, desc: "Research plan id"
......@@ -186,42 +221,6 @@ module Chemotion
end
end
end
namespace :table_schemas do
desc "Return serialized table schemas of current user"
get do
{ table_schemas: ResearchPlanTableSchema.where( creator: current_user)}
end
desc "Save table schema"
params do
requires :name, type: String
requires :value, type: Hash
end
post do
attributes = {
name: params[:name],
value: params[:value]
}
table_schema = ResearchPlanTableSchema.new attributes
table_schema.creator = current_user
table_schema.save!
table_schema
end
desc "Delete table schema"
route_param :id do
before do
error!('401 Unauthorized', 401) unless TableSchemaPolicy.new(current_user, ResearchPlanTableSchema.find(params[:id])).destroy?
end
delete do
ResearchPlanTableSchema.find(params[:id]).destroy
end
end
end
end
end
end
......@@ -159,7 +159,11 @@ export default class ResearchPlansFetcher {
'Content-Type': 'application/json'
}
}).then(response => {
return response.json()
if (response.ok) {
return response.json()
} else {
console.log(response)
}
}).catch((errorMessage) => {
console.log(errorMessage)
})
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment