diff options
| author | Hunternif <hunternif@gmail.com> | 2019-04-12 06:06:18 +0700 |
|---|---|---|
| committer | Hunternif <hunternif@gmail.com> | 2019-04-12 07:30:59 +0700 |
| commit | 902cca66f3062d6c8c93b4bb357d0522d7937d73 (patch) | |
| tree | 5c23e18318c3528d41153fcaedb561cda44e72e8 /client/js/controllers/post_upload_controller.js | |
| parent | f3d59369b15019e2ae6e53695eba5a922b36593a (diff) | |
Add tag input control to upload page. Fix some issues with tag input.
Diffstat (limited to 'client/js/controllers/post_upload_controller.js')
| -rw-r--r-- | client/js/controllers/post_upload_controller.js | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/client/js/controllers/post_upload_controller.js b/client/js/controllers/post_upload_controller.js index 4868042..7bdce9c 100644 --- a/client/js/controllers/post_upload_controller.js +++ b/client/js/controllers/post_upload_controller.js @@ -55,6 +55,7 @@ class PostUploadController { _evtSubmit(e) { this._view.disableForm(); this._view.clearMessages(); + const tagErrors = []; // to be displayed after all uploads e.detail.uploadables.reduce( (promise, uploadable) => @@ -62,10 +63,36 @@ class PostUploadController { uploadable, e.detail.skipDuplicates, e.detail.copyTagsToOriginals)), Promise.resolve()) .then(() => { + // now save the new tags with categories + //TODO: re-use this code in post_main_controller.js + if (!e.detail.newTags) { + return Promise.resolve(); + } + let tagPromises = []; + for (let newTag of e.detail.newTags) { + // load the tag that was created during updating the post + tagPromises.push( + Tag.get(newTag.names[0]).then(tag => { + tag.category = newTag.category; + return tag.save(); + } + ).then(() => { + e.detail.newTags.removeByName(newTag.names[0]); + }, error => { + tagErrors.push(error.message); + }) + ); + } + return Promise.all(tagPromises); + }) + .then(() => { this._view.clearMessages(); misc.disableExitConfirmation(); const ctx = router.show(uri.formatClientLink('posts')); ctx.controller.showSuccess('Posts uploaded.'); + for (let tagError of tagErrors) { + ctx.controller.showError(tagError); + } }, error => { if (error.uploadable) { if (error.similarPosts) { |