fix: page
This commit is contained in:
@@ -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"`
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user