Skip to content

Commit

Permalink
Handle rank sometimes being sent as empty string (#105)
Browse files Browse the repository at this point in the history
Optional informative text (not to be included in commit message) relevant to reviewers.
  • Loading branch information
DnlLrssn authored Sep 9, 2020
1 parent 8db28e4 commit 334f172
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
3 changes: 1 addition & 2 deletions scenario/createsheet.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ type (
ID string `json:"id" displayname:"Sheet ID" doc-key:"createsheet.id"`
Title string `json:"title" displayname:"Sheet title" doc-key:"createsheet.title"`
Description string `json:"description" displayname:"Sheet description" doc-key:"createsheet.description"`
// todo add option to change sheet to this sheet after creation, should probably be default
}
)

Expand Down Expand Up @@ -46,12 +45,12 @@ func (settings CreateSheetSettings) Execute(sessionState *session.State,
}

metaDef := creation.StubMetaDef(settings.Title, settings.Description)
metaDef["rank"] = 0.0 //TODO (?) Support rank

props := map[string]interface{}{
"qMetaDef": metaDef,
"qInfo": creation.StubNxInfo("sheet"),
"cells": []interface{}{},
"rank": 0.0,
}

err := sessionState.SendRequest(actionState, func(ctx context.Context) error {
Expand Down
16 changes: 12 additions & 4 deletions senseobjects/sheetlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ type (
Name string `json:"name,omitempty"`
Type string `json:"type,omitempty"`
} `json:"cells,omitempty"`
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
Rank float64 `json:"rank,omitempty"`
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
Rank interface{} `json:"rank,omitempty"`
}

// SheetListPropertiesData properties of sheetlist
Expand Down Expand Up @@ -94,7 +94,15 @@ func (sheetList *SheetList) UpdateLayout(ctx context.Context) error {
if item1 == nil || item2 == nil || item1.Data == nil || item2.Data == nil {
return false
}
return sheetItems[i].Data.Rank < sheetItems[j].Data.Rank
iRank, ok := sheetItems[i].Data.Rank.(float64)
if !ok {
iRank = 0
}
jRank, ok := sheetItems[j].Data.Rank.(float64)
if !ok {
jRank = 0
}
return iRank < jRank
})
}

Expand Down

0 comments on commit 334f172

Please sign in to comment.