This commit is contained in:
2022-02-23 18:42:25 +00:00
parent c442f1594c
commit 58240ad03e

View File

@@ -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
//###############################################################
/// <summary>
/// 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
/// </summary>
@@ -154,6 +157,11 @@ namespace AyaNova.Api.Controllers
List<PersonalScheduleListItem> r = new List<PersonalScheduleListItem>();
//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<PersonalScheduleListItem> r = new List<PersonalScheduleListItem>();
//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<ScheduleWorkOrderColorSource>();
}
}
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]