Fontos kezelési javítások
This commit is contained in:
@@ -212,8 +212,7 @@ namespace WorkFlowCheck.BL.Services
|
||||
var res = await _dbContext.Locations.Where(w => w.Id == LocationDTO.Id).FirstOrDefaultAsync();
|
||||
if (res != null)
|
||||
{
|
||||
res = _mapper.Map<DL.Entities.Location>(LocationDTO);
|
||||
|
||||
res.FullName = LocationDTO.FullName;
|
||||
await _dbContext.SaveChangesAsync();
|
||||
|
||||
retVal = _mapper.Map<LocationDTO>(res);
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@@ -9,7 +11,13 @@ namespace WorkFlowCheck.Common.DTO
|
||||
public class EquipmentDTO
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "A megnevezést megadása kötelező.")]
|
||||
[DisplayName("Megnevezés")]
|
||||
public string ShortName { get; set; } = null!;
|
||||
|
||||
[Required(ErrorMessage = "Az azonosító megadása kötelező.")]
|
||||
[DisplayName("Azonosító")]
|
||||
public string EquipmentNumber { get; set; } = null!;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@@ -9,6 +11,9 @@ namespace WorkFlowCheck.Common.DTO
|
||||
public class LocationDTO
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "A megnevezést megadása kötelező.")]
|
||||
[DisplayName("Megnevezés")]
|
||||
public string FullName { get; set; } = null!;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
using Microsoft.AspNetCore.Mvc.ViewFeatures;
|
||||
using Microsoft.AspNetCore.Razor.TagHelpers;
|
||||
|
||||
namespace WorkFlowCheck.Web.Helpers
|
||||
{
|
||||
[HtmlTargetElement("input", Attributes = "asp-for-datatype")]
|
||||
public class AspForDataTypeTagHelper : TagHelper
|
||||
{
|
||||
[HtmlAttributeName("asp-for-datatype")]
|
||||
public ModelExpression For { get; set; }
|
||||
|
||||
public override void Process(TagHelperContext context, TagHelperOutput output)
|
||||
{
|
||||
if (For == null) return;
|
||||
|
||||
var type = For.ModelExplorer.ModelType;
|
||||
|
||||
string dataType = GetDataTypeString(type);
|
||||
output.Attributes.SetAttribute("data-type", dataType);
|
||||
}
|
||||
|
||||
private string GetDataTypeString(Type type)
|
||||
{
|
||||
// Nullable<T> esetén nyerjük ki az alaptípust
|
||||
if (Nullable.GetUnderlyingType(type) is Type underlyingType)
|
||||
{
|
||||
type = underlyingType;
|
||||
}
|
||||
|
||||
if (type == typeof(string)) return "string";
|
||||
if (type == typeof(int) || type == typeof(long) || type == typeof(float) ||
|
||||
type == typeof(double) || type == typeof(decimal)) return "number";
|
||||
if (type == typeof(bool)) return "bool";
|
||||
if (type == typeof(DateTime)) return "date";
|
||||
|
||||
return "string"; // default fallback
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -79,7 +79,7 @@
|
||||
$('#tbEquipmentsPage').on('click', '.delete-btn', function ()
|
||||
{
|
||||
const row = table.row($(this).closest('tr')).data();
|
||||
deleteEntity(table, '/BaseStock/Equipments/EquipmentPage?handler=DeleteEquipment', row.id);
|
||||
deleteEntity(table, '/BaseStock/Equipments/EquipmentsPage?handler=DeleteEquipment', row.id);
|
||||
});
|
||||
</script>
|
||||
}
|
||||
|
||||
@@ -17,14 +17,14 @@
|
||||
<thead class="table-primary">
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Full name</th>
|
||||
<th>@DisplayNameHelper.GetDisplayName(nameof(LocationDTO.FullName), typeof(LocationDTO))</th>
|
||||
<th class="text-center">Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tfoot class="table-light">
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Full name</th>
|
||||
<th>@DisplayNameHelper.GetDisplayName(nameof(LocationDTO.FullName), typeof(LocationDTO))</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
|
||||
@@ -2,7 +2,11 @@
|
||||
// for details on configuring this project to bundle and minify static web assets.
|
||||
|
||||
// Write your JavaScript code.
|
||||
function parseValue(value) {
|
||||
function parseValue(value, type = "string") {
|
||||
if (type === "string") {
|
||||
return value;
|
||||
}
|
||||
|
||||
if (value === "") return null;
|
||||
|
||||
// Boolean
|
||||
@@ -23,17 +27,17 @@ function getFormAsNestedObject(formSelector) {
|
||||
|
||||
formArray.forEach(function (item) {
|
||||
var keys = item.name.split('.');
|
||||
var value = parseValue(item.value);
|
||||
var inputElement = document.querySelector(`[name="${item.name}"]`);
|
||||
var type = inputElement?.dataset?.type || "string"; // ha nincs data-type, alap: string
|
||||
var value = parseValue(item.value, type);
|
||||
var current = result;
|
||||
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
var key = keys[i];
|
||||
|
||||
// Ha utolsó kulcs, értéket rendelünk hozzá
|
||||
if (i === keys.length - 1) {
|
||||
current[key] = value;
|
||||
} else {
|
||||
// Ha a következő szint nincs meg, hozzuk létre
|
||||
if (!current[key]) {
|
||||
current[key] = {};
|
||||
}
|
||||
@@ -44,6 +48,7 @@ function getFormAsNestedObject(formSelector) {
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function showConfirmModal(options) {
|
||||
return new Promise(function (resolve) {
|
||||
// Alapértelmezett értékek
|
||||
|
||||
Reference in New Issue
Block a user