wip
This commit is contained in:
parent
e6e0c2b326
commit
bd4a7ac080
9 changed files with 161 additions and 72 deletions
|
@ -23,14 +23,16 @@
|
|||
<div class="alert bg-light border-dark">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<h2 class="workDate">@(DateTime.Parse(_workDate).ToLongDateString())</h2>
|
||||
<h2 style="font-variant: all-small-caps">@(DateTime.Now.ToLongDateString())</h2>
|
||||
</div>
|
||||
<div class="col">
|
||||
<WorkDateComponent OnChanged="GetTaskItems"></WorkDateComponent>
|
||||
<WorkDateComponent SelectedDate="@_today" OnChanged="GetTaskItems"></WorkDateComponent>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<TaskItemTableComponent TaskItemList="_taskItems" OnDelete="OnDeleteConfirmed" OnDone="OnDoneClicked"></TaskItemTableComponent>
|
||||
<TaskItemTableComponent TaskItemList="_taskItems" OnCompleteTask="OnCompleteTask"
|
||||
OnDeleteTask="OnDeleteConfirmed" OnTaskCompleted="OnTaskCompleted" />
|
||||
|
||||
</AuthorizeView>
|
||||
<AuthorizeView Roles="Admin">
|
||||
<h2>Administrator</h2>
|
||||
|
|
|
@ -36,6 +36,7 @@ public partial class Home : IDisposable
|
|||
[Inject] private HttpInterceptorService _interceptor { get; set; }
|
||||
[Inject] private IToastService _toast { get; set; }
|
||||
[Inject] private ITaskItemHttpRepository _taskItemRepo { get; set; }
|
||||
[Inject] private NavigationManager _navigator { get; set; }
|
||||
|
||||
private readonly JsonSerializerOptions _options = new JsonSerializerOptions
|
||||
{
|
||||
|
@ -45,6 +46,7 @@ public partial class Home : IDisposable
|
|||
|
||||
private Preferences _prefs { get; set; } = new();
|
||||
private string _workDate { get; set; } = $"{DateTime.Now:yyyy-MM-dd}";
|
||||
private string _today { get; set; } = $"{DateTime.Now:yyyy-MM-dd}";
|
||||
private List<TaskItemDto>? _taskItems { get; set; } = new();
|
||||
|
||||
|
||||
|
@ -57,28 +59,45 @@ public partial class Home : IDisposable
|
|||
_interceptor.RegisterEvent();
|
||||
_interceptor.RegisterBeforeSendEvent();
|
||||
|
||||
await GetTaskItems(_workDate);
|
||||
//await GetTaskItems(_workDate);
|
||||
await GetAllTasks();
|
||||
}
|
||||
|
||||
private async Task GetAllTasks()
|
||||
{
|
||||
_taskItems = await _taskItemRepo.GetTaskList();
|
||||
}
|
||||
|
||||
private async Task OnCompleteTask(string taskItemId)
|
||||
{
|
||||
await _preferenceService.SetWorkDate(DateTime.Now);
|
||||
var item = _taskItems.Find(x => x.TaskItemId == taskItemId);
|
||||
_navigator.NavigateTo($"/companies/{item.ReferenceId}/activities/new");
|
||||
|
||||
}
|
||||
|
||||
private async Task GetTaskItems(string workDate)
|
||||
{
|
||||
_workDate = workDate;
|
||||
_taskItems = new List<TaskItemDto>();
|
||||
_taskItems = await _taskItemRepo.GetTaskList(workDate);
|
||||
}
|
||||
|
||||
private async Task OnDoneClicked(string taskItemId)
|
||||
private async Task OnTaskCompleted(string taskItemId)
|
||||
{
|
||||
// var item = _taskItems.Find(x => x.TaskItemId == taskItemId);
|
||||
// item.IsCompleted = true;
|
||||
|
||||
_logger.LogDebug("MarkAsDone TaskItemId => {}", taskItemId);
|
||||
//await _taskItemRepo.UpdateTaskItem(taskItemId, item);
|
||||
var item = _taskItems.Find(x => x.TaskItemId == taskItemId);
|
||||
item.IsCompleted = true;
|
||||
await _taskItemRepo.UpdateTaskItem(taskItemId, item);
|
||||
_taskItems.Remove(item);
|
||||
_toast.ShowInfo("Opgaven er markeret som udført.");
|
||||
}
|
||||
|
||||
private async Task OnDeleteConfirmed(string taskItemId)
|
||||
{
|
||||
_logger.LogDebug("Delete TaskItemId => {}", taskItemId);
|
||||
//await _taskItemRepo.DeleteTaskItem(taskItemId);
|
||||
var item = _taskItems.First(x => x.TaskItemId == taskItemId);
|
||||
_taskItems.Remove(item);
|
||||
await _taskItemRepo.DeleteTaskItem(taskItemId);
|
||||
_toast.ShowInfo("Opgaven er slettet.");
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
|
|
@ -15,13 +15,14 @@
|
|||
//
|
||||
*@
|
||||
|
||||
@if (TaskItemList != null)
|
||||
@using Wonky.Client.Shared
|
||||
@if (TaskItemList.Any())
|
||||
{
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col"></th>
|
||||
<th scope="col"></th>
|
||||
<th scope="col">Navn</th>
|
||||
<th scope="col">Dato</th>
|
||||
<th scope="col"></th>
|
||||
<th scope="col"></th>
|
||||
<th scope="col"></th>
|
||||
|
@ -30,16 +31,44 @@
|
|||
<tbody>
|
||||
@foreach (var task in TaskItemList)
|
||||
{
|
||||
|
||||
<tr @onclick="() => ModifyTaskItem(task.TaskItemId)">
|
||||
<td class="align-middle">@task.Description</td>
|
||||
<tr>
|
||||
<td class="align-middle">@task.Name</td>
|
||||
<td class="align-middle">@task.DueTimestamp</td>
|
||||
<td class="align-middle"><button type="button" class="btn btn-primary" @onclick="() => ShowConfirmationModal(task.TaskItemId)">Slet</button></td>
|
||||
<td class="align-middle"><button type="button" class="btn btn-danger" @onclick="() => TaskItemDone(task.TaskItemId)">Udført</button></td>
|
||||
<td class="align-middle">
|
||||
<label class="px-1 py-1 position-relative">
|
||||
@task.DueTimestamp.Split("T")[0]
|
||||
@if (task.OverDue)
|
||||
{
|
||||
<span class="position-absolute top-0 start-100 translate-middle p-2 bg-danger border border-light rounded-circle">
|
||||
<span class="visually-hidden">Forfalden opgave</span>
|
||||
</span>
|
||||
}
|
||||
</label>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<button type="button" class="btn btn-light border-dark" @onclick="() => CallConfirmationModal(task.TaskItemId)">
|
||||
Slet
|
||||
</button>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<button type="button" class="btn btn-light border-dark position-relative" @onclick="() => TaskCompleted(task.TaskItemId)">
|
||||
Færdiggør
|
||||
</button>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
@if (task.TaskTypeEnum is "Recall" or "Revision")
|
||||
{
|
||||
<button type="button" class="btn btn-primary position-relative" @onclick="() => CompleteTask(task.TaskItemId)">
|
||||
Besøg
|
||||
</button>
|
||||
}
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
<Confirmation BodyMessage="Handlingen kan ikke gøres om. Vil du slette opgaven?" OnOkClicked="DeleteTask" @ref="_confirmation"/>
|
||||
}
|
||||
else
|
||||
{
|
||||
<AppSpinner></AppSpinner>
|
||||
}
|
|
@ -25,33 +25,49 @@ namespace Wonky.Client.Components
|
|||
{
|
||||
public partial class TaskItemTableComponent
|
||||
{
|
||||
[Parameter] public List<TaskItemDto>? TaskItemList { get; set; }
|
||||
[Parameter] public EventCallback<string> OnDelete { get; set; }
|
||||
[Parameter] public EventCallback<string> OnDone { get; set; }
|
||||
[Inject] private NavigationManager _navigator { get; set; }
|
||||
|
||||
private Confirmation _confirmation = new ();
|
||||
private string _taskItemId = "";
|
||||
[Parameter] public List<TaskItemDto>? TaskItemList { get; set; } = new();
|
||||
[Parameter] public EventCallback<string> OnDeleteTask { get; set; }
|
||||
[Parameter] public EventCallback<string> OnCompleteTask { get; set; }
|
||||
[Parameter] public EventCallback<string> OnTaskCompleted { get; set; }
|
||||
|
||||
private void ShowConfirmationModal(string taskItemId)
|
||||
private Confirmation _confirmation = new ();
|
||||
private string _taskItemIdToDelete = "";
|
||||
|
||||
/// <summary>
|
||||
/// Complete task callback
|
||||
/// </summary>
|
||||
/// <param name="taskItemId"></param>
|
||||
private async Task CompleteTask(string taskItemId)
|
||||
{
|
||||
_taskItemId = taskItemId;
|
||||
await OnCompleteTask.InvokeAsync(taskItemId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Task completed callback
|
||||
/// </summary>
|
||||
/// <param name="taskItemId"></param>
|
||||
private async Task TaskCompleted(string taskItemId)
|
||||
{
|
||||
await OnTaskCompleted.InvokeAsync(taskItemId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Confirm delete
|
||||
/// </summary>
|
||||
/// <param name="taskItemId"></param>
|
||||
private void CallConfirmationModal(string taskItemId)
|
||||
{
|
||||
_taskItemIdToDelete = taskItemId;
|
||||
_confirmation.Show();
|
||||
}
|
||||
|
||||
private void ModifyTaskItem(string taskItemId)
|
||||
{
|
||||
_navigator.NavigateTo($"/task-items/{taskItemId}");
|
||||
}
|
||||
|
||||
private async Task TaskItemDone(string taskItemId)
|
||||
{
|
||||
await OnDone.InvokeAsync(_taskItemId);
|
||||
}
|
||||
private async Task DeleteConfirmed(string taskItemId)
|
||||
|
||||
/// <summary>
|
||||
/// Delete task call back
|
||||
/// </summary>
|
||||
private async Task DeleteTask()
|
||||
{
|
||||
_confirmation.Hide();
|
||||
await OnDelete.InvokeAsync(_taskItemId);
|
||||
await OnDeleteTask.InvokeAsync(_taskItemIdToDelete);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
</InputSelect>
|
||||
<ValidationMessage For="@(() => _draft.ActivityTypeEnum)"></ValidationMessage>
|
||||
</div>
|
||||
|
||||
|
||||
<label for="statusType" class="col-md-2 col-form-label">Status</label>
|
||||
<div class="col-md-4">
|
||||
<InputSelect id="statusType" class="form-select" @bind-Value="@_draft.ActivityStatusEnum">
|
||||
|
@ -62,28 +62,28 @@
|
|||
<ValidationMessage For="@(() => _draft.ActivityStatusEnum)"></ValidationMessage>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="row mb-1">
|
||||
<label for="demo" class="col-md-2 col-form-label">Demo</label>
|
||||
<div class="col-md-4">
|
||||
<InputText id="demo" class="form-control" @bind-Value="_draft.Demo"/>
|
||||
<ValidationMessage For="@(() => _draft.Demo)"></ValidationMessage>
|
||||
</div>
|
||||
|
||||
|
||||
<label for="email" class="col-md-2 col-form-label">Epost</label>
|
||||
<div class="col-md-4">
|
||||
<InputText id="email" class="form-control" @bind-Value="_draft.Email"/>
|
||||
<ValidationMessage For="@(() => _draft.Email)"></ValidationMessage>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="row mb-1">
|
||||
<label for="referenceNumber" class="col-md-2 col-form-label">Rekvisition</label>
|
||||
<div class="col-md-4">
|
||||
<InputText id="referenceNumber" class="form-control" @bind-Value="_draft.ReferenceNumber"/>
|
||||
<ValidationMessage For="@(() => _draft.ReferenceNumber)"></ValidationMessage>
|
||||
</div>
|
||||
|
||||
|
||||
<label for="yourRef" class="col-md-2 col-form-label">Indkøber</label>
|
||||
<div class="col-md-4">
|
||||
<InputText id="yourRef" class="form-control" @bind-Value="_draft.YourRef"/>
|
||||
|
@ -97,14 +97,14 @@
|
|||
<InputTextArea id="orderMessage" class="form-control" @bind-Value="_draft.OrderMessage"/>
|
||||
<ValidationMessage For="@(() => _draft.OrderMessage)"></ValidationMessage>
|
||||
</div>
|
||||
|
||||
|
||||
<label for="crmNote" class="col-md-2 col-form-label">Note /Selv</label>
|
||||
<div class="col-md-4">
|
||||
<InputTextArea id="crmNote" class="form-control" @bind-Value="_draft.CrmNote"/>
|
||||
<ValidationMessage For="@(() => _draft.CrmNote)"></ValidationMessage>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="row mb-1">
|
||||
<label for="attention" class="col-md-2 col-form-label">Att.</label>
|
||||
<div class="col-md-4">
|
||||
|
@ -118,7 +118,7 @@
|
|||
<ValidationMessage For="@(() => _draft.Phone)"></ValidationMessage>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<div class="accordion" id="crmActivity">
|
||||
@* Order lines *@
|
||||
|
|
|
@ -15,10 +15,19 @@
|
|||
//
|
||||
*@
|
||||
|
||||
@page "/taskitems/view"
|
||||
@page "/task-items/{TaskItemId}"
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h3>Task Item</h3>
|
||||
<h3>Opgave</h3>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<EditForm EditContext="_editContext">
|
||||
<DataAnnotationsValidator/>
|
||||
|
||||
</EditForm>
|
||||
</div>
|
||||
<div class="card-footer">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -14,19 +14,34 @@
|
|||
//
|
||||
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.AspNetCore.Components.Forms;
|
||||
using Wonky.Client.HttpInterceptors;
|
||||
using Wonky.Client.HttpRepository;
|
||||
using Wonky.Entity.DTO;
|
||||
|
||||
namespace Wonky.Client.Pages;
|
||||
|
||||
public partial class TaskItemViewPage : IDisposable
|
||||
{
|
||||
[Inject] private HttpInterceptorService _interceptor { get; set; }
|
||||
[Parameter] public string TaskItemId { get; set; }
|
||||
[Inject] private HttpInterceptorService _interceptor { get; set; }
|
||||
[Inject] private ITaskItemHttpRepository _taskItemRepo { get; set; }
|
||||
private TaskItemDto? _taskItem = new ();
|
||||
private EditContext _editContext { get; set; }
|
||||
|
||||
|
||||
protected override Task OnParametersSetAsync()
|
||||
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
return base.OnParametersSetAsync();
|
||||
_interceptor.RegisterEvent();
|
||||
_interceptor.RegisterBeforeSendEvent();
|
||||
|
||||
_taskItem = await _taskItemRepo.GetTaskItem(TaskItemId);
|
||||
}
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
_editContext = new EditContext(_taskItem);
|
||||
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
|
|
@ -16,20 +16,19 @@
|
|||
*@
|
||||
|
||||
<div class="modal" tabindex="-1" role="dialog" style="display:@_modalDisplay">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<h5 class="modal-header">Bekræft venligst</h5>
|
||||
<button type="button" class="close" @onclick="Hide" aria-label="Luk"></button>
|
||||
<span aria-hidden="true">×</span>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>@BodyMessage</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-success" data-dismiss="modal"
|
||||
@onclick="() => OnOkClicked.InvokeAsync()">OK</button>
|
||||
<button type="button" class="btn btn-danger" data-dismiss="modal"
|
||||
@onclick="Hide">Afbryd</button>
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Er du sikker?</h5>
|
||||
<button type="button" class="btn-close" @onclick="Hide" data-bs-dismiss="modal" aria-label="Luk"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>@BodyMessage</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal" @onclick="Hide">Afbryd</button>
|
||||
<button type="button" class="btn btn-primary" data-bs-dismiss="modal" @onclick="() => OnOkClicked.InvokeAsync()">OK</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
{
|
||||
"appInfo": {
|
||||
"name": "Wonky Client",
|
||||
"version": "0.8.153",
|
||||
"isBeta": false,
|
||||
"version": "0.9.13",
|
||||
"isBeta": true,
|
||||
"sandBox": false,
|
||||
"image": "grumpy-coder.png"
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue