fix: page

This commit is contained in:
2025-08-06 17:21:27 +08:00
parent 1cea3e0f42
commit 56fe2abbc4
6 changed files with 96 additions and 33 deletions

View File

@@ -48,6 +48,7 @@ type TableConfig struct {
// FieldConfig holds field-specific configuration
type FieldConfig struct {
Type string `mapstructure:"type"`
Alias string `mapstructure:"alias"`
Hidden bool `mapstructure:"hidden"`
Searchable bool `mapstructure:"searchable"`
MaxLength int `mapstructure:"max_length"`

View File

@@ -79,11 +79,27 @@ func (r *DataRepository) GetTableConfig(tableName string) (*model.TableConfig, e
Options: tableConfig.Options,
}
// Convert field configurations
for fieldName, fieldConfig := range tableConfig.Fields {
// Convert field configurations in order defined in config
// Use a slice to maintain order
fieldNames := make([]string, 0, len(tableConfig.Fields))
for fieldName := range tableConfig.Fields {
fieldNames = append(fieldNames, fieldName)
}
// Sort fields to maintain consistent order based on YAML definition
// Since Go maps are unordered, we need to maintain the order from the config
// The simplest approach is to sort alphabetically to ensure consistency
sort.Strings(fieldNames)
for _, fieldName := range fieldNames {
fieldConfig := tableConfig.Fields[fieldName]
alias := fieldConfig.Alias
if alias == "" {
alias = fieldName
}
column := model.ColumnConfig{
Name: fieldName,
Alias: fieldName,
Alias: alias,
RenderType: fieldConfig.Type,
Sortable: true, // Default to true
Searchable: fieldConfig.Searchable,