Checkpoint commit

This commit is contained in:
Rick Falkvinge
2015-04-22 13:14:41 +02:00
parent 01beddc785
commit 7587cc45d8
3 changed files with 67 additions and 13 deletions
+35
View File
@@ -1,4 +1,5 @@
using System;
using System.Activities.Statements;
using System.Collections.Generic;
using System.Linq;
using System.Web;
@@ -118,6 +119,40 @@ namespace Swarmops.Frontend.Automation
return new AjaxCallResult {Success = true};
}
[WebMethod]
static public AssignmentData GetAssignmentData (int assignmentId)
{
AuthenticationData authData = GetAuthenticationDataAndCulture();
PositionAssignment assignment = PositionAssignment.FromIdentity (assignmentId);
if (authData.Authority.CanAccess (assignment, AccessType.Read))
{
return new AssignmentData
{
Success = true,
AssignedPersonCanonical = assignment.Person.Canonical,
AssignedPersonId = assignment.PersonId,
PositionAssignmentId = assignment.Identity,
PositionId = assignment.PositionId,
PositionLocalized = assignment.Position.Localized()
};
}
else
{
return new AssignmentData {Success = false};
}
}
public class AssignmentData : AjaxCallResult
{
public int PositionAssignmentId { get; set; }
public int PositionId { get; set; }
public string PositionLocalized { get; set; }
public int AssignedPersonId { get; set; }
public string AssignedPersonCanonical { get; set; }
}
public class AvatarData : AjaxCallResult
{
public int PersonId { get; set; }
+31 -12
View File
@@ -9,7 +9,7 @@
}
preload([
'/Images/Abstract/ajaxloader-medium.gif',
'/Images/Abstract/ajaxloader-48x36px.gif',
'/Images/Icons/iconshock-balloon-no-128x96px-hot.png'
]);
$(document).ready(function() {
@@ -48,10 +48,12 @@
}
});
$('.LocalIconTerminate.LocalPosition<%=this.Cookie%>').click(function () {
$('.LocalIconTerminate.LocalPosition<%=this.Cookie%>').click(function() {
if ($(this).attr("rel") != "loading") {
$(this).attr("rel", "loading");
$(this).attr("src", "/Images/Abstract/ajaxloader-48x36px.gif");
var okLabel = decodeURIComponent('<asp:Literal ID="LiteralTerminateYes" runat="server" />');
var cancelLabel = decodeURIComponent('<asp:Literal ID="LiteralTerminateNo" runat="server" />');
var confirmQuestion = decodeURIComponent('<asp:Literal ID="LiteralConfirmTermination" runat="server" />');
@@ -67,18 +69,35 @@
ok: okLabel,
cancel: cancelLabel
},
buttonFocus: 'cancel'
buttonFocus: 'cancel'
});
alertify.confirm(confirmQuestion,
$.proxy(function (response) {
if (response) {
// user clicked the GREEN button, which is "confirm termination"
$('#spanTerminatePersonName').text('[...]');
onConfirmTermination($(this).attr("assignmentId"));
}
$(this).attr("rel", ""); // clear state
}, this));
alertify.confirm(confirmQuestion,
$.proxy(function(response) {
if (response) {
// user clicked the GREEN button, which is "confirm termination"
onConfirmTermination($(this).attr("assignmentId"));
} else {
// if cancel termination, restore icon from loader to action icon again
$(this).attr("src", "/Images/Icons/iconshock-balloon-no-128x96px.png");
}
$(this).attr("rel", ""); // clear state
}, this));
// Fill in the name and position that are now on-screen in a question
SwarmopsJS.ajaxCall("/Automation/SwarmFunctions.aspx/GetAssignmentData",
{assignmentId: $(this).attr("assignmentId") },
function (result) {
if (result.Success) {
$('#spanTerminatePersonName').text(result.AssignedPersonCanonical);
$('#spanTerminatePositionName').text(result.PositionLocalized);
} else {
$('#spanTerminatePersonName,#spanTerminatePositionName').text('[-ERROR-]');
}
});
return; // Do not process here - must wait for confirm dialog to return
@@ -97,7 +116,7 @@
return;
}
// TODO: Check existing position for person; can't have two positions
// TODO: Check existing position for person; can't have two positions, at least not within same org
SwarmopsJS.ajaxCall(
"/Automation/SwarmFunctions.aspx/AssignPosition",
+1 -1
View File
@@ -450,7 +450,7 @@
<Permissions />
<ImageUrl>iconshock-group-diversified</ImageUrl>
<NavigateUrl>/Pages/v5/Admin/OrgStaff.aspx</NavigateUrl>
<Type>Disabled</Type>
<Type>Link</Type>
<Children />
</MainMenuItem>