From c35e2a486057e5eb8a1fe72c62a36dcb89216d66 Mon Sep 17 00:00:00 2001 From: zmagod Date: Mon, 15 May 2017 09:54:37 +0200 Subject: [PATCH] adds persistence to experiments order in project overview [fixes SCI-974] --- app/controllers/projects_controller.rb | 7 ++++++- ...15073041_add_experiments_order_to_projects.rb | 5 +++++ db/schema.rb | 16 ++++++++++------ 3 files changed, 21 insertions(+), 7 deletions(-) create mode 100644 db/migrate/20170515073041_add_experiments_order_to_projects.rb diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 7f5ebb68d..e65ae93e0 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -251,9 +251,14 @@ class ProjectsController < ApplicationController end def show + # save experiments order + if params[:sort] + @project.experiments_order = params[:sort].to_s + @project.save + end # This is the "info" view current_team_switch(@project.team) - @current_sort = params[:sort].to_s + @current_sort = @project.experiments_order end def notifications diff --git a/db/migrate/20170515073041_add_experiments_order_to_projects.rb b/db/migrate/20170515073041_add_experiments_order_to_projects.rb new file mode 100644 index 000000000..173f0a271 --- /dev/null +++ b/db/migrate/20170515073041_add_experiments_order_to_projects.rb @@ -0,0 +1,5 @@ +class AddExperimentsOrderToProjects < ActiveRecord::Migration + def change + add_column :projects, :experiments_order, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 98b5bc403..a47b3aefc 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170420075905) do +ActiveRecord::Schema.define(version: 20170515073041) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -21,14 +21,16 @@ ActiveRecord::Schema.define(version: 20170420075905) do create_table "activities", force: :cascade do |t| t.integer "my_module_id" t.integer "user_id" - t.integer "type_of", null: false - t.string "message", null: false - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.integer "project_id", null: false + t.integer "type_of", null: false + t.string "message", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.integer "project_id", null: false + t.integer "experiment_id" end add_index "activities", ["created_at"], name: "index_activities_on_created_at", using: :btree + add_index "activities", ["experiment_id"], name: "index_activities_on_experiment_id", using: :btree add_index "activities", ["my_module_id"], name: "index_activities_on_my_module_id", using: :btree add_index "activities", ["project_id"], name: "index_activities_on_project_id", using: :btree add_index "activities", ["type_of"], name: "index_activities_on_type_of", using: :btree @@ -249,6 +251,7 @@ ActiveRecord::Schema.define(version: 20170420075905) do t.integer "archived_by_id" t.integer "restored_by_id" t.datetime "restored_on" + t.string "experiments_order" end add_index "projects", ["archived_by_id"], name: "index_projects_on_archived_by_id", using: :btree @@ -718,6 +721,7 @@ ActiveRecord::Schema.define(version: 20170420075905) do add_index "zip_exports", ["user_id"], name: "index_zip_exports_on_user_id", using: :btree + add_foreign_key "activities", "experiments" add_foreign_key "activities", "my_modules" add_foreign_key "activities", "projects" add_foreign_key "activities", "users"