Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Engineering Digital Service
Metabase
Commits
bc264fb4
Unverified
Commit
bc264fb4
authored
7 years ago
by
Tom Robinson
Browse files
Options
Downloads
Patches
Plain Diff
Right align lat/lon. Add tests
parent
766f7537
Loading
Loading
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
frontend/src/metabase/visualizations/lib/table.js
+6
-2
6 additions, 2 deletions
frontend/src/metabase/visualizations/lib/table.js
frontend/src/metabase/visualizations/lib/table.spec.js
+22
-1
22 additions, 1 deletion
frontend/src/metabase/visualizations/lib/table.spec.js
with
28 additions
and
3 deletions
frontend/src/metabase/visualizations/lib/table.js
+
6
−
2
View file @
bc264fb4
...
...
@@ -2,7 +2,7 @@
import
type
{
DatasetData
,
Column
}
from
"
metabase/meta/types/Dataset
"
;
import
type
{
ClickObject
}
from
"
metabase/meta/types/Visualization
"
;
import
{
isNumber
}
from
"
metabase/lib/schema_metadata
"
;
import
{
isNumber
,
isCoordinate
}
from
"
metabase/lib/schema_metadata
"
;
export
function
getTableCellClickedObject
(
data
:
DatasetData
,
rowIndex
:
number
,
columnIndex
:
number
,
isPivoted
:
boolean
):
ClickObject
{
const
{
rows
,
cols
}
=
data
;
...
...
@@ -37,6 +37,10 @@ export function getTableCellClickedObject(data: DatasetData, rowIndex: number, c
}
}
/*
* Returns whether the column should be right-aligned in a table.
* Includes numbers and lat/lon coordinates, but not zip codes, IDs, etc.
*/
export
function
isColumnRightAligned
(
column
:
Column
)
{
return
isNumber
(
column
);
return
isNumber
(
column
)
||
isCoordinate
(
column
)
;
}
This diff is collapsed.
Click to expand it.
frontend/src/metabase/visualizations/lib/table.spec.js
+
22
−
1
View file @
bc264fb4
import
{
getTableCellClickedObject
}
from
"
./table
"
;
import
{
getTableCellClickedObject
,
isColumnRightAligned
}
from
"
./table
"
;
import
{
TYPE
}
from
"
metabase/lib/types
"
;
const
RAW_COLUMN
=
{
source
:
"
fields
"
...
...
@@ -40,4 +41,24 @@ describe("metabase/visualization/lib/table", () => {
// TODO:
})
})
describe
(
"
isColumnRightAligned
"
,
()
=>
{
it
(
"
should return true for numeric columns without a special type
"
,
()
=>
{
expect
(
isColumnRightAligned
({
base_type
:
TYPE
.
Integer
})).
toBe
(
true
);
});
it
(
"
should return true for numeric columns with special type Number
"
,
()
=>
{
expect
(
isColumnRightAligned
({
base_type
:
TYPE
.
Integer
,
special_type
:
TYPE
.
Number
})).
toBe
(
true
);
});
it
(
"
should return true for numeric columns with special type latitude or longitude
"
,
()
=>
{
expect
(
isColumnRightAligned
({
base_type
:
TYPE
.
Integer
,
special_type
:
TYPE
.
Latitude
})).
toBe
(
true
);
expect
(
isColumnRightAligned
({
base_type
:
TYPE
.
Integer
,
special_type
:
TYPE
.
Longitude
})).
toBe
(
true
);
});
it
(
"
should return false for numeric columns with special type zip code
"
,
()
=>
{
expect
(
isColumnRightAligned
({
base_type
:
TYPE
.
Integer
,
special_type
:
TYPE
.
ZipCode
})).
toBe
(
false
)
});
it
(
"
should return false for numeric columns with special type FK or PK
"
,
()
=>
{
expect
(
isColumnRightAligned
({
base_type
:
TYPE
.
Integer
,
special_type
:
TYPE
.
FK
})).
toBe
(
false
);
expect
(
isColumnRightAligned
({
base_type
:
TYPE
.
Integer
,
special_type
:
TYPE
.
FK
})).
toBe
(
false
);
});
})
})
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment