More work on editing personal data
This commit is contained in:
+9
@@ -1491,6 +1491,15 @@ namespace Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to This doesn't look like a valid phone number, but we're storing it as written here..
|
||||
/// </summary>
|
||||
internal static string Master_EditPersonWarning_Phone {
|
||||
get {
|
||||
return ResourceManager.GetString("Master_EditPersonWarning_Phone", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to You are currently logged into <strong>{0}</strong>. Would you like to switch to another organization?.
|
||||
/// </summary>
|
||||
|
||||
@@ -755,4 +755,8 @@
|
||||
<data name="Master_EditPersonResetPasswordLabel" xml:space="preserve">
|
||||
<value>Mail a password-reset link</value>
|
||||
</data>
|
||||
<data name="Master_EditPersonWarning_Phone" xml:space="preserve">
|
||||
<value>This doesn't look like a valid phone number, but we're storing it as written here.</value>
|
||||
<comment>Trigges as a notice if phone misses a regexp.</comment>
|
||||
</data>
|
||||
</root>
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Web;
|
||||
using System.Web.Services;
|
||||
using System.Web.UI;
|
||||
@@ -263,6 +264,11 @@ namespace Swarmops.Frontend.Automation
|
||||
[WebMethod]
|
||||
public static AjaxInputCallResult SetPersonEditorData(int personId, string field, string newValue)
|
||||
{
|
||||
if (newValue == null || field == null)
|
||||
{
|
||||
throw new ArgumentNullException();
|
||||
}
|
||||
|
||||
AuthenticationData authData = GetAuthenticationDataAndCulture();
|
||||
bool self = false;
|
||||
|
||||
@@ -279,7 +285,7 @@ namespace Swarmops.Frontend.Automation
|
||||
return new AjaxInputCallResult
|
||||
{
|
||||
Success = false,
|
||||
DisplayMessage = JavascriptEscape(Resources.Global.Global_FieldCannotBeEmpty),
|
||||
DisplayMessage = Resources.Global.Global_FieldCannotBeEmpty,
|
||||
FailReason = AjaxInputCallResult.ErrorInvalidFormat,
|
||||
NewValue = GetPersonValue (personId, field)
|
||||
};
|
||||
@@ -301,6 +307,8 @@ namespace Swarmops.Frontend.Automation
|
||||
}
|
||||
|
||||
string oldValue;
|
||||
string displayMessage = string.Empty;
|
||||
newValue = newValue.Trim().Replace (" ", " ");
|
||||
|
||||
switch (field)
|
||||
{
|
||||
@@ -315,8 +323,17 @@ namespace Swarmops.Frontend.Automation
|
||||
case "Phone":
|
||||
oldValue = affectedPerson.Phone;
|
||||
affectedPerson.Phone = newValue;
|
||||
if (!Regex.IsMatch (newValue, @"^[0-9 \(\)\-\+]+$"))
|
||||
{
|
||||
// using characters not typically seen in a phone number? Warn
|
||||
displayMessage = Resources.Global.Master_EditPersonWarning_Phone;
|
||||
}
|
||||
break;
|
||||
case "TwitterId":
|
||||
if (newValue.StartsWith ("@"))
|
||||
{
|
||||
newValue = newValue.Substring (1);
|
||||
}
|
||||
oldValue = affectedPerson.TwitterId;
|
||||
affectedPerson.TwitterId = newValue;
|
||||
break;
|
||||
@@ -329,7 +346,7 @@ namespace Swarmops.Frontend.Automation
|
||||
ActingPersonId = authData.CurrentUser.PersonId,
|
||||
AffectedPersonId = affectedPerson.PersonId,
|
||||
Field = field,
|
||||
IpAddress = HttpContext.Current.Request.UserHostAddress,
|
||||
IpAddress = SupportFunctions.GetMostLikelyRemoteIPAddress(),
|
||||
OldValue = oldValue,
|
||||
NewValue = newValue
|
||||
});
|
||||
@@ -342,7 +359,8 @@ namespace Swarmops.Frontend.Automation
|
||||
return new AjaxInputCallResult
|
||||
{
|
||||
Success = true,
|
||||
NewValue = newValue
|
||||
NewValue = newValue,
|
||||
DisplayMessage = displayMessage
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -420,10 +420,13 @@
|
||||
console.log(result);
|
||||
if (result.Success) {
|
||||
window[controlName + "_updateSuccessAnimate"](result.NewValue);
|
||||
if (result.DisplayMessage != '') {
|
||||
alertify.log(result.DisplayMessage);
|
||||
}
|
||||
} else {
|
||||
window[controlName + "_updateFailAnimate"](result.NewValue);
|
||||
if (result.DisplayMessage != '') {
|
||||
alertify.error(SwarmopsJS.unescape(result.DisplayMessage));
|
||||
alertify.error(result.DisplayMessage);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user