change the list
This commit is contained in:
parent
ab70d65aab
commit
fa51ee850e
8 changed files with 38 additions and 27 deletions
|
@ -300,6 +300,3 @@ DEPENDENCIES
|
||||||
tunemygc
|
tunemygc
|
||||||
uglifier
|
uglifier
|
||||||
uservoice-ruby
|
uservoice-ruby
|
||||||
|
|
||||||
BUNDLED WITH
|
|
||||||
1.11.2
|
|
||||||
|
|
|
@ -64,6 +64,7 @@ Metamaps.Map = {
|
||||||
var start = function (data) {
|
var start = function (data) {
|
||||||
Metamaps.Active.Map = new bb.Map(data.map)
|
Metamaps.Active.Map = new bb.Map(data.map)
|
||||||
Metamaps.Mappers = new bb.MapperCollection(data.mappers)
|
Metamaps.Mappers = new bb.MapperCollection(data.mappers)
|
||||||
|
Metamaps.Collaborators = new bb.MapperCollection(data.collaborators)
|
||||||
Metamaps.Topics = new bb.TopicCollection(data.topics)
|
Metamaps.Topics = new bb.TopicCollection(data.topics)
|
||||||
Metamaps.Synapses = new bb.SynapseCollection(data.synapses)
|
Metamaps.Synapses = new bb.SynapseCollection(data.synapses)
|
||||||
Metamaps.Mappings = new bb.MappingCollection(data.mappings)
|
Metamaps.Mappings = new bb.MappingCollection(data.mappings)
|
||||||
|
@ -477,15 +478,18 @@ Metamaps.Map.InfoBox = {
|
||||||
|
|
||||||
var isCreator = map.authorizePermissionChange(Metamaps.Active.Mapper)
|
var isCreator = map.authorizePermissionChange(Metamaps.Active.Mapper)
|
||||||
var canEdit = map.authorizeToEdit(Metamaps.Active.Mapper)
|
var canEdit = map.authorizeToEdit(Metamaps.Active.Mapper)
|
||||||
|
var relevantPeople = map.get('permission') === 'commons' ? Metamaps.Mappers : Metamaps.Collaborators
|
||||||
var shareable = map.get('permission') !== 'private'
|
var shareable = map.get('permission') !== 'private'
|
||||||
|
|
||||||
obj['name'] = canEdit ? Hogan.compile(self.nameHTML).render({id: map.id, name: map.get('name')}) : map.get('name')
|
obj['name'] = canEdit ? Hogan.compile(self.nameHTML).render({id: map.id, name: map.get('name')}) : map.get('name')
|
||||||
obj['desc'] = canEdit ? Hogan.compile(self.descHTML).render({id: map.id, desc: map.get('desc')}) : map.get('desc')
|
obj['desc'] = canEdit ? Hogan.compile(self.descHTML).render({id: map.id, desc: map.get('desc')}) : map.get('desc')
|
||||||
obj['map_creator_tip'] = isCreator ? self.changePermissionText : ''
|
obj['map_creator_tip'] = isCreator ? self.changePermissionText : ''
|
||||||
obj['contributors_class'] = Metamaps.Mappers.length > 1 ? 'multiple' : ''
|
|
||||||
obj['contributors_class'] += Metamaps.Mappers.length === 2 ? ' mTwo' : ''
|
obj['contributors_class'] = relevantPeople.length > 1 ? 'multiple' : ''
|
||||||
obj['contributor_image'] = Metamaps.Mappers.length > 0 ? Metamaps.Mappers.models[0].get('image') : "<%= asset_path('user.png') %>"
|
obj['contributors_class'] += relevantPeople.length === 2 ? ' mTwo' : ''
|
||||||
|
obj['contributor_image'] = relevantPeople.length > 0 ? relevantPeople.models[0].get('image') : "<%= asset_path('user.png') %>"
|
||||||
obj['contributor_list'] = self.createContributorList()
|
obj['contributor_list'] = self.createContributorList()
|
||||||
|
|
||||||
obj['user_name'] = isCreator ? 'You' : map.get('user_name')
|
obj['user_name'] = isCreator ? 'You' : map.get('user_name')
|
||||||
obj['created_at'] = map.get('created_at_clean')
|
obj['created_at'] = map.get('created_at_clean')
|
||||||
obj['updated_at'] = map.get('updated_at_clean')
|
obj['updated_at'] = map.get('updated_at_clean')
|
||||||
|
@ -562,11 +566,11 @@ Metamaps.Map.InfoBox = {
|
||||||
},
|
},
|
||||||
createContributorList: function () {
|
createContributorList: function () {
|
||||||
var self = Metamaps.Map.InfoBox
|
var self = Metamaps.Map.InfoBox
|
||||||
|
var relevantPeople = Metamaps.Active.Map.get('permission') === 'commons' ? Metamaps.Mappers : Metamaps.Collaborators
|
||||||
var string = ''
|
var string = ''
|
||||||
string += '<ul>'
|
string += '<ul>'
|
||||||
|
|
||||||
Metamaps.Mappers.each(function (m) {
|
relevantPeople.each(function (m) {
|
||||||
string += '<li><a href="/explore/mapper/' + m.get('id') + '">' + '<img class="rtUserImage" width="25" height="25" src="' + m.get('image') + '" />' + m.get('name') + '</a></li>'
|
string += '<li><a href="/explore/mapper/' + m.get('id') + '">' + '<img class="rtUserImage" width="25" height="25" src="' + m.get('image') + '" />' + m.get('name') + '</a></li>'
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -576,18 +580,19 @@ Metamaps.Map.InfoBox = {
|
||||||
updateNumbers: function () {
|
updateNumbers: function () {
|
||||||
var self = Metamaps.Map.InfoBox
|
var self = Metamaps.Map.InfoBox
|
||||||
var mapper = Metamaps.Active.Mapper
|
var mapper = Metamaps.Active.Mapper
|
||||||
|
var relevantPeople = Metamaps.Active.Map.get('permission') === 'commons' ? Metamaps.Mappers : Metamaps.Collaborators
|
||||||
|
|
||||||
var contributors_class = ''
|
var contributors_class = ''
|
||||||
if (Metamaps.Mappers.length === 2) contributors_class = 'multiple mTwo'
|
if (relevantPeople.length === 2) contributors_class = 'multiple mTwo'
|
||||||
else if (Metamaps.Mappers.length > 2) contributors_class = 'multiple'
|
else if (relevantPeople.length > 2) contributors_class = 'multiple'
|
||||||
|
|
||||||
var contributors_image = "<%= asset_path('user.png') %>"
|
var contributors_image = "<%= asset_path('user.png') %>"
|
||||||
if (Metamaps.Mappers.length > 0) {
|
if (relevantPeople.length > 0) {
|
||||||
// get the first contributor and use their image
|
// get the first contributor and use their image
|
||||||
contributors_image = Metamaps.Mappers.models[0].get('image')
|
contributors_image = relevantPeople.models[0].get('image')
|
||||||
}
|
}
|
||||||
$('.mapContributors img').attr('src', contributors_image).removeClass('multiple mTwo').addClass(contributors_class)
|
$('.mapContributors img').attr('src', contributors_image).removeClass('multiple mTwo').addClass(contributors_class)
|
||||||
$('.mapContributors span').text(Metamaps.Mappers.length)
|
$('.mapContributors span').text(relevantPeople.length)
|
||||||
$('.mapContributors .tip').html(self.createContributorList())
|
$('.mapContributors .tip').html(self.createContributorList())
|
||||||
$('.mapTopics').text(Metamaps.Topics.length)
|
$('.mapTopics').text(Metamaps.Topics.length)
|
||||||
$('.mapSynapses').text(Metamaps.Synapses.length)
|
$('.mapSynapses').text(Metamaps.Synapses.length)
|
||||||
|
|
|
@ -490,6 +490,8 @@ Metamaps.Backbone.init = function () {
|
||||||
|
|
||||||
Metamaps.Mappers = Metamaps.Mappers ? new self.MapperCollection(Metamaps.Mappers) : new self.MapperCollection();
|
Metamaps.Mappers = Metamaps.Mappers ? new self.MapperCollection(Metamaps.Mappers) : new self.MapperCollection();
|
||||||
|
|
||||||
|
Metamaps.Collaborators = Metamaps.Collaborators ? new self.MapperCollection(Metamaps.Collaborators) : new self.MapperCollection();
|
||||||
|
|
||||||
// this is for topic view
|
// this is for topic view
|
||||||
Metamaps.Creators = Metamaps.Creators ? new self.MapperCollection(Metamaps.Creators) : new self.MapperCollection();
|
Metamaps.Creators = Metamaps.Creators ? new self.MapperCollection(Metamaps.Creators) : new self.MapperCollection();
|
||||||
|
|
||||||
|
|
|
@ -88,12 +88,13 @@ class MapsController < ApplicationController
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html {
|
format.html {
|
||||||
@allmappers = @map.contributors
|
@allmappers = @map.contributors
|
||||||
|
@allcollaborators = @map.editors
|
||||||
@alltopics = @map.topics.to_a.delete_if {|t| not policy(t).show? }
|
@alltopics = @map.topics.to_a.delete_if {|t| not policy(t).show? }
|
||||||
@allsynapses = @map.synapses.to_a.delete_if {|s| not policy(s).show? }
|
@allsynapses = @map.synapses.to_a.delete_if {|s| not policy(s).show? }
|
||||||
@allmappings = @map.mappings.to_a.delete_if {|m| not policy(m).show? }
|
@allmappings = @map.mappings.to_a.delete_if {|m| not policy(m).show? }
|
||||||
@allmessages = @map.messages.sort_by(&:created_at)
|
@allmessages = @map.messages.sort_by(&:created_at)
|
||||||
|
|
||||||
respond_with(@allmappers, @allmappings, @allsynapses, @alltopics, @allmessages, @map)
|
respond_with(@allmappers, @allcollaborators, @allmappings, @allsynapses, @alltopics, @allmessages, @map)
|
||||||
}
|
}
|
||||||
format.json { render json: @map }
|
format.json { render json: @map }
|
||||||
format.csv { redirect_to action: :export, format: :csv }
|
format.csv { redirect_to action: :export, format: :csv }
|
||||||
|
@ -138,6 +139,7 @@ class MapsController < ApplicationController
|
||||||
authorize @map
|
authorize @map
|
||||||
|
|
||||||
@allmappers = @map.contributors
|
@allmappers = @map.contributors
|
||||||
|
@allcollaborators = @map.editors
|
||||||
@alltopics = @map.topics.to_a.delete_if {|t| not policy(t).show? }
|
@alltopics = @map.topics.to_a.delete_if {|t| not policy(t).show? }
|
||||||
@allsynapses = @map.synapses.to_a.delete_if {|s| not policy(s).show? }
|
@allsynapses = @map.synapses.to_a.delete_if {|s| not policy(s).show? }
|
||||||
@allmappings = @map.mappings.to_a.delete_if {|m| not policy(m).show? }
|
@allmappings = @map.mappings.to_a.delete_if {|m| not policy(m).show? }
|
||||||
|
@ -149,6 +151,7 @@ class MapsController < ApplicationController
|
||||||
@json['synapses'] = @allsynapses
|
@json['synapses'] = @allsynapses
|
||||||
@json['mappings'] = @allmappings
|
@json['mappings'] = @allmappings
|
||||||
@json['mappers'] = @allmappers
|
@json['mappers'] = @allmappers
|
||||||
|
@json['collaborators'] = @allcollaborators
|
||||||
@json['messages'] = @map.messages.sort_by(&:created_at)
|
@json['messages'] = @map.messages.sort_by(&:created_at)
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
|
@ -241,6 +244,7 @@ class MapsController < ApplicationController
|
||||||
removed = @map.collaborators.select { |user| not userIds.include?(user.id) }.map(&:id)
|
removed = @map.collaborators.select { |user| not userIds.include?(user.id) }.map(&:id)
|
||||||
added.each { |uid|
|
added.each { |uid|
|
||||||
um = UserMap.create({ user_id: uid.to_i, map_id: @map.id })
|
um = UserMap.create({ user_id: uid.to_i, map_id: @map.id })
|
||||||
|
# send email here
|
||||||
}
|
}
|
||||||
removed.each { |uid|
|
removed.each { |uid|
|
||||||
@map.user_maps.select{ |um| um.user_id == uid }.each{ |um| um.destroy }
|
@map.user_maps.select{ |um| um.user_id == uid }.each{ |um| um.destroy }
|
||||||
|
|
|
@ -48,6 +48,10 @@ class Map < ActiveRecord::Base
|
||||||
return contributors
|
return contributors
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def editors
|
||||||
|
collaborators + [self.user]
|
||||||
|
end
|
||||||
|
|
||||||
def topic_count
|
def topic_count
|
||||||
topics.length
|
topics.length
|
||||||
end
|
end
|
||||||
|
|
|
@ -12,17 +12,18 @@
|
||||||
|
|
||||||
<div class="mapInfoStat">
|
<div class="mapInfoStat">
|
||||||
<div class="infoStatIcon mapContributors hoverForTip">
|
<div class="infoStatIcon mapContributors hoverForTip">
|
||||||
<% if @map.contributors.count == 0 %>
|
<% relevantPeople = @map.permission == "commons" ? @map.contributors : @map.editors %>
|
||||||
|
<% if relevantPeople.count == 0 %>
|
||||||
<img id="mapContribs" width="25" height="25" src="<%= asset_path('user.png'); %>" />
|
<img id="mapContribs" width="25" height="25" src="<%= asset_path('user.png'); %>" />
|
||||||
<% elsif @map.contributors.count == 1 %>
|
<% elsif relevantPeople.count == 1 %>
|
||||||
<img id="mapContribs" width="25" height="25" src="<%= @map.contributors[0].image.url(:thirtytwo) %>" />
|
<img id="mapContribs" width="25" height="25" src="<%= relevantPeople[0].image.url(:thirtytwo) %>" />
|
||||||
<% elsif @map.contributors.count == 2 %>
|
<% elsif relevantPeople.count == 2 %>
|
||||||
<img id="mapContribs" width="25" height="25" src="<%= @map.contributors[0].image.url(:thirtytwo) %>" class="multiple mTwo" />
|
<img id="mapContribs" width="25" height="25" src="<%= relevantPeople[0].image.url(:thirtytwo) %>" class="multiple mTwo" />
|
||||||
<% elsif @map.contributors.count > 2 %>
|
<% elsif relevantPeople.count > 2 %>
|
||||||
<img id="mapContribs" width="25" height="25" src="<%= @map.contributors[0].image.url(:thirtytwo) %>" class="multiple" />
|
<img id="mapContribs" width="25" height="25" src="<%= relevantPeople[0].image.url(:thirtytwo) %>" class="multiple" />
|
||||||
<% end %>
|
<% end %>
|
||||||
<span><%= @map.contributors.count %></span>
|
<span><%= relevantPeople.count %></span>
|
||||||
<div class="tip"> <ul><% @map.contributors.each_with_index do |c, index| %>
|
<div class="tip"> <ul><% relevantPeople.each_with_index do |c, index| %>
|
||||||
<li ><a href="/explore/mapper/<%= c.id %>" > <img class="rtUserImage" width="25" height="25" src="<%= asset_path c.image.url(:thirtytwo) %>" />
|
<li ><a href="/explore/mapper/<%= c.id %>" > <img class="rtUserImage" width="25" height="25" src="<%= asset_path c.image.url(:thirtytwo) %>" />
|
||||||
<%= c.name %></a>
|
<%= c.name %></a>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
Metamaps.currentPage = <%= @map.id.to_s %>;
|
Metamaps.currentPage = <%= @map.id.to_s %>;
|
||||||
Metamaps.Active.Map = <%= @map.to_json.html_safe %>;
|
Metamaps.Active.Map = <%= @map.to_json.html_safe %>;
|
||||||
Metamaps.Mappers = <%= @allmappers.to_json.html_safe %>;
|
Metamaps.Mappers = <%= @allmappers.to_json.html_safe %>;
|
||||||
|
Metamaps.Collaborators = <%= @allcollaborators.to_json.html_safe %>;
|
||||||
Metamaps.Topics = <%= @alltopics.to_json.html_safe %>;
|
Metamaps.Topics = <%= @alltopics.to_json.html_safe %>;
|
||||||
Metamaps.Synapses = <%= @allsynapses.to_json.html_safe %>;
|
Metamaps.Synapses = <%= @allsynapses.to_json.html_safe %>;
|
||||||
Metamaps.Mappings = <%= @allmappings.to_json.html_safe %>;
|
Metamaps.Mappings = <%= @allmappings.to_json.html_safe %>;
|
||||||
|
|
|
@ -40,16 +40,13 @@ Metamaps::Application.routes.draw do
|
||||||
post 'maps/:id/events/:event', to: 'maps#events'
|
post 'maps/:id/events/:event', to: 'maps#events'
|
||||||
get 'maps/:id/contains', to: 'maps#contains', as: :contains
|
get 'maps/:id/contains', to: 'maps#contains', as: :contains
|
||||||
post 'maps/:id/upload_screenshot', to: 'maps#screenshot', as: :screenshot
|
post 'maps/:id/upload_screenshot', to: 'maps#screenshot', as: :screenshot
|
||||||
|
post 'maps/:id/access', to: 'maps#access', as: :access, defaults: {format: :json}
|
||||||
|
|
||||||
get 'explore/active', to: 'maps#activemaps'
|
get 'explore/active', to: 'maps#activemaps'
|
||||||
get 'explore/featured', to: 'maps#featuredmaps'
|
get 'explore/featured', to: 'maps#featuredmaps'
|
||||||
get 'explore/mine', to: 'maps#mymaps'
|
get 'explore/mine', to: 'maps#mymaps'
|
||||||
get 'explore/shared', to: 'maps#sharedmaps'
|
get 'explore/shared', to: 'maps#sharedmaps'
|
||||||
get 'explore/mapper/:id', to: 'maps#usermaps'
|
get 'explore/mapper/:id', to: 'maps#usermaps'
|
||||||
|
|
||||||
get 'maps/:id/contains', to: 'maps#contains', as: :contains
|
|
||||||
post 'maps/:id/upload_screenshot', to: 'maps#screenshot', as: :screenshot
|
|
||||||
post 'maps/:id/access', to: 'maps#access', as: :access, defaults: {format: :json}
|
|
||||||
|
|
||||||
devise_for :users, controllers: { registrations: 'users/registrations', passwords: 'users/passwords', sessions: 'devise/sessions' }, :skip => :sessions
|
devise_for :users, controllers: { registrations: 'users/registrations', passwords: 'users/passwords', sessions: 'devise/sessions' }, :skip => :sessions
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue