From 95277a43163c815ceadaa4a49c802b3301fee47f Mon Sep 17 00:00:00 2001 From: Enis Necipoglu Date: Tue, 16 Jan 2024 11:56:21 +0300 Subject: [PATCH 1/4] Move all the save logic after the validation --- .../Pages/CmsKit/BlogPosts/create.js | 86 +++++++++---------- .../Pages/CmsKit/BlogPosts/update.js | 27 +++--- 2 files changed, 55 insertions(+), 58 deletions(-) diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/BlogPosts/create.js b/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/BlogPosts/create.js index 4676656c5e..01301351a1 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/BlogPosts/create.js +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/BlogPosts/create.js @@ -27,6 +27,7 @@ $(function () { var UPPY_FILE_ID = "uppy-upload-file"; var isTagsEnabled = true; + var message = l('BlogPostSaveConfirmationMessage', $status.val()); $formCreate.data('validator').settings.ignore = ":hidden, [contenteditable='true']:not([name]), .tui-popup-wrapper"; @@ -47,20 +48,31 @@ $(function () { if ($formCreate.valid()) { - $formCreate.ajaxSubmit({ - success: function (result) { - if (isTagsEnabled) { - submitEntityTags(result.id); + abp.message.confirm( + message, + async function (isConfirmed) { + if (isConfirmed) { + e.preventDefault(); + + await submitCoverImage(); + + $formCreate.ajaxSubmit({ + success: function (result) { + if (isTagsEnabled) { + submitEntityTags(result.id); + } + else { + finishSaving(); + } + }, + error: function (result) { + abp.notify.error(result.responseJSON.error.message); + abp.ui.clearBusy(); + } + }); } - else { - finishSaving(); - } - }, - error: function (result) { - abp.notify.error(result.responseJSON.error.message); - abp.ui.clearBusy(); } - }); + ); } else { abp.ui.clearBusy(); @@ -69,34 +81,23 @@ $(function () { $buttonSubmit.click(function (e) { e.preventDefault(); + message = l('BlogPostDraftConfirmationMessage', $title.val()); $status.val(blogPostStatus.Draft); - submitCoverImage(); + $formCreate.submit(); }); $buttonPublish.click(function (e) { - abp.message.confirm( - l('BlogPostPublishConfirmationMessage', $title.val()), - function (isConfirmed) { - if (isConfirmed) { - e.preventDefault(); - $status.val(blogPostStatus.Published); - submitCoverImage(); - } - } - ); + e.preventDefault(); + message = l('BlogPostPublishConfirmationMessage', $title.val()); + $status.val(blogPostStatus.Published); + $formCreate.submit(); }); $buttonSendToReview.click(function (e) { - abp.message.confirm( - l('BlogPostSendToReviewConfirmationMessage', $title.val()), - function (isConfirmed) { - if (isConfirmed) { - e.preventDefault(); - $status.val(blogPostStatus.SendToReview); - submitCoverImage(); - } - } - ); + e.preventDefault(); + message = l('BlogPostSendToReviewConfirmationMessage', $title.val()); + $status.val(blogPostStatus.SendToReview); + $formCreate.submit(); }); function submitEntityTags(blogPostId) { @@ -129,7 +130,7 @@ $(function () { return headers; } - function submitCoverImage() { + async function submitCoverImage() { abp.ui.setBusy(); var UPPY_OPTIONS = { @@ -155,18 +156,15 @@ $(function () { data: file, // file }); - UPPY.upload().then((result) => { - if (result.failed.length > 0) { - abp.message.error(l("UploadFailedMessage")); - } else { - $coverImage.val(result.successful[0].response.body.id); - - $formCreate.submit(); - } - }); + var result = await UPPY.upload(); + if (result.failed.length > 0) { + abp.message.error(l("UploadFailedMessage")); + } else { + $coverImage.val(result.successful[0].response.body.id); + } } else { - $formCreate.submit(); + abp.ui.clearBusy(); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/BlogPosts/update.js b/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/BlogPosts/update.js index 43a85419ea..5084eca9da 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/BlogPosts/update.js +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/BlogPosts/update.js @@ -4,6 +4,7 @@ $(function () { var $selectBlog = $('#BlogSelectionSelect'); var $formUpdate = $('#form-blog-post-update'); + var $title = $('#ViewModel_Title'); var $coverImage = $('#ViewModel_CoverImageMediaId'); var $slug = $('#ViewModel_Slug'); var $buttonSubmit = $('#button-blog-post-update'); @@ -16,6 +17,7 @@ $(function () { var UPPY_FILE_ID = "uppy-upload-file"; var isTagsEnabled = true; + var message = l('BlogPostSaveConfirmationMessage', $title.val()); $formUpdate.data('validator').settings.ignore = ":hidden, [contenteditable='true']:not([name]), .tui-popup-wrapper"; @@ -31,13 +33,15 @@ $(function () { initSelectBlog(); - $formUpdate.on('submit', function (e) { + $formUpdate.on('submit', async function (e) { e.preventDefault(); if ($formUpdate.valid()) { abp.ui.setBusy(); + await submitCoverImage(); + $formUpdate.ajaxSubmit({ success: function (result) { if (isTagsEnabled) { @@ -60,7 +64,7 @@ $(function () { $buttonSubmit.click(function (e) { e.preventDefault(); - submitCoverImage(); + $formUpdate.submit(); }); function submitEntityTags(blogPostId) { @@ -93,7 +97,7 @@ $(function () { return headers; } - function submitCoverImage() { + async function submitCoverImage() { abp.ui.setBusy(); var UPPY_OPTIONS = { @@ -119,18 +123,13 @@ $(function () { data: file, // file }); - UPPY.upload().then((result) => { - if (result.failed.length > 0) { - abp.message.error(l("UploadFailedMessage")); - } else { - $coverImage.val(result.successful[0].response.body.id); + var result = await UPPY.upload(); - $formUpdate.submit(); - } - }); - } - else { - $formUpdate.submit(); + if (result.failed.length > 0) { + abp.message.error(l("UploadFailedMessage")); + } else { + $coverImage.val(result.successful[0].response.body.id); + } } } From cf45b29c3c690725940f48c5ad9c0d3686c3f771 Mon Sep 17 00:00:00 2001 From: Enis Necipoglu Date: Tue, 16 Jan 2024 11:56:50 +0300 Subject: [PATCH 2/4] Add comment for csproj parameters --- .../Volo.CmsKit.Web.Unified/Volo.CmsKit.Web.Unified.csproj | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/Volo.CmsKit.Web.Unified.csproj b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/Volo.CmsKit.Web.Unified.csproj index dd8c3e8460..996655cc62 100644 --- a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/Volo.CmsKit.Web.Unified.csproj +++ b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/Volo.CmsKit.Web.Unified.csproj @@ -5,7 +5,8 @@ Volo.CmsKit true Volo.CmsKit-c2d31439-b723-48e2-b061-5ebd7aeb6010 - $(DefineConstants);MongoDB + + $(DefineConstants);MongoDB From fc63b3c65e4d1fa616e170d8fa0195dc6eeb046d Mon Sep 17 00:00:00 2001 From: Enis Necipoglu Date: Tue, 16 Jan 2024 13:21:39 +0300 Subject: [PATCH 3/4] Update BlogPostSaveConfirmationMessage in create.js --- .../Volo.CmsKit.Admin.Web/Pages/CmsKit/BlogPosts/create.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/BlogPosts/create.js b/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/BlogPosts/create.js index 01301351a1..bcb5ed051d 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/BlogPosts/create.js +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/BlogPosts/create.js @@ -27,7 +27,7 @@ $(function () { var UPPY_FILE_ID = "uppy-upload-file"; var isTagsEnabled = true; - var message = l('BlogPostSaveConfirmationMessage', $status.val()); + var message = l('BlogPostSaveConfirmationMessage', $title.val()); $formCreate.data('validator').settings.ignore = ":hidden, [contenteditable='true']:not([name]), .tui-popup-wrapper"; @@ -47,7 +47,6 @@ $(function () { e.preventDefault(); if ($formCreate.valid()) { - abp.message.confirm( message, async function (isConfirmed) { @@ -163,9 +162,6 @@ $(function () { $coverImage.val(result.successful[0].response.body.id); } } - else { - abp.ui.clearBusy(); - } } function finishSaving() { From 2d77f2a771a9aab59b3b9932e379c886cce361b7 Mon Sep 17 00:00:00 2001 From: Enis Necipoglu Date: Tue, 16 Jan 2024 13:22:30 +0300 Subject: [PATCH 4/4] Update static files --- .../wwwroot/libs/prismjs/LICENSE | 21 + .../wwwroot/libs/uppy/README.md | 28 +- .../wwwroot/libs/uppy/uppy.css | 2941 +- .../wwwroot/libs/uppy/uppy.js | 42133 ---------------- .../wwwroot/libs/uppy/uppy.js.map | 513 - .../wwwroot/libs/uppy/uppy.legacy.min.js | 56 + .../wwwroot/libs/uppy/uppy.legacy.min.js.map | 7 + .../wwwroot/libs/uppy/uppy.min.css | 4 +- .../wwwroot/libs/uppy/uppy.min.js | 65 +- .../wwwroot/libs/uppy/uppy.min.js.map | 5295 +- .../wwwroot/libs/uppy/uppy.min.mjs | 63 + .../wwwroot/libs/uppy/uppy.min.mjs.map | 7 + .../host/Volo.CmsKit.Web.Unified/yarn.lock | 534 + 13 files changed, 2355 insertions(+), 49312 deletions(-) create mode 100644 modules/cms-kit/host/Volo.CmsKit.Web.Unified/wwwroot/libs/prismjs/LICENSE delete mode 100644 modules/cms-kit/host/Volo.CmsKit.Web.Unified/wwwroot/libs/uppy/uppy.js delete mode 100644 modules/cms-kit/host/Volo.CmsKit.Web.Unified/wwwroot/libs/uppy/uppy.js.map create mode 100644 modules/cms-kit/host/Volo.CmsKit.Web.Unified/wwwroot/libs/uppy/uppy.legacy.min.js create mode 100644 modules/cms-kit/host/Volo.CmsKit.Web.Unified/wwwroot/libs/uppy/uppy.legacy.min.js.map create mode 100644 modules/cms-kit/host/Volo.CmsKit.Web.Unified/wwwroot/libs/uppy/uppy.min.mjs create mode 100644 modules/cms-kit/host/Volo.CmsKit.Web.Unified/wwwroot/libs/uppy/uppy.min.mjs.map diff --git a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/wwwroot/libs/prismjs/LICENSE b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/wwwroot/libs/prismjs/LICENSE new file mode 100644 index 0000000000..528949f42d --- /dev/null +++ b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/wwwroot/libs/prismjs/LICENSE @@ -0,0 +1,21 @@ +MIT LICENSE + +Copyright (c) 2012 Lea Verou + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/wwwroot/libs/uppy/README.md b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/wwwroot/libs/uppy/README.md index d33fe844ca..96526d55c9 100644 --- a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/wwwroot/libs/uppy/README.md +++ b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/wwwroot/libs/uppy/README.md @@ -1,17 +1,17 @@ # Uppy Hi, thanks for trying out the bundled version of the Uppy File Uploader. You can use -this from a CDN (e.g. ``) or bundle it with your webapp. +this from a CDN (``) or bundle it with your webapp. -Note that the recommended way to use Uppy is to install it with yarn/npm and use a -bundler like Webpack so that you can create a smaller custom build with just the +Note that the recommended way to use Uppy is to install it with yarn/npm and use a +bundler like Webpack so that you can create a smaller custom build with only the things that you need. More info on . ## How to use this bundle -You can extract the contents of this zip to e.g. `./js/uppy` +You can extract the contents of this zip to a directory, such as `./js/uppy`. -Now you can create an HTML file, e.g.: `./upload.html` with the following contents: +Now you can create an HTML file, for example `./upload.html`, with the following contents: ```html @@ -28,13 +28,13 @@ Now you can create an HTML file, e.g.: `./upload.html` with the following conten - -