client/upload: restore option to pause upload chain on error

This commit is contained in:
Shyam Sunder 2021-11-29 20:06:20 -05:00
parent 9f95e9eb90
commit 780b7dc6fd
4 changed files with 37 additions and 7 deletions

View file

@ -14,9 +14,11 @@ $cancel-button-color = tomato
&.inactive input[type=submit], &.inactive input[type=submit],
&.inactive .skip-duplicates &.inactive .skip-duplicates
&.inactive .always-upload-similar &.inactive .always-upload-similar
&.inactive .pause-remain-on-error
&.uploading input[type=submit], &.uploading input[type=submit],
&.uploading .skip-duplicates, &.uploading .skip-duplicates,
&.uploading .always-upload-similar &.uploading .always-upload-similar
&.uploading .pause-remain-on-error
&:not(.uploading) .cancel &:not(.uploading) .cancel
display: none display: none
@ -44,6 +46,9 @@ $cancel-button-color = tomato
.always-upload-similar .always-upload-similar
margin-left: 1em margin-left: 1em
.pause-remain-on-error
margin-left: 1em
form>.messages form>.messages
margin-top: 1em margin-top: 1em

View file

@ -7,7 +7,7 @@
<span class='skip-duplicates'> <span class='skip-duplicates'>
<%= ctx.makeCheckbox({ <%= ctx.makeCheckbox({
text: 'Skip duplicates', text: 'Skip duplicate',
name: 'skip-duplicates', name: 'skip-duplicates',
checked: false, checked: false,
}) %> }) %>
@ -15,12 +15,20 @@
<span class='always-upload-similar'> <span class='always-upload-similar'>
<%= ctx.makeCheckbox({ <%= ctx.makeCheckbox({
text: 'Always upload similar', text: 'Force upload similar',
name: 'always-upload-similar', name: 'always-upload-similar',
checked: false, checked: false,
}) %> }) %>
</span> </span>
<span class='pause-remain-on-error'>
<%= ctx.makeCheckbox({
text: 'Pause on error',
name: 'pause-remain-on-error',
checked: true,
}) %>
</span>
<input type='button' value='Cancel' class='cancel'/> <input type='button' value='Cancel' class='cancel'/>
</div> </div>

View file

@ -90,21 +90,30 @@ class PostUploadController {
uploadable uploadable
); );
} }
if (e.detail.pauseRemainOnError) {
return Promise.reject();
}
}) })
), ),
Promise.resolve() Promise.resolve()
) )
.then(() => { .then(() => {
if (anyFailures) { if (anyFailures) {
this._view.showError(genericErrorMessage); return Promise.reject();
this._view.enableForm(); }
} else { })
.then(
() => {
this._view.clearMessages(); this._view.clearMessages();
misc.disableExitConfirmation(); misc.disableExitConfirmation();
const ctx = router.show(uri.formatClientLink("posts")); const ctx = router.show(uri.formatClientLink("posts"));
ctx.controller.showSuccess("Posts uploaded."); ctx.controller.showSuccess("Posts uploaded.");
},
(error) => {
this._view.showError(genericErrorMessage);
this._view.enableForm();
} }
}); );
} }
_uploadSinglePost(uploadable, skipDuplicates, alwaysUploadSimilar) { _uploadSinglePost(uploadable, skipDuplicates, alwaysUploadSimilar) {

View file

@ -285,7 +285,7 @@ class PostUploadView extends events.EventTarget {
for (let uploadable of this._uploadables) { for (let uploadable of this._uploadables) {
this._updateUploadableFromDom(uploadable); this._updateUploadableFromDom(uploadable);
} }
this._submitButtonNode.value = "Resume upload"; this._submitButtonNode.value = "Resume";
this._emit("submit"); this._emit("submit");
} }
@ -362,6 +362,8 @@ class PostUploadView extends events.EventTarget {
skipDuplicates: this._skipDuplicatesCheckboxNode.checked, skipDuplicates: this._skipDuplicatesCheckboxNode.checked,
alwaysUploadSimilar: alwaysUploadSimilar:
this._alwaysUploadSimilarCheckboxNode.checked, this._alwaysUploadSimilarCheckboxNode.checked,
pauseRemainOnError:
this._pauseRemainOnErrorCheckboxNode.checked,
}, },
}) })
); );
@ -431,6 +433,12 @@ class PostUploadView extends events.EventTarget {
); );
} }
get _pauseRemainOnErrorCheckboxNode() {
return this._hostNode.querySelector(
"form [name=pause-remain-on-error]"
);
}
get _submitButtonNode() { get _submitButtonNode() {
return this._hostNode.querySelector("form [type=submit]"); return this._hostNode.querySelector("form [type=submit]");
} }