membership

This commit is contained in:
Galen Wolfe-Pauly 2015-03-09 15:45:34 -07:00
parent 7373c47237
commit 7c846667e0
10 changed files with 122 additions and 84 deletions

View File

@ -137,8 +137,9 @@ body {
font-size: 4rem;
}
#station #station-container {
display: block;
padding-top: 1rem;
min-width: 30rem;
text-align: right;
}
#stations-container,
#messages-container {
@ -155,9 +156,13 @@ body {
#station > div {
display: inline-block;
}
#station-meta {
margin-right: 1rem;
margin-bottom: 1rem;
#station-meta .audi,
#station-meta .iden {
display: inline-block;
}
#station-meta .iden {
width: 6rem;
margin-left: 0.3rem;
}
#sources-container {
position: fixed;
@ -172,9 +177,6 @@ body {
#members {
margin-left: 2rem;
}
#station .iden {
display: block;
}
.station {
margin-bottom: 0.3rem;
cursor: pointer;
@ -247,6 +249,9 @@ body {
#messages .message:hover .time {
opacity: 1;
}
#messages .message .ship {
cursor: pointer;
}
.member {
width: 12rem;
margin: 0.3rem 0.6rem 0.3rem 0;
@ -278,6 +283,7 @@ body {
.attr .iden {
color: #000;
width: 6rem;
margin-left: 0.3rem;
}
.mess {
font-size: 0.9rem;
@ -317,6 +323,7 @@ body {
padding: 0.3rem;
margin-top: -0.3rem;
outline: none;
margin-right: -0.3rem;
}
#audi.valid-false {
color: #ff2f2f;

View File

@ -55,8 +55,9 @@ body
font-size 4rem
#station #station-container
display block
padding-top 1rem
min-width 30rem
text-align right
#stations-container
#messages-container
@ -73,9 +74,13 @@ body
#station > div
display inline-block
#station-meta
margin-right 1rem
margin-bottom 1rem
#station-meta .audi
#station-meta .iden
display inline-block
#station-meta .iden
width 6rem
margin-left .3rem
#sources-container
position fixed
@ -90,9 +95,6 @@ body
#members
margin-left 2rem
#station .iden
display block
.station
margin-bottom .3rem
cursor pointer
@ -166,6 +168,9 @@ body
#messages .message:hover .time
opacity 1
#messages .message .ship
cursor pointer
.member
width 12rem
margin .3rem .6rem .3rem 0
@ -197,6 +202,7 @@ body
.attr .iden
color #000
width 6rem
margin-left .3rem
.mess
font-size .9rem
@ -236,6 +242,7 @@ body
padding .3rem
margin-top -.3rem
outline none
margin-right -.3rem
#audi.valid-false
color #ff2f2f

View File

@ -58,11 +58,10 @@ module.exports =
type:"stations-load"
stations:stations
loadMembers: (station,members) ->
loadMembers: (members) ->
StationDispatcher.handleServerAction
type:"members-load"
members:members
station:station
createStation: (station) ->
StationDispatcher.handleViewAction

View File

@ -20,19 +20,15 @@ Message = recl
"~#{h}.#{m}.#{s}"
_handlePm: (e) ->
$t = $(e.target).closest('.iden')
console.log 'pm'
console.log window.util.mainStation $t.text().slice(1)
return if not @props._handlePm
user = $(e.target).closest('.iden').text().slice(1)
@props._handlePm user
render: ->
# pendingClass = if @props.pending isnt "received" then "pending" else ""
delivery = _.uniq _.pluck @props.thought.audience, "delivery"
pendingClass = if delivery.indexOf("received") isnt -1 then "received" else "pending"
if pendingClass is "pending"
console.log @props.thought
console.log delivery
name = if @props.name then @props.name else ""
audi = _.keys(@props.thought.audience)
audi = audi.join " "
@ -40,7 +36,7 @@ Message = recl
div {className:"message "+pendingClass}, [
(div {className:"attr"}, [
div {className:"audi"}, "#{audi}"
(Member {onClick:@_handlePm,ship:@props.ship}, "")
(div {onClick:@_handlePm}, (Member {ship:@props.ship}, ""))
(br {},"")
div {className:"time"}, @convTime @props.thought.statement.date
])
@ -106,6 +102,13 @@ module.exports = recl
_onChangeStore: -> @setState @stateFromStore()
_handlePm: (user) ->
audi = [
window.util.mainStationPath(user)
window.util.mainStationPath(window.urb.user)
]
StationActions.setAudience audi
render: ->
station = @state.station
_station = "~"+window.urb.ship+"/"+station
@ -128,5 +131,6 @@ module.exports = recl
messages = _messages.map (_message) =>
_message.station = @state.station
_message._handlePm = @_handlePm
Message _message, ""
div {id: "messages"}, messages

View File

@ -60,9 +60,10 @@ module.exports = recl
parts = []
members = []
if @state.station and @state.members[@state.station]
members = _.map @state.members[@state.station], (state,member) ->
Member {ship:member,presence:state.presence}
if @state.station and @state.members
members = _.map @state.members, (stations,member) ->
audi = _.map stations,(presence,station) -> (div {className:"audi"}, station)
(div {}, [audi,Member {ship:member}])
else
members = ""

View File

@ -98,7 +98,7 @@ module.exports = recl
valid
_setAudi: ->
valid = _validateAudi()
valid = @_validateAudi()
StationActions.setValidAudience valid
if valid is true
v = $('#audi').text()

View File

@ -8,7 +8,8 @@ $(() ->
window.chat.StationPersistence = require './persistence/StationPersistence.coffee'
window.util =
mainStation (user): ->
mainStationPath: (user) -> "~#{user}/#{window.util.mainStation(user)}"
mainStation: (user) ->
if not user then user = window.urb.user
switch user.length
when 3

View File

@ -154,11 +154,10 @@ module.exports = {
stations: stations
});
},
loadMembers: function(station, members) {
loadMembers: function(members) {
return StationDispatcher.handleServerAction({
type: "members-load",
members: members,
station: station
members: members
});
},
createStation: function(station) {
@ -237,19 +236,17 @@ Message = recl({
return "~" + h + "." + m + "." + s;
},
_handlePm: function(e) {
var $t;
$t = $(e.target).closest('.iden');
console.log('pm');
return console.log(window.util.mainStation($t.text().slice(1)));
var user;
if (!this.props._handlePm) {
return;
}
user = $(e.target).closest('.iden').text().slice(1);
return this.props._handlePm(user);
},
render: function() {
var audi, delivery, name, pendingClass;
delivery = _.uniq(_.pluck(this.props.thought.audience, "delivery"));
pendingClass = delivery.indexOf("received") !== -1 ? "received" : "pending";
if (pendingClass === "pending") {
console.log(this.props.thought);
console.log(delivery);
}
name = this.props.name ? this.props.name : "";
audi = _.keys(this.props.thought.audience);
audi = audi.join(" ");
@ -344,6 +341,11 @@ module.exports = recl({
_onChangeStore: function() {
return this.setState(this.stateFromStore());
},
_handlePm: function(user) {
var audi;
audi = [window.util.mainStationPath(user), window.util.mainStationPath(window.urb.user)];
return StationActions.setAudience(audi);
},
render: function() {
var _messages, _station, messages, ref1, ref2, sources, station;
station = this.state.station;
@ -367,6 +369,7 @@ module.exports = recl({
messages = _messages.map((function(_this) {
return function(_message) {
_message.station = _this.state.station;
_message._handlePm = _this._handlePm;
return Message(_message, "");
};
})(this));
@ -445,12 +448,19 @@ module.exports = recl({
var _remove, _sources, members, parts, sourceCtrl, sourceInput, sources, station;
parts = [];
members = [];
if (this.state.station && this.state.members[this.state.station]) {
members = _.map(this.state.members[this.state.station], function(state, member) {
return Member({
ship: member,
presence: state.presence
if (this.state.station && this.state.members) {
members = _.map(this.state.members, function(stations, member) {
var audi;
audi = _.map(stations, function(presence, station) {
return div({
className: "audi"
}, station);
});
return div({}, [
audi, Member({
ship: member
})
]);
});
} else {
members = "";
@ -749,7 +759,7 @@ module.exports = recl({
},
_setAudi: function() {
var a, i, len, v, valid;
valid = _validateAudi();
valid = this._validateAudi();
StationActions.setValidAudience(valid);
if (valid === true) {
v = $('#audi').text();
@ -875,8 +885,14 @@ $(function() {
window.chat.MessagePersistence = require('./persistence/MessagePersistence.coffee');
window.chat.StationPersistence = require('./persistence/StationPersistence.coffee');
window.util = {
mainStation: function() {
switch (window.urb.user.length) {
mainStationPath: function(user) {
return "~" + user + "/" + (window.util.mainStation(user));
},
mainStation: function(user) {
if (!user) {
user = window.urb.user;
}
switch (user.length) {
case 3:
return "court";
case 6:
@ -5496,8 +5512,8 @@ module.exports = {
if (res.data.ok === true) {
StationActions.listeningStation(station);
}
if ((ref = res.data.group) != null ? ref.local : void 0) {
StationActions.loadMembers(station, res.data.group.local);
if ((ref = res.data.group) != null ? ref.global : void 0) {
StationActions.loadMembers(res.data.group.global);
}
if (res.data.config) {
return StationActions.loadConfig(station, res.data.config);
@ -5720,21 +5736,26 @@ StationStore = _.merge(new EventEmitter, {
ship: ship
};
},
changeMember: function(dir, name, ship) {
if (dir === "out") {
_members = _.filter(_members, function(_member) {
return _member.ship !== ship;
});
loadMembers: function(members) {
var list, member, presence, results, station;
_members = {};
results = [];
for (station in members) {
list = members[station];
results.push((function() {
var results1;
results1 = [];
for (member in list) {
presence = list[member];
if (!_members[member]) {
_members[member] = {};
}
results1.push(_members[member][station] = presence);
}
return results1;
})());
}
if (dir === "in") {
return _members.push({
name: name,
ship: ship
});
}
},
loadMembers: function(station, members) {
return _members[station] = members;
return results;
},
getMembers: function() {
return _members;
@ -5835,7 +5856,7 @@ StationStore.dispatchToken = StationDispatcher.register(function(payload) {
StationStore.emitChange();
break;
case "members-load":
StationStore.loadMembers(action.station, action.members);
StationStore.loadMembers(action.members);
StationStore.emitChange();
break;
case "typing-set":

View File

@ -68,7 +68,7 @@ module.exports =
console.log(res.data)
if res.data.ok is true
StationActions.listeningStation station
if res.data.group?.local
StationActions.loadMembers station,res.data.group.local
if res.data.group?.global
StationActions.loadMembers res.data.group.global
if res.data.config
StationActions.loadConfig station,res.data.config

View File

@ -1,14 +1,14 @@
EventEmitter = require('events').EventEmitter
EventEmitter = require('events').EventEmitter
StationDispatcher = require '../dispatcher/Dispatcher.coffee'
_audience = []
_members = {}
_stations = []
_listening = []
_station = null
_config = {}
_typing = {}
_audience = []
_members = {}
_stations = []
_listening = []
_station = null
_config = {}
_typing = {}
_validAudience = true
@ -41,14 +41,12 @@ StationStore = _.merge new EventEmitter,{
getMember: (ship) -> {ship:ship}
changeMember: (dir,name,ship) ->
if dir is "out"
_members = _.filter _members, (_member) ->
return (_member.ship isnt ship)
if dir is "in"
_members.push {name:name, ship:ship}
loadMembers: (station,members) -> _members[station] = members
loadMembers: (members) ->
_members = {}
for station,list of members
for member,presence of list
_members[member] = {} if not _members[member]
_members[member][station] = presence
getMembers: -> _members
@ -131,7 +129,7 @@ StationStore.dispatchToken = StationDispatcher.register (payload) ->
StationStore.emitChange()
break
when "members-load"
StationStore.loadMembers action.station,action.members
StationStore.loadMembers action.members
StationStore.emitChange()
break
when "typing-set"