We want custom views to be synced between users, here's the model:
public class CustomView
{
public Guid Id { get; init; }
public DateTimeOffset? DeletedAt { get; set; }
public required string Name { get; set; }
public ViewBase Base { get; set; }
// public DateTimeOffset? DefaultAsOf { get; set; } // defer: does not support setting a builtin view as the default
// public string? DefaultFilter { get; set; } // defer: fairly complex
// public required string[] Fields { get; set; } // 👇 split and used objects/json
public ViewField[] EntryFields { get; set; } = [];
public ViewField[] SenseFields { get; set; } = [];
public ViewField[] ExampleFields { get; set; } = [];
// 👇 also use objects/json
public required ViewWritingSystem[]? Vernacular { get; set; } // null = use defaults/all
public required ViewWritingSystem[]? Analysis { get; set; } // null = use defaults/all
}
public class ViewField
{
public required string FieldId { get; set; }
// Future possibilities: IsReadOnly, HideIfEmpty, custom writing-system selection etc.
public ViewField Copy()
{
return new ViewField
{
FieldId = FieldId
};
}
}
public class ViewWritingSystem
{
public required WritingSystemId WsId { get; set; }
// Future possibilities: IsReadOnly etc.
public ViewWritingSystem Copy()
{
return new ViewWritingSystem
{
WsId = WsId
};
}
}
public enum ViewBase
{
FwLite,
FieldWorks,
}
the view base will determine the field labels which are used. The field order is determined by the order they show up in the Fields list matches the project order, because the project-field order seems more likely to change. The list can include custom fields by CustomFieldId (see #1966). Custom views will not support per field writing system visibility, if that is desired then that would fit better with tasks.
The change for this can be fairly simple just using either a json patch change, or a change which is created based on the custom view and just modifies the view in the Apply method, views won't change frequently and so conflicts will be rare.
This model is designed to have a single default Custom View (based on Max(DefaultAsOf)), we may want to have a default per user role (only manager, editor, observer exist right now), in which case we could have a separate table to track that or just list the roles that this CustomView is default for on a property.
We want custom views to be synced between users, here's the model:
the view base will determine the field labels which are used. The field order is
determined by the order they show up in the Fields listmatches the project order, because the project-field order seems more likely to change. The list can include custom fields byCustomFieldId(see #1966). Custom views will not support per field writing system visibility, if that is desired then that would fit better with tasks.The change for this can be fairly simple just using either a json patch change, or a change which is created based on the custom view and just modifies the view in the Apply method, views won't change frequently and so conflicts will be rare.
This model is designed to have a single default Custom View (based on
Max(DefaultAsOf)), we may want to have a default per user role (only manager, editor, observer exist right now), in which case we could have a separate table to track that or just list the roles that this CustomView is default for on a property.