@attivio/suit
Version:
Attivio SUIT, the Search UI Toolkit, is a library for creating search clients for searching the Attivio platform.
47 lines (34 loc) • 1.32 kB
JavaScript
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
import SearchDocument from './SearchDocument';
import DateUtils from '../util/DateUtils';
/**
* A single comment for a SearchDocument.
*/
var Comment = function () {
Comment.createTimestamp = function createTimestamp(date) {
var d = DateUtils.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;
}();
export { Comment as default };