Commit 92e59faf authored by bbaer's avatar bbaer
Browse files

Editor send action hooked up

parent 1a47f17a
......@@ -30,7 +30,7 @@ var QfqNS = QfqNS || {};
* @param $target Reference to the HTML Element where the output (comment JSON)
* should be stored.
*/
n.CodeCorrection = function (form, data, $container, $target) {
n.CodeCorrection = function (form, data, $container, $target, currentUser) {
this.form = form;
this.data = data;
this.eventEmitter = new EventEmitter();
......@@ -39,7 +39,7 @@ var QfqNS = QfqNS || {};
this.$rows = [];
this.annotations = [];
this.users = [];
this.commentController = {};
this.currentUser = currentUser;
};
/**
......@@ -116,9 +116,7 @@ var QfqNS = QfqNS || {};
text: "this is a test"
});
//$hook.after($html);
//var commentController = this._buildCommentContainer($hook);
var commentController = new n.CommentController();
commentController.buildContainer($hook);
var commentController = this._buildCommentContainer($hook);
commentController.importComments(annotation.comments, this.users);
this._setListeners(commentController);
this._setCommentController(annotation.lineNumber, commentController);
......@@ -160,6 +158,8 @@ var QfqNS = QfqNS || {};
n.CodeCorrection.prototype._buildCommentContainer = function($hook) {
var commentController = new n.CommentController();
commentController.buildContainer($hook);
commentController.setCurrentUser(this.currentUser);
console.log(this.currentUser.name);
return commentController;
};
......
......@@ -76,8 +76,16 @@ var QfqNS = QfqNS || {};
$topLine.appendTo($commentWrap);
var $comment = $('<div />', {
class: "qfqCommentText",
text: this.comment.comment
});
$comment.html(this.comment.comment);
var $commentCommands = $("<div />", {
class: "qfqCommentCommands"
});
var $reply = $('<span />', {
class: "glyphicon glyphicon-comment qfqCommentReply"
});
$reply.appendTo($commentCommands);
$commentCommands.appendTo($comment);
$comment.appendTo($commentWrap);
return $commentWrap;
};
......
......@@ -24,6 +24,7 @@ var QfqNS = QfqNS || {};
*/
n.CommentController = function () {
this.comments = [];
this.currentUser = {};
this.$container = {};
this.$parent = {};
this.height = "auto";
......@@ -33,6 +34,10 @@ var QfqNS = QfqNS || {};
n.CommentController.prototype.on = n.EventEmitter.onMixin;
n.CommentController.prototype.setCurrentUser = function(user) {
this.currentUser = user;
};
/**
* changeHandler emits custom events for actions.
* Additionally writes log entries to console for easier
......@@ -110,10 +115,28 @@ var QfqNS = QfqNS || {};
n.CommentController.prototype.displayEditor = function() {
var editor = new n.Editor();
var that = this;
var $editor = editor.buildEditor();
editor.on("editor.submit", function(editor) {
that._handleEditorSubmit(editor);
});
$editor.appendTo(this.$container);
};
n.CommentController.prototype._handleEditorSubmit = function(editor) {
var comment = this.buildCommentObject(editor.data.text);
this.addComment(comment, this.currentUser);
editor.data.destroy();
};
n.CommentController.prototype.buildCommentObject = function(text) {
var comment = {};
comment.comment = text;
comment.dateTime = new Date().toISOString();
comment.uid = this.currentUser.uid;
return comment;
};
n.CommentController.prototype.getContainer = function() {
return this.$container;
};
......
......@@ -57,10 +57,16 @@ var QfqNS = QfqNS || {};
return this.$container;
};
n.Editor.prototype._handleClick = function() {
var text = this.$textArea.html();
n.Editor.prototype.destroy = function() {
this.$container.remove();
};
console.log(text);
n.Editor.prototype._handleClick = function() {
var that = this;
this.text = this.$textArea.html();
this.eventEmitter.emitEvent('editor.submit',
n.EventEmitter.makePayload(this, that));
console.log(this.text);
};
n.Editor.prototype._playingWithSelection = function() {
......
......@@ -457,13 +457,14 @@ i.@{spinner_class} {
.qfqCommentContainer {
color: #333;
height: 100%;
padding-bottom: 20px;
}
.qfqComment {
display: grid;
position: relative;
grid-template-columns: 110px auto;
grid-template-rows: 30px 90px auto;
grid-template-rows: 30px auto;
margin: 10px;
margin-top: 20px;
}
......@@ -473,6 +474,7 @@ i.@{spinner_class} {
grid-column: 1;
grid-row-start: 1;
grid-row-end: 2;
align-self: start;
width: 100px;
height: 120px;
border: 1px solid #ccc;
......@@ -489,17 +491,37 @@ i.@{spinner_class} {
}
.qfqCommentText {
position: relative;
grid-column: 2;
grid-row-start: 2;
grid-row-end: 3;
grid-row: 2;
background-color: #fff;
width: 100%;
min-height: 90px;
height: 100%;
padding: 10px;
padding-bottom: 25px;
border: 1px solid #ccc;
border-top: none;
border-radius: 0 0 5px 5px;
}
.qfqCommentCommands {
position: absolute;
bottom: 5px;
right: 15px;
width: 100%;
color: #ccc;
text-align: right;
}
.qfqCommentReply {
cursor: pointer;
}
.qfqCommentReply:hover {
color: #9acfea;
}
.qfqCommentTopLine {
position: relative;
grid-row: 1;
......
......@@ -98,7 +98,11 @@
var codeCorrection = new QfqNS.CodeCorrection(qfqPage, {
url: '../javascript/src/CodeCorrection.js'
}, $('.codeCorrection'), $('#codeCorrection-output1'));
}, $('.codeCorrection'), $('#codeCorrection-output1'), {
uid: 5,
name: "Definitely not an AI",
avatar: "mockData/avatar1.png"
});
codeCorrection.initialize();
});
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment