client/auth: fix not hiding anonymity checkbox
This commit is contained in:
parent
e90b8972c7
commit
34022d8fc8
3 changed files with 26 additions and 14 deletions
|
@ -30,6 +30,7 @@
|
||||||
<% } %>
|
<% } %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<% if (ctx.canUploadAnonymously) { %>
|
||||||
<div class='anonymous'>
|
<div class='anonymous'>
|
||||||
<%= ctx.makeCheckbox({
|
<%= ctx.makeCheckbox({
|
||||||
text: 'Upload anonymously',
|
text: 'Upload anonymously',
|
||||||
|
@ -37,4 +38,5 @@
|
||||||
checked: ctx.uploadable.anonymous,
|
checked: ctx.uploadable.anonymous,
|
||||||
}) %>
|
}) %>
|
||||||
</div>
|
</div>
|
||||||
|
<% } %>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
@ -18,7 +18,9 @@ class PostUploadController {
|
||||||
|
|
||||||
topNavigation.activate('upload');
|
topNavigation.activate('upload');
|
||||||
topNavigation.setTitle('Upload');
|
topNavigation.setTitle('Upload');
|
||||||
this._view = new PostUploadView();
|
this._view = new PostUploadView({
|
||||||
|
canUploadAnonymously: api.hasPrivilege('posts:create:anonymous'),
|
||||||
|
});
|
||||||
this._view.addEventListener('change', e => this._evtChange(e));
|
this._view.addEventListener('change', e => this._evtChange(e));
|
||||||
this._view.addEventListener('submit', e => this._evtSubmit(e));
|
this._view.addEventListener('submit', e => this._evtSubmit(e));
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,9 +108,9 @@ class Url extends Uploadable {
|
||||||
}
|
}
|
||||||
|
|
||||||
class PostUploadView extends events.EventTarget {
|
class PostUploadView extends events.EventTarget {
|
||||||
constructor() {
|
constructor(ctx) {
|
||||||
super();
|
super();
|
||||||
|
this._ctx = ctx;
|
||||||
this._hostNode = document.getElementById('content-holder');
|
this._hostNode = document.getElementById('content-holder');
|
||||||
views.replaceContent(this._hostNode, template());
|
views.replaceContent(this._hostNode, template());
|
||||||
views.syncScrollPosition();
|
views.syncScrollPosition();
|
||||||
|
@ -227,21 +227,29 @@ class PostUploadView extends events.EventTarget {
|
||||||
}
|
}
|
||||||
|
|
||||||
_createRowNode(uploadable) {
|
_createRowNode(uploadable) {
|
||||||
const rowNode = rowTemplate({uploadable: uploadable});
|
const rowNode = rowTemplate(Object.assign(
|
||||||
|
{}, this._ctx, {uploadable: uploadable}));
|
||||||
this._listNode.appendChild(rowNode);
|
this._listNode.appendChild(rowNode);
|
||||||
|
|
||||||
for (let radioboxNode of rowNode.querySelectorAll('.safety input')) {
|
for (let radioboxNode of rowNode.querySelectorAll('.safety input')) {
|
||||||
radioboxNode.addEventListener(
|
radioboxNode.addEventListener(
|
||||||
'change', e => this._evtSafetyRadioboxChange(e, uploadable));
|
'change', e => this._evtSafetyRadioboxChange(e, uploadable));
|
||||||
}
|
}
|
||||||
rowNode.querySelector('.anonymous input').addEventListener(
|
|
||||||
|
const anonymousCheckboxNode = rowNode.querySelector('.anonymous input');
|
||||||
|
if (anonymousCheckboxNode) {
|
||||||
|
anonymousCheckboxNode.addEventListener(
|
||||||
'change', e => this._evtAnonymityCheckboxChange(e, uploadable));
|
'change', e => this._evtAnonymityCheckboxChange(e, uploadable));
|
||||||
|
}
|
||||||
|
|
||||||
rowNode.querySelector('a.remove').addEventListener(
|
rowNode.querySelector('a.remove').addEventListener(
|
||||||
'click', e => this._evtRemoveClick(e, uploadable));
|
'click', e => this._evtRemoveClick(e, uploadable));
|
||||||
uploadable.rowNode = rowNode;
|
uploadable.rowNode = rowNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
_updateRowNode(uploadable) {
|
_updateRowNode(uploadable) {
|
||||||
const rowNode = rowTemplate({uploadable: uploadable});
|
const rowNode = rowTemplate(Object.assign(
|
||||||
|
{}, this._ctx, {uploadable: uploadable}));
|
||||||
views.replaceContent(
|
views.replaceContent(
|
||||||
uploadable.rowNode.querySelector('.thumbnail'),
|
uploadable.rowNode.querySelector('.thumbnail'),
|
||||||
rowNode.querySelector('.thumbnail').childNodes);
|
rowNode.querySelector('.thumbnail').childNodes);
|
||||||
|
|
Loading…
Reference in a new issue