update uploaded files in real time for records that already have uploaded files and fix note attachment bug
This commit is contained in:
@@ -1795,6 +1795,7 @@ namespace CarCareTracker.Controllers
|
|||||||
[HttpPost]
|
[HttpPost]
|
||||||
public IActionResult SaveNoteToVehicleId(Note note)
|
public IActionResult SaveNoteToVehicleId(Note note)
|
||||||
{
|
{
|
||||||
|
note.Files = note.Files.Select(x => { return new UploadedFiles { Name = x.Name, Location = _fileHelper.MoveFileFromTemp(x.Location, "documents/") }; }).ToList();
|
||||||
var result = _noteDataAccess.SaveNoteToVehicle(note);
|
var result = _noteDataAccess.SaveNoteToVehicle(note);
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
@@ -2391,6 +2392,12 @@ namespace CarCareTracker.Controllers
|
|||||||
#endregion
|
#endregion
|
||||||
#region "Shared Methods"
|
#region "Shared Methods"
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
|
public IActionResult GetFilesPendingUpload(List<UploadedFiles> uploadedFiles)
|
||||||
|
{
|
||||||
|
var filesPendingUpload = uploadedFiles.Where(x => x.Location.StartsWith("/temp/")).ToList();
|
||||||
|
return PartialView("_FilesToUpload", filesPendingUpload);
|
||||||
|
}
|
||||||
|
[HttpPost]
|
||||||
[TypeFilter(typeof(CollaboratorFilter))]
|
[TypeFilter(typeof(CollaboratorFilter))]
|
||||||
public IActionResult SearchRecords(int vehicleId, string searchQuery)
|
public IActionResult SearchRecords(int vehicleId, string searchQuery)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -89,10 +89,9 @@
|
|||||||
}
|
}
|
||||||
<label for="collisionRecordFiles">@translator.Translate(userLanguage, "Upload documents(optional)")</label>
|
<label for="collisionRecordFiles">@translator.Translate(userLanguage, "Upload documents(optional)")</label>
|
||||||
<input onChange="uploadVehicleFilesAsync(this)" type="file" multiple accept="@config.GetAllowedFileUploadExtensions()" class="form-control-file" id="collisionRecordFiles">
|
<input onChange="uploadVehicleFilesAsync(this)" type="file" multiple accept="@config.GetAllowedFileUploadExtensions()" class="form-control-file" id="collisionRecordFiles">
|
||||||
<br />
|
<br /><small class="text-body-secondary">@translator.Translate(userLanguage, "Max File Size: 28.6MB")</small>
|
||||||
|
|
||||||
<small class="text-body-secondary">@translator.Translate(userLanguage, "Max File Size: 28.6MB")</small>
|
|
||||||
}
|
}
|
||||||
|
<div id="filesPendingUpload"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
23
Views/Vehicle/_FilesToUpload.cshtml
Normal file
23
Views/Vehicle/_FilesToUpload.cshtml
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
@using CarCareTracker.Helper
|
||||||
|
@inject IConfigHelper config
|
||||||
|
@inject ITranslationHelper translator
|
||||||
|
@{
|
||||||
|
var userConfig = config.GetUserConfig(User);
|
||||||
|
var userLanguage = userConfig.UserLanguage;
|
||||||
|
}
|
||||||
|
@model List<UploadedFiles>
|
||||||
|
<label id="documentsPendingUploadLabel">@translator.Translate(userLanguage, "Documents Pending Upload")</label>
|
||||||
|
<ul class="list-group" id="documentsPendingUploadList">
|
||||||
|
@foreach (UploadedFiles filesUploaded in Model)
|
||||||
|
{
|
||||||
|
<li class="list-group-item">
|
||||||
|
<div class="d-flex justify-content-between">
|
||||||
|
<a type="button" class="btn btn-link text-truncate uploadedFileName" 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>
|
||||||
@@ -121,6 +121,7 @@
|
|||||||
<input onChange="uploadVehicleFilesAsync(this)" type="file" multiple accept="@config.GetAllowedFileUploadExtensions()" class="form-control-file" id="gasRecordFiles">
|
<input onChange="uploadVehicleFilesAsync(this)" type="file" multiple accept="@config.GetAllowedFileUploadExtensions()" class="form-control-file" id="gasRecordFiles">
|
||||||
<br /><small class="text-body-secondary">@translator.Translate(userLanguage,"Max File Size: 28.6MB")</small>
|
<br /><small class="text-body-secondary">@translator.Translate(userLanguage,"Max File Size: 28.6MB")</small>
|
||||||
}
|
}
|
||||||
|
<div id="filesPendingUpload"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -45,6 +45,7 @@
|
|||||||
<br />
|
<br />
|
||||||
<small class="text-body-secondary">@translator.Translate(userLanguage, "Max File Size: 28.6MB")</small>
|
<small class="text-body-secondary">@translator.Translate(userLanguage, "Max File Size: 28.6MB")</small>
|
||||||
}
|
}
|
||||||
|
<div id="filesPendingUpload"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<label for="noteRecordTag">@translator.Translate(userLanguage,"Tags(optional)")</label>
|
<label for="noteRecordTag">@translator.Translate(userLanguage,"Tags(optional)")</label>
|
||||||
|
|||||||
@@ -76,6 +76,7 @@
|
|||||||
<input onChange="uploadVehicleFilesAsync(this)" type="file" multiple accept="@config.GetAllowedFileUploadExtensions()" class="form-control-file" id="odometerRecordFiles">
|
<input onChange="uploadVehicleFilesAsync(this)" type="file" multiple accept="@config.GetAllowedFileUploadExtensions()" class="form-control-file" id="odometerRecordFiles">
|
||||||
<br /><small class="text-body-secondary">@translator.Translate(userLanguage,"Max File Size: 28.6MB")</small>
|
<br /><small class="text-body-secondary">@translator.Translate(userLanguage,"Max File Size: 28.6MB")</small>
|
||||||
}
|
}
|
||||||
|
<div id="filesPendingUpload"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -73,10 +73,9 @@
|
|||||||
{
|
{
|
||||||
<label for="planRecordFiles">@translator.Translate(userLanguage, "Upload documents(optional)")</label>
|
<label for="planRecordFiles">@translator.Translate(userLanguage, "Upload documents(optional)")</label>
|
||||||
<input onChange="uploadVehicleFilesAsync(this)" type="file" multiple accept="@config.GetAllowedFileUploadExtensions()" class="form-control-file" id="planRecordFiles">
|
<input onChange="uploadVehicleFilesAsync(this)" type="file" multiple accept="@config.GetAllowedFileUploadExtensions()" class="form-control-file" id="planRecordFiles">
|
||||||
<br />
|
<br /><small class="text-body-secondary">@translator.Translate(userLanguage, "Max File Size: 28.6MB")</small>
|
||||||
|
|
||||||
<small class="text-body-secondary">@translator.Translate(userLanguage, "Max File Size: 28.6MB")</small>
|
|
||||||
}
|
}
|
||||||
|
<div id="filesPendingUpload"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -65,10 +65,9 @@
|
|||||||
{
|
{
|
||||||
<label for="planRecordFiles">@translator.Translate(userLanguage, "Upload documents(optional)")</label>
|
<label for="planRecordFiles">@translator.Translate(userLanguage, "Upload documents(optional)")</label>
|
||||||
<input onChange="uploadVehicleFilesAsync(this)" type="file" multiple accept="@config.GetAllowedFileUploadExtensions()" class="form-control-file" id="planRecordFiles">
|
<input onChange="uploadVehicleFilesAsync(this)" type="file" multiple accept="@config.GetAllowedFileUploadExtensions()" class="form-control-file" id="planRecordFiles">
|
||||||
<br />
|
<br /><small class="text-body-secondary">@translator.Translate(userLanguage, "Max File Size: 28.6MB")</small>
|
||||||
|
|
||||||
<small class="text-body-secondary">@translator.Translate(userLanguage, "Max File Size: 28.6MB")</small>
|
|
||||||
}
|
}
|
||||||
|
<div id="filesPendingUpload"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -91,6 +91,7 @@
|
|||||||
<input onChange="uploadVehicleFilesAsync(this)" type="file" multiple accept="@config.GetAllowedFileUploadExtensions()" class="form-control-file" id="serviceRecordFiles">
|
<input onChange="uploadVehicleFilesAsync(this)" type="file" multiple accept="@config.GetAllowedFileUploadExtensions()" class="form-control-file" id="serviceRecordFiles">
|
||||||
<br /><small class="text-body-secondary">@translator.Translate(userLanguage,"Max File Size: 28.6MB")</small>
|
<br /><small class="text-body-secondary">@translator.Translate(userLanguage,"Max File Size: 28.6MB")</small>
|
||||||
}
|
}
|
||||||
|
<div id="filesPendingUpload"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -77,6 +77,7 @@
|
|||||||
<input onChange="uploadVehicleFilesAsync(this)" type="file" multiple accept="@config.GetAllowedFileUploadExtensions()" class="form-control-file" id="supplyRecordFiles">
|
<input onChange="uploadVehicleFilesAsync(this)" type="file" multiple accept="@config.GetAllowedFileUploadExtensions()" class="form-control-file" id="supplyRecordFiles">
|
||||||
<br /><small class="text-body-secondary">@translator.Translate(userLanguage,"Max File Size: 28.6MB")</small>
|
<br /><small class="text-body-secondary">@translator.Translate(userLanguage,"Max File Size: 28.6MB")</small>
|
||||||
}
|
}
|
||||||
|
<div id="filesPendingUpload"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -92,6 +92,7 @@
|
|||||||
<input onChange="uploadVehicleFilesAsync(this)" type="file" multiple accept="@config.GetAllowedFileUploadExtensions()" class="form-control-file" id="taxRecordFiles">
|
<input onChange="uploadVehicleFilesAsync(this)" type="file" multiple accept="@config.GetAllowedFileUploadExtensions()" class="form-control-file" id="taxRecordFiles">
|
||||||
<br /><small class="text-body-secondary">@translator.Translate(userLanguage,"Max File Size: 28.6MB")</small>
|
<br /><small class="text-body-secondary">@translator.Translate(userLanguage,"Max File Size: 28.6MB")</small>
|
||||||
}
|
}
|
||||||
|
<div id="filesPendingUpload"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -89,10 +89,9 @@
|
|||||||
}
|
}
|
||||||
<label for="upgradeRecordFiles">Upload documents(optional)</label>
|
<label for="upgradeRecordFiles">Upload documents(optional)</label>
|
||||||
<input onChange="uploadVehicleFilesAsync(this)" type="file" multiple accept="@config.GetAllowedFileUploadExtensions()" class="form-control-file" id="upgradeRecordFiles">
|
<input onChange="uploadVehicleFilesAsync(this)" type="file" multiple accept="@config.GetAllowedFileUploadExtensions()" class="form-control-file" id="upgradeRecordFiles">
|
||||||
<br />
|
<br /><small class="text-body-secondary">@translator.Translate(userLanguage, "Max File Size: 28.6MB")</small>
|
||||||
|
|
||||||
<small class="text-body-secondary">@translator.Translate(userLanguage, "Max File Size: 28.6MB")</small>
|
|
||||||
}
|
}
|
||||||
|
<div id="filesPendingUpload"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -6,8 +6,8 @@
|
|||||||
var userLanguage = userConfig.UserLanguage;
|
var userLanguage = userConfig.UserLanguage;
|
||||||
}
|
}
|
||||||
@model List<UploadedFiles>
|
@model List<UploadedFiles>
|
||||||
<label>@translator.Translate(userLanguage, "Uploaded Documents")</label>
|
<label id="uploadedDocumentsLabel">@translator.Translate(userLanguage, "Uploaded Documents")</label>
|
||||||
<ul class="list-group">
|
<ul class="list-group" id="uploadedDocumentsList">
|
||||||
@foreach (UploadedFiles filesUploaded in Model)
|
@foreach (UploadedFiles filesUploaded in Model)
|
||||||
{
|
{
|
||||||
<li class="list-group-item">
|
<li class="list-group-item">
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -375,8 +375,12 @@ function uploadVehicleFilesAsync(event) {
|
|||||||
type: 'POST',
|
type: 'POST',
|
||||||
success: function (response) {
|
success: function (response) {
|
||||||
sloader.hide();
|
sloader.hide();
|
||||||
|
$(event).val(""); //clear out the filename from the uploader
|
||||||
if (response.length > 0) {
|
if (response.length > 0) {
|
||||||
uploadedFiles.push.apply(uploadedFiles, response);
|
uploadedFiles.push.apply(uploadedFiles, response);
|
||||||
|
$.post('/Vehicle/GetFilesPendingUpload', { uploadedFiles: uploadedFiles }, function (viewData) {
|
||||||
|
$("#filesPendingUpload").html(viewData);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error: function () {
|
error: function () {
|
||||||
@@ -388,6 +392,15 @@ function uploadVehicleFilesAsync(event) {
|
|||||||
function deleteFileFromUploadedFiles(fileLocation, event) {
|
function deleteFileFromUploadedFiles(fileLocation, event) {
|
||||||
event.parentElement.parentElement.parentElement.remove();
|
event.parentElement.parentElement.parentElement.remove();
|
||||||
uploadedFiles = uploadedFiles.filter(x => x.location != fileLocation);
|
uploadedFiles = uploadedFiles.filter(x => x.location != fileLocation);
|
||||||
|
if (fileLocation.startsWith("/temp/")) {
|
||||||
|
if ($("#documentsPendingUploadList > li").length == 0) {
|
||||||
|
$("#documentsPendingUploadLabel").text("");
|
||||||
|
}
|
||||||
|
} else if (fileLocation.startsWith("/documents/")) {
|
||||||
|
if ($("#uploadedDocumentsList > li").length == 0) {
|
||||||
|
$("#uploadedDocumentsLabel").text("");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
function editFileName(fileLocation, event) {
|
function editFileName(fileLocation, event) {
|
||||||
Swal.fire({
|
Swal.fire({
|
||||||
|
|||||||
Reference in New Issue
Block a user