mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
parent
52a5e95d21
commit
198b8b2955
1 changed files with 19 additions and 15 deletions
|
|
@ -393,7 +393,7 @@ class DatabaseDownload(BaseView):
|
||||||
|
|
||||||
|
|
||||||
class RowTableShared(BaseView):
|
class RowTableShared(BaseView):
|
||||||
async def make_display_rows(self, database, database_hash, table, rows, display_columns, pks, is_view, use_rowid):
|
async def make_display_rows(self, database, database_hash, table, rows, display_columns, pks, is_view, use_rowid, is_row_display):
|
||||||
# Get fancy with foreign keys
|
# Get fancy with foreign keys
|
||||||
expanded = {}
|
expanded = {}
|
||||||
tables = self.ds.inspect()[database]['tables']
|
tables = self.ds.inspect()[database]['tables']
|
||||||
|
|
@ -427,18 +427,22 @@ class RowTableShared(BaseView):
|
||||||
# Unless we are a view, the first column is a link - either to the rowid
|
# Unless we are a view, the first column is a link - either to the rowid
|
||||||
# or to the simple or compound primary key
|
# or to the simple or compound primary key
|
||||||
if not is_view:
|
if not is_view:
|
||||||
display_value = jinja2.Markup(
|
# On row display, only show the extra first column for use_rowid
|
||||||
'<a href="/{database}-{database_hash}/{table}/{flat_pks}">{flat_pks}</a>'.format(
|
if not is_row_display or (is_row_display and use_rowid):
|
||||||
database=database,
|
display_value = path_from_row_pks(row, pks, use_rowid)
|
||||||
database_hash=database_hash,
|
if not is_row_display:
|
||||||
table=urllib.parse.quote_plus(table),
|
display_value = jinja2.Markup(
|
||||||
flat_pks=path_from_row_pks(row, pks, use_rowid),
|
'<a href="/{database}-{database_hash}/{table}/{flat_pks}">{flat_pks}</a>'.format(
|
||||||
)
|
database=database,
|
||||||
)
|
database_hash=database_hash,
|
||||||
cells.append({
|
table=urllib.parse.quote_plus(table),
|
||||||
'column': 'rowid' if use_rowid else 'Link',
|
flat_pks=path_from_row_pks(row, pks, use_rowid),
|
||||||
'value': display_value,
|
)
|
||||||
})
|
)
|
||||||
|
cells.append({
|
||||||
|
'column': 'rowid' if use_rowid else 'Link',
|
||||||
|
'value': display_value,
|
||||||
|
})
|
||||||
|
|
||||||
for value, column in zip(row, display_columns):
|
for value, column in zip(row, display_columns):
|
||||||
if use_rowid and column == 'rowid':
|
if use_rowid and column == 'rowid':
|
||||||
|
|
@ -675,7 +679,7 @@ class TableView(RowTableShared):
|
||||||
'filters': filters,
|
'filters': filters,
|
||||||
'display_columns': display_columns,
|
'display_columns': display_columns,
|
||||||
'filter_columns': filter_columns,
|
'filter_columns': filter_columns,
|
||||||
'display_rows': await self.make_display_rows(name, hash, table, rows, display_columns, pks, is_view, use_rowid),
|
'display_rows': await self.make_display_rows(name, hash, table, rows, display_columns, pks, is_view, use_rowid, is_row_display=False),
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
@ -734,7 +738,7 @@ class RowView(RowTableShared):
|
||||||
'database_hash': hash,
|
'database_hash': hash,
|
||||||
'foreign_key_tables': await self.foreign_key_tables(name, table, pk_values),
|
'foreign_key_tables': await self.foreign_key_tables(name, table, pk_values),
|
||||||
'display_columns': columns,
|
'display_columns': columns,
|
||||||
'display_rows': await self.make_display_rows(name, hash, table, rows, columns, pks, False, use_rowid),
|
'display_rows': await self.make_display_rows(name, hash, table, rows, columns, pks, is_view=False, use_rowid=use_rowid, is_row_display=True),
|
||||||
}
|
}
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue