disabled awkward panning and zooming bugs by editing jit code

This commit is contained in:
Connor Turland 2013-01-05 16:21:11 -05:00
parent 8260fdf7e0
commit e5076533c0
8 changed files with 450 additions and 424 deletions

View file

@ -57,7 +57,7 @@ function graphSettings(type) {
},
//Update node positions when dragged
onDragMove: function (node, eventInfo, e) {
clickDragOnTopic(node, eventInfo, e);
clickDragOnTopic(node, eventInfo, e);
},
onDragEnd: function() {
if (tempInit && tempNode2 == null) {
@ -196,7 +196,7 @@ function graphSettings(type) {
},
//Update node positions when dragged
onDragMove: function (node, eventInfo, e) {
clickDragOnTopic(node, eventInfo, e);
clickDragOnTopic(node, eventInfo, e);
},
onDragEnd: function() {
if (tempInit && tempNode2 == null) {
@ -557,7 +557,6 @@ function onCreateLabelHandler(domElement, node) {
height="50" \
width="50" \
src="$_imgsrc_$" /> \
<div class="scroll"> \
<span class="title"> \
<span class="best_in_place best_in_place_name" \
data-url="/topics/$_id_$" \
@ -575,6 +574,7 @@ function onCreateLabelHandler(domElement, node) {
Added by: <a href="/users/$_userid_$" target="_blank">$_username_$ \
</a> \
</div> \
<div class="scroll"> \
<div class="desc"> \
<span class="best_in_place best_in_place_desc" \
data-url="/topics/$_id_$" \
@ -593,6 +593,7 @@ function onCreateLabelHandler(domElement, node) {
data-object="topic" \
data-attribute="link" \
data-type="input">$_link_$</span>$_close_a_tag_$ \
<div class="clearfloat"></div> \
</div>';
//link is rendered differently if user is logged out or in

View file

@ -2585,6 +2585,9 @@ Extras.Classes.Navigation = new Class({
onMouseWheel: function(e, win, scroll) {
if(!this.config.zooming) return;
// START METAMAPS CODE
if (e.target.id != 'infovis-canvas') return;
// END METAMAPS CODE
$.event.stop($.event.get(e, win));
var val = this.config.zooming / 1000,
ans = 1 + scroll * val;
@ -2611,6 +2614,12 @@ Extras.Classes.Navigation = new Class({
if(!this.config.panning) return;
if(!this.pressed) return;
if(this.config.panning == 'avoid nodes' && eventInfo.getNode()) return;
// START METAMAPS CODE
if (e.target.id != 'infovis-canvas') {
this.pressed = false;
return;
}
// END METAMAPS CODE
var thispos = this.pos,
currentPos = eventInfo.getPos(),
canvas = this.canvas,

View file

@ -33,6 +33,7 @@ var labelType, useGradients, nativeTextSupport, animate, json, Mconsole = null,
$('#topic_name').bind('railsAutocomplete.select', function(event, data){
if (data.item.id != undefined) {
$('#topic_grabTopic').val(data.item.id);
$('.new_topic').submit();
}
});

View file

@ -127,27 +127,19 @@
return false;
});
// Add code that makes up and down arrows scroll through.
$('.new_topic').bind('keydown keypress',this,function(event) {
//console.log(event)
if (event.keyCode == 38 || event.keyCode == 40)
{
//e.preventDefault();
// Add code that makes tab and shift+tab scroll through metacodes
$('.new_topic').bind('keydown',this,function(event){
if (event.keyCode == 9 || (event.keyCode == 9 && event.shiftKey)) {
event.preventDefault();
}
});
$('.new_topic').bind('keyup',this,function(event){
console.log(event);
//console.log(event);
/*key navigation through elements*/
if (event.keyCode == 38 || event.keyCode == 40) {
switch ( event.keyCode ) {
case 38: // Up
event.data.rotate(-1);
break;
case 40: // Down
event.data.rotate(1);
break;
}
return;
if (event.keyCode == 9 && event.shiftKey) {
event.data.rotate(-1);
} else if (event.keyCode == 9) {
event.data.rotate(1);
}
});

View file

@ -44,7 +44,7 @@
.CardOnGraph .scroll {
display:block;
height:283px;
height:232px;
}
.CardOnGraph .type {
@ -71,6 +71,15 @@
padding-bottom:5px;
}
.CardOnGraph .best_in_place_name {
max-width:130px;
float:left;
}
.CardOnGraph .best_in_place_name input{
max-width:130px;
}
.CardOnGraph .desc {
font-size:15px;
font-family:Arial, Helvetica, sans-serif;
@ -81,28 +90,47 @@
margin-top:5px;
}
.CardOnGraph .link {
position:absolute;
width:170px;
top:295px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.CardOnGraph .best_in_place_desc {
width:160px;
height:180px;
display:block;
margin-top:2px;
}
.CardOnGraph .best_in_place_desc input {
float: right;
margin: 2px 0px 0px 2px;
padding: 1px 5px;
}
.CardOnGraph .best_in_place_desc {
width:140px;
display:block;
margin-top:2px;
}
.CardOnGraph .best_in_place_desc input[value="Save"] {
margin-right: -8px;
}
.CardOnGraph .link {
position:absolute;
width:170px;
top:293px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.CardOnGraph .best_in_place_link {
width: 135px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
display: block;
float: left;
padding-left: 5px;
padding-top:2px;
}
.CardOnGraph .best_in_place_link input {
width:130px;
margin-top:-2px;
}
.CardOnGraph .go-link {
float:left;
}

View file

@ -75,16 +75,7 @@ line-height: 24px;}
.topic .desc { font-size:15px; font-family:Arial, Helvetica, sans-serif; }
.topic .desc h3 { font-style:normal; margin-top:5px; }
.topic .link { position:absolute; width:170px; top:295px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.best_in_place_name {
max-width:130px;
float:left;
}
.best_in_place_name input{
max-width:130px;
}
.topic .link { position:absolute; width:140px; top:295px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topic-go-arrow {
width: 25px;

View file

@ -1,182 +1,182 @@
class TopicsController < ApplicationController
before_filter :require_user, only: [:new, :create, :edit, :update]
respond_to :html, :js, :json
autocomplete :topic, :name, :full => true, :extra_data => [:user_id]
# GET topics
# or GET /users/:user_id/topics
def index
@current = current_user
if params[:user_id]
@user = User.find(params[:user_id])
@topics = Topic.order("name ASC").visibleToUser(@current, @user)
elsif
@topics = Topic.order("name ASC").visibleToUser(@current, nil)
end
respond_with(@user,@topics)
end
# Get topics/new
def new
@topic = Topic.new
@user = current_user
respond_with(@topic)
end
# GET topics/:id
def show
@current = current_user
@topic = Topic.find(params[:id]).authorize_to_show(@current)
if @topic
@relatives = @topic.network_as_json(@current).html_safe
else
redirect_to root_url and return
end
respond_to do |format|
format.html { respond_with(@topic, @user) }
format.json { respond_with(@relatives) }
end
end
# POST topics
def create
@user = current_user
# if the topic exists grab it and return it
if params[:topic][:grabTopic] != "null"
@topic = Topic.find(params[:topic][:grabTopic])
# if the topic doesn't exist yet, create it
else
@topic = Topic.new()
@topic.name = params[:topic][:name]
@topic.desc = ""
@topic.link = ""
@topic.permission = 'commons'
@topic.metacode = Metacode.find_by_name(params[:topic][:metacode])
@topic.user = @user
@topic.save
end
# pass on to the topic create js whether it's being created with a synapse
@synapse = "false"
if params[:topic][:addSynapse] == "true"
@synapse = "true"
end
# also create an object to return the position to the canvas
@position = Hash.new()
@position['x'] = params[:topic][:x]
@position['y'] = params[:topic][:y]
# set this for the case where the topic is being created on a map.
@mapping = Mapping.new()
if params[:topic][:map]
@mapping.category = "Topic"
@mapping.user = @user
@mapping.map = Map.find(params[:topic][:map])
@mapping.topic = @topic
@mapping.xloc = params[:topic][:x]
@mapping.yloc = params[:topic][:y]
@mapping.save
end
respond_to do |format|
format.html { respond_with(@user, location: topic_url(@topic)) }
format.js { respond_with(@topic, @mapping, @synapse, @position) }
end
end
# GET topics/:id/edit
def edit
@current = current_user
@topic = Topic.find(params[:id]).authorize_to_edit(@current)
if not @topic
redirect_to root_url and return
end
respond_with(@topic)
end
# PUT topics/:id
def update
@current = current_user
@topic = Topic.find(params[:id]).authorize_to_edit(@current)
if @topic
if params[:topic]
@topic.name = params[:topic][:name] if params[:topic][:name]
@topic.desc = params[:topic][:desc] if params[:topic][:desc]
@topic.link = params[:topic][:link] if params[:topic][:link]
@topic.permission = params[:topic][:permission] if params[:topic][:permission]
@topic.metacode = Metacode.find_by_name(params[:topic][:metacode]) if params[:topic][:metacode]
end
@topic.save
end
respond_with @topic
# respond_with(@user, location: topic_url(@topic)) do |format|
# end
end
# GET mappings/:map_id/:topic_id/removefrommap
def removefrommap
@current = current_user
@mapping = Mapping.find_by_topic_id_and_map_id(params[:topic_id],params[:map_id])
@map = Map.find(params[:map_id])
@topic = Topic.find(params[:topic_id])
@mappings = @map.mappings.select{|m|
if m.synapse != nil
m.synapse.topic1 == @topic || m.synapse.topic2 == @topic
else
false
end
}
@mappings.each do |m|
m.delete
end
@mapping.delete
respond_to do |format|
format.js
end
end
# DELETE topics/:id
def destroy
@current = current_user
@topic = Topic.find(params[:id]).authorize_to_edit(@current)
if @topic
@synapses = @topic.synapses
@mappings = @topic.mappings
@synapses.each do |synapse|
synapse.delete
end
@mappings.each do |mapping|
mapping.delete
end
@topic.delete
end
respond_to do |format|
format.js
end
end
end
class TopicsController < ApplicationController
before_filter :require_user, only: [:new, :create, :edit, :update]
respond_to :html, :js, :json
autocomplete :topic, :name, :full => true, :extra_data => [:user_id], :display_value => :topic_autocomplete_method
# GET topics
# or GET /users/:user_id/topics
def index
@current = current_user
if params[:user_id]
@user = User.find(params[:user_id])
@topics = Topic.order("name ASC").visibleToUser(@current, @user)
elsif
@topics = Topic.order("name ASC").visibleToUser(@current, nil)
end
respond_with(@user,@topics)
end
# Get topics/new
def new
@topic = Topic.new
@user = current_user
respond_with(@topic)
end
# GET topics/:id
def show
@current = current_user
@topic = Topic.find(params[:id]).authorize_to_show(@current)
if @topic
@relatives = @topic.network_as_json(@current).html_safe
else
redirect_to root_url and return
end
respond_to do |format|
format.html { respond_with(@topic, @user) }
format.json { respond_with(@relatives) }
end
end
# POST topics
def create
@user = current_user
# if the topic exists grab it and return it
if params[:topic][:grabTopic] != "null"
@topic = Topic.find(params[:topic][:grabTopic])
# if the topic doesn't exist yet, create it
else
@topic = Topic.new()
@topic.name = params[:topic][:name]
@topic.desc = ""
@topic.link = ""
@topic.permission = 'commons'
@topic.metacode = Metacode.find_by_name(params[:topic][:metacode])
@topic.user = @user
@topic.save
end
# pass on to the topic create js whether it's being created with a synapse
@synapse = "false"
if params[:topic][:addSynapse] == "true"
@synapse = "true"
end
# also create an object to return the position to the canvas
@position = Hash.new()
@position['x'] = params[:topic][:x]
@position['y'] = params[:topic][:y]
# set this for the case where the topic is being created on a map.
@mapping = Mapping.new()
if params[:topic][:map]
@mapping.category = "Topic"
@mapping.user = @user
@mapping.map = Map.find(params[:topic][:map])
@mapping.topic = @topic
@mapping.xloc = params[:topic][:x]
@mapping.yloc = params[:topic][:y]
@mapping.save
end
respond_to do |format|
format.html { respond_with(@user, location: topic_url(@topic)) }
format.js { respond_with(@topic, @mapping, @synapse, @position) }
end
end
# GET topics/:id/edit
def edit
@current = current_user
@topic = Topic.find(params[:id]).authorize_to_edit(@current)
if not @topic
redirect_to root_url and return
end
respond_with(@topic)
end
# PUT topics/:id
def update
@current = current_user
@topic = Topic.find(params[:id]).authorize_to_edit(@current)
if @topic
if params[:topic]
@topic.name = params[:topic][:name] if params[:topic][:name]
@topic.desc = params[:topic][:desc] if params[:topic][:desc]
@topic.link = params[:topic][:link] if params[:topic][:link]
@topic.permission = params[:topic][:permission] if params[:topic][:permission]
@topic.metacode = Metacode.find_by_name(params[:topic][:metacode]) if params[:topic][:metacode]
end
@topic.save
end
respond_with @topic
# respond_with(@user, location: topic_url(@topic)) do |format|
# end
end
# GET mappings/:map_id/:topic_id/removefrommap
def removefrommap
@current = current_user
@mapping = Mapping.find_by_topic_id_and_map_id(params[:topic_id],params[:map_id])
@map = Map.find(params[:map_id])
@topic = Topic.find(params[:topic_id])
@mappings = @map.mappings.select{|m|
if m.synapse != nil
m.synapse.topic1 == @topic || m.synapse.topic2 == @topic
else
false
end
}
@mappings.each do |m|
m.delete
end
@mapping.delete
respond_to do |format|
format.js
end
end
# DELETE topics/:id
def destroy
@current = current_user
@topic = Topic.find(params[:id]).authorize_to_edit(@current)
if @topic
@synapses = @topic.synapses
@mappings = @topic.mappings
@synapses.each do |synapse|
synapse.delete
end
@mappings.each do |mapping|
mapping.delete
end
@topic.delete
end
respond_to do |format|
format.js
end
end
end

View file

@ -1,195 +1,199 @@
class Topic < ActiveRecord::Base
include TopicsHelper
belongs_to :user
has_many :synapses1, :class_name => 'Synapse', :foreign_key => 'node1_id'
has_many :synapses2, :class_name => 'Synapse', :foreign_key => 'node2_id'
has_many :topics1, :through => :synapses2, :source => :topic1
has_many :topics2, :through => :synapses1, :source => :topic2
has_many :mappings
has_many :maps, :through => :mappings
def synapses
synapses1 + synapses2
end
def relatives
topics1 + topics2
end
belongs_to :metacode
# has no viewable synapses helper function
def has_viewable_synapses(current)
result = false
self.synapses.each do |synapse|
if synapse.authorize_to_view(current)
result = true
end
end
return result
end
###### JSON ######
def self_as_json
Jbuilder.encode do |json|
@inmaps = Array.new
self.maps.each do |map|
@inmaps.push(map.id)
end
@topicdata = Hash.new
@topicdata['$desc'] = self.desc
@topicdata['$link'] = self.link
@topicdata['$metacode'] = self.metacode.name
@topicdata['$inmaps'] = @inmaps
@topicdata['$userid'] = self.user.id
@topicdata['$username'] = self.user.name
json.data @topicdata
json.id self.id
json.name self.name
end
end
def selfonmap_as_json(mapid)
Jbuilder.encode do |json|
@inmaps = Array.new
self.maps.each do |map|
@inmaps.push(map.id)
end
@topicdata = Hash.new
@topicdata['$desc'] = self.desc
@topicdata['$link'] = self.link
@topicdata['$metacode'] = self.metacode.name
@topicdata['$inmaps'] = @inmaps
@topicdata['$userid'] = self.user.id
@topicdata['$username'] = self.user.name
@mapping = Mapping.find_by_topic_id_and_map_id(self.id,mapid)
@topicdata['$xloc'] = @mapping.xloc
@topicdata['$yloc'] = @mapping.yloc
@topicdata['$mappingid'] = @mapping.id
json.data @topicdata
json.id self.id
json.name self.name
end
end
#build a json object of everything connected to a specified node
def network_as_json(current)
Jbuilder.encode do |json|
@topics = network(self,nil,4)
if @topics.count > 1
json.array!(@topics.delete_if{|topic| (not topic.authorize_to_view(current)) || (not topic.has_viewable_synapses(current))}) do |topic|
json.adjacencies topic.synapses1.delete_if{|synapse| (not @topics.include?(synapse.topic2)) || (not synapse.authorize_to_view(current)) || (not synapse.topic2.authorize_to_view(current)) } do |json, synapse|
json.nodeTo synapse.node2_id
json.nodeFrom synapse.node1_id
@synapsedata = Hash.new
@synapsedata['$desc'] = synapse.desc
@synapsedata['$showDesc'] = false
@synapsedata['$category'] = synapse.category
@synapsedata['$id'] = synapse.id
@synapsedata['$userid'] = synapse.user.id
@synapsedata['$username'] = synapse.user.name
@synapsedata['$direction'] = [synapse.node1_id.to_s(), synapse.node2_id.to_s()]
json.data @synapsedata
end
@inmaps = Array.new
topic.maps.each do |map|
@inmaps.push(map.id)
end
@topicdata = Hash.new
@topicdata['$desc'] = topic.desc
@topicdata['$link'] = topic.link
@topicdata['$metacode'] = topic.metacode.name
@topicdata['$inmaps'] = @inmaps
@topicdata['$userid'] = topic.user.id
@topicdata['$username'] = topic.user.name
json.data @topicdata
json.id topic.id
json.name topic.name
end
elsif @topics.count == 1
json.array!(@topics) do |topic|
@inmaps = Array.new
topic.maps.each do |map|
@inmaps.push(map.id)
end
@topicdata = Hash.new
@topicdata['$desc'] = topic.desc
@topicdata['$link'] = topic.link
@topicdata['$metacode'] = topic.metacode.name
@topicdata['$inmaps'] = @inmaps
@topicdata['$userid'] = topic.user.id
@topicdata['$username'] = topic.user.name
json.data @topicdata
json.id topic.id
json.name topic.name
end
end
end
end
##### PERMISSIONS ######
scope :visibleToUser, lambda { |current, user|
if user != nil
if user != current
Topic.find_all_by_user_id_and_permission(user.id, "commons") | Topic.find_all_by_user_id_and_permission(user.id, "public")
elsif user == current
Topic.find_all_by_user_id_and_permission(user.id, "commons") | Topic.find_all_by_user_id_and_permission(user.id, "public") | current.topics.where(:permission => "private")
end
elsif (current != nil && user == nil)
Topic.find_all_by_permission("commons") | Topic.find_all_by_permission("public") | current.topics.where(:permission => "private")
elsif (current == nil)
Topic.find_all_by_permission("commons") | Topic.find_all_by_permission("public")
end
}
# returns false if user not allowed to 'show' Topic, Synapse, or Map
def authorize_to_show(user)
if (self.permission == "private" && self.user != user)
return false
end
return self
end
# returns false if user not allowed to 'edit' Topic, Synapse, or Map
def authorize_to_edit(user)
if (self.permission == "private" && self.user != user)
return false
elsif (self.permission == "public" && self.user != user)
return false
end
return self
end
# returns Boolean if user allowed to view Topic, Synapse, or Map
def authorize_to_view(user)
if (self.permission == "private" && self.user != user)
return false
end
return true
end
# returns Boolean based on whether user has permissions to edit or not
def authorize_linkto_edit(user)
if (self.user == user)
return true
elsif (self.permission == "commons")
return true
end
return false
end
end
class Topic < ActiveRecord::Base
include TopicsHelper
belongs_to :user
has_many :synapses1, :class_name => 'Synapse', :foreign_key => 'node1_id'
has_many :synapses2, :class_name => 'Synapse', :foreign_key => 'node2_id'
has_many :topics1, :through => :synapses2, :source => :topic1
has_many :topics2, :through => :synapses1, :source => :topic2
has_many :mappings
has_many :maps, :through => :mappings
def synapses
synapses1 + synapses2
end
def relatives
topics1 + topics2
end
belongs_to :metacode
def topic_autocomplete_method
"Get: #{self.name}"
end
# has no viewable synapses helper function
def has_viewable_synapses(current)
result = false
self.synapses.each do |synapse|
if synapse.authorize_to_view(current)
result = true
end
end
return result
end
###### JSON ######
def self_as_json
Jbuilder.encode do |json|
@inmaps = Array.new
self.maps.each do |map|
@inmaps.push(map.id)
end
@topicdata = Hash.new
@topicdata['$desc'] = self.desc
@topicdata['$link'] = self.link
@topicdata['$metacode'] = self.metacode.name
@topicdata['$inmaps'] = @inmaps
@topicdata['$userid'] = self.user.id
@topicdata['$username'] = self.user.name
json.data @topicdata
json.id self.id
json.name self.name
end
end
def selfonmap_as_json(mapid)
Jbuilder.encode do |json|
@inmaps = Array.new
self.maps.each do |map|
@inmaps.push(map.id)
end
@topicdata = Hash.new
@topicdata['$desc'] = self.desc
@topicdata['$link'] = self.link
@topicdata['$metacode'] = self.metacode.name
@topicdata['$inmaps'] = @inmaps
@topicdata['$userid'] = self.user.id
@topicdata['$username'] = self.user.name
@mapping = Mapping.find_by_topic_id_and_map_id(self.id,mapid)
@topicdata['$xloc'] = @mapping.xloc
@topicdata['$yloc'] = @mapping.yloc
@topicdata['$mappingid'] = @mapping.id
json.data @topicdata
json.id self.id
json.name self.name
end
end
#build a json object of everything connected to a specified node
def network_as_json(current)
Jbuilder.encode do |json|
@topics = network(self,nil,4)
if @topics.count > 1
json.array!(@topics.delete_if{|topic| (not topic.authorize_to_view(current)) || (not topic.has_viewable_synapses(current))}) do |topic|
json.adjacencies topic.synapses1.delete_if{|synapse| (not @topics.include?(synapse.topic2)) || (not synapse.authorize_to_view(current)) || (not synapse.topic2.authorize_to_view(current)) } do |json, synapse|
json.nodeTo synapse.node2_id
json.nodeFrom synapse.node1_id
@synapsedata = Hash.new
@synapsedata['$desc'] = synapse.desc
@synapsedata['$showDesc'] = false
@synapsedata['$category'] = synapse.category
@synapsedata['$id'] = synapse.id
@synapsedata['$userid'] = synapse.user.id
@synapsedata['$username'] = synapse.user.name
@synapsedata['$direction'] = [synapse.node1_id.to_s(), synapse.node2_id.to_s()]
json.data @synapsedata
end
@inmaps = Array.new
topic.maps.each do |map|
@inmaps.push(map.id)
end
@topicdata = Hash.new
@topicdata['$desc'] = topic.desc
@topicdata['$link'] = topic.link
@topicdata['$metacode'] = topic.metacode.name
@topicdata['$inmaps'] = @inmaps
@topicdata['$userid'] = topic.user.id
@topicdata['$username'] = topic.user.name
json.data @topicdata
json.id topic.id
json.name topic.name
end
elsif @topics.count == 1
json.array!(@topics) do |topic|
@inmaps = Array.new
topic.maps.each do |map|
@inmaps.push(map.id)
end
@topicdata = Hash.new
@topicdata['$desc'] = topic.desc
@topicdata['$link'] = topic.link
@topicdata['$metacode'] = topic.metacode.name
@topicdata['$inmaps'] = @inmaps
@topicdata['$userid'] = topic.user.id
@topicdata['$username'] = topic.user.name
json.data @topicdata
json.id topic.id
json.name topic.name
end
end
end
end
##### PERMISSIONS ######
scope :visibleToUser, lambda { |current, user|
if user != nil
if user != current
Topic.find_all_by_user_id_and_permission(user.id, "commons") | Topic.find_all_by_user_id_and_permission(user.id, "public")
elsif user == current
Topic.find_all_by_user_id_and_permission(user.id, "commons") | Topic.find_all_by_user_id_and_permission(user.id, "public") | current.topics.where(:permission => "private")
end
elsif (current != nil && user == nil)
Topic.find_all_by_permission("commons") | Topic.find_all_by_permission("public") | current.topics.where(:permission => "private")
elsif (current == nil)
Topic.find_all_by_permission("commons") | Topic.find_all_by_permission("public")
end
}
# returns false if user not allowed to 'show' Topic, Synapse, or Map
def authorize_to_show(user)
if (self.permission == "private" && self.user != user)
return false
end
return self
end
# returns false if user not allowed to 'edit' Topic, Synapse, or Map
def authorize_to_edit(user)
if (self.permission == "private" && self.user != user)
return false
elsif (self.permission == "public" && self.user != user)
return false
end
return self
end
# returns Boolean if user allowed to view Topic, Synapse, or Map
def authorize_to_view(user)
if (self.permission == "private" && self.user != user)
return false
end
return true
end
# returns Boolean based on whether user has permissions to edit or not
def authorize_linkto_edit(user)
if (self.user == user)
return true
elsif (self.permission == "commons")
return true
end
return false
end
end