From e227a523fd14b79d34da9eff6deb0e83100a8b03 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Tue, 1 Sep 2015 11:27:12 -0700 Subject: [PATCH] show work-tasks on talk web frontend, clean up {foo}=React.DOM --- mar/talk/report.hoon | 11 ++-- .../src/js/components/MemberComponent.coffee | 2 +- .../js/components/MessagesComponent.coffee | 28 +++++----- .../js/components/StationsComponent.coffee | 2 +- .../src/js/components/TalkComponent.coffee | 2 +- .../src/js/components/WritingComponent.coffee | 2 +- pub/talk/src/js/main.js | 56 +++++++++++-------- 7 files changed, 59 insertions(+), 44 deletions(-) diff --git a/mar/talk/report.hoon b/mar/talk/report.hoon index 42c49a4d37..ad9fae91bd 100644 --- a/mar/talk/report.hoon +++ b/mar/talk/report.hoon @@ -87,11 +87,12 @@ |= a=speech %+ joba -.a ?+ -.a ~|(stub/-.a !!) - %lin (jobe say/[%b p.a] txt/[%s q.a] ~) - %url (jobe url/[%s (crip (earf p.a))] ~) - %exp (jobe code/[%s p.a] ~) - %app (jobe app/[%s p.a] txt/[%s q.a] ~) - %fat (jobe fat/(tors p.a) taf/$(a q.a) ~) + %lin (jobe txt/[%s q.a] say/[%b p.a] ~) + %url (joba txt/[%s (crip (earf p.a))]) + %exp (joba txt/[%s p.a]) + %tax (joba txt/(jape )) + %app (jobe txt/[%s q.a] src/[%s p.a] ~) + %fat (jobe tor/(tors p.a) taf/$(a q.a) ~) :: %inv (jobe ship/(jope p.a) party/[%s q.a] ~) == :: diff --git a/pub/talk/src/js/components/MemberComponent.coffee b/pub/talk/src/js/components/MemberComponent.coffee index 965320ca19..5dff6db471 100644 --- a/pub/talk/src/js/components/MemberComponent.coffee +++ b/pub/talk/src/js/components/MemberComponent.coffee @@ -1,5 +1,5 @@ recl = React.createClass -[div,input,textarea] = [React.DOM.div,React.DOM.input,React.DOM.textarea] +{div,input,textarea} = React.DOM module.exports = recl render: -> diff --git a/pub/talk/src/js/components/MessagesComponent.coffee b/pub/talk/src/js/components/MessagesComponent.coffee index f9878d6ace..c67b5f79d9 100644 --- a/pub/talk/src/js/components/MessagesComponent.coffee +++ b/pub/talk/src/js/components/MessagesComponent.coffee @@ -1,7 +1,7 @@ moment = require 'moment-timezone' recl = React.createClass -[div,pre,br,input,textarea,a] = [React.DOM.div,React.DOM.pre,React.DOM.br,React.DOM.input,React.DOM.textarea,React.DOM.a] +{div,pre,br,input,textarea,a} = React.DOM MessageActions = require '../actions/MessageActions.coffee' MessageStore = require '../stores/MessageStore.coffee' @@ -51,17 +51,19 @@ Message = recl type = ['private','public'] type = type[Number(aude.indexOf(window.util.mainStationPath(window.urb.user)) is -1)] - if speech.lin?.txt then txt = speech.lin.txt - if speech.url - url = speech.url.url - txt = (a {href:url,target:"_blank"}, url) - if speech.app - txt = speech.app.txt - klass += " say" - if speech.exp - txt = speech.exp.code - klass += " exp" - + mess = switch + when (con = speech.lin) or (con = speech.app) or + (con = speech.exp) or (con = speech.tax) + con.txt + when (con = speech.url) + (a {href:con.txt,target:"_blank"}, con.txt) + else "Unknown speech type:" + (" %"+x for x of speech).join '' + + klass += switch + when speech.app? then " say" + when speech.exp? then " exp" + else "" + div {className:"message#{klass}"}, [ (div {className:"attr"}, [ div {className:"type #{type}"}, "" @@ -69,7 +71,7 @@ Message = recl div {onClick:@_handleAudi,className:"audi"}, audi div {className:"time"}, @convTime @props.thought.statement.date ]) - div {className:"mess"}, txt, + div {className:"mess"}, mess, if attachments.length div {className:"fat"}, attachments ] diff --git a/pub/talk/src/js/components/StationsComponent.coffee b/pub/talk/src/js/components/StationsComponent.coffee index 7940a2aae5..0309ffc32b 100644 --- a/pub/talk/src/js/components/StationsComponent.coffee +++ b/pub/talk/src/js/components/StationsComponent.coffee @@ -1,5 +1,5 @@ recl = React.createClass -[div,input] = [React.DOM.div,React.DOM.input] +{div,input} = React.DOM StationStore = require '../stores/StationStore.coffee' StationActions = require '../actions/StationActions.coffee' diff --git a/pub/talk/src/js/components/TalkComponent.coffee b/pub/talk/src/js/components/TalkComponent.coffee index d9191c9b58..ae816c81e5 100644 --- a/pub/talk/src/js/components/TalkComponent.coffee +++ b/pub/talk/src/js/components/TalkComponent.coffee @@ -1,6 +1,6 @@ recl = React.createClass recf = React.createFactory -[div] = [React.DOM.div] +{div} = React.DOM StationComponent = recf require './StationComponent.coffee' MessagesComponent = recf require './MessagesComponent.coffee' diff --git a/pub/talk/src/js/components/WritingComponent.coffee b/pub/talk/src/js/components/WritingComponent.coffee index 7e6ae4b5ed..0b065f0285 100644 --- a/pub/talk/src/js/components/WritingComponent.coffee +++ b/pub/talk/src/js/components/WritingComponent.coffee @@ -1,5 +1,5 @@ recl = React.createClass -[div,br,input,textarea] = [React.DOM.div,React.DOM.br,React.DOM.input,React.DOM.textarea] +{div,br,input,textarea} = React.DOM MessageActions = require '../actions/MessageActions.coffee' MessageStore = require '../stores/MessageStore.coffee' diff --git a/pub/talk/src/js/main.js b/pub/talk/src/js/main.js index 3abab17e6b..df9980e677 100644 --- a/pub/talk/src/js/main.js +++ b/pub/talk/src/js/main.js @@ -184,7 +184,7 @@ var div, input, recl, ref, textarea; recl = React.createClass; -ref = [React.DOM.div, React.DOM.input, React.DOM.textarea], div = ref[0], input = ref[1], textarea = ref[2]; +ref = React.DOM, div = ref.div, input = ref.input, textarea = ref.textarea; module.exports = recl({ render: function() { @@ -215,7 +215,7 @@ moment = require('moment-timezone'); recl = React.createClass; -ref = [React.DOM.div, React.DOM.pre, React.DOM.br, React.DOM.input, React.DOM.textarea, React.DOM.a], div = ref[0], pre = ref[1], br = ref[2], input = ref[3], textarea = ref[4], a = ref[5]; +ref = React.DOM, div = ref.div, pre = ref.pre, br = ref.br, input = ref.input, textarea = ref.textarea, a = ref.a; MessageActions = require('../actions/MessageActions.coffee'); @@ -262,7 +262,7 @@ Message = recl({ return this.props._handlePm(user); }, render: function() { - var attachments, aude, audi, delivery, klass, name, ref1, ref2, speech, txt, type, url; + var attachments, aude, audi, con, delivery, klass, mess, name, ref1, speech, type, x; delivery = _.uniq(_.pluck(this.props.thought.audience, "delivery")); klass = delivery.indexOf("received") !== -1 ? " received" : " pending"; speech = this.props.thought.statement.speech; @@ -295,24 +295,36 @@ Message = recl({ }); type = ['private', 'public']; type = type[Number(aude.indexOf(window.util.mainStationPath(window.urb.user)) === -1)]; - if ((ref2 = speech.lin) != null ? ref2.txt : void 0) { - txt = speech.lin.txt; - } - if (speech.url) { - url = speech.url.url; - txt = a({ - href: url, - target: "_blank" - }, url); - } - if (speech.app) { - txt = speech.app.txt; - klass += " say"; - } - if (speech.exp) { - txt = speech.exp.code; - klass += " exp"; - } + mess = (function() { + switch (false) { + case !((con = speech.lin) || (con = speech.app) || (con = speech.exp) || (con = speech.tax)): + return con.txt; + case !(con = speech.url): + return a({ + href: con.txt, + target: "_blank" + }, con.txt); + default: + return "Unknown speech type:" + ((function() { + var results; + results = []; + for (x in speech) { + results.push(" %" + x); + } + return results; + })()).join(''); + } + })(); + klass += (function() { + switch (false) { + case speech.app == null: + return " say"; + case speech.exp == null: + return " exp"; + default: + return ""; + } + })(); return div({ className: "message" + klass }, [ @@ -333,7 +345,7 @@ Message = recl({ }, this.convTime(this.props.thought.statement.date)) ]), div({ className: "mess" - }, txt, attachments.length ? div({ + }, mess, attachments.length ? div({ className: "fat" }, attachments) : void 0) ]);