diff --git a/client/html/post_upload_row.tpl b/client/html/post_upload_row.tpl
index b12a9d0..e336107 100644
--- a/client/html/post_upload_row.tpl
+++ b/client/html/post_upload_row.tpl
@@ -30,11 +30,13 @@
<% } %>
-
- <%= ctx.makeCheckbox({
- text: 'Upload anonymously',
- name: 'anonymous',
- checked: ctx.uploadable.anonymous,
- }) %>
-
+ <% if (ctx.canUploadAnonymously) { %>
+
+ <%= ctx.makeCheckbox({
+ text: 'Upload anonymously',
+ name: 'anonymous',
+ checked: ctx.uploadable.anonymous,
+ }) %>
+
+ <% } %>
diff --git a/client/js/controllers/post_upload_controller.js b/client/js/controllers/post_upload_controller.js
index ae4f497..c9da651 100644
--- a/client/js/controllers/post_upload_controller.js
+++ b/client/js/controllers/post_upload_controller.js
@@ -18,7 +18,9 @@ class PostUploadController {
topNavigation.activate('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('submit', e => this._evtSubmit(e));
}
diff --git a/client/js/views/post_upload_view.js b/client/js/views/post_upload_view.js
index 26a4329..7e53840 100644
--- a/client/js/views/post_upload_view.js
+++ b/client/js/views/post_upload_view.js
@@ -108,9 +108,9 @@ class Url extends Uploadable {
}
class PostUploadView extends events.EventTarget {
- constructor() {
+ constructor(ctx) {
super();
-
+ this._ctx = ctx;
this._hostNode = document.getElementById('content-holder');
views.replaceContent(this._hostNode, template());
views.syncScrollPosition();
@@ -227,21 +227,29 @@ class PostUploadView extends events.EventTarget {
}
_createRowNode(uploadable) {
- const rowNode = rowTemplate({uploadable: uploadable});
+ const rowNode = rowTemplate(Object.assign(
+ {}, this._ctx, {uploadable: uploadable}));
this._listNode.appendChild(rowNode);
+
for (let radioboxNode of rowNode.querySelectorAll('.safety input')) {
radioboxNode.addEventListener(
'change', e => this._evtSafetyRadioboxChange(e, uploadable));
}
- rowNode.querySelector('.anonymous input').addEventListener(
- 'change', e => this._evtAnonymityCheckboxChange(e, uploadable));
+
+ const anonymousCheckboxNode = rowNode.querySelector('.anonymous input');
+ if (anonymousCheckboxNode) {
+ anonymousCheckboxNode.addEventListener(
+ 'change', e => this._evtAnonymityCheckboxChange(e, uploadable));
+ }
+
rowNode.querySelector('a.remove').addEventListener(
'click', e => this._evtRemoveClick(e, uploadable));
uploadable.rowNode = rowNode;
}
_updateRowNode(uploadable) {
- const rowNode = rowTemplate({uploadable: uploadable});
+ const rowNode = rowTemplate(Object.assign(
+ {}, this._ctx, {uploadable: uploadable}));
views.replaceContent(
uploadable.rowNode.querySelector('.thumbnail'),
rowNode.querySelector('.thumbnail').childNodes);