Add PreferExternalValue to control which value will be the final value
This commit is contained in:
@@ -51,6 +51,18 @@ Namespace Documents
|
||||
Return SortKey.CompareTo(DirectCast(other, DocumentRow).SortKey)
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' TODO: Use this class to
|
||||
''' </summary>
|
||||
Public Class Field
|
||||
Public ReadOnly Property Name
|
||||
Public Property Value As FieldValue
|
||||
|
||||
Public Sub New(pName As String)
|
||||
Name = pName
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
Public Class FieldValue
|
||||
Private _Final As String = ""
|
||||
Private _External As String = ""
|
||||
@@ -60,38 +72,33 @@ Namespace Documents
|
||||
|
||||
Public Property Errors As New List(Of FieldError)
|
||||
|
||||
Public Property Original As String
|
||||
Public ReadOnly Property Original As String
|
||||
Get
|
||||
Return FormatValue(_Original, DataType)
|
||||
End Get
|
||||
Set(value As String)
|
||||
_Original = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Public Property External As String
|
||||
Public ReadOnly Property External As String
|
||||
Get
|
||||
Return FormatValue(_External, DataType)
|
||||
End Get
|
||||
Set(value As String)
|
||||
_External = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Public Property Final As String
|
||||
Public ReadOnly Property Final As String
|
||||
Get
|
||||
Return FormatValue(_Final, DataType)
|
||||
End Get
|
||||
Set(value As String)
|
||||
_Final = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Public Property IsRequired As Boolean = False
|
||||
Public Property IsVirtual As Boolean = False
|
||||
Public Property PreferExternalValue As Boolean = True
|
||||
Public Property SortKey As Integer = 0
|
||||
|
||||
Public Function GetValue(pValueType) As String
|
||||
Public Sub New()
|
||||
End Sub
|
||||
|
||||
Public Function GetValue(pValueType As String) As String
|
||||
Select Case pValueType
|
||||
Case "Original"
|
||||
Return Original
|
||||
@@ -104,6 +111,19 @@ Namespace Documents
|
||||
End Select
|
||||
End Function
|
||||
|
||||
Public Sub SetValue(pValueType As String, pValue As String)
|
||||
Select Case pValueType
|
||||
Case "Original"
|
||||
_Original = pValue
|
||||
Case "External"
|
||||
_External = pValue
|
||||
Case "Final"
|
||||
_Final = pValue
|
||||
Case Else
|
||||
' Noop
|
||||
End Select
|
||||
End Sub
|
||||
|
||||
Public Sub AddFieldError(pType As FieldErrorType, pMessage As String)
|
||||
Errors.Add(New FieldError() With {
|
||||
.Type = pType,
|
||||
@@ -111,6 +131,27 @@ Namespace Documents
|
||||
})
|
||||
End Sub
|
||||
|
||||
Public Sub SetExternalValue(pValue As String)
|
||||
_External = pValue
|
||||
|
||||
' Set the external value as the final value, overriding the original / previous external value
|
||||
' if the external value should be preferred
|
||||
If PreferExternalValue = True Then
|
||||
_Final = pValue
|
||||
End If
|
||||
|
||||
' If there is no Original value (because the field is virtual),
|
||||
' set the external value as the final value regardless of the PreferExternalValue setting
|
||||
If Original = String.Empty Then
|
||||
_Final = pValue
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Public Sub SetOriginalValue(pValue As String)
|
||||
_Original = pValue
|
||||
_Final = pValue
|
||||
End Sub
|
||||
|
||||
Public ReadOnly Property HasError As Boolean
|
||||
Get
|
||||
' Required check was moved to DocumentLoader
|
||||
|
||||
Reference in New Issue
Block a user