Deploying more work to Sandbox for testing

This commit is contained in:
Rick Falkvinge
2016-09-12 12:57:33 +02:00
parent 639919cb2d
commit ef11b6b9af
3 changed files with 101 additions and 46 deletions
+2 -2
View File
@@ -258,12 +258,12 @@ namespace Swarmops.Frontend.Automation
}
[WebMethod]
public static AjaxInputCallResult SetPersonEditorData(string newValue, string cookie)
public static AjaxInputCallResult SetPersonEditorData(int personId, string field, string newValue)
{
return new AjaxInputCallResult
{
Success = true,
NewValue = "The change call was successful"
NewValue = field + ": The change call was successful"
};
throw new NotImplementedException();
}
+60 -38
View File
@@ -1,5 +1,6 @@
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="AjaxTextBox.ascx.cs" Inherits="Swarmops.Frontend.Controls.v5.Base.AjaxTextBox" %>
<%-- ReSharper disable once ConditionIsAlwaysConst --%>
<script type="text/javascript">
$(document).ready(function () {
@@ -22,54 +23,75 @@
// The page must include IncludedControls.JsonParameters and IncludedControls.ColorAnimation among its script.
$(this).css('background-color', '#FFFFE0');
SwarmopsJS.ajaxCall(
"<%=this.AjaxCallbackUrl%>",
jsonData,
$.proxy(function(msg) {
if (msg.Success == false) {
if (msg.DisplayMessage != null) {
alertify.error(msg.DisplayMessage);
} else {
alertify.error("There was an error attempting to set this value."); // TODO: Localize
}
$(this).css('background-color', '#FFA0A0');
} else {
if (msg.DisplayMessage != null) {
alertify.log(msg.DisplayMessage);
}
$(this).css('background-color', '#E0FFE0');
_initVal_<%=this.TextInput.ClientID%> = msg.NewValue;
}
$(this).val(_initVal_<%=this.TextInput.ClientID%>);
$(this).animate({ backgroundColor: "#FFFFFF" }, 250);
<%
if (!string.IsNullOrEmpty(this.OnChange))
{
if (string.IsNullOrEmpty (this.Cookie))
{
Response.Write (this.OnChange + "(msg.NewValue);"); // JavaScript callback on successful change
if ("" != "<%=this.AjaxCallbackUrl%>") { // if there's a direct callback AJAX url
SwarmopsJS.ajaxCall(
"<%=this.AjaxCallbackUrl%>",
jsonData,
$.proxy(function(msg) {
if (msg.Success == false) {
if (msg.DisplayMessage != null) {
alertify.error(msg.DisplayMessage);
} else {
alertify.error("There was an error attempting to set this value."); // TODO: Localize
}
else
{
Response.Write (this.OnChange + "(msg.NewValue, '" + this.Cookie + "');"); // JavaScript callback on successful change
$(this).css('background-color', '#FFA0A0');
} else {
if (msg.DisplayMessage != null) {
alertify.log(msg.DisplayMessage);
}
$(this).css('background-color', '#E0FFE0');
_initVal_<%=this.TextInput.ClientID%> = msg.NewValue;
}
$(this).val(_initVal_<%=this.TextInput.ClientID%>);
$(this).animate({ backgroundColor: "#FFFFFF" }, 250);
<%
if (!string.IsNullOrEmpty(this.OnChange))
{
if (string.IsNullOrEmpty (this.Cookie))
{
Response.Write (this.OnChange + "(msg.NewValue);"); // JavaScript callback on successful change
}
else
{
Response.Write (this.OnChange + "(msg.NewValue, '" + this.Cookie + "');"); // JavaScript callback on successful change
}
}
%>
}, this),
$.proxy(function(msg) {
alertify.error("<%= Resources.Global.Error_AjaxCallException %>");
$(this).val(_initVal_<%=this.TextInput.ClientID%>);
$(this).css('background-color', '#FFA0A0');
$(this).animate({ backgroundColor: "#FFFFFF" }, 250);
}, this)
);
%>
}, this),
$.proxy(function(msg) {
alertify.error("<%= Resources.Global.Error_AjaxCallException %>");
$(this).val(_initVal_<%=this.TextInput.ClientID%>);
$(this).css('background-color', '#FFA0A0');
$(this).animate({ backgroundColor: "#FFFFFF" }, 250);
}, this)
);
} else {
// if there's no AJAX callback URL given, the javascript handler must take care of it
// Resharper marks this code as unused because it falsely thinks the if condition above is always true
<%=this.OnChange%> (currentValue, '<%=this.Cookie%>', '<%=this.ClientID%>'); // JavaScript callback on successful change
}
}
});
});
function <%=this.ClientID%>_updateSuccessAnimate(newValue) {
$('#<%=this.TextInput.ClientID%>').css('background-color', '#E0FFE0');
$('#<%=this.TextInput.ClientID%>').animate({ backgroundColor: "#FFFFFF" }, 250);
<%=this.ClientID%>_initialize(newValue);
}
function <%=this.ClientID%>_updateFailAnimate(newValue) {
$('#<%=this.TextInput.ClientID%>').css('background-color', '#FFA0A0');
$('#<%=this.TextInput.ClientID%>').animate({ backgroundColor: "#FFFFFF" }, 250);
<%=this.ClientID%>_initialize(newValue);
}
function <%=this.ClientID%>_disable() {
$('#<%=this.TextInput.ClientID%>').attr ('disabled', 'disabled');
+39 -6
View File
@@ -224,10 +224,10 @@
<div title="<img src='/Images/Icons/iconshock-redshirt-128px.png' width='64' height='64' />">
<h2><span class="spanModalEditingPersonName">PERSONNAME</span>: Account</h2>
<div class="entryFields">
<Swarmops5:AjaxTextBox ID="MasterEditPersonName" runat="server" OnChange="masterPersonEditorOnFieldChange" Cookie="Name" AjaxCallbackUrl="/Automation/SwarmFunctions.aspx/SetPersonEditorData" />&#8203;<br/>
<Swarmops5:AjaxTextBox ID="MasterEditPersonMail" runat="server" />&#8203;<br/>
<Swarmops5:AjaxTextBox ID="MasterEditPersonPhone" runat="server" />&#8203;<br/>
<Swarmops5:AjaxTextBox ID="MasterEditPersonTwitterId" runat="server" />
<Swarmops5:AjaxTextBox ID="MasterEditPersonName" runat="server" OnChange="masterPersonEditorOnFieldChange" Cookie="Name" AjaxCallbackUrl="" />&#8203;<br/>
<Swarmops5:AjaxTextBox ID="MasterEditPersonMail" runat="server" OnChange="masterPersonEditorOnFieldChange" Cookie="Mail" AjaxCallbackUrl="" />&#8203;<br/>
<Swarmops5:AjaxTextBox ID="MasterEditPersonPhone" runat="server" OnChange="masterPersonEditorOnFieldChange" Cookie="Phone" AjaxCallbackUrl="" />&#8203;<br/>
<Swarmops5:AjaxTextBox ID="MasterEditPersonTwitterId" runat="server" OnChange="masterPersonEditorOnFieldChange" Cookie="TwitterId" AjaxCallbackUrl="" />
</div>
<div class="entryLabels">
Name<br/>
@@ -367,6 +367,14 @@
<%= this.MasterEditPersonTwitterId.ClientID %>_initialize(data.TwitterId);
_master_PersonEditLoading = false;
// TEST CODE BELOW
masterPersonEditorOnFieldChange("YAY1", "Name", '<%=this.MasterEditPersonName.ClientID%>');
masterPersonEditorOnFieldChange("YAY2", "Mail", '<%=this.MasterEditPersonMail.ClientID%>');
masterPersonEditorOnFieldChange("YAY3", "Phone", '<%=this.MasterEditPersonPhone.ClientID%>');
} else {
alert('Server error: Call to SwarmFunctions.aspx failed');
}
@@ -381,8 +389,33 @@
var _master_PersonEditedId = -1; // no person: zero means "self"
var _master_PersonEditLoading = false;
function masterPersonEditorOnFieldChange(newValue, fieldName) {
alert("Field Change: " + fieldName + " changed to '" + newValue + "'");
function masterPersonEditorOnFieldChange(newValue, fieldName, controlName) {
// Do the AJAX call from here, as we need to also pass along the person ID of the person edited
// (the AjaxTextBox auto-callback is disabled for this reason, code duplicated here)
var jsonData = {
personId: _master_PersonEditedId,
field: fieldName,
newValue: newValue
};
SwarmopsJS.ajaxCall(
// HACK: Possible race condition for "controlName" here in some environments?
"/Automation/SwarmFunctions.aspx/SetPersonEditorData",
jsonData,
function(result) {
window[controlName + "_updateSuccessAnimate"](result.NewValue);
},
function(result) {
window[controlName + "_updateFailAnimate"](result.NewValue);
});
//alert("Field Change: " + fieldName + " changed to '" + newValue + "'");
}
function masterEndEditPerson() {