diff --git a/devdocs/todo.txt b/devdocs/todo.txt index 163f661b..472b235c 100644 --- a/devdocs/todo.txt +++ b/devdocs/todo.txt @@ -5,12 +5,14 @@ Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOiIxNTQ0NTU5NzAwIiwiZXhwIjoi ## IMMEDIATE ITEMS - + Item below half done: widget picklist is done, might need test cleanup for that, user picklist needs to have code copied Widget and user picklist, modify to use filter and sort criteria, remove the startswith built in filter - Fix up the old tests for picklists and replace with new test using filter ID - Don't forget to test with no filter ID to ensure still works as normal (default picklist should sort by alpha, need extra default method for sql query) + GetMany - have a look at the widget getmany code and the get picklist utility helper and see if there is a possibility of moving the getmany code into a helper similarly to picklist + ENUM - Need route to get enum values and lt by providing a lowercase name of the enum (used for building filter UI for enum types) - Client needs to pick enum value adn display localized @@ -110,6 +112,7 @@ TODO SERVER STUFF - Maybe a reference count for each tag to drive a tag cloud feature and also a order by commonality feature when offering and also to know when to remove the tag repository when no one is using that tag anymore in any records - Boot server and seed with debug log turned on, see what is being tracked by EF that doesn't need to, seems some of that shit is being tracked. + - Docs: pagingOptions, sort and filter need to be documented for API ----------------- diff --git a/server/AyaNova/Controllers/WidgetController.cs b/server/AyaNova/Controllers/WidgetController.cs index 30f84b19..31eb73a7 100644 --- a/server/AyaNova/Controllers/WidgetController.cs +++ b/server/AyaNova/Controllers/WidgetController.cs @@ -133,52 +133,16 @@ namespace AyaNova.Api.Controllers - // /// - // /// Get widget pick list - // /// - // /// Required roles: Any - // /// - // /// This list supports querying the Name property - // /// include a "q" parameter for string to search for - // /// use % for wildcards. - // /// - // /// e.g. q=%Jones% - // /// - // /// Query is case insensitive - // /// - // /// Paged id/name collection of widgets with paging data - // [HttpGet("PickList", Name = nameof(WidgetPickList))] - // public async Task WidgetPickList([FromQuery] string q, [FromQuery] PagingOptions pagingOptions) - // { - // 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 - // WidgetBiz biz = WidgetBiz.GetBiz(ct, HttpContext); - - // ApiPagedResponse pr = await biz.GetPickListAsync(Url, nameof(WidgetPickList), pagingOptions, q); - // return Ok(new ApiOkWithPagingResponse(pr)); - // } - - /// - /// Get widget pick list + /// + /// Get widget pick list /// /// Required roles: Any /// - /// This list supports querying the Name property - /// include a "q" parameter for string to search for - /// use % for wildcards. - /// - /// e.g. q=%Jones% - /// - /// Query is case insensitive /// - /// Paged id/name collection of widgets with paging data + /// Paging, filtering and sorting options + /// Paged id/name collection of widgets with paging data [HttpGet("PickList", Name = nameof(WidgetPickList))] - public async Task WidgetPickList([FromQuery] PagingOptions pagingOptions) + public ActionResult WidgetPickList([FromQuery] PagingOptions pagingOptions) { if (serverState.IsClosed) return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason)); @@ -189,10 +153,10 @@ namespace AyaNova.Api.Controllers //Instantiate the business object handler WidgetBiz biz = WidgetBiz.GetBiz(ct, HttpContext); - ApiPagedResponse pr = await biz.GetPickListAsync(Url, nameof(WidgetPickList), pagingOptions); + ApiPagedResponse pr = biz.GetPickList(Url, nameof(WidgetPickList), pagingOptions); return Ok(new ApiOkWithPagingResponse(pr)); } - + /// /// Put (update) widget diff --git a/server/AyaNova/biz/WidgetBiz.cs b/server/AyaNova/biz/WidgetBiz.cs index 107b4173..8c90e45a 100644 --- a/server/AyaNova/biz/WidgetBiz.cs +++ b/server/AyaNova/biz/WidgetBiz.cs @@ -214,82 +214,11 @@ namespace AyaNova.Biz //get picklist (paged) - internal async Task> GetPickListAsync(IUrlHelper Url, string routeName, PagingOptions pagingOptions) + internal ApiPagedResponse GetPickList(IUrlHelper Url, string routeName, PagingOptions pagingOptions) { pagingOptions.Offset = pagingOptions.Offset ?? PagingOptions.DefaultOffset; pagingOptions.Limit = pagingOptions.Limit ?? PagingOptions.DefaultLimit; - // NameIdItem[] items; - // int totalRecordCount = 0; - - // //BUILD THE QUERY - // //base query - // var q = "SELECT id, name FROM AWIDGET "; - - // //GET THE FILTER / SORT - // if (pagingOptions.DataFilterId > 0) - // { - // var TheFilter = await ct.DataFilter.FirstOrDefaultAsync(x => x.Id == pagingOptions.DataFilterId); - - // //BUILD WHERE AND APPEND IT - // q = q + FilterSqlCriteriaBuilder.DataFilterToSQLCriteria(TheFilter, WidgetBiz.FilterOptions(), UserId); - - // //BUILD ORDER BY AND APPEND IT - // q = q + FilterSqlOrderByBuilder.DataFilterToSQLOrderBy(TheFilter); - // } - // else - // { - // //GET DEFAULT ORDER BY - // q = q + FilterSqlOrderByBuilder.DefaultOrderBy(); - // } - - - // #pragma warning disable EF1000 - - // var items = await ct.Widget - // .AsNoTracking() - // .FromSql(q) - // .Skip(pagingOptions.Offset.Value) - // .Take(pagingOptions.Limit.Value) - // .ToArrayAsync(); - - // var totalRecordCount = await ct.Widget - // .AsNoTracking() - // .FromSql(q) - // .CountAsync(); - // #pragma warning restore EF1000 - - // if (!string.IsNullOrWhiteSpace(q)) - // { - // items = await ct.Widget - // .AsNoTracking() - // .Where(m => EF.Functions.ILike(m.Name, q)) - // .OrderBy(m => m.Name) - // .Skip(pagingOptions.Offset.Value) - // .Take(pagingOptions.Limit.Value) - // .Select(m => new NameIdItem() - // { - // Id = m.Id, - // Name = m.Name - // }).ToArrayAsync(); - - // totalRecordCount = await ct.Widget.Where(m => EF.Functions.ILike(m.Name, q)).CountAsync(); - // } - // else - // { - // items = await ct.Widget - // .AsNoTracking() - // .OrderBy(m => m.Name) - // .Skip(pagingOptions.Offset.Value) - // .Take(pagingOptions.Limit.Value) - // .Select(m => new NameIdItem() - // { - // Id = m.Id, - // Name = m.Name - // }).ToArrayAsync(); - - // totalRecordCount = await ct.Widget.CountAsync(); - // } var ret = PickListFetcher.GetPickList(ct, UserId, pagingOptions, "awidget");