Apply suggestions from code review
[GitHub/WoltLab/com.woltlab.wcf.conversation.git] / templates / conversationList.tpl
1 {capture assign='pageTitle'}{if $filter}{lang}wcf.conversation.folder.{$filter}{/lang}{else}{$__wcf->getActivePage()->getTitle()}{/if}{if $pageNo > 1} - {lang}wcf.page.pageNo{/lang}{/if}{/capture}
2
3 {capture assign='contentHeader'}
4 <header class="contentHeader">
5 <div class="contentHeaderTitle">
6 <h1 class="contentTitle">{if $filter}{lang}wcf.conversation.folder.{$filter}{/lang}{else}{$__wcf->getActivePage()->getTitle()}{/if}</h1>
7 </div>
8
9 {hascontent}
10 <nav class="contentHeaderNavigation">
11 <ul>
12 {content}
13 {if $__wcf->session->getPermission('user.conversation.canStartConversation')}
14 <li>
15 <a href="{link controller='ConversationAdd'}{/link}" title="{lang}wcf.conversation.add{/lang}" class="button buttonPrimary">
16 {icon name='plus'}
17 <span>{lang}wcf.conversation.button.add{/lang}</span>
18 </a>
19 </li>
20 {/if}
21 {event name='contentHeaderNavigation'}
22 {/content}
23 </ul>
24 </nav>
25 {/hascontent}
26 </header>
27 {/capture}
28
29 {capture assign='headContent'}
30 <link rel="alternate" type="application/rss+xml" title="{lang}wcf.global.button.rss{/lang}" href="{link controller='ConversationFeed'}at={@$__wcf->getUser()->userID}-{@$__wcf->getUser()->accessToken}{/link}">
31 {/capture}
32
33 {capture assign='sidebarRight'}
34 <section class="box">
35 <h2 class="boxTitle">{lang}wcf.conversation.folders{/lang}</h2>
36
37 <div class="boxContent">
38 <nav>
39 <ol class="boxMenu">
40 <li{if $filter == ''} class="active"{/if}>
41 <a class="boxMenuLink" href="{link controller='ConversationList'}{/link}"><span class="boxMenuLinkTitle">{lang}wcf.conversation.conversations{/lang}</span>{if $conversationCount} <span class="badge">{#$conversationCount}</span>{/if}</a>
42 </li>
43 <li{if $filter == 'draft'} class="active"{/if}>
44 <a class="boxMenuLink" href="{link controller='ConversationList'}filter=draft{/link}"><span class="boxMenuLinkTitle">{lang}wcf.conversation.folder.draft{/lang}</span>{if $draftCount} <span class="badge">{#$draftCount}</span>{/if}</a>
45 </li>
46 <li{if $filter == 'outbox'} class="active"{/if}>
47 <a class="boxMenuLink" href="{link controller='ConversationList'}filter=outbox{/link}"><span class="boxMenuLinkTitle">{lang}wcf.conversation.folder.outbox{/lang}</span>{if $outboxCount} <span class="badge">{#$outboxCount}</span>{/if}</a>
48 </li>
49 <li{if $filter == 'hidden'} class="active"{/if}>
50 <a class="boxMenuLink" href="{link controller='ConversationList'}filter=hidden{/link}"><span class="boxMenuLinkTitle">{lang}wcf.conversation.folder.hidden{/lang}</span>{if $hiddenCount} <span class="badge">{#$hiddenCount}</span>{/if}</a>
51 </li>
52 </ol>
53 </nav>
54 </div>
55 </section>
56
57 <section class="box">
58 <h2 class="boxTitle">{lang}wcf.conversation.filter.participants{/lang}</h2>
59
60 <div class="boxContent">
61 <form action="{link controller='ConversationList'}{if $filter}filter={@$filter}&{/if}sortField={$sortField}&sortOrder={$sortOrder}&pageNo={@$pageNo}{/link}" method="post">
62 <dl>
63 <dt></dt>
64 <dd><label><textarea id="participants" name="participants" class="long">{implode from=$participants item=participant glue=','}{$participant}{/implode}</textarea></label></dd>
65 </dl>
66
67 <div class="formSubmit">
68 <input type="submit" value="{lang}wcf.global.button.submit{/lang}" accesskey="s">
69 {csrfToken}
70 </div>
71 </form>
72 </div>
73 </section>
74
75 <section class="box jsOnly">
76 <h2 class="boxTitle">{lang}wcf.conversation.label{/lang}</h2>
77
78 <div class="boxContent">
79 <div id="conversationLabelFilter" class="dropdown">
80 <div class="dropdownToggle" data-toggle="conversationLabelFilter">
81 {if $labelID}
82 {foreach from=$labelList item=label}
83 {if $label->labelID == $labelID}
84 <span class="badge label{if $label->cssClassName} {$label->cssClassName}{/if}">{$label->label}</span>
85 {/if}
86 {/foreach}
87 {else}
88 <span class="badge">{lang}wcf.conversation.label.filter{/lang}</span>
89 {/if}
90 </div>
91
92 <div class="dropdownMenu">
93 <ul class="scrollableDropdownMenu">
94 {foreach from=$labelList item=label}
95 <li><a href="{link controller='ConversationList'}{if $filter}filter={@$filter}&{/if}{if !$participants|empty}participants={implode from=$participants item=participant}{$participant|rawurlencode}{/implode}&{/if}sortField={$sortField}&sortOrder={$sortOrder}&pageNo={@$pageNo}&labelID={@$label->labelID}{/link}"><span class="badge label{if $label->cssClassName} {@$label->cssClassName}{/if}" data-css-class-name="{if $label->cssClassName}{@$label->cssClassName}{/if}" data-label-id="{$label->labelID}">{$label->label}</span></a></li>
96 {/foreach}
97 </ul>
98 <ul>
99 <li class="dropdownDivider"{if !$labelList|count} style="display: none;"{/if}></li>
100 <li><a href="{link controller='ConversationList'}{if $filter}filter={@$filter}&{/if}{if !$participants|empty}participants={implode from=$participants item=participant}{$participant|rawurlencode}{/implode}&{/if}sortField={$sortField}&sortOrder={$sortOrder}&pageNo={@$pageNo}{/link}"><span class="badge label">{lang}wcf.conversation.label.disableFilter{/lang}</span></a></li>
101 </ul>
102 </div>
103 </div>
104 </div>
105
106 <div class="boxContent">
107 <button type="button" id="manageLabel" class="button">{lang}wcf.conversation.label.management{/lang}</button>
108 </div>
109 </section>
110
111 {event name='beforeQuotaBox'}
112
113 <section class="box conversationQuota">
114 <h2 class="boxTitle">{lang}wcf.conversation.quota{/lang}</h2>
115
116 <div class="boxContent">
117 {assign var='conversationCount' value=$__wcf->getConversationHandler()->getConversationCount()}
118 {assign var='maxConversationCount' value=$__wcf->session->getPermission('user.conversation.maxConversations')}
119 {assign var='conversationCountValue' value=$conversationCount/$maxConversationCount*100}
120 <meter class="conversationQuotaMeter" min="0" max="100" low="90" high="99" value="{$conversationCountValue|ceil}" aria-label="{lang}wcf.conversation.quota{/lang}">
121 {#$conversationCountValue}&nbsp;%
122 </meter>
123 <p><small>{lang}wcf.conversation.quota.description{/lang}</small></p>
124 </div>
125 </section>
126
127 {event name='boxes'}
128 {/capture}
129
130 {capture assign='contentInteractionPagination'}
131 {assign var='participantsParameter' value=''}
132 {if $participants}{capture assign='participantsParameter'}&participants={implode from=$participants item=participant}{$participant|rawurlencode}{/implode}{/capture}{/if}
133 {assign var='labelIDParameter' value=''}
134 {if $labelID}{assign var='labelIDParameter' value="&labelID=$labelID"}{/if}
135 {pages print=true assign=pagesLinks controller='ConversationList' link="filter=$filter$participantsParameter&pageNo=%d&sortField=$sortField&sortOrder=$sortOrder$labelIDParameter"}
136 {/capture}
137
138 {capture assign='contentInteractionButtons'}
139 <button type="button" class="markAllAsReadButton contentInteractionButton button small jsOnly">
140 {icon name='check'}
141 <span>{lang}wcf.global.button.markAllAsRead{/lang}</span>
142 </button>
143 {/capture}
144
145 {capture assign='contentInteractionDropdownItems'}
146 <li><a rel="alternate" href="{link controller='ConversationFeed'}at={@$__wcf->getUser()->userID}-{@$__wcf->getUser()->accessToken}{/link}">{lang}wcf.global.button.rss{/lang}</a></li>
147 {/capture}
148
149 {include file='header'}
150
151 {if !$items}
152 <p class="info" role="status">{lang}wcf.conversation.noConversations{/lang}</p>
153 {else}
154 <div class="section tabularBox messageGroupList conversationList jsClipboardContainer" data-type="com.woltlab.wcf.conversation.conversation">
155 <ol class="tabularList">
156 <li class="tabularListRow tabularListRowHead">
157 <ol class="tabularListColumns">
158 <li class="columnMark jsOnly"><label><input type="checkbox" class="jsClipboardMarkAll"></label></li>
159
160 <li class="columnSort">
161 <ul class="inlineList">
162 <li>
163 <a rel="nofollow" href="{link controller='ConversationList'}{if $filter}filter={@$filter}&{/if}{if !$participants|empty}participants={implode from=$participants item=participant}{$participant|rawurlencode}{/implode}&{/if}pageNo={@$pageNo}&sortField={$sortField}&sortOrder={if $sortOrder == 'ASC'}DESC{else}ASC{/if}{if $labelID}&labelID={@$labelID}{/if}{/link}">
164 {if $sortOrder === 'ASC'}
165 <span class="jsTooltip" title="{lang}wcf.global.sorting{/lang} ({lang}wcf.global.sortOrder.ascending{/lang})">
166 {icon name='arrow-down-wide-short'}
167 </span>
168 {else}
169 <span class="jsTooltip" title="{lang}wcf.global.sorting{/lang} ({lang}wcf.global.sortOrder.descending{/lang})">
170 {icon name='arrow-down-short-wide'}
171 </span>
172 {/if}
173 </a>
174 </li>
175 <li>
176 <div class="dropdown">
177 <span class="dropdownToggle">{if $sortField == 'subject'}{lang}wcf.global.subject{/lang}{else}{lang}wcf.conversation.{$sortField}{/lang}{/if}</span>
178
179 <ul class="dropdownMenu">
180 {foreach from=$validSortFields item=_sortField}
181 <li{if $_sortField === $sortField} class="active"{/if}><a rel="nofollow" href="{link controller='ConversationList'}{if $filter}filter={@$filter}&{/if}{if !$participants|empty}participants={implode from=$participants item=participant}{$participant|rawurlencode}{/implode}&{/if}pageNo={@$pageNo}&sortField={$_sortField}&sortOrder={if $sortField === $_sortField}{if $sortOrder === 'DESC'}ASC{else}DESC{/if}{else}{$sortOrder}{/if}{if $labelID}&labelID={@$labelID}{/if}{/link}">{if $_sortField == 'subject'}{lang}wcf.global.subject{/lang}{else}{lang}wcf.conversation.{$_sortField}{/lang}{/if}</a></li>
182 {/foreach}
183 </ul>
184 </div>
185 </li>
186 </ul>
187 </li>
188 </ol>
189 </li>
190
191 {foreach from=$objects item=conversation}
192 <li class="tabularListRow">
193 <ol class="tabularListColumns messageGroup conversation jsClipboardObject{if $conversation->isNew()} new{/if}" data-conversation-id="{$conversation->conversationID}" data-label-ids="[ {implode from=$conversation->getAssignedLabels() item=label}{$label->labelID}{/implode} ]" data-is-closed="{$conversation->isClosed}" data-can-close-conversation="{if $conversation->userID == $__wcf->getUser()->userID}1{else}0{/if}" data-can-add-participants="{if $conversation->canAddParticipants()}1{else}0{/if}">
194 <li class="columnMark jsOnly">
195 <label><input type="checkbox" class="jsClipboardItem" data-object-id="{$conversation->conversationID}"></label>
196 </li>
197 <li class="columnIcon columnAvatar">
198 {if $conversation->getUserProfile()->getAvatar()}
199 <div>
200 <p{if $conversation->isNew()} title="{lang}wcf.conversation.markAsRead.doubleClick{/lang}"{/if}>{@$conversation->getUserProfile()->getAvatar()->getImageTag(48)}</p>
201
202 {if $conversation->ownPosts && $conversation->userID != $__wcf->user->userID}
203 {if $__wcf->getUserProfileHandler()->getAvatar()}
204 <small class="myAvatar jsTooltip" title="{lang}wcf.conversation.ownPosts{/lang}">{@$__wcf->getUserProfileHandler()->getAvatar()->getImageTag(24)}</small>
205 {/if}
206 {/if}
207 </div>
208 {/if}
209 </li>
210 <li class="columnSubject">
211 {hascontent}
212 <ul class="labelList">
213 {content}
214 {foreach from=$conversation->getAssignedLabels() item=label}
215 <li><a href="{link controller='ConversationList'}{if $filter}filter={@$filter}&{/if}{if !$participants|empty}participants={implode from=$participants item=participant}{$participant|rawurlencode}{/implode}&{/if}sortField={$sortField}&sortOrder={$sortOrder}&pageNo={@$pageNo}&labelID={@$label->labelID}{/link}" class="badge label{if $label->cssClassName} {@$label->cssClassName}{/if}">{$label->label}</a></li>
216 {/foreach}
217 {/content}
218 </ul>
219 {/hascontent}
220
221 <h3>
222 <a href="{if $conversation->isNew()}{link controller='Conversation' object=$conversation}action=firstNew{/link}{else}{$conversation->getLink()}{/if}" class="conversationLink messageGroupLink" data-object-id="{$conversation->conversationID}">{$conversation->subject}</a>
223 {if $conversation->replies}
224 <span class="badge messageGroupCounterMobile">{@$conversation->replies|shortUnit}</span>
225 {/if}
226 </h3>
227
228 <aside class="statusDisplay" role="presentation">
229 <ul class="statusIcons">
230 {if $conversation->isClosed}
231 <li>
232 <span class="jsIconLock jsTooltip" title="{lang}wcf.global.state.closed{/lang}">
233 {icon name='lock'}
234 </span>
235 </li>
236 {/if}
237 {if $conversation->attachments}
238 <li>
239 <span class="jsIconAttachment jsTooltip" title="{lang}wcf.conversation.attachments{/lang}">
240 {icon name='paperclip'}
241 </span>
242 </li>
243 {/if}
244 </ul>
245 </aside>
246
247 <ul class="inlineList dotSeparated small messageGroupInfo">
248 <li class="messageGroupAuthor">{user object=$conversation->getUserProfile()}</li>
249 <li class="messageGroupTime">{time time=$conversation->time}</li>
250 <li class="messageGroupEditLink jsOnly"><a href="#" class="jsConversationInlineEditor">{lang}wcf.global.button.edit{/lang}</a></li>
251 {event name='messageGroupInfo'}
252 </ul>
253
254 <ul class="messageGroupInfoMobile">
255 <li class="messageGroupAuthorMobile">{$conversation->username}</li>
256 <li class="messageGroupLastPostTimeMobile">{time time=$conversation->lastPostTime}</li>
257 </ul>
258
259 {if $conversation->getParticipantSummary()|count}
260 <small class="conversationParticipantSummary">
261 {assign var='participantSummaryCount' value=$conversation->getParticipantSummary()|count}
262 {lang}wcf.conversation.participants{/lang}: {implode from=$conversation->getParticipantSummary() item=participant}<a href="{$participant->getLink()}" class="userLink{if $participant->hideConversation == 2} conversationLeft{/if}" data-object-id="{$participant->userID}">{$participant->username}</a>{/implode}
263 {if $participantSummaryCount < $conversation->participants}{lang}wcf.conversation.participants.other{/lang}{/if}
264 </small>
265 {/if}
266
267 {event name='conversationData'}
268 </li>
269 <li class="columnStats">
270 <dl class="plain statsDataList">
271 <dt>{lang}wcf.conversation.replies{/lang}</dt>
272 <dd>{@$conversation->replies|shortUnit}</dd>
273 </dl>
274 <dl class="plain statsDataList">
275 <dt>{lang}wcf.conversation.participants{/lang}</dt>
276 <dd>{@$conversation->participants|shortUnit}</dd>
277 </dl>
278
279 <div class="messageGroupListStatsSimple">
280 {if $conversation->replies}
281 <span aria-label="{lang}wcf.conversation.replies{/lang}">
282 {icon name='comment'}
283 </span>
284 {@$conversation->replies|shortUnit}
285 {/if}
286 </div>
287 </li>
288 <li class="columnLastPost">
289 {if $conversation->replies != 0 && $conversation->lastPostTime}
290 <div class="box32">
291 <a href="{link controller='Conversation' object=$conversation}action=lastPost{/link}" class="jsTooltip" title="{lang}wcf.conversation.gotoLastPost{/lang}">{@$conversation->getLastPosterProfile()->getAvatar()->getImageTag(32)}</a>
292
293 <div>
294 <p>
295 {user object=$conversation->getLastPosterProfile()}
296 </p>
297 <small>{time time=$conversation->lastPostTime}</small>
298 </div>
299 </div>
300 {/if}
301 </li>
302
303 {event name='columns'}
304 </ol>
305 </li>
306 {/foreach}
307 </ol>
308 </div>
309 {/if}
310
311 <footer class="contentFooter">
312 {hascontent}
313 <div class="paginationBottom">
314 {content}{@$pagesLinks}{/content}
315 </div>
316 {/hascontent}
317
318 {hascontent}
319 <nav class="contentFooterNavigation">
320 <ul>
321 {content}
322 {if $__wcf->session->getPermission('user.conversation.canStartConversation')}
323 <li>
324 <a href="{link controller='ConversationAdd'}{/link}" title="{lang}wcf.conversation.add{/lang}" class="button buttonPrimary">
325 {icon name='plus'}
326 <span>{lang}wcf.conversation.button.add{/lang}</span>
327 </a>
328 </li>
329 {/if}
330 {event name='contentFooterNavigation'}
331 {/content}
332 </ul>
333 </nav>
334 {/hascontent}
335 </footer>
336
337 <script data-relocate="true" src="{$__wcf->getPath()}js/WCF.Conversation{if !ENABLE_DEBUG_MODE}.min{/if}.js?v={@LAST_UPDATE_TIME}"></script>
338 <script data-relocate="true">
339 require([
340 'WoltLabSuite/Core/Language',
341 'WoltLabSuite/Core/Controller/Popover',
342 'WoltLabSuite/Core/Ui/ItemList/User',
343 'WoltLabSuite/Core/Controller/Clipboard',
344 ], (
345 Language,
346 ControllerPopover,
347 UiItemListUser,
348 ControllerClipboard
349 ) => {
350 Language.addObject({
351 'wcf.conversation.edit.addParticipants': '{jslang}wcf.conversation.edit.addParticipants{/jslang}',
352 'wcf.conversation.edit.assignLabel': '{jslang}wcf.conversation.edit.assignLabel{/jslang}',
353 'wcf.conversation.edit.close': '{jslang}wcf.conversation.edit.close{/jslang}',
354 'wcf.conversation.edit.leave': '{jslang}wcf.conversation.edit.leave{/jslang}',
355 'wcf.conversation.edit.open': '{jslang}wcf.conversation.edit.open{/jslang}',
356 'wcf.conversation.edit.subject': '{jslang}wcf.conversation.edit.subject{/jslang}',
357 'wcf.conversation.label.management': '{jslang}wcf.conversation.label.management{/jslang}',
358 'wcf.conversation.label.management.addLabel.success': '{jslang}wcf.conversation.label.management.addLabel.success{/jslang}',
359 'wcf.conversation.label.management.deleteLabel.confirmMessage': '{jslang}wcf.conversation.label.management.deleteLabel.confirmMessage{/jslang}',
360 'wcf.conversation.label.management.editLabel': '{jslang}wcf.conversation.label.management.editLabel{/jslang}',
361 'wcf.conversation.label.placeholder': '{jslang}wcf.conversation.label.placeholder{/jslang}',
362 'wcf.conversation.leave.title': '{jslang}wcf.conversation.leave.title{/jslang}',
363 'wcf.global.state.closed': '{jslang}wcf.global.state.closed{/jslang}',
364 'wcf.global.subject': '{jslang}wcf.global.subject{/jslang}',
365 'wcf.conversation.label.assignLabels': '{jslang}wcf.conversation.label.assignLabels{/jslang}'
366 });
367
368 ControllerClipboard.setup({
369 pageClassName: 'wcf\\page\\ConversationListPage',
370 hasMarkedItems: {if $hasMarkedItems}true{else}false{/if},
371 });
372
373 var $editorHandler = new WCF.Conversation.EditorHandler();
374 var $inlineEditor = new WCF.Conversation.InlineEditor('.conversation');
375 $inlineEditor.setEditorHandler($editorHandler, 'list');
376
377 new WCF.Conversation.Clipboard($editorHandler);
378 new WCF.Conversation.Label.Manager('{link controller='ConversationList' encode=false}{if $filter}filter={@$filter}&{/if}{if !$participants|empty}participants={implode from=$participants item=participant}{$participant|rawurlencode}{/implode}&{/if}sortField={$sortField}&sortOrder={$sortOrder}&pageNo={@$pageNo}{/link}');
379
380 // mobile safari hover workaround
381 if ($(window).width() <= 800) {
382 $('.sidebar').addClass('mobileSidebar').hover(function() { });
383 }
384
385 UiItemListUser.init('participants', {
386 excludedSearchValues: ['{$__wcf->user->username|encodeJS}'],
387 maxItems: 20
388 });
389
390 ControllerPopover.init({
391 className: 'conversationLink',
392 dboAction: 'wcf\\data\\conversation\\ConversationAction',
393 identifier: 'com.woltlab.wcf.conversation'
394 });
395 });
396 </script>
397
398 <script data-relocate="true">
399 require(['WoltLabSuite/Core/Conversation/Ui/MarkAsRead'], (MarkAsRead) => {
400 MarkAsRead.setup();
401 });
402 require(['WoltLabSuite/Core/Conversation/Ui/MarkAllAsRead'], (MarkAllAsRead) => {
403 MarkAllAsRead.setup();
404 });
405 </script>
406
407 {include file='footer'}