All table column names went into consts

This commit is contained in:
Simon Martens
2025-02-07 22:12:40 +01:00
parent 706349e748
commit f4cbb037e0
10 changed files with 234 additions and 104 deletions

View File

@@ -11,7 +11,7 @@ import (
func init() {
m.Register(func(app core.App) error {
entries := entriesTable()
fields := entriesFields(entries, app)
fields := entriesFields(app)
if fields == nil {
return errors.New("Could not find places collection")
}
@@ -36,7 +36,7 @@ func entriesTable() *core.Collection {
return collection
}
func entriesFields(collection *core.Collection, app core.App) *core.FieldsList {
func entriesFields(app core.App) *core.FieldsList {
places, err := app.FindCollectionByNameOrId(models.PLACES_TABLE)
if err != nil {
return nil
@@ -44,43 +44,74 @@ func entriesFields(collection *core.Collection, app core.App) *core.FieldsList {
fields := core.NewFieldsList(
// Title information
&core.TextField{Name: "preferredtitle", Required: true, Presentable: true},
&core.TextField{Name: "varianttitle", Required: false, Presentable: false},
&core.BoolField{Name: "paralleltitle", Required: false},
&core.TextField{Name: models.PREFERRED_TITLE_FIELD, Required: true, Presentable: true},
&core.TextField{Name: models.VARIANT_TITLE_FIELD, Required: false, Presentable: false},
&core.BoolField{Name: models.PARALLEL_TITLE_FIELD, Required: false},
// Transcribed information
&core.TextField{Name: "title_statement", Required: false, Presentable: false},
&core.TextField{Name: "subtitle_statement", Required: false, Presentable: false},
&core.TextField{Name: "incipit_statement", Required: false, Presentable: false},
&core.TextField{Name: models.TITLE_STMT_FIELD, Required: false, Presentable: false},
&core.TextField{Name: models.SUBTITLE_STMT_FIELD, Required: false, Presentable: false},
&core.TextField{Name: models.INCIPIT_STMT_FIELD, Required: false, Presentable: false},
&core.TextField{Name: "responsibility_statement", Required: false, Presentable: false},
&core.TextField{Name: "place_statement", Required: false, Presentable: false},
&core.TextField{Name: "publication_statement", Required: false, Presentable: false},
&core.TextField{Name: models.RESPONSIBILITY_STMT_FIELD, Required: false, Presentable: false},
&core.TextField{Name: models.PLACE_STMT_FIELD, Required: false, Presentable: false},
&core.TextField{Name: models.PUBLICATION_STMT_FIELD, Required: false, Presentable: false},
// Other discerning Information
&core.NumberField{Name: "year", Required: false},
&core.TextField{Name: "edition", Required: false},
&core.NumberField{Name: models.YEAR_FIELD, Required: false},
&core.TextField{Name: models.EDITION_FIELD, Required: false},
// Media Information
&core.SelectField{Name: "language", Required: false, Values: models.LANGUAGE_VALUES, MaxSelect: len(models.LANGUAGE_VALUES)},
&core.SelectField{Name: "content_type", Required: false, Values: models.CONTENT_TYPE_VALUES, MaxSelect: len(models.CONTENT_TYPE_VALUES)},
&core.SelectField{
Name: models.LANGUAGE_FIELD,
Required: false,
Values: models.LANGUAGE_VALUES,
MaxSelect: len(models.LANGUAGE_VALUES),
},
&core.SelectField{
Name: models.CONTENT_TYPE_FIELD,
Required: false,
Values: models.CONTENT_TYPE_VALUES,
MaxSelect: len(models.CONTENT_TYPE_VALUES),
},
// Physical Description
&core.TextField{Name: "extent", Required: false},
&core.TextField{Name: "dimensions", Required: false},
&core.SelectField{Name: "media_type", Required: false, Values: models.MEDIA_TYPE_VALUES, MaxSelect: len(models.MEDIA_TYPE_VALUES)},
&core.SelectField{Name: "carrier_type", Required: false, Values: models.CARRIER_TYPE_VALUES, MaxSelect: len(models.CARRIER_TYPE_VALUES)},
&core.TextField{Name: models.EXTENT_FIELD, Required: false},
&core.TextField{Name: models.DIMENSIONS_FIELD, Required: false},
&core.SelectField{
Name: models.CARRIER_TYPE_FIELD,
Required: false,
Values: models.MEDIA_TYPE_VALUES,
MaxSelect: len(models.MEDIA_TYPE_VALUES),
},
&core.SelectField{
Name: models.CARRIER_TYPE_FIELD,
Required: false,
Values: models.CARRIER_TYPE_VALUES,
MaxSelect: len(models.CARRIER_TYPE_VALUES),
},
// Norm Data
&core.TextField{Name: "references", Required: false},
&core.RelationField{Name: "places", Required: false, CollectionId: places.Id, CascadeDelete: false, MaxSelect: 5000},
&core.TextField{Name: models.REFERENCES_FIELD, Required: false},
&core.RelationField{
Name: models.PLACES_TABLE,
Required: false,
CollectionId: places.Id,
CascadeDelete: false,
MaxSelect: 5000,
},
// Musenalm specific data
&core.SelectField{Name: "musenalm_status", Required: false, Values: models.MUSENALM_STATUS_VALUES, MaxSelect: len(models.MUSENALM_STATUS_VALUES)},
&core.JSONField{Name: "musenalm_deprecated", Required: false},
&core.SelectField{
Name: models.MUSENALM_BAENDE_STATUS_FIELD,
Required: false,
Values: models.MUSENALM_STATUS_VALUES,
MaxSelect: len(models.MUSENALM_STATUS_VALUES),
},
&core.JSONField{Name: models.MUSENALM_DEPRECATED_FIELD, Required: false},
// Exemplare:
&core.JSONField{Name: "items", Required: false},
&core.JSONField{Name: models.ITEMS_TABLE, Required: false},
)
setMusenalmIDField(&fields)
@@ -92,15 +123,15 @@ func entriesFields(collection *core.Collection, app core.App) *core.FieldsList {
func entriesIndexes(collection *core.Collection) {
addMusenalmIDIndex(collection)
addIndex(collection, "preferredtitle", false)
addIndex(collection, "varianttitle", false)
addIndex(collection, "paralleltitle", false)
addIndex(collection, "title_statement", false)
addIndex(collection, "subtitle_statement", false)
addIndex(collection, "incipit_statement", false)
addIndex(collection, "responsibility_statement", false)
addIndex(collection, "place_statement", false)
addIndex(collection, "publication_statement", false)
addIndex(collection, "year", false)
addIndex(collection, "edition", false)
addIndex(collection, models.PREFERRED_TITLE_FIELD, false)
addIndex(collection, models.VARIANT_TITLE_FIELD, false)
addIndex(collection, models.PARALLEL_TITLE_FIELD, false)
addIndex(collection, models.TITLE_STMT_FIELD, false)
addIndex(collection, models.SUBTITLE_STMT_FIELD, false)
addIndex(collection, models.INCIPIT_STMT_FIELD, false)
addIndex(collection, models.RESPONSIBILITY_STMT_FIELD, false)
addIndex(collection, models.PLACE_STMT_FIELD, false)
addIndex(collection, models.PUBLICATION_STMT_FIELD, false)
addIndex(collection, models.YEAR_FIELD, false)
addIndex(collection, models.EDITION_FIELD, false)
}