This commit is contained in:
2020-01-15 18:52:18 +00:00
parent 8c574152e8
commit de08030b37
6 changed files with 39 additions and 22 deletions

View File

@@ -20,6 +20,15 @@ REALLY MAKING MORE PROGRESS WHEN CLIENT DEV DRIVES BACKEND DEV, STICK TO THAT!!
----------------------- -----------------------
DATATYPE: should this be an enum rather than text because text takes up a lot of space bandwidth wise and is inefficient and also an enum can allow compiler type enforcement to avoid typos etc DATATYPE: should this be an enum rather than text because text takes up a lot of space bandwidth wise and is inefficient and also an enum can allow compiler type enforcement to avoid typos etc
- Test enum picklist route on datatypes
CLIENT CUSTOM FIELDS CHANGE
- Must use numeric instead of text values now
- Additional NUMBER is split now between integer and decimal types update control STEP value for inputs to include decimal places or none depending on type
TEST CHANGES
- Must use numeric instead of text values now
- Test datatypes enum picklist
GRID LISTS TODO NOW: GRID LISTS TODO NOW:

View File

@@ -63,6 +63,19 @@ namespace AyaNova.Api.Controllers
switch (enumkey) switch (enumkey)
{ {
case "datatypes":
{
//Iterate the enum and get the values
Type t = typeof(AyaDataType);
Enum.GetName(t, AyaDataType.NoType);
foreach (var dt in Enum.GetValues(t))
{
ReturnList.Add(new NameIdItem() { Name = Enum.GetName(t, dt), Id = (long) dt });
}
}
break;
case "usertypes": case "usertypes":
{ {
LocaleKeysToFetch.Add("UserTypesAdministrator"); LocaleKeysToFetch.Add("UserTypesAdministrator");
@@ -160,6 +173,7 @@ namespace AyaNova.Api.Controllers
ret.Add(new KeyValuePair<string, string>("usertypes", "AyaNova user account types")); ret.Add(new KeyValuePair<string, string>("usertypes", "AyaNova user account types"));
ret.Add(new KeyValuePair<string, string>("authorizationroles", "AyaNova user account role types")); ret.Add(new KeyValuePair<string, string>("authorizationroles", "AyaNova user account role types"));
ret.Add(new KeyValuePair<string, string>("AyaType", "All AyaNova object types, use the AyaTypeController route to fetch these")); ret.Add(new KeyValuePair<string, string>("AyaType", "All AyaNova object types, use the AyaTypeController route to fetch these"));
ret.Add(new KeyValuePair<string, string>("datatypes", "Types of data used in AyaNova for display and formatting UI purposes"));
return Ok(ApiOkResponse.Response(ret, true)); return Ok(ApiOkResponse.Response(ret, true));
} }

View File

@@ -102,12 +102,14 @@ namespace AyaNova.Api.Controllers
/// <summary> /// <summary>
/// Get available types allowed for Custom fields /// Get available types allowed for Custom fields
/// Used to build UI for customizing a form /// Used to build UI for customizing a form
/// These values are a subset of the AyaDataTypes values
/// which can be fetched from the EnumPickList route
/// ///
/// Required roles: /// Required roles:
/// BizAdminFull only has rights to customize forms /// BizAdminFull only has rights to customize forms
/// ///
/// </summary> /// </summary>
/// <returns>A list of type string values valid for custom fields</returns> /// <returns>A list of valid values for custom field types</returns>
[HttpGet("AvailableCustomTypes")] [HttpGet("AvailableCustomTypes")]
public ActionResult GetAvailableCustomTypes() public ActionResult GetAvailableCustomTypes()
{ {

View File

@@ -13,16 +13,6 @@ namespace AyaNova.Biz
// - Text // - Text
// - Bool // - Bool
// public const string Currency = "currency";
// public const string Date = "date";
// public const string Time = "time";
// public const string DateTime = "datetime";
// public const string Text = "text";
// public const string Number = "number"; //decimal regardless
// public const string Bool = "bool";
public static List<int> ValidCustomFieldTypes public static List<int> ValidCustomFieldTypes
{ {
get get
@@ -33,7 +23,8 @@ namespace AyaNova.Biz
ret.Add((int)AyaDataType.Time); ret.Add((int)AyaDataType.Time);
ret.Add((int)AyaDataType.DateTime); ret.Add((int)AyaDataType.DateTime);
ret.Add((int)AyaDataType.Text); ret.Add((int)AyaDataType.Text);
ret.Add((int)AyaDataType.Number); ret.Add((int)AyaDataType.Decimal);
ret.Add((int)AyaDataType.Integer);
ret.Add((int)AyaDataType.Bool); ret.Add((int)AyaDataType.Bool);
return ret; return ret;
} }

View File

@@ -258,7 +258,7 @@ namespace AyaNova.Biz
AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "Template", $"Template array item {i}, \"type\" property value is not valid, only Custom fields can have types specified"); AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "Template", $"Template array item {i}, \"type\" property value is not valid, only Custom fields can have types specified");
else else
{//It is a custom field, is it a valid type value {//It is a custom field, is it a valid type value
var templateFieldCustomTypeValue = formFieldItem["type"].Value<string>(); var templateFieldCustomTypeValue = formFieldItem["type"].Value<int>();
if (!ValidCustomFieldTypes.Contains(templateFieldCustomTypeValue)) if (!ValidCustomFieldTypes.Contains(templateFieldCustomTypeValue))
AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "Template", $"Template array item {i}, \"type\" property value of \"{templateFieldCustomTypeValue}\" is not a valid custom field type"); AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "Template", $"Template array item {i}, \"type\" property value of \"{templateFieldCustomTypeValue}\" is not a valid custom field type");
} }

View File

@@ -79,6 +79,7 @@ namespace AyaNova.Util
//WIDGET sample form customization //WIDGET sample form customization
{ {
var fc = new FormCustom() var fc = new FormCustom()
{ {
FormKey = ObjectFields.WIDGET_KEY, FormKey = ObjectFields.WIDGET_KEY,
@@ -90,37 +91,37 @@ namespace AyaNova.Util
{ {
""fld"": ""WidgetCustom1"", ""fld"": ""WidgetCustom1"",
""required"": false, ""required"": false,
""type"": ""datetime"" ""type"": 1
}, },
{ {
""fld"": ""WidgetCustom2"", ""fld"": ""WidgetCustom2"",
""required"": true, ""required"": true,
""type"": ""text"" ""type"": 4
}, },
{ {
""fld"": ""WidgetCustom3"", ""fld"": ""WidgetCustom3"",
""required"": false, ""required"": false,
""type"": ""number"" ""type"": 5
}, },
{ {
""fld"": ""WidgetCustom4"", ""fld"": ""WidgetCustom4"",
""required"": false, ""required"": false,
""type"": ""bool"" ""type"": 6
}, },
{ {
""fld"": ""WidgetCustom5"", ""fld"": ""WidgetCustom5"",
""required"": false, ""required"": false,
""type"": ""currency"" ""type"": 8
}, },
{ {
""fld"": ""WidgetCustom6"", ""fld"": ""WidgetCustom6"",
""required"": false, ""required"": false,
""type"": ""date"" ""type"": 2
}, },
{ {
""fld"": ""WidgetCustom7"", ""fld"": ""WidgetCustom7"",
""required"": false, ""required"": false,
""type"": ""time"" ""type"": 3
} }
]" ]"
}; };