Skip to content

Commit

Permalink
Merge pull request mrlvsb#535 from patrick11514/master
Browse files Browse the repository at this point in the history
Small adjustements to Task Datatable
  • Loading branch information
Kobzol authored Oct 9, 2024
2 parents 9a4086d + 909d028 commit fb7d83e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
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

0 comments on commit fb7d83e

Please sign in to comment.