зеркало из https://github.com/mozilla/buddyup.git
Bug 1154257 - Helpees should not see "Choose a category" when viewing questions
This commit is contained in:
Родитель
fdc2fe1425
Коммит
5edba372d7
|
@ -140,27 +140,31 @@
|
|||
*/
|
||||
function add_thread_header(question) {
|
||||
var date_posted = Utils.time_since(new Date(question.updated));
|
||||
var author = question.creator.display_name || question.creator.username;
|
||||
|
||||
var displayable_metadata =
|
||||
Utils.convert_metadata_for_display(question.metadata);
|
||||
|
||||
var html = nunjucks.render('thread_header.html', {
|
||||
date_posted: date_posted,
|
||||
displayable_metadata: displayable_metadata,
|
||||
author: author,
|
||||
categories: CATEGORIES,
|
||||
selected_category: question.category
|
||||
});
|
||||
question_thread.insertAdjacentHTML('afterbegin', html);
|
||||
User.is_helper().then(function(is_helper) {
|
||||
var html = nunjucks.render('thread_header.html', {
|
||||
date_posted: date_posted,
|
||||
displayable_metadata: displayable_metadata,
|
||||
viewer_is_helper: is_helper,
|
||||
categories: CATEGORIES,
|
||||
selected_category: question.category
|
||||
});
|
||||
question_thread.insertAdjacentHTML('afterbegin', html);
|
||||
|
||||
var category_chooser = document.getElementById('category_chooser');
|
||||
category_chooser.addEventListener('change', function(evt) {
|
||||
var category = evt.target.value;
|
||||
if (category == question.category) {
|
||||
var category_chooser = document.getElementById('category_chooser');
|
||||
if (!category_chooser) {
|
||||
return;
|
||||
}
|
||||
SumoDB.set_category_for_question(category, question.id);
|
||||
category_chooser.addEventListener('change', function(evt) {
|
||||
var category = evt.target.value;
|
||||
if (category == question.category) {
|
||||
return;
|
||||
}
|
||||
SumoDB.set_category_for_question(category, question.id);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -497,7 +497,9 @@ output += runtime.suppressValue(runtime.memberLookup((runtime.contextOrFrameLook
|
|||
output += "</span>\n</div>\n<h3 class=\"QuestionThread-date text-blue\">\n ";
|
||||
output += runtime.suppressValue(runtime.contextOrFrameLookup(context, frame, "date_posted"), env.autoesc);
|
||||
output += "\n</h3>\n\n";
|
||||
output += "\n<ul>\n <li>\n <div class=\"button\" data-icon=\"forward\">\n <select id=\"category_chooser\">\n ";
|
||||
if(runtime.contextOrFrameLookup(context, frame, "viewer_is_helper")) {
|
||||
output += "\n ";
|
||||
output += "\n <ul>\n <li>\n <div class=\"button\" data-icon=\"forward\">\n <select id=\"category_chooser\">\n ";
|
||||
frame = frame.push();
|
||||
var t_3 = runtime.contextOrFrameLookup(context, frame, "categories");
|
||||
if(t_3) {var t_1;
|
||||
|
@ -515,16 +517,16 @@ frame.set("loop.revindex0", t_2 - t_1 - 1);
|
|||
frame.set("loop.first", t_1 === 0);
|
||||
frame.set("loop.last", t_1 === t_2 - 1);
|
||||
frame.set("loop.length", t_2);
|
||||
output += "\n <option value=\"";
|
||||
output += "\n <option value=\"";
|
||||
output += runtime.suppressValue(t_4, env.autoesc);
|
||||
output += "\"\n ";
|
||||
output += "\"\n ";
|
||||
if(runtime.contextOrFrameLookup(context, frame, "selected_category") == t_4) {
|
||||
output += "selected";
|
||||
;
|
||||
}
|
||||
output += ">\n ";
|
||||
output += ">\n ";
|
||||
output += runtime.suppressValue(t_5, env.autoesc);
|
||||
output += "\n </option>\n ";
|
||||
output += "\n </option>\n ";
|
||||
;
|
||||
}
|
||||
} else {
|
||||
|
@ -542,22 +544,25 @@ frame.set("loop.revindex0", t_2 - t_1 - 1);
|
|||
frame.set("loop.first", t_1 === 0);
|
||||
frame.set("loop.last", t_1 === t_2 - 1);
|
||||
frame.set("loop.length", t_2);
|
||||
output += "\n <option value=\"";
|
||||
output += "\n <option value=\"";
|
||||
output += runtime.suppressValue(t_6, env.autoesc);
|
||||
output += "\"\n ";
|
||||
output += "\"\n ";
|
||||
if(runtime.contextOrFrameLookup(context, frame, "selected_category") == t_6) {
|
||||
output += "selected";
|
||||
;
|
||||
}
|
||||
output += ">\n ";
|
||||
output += ">\n ";
|
||||
output += runtime.suppressValue(t_7, env.autoesc);
|
||||
output += "\n </option>\n ";
|
||||
output += "\n </option>\n ";
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
frame = frame.pop();
|
||||
output += "\n </select>\n </div>\n </li>\n</ul>\n";
|
||||
output += "\n </select>\n </div>\n </li>\n </ul>\n";
|
||||
;
|
||||
}
|
||||
output += "\n";
|
||||
cb(null, output);
|
||||
;
|
||||
} catch (e) {
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
var MockUser = {
|
||||
get_user: function() {},
|
||||
is_helper: function() {},
|
||||
get_credentials: function() {},
|
||||
reauthenticate_user: function() {}
|
||||
};
|
||||
|
|
|
@ -86,6 +86,8 @@ suite('QuestionController', function() {
|
|||
window.parent.Notif = MockNotif;
|
||||
|
||||
this.sinon.stub(User, 'get_user').returns(Promise.resolve(FAKE_USER));
|
||||
this.sinon.stub(User, 'is_helper').returns(Promise.resolve(true));
|
||||
|
||||
this.sinon.stub(Utils, 'get_url_parameters')
|
||||
.returns({id: DISPLAYED_QUESTION_ID});
|
||||
this.sinon.stub(Utils, 'time_since');
|
||||
|
@ -125,6 +127,6 @@ suite('QuestionController', function() {
|
|||
});
|
||||
|
||||
test('only display new answers since last time', function() {
|
||||
sinon.assert.calledOnce(nunjucks.render);
|
||||
sinon.assert.calledOnce(nunjucks.render.withArgs('thread.html'));
|
||||
});
|
||||
});
|
||||
|
|
|
@ -11,18 +11,20 @@
|
|||
{{ date_posted }}
|
||||
</h3>
|
||||
|
||||
{# This <ul><li> is needed to get the right Building block styling for that button #}
|
||||
<ul>
|
||||
<li>
|
||||
<div class="button" data-icon="forward">
|
||||
<select id="category_chooser">
|
||||
{% for key, value in categories %}
|
||||
<option value="{{ key }}"
|
||||
{% if selected_category == key %}selected{% endif %}>
|
||||
{{ value }}
|
||||
</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
{% if viewer_is_helper %}
|
||||
{# This <ul><li> is needed to get the right Building block styling for that button #}
|
||||
<ul>
|
||||
<li>
|
||||
<div class="button" data-icon="forward">
|
||||
<select id="category_chooser">
|
||||
{% for key, value in categories %}
|
||||
<option value="{{ key }}"
|
||||
{% if selected_category == key %}selected{% endif %}>
|
||||
{{ value }}
|
||||
</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
{% endif %}
|
||||
|
|
Загрузка…
Ссылка в новой задаче