Skip to content

Commit

Permalink
Merge pull request #596 from SSWConsulting/561-new_fields_on_calendar…
Browse files Browse the repository at this point in the history
…_card

Add end date field
  • Loading branch information
jimmidier authored Aug 2, 2023
2 parents 2b907f5 + b0b5ab5 commit 8b43155
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 56 deletions.
45 changes: 0 additions & 45 deletions .github/workflows/SSW.SophieBot.test.yml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using SSW.SophieBot.HttpClientComponents.PersonQuery.Models;
using System;
using System.Linq;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;
Expand Down Expand Up @@ -68,16 +69,7 @@ private EmployeeProfileWithStatusModel ConvertToProfile(GetEmployeeModel employe
LastName = employee.LastName,
BillableRate = employee.BillableRate,
BookedDays = EmployeesHelper.GetBookedDays(employee, date),
Appointments = EmployeesHelper.GetAppointments(employee.NormalizedAppointments, date, 10)
.Select(a => new EmployeeProfileAppointment
{
Start = a.Start.DateTime.ToUserFriendlyDate(date),
Duration = (a.End - a.Start).ToUserFriendlyDuration(),
BookingStatus = EmployeesHelper.GetBookingStatus(a),
Subject = a.Subject.Trim(),
Regarding = a.Regarding.Trim()
})
.ToList()
Appointments = GetDisplayAppointments(EmployeesHelper.GetAppointments(employee.NormalizedAppointments, date, 10), date)
};

if (profile.BookingStatus == BookingStatus.Leave)
Expand All @@ -99,5 +91,40 @@ private EmployeeProfileWithStatusModel ConvertToProfile(GetEmployeeModel employe

return profile;
}

private List<EmployeeProfileAppointment> GetDisplayAppointments(IEnumerable<GetAppointmentModel> sourceAppointments, DateTime date)
{
var result = new List<EmployeeProfileAppointment>();
var appointment = new EmployeeProfileAppointment();
if (!sourceAppointments.Any())
{
return result;
}

foreach (var sourceAppointment in sourceAppointments.OrderBy(sa => sa.Start.DateTime))
{
if (appointment.Subject != sourceAppointment.Subject)
{
appointment = new EmployeeProfileAppointment
{
Start = sourceAppointment.Start.DateTime.ToUserFriendlyDate(date),
End = sourceAppointment.End.DateTime.ToUserFriendlyDate(date),
Duration = (sourceAppointment.End - sourceAppointment.Start).ToUserFriendlyDuration(),
BookingStatus = EmployeesHelper.GetBookingStatus(sourceAppointment),
Subject = sourceAppointment.Subject.Trim(),
Regarding = sourceAppointment.Regarding.Trim()
};

result.Add(appointment);
}
else
{
appointment.End = sourceAppointment.End.DateTime.ToUserFriendlyDate(date);
appointment.Duration = (sourceAppointment.End - sourceAppointment.Start).ToUserFriendlyDuration();
}
}

return result;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ public class EmployeeProfileAppointment
{
[JsonProperty("start")]
public string Start { get; set; }

[JsonProperty("end")]
public string End { get; set; }

[JsonProperty("duration")]
public string Duration { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,20 @@
"items": [
{
"type": "TextBlock",
"text": "Date",
"text": "Start",
"wrap": true,
"weight": "Bolder"
}
],
"verticalContentAlignment": "Center"
},
{
"type": "Column",
"width": "stretch",
"items": [
{
"type": "TextBlock",
"text": "End",
"wrap": true,
"weight": "Bolder"
}
Expand Down Expand Up @@ -128,6 +141,19 @@
],
"verticalContentAlignment": "Center"
},
{
"type": "Column",
"width": "stretch",
"items": [
{
"type": "TextBlock",
"text": "${appointment.end}",
"wrap": true,
"size": "${ContentTextSize()}"
}
],
"verticalContentAlignment": "Center"
},
{
"type": "Column",
"width": "stretch",
Expand Down

0 comments on commit 8b43155

Please sign in to comment.