UNPKG

@attivio/suit

Version:

Attivio SUIT, the Search UI Toolkit, is a library for creating search clients for searching the Attivio platform.

59 lines (41 loc) 1.66 kB
'use strict'; exports.__esModule = true; exports.default = undefined; var _SearchDocument = require('./SearchDocument'); var _SearchDocument2 = _interopRequireDefault(_SearchDocument); var _DateUtils = require('../util/DateUtils'); var _DateUtils2 = _interopRequireDefault(_DateUtils); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * A single comment for a SearchDocument. */ var Comment = function () { Comment.createTimestamp = function createTimestamp(date) { var d = _DateUtils2.default.stringToDate(date); return 'Posted on ' + d.toDateString() + ' at ' + d.toLocaleTimeString(); }; Comment.fromDoc = function fromDoc(doc) { var id = doc.getFirstValue('.id'); var text = doc.getFirstValue('comment_s'); var date = doc.getFirstValue('date'); var timestamp = Comment.createTimestamp(date); // const timestamp = doc.getFirstValue('date'); var username = doc.getFirstValue('username_s'); return new Comment(id, text, timestamp, username); }; /** The comment's ID */ /** The comment text */ /** The timestamp for when the comment is posted */ /** The username of the user who posted this comment */ function Comment(id, text, timestamp, username) { _classCallCheck(this, Comment); this.id = id; this.text = text; this.timestamp = timestamp; this.username = username; } return Comment; }(); exports.default = Comment; module.exports = exports['default'];