| | | 1 | | using Microsoft.AspNetCore.Components; |
| | | 2 | | using Pomodoro.Web.Models; |
| | | 3 | | using Pomodoro.Web.Services.Formatters; |
| | | 4 | | |
| | | 5 | | namespace Pomodoro.Web.Components.History; |
| | | 6 | | |
| | | 7 | | /// <summary> |
| | | 8 | | /// Code-behind for ActivityItem component |
| | | 9 | | /// Displays a single activity record |
| | | 10 | | /// </summary> |
| | | 11 | | public class ActivityItemBase : ComponentBase |
| | | 12 | | { |
| | | 13 | | [Inject] |
| | 743 | 14 | | private ActivityItemFormatter Formatter { get; set; } = null!; |
| | | 15 | | |
| | | 16 | | #region Parameters |
| | | 17 | | |
| | | 18 | | [Parameter] |
| | 2721 | 19 | | public ActivityRecord Activity { get; set; } = default!; |
| | | 20 | | |
| | | 21 | | #endregion |
| | | 22 | | |
| | | 23 | | #region Methods for Testing |
| | | 24 | | |
| | | 25 | | /// <summary> |
| | | 26 | | /// Checks if the activity is valid |
| | | 27 | | /// </summary> |
| | | 28 | | public bool IsValidActivity() |
| | 2 | 29 | | { |
| | 2 | 30 | | return Formatter.IsValidActivity(Activity); |
| | 2 | 31 | | } |
| | | 32 | | |
| | | 33 | | /// <summary> |
| | | 34 | | /// Gets the formatted time for display |
| | | 35 | | /// </summary> |
| | | 36 | | public string GetFormattedTime() |
| | 1 | 37 | | { |
| | 1 | 38 | | return Formatter.GetFormattedTime(Activity); |
| | 1 | 39 | | } |
| | | 40 | | |
| | | 41 | | /// <summary> |
| | | 42 | | /// Gets the formatted duration for display |
| | | 43 | | /// </summary> |
| | | 44 | | public string GetFormattedDuration() |
| | 1 | 45 | | { |
| | 1 | 46 | | return Formatter.GetFormattedDuration(Activity); |
| | 1 | 47 | | } |
| | | 48 | | |
| | | 49 | | /// <summary> |
| | | 50 | | /// Gets the session type display name |
| | | 51 | | /// </summary> |
| | | 52 | | public string GetSessionTypeDisplay() |
| | 1 | 53 | | { |
| | 1 | 54 | | return Formatter.GetSessionTypeDisplay(Activity); |
| | 1 | 55 | | } |
| | | 56 | | |
| | | 57 | | /// <summary> |
| | | 58 | | /// Checks if the activity has an associated task |
| | | 59 | | /// </summary> |
| | | 60 | | public bool HasTask() |
| | 2 | 61 | | { |
| | 2 | 62 | | return Formatter.HasTask(Activity); |
| | 2 | 63 | | } |
| | | 64 | | |
| | | 65 | | /// <summary> |
| | | 66 | | /// Gets the task name or default value |
| | | 67 | | /// </summary> |
| | | 68 | | public string GetTaskName() |
| | 2 | 69 | | { |
| | 2 | 70 | | return Formatter.GetTaskName(Activity); |
| | 2 | 71 | | } |
| | | 72 | | |
| | | 73 | | #endregion |
| | | 74 | | } |