objectID: number;
authorID: number;
author: string;
- time: number;
+ time: string;
+ title: string;
link: string;
avatar: string;
};
objectID: number;
authorID: number;
author: string;
- time: number;
+ time: string;
link: string;
+ title: string;
avatar: string;
message: string;
};
import { getTabMenu } from "WoltLabSuite/Core/Component/Message/MessageTabMenu";
import { getPhrase } from "WoltLabSuite/Core/Language";
import { setActiveEditor } from "WoltLabSuite/Core/Component/Quote/Message";
-import { getQuotes } from "WoltLabSuite/Core/Component/Quote/Storage";
+import { getQuotes, getMessage } from "WoltLabSuite/Core/Component/Quote/Storage";
+import DomUtil from "WoltLabSuite/Core/Dom/Util";
const quoteLists = new Map<string, QuoteList>();
public renderQuotes(): void {
this.#container.innerHTML = "";
- for (const [, quotes] of getQuotes()) {
+ for (const [key, quotes] of getQuotes()) {
+ const message = getMessage(key)!;
+
+ // TODO escape values
+ // TODO create web components???
+ this.#container.append(
+ DomUtil.createFragmentFromHtml(`<article class="message messageReduced jsInvalidQuoteTarget">
+ <div class="messageContent">
+ <header class="messageHeader">
+ <div class="box32 messageHeaderWrapper">
+ <!-- TODO load real avatar -->
+ <span><img src="${window.WCF_PATH}images/avatars/avatar-default.svg" alt="" class="userAvatarImage" style="width: 32px; height: 32px"></span>
+ <div class="messageHeaderBox">
+ <h2 class="messageTitle">
+ <a href="${message.link}">${message.title}</a>
+ </h2>
+ <ul class="messageHeaderMetaData">
+ <!-- TODO add link to author profile -->
+ <li><span class="username">${message.author}</span></li>
+ <li><span class="messagePublicationTime"><woltlab-core-date-time date="${message.time}">${message.time}</woltlab-core-date-time></span></li>
+ </ul>
+ </div>
+ </div>
+ </header>
+ <div class="messageBody">
+ <div class="messageText">
+ <ul class="messageQuoteItemList">
+ ${Array.from(quotes)
+ .map(
+ (quote) => `<li>
+ <span>
+ <input type="checkbox" value="1" class="jsCheckbox">
+ <button type="button" class="jsTooltip jsInsertQuote" title="${getPhrase("wcf.message.quote.insertQuote")}">
+ </button>
+ </span>
+
+ <div class="jsQuote">
+ ${quote}
+ </div>
+</li>`,
+ )
+ .join("")}
+ </ul>
+ </div>
+ </div>
+ </div>
+</article>`),
+ );
// TODO render quotes
}
interface Message {
objectID: number;
- time: number;
+ time: string;
+ title: string;
link: string;
authorID: number;
author: string;
{
objectID: result.value.objectID,
time: result.value.time,
+ title: result.value.title,
link: result.value.link,
authorID: result.value.authorID,
author: result.value.author,
return getStorage().quotes;
}
+export function getMessage(objectType: string, objectId?: number): Message | undefined {
+ const key = objectId ? getKey(objectType, objectId) : objectType;
+
+ return getStorage().messages.get(key);
+}
+
function getStorage(): StorageData {
const data = window.localStorage.getItem(STORAGE_KEY);
if (data === null) {
* @since 6.2
* @woltlabExcludeBundle tiny
*/
-define(["require", "exports", "WoltLabSuite/Core/Component/Ckeditor/Event", "WoltLabSuite/Core/Component/Message/MessageTabMenu", "WoltLabSuite/Core/Language", "WoltLabSuite/Core/Component/Quote/Message", "WoltLabSuite/Core/Component/Quote/Storage"], function (require, exports, Event_1, MessageTabMenu_1, Language_1, Message_1, Storage_1) {
+define(["require", "exports", "tslib", "WoltLabSuite/Core/Component/Ckeditor/Event", "WoltLabSuite/Core/Component/Message/MessageTabMenu", "WoltLabSuite/Core/Language", "WoltLabSuite/Core/Component/Quote/Message", "WoltLabSuite/Core/Component/Quote/Storage", "WoltLabSuite/Core/Dom/Util"], function (require, exports, tslib_1, Event_1, MessageTabMenu_1, Language_1, Message_1, Storage_1, Util_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getQuoteList = getQuoteList;
exports.setup = setup;
+ Util_1 = tslib_1.__importDefault(Util_1);
const quoteLists = new Map();
class QuoteList {
#container;
}
renderQuotes() {
this.#container.innerHTML = "";
- for (const [, quotes] of (0, Storage_1.getQuotes)()) {
+ for (const [key, quotes] of (0, Storage_1.getQuotes)()) {
+ const message = (0, Storage_1.getMessage)(key);
+ // TODO escape values
+ // TODO create web components???
+ this.#container.append(Util_1.default.createFragmentFromHtml(`<article class="message messageReduced jsInvalidQuoteTarget">
+ <div class="messageContent">
+ <header class="messageHeader">
+ <div class="box32 messageHeaderWrapper">
+ <!-- TODO load real avatar -->
+ <span><img src="${window.WCF_PATH}images/avatars/avatar-default.svg" alt="" class="userAvatarImage" style="width: 32px; height: 32px"></span>
+ <div class="messageHeaderBox">
+ <h2 class="messageTitle">
+ <a href="${message.link}">${message.title}</a>
+ </h2>
+ <ul class="messageHeaderMetaData">
+ <!-- TODO add link to author profile -->
+ <li><span class="username">${message.author}</span></li>
+ <li><span class="messagePublicationTime"><woltlab-core-date-time date="${message.time}">${message.time}</woltlab-core-date-time></span></li>
+ </ul>
+ </div>
+ </div>
+ </header>
+ <div class="messageBody">
+ <div class="messageText">
+ <ul class="messageQuoteItemList">
+ ${Array.from(quotes)
+ .map((quote) => `<li>
+ <span>
+ <input type="checkbox" value="1" class="jsCheckbox">
+ <button type="button" class="jsTooltip jsInsertQuote" title="${(0, Language_1.getPhrase)("wcf.message.quote.insertQuote")}">
+ </button>
+ </span>
+
+ <div class="jsQuote">
+ <label for="quote_{@$quoteID}">
+ ${quote}
+ </label>
+ </div>
+</li>`)
+ .join("")}
+ </ul>
+ </div>
+ </div>
+ </div>
+</article>`));
// TODO render quotes
}
if (this.#container.hasChildNodes()) {
"objectID" => $object->getObjectID(),
"authorID" => $userProfile->getUserID(),
"author" => $userProfile->getUsername(),
+ "title" => $object->getTitle(),
"avatar" => $userProfile->getAvatar()->getURL(),
- "time" => $object->getTime(),
+ "time" => (new \DateTime('@' . $object->getTime()))->format("c"),
"link" => $object->getLink(),
],
200,
"authorID" => $userProfile->getUserID(),
"author" => $userProfile->getUsername(),
"avatar" => $userProfile->getAvatar()->getURL(),
- "time" => $object->getTime(),
+ "time" => (new \DateTime('@' . $object->getTime()))->format("c"),
+ "title" => $object->getTitle(),
"link" => $object->getLink(),
"message" => $parameters->fullQuote ? $this->renderFullQuote($object) : ""
],