fixed filters, updated ruby models further for returning json
This commit is contained in:
parent
f0eb4da6a9
commit
173179d682
7 changed files with 48 additions and 24 deletions
|
@ -126,9 +126,6 @@ Metamaps.Backbone.init = function () {
|
||||||
},
|
},
|
||||||
getDate: function () {
|
getDate: function () {
|
||||||
|
|
||||||
},
|
|
||||||
getUser: function () {
|
|
||||||
return Metamaps.Mapper.get(this.get('user_id'));
|
|
||||||
},
|
},
|
||||||
getMetacode: function () {
|
getMetacode: function () {
|
||||||
return Metamaps.Metacodes.get(this.get('metacode_id'));
|
return Metamaps.Metacodes.get(this.get('metacode_id'));
|
||||||
|
@ -212,9 +209,6 @@ Metamaps.Backbone.init = function () {
|
||||||
if (mapper && this.get('user_id') === mapper.get('id')) return true;
|
if (mapper && this.get('user_id') === mapper.get('id')) return true;
|
||||||
else return false;
|
else return false;
|
||||||
},
|
},
|
||||||
getUser: function () {
|
|
||||||
return Metamaps.Mapper.get(this.get('user_id'));
|
|
||||||
},
|
|
||||||
getTopic1: function () {
|
getTopic1: function () {
|
||||||
return Metamaps.Topic.get(this.get('node1_id'));
|
return Metamaps.Topic.get(this.get('node1_id'));
|
||||||
},
|
},
|
||||||
|
@ -291,9 +285,6 @@ Metamaps.Backbone.init = function () {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
getUser: function () {
|
|
||||||
return Metamaps.Mapper.get(this.get('user_id'));
|
|
||||||
},
|
|
||||||
getMap: function () {
|
getMap: function () {
|
||||||
return Metamaps.Map.get(this.get('map_id'));
|
return Metamaps.Map.get(this.get('map_id'));
|
||||||
},
|
},
|
||||||
|
@ -921,7 +912,7 @@ Metamaps.TopicCard = {
|
||||||
nodeValues.imgsrc = topic.getMetacode().get("icon");
|
nodeValues.imgsrc = topic.getMetacode().get("icon");
|
||||||
nodeValues.name = topic.get("name");
|
nodeValues.name = topic.get("name");
|
||||||
nodeValues.userid = topic.get("user_id");
|
nodeValues.userid = topic.get("user_id");
|
||||||
nodeValues.username = topic.getUser().get("name");
|
nodeValues.username = topic.get("user_name");
|
||||||
nodeValues.date = topic.getDate();
|
nodeValues.date = topic.getDate();
|
||||||
// the code for this is stored in /views/main/_metacodeOptions.html.erb
|
// the code for this is stored in /views/main/_metacodeOptions.html.erb
|
||||||
nodeValues.metacode_select = $('#metacodeOptions').html();
|
nodeValues.metacode_select = $('#metacodeOptions').html();
|
||||||
|
@ -1033,7 +1024,7 @@ Metamaps.SynapseCard = {
|
||||||
|
|
||||||
add_user_info: function (synapse) {
|
add_user_info: function (synapse) {
|
||||||
var u = '<div id="edgeUser" class="hoverForTip">';
|
var u = '<div id="edgeUser" class="hoverForTip">';
|
||||||
u += '<div class="tip">Created by ' + synapse.getUser().get("name") + '</div></div>';
|
u += '<div class="tip">Created by ' + synapse.get("user_name") + '</div></div>';
|
||||||
$('#edit_synapse').append(u);
|
$('#edit_synapse').append(u);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -2180,7 +2171,7 @@ Metamaps.Filter = {
|
||||||
},
|
},
|
||||||
checkMappers: function () {
|
checkMappers: function () {
|
||||||
var self = Metamaps.Filter;
|
var self = Metamaps.Filter;
|
||||||
self.updateFilters('both', 'user_id', 'Mapper', 'mappers', 'mapper');
|
self.updateFilters('both', 'user_id', 'Mappers', 'mappers', 'mapper');
|
||||||
},
|
},
|
||||||
checkSynapses: function () {
|
checkSynapses: function () {
|
||||||
var self = Metamaps.Filter;
|
var self = Metamaps.Filter;
|
||||||
|
|
|
@ -9,17 +9,9 @@ class MainController < ApplicationController
|
||||||
# home page
|
# home page
|
||||||
def home
|
def home
|
||||||
@current = current_user
|
@current = current_user
|
||||||
|
|
||||||
if !authenticated?
|
|
||||||
@maps = Map.find_all_by_featured(true).shuffle!
|
|
||||||
@maps = @maps.slice(0,3)
|
|
||||||
elsif authenticated?
|
|
||||||
#@maps = Map.order("updated_at DESC").where("permission != ?", "private").limit(3)
|
|
||||||
@maps = Map.order("name ASC").find_all_by_user_id(@current.id)
|
|
||||||
end
|
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { respond_with(@maps, @current) }
|
format.html { respond_with(@current) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -45,8 +45,12 @@ end
|
||||||
self.user.name
|
self.user.name
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def user_image
|
||||||
|
self.user.image.url
|
||||||
|
end
|
||||||
|
|
||||||
def as_json(options={})
|
def as_json(options={})
|
||||||
super(:methods =>[:user_name, :topic_count, :synapse_count])
|
super(:methods =>[:user_name, :user_image, :topic_count, :synapse_count])
|
||||||
end
|
end
|
||||||
|
|
||||||
##### PERMISSIONS ######
|
##### PERMISSIONS ######
|
||||||
|
|
|
@ -5,6 +5,18 @@ belongs_to :synapse, :class_name => "Synapse", :foreign_key => "synapse_id"
|
||||||
belongs_to :map, :class_name => "Map", :foreign_key => "map_id"
|
belongs_to :map, :class_name => "Map", :foreign_key => "map_id"
|
||||||
|
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
|
|
||||||
|
def user_name
|
||||||
|
self.user.name
|
||||||
|
end
|
||||||
|
|
||||||
|
def user_image
|
||||||
|
self.user.image.url
|
||||||
|
end
|
||||||
|
|
||||||
|
def as_json(options={})
|
||||||
|
super(:methods =>[:user_name, :user_image])
|
||||||
|
end
|
||||||
|
|
||||||
# sends push updates through redis to websockets for realtime updates
|
# sends push updates through redis to websockets for realtime updates
|
||||||
def message action, origin_user_id
|
def message action, origin_user_id
|
||||||
|
|
|
@ -8,6 +8,18 @@ belongs_to :topic2, :class_name => "Topic", :foreign_key => "node2_id"
|
||||||
has_many :mappings
|
has_many :mappings
|
||||||
has_many :maps, :through => :mappings
|
has_many :maps, :through => :mappings
|
||||||
|
|
||||||
|
def user_name
|
||||||
|
self.user.name
|
||||||
|
end
|
||||||
|
|
||||||
|
def user_image
|
||||||
|
self.user.image.url
|
||||||
|
end
|
||||||
|
|
||||||
|
def as_json(options={})
|
||||||
|
super(:methods =>[:user_name, :user_image])
|
||||||
|
end
|
||||||
|
|
||||||
# sends push updates through redis to websockets for realtime updates
|
# sends push updates through redis to websockets for realtime updates
|
||||||
def message action, origin_user_id
|
def message action, origin_user_id
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,19 @@ has_many :maps, :through => :mappings
|
||||||
topics1 + topics2
|
topics1 + topics2
|
||||||
end
|
end
|
||||||
|
|
||||||
belongs_to :metacode
|
belongs_to :metacode
|
||||||
|
|
||||||
|
def user_name
|
||||||
|
self.user.name
|
||||||
|
end
|
||||||
|
|
||||||
|
def user_image
|
||||||
|
self.user.image.url
|
||||||
|
end
|
||||||
|
|
||||||
|
def as_json(options={})
|
||||||
|
super(:methods =>[:user_name, :user_image])
|
||||||
|
end
|
||||||
|
|
||||||
# sends push updates through redis to websockets for realtime updates
|
# sends push updates through redis to websockets for realtime updates
|
||||||
def message action, origin_user_id
|
def message action, origin_user_id
|
||||||
|
|
|
@ -40,7 +40,8 @@ has_many :mappings
|
||||||
end
|
end
|
||||||
|
|
||||||
def as_json(options={})
|
def as_json(options={})
|
||||||
{ :name =>self.name,
|
{ :id => self.id,
|
||||||
|
:name => self.name,
|
||||||
:email => self.email,
|
:email => self.email,
|
||||||
:image => self.image.url
|
:image => self.image.url
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue