evidence-dev / evidence-vscode

The official VS Code extension for Evidence projects.
https://marketplace.visualstudio.com/items?itemName=Evidence.evidence-vscode
MIT License
9 stars 2 forks source link

Create Templated Page from Query does not work without a link column #169

Open archiewood opened 11 months ago

archiewood commented 11 months ago

Steps To Reproduce

  1. create a query categories.sql
SELECT
    category,
    sum(sales) as total_sales
from orders
group by category
  1. run the command, choosing the column category as the identifier
  2. run code

Environment

Expected Behavior

a working datatable to create the links is created

---
title: Categories
sources:
   - categories: categories.sql
---

Click on an item to see more detail

<DataTable data={categories} showLinkCol=true link=category/>

Actual Behaviour

generated code

---
title: Categories
sources:
   - categories: categories.sql
---

Click on an item to see more detail

<DataTable data={categories} link=link/>

There is no link column in the query so this does not work as expected

Workarounds

include a link column in the query

hughess commented 11 months ago

@archiewood won’t the user need to add the link themselves for the page to successfully be created?

one way around this might be to add a chained query to the Templated page and append a link column based on the query name (e.g., items) and column name (e.g., item)

hughess commented 11 months ago

Here's an example of that - where it sets up a chained query to produce the link on the user's behalf:

https://github.com/evidence-dev/evidence-vscode/assets/12602440/a84e5fcc-1ecf-4811-83a2-a46c423f6211