-
-
Notifications
You must be signed in to change notification settings - Fork 4
Description
Note, this is not how field data is stored, that's in #1965, this is how we store the configuration/definition of each field.
The simplest thing to start with is the field types:
public enum CustomFieldType
{
Unknown,
SingleLineString,//maps to RichString, not multi string
SingleLineMultiString, //maps to MultiString, depending on CustomFieldWrintingSystem we show all the writing systems or just one
MultiLineText, //maps to RichString (not multi string!), don't need to implement this until a user asks for it
Number,
DateTime,
SingleItemReference,
MultiItemReference,
}
To reference stored data we will have a custom Id struct, similar to writing system Id. It looks like this:
public struct CustomFieldId
{
public Guid Id { get; init; }//FLEx doesn't have a guid here, to avoid problems we had in other places we will generate a Guid with a v5 guid based off the field name, reference LocalMediaAdapter in the FwData bridge
public string Name { get; init; }
public CustomFieldType Type { get; init; }
}
which will be round tripped to a string, for serialization in the format: "{Name}_{Id}_{Type}"
. The purpose is so that when looking at the JSON which contains custom fields the name will be front and center, if only the GUID were used it would be impossible to know what the values represented without matching the Id to the custom field definition.
Important
for equality purposes only the Guid is used for comparison, it is not valid to have 2 CustomFieldDefinitions with the same Guid and different Names or types.
Custom Field Definition:
public class CustomFieldDefinition
{
public CustomFieldId Id { get; init; }
public string Label { get; set; }
public string Description { get; set; }
public CustomFieldWritingSystem? WritingSystem { get; init; }
}
public enum CustomFieldWritingSystem
{
Unknown,
FirstAnalysis,
FirstVernacular,
AllAnalysis,
AllVernacular,
AnalysisThenVernacular,
VernacularThenAnalysis,
}
Important
Only Label and Description can be changed after a field is created, the rest of the properties are immutable.