diff --git a/Enum/ExtraFieldType.cs b/Enum/ExtraFieldType.cs
new file mode 100644
index 0000000..eff2212
--- /dev/null
+++ b/Enum/ExtraFieldType.cs
@@ -0,0 +1,12 @@
+namespace CarCareTracker.Models
+{
+ public enum ExtraFieldType
+ {
+ Text = 0,
+ Number = 1,
+ Decimal = 2,
+ Date = 3,
+ Time = 4,
+ Location = 5
+ }
+}
diff --git a/Helper/StaticHelper.cs b/Helper/StaticHelper.cs
index 67c5427..2a2fd6a 100644
--- a/Helper/StaticHelper.cs
+++ b/Helper/StaticHelper.cs
@@ -262,7 +262,9 @@ namespace CarCareTracker.Helper
//update isrequired setting
foreach (ExtraField extraField in recordExtraFields)
{
- extraField.IsRequired = templateExtraFields.Where(x => x.Name == extraField.Name).First().IsRequired;
+ var firstMatchingField = templateExtraFields.First(x => x.Name == extraField.Name);
+ extraField.IsRequired = firstMatchingField.IsRequired;
+ extraField.FieldType = firstMatchingField.FieldType;
}
//append extra fields
foreach (ExtraField extraField in templateExtraFields)
diff --git a/Models/Shared/ExtraField.cs b/Models/Shared/ExtraField.cs
index 9a4ed8c..9b5e3ec 100644
--- a/Models/Shared/ExtraField.cs
+++ b/Models/Shared/ExtraField.cs
@@ -5,5 +5,6 @@
public string Name { get; set; }
public string Value { get; set; }
public bool IsRequired { get; set; }
+ public ExtraFieldType FieldType { get; set; } = ExtraFieldType.Text;
}
}
diff --git a/Views/Home/_ExtraFields.cshtml b/Views/Home/_ExtraFields.cshtml
index ec1b25b..cb28de0 100644
--- a/Views/Home/_ExtraFields.cshtml
+++ b/Views/Home/_ExtraFields.cshtml
@@ -36,8 +36,9 @@
- | @translator.Translate(userLanguage, "Name") |
+ @translator.Translate(userLanguage, "Name") |
@translator.Translate(userLanguage, "Required") |
+ @translator.Translate(userLanguage, "Type") |
@translator.Translate(userLanguage, "Delete") |
@@ -47,11 +48,21 @@
@foreach (ExtraField extraField in Model.ExtraFields)
{
- | @extraField.Name |
+ @extraField.Name |
|
+
+
+ |
|
}
@@ -99,6 +110,12 @@
extraFieldToEdit.isRequired = $(checkbox).is(":checked");
updateExtraFields();
}
+ function updateExtraFieldType(fieldId, dropDown){
+ var indexToEdit = extraFields.findIndex(x => x.name == fieldId);
+ var extraFieldToEdit = extraFields[indexToEdit];
+ extraFieldToEdit.fieldType = $(dropDown).val();
+ updateExtraFields();
+ }
function deleteExtraField(fieldId) {
extraFields = extraFields.filter(x => x.name != fieldId);
updateExtraFields();
diff --git a/Views/Vehicle/_CollisionRecordModal.cshtml b/Views/Vehicle/_CollisionRecordModal.cshtml
index 2ba92a0..692715e 100644
--- a/Views/Vehicle/_CollisionRecordModal.cshtml
+++ b/Views/Vehicle/_CollisionRecordModal.cshtml
@@ -52,14 +52,7 @@
@tag!option>
}
- @foreach (ExtraField field in Model.ExtraFields)
- {
- var elementId = Guid.NewGuid();
-
- }
+ @await Html.PartialAsync("_ExtraField", Model.ExtraFields)
diff --git a/Views/Vehicle/_ExtraField.cshtml b/Views/Vehicle/_ExtraField.cshtml
new file mode 100644
index 0000000..f87e0c1
--- /dev/null
+++ b/Views/Vehicle/_ExtraField.cshtml
@@ -0,0 +1,42 @@
+@model List
+@if (Model.Any()){
+ @foreach (ExtraField field in Model)
+ {
+ var elementId = Guid.NewGuid();
+
+ }
+}
\ No newline at end of file
diff --git a/Views/Vehicle/_OdometerRecordModal.cshtml b/Views/Vehicle/_OdometerRecordModal.cshtml
index 94fd691..5001909 100644
--- a/Views/Vehicle/_OdometerRecordModal.cshtml
+++ b/Views/Vehicle/_OdometerRecordModal.cshtml
@@ -72,14 +72,7 @@
@tag!option>
}
- @foreach (ExtraField field in Model.ExtraFields)
- {
- var elementId = Guid.NewGuid();
-
- }
+ @await Html.PartialAsync("_ExtraField", Model.ExtraFields)
diff --git a/Views/Vehicle/_PlanRecordModal.cshtml b/Views/Vehicle/_PlanRecordModal.cshtml
index d774916..598610c 100644
--- a/Views/Vehicle/_PlanRecordModal.cshtml
+++ b/Views/Vehicle/_PlanRecordModal.cshtml
@@ -40,14 +40,7 @@
@translator.Translate(userLanguage, "Doing")!option>
@translator.Translate(userLanguage, "Testing")!option>
- @foreach (ExtraField field in Model.ExtraFields)
- {
- var elementId = Guid.NewGuid();
-
- }
+ @await Html.PartialAsync("_ExtraField", Model.ExtraFields)
@if (!isNew)
{
diff --git a/Views/Vehicle/_PlanRecordTemplateEditModal.cshtml b/Views/Vehicle/_PlanRecordTemplateEditModal.cshtml
index a69e48c..8635504 100644
--- a/Views/Vehicle/_PlanRecordTemplateEditModal.cshtml
+++ b/Views/Vehicle/_PlanRecordTemplateEditModal.cshtml
@@ -40,14 +40,7 @@
@translator.Translate(userLanguage, "Doing")!option>
@translator.Translate(userLanguage, "Testing")!option>
- @foreach (ExtraField field in Model.ExtraFields)
- {
- var elementId = Guid.NewGuid();
-
- }
+ @await Html.PartialAsync("_ExtraField", Model.ExtraFields)
diff --git a/Views/Vehicle/_ServiceRecordModal.cshtml b/Views/Vehicle/_ServiceRecordModal.cshtml
index e1e136a..344cbe0 100644
--- a/Views/Vehicle/_ServiceRecordModal.cshtml
+++ b/Views/Vehicle/_ServiceRecordModal.cshtml
@@ -52,14 +52,7 @@
@tag!option>
}
- @foreach (ExtraField field in Model.ExtraFields)
- {
- var elementId = Guid.NewGuid();
-
- }
+ @await Html.PartialAsync("_ExtraField", Model.ExtraFields)
diff --git a/Views/Vehicle/_SupplyRecordModal.cshtml b/Views/Vehicle/_SupplyRecordModal.cshtml
index 6b9aa76..d77ac8c 100644
--- a/Views/Vehicle/_SupplyRecordModal.cshtml
+++ b/Views/Vehicle/_SupplyRecordModal.cshtml
@@ -50,14 +50,7 @@
@tag!option>
}
- @foreach (ExtraField field in Model.ExtraFields)
- {
- var elementId = Guid.NewGuid();
-
- }
+ @await Html.PartialAsync("_ExtraField", Model.ExtraFields)
diff --git a/Views/Vehicle/_TaxRecordModal.cshtml b/Views/Vehicle/_TaxRecordModal.cshtml
index 6517de2..69f2080 100644
--- a/Views/Vehicle/_TaxRecordModal.cshtml
+++ b/Views/Vehicle/_TaxRecordModal.cshtml
@@ -41,14 +41,7 @@
@tag!option>
}
- @foreach (ExtraField field in Model.ExtraFields)
- {
- var elementId = Guid.NewGuid();
-
- }
+ @await Html.PartialAsync("_ExtraField", Model.ExtraFields)
diff --git a/Views/Vehicle/_UpgradeRecordModal.cshtml b/Views/Vehicle/_UpgradeRecordModal.cshtml
index b683a91..ab5ebc2 100644
--- a/Views/Vehicle/_UpgradeRecordModal.cshtml
+++ b/Views/Vehicle/_UpgradeRecordModal.cshtml
@@ -52,14 +52,7 @@
@tag!option>
}
- @foreach (ExtraField field in Model.ExtraFields)
- {
- var elementId = Guid.NewGuid();
-
- }
+ @await Html.PartialAsync("_ExtraField", Model.ExtraFields)