Skip to content

Commit 763c129

Browse files
committed
fix a bug with export and move apply btn
Signed-off-by: Doug Davis <[email protected]>
1 parent 1b5b19e commit 763c129

File tree

2 files changed

+31
-18
lines changed

2 files changed

+31
-18
lines changed

registry/entity.go

+8-3
Original file line numberDiff line numberDiff line change
@@ -1012,7 +1012,9 @@ var OrderedSpecProps = []*Attribute{
10121012
}
10131013

10141014
if e.Type == ENTITY_RESOURCE || e.Type == ENTITY_VERSION {
1015-
meta := info != nil && (info.ShowStructure || info.ResourceUID == "" || len(info.Parts) == 5)
1015+
meta := info != nil && (info.ShowStructure ||
1016+
info.HasFlag("export") ||
1017+
info.ResourceUID == "" || len(info.Parts) == 5)
10161018
_, rm := e.GetModels()
10171019
if rm.GetHasDocument() == false {
10181020
meta = false
@@ -1045,7 +1047,9 @@ var OrderedSpecProps = []*Attribute{
10451047
base = info.BaseURL
10461048
}
10471049
if e.Type == ENTITY_RESOURCE || e.Type == ENTITY_VERSION {
1048-
meta := info != nil && (info.ShowStructure || info.ResourceUID == "" || len(info.Parts) == 5)
1050+
meta := info != nil && (info.ShowStructure ||
1051+
info.HasFlag("export") ||
1052+
info.ResourceUID == "" || len(info.Parts) == 5)
10491053
_, rm := e.GetModels()
10501054
if rm.GetHasDocument() == false {
10511055
meta = false
@@ -1451,7 +1455,8 @@ var OrderedSpecProps = []*Attribute{
14511455

14521456
tmp := base + "/" + rPath + "/versions/" + val.(string)
14531457

1454-
meta := info != nil && (info.ShowStructure || info.ResourceUID == "")
1458+
meta := info != nil && (info.ShowStructure ||
1459+
info.HasFlag("export") || info.ResourceUID == "")
14551460
_, rm := e.GetModels()
14561461
if rm.GetHasDocument() == false {
14571462
meta = false

registry/httpStuff.go

+23-15
Original file line numberDiff line numberDiff line change
@@ -356,8 +356,8 @@ func (pw *PageWriter) Done() {
356356
if pw.Info.RootPath == r.u {
357357
name = "<b>" + name + "</b>"
358358
}
359-
roots += fmt.Sprintf(" <li><a href=\"%s?ui\">%s</a>\n",
360-
pw.Info.BaseURL+"/"+r.u+"</li>", name)
359+
roots += fmt.Sprintf(" <li><a href=\"%s?ui\">%s</a></li>\n",
360+
pw.Info.BaseURL+"/"+r.u, name)
361361
}
362362

363363
if pw.Info.RootPath == "" {
@@ -527,17 +527,19 @@ func (pw *PageWriter) Done() {
527527
structuretext = "Show structure"
528528
}
529529
if pw.Info.ResourceUID != "" && pw.Info.What == "Entity" {
530-
structureButton = fmt.Sprintf(`
531-
<div><button id=structure onclick='structureswitch=!structureswitch ; apply()' style="font-weight:bold">%s</button></div>
530+
structureButton = fmt.Sprintf(`<div>
531+
<button id=structure onclick='structureswitch=!structureswitch ; apply()' style="font-weight:bold">%s</button>
532+
</div>
532533
`, structuretext)
533534
}
534535

535536
apply = `
536-
<hr style="width:100%% ; margin-top:15px ; margin-bottom:15px">
537-
<div style="display:ruby">
538-
<button onclick="apply()" style="font-weight:bold">Apply</button>` +
539-
structureButton + `
540-
</div>`
537+
` + structureButton
538+
}
539+
540+
applyBtn := ""
541+
if options != "" || filters != "" || inlines != "" {
542+
applyBtn = "<button id=applyBtn onclick='apply()'>Apply</button>"
541543
}
542544

543545
pw.OldWriter.Write([]byte(fmt.Sprintf(`<html>
@@ -592,6 +594,7 @@ func (pw *PageWriter) Done() {
592594
display: flex ;
593595
flex-direction: column ;
594596
align-items: start ;
597+
margin-top: -15 ;
595598
}
596599
#buttonBar {
597600
background-color: lightsteelblue;
@@ -602,8 +605,17 @@ func (pw *PageWriter) Done() {
602605
}
603606
#structure {
604607
display: inline ;
608+
margin-top: 10px ;
605609
margin-bottom: 10px ;
606610
}
611+
612+
#applyBtn {
613+
font-weight: bold ;
614+
align-self: end ;
615+
position: relative ;
616+
top: 20 ;
617+
}
618+
607619
#commit {
608620
background-color: lightsteelblue ;
609621
font-size: 12px ;
@@ -727,6 +739,7 @@ func (pw *PageWriter) Done() {
727739
<hr>
728740
`+roots+`
729741
<div id=buttonList>
742+
`+applyBtn+`
730743
`+options+`
731744
`+filters+`
732745
`+inlines+`
@@ -1171,16 +1184,11 @@ func HTTPGet(info *RequestInfo) error {
11711184
return SerializeQuery(info, nil, "Registry", info.Filters)
11721185
}
11731186

1174-
// Might need to check other flags, but if we're exporting, it makes
1175-
// no sense to show just the resource contents
1176-
if info.HasFlag("export") {
1177-
info.ShowStructure = true
1178-
}
1179-
11801187
// 'metaInBody' tells us whether xReg metadata should be in the http
11811188
// response body or not (meaning, the hasDoc doc)
11821189
metaInBody := (info.ResourceModel == nil) ||
11831190
(info.ResourceModel.GetHasDocument() == false || info.ShowStructure ||
1191+
info.HasFlag("export") ||
11841192
(len(info.Parts) == 5 && info.Parts[4] == "meta"))
11851193

11861194
// Return the Resource's document

0 commit comments

Comments
 (0)