moved add news button
This commit is contained in:
@@ -457,11 +457,23 @@ $counts['total'] = count($all_contributions);
|
|||||||
<!-- News Article Tab -->
|
<!-- News Article Tab -->
|
||||||
<!-- ========================================================= -->
|
<!-- ========================================================= -->
|
||||||
<div id="tab-news" class="page-tab-content" style="display:none;">
|
<div id="tab-news" class="page-tab-content" style="display:none;">
|
||||||
<div class="tab-header">
|
|
||||||
<h2><i class="fa-solid fa-newspaper"></i> Neuigkeiten</h2>
|
<!-- Filter -->
|
||||||
<button class="btn btn-approve" onclick="createNews()">
|
<div class="filter-tabs" id="news-filter-tabs">
|
||||||
<i class="fa-solid fa-plus"></i> Nachricht hinzufügen
|
<button class="filter-tab active" onclick="filterNewsByStatus('all', this)">
|
||||||
</button>
|
Alle <span class="tab-count"><?= count($news_items) ?></span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Sort Controls -->
|
||||||
|
<div class="sort-controls">
|
||||||
|
<span id="news-visible-count"><?= count($news_items) ?> Neuigkeiten</span>
|
||||||
|
<div style="display:flex;gap:var(--space-sm);align-items:center;">
|
||||||
|
<select onchange="sortNewsRows(this.value)">
|
||||||
|
<option value="date-desc">Neueste zuerst</option>
|
||||||
|
<option value="date-asc">Älteste zuerst</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php if (empty($news_items)): ?>
|
<?php if (empty($news_items)): ?>
|
||||||
@@ -471,7 +483,7 @@ $counts['total'] = count($all_contributions);
|
|||||||
</div>
|
</div>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<?php foreach ($news_items as $news): ?>
|
<?php foreach ($news_items as $news): ?>
|
||||||
<div class="contribution-row" data-id="<?= $news['news_id'] ?>">
|
<div class="contribution-row" data-id="<?= $news['news_id'] ?>" data-date="<?= $news['published_at'] ?>">
|
||||||
<div class="contribution-row-header" onclick="toggleRow(this.parentElement)">
|
<div class="contribution-row-header" onclick="toggleRow(this.parentElement)">
|
||||||
<div class="contribution-row-summary">
|
<div class="contribution-row-summary">
|
||||||
<span class="title"><?= htmlspecialchars($news['title']) ?></span>
|
<span class="title"><?= htmlspecialchars($news['title']) ?></span>
|
||||||
@@ -498,6 +510,12 @@ $counts['total'] = count($all_contributions);
|
|||||||
</div>
|
</div>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<div class="tab-footer-action">
|
||||||
|
<button class="btn btn-approve" onclick="createNews()">
|
||||||
|
<i class="fa-solid fa-plus"></i> Neuigkeit hinzufügen
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -275,7 +275,26 @@ function sortCommentRows(sortBy) {
|
|||||||
|
|
||||||
|
|
||||||
// =====================================================================
|
// =====================================================================
|
||||||
// Block 7: Helper Functions
|
// Block 7: News Filter and Sorting
|
||||||
|
// =====================================================================
|
||||||
|
|
||||||
|
// Sorts News
|
||||||
|
function sortNewsRows(sortBy) {
|
||||||
|
var container = document.getElementById('tab-news');
|
||||||
|
var rows = Array.from(container.querySelectorAll('.contribution-row'));
|
||||||
|
|
||||||
|
rows.sort(function (a, b) {
|
||||||
|
if (sortBy === 'date-desc') return new Date(b.dataset.date || 0) - new Date(a.dataset.date || 0);
|
||||||
|
if (sortBy === 'date-asc') return new Date(a.dataset.date || 0) - new Date(b.dataset.date || 0);
|
||||||
|
return 0;
|
||||||
|
});
|
||||||
|
|
||||||
|
rows.forEach(function (row) { row.parentNode.appendChild(row); });
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// =====================================================================
|
||||||
|
// Block 8: Helper Functions
|
||||||
// =====================================================================
|
// =====================================================================
|
||||||
|
|
||||||
// Sends a POST request to API
|
// Sends a POST request to API
|
||||||
@@ -301,7 +320,7 @@ function escapeHtml(text) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// =====================================================================
|
// =====================================================================
|
||||||
// Block 8: CRUD Operations for Contributions
|
// Block 9: CRUD Operations for Contributions
|
||||||
// =====================================================================
|
// =====================================================================
|
||||||
|
|
||||||
// STATUS: Changes Contribution Status
|
// STATUS: Changes Contribution Status
|
||||||
@@ -406,7 +425,7 @@ function deleteContribution(contributionId) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// =====================================================================
|
// =====================================================================
|
||||||
// Block 9: CRUD Operations for Comments
|
// Block 10: CRUD Operations for Comments
|
||||||
// =====================================================================
|
// =====================================================================
|
||||||
|
|
||||||
// STATUS: Changes Comment Status
|
// STATUS: Changes Comment Status
|
||||||
@@ -501,7 +520,7 @@ function deleteModComment(commentId) {
|
|||||||
|
|
||||||
|
|
||||||
// =====================================================================
|
// =====================================================================
|
||||||
// Block 10: CRUD Operations for News
|
// Block 11: CRUD Operations for News
|
||||||
// =====================================================================
|
// =====================================================================
|
||||||
|
|
||||||
// CREATE: Submits new News Article
|
// CREATE: Submits new News Article
|
||||||
|
|||||||
@@ -1374,6 +1374,12 @@ select.form-input { cursor: pointer; }
|
|||||||
border-top: 1px solid #f0f0f0;
|
border-top: 1px solid #f0f0f0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.tab-footer-action {
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-end;
|
||||||
|
margin-top: var(--space-md);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* News and Comments Tab Headers */
|
/* News and Comments Tab Headers */
|
||||||
.tab-header {
|
.tab-header {
|
||||||
|
|||||||
Reference in New Issue
Block a user