Skip to content

Commit 84500e2

Browse files
committed
fix a bug in PP and support inline=xxx.* in UI
Signed-off-by: Doug Davis <[email protected]>
1 parent e0ce739 commit 84500e2

File tree

2 files changed

+87
-40
lines changed

2 files changed

+87
-40
lines changed

registry/httpStuff.go

+71-24
Original file line numberDiff line numberDiff line change
@@ -486,17 +486,37 @@ func (pw *PageWriter) Done() {
486486
}
487487

488488
pp, _ := PropPathFromPath(pw.Info.Abstract)
489-
for _, inline := range inlineOptions {
489+
for i, inline := range inlineOptions {
490+
hilight := ""
491+
if i%2 == 0 {
492+
hilight = " inlinehilight"
493+
}
490494
checked = ""
491495
pInline := MustPropPathFromUI(inline)
492-
fullInline := pp.Append(pInline).DB()
493-
if pw.Info.IsInlineSet(fullInline) {
496+
fullPP := pp.Append(pInline)
497+
if pw.Info.IsInlineSet(fullPP.DB()) {
494498
checked = " checked"
495499
}
500+
501+
mini := ""
502+
if (fullPP.Len() != 3 || fullPP.Parts[2].Text == "versions") &&
503+
fullPP.Len() != 4 {
504+
minichecked := ""
505+
if pw.Info.IsInlineSet(fullPP.Append(NewPPP("*")).DB()) {
506+
minichecked = " checked"
507+
}
508+
mini = fmt.Sprintf(`
509+
<div class=minicheckdiv>
510+
<input id=inline%d type='checkbox' class=minicheck value='%s'%s/>.*
511+
</div>`, inlineCount, inline+".*", minichecked)
512+
inlineCount++
513+
}
514+
496515
inlines += fmt.Sprintf(`
497-
<div class=inlines>
498-
<input id=inline%d type='checkbox' value='%s'%s/>%s
499-
</div>`, inlineCount, inline, checked, inline)
516+
<div class='inlines%s'>
517+
<input id=inline%d type='checkbox' value='%s'%s/>%s%s
518+
</div>`, hilight, inlineCount, inline, checked, inline, mini)
519+
500520
inlineCount++
501521

502522
}
@@ -515,9 +535,9 @@ func (pw *PageWriter) Done() {
515535
}
516536

517537
structureswitch := "false"
538+
structureButton := ""
518539
if pw.Info.RootPath == "" || pw.Info.RootPath == "export" {
519540
structuretext := ""
520-
structureButton := ""
521541
if pw.Info.ShowStructure {
522542
structureswitch = "true"
523543
structuretext = "Show document"
@@ -527,14 +547,11 @@ func (pw *PageWriter) Done() {
527547
structuretext = "Show structure"
528548
}
529549
if pw.Info.ResourceUID != "" && pw.Info.What == "Entity" {
530-
structureButton = fmt.Sprintf(`<div>
531-
<button id=structure onclick='structureswitch=!structureswitch ; apply()' style="font-weight:bold">%s</button>
532-
</div>
550+
structureButton = fmt.Sprintf(`<center>
551+
<button id=structure onclick='structureswitch=!structureswitch ; apply()'>%s</button>
552+
</center>
533553
`, structuretext)
534554
}
535-
536-
apply = `
537-
` + structureButton
538555
}
539556

540557
applyBtn := ""
@@ -607,28 +624,39 @@ func (pw *PageWriter) Done() {
607624
align-items: start ;
608625
padding: 2px ;
609626
}
627+
628+
.colorButton, #applyBtn, #structure {
629+
border-radius: 13px ;
630+
border: 1px solid #407d16 ;
631+
background: #407d16 ;
632+
padding: 5 20 6 20 ;
633+
color: white ;
634+
}
635+
610636
#structure {
637+
font-weight: bold ;
611638
display: inline ;
612639
margin-top: 10px ;
613640
margin-bottom: 10px ;
641+
padding: 1 10 2 10 ;
642+
}
643+
#structure:hover { background: #c4c4c4 ; color : black ; }
644+
#structure:active { background: #c4c4c4 ; color : black ; }
645+
#structure:focus { background: darkgray ; color : black ; }
646+
647+
legend {
648+
margin-bottom: 3 ;
614649
}
615650
616651
fieldset {
617-
// padding: 0 ;
618-
border-width: 2 0 0 2 ;
652+
border-width: 1 0 1 1 ;
619653
border-color: black ;
620-
padding: 0 0 0 2 ;
621-
margin-bottom: 10 ;
654+
padding: 0 0 4 4 ;
622655
}
623656
624657
#applyBtn {
625658
font-weight: bold ;
626-
margin: 0 5 0 5 ;
627-
border-radius: 13px ;
628-
border: 1px solid #407d16 ;
629-
background: #407d16 ;
630-
padding: 5 20 6 20 ;
631-
color: white ;
659+
margin: 5 5 0 5 ;
632660
}
633661
634662
#applyBtn:hover { background: #c4c4c4 ; color : black ; }
@@ -663,16 +691,34 @@ func (pw *PageWriter) Done() {
663691
font-family: courier ;
664692
}
665693
.inlines {
694+
display: flex ;
666695
font-size: 13px ;
667696
font-family: courier ;
697+
align-items: center ;
668698
}
699+
700+
.inlinehilight {
701+
background-color : #d0d0d0 ;
702+
}
703+
704+
.minicheckdiv {
705+
margin-left: auto ;
706+
padding: 0 2 0 5 ;
707+
}
708+
709+
.minicheck {
710+
height: 10px ;
711+
width: 10px ;
712+
margin: 0px ;
713+
}
714+
669715
.line {
670716
width: 90%% ;
671717
border-bottom: 1px solid black ;
672718
margin: 3 0 3 20 ;
673719
}
674720
#urlPath {
675-
background-color: lightgray ;
721+
background-color: ghostwhite; // lightgray ;
676722
padding: 3px ;
677723
font-size: 16px ;
678724
font-family: courier ;
@@ -759,6 +805,7 @@ func (pw *PageWriter) Done() {
759805
`+roots+`
760806
<div id=buttonList>
761807
`+applyBtn+`
808+
`+structureButton+`
762809
</div>
763810
<div style="height:12px"></div> <!-- buffer for "Commmit:" line -->
764811
<div id=commit><a target=_blank

registry/info.go

+16-16
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ var nonModelInlines = append([]string{"*"}, explicitInlines...)
4545
var rootPaths = []string{"capabilities", "model", "export"}
4646

4747
type Inline struct {
48-
path string // value from ?inline query param
49-
pp *PropPath // PP for 'value'
50-
nonWild *PropPath // PP for value w/o .* if present, else nil
48+
Path string // value from ?inline query param
49+
PP *PropPath // PP for 'value'
50+
NonWild *PropPath // PP for value w/o .* if present, else nil
5151
}
5252

5353
func (info *RequestInfo) AddInline(path string) error {
@@ -57,9 +57,9 @@ func (info *RequestInfo) AddInline(path string) error {
5757

5858
if ArrayContains(nonModelInlines, path) {
5959
info.Inlines = append(info.Inlines, &Inline{
60-
path: NewPPP(path).DB(),
61-
pp: NewPPP(path),
62-
nonWild: nil,
60+
Path: NewPPP(path).DB(),
61+
PP: NewPPP(path),
62+
NonWild: nil,
6363
})
6464
return nil
6565
}
@@ -70,14 +70,14 @@ func (info *RequestInfo) AddInline(path string) error {
7070
}
7171

7272
storeInline := &Inline{
73-
path: NewPPP(path).DB(),
74-
pp: pp,
75-
nonWild: nil,
73+
Path: pp.DB(),
74+
PP: pp,
75+
NonWild: nil,
7676
}
7777

7878
if pp.Bottom() == "*" {
7979
pp = pp.RemoveLast()
80-
storeInline.nonWild = pp
80+
storeInline.NonWild = pp
8181
}
8282

8383
// Check to make sure the requested inline attribute exists, else error
@@ -109,7 +109,7 @@ func (info *RequestInfo) AddInline(path string) error {
109109

110110
// We have a match, but these don't allow wildcards, so err
111111
// if * was in ?inline value
112-
if storeInline.nonWild != nil {
112+
if storeInline.NonWild != nil {
113113
hasErr = true
114114
break
115115
}
@@ -140,7 +140,7 @@ func (info *RequestInfo) IsInlineSet(entityPath string) bool {
140140
entityPath = "*"
141141
}
142142
for _, inline := range info.Inlines {
143-
if inline.path == entityPath {
143+
if inline.Path == entityPath {
144144
return true
145145
}
146146
}
@@ -156,8 +156,8 @@ func (info *RequestInfo) ShouldInline(entityPath string) bool {
156156
ePP, _ := PropPathFromDB(entityPath) // entity-PP
157157

158158
for _, inline := range info.Inlines {
159-
iPP := inline.pp
160-
log.VPrintf(4, "Inline cmp: %q in %q", entityPath, inline.path)
159+
iPP := inline.PP
160+
log.VPrintf(4, "Inline cmp: %q in %q", entityPath, inline.Path)
161161

162162
// * doesn't include "model"... because they're special, they need to
163163
// be explicit if they want to include those
@@ -171,10 +171,10 @@ func (info *RequestInfo) ShouldInline(entityPath string) bool {
171171
if (iPP.Top() == "*" && !ArrayContains(explicitInlines, ePP.UI())) ||
172172
ePP.Equals(iPP) ||
173173
iPP.HasPrefix(ePP) ||
174-
(inline.nonWild != nil && ePP.HasPrefix(inline.nonWild)) {
174+
(inline.NonWild != nil && ePP.HasPrefix(inline.NonWild)) {
175175
// (iPP.Len() > 1 && iPP.Bottom() == "*" && ePP.HasPrefix(iPP.RemoveLast())) {
176176

177-
log.VPrintf(4, "Inline match: %q in %q", entityPath, inline.path)
177+
log.VPrintf(4, "Inline match: %q in %q", entityPath, inline.Path)
178178
return true
179179
}
180180
}

0 commit comments

Comments
 (0)