client/posts: disable form controls during upload

Closes #99
This commit is contained in:
rr- 2016-09-29 12:39:18 +02:00
parent 67cb12e9d9
commit f44f2335da
1 changed files with 12 additions and 0 deletions

View File

@ -133,6 +133,7 @@ class PostUploadView extends events.EventTarget {
super(); super();
this._ctx = ctx; this._ctx = ctx;
this._hostNode = document.getElementById('content-holder'); this._hostNode = document.getElementById('content-holder');
this._enabled = true;
views.replaceContent(this._hostNode, template()); views.replaceContent(this._hostNode, template());
views.syncScrollPosition(); views.syncScrollPosition();
@ -154,10 +155,12 @@ class PostUploadView extends events.EventTarget {
} }
enableForm() { enableForm() {
this._enabled = true;
views.enableForm(this._formNode); views.enableForm(this._formNode);
} }
disableForm() { disableForm() {
this._enabled = false;
views.disableForm(this._formNode); views.disableForm(this._formNode);
} }
@ -230,11 +233,17 @@ class PostUploadView extends events.EventTarget {
_evtRemoveClick(e, uploadable) { _evtRemoveClick(e, uploadable) {
e.preventDefault(); e.preventDefault();
if (!this._enabled) {
return;
}
this.removeUploadable(uploadable); this.removeUploadable(uploadable);
} }
_evtMoveUpClick(e, uploadable) { _evtMoveUpClick(e, uploadable) {
e.preventDefault(); e.preventDefault();
if (!this._enabled) {
return;
}
let sortedUploadables = this._getSortedUploadables(); let sortedUploadables = this._getSortedUploadables();
if (uploadable.order > 0) { if (uploadable.order > 0) {
uploadable.order--; uploadable.order--;
@ -247,6 +256,9 @@ class PostUploadView extends events.EventTarget {
_evtMoveDownClick(e, uploadable) { _evtMoveDownClick(e, uploadable) {
e.preventDefault(); e.preventDefault();
if (!this._enabled) {
return;
}
let sortedUploadables = this._getSortedUploadables(); let sortedUploadables = this._getSortedUploadables();
if (uploadable.order + 1 < sortedUploadables.length) { if (uploadable.order + 1 < sortedUploadables.length) {
uploadable.order++; uploadable.order++;