This commit is contained in:
Devin Howard 2013-01-20 21:22:33 -05:00
commit aa911d4bdf
18 changed files with 249 additions and 38 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 3 KiB

View file

@ -83,7 +83,40 @@ var labelType, useGradients, nativeTextSupport, animate, json, Mconsole = null,
},800);
}
);
// controls the sliding hover of the settings for cards
var sliding2 = false;
var lT2;
$(".permActivator").hover(
function () {
clearTimeout(lT2);
if (! sliding2) {
sliding2 = true;
$(this).animate({
width: '203px',
height: '37px'
}, 300, function() {
sliding2 = false;
});
}
},
function () {
that = this;
lT2 = setTimeout(function() {
if (! sliding2) {
sliding2 = true;
$(that).animate({
height: '16px',
width: '16px'
}, 300, function() {
sliding2 = false;
});
}
},800);
}
);
// this is to save the layout of maps when you're on a map page
$("#saveLayout").click(function(event) {
event.preventDefault();

View file

@ -3,4 +3,4 @@
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
jQuery ->
$('.authenticated .best_in_place').best_in_place()
$('.authenticated div.permission.canEdit .best_in_place').best_in_place()

View file

@ -135,3 +135,44 @@ margin-right: -8px;
.CardOnGraph .go-link {
float:left;
}
.cardSettings {
position: absolute;
left: 12px;
top: 13px;
}
.editSettings {
background: #ddd;
border-radius: 10px;
padding: 5px 0 5px 5px;
position: relative;
left: 16px;
width: 172px;
opacity: 0.98;
box-shadow: 4px 4px 5px #888888;
border: 1px solid #AAA;
}
.editSettings span {
float:left;
}
.permActivator {
width: 16px;
height: 16px;
background: url('settings.png') no-repeat 0 0;
overflow:hidden;
}
.mapPerm {
background: #fff;
padding: 0 4px 4px 4px;
border-radius: 15px;
border: 1px solid #AAA;
position: absolute;
left: -7px;
top: 18px;
width:16px;
text-align:center;
}

View file

@ -6,9 +6,12 @@ class MainController < ApplicationController
respond_to :html, :js, :json
def home
@topics = Topic.order("created_at DESC").limit(3).visibleToUser(@current, nil)
@synapses = Synapse.order("created_at DESC").limit(3).visibleToUser(@current, nil)
@maps = Map.order("created_at DESC").limit(3).visibleToUser(@current, nil)
@topics = Topic.visibleToUser(@current, nil).sort! { |a,b| b.created_at <=> a.created_at }
@topics = @topics.slice(0,3)
@synapses = Synapse.visibleToUser(@current, nil).sort! { |a,b| b.created_at <=> a.created_at }
@synapses = @synapses.slice(0,3)
@maps = Map.visibleToUser(@current, nil).sort! { |a,b| b.created_at <=> a.created_at }
@maps = @maps.slice(0,3)
respond_with(@topics, @synapses, @maps)
end

View file

@ -1,6 +1,6 @@
class MapsController < ApplicationController
before_filter :require_user, only: [:new, :create, :edit, :update, :savelayout]
before_filter :require_user, only: [:new, :create, :edit, :update, :savelayout, :destroy]
respond_to :html, :js, :json
@ -48,6 +48,21 @@ class MapsController < ApplicationController
end
end
# GET maps/:id/json
def json
@current = current_user
@map = Map.find(params[:id]).authorize_to_show(@current)
if not @map
redirect_to root_url and return
end
respond_to do |format|
format.json { render :json => @map.self_as_json(@current) }
end
end
# POST maps
def create
@ -116,13 +131,19 @@ class MapsController < ApplicationController
# PUT maps/:id
def update
@map = Map.find(params[:id])
@current = current_user
@map = Map.find(params[:id]).authorize_to_edit(@current)
@map.attributes = params[:map]
@map.save
respond_with(@user, location: map_path(@map)) do |format|
if @map
if params[:map]
@map.name = params[:map][:name] if params[:map][:name]
@map.desc = params[:map][:desc] if params[:map][:desc]
@map.permission = params[:map][:permission] if params[:map][:permission]
end
@map.save
end
respond_with @map
end
# PUT maps/:id/savelayout

View file

@ -1,7 +1,7 @@
class SynapsesController < ApplicationController
include TopicsHelper
before_filter :require_user, only: [:new, :create, :edit, :update]
before_filter :require_user, only: [:new, :create, :edit, :update, :destroy]
respond_to :html, :js, :json
@ -54,6 +54,20 @@ class SynapsesController < ApplicationController
end
end
# GET synapses/:id/json
def json
@current = current_user
@synapse = Synapse.find(params[:id]).authorize_to_show(@current)
if not @synapse
redirect_to root_url and return
end
respond_to do |format|
format.json { render :json => @synapse.selfplusnodes_as_json }
end
end
# POST synapses
def create
@ -69,12 +83,18 @@ class SynapsesController < ApplicationController
@synapse.save
if params[:synapse][:map]
@mapping = Mapping.new()
@map = Map.find(params[:synapse][:map])
@mapping = Mapping.new()
@mapping.category = "Synapse"
@mapping.user = @user
@mapping.map = Map.find(params[:synapse][:map])
@mapping.map = @map
@mapping.synapse = @synapse
@mapping.save
# set the permission of the synapse to whatever the permission of the map is
@synapse.permission = @map.permission
@synapse.save
end
respond_to do |format|

View file

@ -1,5 +1,5 @@
class TopicsController < ApplicationController
before_filter :require_user, only: [:new, :create, :edit, :update]
before_filter :require_user, only: [:new, :create, :edit, :update, :destroy]
respond_to :html, :js, :json
@ -45,6 +45,20 @@ class TopicsController < ApplicationController
format.json { respond_with(@relatives) }
end
end
# GET topics/:id/json
def json
@current = current_user
@topic = Topic.find(params[:id]).authorize_to_show(@current)
if not @topic
redirect_to root_url and return
end
respond_to do |format|
format.json { render :json => @topic.self_as_json }
end
end
# POST topics
def create
@ -63,6 +77,12 @@ class TopicsController < ApplicationController
@topic.permission = 'commons'
@topic.metacode = Metacode.find_by_name(params[:topic][:metacode])
@topic.user = @user
#if being created on a map, set topic by default to whatever permissions the map is
if params[:topic][:map]
@map = Map.find(params[:topic][:map])
@topic.permission = @map.permission
end
@topic.save
end
@ -81,9 +101,11 @@ class TopicsController < ApplicationController
# set this for the case where the topic is being created on a map.
@mapping = Mapping.new()
if params[:topic][:map]
@map = Map.find(params[:topic][:map])
@mapping.category = "Topic"
@mapping.user = @user
@mapping.map = Map.find(params[:topic][:map])
@mapping.map = @map
@mapping.topic = @topic
@mapping.xloc = params[:topic][:x]
@mapping.yloc = params[:topic][:y]
@ -116,18 +138,15 @@ class TopicsController < ApplicationController
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.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
end
respond_with @topic
# respond_with(@user, location: topic_url(@topic)) do |format|
# end
respond_with @topic
end
# GET mappings/:map_id/:topic_id/removefrommap

View file

@ -21,12 +21,15 @@ class UsersController < ApplicationController
respond_with(@user)
end
# GET /user
# GET /user/:id
def show
@user = User.find(params[:id])
@topics = @user.topics.order("created_at DESC").limit(3)
@synapses = @user.synapses.order("created_at DESC").limit(3)
@maps = @user.maps.order("created_at DESC").limit(3)
@topics = Topic.visibleToUser(@current, @user).sort! { |a,b| b.created_at <=> a.created_at }
@topics = @topics.slice(0,3)
@synapses = Synapse.visibleToUser(@current, @user).sort! { |a,b| b.created_at <=> a.created_at }
@synapses = @synapses.slice(0,3)
@maps = Map.visibleToUser(@current, @user).sort! { |a,b| b.created_at <=> a.created_at }
@maps = @maps.slice(0,3)
respond_with(@user, @topics, @synapses, @maps)
end

View file

@ -11,6 +11,16 @@ has_many :synapses, :through => :synapsemappings
def mappings
topicmappings + synapsemappings
end
def mk_permission
if self.permission == "commons"
"co"
elsif self.permission == "public"
"pu"
elsif self.permission == "private"
"pr"
end
end
###### JSON ######

View file

@ -25,6 +25,16 @@ belongs_to :metacode
def topic_autocomplete_method
"Get: #{self.name}"
end
def mk_permission
if self.permission == "commons"
"cc"
elsif self.permission == "public"
"pu"
elsif self.permission == "private"
"pr"
end
end
# has no viewable synapses helper function
def has_viewable_synapses(current)

View file

@ -1,16 +1,30 @@
<%#
# @file
# Shows a map as a card.
# I believe this is rendered on the profile pages.
# TODO: Am I correct?
# TODO: Is it rendered on any other pages?
# Any list of maps uses this rendering.
#%>
<%= div_for map do %>
<% if map.authorize_to_edit(user) %>
<div class="permission canEdit">
<% end %>
<% if map.user == user %><%= link_to 'Delete', map_path(map), :class => 'delete', :confirm => 'Delete this map (nodes and synapses will remain)?', :method => :delete, :remote => true %><% end %>
<p class="type">Map</p>
<%= image_tag 'map.png', :class => 'icon', :size => '50x50' %>
<div class="cardSettings">
<% if map.user == user %>
<div class="permActivator">
<div class="editSettings">
<span>Permissions:&nbsp;</span>
<span title="Click to Edit"><%= best_in_place map, :permission, :type => :select, :collection => [['commons', 'commons'], ['public','public'], ['private','private']] %></span>
<div class="clearfloat"></div>
</div>
</div>
<% end %>
<div class="mapPerm"><%= map.mk_permission %></div>
</div>
<span class="title">
<span><%=map.name %></span>
<span><%= best_in_place map, :name, :type => :input %></span>
<a href="/maps/<%=map.id %>" class="topic-go-arrow">
<img class="topic-go-arrow"
title="Go to map"
@ -25,7 +39,11 @@
<div class="scroll">
<div class="desc">
<p class="mapdata"><%= map.topics.count %> topics and <%= map.synapses.count %> synapses</p>
<p><%= map.desc %></p>
<p><%= best_in_place map, :desc, :type => :textarea, :nil => "<span class='gray'>Click to add description.</span>" %></p>
</div>
</div>
<% if map.authorize_to_edit(user) %>
</div>
<% end %>
<% end %>

View file

@ -9,8 +9,9 @@
<%= form.text_field :name %>
<label for="map_desc">Description</label>
<%= form.text_area :desc, class: "description", :rows => 5 %>
<label for="map_permission">Permission</label>
<label for="map_permission">Permission</label>
<%= form.select(:permission, options_for_select(['commons', 'public', 'private'])) %>
<p>Topics and synapses you create newly on this map will be set by default to the permissions of your map.</p>
<%= form.hidden_field :topicsToMap, :value => 0 %>
<%= form.hidden_field :synapsesToMap, :value => 0 %>
<%= form.submit "Save", class: "add" %>

View file

@ -1,8 +1,7 @@
<%#
# @file
# Form for editing a map
# TODO: I think this code is no longer in use. Is it?
# TODO: What URL is this accessible at?
# Located at addresses /maps/:id/edit. In use.
#%>
<%= form_for @map, url: map_url(@map) do |form| %>
<h3>Edit Map</h3>

View file

@ -1,8 +1,7 @@
<%#
# @file
# Form to create a new map.
# TODO: What URL is this accessible from?
# TODO: Is this code being used anymore?
# Accessible from /maps/new. Still in use.
#%>
<div class="nothidden">
<%= form_for @map || Map.new, url: maps_url do |form|%>
@ -13,6 +12,7 @@
<%= form.text_area :desc, class: "description", :rows => 5 %>
<label for="map_permission">Permission</label>
<%= form.select(:permission, options_for_select(['commons', 'public', 'private'])) %>
<p>Topics and synapses you create newly on this map will be set by default to the permissions of your map.</p>
<%= form.submit "Add Map", class: "add" %>
<% end %>
</div>

View file

@ -5,6 +5,11 @@
#%>
<%= div_for topic do %>
<% if topic.authorize_to_edit(user) %>
<div class="permission canEdit">
<% end %>
<div class="CardOnGraph"
id="topic_<%=topic.id %>">
<% if topic.user == user %><%= link_to 'Delete', topic_path(topic), :class => 'delete', :confirm => 'Delete this topic and all synapses linking to it?', :method => :delete, :remote => true%><% end %>
@ -59,4 +64,8 @@
<div class="clearfloat"></div>
</div>
<% if topic.authorize_to_edit(user) %>
</div>
<% end %>
<% end %>

View file

@ -0,0 +1,21 @@
development:
min_messages: WARNING
adapter: postgresql
host: 127.0.0.1
port: 5432
encoding: unicode
database: metamap002_development
pool: 5
username: postgres
password: "3112"
production:
min_messages: WARNING
adapter: postgresql
host: ec2-107-21-107-194.compute-1.amazonaws.com
port: 5432
encoding: unicode
database: ddcrn2lgphjk9k
pool: 5
username: qqpckkahytovwv
password: "njeP6cMA8EjM9ukHk9s3ReOdy7"

View file

@ -18,14 +18,17 @@ ISSAD::Application.routes.draw do
resources :topics do
get :autocomplete_topic_name, :on => :collection
end
match 'topics/:id/:format', to: 'topics#json', via: :get, as: :json
resources :synapses do
get :autocomplete_synapse_desc, :on => :collection
end
match 'synapses/:id/:format', to: 'synapses#json', via: :get, as: :json
resources :maps do
get :autocomplete_map_name, :on => :collection
end
match 'maps/:id/:format', to: 'maps#json', via: :get, as: :json
resources :users do
get :autocomplete_user_name, :on => :collection