Skip to content

Commit

Permalink
Made sure the UI button says "Mark", edited src/views/modals/best-res…
Browse files Browse the repository at this point in the history
…ponse.tpl

Added comments for next steps in public/src/client/topic/best-response.js
  • Loading branch information
Procos12 committed Oct 1, 2024
1 parent f577b08 commit 0b3a627
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
23 changes: 13 additions & 10 deletions public/src/client/topic/best-response.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ define('forum/topic/delete-posts', [
], function (postSelect, alerts, api) {
const DeletePosts = {};

Check failure on line 6 in public/src/client/topic/best-response.js

View workflow job for this annotation

GitHub Actions / test

Expected indentation of 1 tab but found 4 spaces
let modal;

Check failure on line 7 in public/src/client/topic/best-response.js

View workflow job for this annotation

GitHub Actions / test

Expected indentation of 1 tab but found 4 spaces
let deleteBtn;
let markBtn;

Check failure on line 8 in public/src/client/topic/best-response.js

View workflow job for this annotation

GitHub Actions / test

Expected indentation of 1 tab but found 4 spaces
let purgeBtn;

Check failure on line 9 in public/src/client/topic/best-response.js

View workflow job for this annotation

GitHub Actions / test

Expected indentation of 1 tab but found 4 spaces
let tid;

Check failure on line 10 in public/src/client/topic/best-response.js

View workflow job for this annotation

GitHub Actions / test

Expected indentation of 1 tab but found 4 spaces

Expand All @@ -25,10 +25,10 @@ define('forum/topic/delete-posts', [
$('body').append(modal);

//These are the buttons that are on the modal (other than close)
deleteBtn = modal.find('#delete_posts_confirm');
markBtn = modal.find('#markResponse_posts_confirm');
purgeBtn = modal.find('#purge_posts_confirm');

modal.find('#delete_posts_cancel').on('click', closeModal);
modal.find('#markResponse_posts_cancel').on('click', closeModal);

postSelect.init(function () {
checkButtonEnable();
Expand All @@ -37,12 +37,13 @@ define('forum/topic/delete-posts', [
showPostsSelected();

//Linking the buttons to the functionality
deleteBtn.on('click', function () {
deletePosts(deleteBtn, pid => `/posts/${pid}/state`);
markBtn.on('click', function () {
console.log('Clicked on mark');
markBestResponse(markBtn, pid => `/posts/${pid}/state`);
});
//ignore the purge button from now
purgeBtn.on('click', function () {
deletePosts(purgeBtn, pid => `/posts/${pid}`);
markBestResponse(purgeBtn, pid => `/posts/${pid}`);
});
});
};
Expand All @@ -55,8 +56,10 @@ define('forum/topic/delete-posts', [
}

//Edit this function to mark a post as the best response
function deletePosts(btn, route) {
function markBestResponse(btn, route) {
btn.attr('disabled', true);
//-Change the function below to mark as a best response here in the UI
console.log('marked');
Promise.all(postSelect.pids.map(pid => api.del(route(pid), {})))
.then(closeModal)
.catch(alerts.error)
Expand All @@ -72,13 +75,13 @@ define('forum/topic/delete-posts', [
modal.find('#pids').translateHtml('[[topic:fork-no-pids]]');
}
}

//Made sure you can only mark one post at a time in the UI
function checkButtonEnable() {
if (postSelect.pids.length==1) {
deleteBtn.removeAttr('disabled');
markBtn.removeAttr('disabled');
purgeBtn.removeAttr('disabled');
} else {
deleteBtn.attr('disabled', true);
markBtn.attr('disabled', true);
purgeBtn.attr('disabled', true);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/views/modals/best-response.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<p><strong><span id="pids"></span></strong></p>
</div>
<div class="card-footer text-end">
<button class="btn btn-link btn-sm" id="delete_posts_cancel">[[global:buttons.close]]</button>
<button class="btn btn-primary btn-sm" id="delete_posts_confirm" disabled>[[topic:delete]]</button>
<button class="btn btn-link btn-sm" id="markResponse_posts_cancel">[[global:buttons.close]]</button>
<button class="btn btn-primary btn-sm" id="markResponse_posts_confirm" disabled>Mark</button>
</div>
</div>

0 comments on commit 0b3a627

Please sign in to comment.