Skip to content

Commit

Permalink
add nested keyword attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
mjy committed Oct 13, 2017
1 parent b984aed commit 7d978a9
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 16 deletions.
1 change: 0 additions & 1 deletion Gemfile
Expand Up @@ -57,7 +57,6 @@ gem 'jquery-rails', '~> 4.3.1'
gem 'jquery-ui-rails', '~> 6.0.1'
gem 'rails-jquery-autocomplete', '~> 1.0.3'

# TODO: New version of turbolinks is major fail, Hold for further investigation
gem 'turbolinks', '~> 5.0.1'
gem 'jquery-turbolinks', '~> 2.1'

Expand Down
12 changes: 10 additions & 2 deletions app/controllers/data_attributes_controller.rb
Expand Up @@ -6,8 +6,16 @@ class DataAttributesController < ApplicationController
# GET /data_attributes
# GET /data_attributes.json
def index
@recent_objects = DataAttribute.where(project_id: sessions_current_project_id).order(updated_at: :desc).limit(10)
render '/shared/data/all/index'
respond_to do |format|
format.html {
@recent_objects = DataAttribute.where(project_id: sessions_current_project_id).order(updated_at: :desc).limit(10)
render '/shared/data/all/index'
}
format.json {
DataAttributes.where(project_id: sessions_current_project_id).where(

)
}
end

# GET /data_attributes/new
Expand Down
5 changes: 3 additions & 2 deletions app/controllers/notes_controller.rb
Expand Up @@ -14,7 +14,7 @@ def index
}
format.json {
@notes = Note.where(project_id: sessions_current_project_id).where(
polymorphic_filter_params('note_object', [
polymorphic_filter_params('note_object', [ # TODO: this has to be made into a method
:observation_id,
:otu_id,
:descriptor_id,
Expand Down Expand Up @@ -69,7 +69,8 @@ def update
def destroy
@note.destroy
respond_to do |format|
format.html {redirect_back(fallback_location: (request.referer || root_path), notice: 'Note was successfully destroyed.')}
# TODO: probably needs to be changed
format.html { redirect_back(fallback_location: (request.referer || root_path), notice: 'Note was successfully destroyed.')}
format.json { head :no_content }
end
end
Expand Down
5 changes: 4 additions & 1 deletion app/controllers/tags_controller.rb
Expand Up @@ -132,7 +132,10 @@ def set_tag
end

def tag_params
params.require(:tag).permit(:keyword_id, :tag_object_id, :tag_object_type, :tag_object_attribute, :tag_object_global_entity)
params.require(:tag).permit(
:keyword_id, :tag_object_id, :tag_object_type, :tag_object_attribute, :tag_object_global_entity, :_destroy,
keyword_attributes: [:name, :definition, :uri, :uri_relation, :css_color]
)
end

def taggable_object_params
Expand Down
2 changes: 1 addition & 1 deletion app/models/concerns/shared/taggable.rb
Expand Up @@ -21,7 +21,7 @@ def identical_new_keywords_are_prevented
a = []
tags.each do |t|
errors.add(:base, 'identical keyword attempt') if a.include?({:id => t.keyword.id, :name => t.keyword.name, :definition => t.keyword.definition})
# t.keyword.attributes cannot be used, because the updated_at is truncated after save. The date is returned in different format.
# t.keyword.attributes cannot be used, because the updated_at is truncated after save. The date is returned in different format.
a.push ({:id => t.keyword.id, :name => t.keyword.name, :definition => t.keyword.definition})
end
end
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Expand Up @@ -21,14 +21,14 @@ services:
- "0.0.0.0:15432:5432"
volumes:
- pg:/var/lib/postgresql/data
- ./volumes/webpack_build:/mnt/rails/public/webpack
webpack:
build:
context: .
dockerfile: Dockerfile.development
command: bash -c "yarn && /app/bin/webpack-dev-server --host 0.0.0.0"
volumes:
- .:/app
- ./volumes/webpack_build:/mnt/rails/public/webpack
ports:
- '3808:3808'
volumes:
Expand Down
15 changes: 7 additions & 8 deletions exe/docker_compose_start.sh
Expand Up @@ -28,14 +28,13 @@ if [ ! -f /app/config/secrets.yml ]; then
cp /app/config/secrets.yml.example /app/config/secrets.yml
fi

if echo "\c db; \dt" | psql | grep schema_migrations 2>&1 >/dev/null
then
bundle exec rake db:migrate
echo "Done migration successfully"
else
printf "\n\n !!!!!!!!!! Building a new taxonworks_development database !!!!!!!!!! \n\n "
bundle exec rake db:create
fi
if echo "\c db; \dt" | psql -u | grep schema_migrations 2>&1 >/dev/null; then
bundle exec rake db:migrate
echo "Done migration successfully"
else
printf "\n\n !!!!!!!!!! Building a new taxonworks_development database !!!!!!!!!! \n\n "
bundle exec rake db:create
fi

# if bundle exec rake db:migrate RAILS_ENV=development; then

Expand Down

0 comments on commit 7d978a9

Please sign in to comment.