2016-01-26 08:36:56 +08:00
|
|
|
_ = require 'underscore'
|
|
|
|
React = require 'react'
|
2016-04-01 05:58:16 +08:00
|
|
|
{Actions, Utils} = require 'nylas-exports'
|
2016-02-19 02:00:11 +08:00
|
|
|
{InjectedComponentSet, ListTabular} = require 'nylas-component-kit'
|
|
|
|
|
2016-02-05 06:14:24 +08:00
|
|
|
|
2016-01-26 08:36:56 +08:00
|
|
|
snippet = (html) =>
|
|
|
|
return "" unless html and typeof(html) is 'string'
|
|
|
|
try
|
2016-04-01 05:58:16 +08:00
|
|
|
text = Utils.extractTextFromHtml(html, maxLength: 400)
|
2016-01-26 08:36:56 +08:00
|
|
|
text[0..200]
|
|
|
|
catch
|
|
|
|
return ""
|
|
|
|
|
2016-03-18 00:50:30 +08:00
|
|
|
subject = (subj) ->
|
|
|
|
if (subj ? "").trim().length is 0
|
|
|
|
return <span className="no-subject">(No Subject)</span>
|
|
|
|
else
|
|
|
|
return subj
|
|
|
|
|
2016-02-05 06:14:24 +08:00
|
|
|
ParticipantsColumn = new ListTabular.Column
|
|
|
|
name: "Participants"
|
2016-01-26 08:36:56 +08:00
|
|
|
width: 200
|
|
|
|
resolver: (draft) =>
|
2016-02-05 06:14:24 +08:00
|
|
|
list = [].concat(draft.to, draft.cc, draft.bcc)
|
|
|
|
|
|
|
|
if list.length > 0
|
|
|
|
<div className="participants">
|
2016-02-19 04:14:18 +08:00
|
|
|
<span>{list.map((p) => p.displayName()).join(', ')}</span>
|
2016-02-05 06:14:24 +08:00
|
|
|
</div>
|
|
|
|
else
|
|
|
|
<div className="participants no-recipients">
|
|
|
|
(No Recipients)
|
|
|
|
</div>
|
2016-01-26 08:36:56 +08:00
|
|
|
|
2016-02-05 06:14:24 +08:00
|
|
|
ContentsColumn = new ListTabular.Column
|
|
|
|
name: "Contents"
|
2016-01-26 08:36:56 +08:00
|
|
|
flex: 4
|
|
|
|
resolver: (draft) =>
|
|
|
|
attachments = []
|
|
|
|
if draft.files?.length > 0
|
|
|
|
attachments = <div className="thread-icon thread-icon-attachment"></div>
|
|
|
|
<span className="details">
|
|
|
|
<span className="subject">{subject(draft.subject)}</span>
|
|
|
|
<span className="snippet">{snippet(draft.body)}</span>
|
|
|
|
{attachments}
|
|
|
|
</span>
|
|
|
|
|
2016-02-19 02:00:11 +08:00
|
|
|
StatusColumn = new ListTabular.Column
|
2016-02-05 06:14:24 +08:00
|
|
|
name: "State"
|
2016-01-26 08:36:56 +08:00
|
|
|
resolver: (draft) =>
|
2016-02-19 02:00:11 +08:00
|
|
|
<InjectedComponentSet
|
|
|
|
inline={true}
|
|
|
|
containersRequired={false}
|
|
|
|
matching={role: "DraftList:DraftStatus"}
|
|
|
|
className="draft-list-injected-state"
|
|
|
|
exposedProps={{draft}}/>
|
2016-01-26 08:36:56 +08:00
|
|
|
|
|
|
|
module.exports =
|
2016-02-19 02:00:11 +08:00
|
|
|
Wide: [ParticipantsColumn, ContentsColumn, StatusColumn]
|