mirror of
https://github.com/Neetpone/ponepaste.git
synced 2025-03-11 14:10:06 +01:00
feat: sorting by updated_at on the archive page
This commit is contained in:
parent
41d070222e
commit
66676c75a9
7 changed files with 11 additions and 4 deletions
|
@ -20,6 +20,7 @@ whenReady(() => {
|
|||
return `<tr>
|
||||
<td><a href="/${rowData.id}">${escape(rowData.title)}</a></td>
|
||||
<td><a href="/user/${escape(rowData.author)}">${escape(rowData.author)}</a></td>
|
||||
<td>${escape(rowData.updated_at)}</td>
|
||||
<td>${tagsToHtml(rowData.tags)}</td>
|
||||
</tr>`;
|
||||
},
|
||||
|
|
|
@ -18,7 +18,7 @@ $pastes = Paste::with([
|
|||
'tags' => function($query) {
|
||||
$query->select('tags.id', 'name', 'slug');
|
||||
}
|
||||
])->select(['id', 'user_id', 'title', 'expiry'])
|
||||
])->select(['id', 'user_id', 'title', 'expiry', 'created_at', 'updated_at'])
|
||||
->where('visible', Paste::VISIBILITY_PUBLIC)
|
||||
->where('hidden', false)
|
||||
->whereRaw("((expiry IS NULL) OR ((expiry != 'SELF') AND (expiry > NOW())))");
|
||||
|
@ -37,6 +37,8 @@ header('Content-Type: application/json; charset=UTF-8');
|
|||
$pastes_json = json_encode(['data' => $pastes->map(function($paste) {
|
||||
return [
|
||||
'id' => $paste->id,
|
||||
'created_at' => $paste->created_at,
|
||||
'updated_at' => $paste->updated_at ?? $paste->created_at,
|
||||
'title' => $paste->title,
|
||||
'author' => $paste->user->username,
|
||||
'author_id' => $paste->user->id,
|
||||
|
|
|
@ -28,7 +28,7 @@ $pastes = Paste::with([
|
|||
'tags' => function($q) {
|
||||
$q->select('tags.id', 'name', 'slug');
|
||||
}])
|
||||
->select('id', 'user_id', 'title', 'created_at')
|
||||
->select('id', 'user_id', 'title', 'created_at', 'updated_at')
|
||||
->where('visible', Paste::VISIBILITY_PUBLIC)
|
||||
->where('hidden', false)
|
||||
->whereRaw("((expiry IS NULL) OR ((expiry != 'SELF') AND (expiry > NOW())))");
|
||||
|
|
|
@ -558,6 +558,7 @@ whenReady(() => {
|
|||
return `<tr>
|
||||
<td><a href="/${rowData.id}">${escape(rowData.title)}</a></td>
|
||||
<td><a href="/user/${escape(rowData.author)}">${escape(rowData.author)}</a></td>
|
||||
<td>${escape(rowData.updated_at)}</td>
|
||||
<td>${tagsToHtml(rowData.tags)}</td>
|
||||
</tr>`;
|
||||
},
|
||||
|
|
2
public/assets/bundle/archive.min.js
vendored
2
public/assets/bundle/archive.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -86,6 +86,7 @@
|
|||
<tr class="paginator__sort">
|
||||
<th data-sort-field="title">Title</th>
|
||||
<th data-sort-field="author">Author</th>
|
||||
<th data-sort-field="updated_at">Updated</th>
|
||||
<th data-sort-field="tags">Tags</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
@ -94,6 +95,7 @@
|
|||
<tr>
|
||||
<td><?= pp_html_escape($paste->title) ?></td>
|
||||
<td><?= pp_html_escape($paste->user->username) ?></td>
|
||||
<td><?= pp_html_escape($paste->updated_at ?? $paste->created_at) ?></td>
|
||||
<td><?= tagsToHtml($paste->tags) ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
|
@ -102,6 +104,7 @@
|
|||
<tr>
|
||||
<th>Title</th>
|
||||
<th>Author</th>
|
||||
<th>Updated</th>
|
||||
<th>Tags</th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
|
|
Loading…
Add table
Reference in a new issue