Skip to content

Commit

Permalink
Update html and translations (ether#161)
Browse files Browse the repository at this point in the history
  • Loading branch information
ilmartyrk authored Nov 13, 2020
1 parent 6e9d81d commit c95393c
Show file tree
Hide file tree
Showing 15 changed files with 82 additions and 17 deletions.
5 changes: 5 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ exports.socketio = function (hook_name, args, cb){
return cb();
};

exports.eejsBlock_dd_insert = function (hook_name, args, cb) {
args.content = args.content + eejs.require("ep_comments_page/templates/menuButtons.ejs");
return cb();
};

exports.eejsBlock_mySettings = function (hook_name, args, cb) {
args.content = args.content + eejs.require("ep_comments_page/templates/settings.ejs");
return cb();
Expand Down
1 change: 1 addition & 0 deletions locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"ep_comments_page.comment" : "Kommentar",
"ep_comments_page.comments" : "Kommentare",
"ep_comments_page.add_comment.title" : "Kommentar zur Auswahl hinzufügen",
"ep_comments_page.add_comment" : "Kommentar zur Auswahl hinzufügen",
"ep_comments_page.add_comment.hint" : "Bitte wählen Sie zuerst den zu kommentierenden Text aus",
"ep_comments_page.delete_comment.title" : "Diesen Kommentar löschen",
"ep_comments_page.show_comments" : "Kommentare anzeigen",
Expand Down
5 changes: 3 additions & 2 deletions locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"ep_comments_page.comment" : "Comment",
"ep_comments_page.comments" : "Comments",
"ep_comments_page.add_comment.title" : "Add new comment on selection",
"ep_comments_page.add_comment": "Add new comment on selection",
"ep_comments_page.add_comment.hint" : "Please first select the text to comment",
"ep_comments_page.delete_comment.title" : "Delete this comment",
"ep_comments_page.edit_comment.title" : "Edit this comment",
Expand All @@ -10,8 +11,8 @@
"ep_comments_page.comments_template.from" : "From",
"ep_comments_page.comments_template.accept_change.value" : "Accept Change",
"ep_comments_page.comments_template.revert_change.value" : "Revert Change",
"ep_comments_page.comments_template.suggested_change_from" : "Suggested change From",
"ep_comments_page.comments_template.suggest_change_from" : "Suggest change From",
"ep_comments_page.comments_template.suggested_change_from" : "Suggested change from \"{{changeFrom}}\" to \"{{changeTo}}\"",
"ep_comments_page.comments_template.suggest_change_from" : "Suggest change from \"{{changeFrom}}\" to",
"ep_comments_page.comments_template.to" : "To",
"ep_comments_page.comments_template.include_suggestion" : "Include suggested change",
"ep_comments_page.comments_template.comment.value" : "Comment",
Expand Down
1 change: 1 addition & 0 deletions locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"ep_comments_page.comment" : "Annotation",
"ep_comments_page.comments" : "Annotations",
"ep_comments_page.add_comment.title" : "Annoter la sélection",
"ep_comments_page.add_comment" : "Annoter la sélection",
"ep_comments_page.add_comment.hint" : "Vous devez d'abord sélectionner un texte à annoter",
"ep_comments_page.delete_comment.title" : "Supprimer cette annotation",
"ep_comments_page.show_comments" : "Afficher les annotations",
Expand Down
1 change: 1 addition & 0 deletions locales/hu.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"ep_comments_page.comment" : "Megjegyzés",
"ep_comments_page.comments" : "Megjegyzések",
"ep_comments_page.add_comment.title" : "Új megjegyzés hozzáadása a kijelöléshez",
"ep_comments_page.add_comment" : "Új megjegyzés hozzáadása a kijelöléshez",
"ep_comments_page.add_comment.hint" : "Először jelölje meg a szöveget a megjegyzéshez",
"ep_comments_page.delete_comment.title" : "Megjegyzés törlése",
"ep_comments_page.edit_comment.title" : "Megjegyzés szerkesztése",
Expand Down
1 change: 1 addition & 0 deletions locales/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"ep_comments_page.comment" : "Opmerking",
"ep_comments_page.comments" : "Opmerkingen",
"ep_comments_page.add_comment.title" : "Voeg opmerking toe aan selectie",
"ep_comments_page.add_comment" : "Voeg opmerking toe aan selectie",
"ep_comments_page.add_comment.hint" : "Selecteer eerst een stuk tekst om een opmerking aan toe te voegen",
"ep_comments_page.delete_comment.title" : "Verwijder deze opmerking",
"ep_comments_page.edit_comment.title" : "Bewerk deze opmerking",
Expand Down
1 change: 1 addition & 0 deletions locales/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"ep_comments_page.comment" : "Komentarz",
"ep_comments_page.comments" : "Komentarze",
"ep_comments_page.add_comment.title" : "Dodaj nowy komentarz do sekcji",
"ep_comments_page.add_comment" : "Dodaj nowy komentarz do sekcji",
"ep_comments_page.add_comment.hint" : "Najpierw wybierz tekst do skomentowania",
"ep_comments_page.delete_comment.title" : "Usuń komentarz",
"ep_comments_page.show_comments" : "Pokaż komentarze",
Expand Down
1 change: 1 addition & 0 deletions locales/pt-BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"ep_comments_page.comment" : "Comentário",
"ep_comments_page.comments" : "Comentários",
"ep_comments_page.add_comment.title" : "Adicionar novo comentário ao texto selecionado",
"ep_comments_page.add_comment" : "Adicionar novo comentário ao texto selecionado",
"ep_comments_page.add_comment.hint" : "Por favor, selecione primeiro o texto para comentar",
"ep_comments_page.delete_comment.title" : "Apagar este comentário",
"ep_comments_page.edit_comment.title" : "Editar este comentário",
Expand Down
1 change: 1 addition & 0 deletions locales/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"ep_comments_page.comment" : "Примечание",
"ep_comments_page.comments" : "Примечания",
"ep_comments_page.add_comment.title" : "Добавьте примечание к выделенному тексту",
"ep_comments_page.add_comment" : "Добавьте примечание к выделенному тексту",
"ep_comments_page.add_comment.hint" : "Выделите текст чтобы создать примечание",
"ep_comments_page.delete_comment.title" : "Удалить примечание",
"ep_comments_page.edit_comment.title" : "Отредактировать примечание",
Expand Down
1 change: 1 addition & 0 deletions locales/sv.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"ep_comments_page.comment" : "Kommentar",
"ep_comments_page.comments" : "Kommentarer",
"ep_comments_page.add_comment.title" : "Lägg till ny kommentar till markering",
"ep_comments_page.add_comment" : "Lägg till ny kommentar till markering",
"ep_comments_page.add_comment.hint" : "Markera först den text du vill kommentera",
"ep_comments_page.delete_comment.title" : "Radera den här kommentaren",
"ep_comments_page.edit_comment.title" : "Redigera den här kommentaren",
Expand Down
8 changes: 8 additions & 0 deletions static/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,7 @@ ep_comments.prototype.collectComments = function(callback){

var comment = comments[commentId];
if(comment){
comment.data.changeFrom = parseMultiline(comment.data.changeFrom);
if (comment !== null) {
// If comment is not in sidebar insert it
if (commentElm.length == 0) {
Expand Down Expand Up @@ -800,6 +801,12 @@ ep_comments.prototype.deleteComment = function(commentId){
$('iframe[name="ace_outer"]').contents().find('#' + commentId).remove();
}

function parseMultiline (text) {
if (!text) return text;
text = JSON.stringify(text);
return text.substr(1, (text.length-2));
}

ep_comments.prototype.displayNewCommentForm = function() {
var self = this;
var rep = {};
Expand Down Expand Up @@ -903,6 +910,7 @@ ep_comments.prototype.createNewCommentFormIfDontExist = function(rep) {
var self = this;

// If a new comment box doesn't already exist, create one
data.changeFrom = parseMultiline(self.getSelectedText(rep));
newComment.insertNewCommentPopupIfDontExist(data, function(comment, index) {
if(comment.changeTo){
data.comment.changeFrom = comment.changeFrom;
Expand Down
52 changes: 46 additions & 6 deletions static/tests/frontend/specs/commentSuggestion.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,46 @@ describe("ep_comments_page - Comment Suggestion", function(){
});
});

it("Fills suggestion Change From field, adds sugestion", async function() {
var outer$ = helper.padOuter$;
var inner$ = helper.padInner$;
var chrome$ = helper.padChrome$;
var suggestedText = 'A new suggested text';
openCommentFormWithSuggestion('This content will receive a comment');

await new Promise(function (resolve) {
helper.waitFor(function () {
return chrome$("#newComment.popup-show").is(':visible')
}).done(function () {
chrome$("#newComment").find('textarea.comment-content').val('A new comment text');
chrome$("#newComment").find('textarea.to-value').val(suggestedText);
chrome$('#comment-create-btn').click();
return helper.waitFor(function () {
return inner$("div").first().find('.comment').length;
}).done(function () {
var comment$ = inner$("div").first().find('.comment');
comment$.click();
resolve();
})
});
});
await new Promise(function (resolve) {
helper.waitFor(function () {
outer$('.approve-suggestion-btn:visible').click();
return true;
}).done(resolve);
});
await new Promise(function (resolve) {
var comment$ = inner$("div").first().find('.comment');
helper.waitFor(function () {
return comment$.text() === suggestedText;
}).done(function () {
expect(comment$.text()).to.be(suggestedText);
resolve();
});
})

});
});

function openCommentFormWithSuggestion(targetText) {
Expand All @@ -60,11 +100,11 @@ function openCommentFormWithSuggestion(targetText) {
// to simulate a selection with more than one line we have to send the sendkeys selectall
// at the same line. The sendkeys will be run before the line break.
$firstTextElement.html(targetText).sendkeys("{selectall}");
chrome$(".addComment").first().click();
helper.waitFor(function() {
return chrome$("#newComment.popup-show").find('.suggestion-checkbox').length;
}).done(function () {
chrome$("#newComment.popup-show").find(".suggestion-checkbox").first().click();
});

var $commentButton = chrome$(".addComment");
$commentButton.click();

// check suggestion box
var $hasSuggestion = chrome$(".suggestion-checkbox");
$hasSuggestion.click();
}
4 changes: 2 additions & 2 deletions static/tests/frontend/specs/comment_l10n.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ describe("ep_comments_page - Comment Localization", function(){
var commentId = getCommentId();

//get the 'Suggested Change' label
var $changeToLabel = outer$("#" + commentId + " .to-label").first();
expect($changeToLabel.text()).to.be("Para");
var $changeToLabel = outer$("#" + commentId + " .from-label").first();
expect($changeToLabel.text()).to.be("Sugerir alteração de");

done();
});
Expand Down
14 changes: 7 additions & 7 deletions templates/comments.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@ <h1 data-l10n-id="ep_comments_page.comment">Comment</h1>
<label for="suggestion-checkbox-${commentId}" class="label-suggestion-checkbox" data-l10n-id="ep_comments_page.comments_template.include_suggestion">Include suggested change</label>
</p>
<div class="suggestion suggestion-create">
<span class="from-label" data-l10n-id="ep_comments_page.comments_template.suggest_change_from">Suggest Change From</span>
<span class="from-value">${changeFrom}</span>
<span class="to-label" data-l10n-id="ep_comments_page.comments_template.to">To</span>
<span class="from-label" data-l10n-id="ep_comments_page.comments_template.suggest_change_from" data-l10n-args='{"changeFrom": "${changeFrom}"}'>Suggest Change From</span>
<span class="hidden from-value">${changeFrom}</span>
<textarea class="to-value"></textarea>
</div>

Expand Down Expand Up @@ -97,10 +96,11 @@ <h1 data-l10n-id="ep_comments_page.comment">Comment</h1>
<!-- When comment contains a suggestion, we display it with an approval button -->
{{if changeTo}}
<form class="comment-changeTo-form suggestion-display">
<span class="from-label" data-l10n-id="ep_comments_page.comments_template.suggested_change_from">Suggested Change From</span>
<span class="from-value">${changeFrom}</span>
<span class="to-label" data-l10n-id="ep_comments_page.comments_template.to">To</span>
<span class="to-value">${changeTo}</span>
<div>
<span class="from-label" data-l10n-id="ep_comments_page.comments_template.suggested_change_from" data-l10n-args='{"changeFrom": "${changeFrom}", "changeTo": "${changeTo}"}'>Suggested Change From</span>
<span class="hidden from-value">${changeFrom}</span>
<span class="hidden to-value">${changeTo}</span>
</div>
<!-- Approve/revert button -->
<input type="Submit" class="btn btn-primary approve-suggestion-btn acl-write" value="Accept Change" data-l10n-id="ep_comments_page.comments_template.accept_change.value">
<input type="Submit" class="btn btn-default revert-suggestion-btn acl-write" value="Revert Change" data-l10n-id="ep_comments_page.comments_template.revert_change.value">
Expand Down
3 changes: 3 additions & 0 deletions templates/menuButtons.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<li class="addComment">
<a title="Add new comment on selection" data-l10n-id="ep_comments_page.add_comment.title"><span data-l10n-id="ep_comments_page.comment">Comment</span></a>
</li>

0 comments on commit c95393c

Please sign in to comment.