track forks

This commit is contained in:
Connor Turland 2016-12-18 14:18:58 -05:00
parent 33fc27ffd1
commit 2beaa2e5be
5 changed files with 12 additions and 2 deletions

View file

@ -124,7 +124,7 @@ class MapsController < ApplicationController
end
def create_map_params
params.permit(:name, :desc, :permission)
params.permit(:name, :desc, :permission, :source_id)
end
def update_map_params

View file

@ -1,6 +1,7 @@
# frozen_string_literal: true
class Map < ApplicationRecord
belongs_to :user
belongs_to :source, class_name: :Map
has_many :topicmappings, -> { Mapping.topicmapping }, class_name: :Mapping, dependent: :destroy
has_many :synapsemappings, -> { Mapping.synapsemapping }, class_name: :Mapping, dependent: :destroy

View file

@ -0,0 +1,5 @@
class AddSourceToMaps < ActiveRecord::Migration[5.0]
def change
add_reference :maps, :source, foreign_key: {to_table: :maps}
end
end

View file

@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20161216174257) do
ActiveRecord::Schema.define(version: 20161218183817) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -151,6 +151,8 @@ ActiveRecord::Schema.define(version: 20161216174257) do
t.string "screenshot_content_type", limit: 255
t.integer "screenshot_file_size"
t.datetime "screenshot_updated_at"
t.integer "source_id"
t.index ["source_id"], name: "index_maps_on_source_id", using: :btree
t.index ["user_id"], name: "index_maps_on_user_id", using: :btree
end
@ -340,5 +342,6 @@ ActiveRecord::Schema.define(version: 20161216174257) do
add_foreign_key "mailboxer_notifications", "mailboxer_conversations", column: "conversation_id", name: "notifications_on_conversation_id"
add_foreign_key "mailboxer_receipts", "mailboxer_notifications", column: "notification_id", name: "receipts_on_notification_id"
add_foreign_key "mappings", "users", column: "updated_by_id"
add_foreign_key "maps", "maps", column: "source_id"
add_foreign_key "tokens", "users"
end

View file

@ -61,6 +61,7 @@ const CreateMap = {
if (GlobalUI.lightbox === 'forkmap') {
self.newMap.set('topicsToMap', self.topicsToMap)
self.newMap.set('synapsesToMap', self.synapsesToMap)
self.newMap.set('source_id', Active.Map.id)
}
var formId = GlobalUI.lightbox === 'forkmap' ? '#fork_map' : '#new_map'