diff --git a/devdocs/todo.txt b/devdocs/todo.txt
index 068e3b08..b86f63f3 100644
--- a/devdocs/todo.txt
+++ b/devdocs/todo.txt
@@ -17,9 +17,9 @@ todo: Search get search result for workorder descendents doesn't fit into existi
In Client, navigating to exact item e.g. a workorder item part is a client ui issue really
The only issue related to the server is getting the top most parent openable object, the workorder in this case
the rest can be done at the client easily
- Add route: ancestor(ayatype, ayaid) returns type and id, if no higher ancestor returns what came in
+ Add Search controller route: ancestor(ayatype, ayaid) returns type and id, if no higher ancestor returns what came in
this needs to be a central route, not tied to an object though objects can handle the inner workings maybe i.e. wokorderbiz for workorder tree , pobiz for po tree etc
-
+
todo: search tables in schema, I think there is a missing index here, need to look at the search query section again as it was changed several times from the original schema creation
todo: schema, move all initializing stuff to schema update 1
@@ -45,7 +45,8 @@ todo: REMOVE TAGS
route: mass remove specified tag by type and id collection
route: mass remove tag by type and all objects no id specified
-
+todo: API root controller
+ build mode and server info should be authorized shoudln't they? Unauthorized people have no need to see that stuff
todo: api / server landing page is shitty on a mobile
and really just shitty, add a logo or some shit
todo: Should server show uptime somewhere?
diff --git a/server/AyaNova/Controllers/SearchController.cs b/server/AyaNova/Controllers/SearchController.cs
index dd80816e..dbe6c960 100644
--- a/server/AyaNova/Controllers/SearchController.cs
+++ b/server/AyaNova/Controllers/SearchController.cs
@@ -99,6 +99,40 @@ namespace AyaNova.Api.Controllers
return Ok(ApiOkResponse.Response(res, true));
}
+
+
+ ///
+ /// Get the top level ancestor of provided type and id
+ /// (e.g. find the WorkOrder principle for a WorkOrderItemPart object descendent)
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// A search result excerpt of object
+ [HttpGet("ancestor/{ayaType}/{id}")]
+ public async Task GetAncestor([FromRoute] AyaType ayaType, [FromRoute] long id, [FromQuery] string phrase, [FromQuery] int max = 80)
+ {
+ if (serverState.IsClosed)
+ return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
+
+ if (!Authorized.HasReadFullRole(HttpContext.Items, ayaType))
+ return StatusCode(403, new ApiNotAuthorizedResponse());
+
+ if (!ModelState.IsValid)
+ return BadRequest(new ApiErrorResponse(ModelState));
+ if (id == 0)
+ return NotFound();
+
+//pawn this off to biz object static methods as appropriate
+//if not in this list of types then it has no ancestor so just return the same values back
+//or, maybe just fail code so people don't think they should run every object through here when they want to open it foolishly / needlessly / ignorantely
+
+ // var res = await Search.GetInfoAsync(ct, UserTranslationIdFromContext.Id(HttpContext.Items),
+ // UserRolesFromContext.Roles(HttpContext.Items), UserIdFromContext.Id(HttpContext.Items), phrase, max, ayaType, id);
+
+ return Ok(ApiOkResponse.Response(res, true));
+ }
//------------