Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small adjustements to Task Datatable #535

Merged
merged 2 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion api/views.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from collections import defaultdict

import django.http
from django.shortcuts import get_object_or_404
from django.shortcuts import get_object_or_404, resolve_url
from django.http import HttpRequest, HttpResponseBadRequest
from django.views.decorators.http import require_POST
from django.contrib.auth.models import User
Expand Down Expand Up @@ -97,6 +97,7 @@ def tasks_list_all(request: HttpRequest, subject_abbr: str | None = None):
"path": task.code,
"subject": task.subject.abbr,
"date": task.created_at,
"link": resolve_url("teacher_task", task_id=task.pk),
}
)
return JsonResponse({"tasks": result, "count": allCount})
Expand Down
9 changes: 6 additions & 3 deletions frontend/src/Teacher/AllTasks.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type Task = {
title: string;
subject: string;
date: Date;
link: string;
};

type RawTask = Omit<Task, 'date'> & {
Expand Down Expand Up @@ -109,9 +110,10 @@ const columns = [
},
{
title: 'Title',
data: 'title',
data: (row: Task) => row,
orderable: true,
searchable: true
searchable: true,
render: (data: Task) => `<a href="${data.link}" target="_blank">${data.title}</a>`
},
{
title: 'Subject',
Expand Down Expand Up @@ -174,7 +176,8 @@ const options = {

callback({ data: items, recordsTotal: count, recordsFiltered: count }); // https://datatables.net/manual/server-side#Returned-data
},
orderMulti: false
orderMulti: false,
pageLength: 25
} satisfies Config;

//save ref to data table and if it changes save datatable instance to table variable
Expand Down