Merge pull request #27 from hargata/Hargata/rename.uploadedfiles
Rename Uploaded Files
This commit is contained in:
@@ -45,7 +45,8 @@ namespace CarCareTracker.Controllers
|
||||
UseDarkMode = bool.Parse(_config[nameof(UserConfig.UseDarkMode)]),
|
||||
UseMPG = bool.Parse(_config[nameof(UserConfig.UseMPG)]),
|
||||
UseDescending = bool.Parse(_config[nameof(UserConfig.UseDescending)]),
|
||||
EnableAuth = bool.Parse(_config[nameof(UserConfig.EnableAuth)])
|
||||
EnableAuth = bool.Parse(_config[nameof(UserConfig.EnableAuth)]),
|
||||
HideZero = bool.Parse(_config[nameof(UserConfig.HideZero)])
|
||||
};
|
||||
return PartialView("_Settings", userConfig);
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
public bool UseMPG { get; set; }
|
||||
public bool UseDescending { get; set; }
|
||||
public bool EnableAuth { get; set; }
|
||||
public bool HideZero { get; set; }
|
||||
public string UserNameHash { get; set; }
|
||||
public string UserPasswordHash { get; set;}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,10 @@
|
||||
<input class="form-check-input" onChange="updateSettings()" type="checkbox" role="switch" id="useDescending" checked="@Model.UseDescending">
|
||||
<label class="form-check-label" for="useDescending">Sort lists in Descending Order(Newest to Oldest)</label>
|
||||
</div>
|
||||
<div class="form-check form-switch">
|
||||
<input class="form-check-input" onChange="updateSettings()" type="checkbox" role="switch" id="hideZero" checked="@Model.HideZero">
|
||||
<label class="form-check-label" for="hideZero">Replace @(0.ToString("C")) Costs with ---</label>
|
||||
</div>
|
||||
<div class="form-check form-switch">
|
||||
<input class="form-check-input" onChange="enableAuthCheckChanged()" type="checkbox" role="switch" id="enableAuth" checked="@Model.EnableAuth">
|
||||
<label class="form-check-label" for="enableAuth">Enable Authentication</label>
|
||||
@@ -76,7 +80,8 @@
|
||||
useDarkMode: $("#enableDarkMode").is(':checked'),
|
||||
enableCsvImports: $("#enableCsvImports").is(':checked'),
|
||||
useMPG: $("#useMPG").is(':checked'),
|
||||
useDescending: $("#useDescending").is(':checked')
|
||||
useDescending: $("#useDescending").is(':checked'),
|
||||
hideZero: $("#hideZero").is(":checked")
|
||||
}
|
||||
$.post('/Home/WriteToSettings', { userConfig: userConfigObject}, function(data){
|
||||
if (data) {
|
||||
|
||||
@@ -30,14 +30,7 @@
|
||||
@if (Model.Files.Any())
|
||||
{
|
||||
<div>
|
||||
<label>Uploaded Documents</label>
|
||||
@foreach (UploadedFiles filesUploaded in Model.Files)
|
||||
{
|
||||
<div class="d-flex justify-content-between">
|
||||
<a type="button" class="btn btn-link" href="@filesUploaded.Location" target="_blank">@filesUploaded.Name</a>
|
||||
<button type="button" class="btn btn-sm btn-outline-danger" onclick="deleteCollisionRecordFile('@filesUploaded.Location', this)"><i class="bi bi-trash"></i></button>
|
||||
</div>
|
||||
}
|
||||
@await Html.PartialAsync("_UploadedFiles", Model.Files)
|
||||
<label for="collisionRecordFiles">Upload more documents</label>
|
||||
<input onChange="uploadVehicleFilesAsync(this)" type="file" multiple accept=".png,.jpg,.jpeg,.pdf,.xls,.xlsx,.docx" class="form-control-file" id="collisionRecordFiles">
|
||||
</div>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
@inject IConfiguration Configuration
|
||||
@{
|
||||
var enableCsvImports = bool.Parse(Configuration[nameof(UserConfig.EnableCsvImports)]);
|
||||
var hideZero = bool.Parse(Configuration[nameof(UserConfig.HideZero)]);
|
||||
}
|
||||
@model List<CollisionRecord>
|
||||
<div class="row">
|
||||
@@ -48,7 +49,7 @@
|
||||
<td class="col-1">@collisionRecord.Date.ToShortDateString()</td>
|
||||
<td class="col-2">@collisionRecord.Mileage</td>
|
||||
<td class="col-4">@collisionRecord.Description</td>
|
||||
<td class="col-2">@collisionRecord.Cost.ToString("C")</td>
|
||||
<td class="col-2">@((hideZero && collisionRecord.Cost == default) ? "---" : collisionRecord.Cost.ToString("C"))</td>
|
||||
<td class="col-3 text-truncate">@collisionRecord.Notes</td>
|
||||
</tr>
|
||||
}
|
||||
@@ -58,7 +59,7 @@
|
||||
</div>
|
||||
|
||||
|
||||
<div class="modal fade" id="collisionRecordModal" tabindex="-1" role="dialog" aria-hidden="true">
|
||||
<div class="modal fade" data-bs-focus="false" id="collisionRecordModal" tabindex="-1" role="dialog" aria-hidden="true">
|
||||
<div class="modal-dialog modal-lg" role="document">
|
||||
<div class="modal-content" id="collisionRecordModalContent">
|
||||
</div>
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
@{
|
||||
var enableCsvImports = bool.Parse(Configuration[nameof(UserConfig.EnableCsvImports)]);
|
||||
var useMPG = bool.Parse(Configuration[nameof(UserConfig.UseMPG)]);
|
||||
var hideZero = bool.Parse(Configuration[nameof(UserConfig.HideZero)]);
|
||||
var useKwh = Model.UseKwh;
|
||||
string consumptionUnit;
|
||||
string fuelEconomyUnit;
|
||||
@@ -66,8 +67,8 @@
|
||||
<td class="col-2">@gasRecord.Mileage</td>
|
||||
<td class="col-2">@gasRecord.Gallons.ToString("F")</td>
|
||||
<td class="col-4">@(gasRecord.MilesPerGallon == 0 ? "---" : gasRecord.MilesPerGallon.ToString("F"))</td>
|
||||
<td class="col-1">@gasRecord.Cost.ToString("C3")</td>
|
||||
<td class="col-1">@gasRecord.CostPerGallon.ToString("C3")</td>
|
||||
<td class="col-1">@((hideZero && gasRecord.Cost == default) ? "---" : gasRecord.Cost.ToString("C3"))</td>
|
||||
<td class="col-1">@((hideZero && gasRecord.CostPerGallon == default) ? "---" : gasRecord.CostPerGallon.ToString("C3"))</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
@@ -76,7 +77,7 @@
|
||||
</div>
|
||||
|
||||
|
||||
<div class="modal fade" id="gasRecordModal" tabindex="-1" role="dialog" aria-hidden="true">
|
||||
<div class="modal fade" data-bs-focus="false" id="gasRecordModal" tabindex="-1" role="dialog" aria-hidden="true">
|
||||
<div class="modal-dialog modal-lg" role="document">
|
||||
<div class="modal-content" id="gasRecordModalContent">
|
||||
|
||||
|
||||
@@ -44,14 +44,7 @@
|
||||
@if (Model.GasRecord.Files.Any())
|
||||
{
|
||||
<div>
|
||||
<label>Uploaded Documents</label>
|
||||
@foreach (UploadedFiles filesUploaded in Model.GasRecord.Files)
|
||||
{
|
||||
<div class="d-flex justify-content-between">
|
||||
<a type="button" class="btn btn-link" href="@filesUploaded.Location" target="_blank">@filesUploaded.Name</a>
|
||||
<button type="button" class="btn btn-sm btn-outline-danger" onclick="deleteGasRecordFile('@filesUploaded.Location', this)"><i class="bi bi-trash"></i></button>
|
||||
</div>
|
||||
}
|
||||
@await Html.PartialAsync("_UploadedFiles", Model.GasRecord.Files)
|
||||
<label for="gasRecordFiles">Upload more documents</label>
|
||||
<input onChange="uploadVehicleFilesAsync(this)" type="file" multiple accept=".png,.jpg,.jpeg,.pdf,.xls,.xlsx,.docx" class="form-control-file" id="gasRecordFiles">
|
||||
</div>
|
||||
|
||||
@@ -30,14 +30,7 @@
|
||||
@if (Model.Files.Any())
|
||||
{
|
||||
<div>
|
||||
<label>Uploaded Documents</label>
|
||||
@foreach (UploadedFiles filesUploaded in Model.Files)
|
||||
{
|
||||
<div class="d-flex justify-content-between">
|
||||
<a type="button" class="btn btn-link" href="@filesUploaded.Location" target="_blank">@filesUploaded.Name</a>
|
||||
<button type="button" class="btn btn-sm btn-outline-danger" onclick="deleteServiceRecordFile('@filesUploaded.Location', this)"><i class="bi bi-trash"></i></button>
|
||||
</div>
|
||||
}
|
||||
@await Html.PartialAsync("_UploadedFiles", Model.Files)
|
||||
<label for="serviceRecordFiles">Upload more documents</label>
|
||||
<input onChange="uploadVehicleFilesAsync(this)" type="file" multiple accept=".png,.jpg,.jpeg,.pdf,.xls,.xlsx,.docx" class="form-control-file" id="serviceRecordFiles">
|
||||
</div>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
@inject IConfiguration Configuration
|
||||
@{
|
||||
var enableCsvImports = bool.Parse(Configuration[nameof(UserConfig.EnableCsvImports)]);
|
||||
var hideZero = bool.Parse(Configuration[nameof(UserConfig.HideZero)]);
|
||||
}
|
||||
@model List<ServiceRecord>
|
||||
<div class="row">
|
||||
@@ -48,7 +49,7 @@
|
||||
<td class="col-1">@serviceRecord.Date.ToShortDateString()</td>
|
||||
<td class="col-2">@serviceRecord.Mileage</td>
|
||||
<td class="col-4">@serviceRecord.Description</td>
|
||||
<td class="col-2">@serviceRecord.Cost.ToString("C")</td>
|
||||
<td class="col-2">@((hideZero && serviceRecord.Cost == default) ? "---" : serviceRecord.Cost.ToString("C"))</td>
|
||||
<td class="col-3 text-truncate">@serviceRecord.Notes</td>
|
||||
</tr>
|
||||
}
|
||||
@@ -58,7 +59,7 @@
|
||||
</div>
|
||||
|
||||
|
||||
<div class="modal fade" id="serviceRecordModal" tabindex="-1" role="dialog" aria-hidden="true">
|
||||
<div class="modal fade" data-bs-focus="false" id="serviceRecordModal" tabindex="-1" role="dialog" aria-hidden="true">
|
||||
<div class="modal-dialog modal-lg" role="document">
|
||||
<div class="modal-content" id="serviceRecordModalContent">
|
||||
|
||||
|
||||
@@ -28,14 +28,7 @@
|
||||
@if (Model.Files.Any())
|
||||
{
|
||||
<div>
|
||||
<label>Uploaded Documents</label>
|
||||
@foreach (UploadedFiles filesUploaded in Model.Files)
|
||||
{
|
||||
<div class="d-flex justify-content-between">
|
||||
<a type="button" class="btn btn-link" href="@filesUploaded.Location" target="_blank">@filesUploaded.Name</a>
|
||||
<button type="button" class="btn btn-sm btn-outline-danger" onclick="deleteTaxRecordFile('@filesUploaded.Location', this)"><i class="bi bi-trash"></i></button>
|
||||
</div>
|
||||
}
|
||||
@await Html.PartialAsync("_UploadedFiles", Model.Files)
|
||||
<label for="taxRecordFiles">Upload more documents</label>
|
||||
<input onChange="uploadVehicleFilesAsync(this)" type="file" multiple accept=".png,.jpg,.jpeg,.pdf,.xls,.xlsx,.docx" class="form-control-file" id="taxRecordFiles">
|
||||
</div>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
@inject IConfiguration Configuration
|
||||
@{
|
||||
var enableCsvImports = bool.Parse(Configuration[nameof(UserConfig.EnableCsvImports)]);
|
||||
var hideZero = bool.Parse(Configuration[nameof(UserConfig.HideZero)]);
|
||||
}
|
||||
@model List<TaxRecord>
|
||||
<div class="row">
|
||||
@@ -46,7 +47,7 @@
|
||||
<tr class="d-flex" style="cursor:pointer;" onclick="showEditTaxRecordModal(@taxRecord.Id)">
|
||||
<td class="col-1">@taxRecord.Date.ToShortDateString()</td>
|
||||
<td class="col-6">@taxRecord.Description</td>
|
||||
<td class="col-2">@taxRecord.Cost.ToString("C")</td>
|
||||
<td class="col-2">@((hideZero && taxRecord.Cost == default) ? "---" : taxRecord.Cost.ToString("C"))</td>
|
||||
<td class="col-3 text-truncate">@taxRecord.Notes</td>
|
||||
</tr>
|
||||
}
|
||||
@@ -56,7 +57,7 @@
|
||||
</div>
|
||||
|
||||
|
||||
<div class="modal fade" id="taxRecordModal" tabindex="-1" role="dialog" aria-hidden="true">
|
||||
<div class="modal fade" data-bs-focus="false" id="taxRecordModal" tabindex="-1" role="dialog" aria-hidden="true">
|
||||
<div class="modal-dialog modal-lg" role="document">
|
||||
<div class="modal-content" id="taxRecordModalContent">
|
||||
</div>
|
||||
|
||||
16
Views/Vehicle/_UploadedFiles.cshtml
Normal file
16
Views/Vehicle/_UploadedFiles.cshtml
Normal file
@@ -0,0 +1,16 @@
|
||||
@model List<UploadedFiles>
|
||||
<label>Uploaded Documents</label>
|
||||
<ul class="list-group">
|
||||
@foreach (UploadedFiles filesUploaded in Model)
|
||||
{
|
||||
<li class="list-group-item">
|
||||
<div class="d-flex justify-content-between">
|
||||
<a type="button" class="btn btn-link" href="@filesUploaded.Location" target="_blank">@filesUploaded.Name</a>
|
||||
<div class="d-flex align-items-center">
|
||||
<button type="button" class="btn btn-sm btn-outline-secondary me-2" onclick="editFileName('@filesUploaded.Location', this)"><i class="bi bi-pencil"></i></button>
|
||||
<button type="button" class="btn btn-sm btn-outline-danger" onclick="deleteFileFromUploadedFiles('@filesUploaded.Location', this)"><i class="bi bi-trash"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
@@ -11,6 +11,7 @@
|
||||
"UseMPG": true,
|
||||
"UseDescending": false,
|
||||
"EnableAuth": false,
|
||||
"HideZero": false,
|
||||
"UserNameHash": "",
|
||||
"UserPasswordHash": ""
|
||||
}
|
||||
|
||||
@@ -121,8 +121,4 @@ function getAndValidateCollisionRecordValues() {
|
||||
files: uploadedFiles,
|
||||
addReminderRecord: addReminderRecord
|
||||
}
|
||||
}
|
||||
function deleteCollisionRecordFile(fileLocation, event) {
|
||||
event.parentElement.remove();
|
||||
uploadedFiles = uploadedFiles.filter(x => x.location != fileLocation);
|
||||
}
|
||||
@@ -116,8 +116,4 @@ function getAndValidateGasRecordValues() {
|
||||
files: uploadedFiles,
|
||||
isFillToFull: gasIsFillToFull
|
||||
}
|
||||
}
|
||||
function deleteGasRecordFile(fileLocation, event) {
|
||||
event.parentElement.remove();
|
||||
uploadedFiles = uploadedFiles.filter(x => x.location != fileLocation);
|
||||
}
|
||||
@@ -121,8 +121,4 @@ function getAndValidateServiceRecordValues() {
|
||||
files: uploadedFiles,
|
||||
addReminderRecord: addReminderRecord
|
||||
}
|
||||
}
|
||||
function deleteServiceRecordFile(fileLocation, event) {
|
||||
event.parentElement.remove();
|
||||
uploadedFiles = uploadedFiles.filter(x => x.location != fileLocation);
|
||||
}
|
||||
@@ -113,8 +113,4 @@ function getAndValidateTaxRecordValues() {
|
||||
files: uploadedFiles,
|
||||
addReminderRecord: addReminderRecord
|
||||
}
|
||||
}
|
||||
function deleteTaxRecordFile(fileLocation, event) {
|
||||
event.parentElement.remove();
|
||||
uploadedFiles = uploadedFiles.filter(x => x.location != fileLocation);
|
||||
}
|
||||
@@ -213,4 +213,33 @@ function getVehicleHaveImportantReminders(vehicleId) {
|
||||
}
|
||||
});
|
||||
}, 500);
|
||||
}
|
||||
|
||||
function deleteFileFromUploadedFiles(fileLocation, event) {
|
||||
event.parentElement.parentElement.parentElement.remove();
|
||||
uploadedFiles = uploadedFiles.filter(x => x.location != fileLocation);
|
||||
}
|
||||
function editFileName(fileLocation, event) {
|
||||
Swal.fire({
|
||||
title: 'Rename File',
|
||||
html: `
|
||||
<input type="text" id="newFileName" class="swal2-input" placeholder="New File Name">
|
||||
`,
|
||||
confirmButtonText: 'Rename',
|
||||
focusConfirm: false,
|
||||
preConfirm: () => {
|
||||
const newFileName = $("#newFileName").val();
|
||||
if (!newFileName) {
|
||||
Swal.showValidationMessage(`Please enter a valid file name`)
|
||||
}
|
||||
return { newFileName }
|
||||
},
|
||||
}).then(function (result) {
|
||||
if (result.isConfirmed) {
|
||||
var linkDisplayObject = $(event.parentElement.parentElement).find('a')[0];
|
||||
linkDisplayObject.text = result.value.newFileName;
|
||||
var editFileIndex = uploadedFiles.findIndex(x => x.location == fileLocation);
|
||||
uploadedFiles[editFileIndex].name = result.value.newFileName;
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user