sillsdev / sillsdev/languageforge-lexbox

Custom field definition model

Open
#1,966 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

📖 MiniLcm
Dominant language
C#
Stars
9
Forks
8
Avg merge
2d 13h
Merged PRs (30d)
49

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the existing writing system ID and the FwData bridge's LocalMediaAdapter reference mentioned in the issue. The work is complete when custom field types and definitions support the specified string round-trip format, GUID-only equality, and immutability rules for all properties except Label and Description.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
backend-api-design
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.