-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
small test with new contaent updates data
- Loading branch information
Showing
6 changed files
with
50 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 11 additions & 8 deletions
19
packages/site/src/routes/[dictionaryId]/history/RecordRow.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,38 @@ | ||
<script lang="ts"> | ||
import type { Change } from '@living-dictionaries/types' | ||
import type { Tables } from '@living-dictionaries/types' | ||
import { getActionValue } from './getActionValue' | ||
import { sortedColumn } from './sortedColumnStore' | ||
import { printDateTime } from '$lib/helpers/time' | ||
import { page } from '$app/stores' | ||
export let record: Change | ||
export let record: Tables<'content_updates'> | ||
const maxNumChar = 50 | ||
const htmlRegex = /<[^>]*>/g | ||
</script> | ||
|
||
<tr> | ||
<td class:font-bold={$sortedColumn === 'entryName'}> | ||
<a class="underline hover:no-underline text-blue-500 visited:text-purple-500" href="entry/{record.entryId}" target="_blank">{record.entryName}</a> | ||
<a class="underline hover:no-underline text-blue-500 visited:text-purple-500" href="entry/{record.entry_id}" target="_blank">{record.id}</a> | ||
</td> | ||
<td class:font-bold={$sortedColumn === 'updatedName'}> | ||
{record.updatedName || ''} | ||
{record.user_id || ''} | ||
</td> | ||
<td class:font-bold={$sortedColumn === 'action'}> | ||
{$page.data.t(`history.${getActionValue(record)}`) || ''} | ||
</td> | ||
<td class:font-bold={$sortedColumn === 'previousValue'}> | ||
<!-- <td class:font-bold={$sortedColumn === 'previousValue'}> | ||
{record.previousValue?.slice(0, maxNumChar).toString().replace(htmlRegex, '') || ''}{#if record.previousValue?.length >= maxNumChar}<a href="entry/{record.entryId}" target="_blank">...</a>{/if} | ||
</td> | ||
<td class:font-bold={$sortedColumn === 'currentValue'}> | ||
{record.currentValue?.slice(0, maxNumChar).toString().replace(htmlRegex, '') || ''}{#if record.currentValue?.length >= maxNumChar}<a href="entry/{record.entryId}" target="_blank">...</a>{/if} | ||
</td> | ||
</td> --> | ||
<td class:font-bold={$sortedColumn === 'field'}> | ||
{$page.data.t(`entry_field.${record.field}`) || ''} | ||
{`${JSON.stringify(record.change.data)}` || ''} | ||
</td> | ||
<td class:font-bold={$sortedColumn === 'type'}> | ||
{`${JSON.stringify(record.change.type)}` || ''} | ||
</td> | ||
<td class:font-bold={$sortedColumn === 'date'}> | ||
{printDateTime(record.updatedAtMs) || ''} | ||
{printDateTime(new Date(record.timestamp)) || ''} | ||
</td> | ||
</tr> |
13 changes: 7 additions & 6 deletions
13
packages/site/src/routes/[dictionaryId]/history/getActionValue.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
import type { Change } from '@living-dictionaries/types' | ||
import type { Tables } from '@living-dictionaries/types' | ||
|
||
export function getActionValue(record: Change): 'created' | 'edited' | 'deleted' { | ||
if (record.previousValue?.length === 0) | ||
return 'created' | ||
else if (record.currentValue?.length === 0) | ||
return 'deleted' | ||
export function getActionValue(record: Tables<'content_updates'>): 'created' | 'edited' | 'deleted' { | ||
console.info(record) | ||
// if (record.previousValue?.length === 0) | ||
// return 'created' | ||
// else if (record.currentValue?.length === 0) | ||
// return 'deleted' | ||
|
||
return 'edited' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters