From 58240ad03ec10bf42b128f00048f55b6a69d363d Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Wed, 23 Feb 2022 18:42:25 +0000 Subject: [PATCH] --- .../AyaNova/Controllers/ScheduleController.cs | 33 +++++++++++++++++-- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/server/AyaNova/Controllers/ScheduleController.cs b/server/AyaNova/Controllers/ScheduleController.cs index 037a1e3c..505f4f02 100644 --- a/server/AyaNova/Controllers/ScheduleController.cs +++ b/server/AyaNova/Controllers/ScheduleController.cs @@ -12,6 +12,7 @@ using System.Linq; using System.Collections.Generic; using AyaNova.Util; using System.ComponentModel.DataAnnotations; +using Newtonsoft.Json.Linq; namespace AyaNova.Api.Controllers { @@ -132,12 +133,14 @@ namespace AyaNova.Api.Controllers } + //############################################################### //USER - svc-schedule-user //############################################################### /// /// Get User schedule for parameters specified + /// This is called when drilling down into specific user from service schedule form and is not the personal schedule /// time zone UTC offset in minutes is required to be passed in /// timestamps returned are in Unix Epoch milliseconds converted for local time display /// @@ -154,6 +157,11 @@ namespace AyaNova.Api.Controllers List r = new List(); + //user options color source should never be empty here but just in case + if (p.WisuColorSource == null) + { + p.WisuColorSource = ScheduleWorkOrderColorSource.WorkOrderStatus; + } //Note: query will return records that fall within viewed range even if they start or end outside of it @@ -207,6 +215,26 @@ namespace AyaNova.Api.Controllers List r = new List(); + + //user options will be empty here if route called from dashboard so fetch here + if (p.Wisu && p.WisuColorSource == null) + { + //default if not set yet + p.WisuColorSource = ScheduleWorkOrderColorSource.WorkOrderStatus; + + //not provided so fetch it here at the server + //this is a stupid work around due to close to release date and not wanting to change front end areas but to support dashboard widgets to lower amount of fetches + FormUserOptionsBiz uoptbiz = FormUserOptionsBiz.GetBiz(ct, HttpContext); + var o = await uoptbiz.GetAsync("home-schedule"); + if (o != null) + { + JObject formData = JObject.Parse(o.Options); + p.WisuColorSource = formData["wisuColorSource"].ToObject(); + } + } + + + var UserId = UserIdFromContext.Id(HttpContext.Items); var UType = UserTypeFromContext.Type(HttpContext.Items); @@ -353,7 +381,7 @@ namespace AyaNova.Api.Controllers var s = new PersonalScheduleListItem(); s.Id = v.WoItemSchedUserId; - s.Color = ColorFromWOItem(v, p.WisuColorSource); + s.Color = ColorFromWOItem(v, (ScheduleWorkOrderColorSource)p.WisuColorSource); s.TextColor = TextColor(s.Color); s.Start = (DateTime)v.StartDate; s.End = (DateTime)v.StopDate; @@ -458,8 +486,7 @@ namespace AyaNova.Api.Controllers public DateTime Start { get; set; } [Required] public DateTime End { get; set; } - [Required] - public ScheduleWorkOrderColorSource WisuColorSource { get; set; } + public ScheduleWorkOrderColorSource? WisuColorSource { get; set; } [Required] public bool Wisu { get; set; } [Required]