402 lines
23 KiB
HTML
402 lines
23 KiB
HTML
{{template "base" .}}
|
|
|
|
{{define "content"}}
|
|
<div class="d-flex justify-content-between align-items-center mb-3">
|
|
<h4 class="mb-0 fw-bold"><i class="bi bi-list-task me-2" aria-hidden="true"></i>課題一覧</h4>
|
|
<div class="d-flex gap-2">
|
|
<button class="btn btn-sm btn-secondary text-white" onclick="toggleCountdown()" id="toggleCountdownBtn" aria-pressed="false">
|
|
<i class="bi bi-clock me-1" aria-hidden="true"></i><span id="countdownBtnText">カウントダウンを非表示</span>
|
|
</button>
|
|
<a href="/assignments/new" class="btn btn-sm btn-primary">
|
|
<i class="bi bi-plus-lg me-1" aria-hidden="true"></i>新規登録
|
|
</a>
|
|
</div>
|
|
</div>
|
|
|
|
<ul class="nav nav-tabs border-0 mb-2" id="assignmentTabs" role="tablist">
|
|
<li class="nav-item" role="presentation">
|
|
<a class="nav-link py-2 rounded-0 {{if eq .filter "pending"}}fw-bold border-bottom border-dark border-3 text-dark{{else}}border-0 text-muted{{end}}"
|
|
href="/assignments?filter=pending&q={{.query}}&priority={{.priority}}">未完了</a>
|
|
</li>
|
|
<li class="nav-item" role="presentation">
|
|
<a class="nav-link py-2 rounded-0 {{if eq .filter "due_today"}}fw-bold border-bottom border-dark border-3 text-dark{{else}}border-0 text-muted{{end}}"
|
|
href="/assignments?filter=due_today&q={{.query}}&priority={{.priority}}">今日が期限</a>
|
|
</li>
|
|
<li class="nav-item" role="presentation">
|
|
<a class="nav-link py-2 rounded-0 {{if eq .filter "due_this_week"}}fw-bold border-bottom border-dark border-3 text-dark{{else}}border-0 text-muted{{end}}"
|
|
href="/assignments?filter=due_this_week&q={{.query}}&priority={{.priority}}">今週が期限</a>
|
|
</li>
|
|
<li class="nav-item" role="presentation">
|
|
<a class="nav-link py-2 rounded-0 {{if eq .filter "completed"}}fw-bold border-bottom border-dark border-3 text-dark{{else}}border-0 text-muted{{end}}"
|
|
href="/assignments?filter=completed&q={{.query}}&priority={{.priority}}">完了済み</a>
|
|
</li>
|
|
<li class="nav-item" role="presentation">
|
|
<a class="nav-link py-2 rounded-0 {{if eq .filter "overdue"}}fw-bold border-bottom border-dark border-3 text-dark{{else}}border-0 text-muted{{end}}"
|
|
href="/assignments?filter=overdue&q={{.query}}&priority={{.priority}}">期限切れ</a>
|
|
</li>
|
|
<li class="nav-item ms-auto" role="presentation">
|
|
<a class="nav-link py-2 rounded-0 border-0 text-muted" href="/recurring">
|
|
<i class="bi bi-arrow-repeat me-1" aria-hidden="true"></i>繰り返し管理
|
|
</a>
|
|
</li>
|
|
</ul>
|
|
<hr class="mt-0 mb-3 text-muted" style="opacity: 0.1;">
|
|
|
|
<form action="/assignments" method="GET" class="row g-2 mb-3 align-items-center" role="search">
|
|
<input type="hidden" name="filter" value="{{.filter}}">
|
|
<div class="col-md-5">
|
|
<div class="input-group input-group-sm">
|
|
<span class="input-group-text bg-white border-end-0 text-muted"><i class="bi bi-search" aria-hidden="true"></i></span>
|
|
<label for="searchInput" class="visually-hidden">課題を検索</label>
|
|
<input type="text" class="form-control border-start-0 ps-0 bg-white" id="searchInput" name="q" placeholder="検索..." value="{{.query}}">
|
|
</div>
|
|
</div>
|
|
<div class="col-md-4">
|
|
<label for="priorityFilter" class="visually-hidden">重要度で絞り込み</label>
|
|
<select class="form-select form-select-sm bg-white" id="priorityFilter" name="priority" onchange="this.form.submit()">
|
|
<option value="">全ての重要度</option>
|
|
<option value="high" {{if eq .priority "high" }}selected{{end}}>高</option>
|
|
<option value="medium" {{if eq .priority "medium"}}selected{{end}}>中</option>
|
|
<option value="low" {{if eq .priority "low" }}selected{{end}}>低</option>
|
|
</select>
|
|
</div>
|
|
<div class="col-md-3">
|
|
<a href="/assignments?filter={{.filter}}" class="btn btn-sm btn-outline-secondary w-100 bg-white">クリア</a>
|
|
</div>
|
|
</form>
|
|
|
|
<div class="card shadow-sm border-0 rounded-0">
|
|
<div class="card-body p-0">
|
|
<div class="table-responsive">
|
|
<table class="table table-hover align-middle mb-0 custom-table" aria-label="課題一覧">
|
|
<thead class="bg-secondary-subtle">
|
|
<tr>
|
|
<th scope="col" style="width: 50px;" class="ps-3 text-center text-dark fw-bold">状態</th>
|
|
<th scope="col" style="width: 120px;" class="text-dark fw-bold">科目</th>
|
|
<th scope="col" style="width: 80px;" class="text-dark fw-bold">重要度</th>
|
|
<th scope="col" class="text-dark fw-bold">タイトル</th>
|
|
<th scope="col" style="width: 140px;" class="text-dark fw-bold">期限</th>
|
|
<th scope="col" style="width: 120px;" class="countdown-col text-dark fw-bold">残り</th>
|
|
<th scope="col" style="width: 80px;" class="text-end pe-3 text-dark fw-bold">操作</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{{range .assignments}}
|
|
<tr class="assignment-row border-bottom" data-due-ts="{{.DueDate.Unix}}" data-completed="{{.IsCompleted}}">
|
|
<td class="ps-3 text-center">
|
|
{{if .IsCompleted}}
|
|
<form action="/assignments/{{.ID}}/toggle" method="POST" class="d-inline">
|
|
<input type="hidden" name="_csrf" value="{{$.csrfToken}}">
|
|
<button type="submit" class="btn btn-link p-0 text-success text-decoration-none btn-touch" aria-label="未完了に戻す">
|
|
<i class="bi bi-check-circle-fill" aria-hidden="true"></i>
|
|
</button>
|
|
</form>
|
|
{{else}}
|
|
<form action="/assignments/{{.ID}}/toggle" method="POST" class="d-inline">
|
|
<input type="hidden" name="_csrf" value="{{$.csrfToken}}">
|
|
<button type="submit" class="btn btn-link p-0 text-secondary text-decoration-none btn-touch" aria-label="完了にする">
|
|
<i class="bi bi-circle" aria-hidden="true"></i>
|
|
</button>
|
|
</form>
|
|
{{end}}
|
|
</td>
|
|
<td><span class="badge bg-secondary text-white border-0 fw-bold">{{.Subject}}</span></td>
|
|
<td>
|
|
{{if eq .Priority "high"}}
|
|
<span class="badge bg-danger text-white border-0 fw-bold small">高<span class="visually-hidden">(重要度:高)</span></span>
|
|
{{else if eq .Priority "medium"}}
|
|
<span class="badge bg-warning text-dark border-0 fw-bold small">中<span class="visually-hidden">(重要度:中)</span></span>
|
|
{{else}}
|
|
<span class="badge bg-dark text-white border-0 fw-bold small">低<span class="visually-hidden">(重要度:低)</span></span>
|
|
{{end}}
|
|
</td>
|
|
<td>
|
|
<div class="d-flex align-items-center">
|
|
<div class="fw-bold text-dark text-truncate" style="max-width: 280px;">{{.Title}}</div>
|
|
{{if .RecurringAssignmentID}}
|
|
<button type="button" class="btn btn-link p-0 ms-2 text-info btn-touch" data-bs-toggle="modal"
|
|
data-bs-target="#recurringModal"
|
|
data-recurring-id="{{.RecurringAssignmentID}}"
|
|
data-assignment-id="{{.ID}}"
|
|
data-recurring-title="{{.Title}}"
|
|
data-recurring-type="{{if .RecurringAssignment}}{{.RecurringAssignment.RecurrenceType}}{{else}}unknown{{end}}"
|
|
data-recurring-active="{{if .RecurringAssignment}}{{.RecurringAssignment.IsActive}}{{else}}true{{end}}"
|
|
aria-label="繰り返し設定を表示">
|
|
<i class="bi bi-repeat" aria-hidden="true"></i>
|
|
</button>
|
|
{{end}}
|
|
</div>
|
|
</td>
|
|
<td>
|
|
<div class="small fw-bold text-dark user-select-all">{{.DueDate.Format "2006/01/02 15:04"}}</div>
|
|
{{if .SoftDueDate}}<div class="small text-info" title="自分の期限"><i class="bi bi-clock-history me-1" aria-hidden="true"></i>{{.SoftDueDate.Format "01/02 15:04"}}</div>{{end}}
|
|
</td>
|
|
<td class="countdown-col">
|
|
{{if not .IsCompleted}}
|
|
<span class="countdown small fw-bold font-monospace text-dark" aria-live="off">...</span>
|
|
{{else}}
|
|
<span class="text-secondary small fw-bold">-</span>
|
|
{{end}}
|
|
</td>
|
|
<td class="text-end pe-3">
|
|
<div class="d-flex justify-content-end gap-2">
|
|
<a href="/assignments/{{.ID}}/edit" class="text-primary text-decoration-none btn-touch d-inline-flex align-items-center" aria-label="編集">
|
|
<i class="bi bi-pencil-fill" aria-hidden="true"></i>
|
|
</a>
|
|
{{if .RecurringAssignment}}
|
|
<button type="button" class="btn btn-link p-0 text-danger text-decoration-none border-0 bg-transparent btn-touch" onclick="showDeleteRecurringModal({{.ID}}, {{.RecurringAssignmentID}})" aria-label="削除">
|
|
<i class="bi bi-trash-fill" aria-hidden="true"></i>
|
|
</button>
|
|
{{else}}
|
|
<form action="/assignments/{{.ID}}/delete" method="POST" class="d-inline" data-confirm="削除しますか?">
|
|
<input type="hidden" name="_csrf" value="{{$.csrfToken}}">
|
|
<button type="submit" class="btn btn-link p-0 text-danger text-decoration-none border-0 bg-transparent btn-touch" aria-label="削除">
|
|
<i class="bi bi-trash-fill" aria-hidden="true"></i>
|
|
</button>
|
|
</form>
|
|
{{end}}
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
{{else}}
|
|
<tr>
|
|
<td colspan="7" class="text-center py-5">
|
|
<i class="bi bi-inbox display-4 text-muted" aria-hidden="true"></i>
|
|
<p class="mt-2 mb-1 text-muted fw-bold">課題がありません</p>
|
|
<a href="/assignments/new" class="btn btn-sm btn-primary mt-1">
|
|
<i class="bi bi-plus-lg me-1" aria-hidden="true"></i>課題を登録する
|
|
</a>
|
|
</td>
|
|
</tr>
|
|
{{end}}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
{{if gt .totalPages 1}}
|
|
<div class="card-footer bg-white border-top-0 py-2">
|
|
<nav aria-label="ページナビゲーション">
|
|
<ul class="pagination pagination-sm justify-content-center mb-0">
|
|
<li class="page-item {{if not .hasPrev}}disabled{{end}}">
|
|
<a class="page-link border-0 text-secondary" href="/assignments?page={{.prevPage}}&filter={{.filter}}&q={{.query}}&priority={{.priority}}" aria-label="前のページ">
|
|
<i class="bi bi-chevron-left" aria-hidden="true"></i>
|
|
</a>
|
|
</li>
|
|
<li class="page-item disabled">
|
|
<span class="page-link border-0 text-dark fw-bold" aria-current="page">{{.currentPage}} / {{.totalPages}}</span>
|
|
</li>
|
|
<li class="page-item {{if not .hasNext}}disabled{{end}}">
|
|
<a class="page-link border-0 text-secondary" href="/assignments?page={{.nextPage}}&filter={{.filter}}&q={{.query}}&priority={{.priority}}" aria-label="次のページ">
|
|
<i class="bi bi-chevron-right" aria-hidden="true"></i>
|
|
</a>
|
|
</li>
|
|
</ul>
|
|
</nav>
|
|
</div>
|
|
{{end}}
|
|
</div>
|
|
|
|
<script>
|
|
var _countdownInterval = null;
|
|
|
|
function updateCountdowns() {
|
|
var now = new Date();
|
|
var hasUnder24h = false;
|
|
|
|
document.querySelectorAll('.assignment-row').forEach(function(row) {
|
|
if (row.getAttribute('data-completed') === 'true') return;
|
|
var dueTs = row.getAttribute('data-due-ts');
|
|
if (!dueTs) return;
|
|
var due = new Date(parseInt(dueTs) * 1000);
|
|
if (isNaN(due.getTime())) return;
|
|
|
|
var diff = due - now;
|
|
var countdownEl = row.querySelector('.countdown');
|
|
|
|
row.classList.remove('anxiety-danger', 'anxiety-warning', 'bg-danger-subtle');
|
|
if (countdownEl) countdownEl.className = 'countdown small fw-bold font-monospace';
|
|
|
|
if (diff < 0) {
|
|
if (countdownEl) {
|
|
countdownEl.textContent = '期限切れ';
|
|
countdownEl.classList.add('text-danger');
|
|
}
|
|
row.classList.add('bg-danger-subtle');
|
|
return;
|
|
}
|
|
|
|
var days = Math.floor(diff / 86400000);
|
|
var hours = Math.floor((diff % 86400000) / 3600000);
|
|
var minutes = Math.floor((diff % 3600000) / 60000);
|
|
var seconds = Math.floor((diff % 60000) / 1000);
|
|
var remainingHours = days * 24 + hours;
|
|
|
|
var text = (days > 0 ? days + '日 ' : '') +
|
|
String(hours).padStart(2, '0') + ':' +
|
|
String(minutes).padStart(2, '0') + ':' +
|
|
String(seconds).padStart(2, '0');
|
|
|
|
if (countdownEl) countdownEl.textContent = text;
|
|
|
|
if (remainingHours < 24) {
|
|
hasUnder24h = true;
|
|
row.classList.add('anxiety-danger');
|
|
if (countdownEl) {
|
|
countdownEl.classList.add('text-danger', 'countdown-urgent');
|
|
countdownEl.innerHTML = '<i class="bi bi-exclamation-triangle-fill me-1" aria-hidden="true"></i>' + text;
|
|
}
|
|
} else if (days < 7) {
|
|
row.classList.add('anxiety-warning');
|
|
if (countdownEl) {
|
|
countdownEl.classList.add('text-dark');
|
|
countdownEl.innerHTML = '<i class="bi bi-exclamation-triangle-fill text-warning me-1" aria-hidden="true"></i>' + text;
|
|
}
|
|
} else {
|
|
if (countdownEl) countdownEl.classList.add('text-secondary');
|
|
}
|
|
});
|
|
|
|
scheduleNextUpdate(hasUnder24h);
|
|
}
|
|
|
|
function scheduleNextUpdate(hasUnder24h) {
|
|
if (_countdownInterval !== null) return;
|
|
var interval = hasUnder24h ? 1000 : 60000;
|
|
_countdownInterval = setTimeout(function() {
|
|
_countdownInterval = null;
|
|
updateCountdowns();
|
|
}, interval);
|
|
}
|
|
|
|
function toggleCountdown() {
|
|
var cols = document.querySelectorAll('.countdown-col');
|
|
var btn = document.getElementById('toggleCountdownBtn');
|
|
var btnText = document.getElementById('countdownBtnText');
|
|
var isHidden = cols[0] && cols[0].style.display === 'none';
|
|
|
|
cols.forEach(function(col) { col.style.display = isHidden ? '' : 'none'; });
|
|
|
|
var nowHidden = !isHidden;
|
|
btnText.textContent = nowHidden ? 'カウントダウンを表示' : 'カウントダウンを非表示';
|
|
btn.setAttribute('aria-pressed', nowHidden ? 'true' : 'false');
|
|
localStorage.setItem('countdownHidden', nowHidden);
|
|
}
|
|
|
|
updateCountdowns();
|
|
|
|
if (localStorage.getItem('countdownHidden') === 'true') {
|
|
document.querySelectorAll('.countdown-col').forEach(function(col) { col.style.display = 'none'; });
|
|
var btn = document.getElementById('toggleCountdownBtn');
|
|
var btnText = document.getElementById('countdownBtnText');
|
|
if (btnText) btnText.textContent = 'カウントダウンを表示';
|
|
if (btn) btn.setAttribute('aria-pressed', 'true');
|
|
}
|
|
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
var recurringModal = document.getElementById('recurringModal');
|
|
if (recurringModal) {
|
|
recurringModal.addEventListener('show.bs.modal', function(event) {
|
|
var button = event.relatedTarget;
|
|
var id = button.getAttribute('data-recurring-id');
|
|
var title = button.getAttribute('data-recurring-title');
|
|
var type = button.getAttribute('data-recurring-type');
|
|
var isActive = button.getAttribute('data-recurring-active') === 'true';
|
|
|
|
document.getElementById('recurringModalTitle').textContent = title;
|
|
document.getElementById('recurringStopForm').action = '/recurring/' + id + '/stop';
|
|
document.getElementById('recurringEditBtn').href = '/recurring/' + id + '/edit';
|
|
|
|
var typeLabels = { daily: '毎日', weekly: '毎週', monthly: '毎月', unknown: '(不明)' };
|
|
document.getElementById('recurringTypeLabel').textContent = typeLabels[type] || type || '不明';
|
|
|
|
var statusEl = document.getElementById('recurringStatus');
|
|
if (isActive) {
|
|
statusEl.innerHTML = '<span class="badge bg-success">有効</span>';
|
|
document.getElementById('recurringStopBtn').style.display = 'inline-block';
|
|
} else {
|
|
statusEl.innerHTML = '<span class="badge bg-secondary">停止中</span>';
|
|
document.getElementById('recurringStopBtn').style.display = 'none';
|
|
}
|
|
});
|
|
}
|
|
});
|
|
</script>
|
|
|
|
<div class="modal fade" id="recurringModal" tabindex="-1" aria-labelledby="recurringModalHeading" aria-modal="true" role="dialog">
|
|
<div class="modal-dialog">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h5 class="modal-title" id="recurringModalHeading"><i class="bi bi-repeat me-2" aria-hidden="true"></i>繰り返し課題</h5>
|
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="閉じる"></button>
|
|
</div>
|
|
<div class="modal-body">
|
|
<h6 id="recurringModalTitle" class="mb-3 fw-bold"></h6>
|
|
<table class="table table-sm table-borderless">
|
|
<tbody>
|
|
<tr>
|
|
<th class="text-muted" style="width: 100px;" scope="row">繰り返し</th>
|
|
<td id="recurringTypeLabel">読み込み中...</td>
|
|
</tr>
|
|
<tr>
|
|
<th class="text-muted" scope="row">状態</th>
|
|
<td id="recurringStatus">読み込み中...</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<div class="alert alert-info small mb-0" role="note">
|
|
<i class="bi bi-info-circle me-1" aria-hidden="true"></i>
|
|
繰り返しを停止すると、今後新しい課題は自動作成されなくなります。既存の課題はそのまま残ります。
|
|
</div>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">閉じる</button>
|
|
<a id="recurringEditBtn" href="#" class="btn btn-primary">
|
|
<i class="bi bi-pencil me-1" aria-hidden="true"></i>編集
|
|
</a>
|
|
<form id="recurringStopForm" method="POST" class="d-inline" data-confirm="繰り返しを停止しますか?">
|
|
<input type="hidden" name="_csrf" value="{{.csrfToken}}">
|
|
<button type="submit" id="recurringStopBtn" class="btn btn-danger">
|
|
<i class="bi bi-stop-fill me-1" aria-hidden="true"></i>停止
|
|
</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="modal fade" id="deleteRecurringModal" tabindex="-1" aria-labelledby="deleteRecurringModalHeading" aria-modal="true" role="dialog">
|
|
<div class="modal-dialog">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h5 class="modal-title" id="deleteRecurringModalHeading"><i class="bi bi-trash me-2" aria-hidden="true"></i>繰り返し課題の削除</h5>
|
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="閉じる"></button>
|
|
</div>
|
|
<div class="modal-body">
|
|
<p>この課題は繰り返し設定に関連付けられています。</p>
|
|
<p>繰り返し設定も停止しますか?</p>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">キャンセル</button>
|
|
<form id="deleteOnlyForm" method="POST" class="d-inline">
|
|
<input type="hidden" name="_csrf" value="{{.csrfToken}}">
|
|
<button type="submit" class="btn btn-outline-danger">課題のみ削除</button>
|
|
</form>
|
|
<form id="deleteAndStopForm" method="POST" class="d-inline">
|
|
<input type="hidden" name="_csrf" value="{{.csrfToken}}">
|
|
<button type="submit" class="btn btn-danger">削除して繰り返しも削除</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
function showDeleteRecurringModal(assignmentId, recurringId) {
|
|
var modal = new bootstrap.Modal(document.getElementById('deleteRecurringModal'));
|
|
document.getElementById('deleteOnlyForm').action = '/assignments/' + assignmentId + '/delete';
|
|
document.getElementById('deleteAndStopForm').action = '/assignments/' + assignmentId + '/delete?stop_recurring=' + recurringId;
|
|
modal.show();
|
|
}
|
|
</script>
|
|
{{end}}
|