Whatthefack

This commit is contained in:
Adam 2024-04-06 12:53:06 +02:00
parent 2c12f1a4c1
commit 0cf8a4d4cc
3 changed files with 74 additions and 135 deletions

View File

@ -26,12 +26,44 @@
<h2 style="font-size:small">Manage transfers here!</h2> <h2 style="font-size:small">Manage transfers here!</h2>
</div> </div>
<DxPopup CssClass="popup-demo-events"
@bind-Visible="@PopupVisible"
ShowFooter="true"
CloseOnEscape="true"
CloseOnOutsideClick="false"
ShowCloseButton="false"
HeaderText="MessageBox"
Closing="EulaPopupClosing"
Closed="EulaPopupClosed">
<BodyContentTemplate>
<InputWizard Data=@messageWizardModel
OnSubmit="SubmitForm"
IgnoreReflection=@ignoreList
TitleResourceString="NewMessage"
SubtitleResourceString="NewMessageSubtitle"
SubmitButtonText="ButtonSend"></InputWizard>
</BodyContentTemplate>
<FooterContentTemplate Context="Context">
<div class="popup-demo-events-footer">
<!--DxCheckBox CssClass="popup-demo-events-checkbox" @bind-Checked="@EulaAccepted">I accept the terms of the EULA</!--DxCheckBox-->
<!--DxButton CssClass="popup-demo-events-button ms-2" RenderStyle="ButtonRenderStyle.Primary" Text="OK" Click="Context.CloseCallback" /-->
<DxButton CssClass="popup-demo-events-button ms-2" RenderStyle="ButtonRenderStyle.Secondary" Text="Cancel" Click="CancelCreateClick" />
</div>
</FooterContentTemplate>
</DxPopup>
<div class="container"> <div class="container">
<div class="row"> <div class="row">
<div class=" col-12"> <div class=" col-12">
<Animation Effect="@Effect.FadeInUp" Class="glass" Speed="@Speed.Fast" Delay="@TimeSpan.FromMilliseconds(250)"> <Animation Effect="@Effect.FadeInUp" Class="glass" Speed="@Speed.Fast" Delay="@TimeSpan.FromMilliseconds(250)">
<div class="card"> <div class="card">
<div class="d-flex flex-column mb-4 pb-2"> <div class="d-flex flex-column mb-4 pb-2">
<div class="align-self-end pl-2 pb-2">
<DxButton Text="Column Chooser"
RenderStyle="ButtonRenderStyle.Secondary"
IconCssClass="btn-column-chooser"
Click="ColumnChooserButton_Click" />
</div>
<DxGrid @ref="Grid2" <DxGrid @ref="Grid2"
Data="TransferData" Data="TransferData"
@ -47,19 +79,30 @@
<Columns> <Columns>
<DxGridCommandColumn Width="8%" FixedPosition="GridColumnFixedPosition.Left" /> <DxGridCommandColumn Width="8%" FixedPosition="GridColumnFixedPosition.Left" />
<DxGridDataColumn FieldName="Id" SortIndex="0" /> <DxGridDataColumn FieldName="Id" SortIndex="0" Visible="false" />
<DxGridDataColumn FieldName="OrderId" /> <DxGridDataColumn FieldName="OrderId" />
<DxGridDataColumn FieldName="FromAddress" /> <DxGridDataColumn FieldName="FromAddress" />
<DxGridDataColumn FieldName="ToAddress" /> <DxGridDataColumn FieldName="ToAddress" />
<DxGridDataColumn FieldName="Appointment" /> <DxGridDataColumn FieldName="Appointment" />
<DxGridDataColumn FieldName="ContactPhone" />
<DxGridDataColumn FieldName="ContactEmail">
<CellDisplayTemplate>
@{
var keyField = context.Value;
var keyItem = (Transfer)context.DataItem;
string buttonText = "Contact";
<DxButton Click="() => SendMail(keyItem)" Text="@buttonText" RenderStyle="ButtonRenderStyle.Primary" />
}
</CellDisplayTemplate>
</DxGridDataColumn>
<DxGridDataColumn FieldName="PassengerCount" /> <DxGridDataColumn FieldName="PassengerCount" />
<DxGridDataColumn FieldName="TransferStatusType"> <DxGridDataColumn FieldName="TransferStatusType">
<CellDisplayTemplate> <CellDisplayTemplate>
@{ @{
TransferStatusModel keyField = Statuses.FirstOrDefault(x => x.StatusValue == Convert.ToInt16(context.Value)); TransferStatusModel keyField = Statuses.FirstOrDefault(x => x.StatusValue == Convert.ToInt16(context.Value));
string driverText = keyField.StatusName; string transferStatusText = keyField.StatusName;
<p>@driverText</p> <p>@transferStatusText</p>
} }
</CellDisplayTemplate> </CellDisplayTemplate>
</DxGridDataColumn> </DxGridDataColumn>
@ -97,120 +140,6 @@
</div> </div>
<div class="d-flex flex-column mb-4 pb-2">
<div class="align-self-end pl-2 pb-2">
<DxButton Text="Column Chooser"
RenderStyle="ButtonRenderStyle.Secondary"
IconCssClass="btn-column-chooser"
Click="ColumnChooserButton_Click" />
</div>
<DxGrid @ref="Grid"
Data="TransferData"
PageSize="8"
KeyFieldName="Id"
ValidationEnabled="false"
CustomizeEditModel="Grid_CustomizeEditModel"
EditModelSaving="Grid_EditModelSaving"
DataItemDeleting="Grid_DataItemDeleting"
EditMode="GridEditMode.EditForm"
ColumnResizeMode="GridColumnResizeMode.NextColumn"
KeyboardNavigationEnabled="true"
ShowFilterRow="true">
<Columns>
<DxGridCommandColumn Width="8%" FixedPosition="GridColumnFixedPosition.Left" />
<DxGridDataColumn FieldName="Id" MinWidth="80" Width="20%" Visible="false" />
<DxGridDataColumn FieldName="ToAddress" FixedPosition="GridColumnFixedPosition.Left" MinWidth="80">
<CellDisplayTemplate>
@{
var keyField = context.Value;
<a class="d-block text-left" href="transferdetails">@context.Value</a>
}
</CellDisplayTemplate>
</DxGridDataColumn>
<DxGridDataColumn FieldName="FromAddress" FixedPosition="GridColumnFixedPosition.Left" MinWidth="80" />
<DxGridDataColumn FieldName="Appointment" MinWidth="80" Width="20%" />
<DxGridDataColumn FieldName="PassengerCount" MinWidth="40" Width="3%" />
@* <DxGridDataColumn FieldName="Drivers" MinWidth="80" /> *@
@*<DxGridDataColumn FieldName="PhoneNumber" MinWidth="80" Width="10%" />
<DxGridDataColumn FieldName="EmailAddress" MinWidth="80" Width="10%">
<CellDisplayTemplate>
@{
var keyField = context.Value;
var keyItem = (TransferWizardModel)context.DataItem;
string buttonText = "Contact";
<DxButton Click="() => SendMail(keyItem)" Text="@buttonText" RenderStyle="ButtonRenderStyle.Primary" />
}
</CellDisplayTemplate>
</DxGridDataColumn>*@
@* <DxGridDataColumn FieldName="Driver" FixedPosition="GridColumnFixedPosition.Right" MinWidth="80" Width="15%">
<CellDisplayTemplate>
@{
DriverModel keyField = (DriverModel)context.Value;
string driverText = keyField.Name;
<p>@driverText</p>
}
</CellDisplayTemplate>
</DxGridDataColumn> *@
</Columns>
<EditFormTemplate Context="EditFormContext">
@{
var transfer = (TransferWizardModel)EditFormContext.EditModel;
}
<DxFormLayout CssClass="w-100">
<DxFormLayoutItem Caption=@localizer.GetString(ResourceKeys.DestinationAddress) ColSpanMd="6">
@EditFormContext.GetEditor("ToAddress")
</DxFormLayoutItem>
<DxFormLayoutItem Caption=@localizer.GetString(ResourceKeys.PickupAddress) ColSpanMd="6">
@EditFormContext.GetEditor("FromAddress")
</DxFormLayoutItem>
<DxFormLayoutItem Caption="Trip date:" ColSpanMd="6">
@EditFormContext.GetEditor("Appointment")
</DxFormLayoutItem>
<DxFormLayoutItem Caption="Passengers:" ColSpanMd="6">
@EditFormContext.GetEditor("PassengerCount")
</DxFormLayoutItem>
@* <DxFormLayoutItem Caption="Full name:" ColSpanMd="6">
@EditFormContext.GetEditor("FullName")
</DxFormLayoutItem>
<DxFormLayoutItem Caption="Phone number:" ColSpanMd="6">
@EditFormContext.GetEditor("PhoneNumber")
</DxFormLayoutItem>
<DxFormLayoutItem Caption="Email:" ColSpanMd="6">
@EditFormContext.GetEditor("EmailAddress")
</DxFormLayoutItem> *@
@*<DxFormLayoutItem Caption="Driver:" ColSpanMd="6">
<DxComboBox Data="@drivers"
NullText="Select driver..."
FilteringMode="DataGridFilteringMode.Contains"
TextFieldName="Name"
ValueFieldName="Name"
Value="@transfer.Driver.Name"
ValueChanged="(string newCellValue) => {
transfer.Driver = drivers.FirstOrDefault(x => x.Name == newCellValue);
logToBrowserConsole.LogToBC(newCellValue);
}">
</DxComboBox>
</DxFormLayoutItem> *@
</DxFormLayout>
</EditFormTemplate>
</DxGrid>
</div>
</div> </div>
</Animation> </Animation>
</div> </div>
@ -224,8 +153,6 @@
@code { @code {
IGrid Grid { get; set; }
//object? TransferData { get; set; }
public TransferWizardModel myModel = new TransferWizardModel(); public TransferWizardModel myModel = new TransferWizardModel();
@ -241,16 +168,16 @@
"ContextId" "ContextId"
}; };
public List<TransferStatusModel> Statuses { get; set; } public List<TransferStatusModel>? Statuses { get; set; }
public MessageWizardModel messageWizardModel = new MessageWizardModel(); public MessageWizardModel messageWizardModel = new MessageWizardModel();
//IEnumerable<DriverModel> drivers { get; set; } //IEnumerable<DriverModel> drivers { get; set; }
void SendMail(TransferWizardModel Item) void SendMail(Transfer Item)
{ {
logToBrowserConsole.LogToBC($"Sending mail to {Item.EmailAddress}"); logToBrowserConsole.LogToBC($"Sending mail to {Item.ContactEmail}");
PopupVisible = true; PopupVisible = true;
} }
@ -291,27 +218,33 @@
{ {
if (e.IsNew) if (e.IsNew)
{ {
var newEmployee = (TransferWizardModel)e.EditModel; var transferEditModel = (Transfer)e.EditModel; //TODO not valid cast
newEmployee.Id = Guid.NewGuid(); transferEditModel.Id = Guid.NewGuid();
newEmployee.Destination = "ghjgkg hkgh ghjkghgkjgh"; transferEditModel.ToAddress = "Where to?";
newEmployee.PickupAddress = "ghjgkg hkgh ghjkghgkjgh"; transferEditModel.FromAddress = "From where?";
newEmployee.TripDate = DateTime.UtcNow.AddDays(3); transferEditModel.Appointment = DateTime.UtcNow.AddDays(3);
newEmployee.NumberOfPassengers = 1; transferEditModel.PassengerCount = 1;
newEmployee.FullName = "ghjgkg hkgh ghjkghgkjgh"; transferEditModel.ContactName = "Full name";
newEmployee.PhoneNumber = "+13021234567"; transferEditModel.ContactPhone = "+00000000000";
newEmployee.EmailAddress = "ghjgkg hkgh ghjkghgkjgh"; transferEditModel.ContactEmail = "your@email.address";
} }
} }
async Task Grid_EditModelSaving(GridEditModelSavingEventArgs e) async Task Grid_EditModelSaving(GridEditModelSavingEventArgs e)
{ {
if (e.IsNew) if (e.IsNew)
{
//add new orderData to orderData array //add new orderData to orderData array
logToBrowserConsole.LogToBC("New orderData added"); logToBrowserConsole.LogToBC("New orderData added");
//await NwindDataService.InsertEmployeeAsync((EditableEmployee)e.EditModel); //await transferDataService.CreateTransfer((TransferWizardModel)e.EditModel);
}
else else
logToBrowserConsole.LogToBC("orderData updated"); {
//modify transferData where transferData.Id == e.EditModel.Id logToBrowserConsole.LogToBC("orderData updated at id " + ((TransferWizardModel)e.EditModel).Id);
//await transferDataService.UpdateTransferAsync((TransferWizardModel)e.EditModel);
//modify transferData where transferData.Id == e.EditModel.Id
}
//get transfer from TransferData by Id //get transfer from TransferData by Id
foreach (var transferToModify in (List<Transfer>)TransferData) foreach (var transferToModify in (List<Transfer>)TransferData)
@ -336,8 +269,8 @@
} }
async Task UpdateDataAsync() async Task UpdateDataAsync()
{ {
//DataSource = await NwindDataService.GetEmployeesEditableAsync();
//refresh grid //refresh grid
//DataSource = await NwindDataService.GetEmployeesEditableAsync();
logToBrowserConsole.LogToBC("orderData grid refreshed"); logToBrowserConsole.LogToBC("orderData grid refreshed");
} }

View File

@ -18,5 +18,6 @@ namespace TIAMWebApp.Shared.Application.Interfaces
Task<Transfer?> GetTransferByIdAsync(Guid id); Task<Transfer?> GetTransferByIdAsync(Guid id);
Task<List<Transfer>> GetTransfersAsync(); Task<List<Transfer>> GetTransfersAsync();
Task<Transfer> UpdateTransferAsync(TransferWizardModel model);
} }
} }

View File

@ -178,5 +178,10 @@ namespace TIAMWebApp.Shared.Application.Services
return new List<Transfer>(); return new List<Transfer>();
return response; return response;
} }
public Task<Transfer> UpdateTransferAsync(TransferWizardModel model)
{
return null;
}
} }
} }