Skip to content

Commit

Permalink
Fix falsy displaying of warning dialog when assigning task to a user.
Browse files Browse the repository at this point in the history
  • Loading branch information
krausvo1 committed Sep 2, 2024
1 parent c184bbe commit c70d652
Showing 1 changed file with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* information: "Portions copyright [year] [name of copyright owner]".
*
* Copyright 2015-2016 ForgeRock AS.
* Portions Copyright 2023 Wren Security.
* Portions Copyright 2023-2024 Wren Security.
*/

define([
Expand Down Expand Up @@ -99,14 +99,14 @@ define([
cssClass: "btn-primary",
action: function(dialogRef) {
var id = $("#candidateUsersSelect").val(),
label = $("#candidateUsersSelect option:selected").text(),
selectedUser = _.find(candidateUsers, { _id: id }),
callback = function () {
_this.render([_this.model.id], _.bind(function () {
messagesManager.messages.addMessage({"message": $.t("templates.taskInstance.assignedSuccess")});
}, this));
};

obj.assignTask(_this.model, id, label, callback);
obj.assignTask(_this.model, selectedUser, callback);
dialogRef.close();
}
}
Expand All @@ -118,18 +118,17 @@ define([
* sets the assignee attribute on a taskinstance
*
* @param model {a taskinstance model}
* @id {the new assignee id to be set}
* @label {the username text to be displayed in the nonCandidateWarning}
* @user {object representing the new assignee user to be set}
* @successCallback
* @returns {nothing}
* @constructor
*/
obj.assignTask = function(model, id, label, successCallback) {
obj.assignTask = function(model, user, successCallback) {
var assignNow = function () {
model.set("assignee",id);
model.set("assignee", user._id);

if (id === "noUserAssigned") {
model.set("assignee",null);
if (user._id === "noUserAssigned") {
model.set("assignee", null);
}

model.save().then(successCallback);
Expand All @@ -139,8 +138,8 @@ define([
* before changing assignee alert the "assigner" that the user
* being assigned does not exist in the list of candidate users
*/
if (id !== "noUserAssigned" && !_.includes(model.get("candidates").candidateUsers, id)) {
UIUtils.jqConfirm($.t("templates.taskInstance.nonCanditateWarning",{ userName: label }), _.bind(function() {
if (user._id !== "noUserAssigned" && !_.includes(model.get("candidates").candidateUsers, user.userName)) {
UIUtils.jqConfirm($.t("templates.taskInstance.nonCanditateWarning",{ userName: user.userName }), _.bind(function() {
assignNow();
}, this));
} else {
Expand Down

0 comments on commit c70d652

Please sign in to comment.