Skip to content

Commit

Permalink
Separate aliases from fields in UI (#529)
Browse files Browse the repository at this point in the history
  • Loading branch information
pivovarit authored Jul 14, 2024
1 parent 11f56ec commit 4dd7dba
Showing 1 changed file with 20 additions and 22 deletions.
42 changes: 20 additions & 22 deletions quesma/quesma/ui/schemas.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,9 @@ func (qmc *QuesmaManagementConsole) generateSchemas() []byte {
buffer.Html(`</h2></th>`)
buffer.Html(`</tr>`)
buffer.Html(`<tr>`)
buffer.Html(`<th>`)
buffer.Html(`Public Name`)
buffer.Html(`</th>`)
buffer.Html(`<th>`)
buffer.Html(`Internal Name`)
buffer.Html(`</th>`)
buffer.Html(`<th>`)
buffer.Html(`Type`)
buffer.Html(`</th>`)
buffer.Html(`<th>Public Name</th>`)
buffer.Html(`<th>Internal Name</th>`)
buffer.Html(`<th>Type</th>`)
buffer.Html(`</tr>`)

for _, fieldName := range util.MapKeysSorted(schema.Fields) {
Expand All @@ -55,19 +49,23 @@ func (qmc *QuesmaManagementConsole) generateSchemas() []byte {
buffer.Html(`</tr>`)
}

for _, aliasFieldName := range util.MapKeysSorted(schema.Aliases) {
targetFieldName := schema.Aliases[aliasFieldName]
buffer.Html(`<tr>`)
buffer.Html(`<td>`)
buffer.Text("-")
buffer.Html(`</td>`)
buffer.Html(`<td>`)
buffer.Text(fmt.Sprintf("%s->%s", aliasFieldName.AsString(), targetFieldName.AsString()))
buffer.Html(`</td>`)
buffer.Html(`<td>`)
field := schema.Fields[targetFieldName]
buffer.Text(fmt.Sprintf("%s %s", field.Type.Name, field.Type.Properties))
buffer.Html(`</td>`)
if len(schema.Aliases) > 0 {
buffer.Html(`<th colspan=3><h4>Aliases</h4></th>`)

for _, aliasFieldName := range util.MapKeysSorted(schema.Aliases) {
targetFieldName := schema.Aliases[aliasFieldName]
buffer.Html(`<tr>`)
buffer.Html(`<td>`)
buffer.Text(fmt.Sprintf("%s->%s", aliasFieldName.AsString(), targetFieldName.AsString()))
buffer.Html(`</td>`)
buffer.Html(`<td>`)
buffer.Text("-")
buffer.Html(`</td>`)
buffer.Html(`<td>`)
field := schema.Fields[targetFieldName]
buffer.Text(fmt.Sprintf("%s %s", field.Type.Name, field.Type.Properties))
buffer.Html(`</td>`)
}
}
}

Expand Down

0 comments on commit 4dd7dba

Please sign in to comment.