From 3d65b7736a391ab19b7537e1b7d25ec8d493fc74 Mon Sep 17 00:00:00 2001 From: Horilla Date: Mon, 20 Nov 2023 10:40:41 +0530 Subject: [PATCH] [FIX] RECRUITMENT: Bulk stage not update issue if record updated previously --- recruitment/static/pipeline/badge.js | 116 +++++++++---------- recruitment/templates/pipeline/pipeline.html | 1 + 2 files changed, 57 insertions(+), 60 deletions(-) diff --git a/recruitment/static/pipeline/badge.js b/recruitment/static/pipeline/badge.js index 2a260570a..fc2b8f054 100644 --- a/recruitment/static/pipeline/badge.js +++ b/recruitment/static/pipeline/badge.js @@ -1,77 +1,73 @@ - $(document).ready(function () { - $('.stage-change').on('change', function(e) { - e.preventDefault() + $(".stage-change").on("change", function (e) { + e.preventDefault(); - // Your code here - var candidateId = $(this).attr('data-candidate-id'); - var stageId = $(this).val(); - const elementToMove = $(`[data-change-cand-id=${candidateId}]`) - $(`#candidateContainer${stageId}`).append(elementToMove); - setTimeout(() => { - $.ajax({ - type: "post", - url: `/recruitment/candidate-stage-update/${candidateId}/`, - data: { - csrfmiddlewaretoken: getCookie("csrftoken"), - stageId: stageId, - }, - success: function (response) { - var selectElement = $("#stageChange" + candidateId); - selectElement.val(stageId); - var duration = 0; - if (response.type != "noChange") { - $("#ohMessages").append(` + // Your code here + var candidateId = $(this).attr("data-candidate-id"); + var stageId = $(this).val(); + const elementToMove = $(`[data-change-cand-id=${candidateId}]`); + $(`#candidateContainer${stageId}`).append(elementToMove); + setTimeout(() => { + $.ajax({ + type: "post", + url: `/recruitment/candidate-stage-update/${candidateId}/`, + data: { + csrfmiddlewaretoken: getCookie("csrftoken"), + stageId: stageId, + }, + success: function (response) { + var selectElement = $("#stageChange" + candidateId); + selectElement.val(stageId); + selectElement.attr("data-stage-id", stageId); + var duration = 0; + if (response.type != "noChange") { + $("#ohMessages").append(`
${response.message}
`); - duration = 1500; - }else{ - countSequence(false); - } - }, - error: (response) => { - $("#ohMessages").append(` + duration = 1500; + } else { + countSequence(false); + } + }, + error: (response) => { + $("#ohMessages").append(`
Something went wrong.
`); - }, - }); - }, 100); + }, + }); + }, 100); + }); - - }); - - - - // Bind the DOMNodeInserted event listener - $('.candidate-container').on('DOMNodeInserted', function(event) { - var addedNode = event.target; - // Check if the added node is a div with the class name "change-cand" - if (addedNode.nodeType === 1 && $(addedNode).hasClass('change-cand')) { - let count = $(this).children().filter('.change-cand').length; - var stageId = $(this).attr('data-stage-id'); - var stageBadge = $(`#stageCount${stageId}`) - stageBadge.html(count) - stageBadge.attr("title", `${count} candidates`); + // Bind the DOMNodeInserted event listener + $(".candidate-container").on("DOMNodeInserted", function (event) { + var addedNode = event.target; + // Check if the added node is a div with the class name "change-cand" + if (addedNode.nodeType === 1 && $(addedNode).hasClass("change-cand")) { + let count = $(this).children().filter(".change-cand").length; + var stageId = $(this).attr("data-stage-id"); + var stageBadge = $(`#stageCount${stageId}`); + stageBadge.html(count); + stageBadge.attr("title", `${count} candidates`); + $(this).find(".stage-change").attr("data-stage-id",stageId) + } + }); - } - }); - - $('.candidate-container').on('DOMNodeRemoved', function(event) { + $(".candidate-container").on("DOMNodeRemoved", function (event) { var removedNode = event.target; // Check if the removed node is a div with the class name "change-cand" - if (removedNode.nodeType === 1 && $(removedNode).hasClass('change-cand')) { - let count = $(this).children().filter('.change-cand').length; - var stageId = $(this).attr('data-stage-id'); - var stageBadge = $(`#stageCount${stageId}`) - count_element() - stageBadge.html(count-1) - stageBadge.attr("title", `${count-1} candidates`); + if (removedNode.nodeType === 1 && $(removedNode).hasClass("change-cand")) { + let count = $(this).children().filter(".change-cand").length; + var stageId = $(this).attr("data-stage-id"); + var stageBadge = $(`#stageCount${stageId}`); + count_element(); + stageBadge.html(count - 1); + stageBadge.attr("title", `${count - 1} candidates`); } - }); - }); \ No newline at end of file + }); +}); diff --git a/recruitment/templates/pipeline/pipeline.html b/recruitment/templates/pipeline/pipeline.html index 160fb169c..eb35afb11 100644 --- a/recruitment/templates/pipeline/pipeline.html +++ b/recruitment/templates/pipeline/pipeline.html @@ -431,6 +431,7 @@ select.val(nextStageId) select.change() $(this).val(""); + $(this).closest(".oh-table-config__tr").find(".stage-candidates").prop("checked",false).change() }); });