This commit is contained in:
2019-01-10 19:32:24 +00:00
parent 55266fd87f
commit d7c54cca70
3 changed files with 54 additions and 119 deletions

View File

@@ -36,11 +36,12 @@ UI FEATURE - The ability to customize forms:
- #DONE# Need a FormCustom table and model to hold the user's form customization data - #DONE# Need a FormCustom table and model to hold the user's form customization data
- Like DataFilter, holds a JSON fragment in one field and the form key in another field - Like DataFilter, holds a JSON fragment in one field and the form key in another field
- JSON FRAGMENT holds items that differ from stock, no "core" fields allowed - JSON FRAGMENT holds items that differ from stock, Hide not valid for non hideable core fields
- FieldKey - FieldKey "fld"
- Hide - Hide "hide"
- Required - Required "required"
- Type (checkbox, date, date time, decimal, number, picklist(FUTURE), and text) - Type One of values from AyDataType but not tags or enum (bool, date, date time, decimal, number, picklist(FUTURE), and text)
- e.g.: {fields:[{fld:"ltkeyoffieldname",hide:"true/false",required:"true/false", type:"bool"},{fld:"dollarAmount",lt:"WidgetDollarAmount",type:"currency"}]}
- #DONE# Need a FormAvailableFields static collection class that contains the fields available to each form - #DONE# Need a FormAvailableFields static collection class that contains the fields available to each form
- This should be independent from any other class tied to a particular route or controller or db table as it could be some or none of all of those things - This should be independent from any other class tied to a particular route or controller or db table as it could be some or none of all of those things

View File

@@ -127,30 +127,6 @@ namespace AyaNova.Api.Controllers
// /// <summary>
// /// Get FormCustom pick list
// ///
// /// Required roles: Any
// ///
// /// </summary>
// /// <returns>List of public or owned data filters for listKey provided</returns>
// [HttpGet("PickList", Name = nameof(FormCustomPickList))]
// public async Task<IActionResult> FormCustomPickList([FromQuery] string ListKey)
// {
// if (serverState.IsClosed)
// return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
// if (!ModelState.IsValid)
// return BadRequest(new ApiErrorResponse(ModelState));
// //Instantiate the business object handler
// FormCustomBiz biz = FormCustomBiz.GetBiz(ct, HttpContext);
// var l = await biz.GetPickListAsync(ListKey);
// return Ok(new ApiOkResponse(l));
// }
// /// <summary> // /// <summary>
// /// Put (update) FormCustom // /// Put (update) FormCustom
@@ -197,75 +173,40 @@ namespace AyaNova.Api.Controllers
// } // }
// /// <summary> /// <summary>
// /// Post FormCustom /// Post FormCustom
// /// ///
// /// Required roles: /// Required roles: BizAdminFull
// /// BizAdminFull, InventoryFull, TechFull /// </summary>
// /// </summary> /// <param name="inObj"></param>
// /// <param name="inObj"></param> /// <returns></returns>
// /// <returns></returns> [HttpPost]
// [HttpPost] public async Task<IActionResult> PostFormCustom([FromBody] FormCustom inObj)
// public async Task<IActionResult> PostFormCustom([FromBody] FormCustom inObj) {
// { if (!serverState.IsOpen)
// if (!serverState.IsOpen) return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
// return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
// //Instantiate the business object handler //Instantiate the business object handler
// FormCustomBiz biz = FormCustomBiz.GetBiz(ct, HttpContext); FormCustomBiz biz = FormCustomBiz.GetBiz(ct, HttpContext);
// //If a user has change roles, or editOwnRoles then they can create, true is passed for isOwner since they are creating so by definition the owner //check rights
// if (!Authorized.IsAuthorizedToCreate(HttpContext.Items, biz.BizType)) if (!Authorized.IsAuthorizedToCreate(HttpContext.Items, biz.BizType))
// return StatusCode(401, new ApiNotAuthorizedResponse()); return StatusCode(401, new ApiNotAuthorizedResponse());
// if (!ModelState.IsValid) if (!ModelState.IsValid)
// return BadRequest(new ApiErrorResponse(ModelState)); return BadRequest(new ApiErrorResponse(ModelState));
// //Create and validate //Create and validate
// FormCustom o = await biz.CreateAsync(inObj); FormCustom o = await biz.CreateAsync(inObj);
// if (o == null) if (o == null)
// return BadRequest(new ApiErrorResponse(biz.Errors)); return BadRequest(new ApiErrorResponse(biz.Errors));
// else else
// return CreatedAtAction("GetFormCustom", new { id = o.Id }, new ApiCreatedResponse(o)); return CreatedAtAction("GetFormCustom", new { id = o.Id }, new ApiCreatedResponse(o));
// } }
// /// <summary>
// /// Delete FormCustom
// ///
// /// Required roles:
// /// Any if public otherwise creator only
// ///
// /// </summary>
// /// <param name="id"></param>
// /// <returns>Ok</returns>
// [HttpDelete("{id}")]
// public async Task<IActionResult> DeleteFormCustom([FromRoute] long id)
// {
// if (!serverState.IsOpen)
// return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
// if (!ModelState.IsValid)
// return BadRequest(new ApiErrorResponse(ModelState));
// //Instantiate the business object handler
// FormCustomBiz biz = FormCustomBiz.GetBiz(ct, HttpContext);
// var o = await biz.GetNoLogAsync(id);
// if (o == null)
// return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
// if (!Authorized.IsAuthorizedToDelete(HttpContext.Items, biz.BizType, o.OwnerId))
// return StatusCode(401, new ApiNotAuthorizedResponse());
// if (!biz.Delete(o))
// return BadRequest(new ApiErrorResponse(biz.Errors));
// return NoContent();
// }
//------------ //------------

View File

@@ -80,35 +80,7 @@ namespace AyaNova.Biz
} }
} }
////////////////////////////////////////////////////////////////////////////////////////////////
//CREATE
internal FormCustom Create(AyContext TempContext, FormCustom inObj)
{
Validate(inObj, true);
if (HasErrors)
return null;
else
{
//do stuff with datafilter
FormCustom outObj = inObj;
outObj.OwnerId = UserId;
TempContext.FormCustom.Add(outObj);
TempContext.SaveChanges();
//Handle child and associated items:
//EVENT LOG
EventLogProcessor.LogEventToDatabase(new Event(UserId, outObj.Id, BizType, AyaEvent.Created), TempContext);
//SEARCH INDEXING
// Search.ProcessNewObjectKeywords(UserLocaleId, outObj.Id, BizType, outObj.Name, outObj.Name);
return outObj;
}
}
//////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////
/// GET /// GET
@@ -203,7 +175,28 @@ namespace AyaNova.Biz
try try
{ {
var v = JArray.Parse(inObj.Template); var v = JArray.Parse(inObj.Template);
//Validate the following:
//FormKey is valid value
//All fields specified are valid values
//Field is allowed to be hidden if hidden
//Type is one of the valid types:
/*
public const string Date = "date";
public const string Text = "text";
public const string Integer = "int";
public const string Bool = "bool";
public const string Decimal = "decimal";
*/
//TODO: validate the json //TODO: validate the json
/*
- JSON FRAGMENT holds items that differ from stock, no "core" fields allowed
- FieldKey
- Hide
- Required
- Type (checkbox, date, date time, decimal, number, picklist(FUTURE), and text)
*/
// for (int i = 0; i < v.Count; i++) // for (int i = 0; i < v.Count; i++)
// { // {
// var filterItem = v[i]; // var filterItem = v[i];