From e307a56e8edfcea3587466855e5016280d1e5134 Mon Sep 17 00:00:00 2001 From: Saurabh Kumar <theskumar@users.noreply.github.com> Date: Thu, 20 Jun 2024 01:31:50 +0530 Subject: [PATCH] Update the flagging feature to use htmx (#3985) Fixes https://github.com/HyphaApp/hypha/issues/3851 - Update the flagging design slightly (see screenshots) - Update jquery js to vanilla, for showing if a submission is flagged in the table row. - Reuse the submission list view to display user flags and staff flag pages --- .../templates/dashboard/dashboard.html | 1 - .../templates/dashboard/includes/flagged.html | 4 +- .../dashboard/reviewer_dashboard.html | 1 - hypha/apply/flags/templates/flags/flags.html | 63 +++++++-- hypha/apply/flags/views.py | 11 +- hypha/apply/funds/tables.py | 8 -- .../applicationsubmission_admin_detail.html | 6 +- .../funds/applicationsubmission_detail.html | 1 - ...applicationsubmission_reviewer_detail.html | 5 +- .../funds/grouped_application_list.html | 1 - .../templates/funds/staff_assignments.html | 1 - .../templates/funds/submissions_overview.html | 13 -- .../funds/submissions_staff_flagged.html | 29 ---- .../funds/submissions_user_flagged.html | 22 --- hypha/apply/funds/urls.py | 15 -- hypha/apply/funds/views.py | 53 ------- hypha/core/navigation.py | 129 +++++++++--------- hypha/static_src/javascript/flag.js | 41 ------ hypha/static_src/sass/components/_button.scss | 6 - 19 files changed, 136 insertions(+), 274 deletions(-) delete mode 100644 hypha/apply/funds/templates/funds/submissions_staff_flagged.html delete mode 100644 hypha/apply/funds/templates/funds/submissions_user_flagged.html delete mode 100644 hypha/static_src/javascript/flag.js diff --git a/hypha/apply/dashboard/templates/dashboard/dashboard.html b/hypha/apply/dashboard/templates/dashboard/dashboard.html index 4b5d0350e..517b4af32 100644 --- a/hypha/apply/dashboard/templates/dashboard/dashboard.html +++ b/hypha/apply/dashboard/templates/dashboard/dashboard.html @@ -129,5 +129,4 @@ <script src="{% static 'js/all-submissions-table.js' %}"></script> <script src="{% static 'js/submission-filters.js' %}"></script> <script src="{% static 'js/tabs.js' %}"></script> - <script src="{% static 'js/flag.js' %}"></script> {% endblock %} diff --git a/hypha/apply/dashboard/templates/dashboard/includes/flagged.html b/hypha/apply/dashboard/templates/dashboard/includes/flagged.html index ef096a47f..0f7c4c68f 100644 --- a/hypha/apply/dashboard/templates/dashboard/includes/flagged.html +++ b/hypha/apply/dashboard/templates/dashboard/includes/flagged.html @@ -6,10 +6,12 @@ </h2> {% if my_flagged.data %} + {% render_table my_flagged %} + {% if display_more %} <div class="all-submissions-table__more"> - <a href="{% url 'apply:submissions:flagged' %}">{% trans "Show all" %}</a> + <a href="{% url 'apply:submissions:list-alt' %}?query=flagged:@me">{% trans "Show all" %}</a> </div> {% endif %} {% endif %} diff --git a/hypha/apply/dashboard/templates/dashboard/reviewer_dashboard.html b/hypha/apply/dashboard/templates/dashboard/reviewer_dashboard.html index 462fc2c47..5825aaccd 100644 --- a/hypha/apply/dashboard/templates/dashboard/reviewer_dashboard.html +++ b/hypha/apply/dashboard/templates/dashboard/reviewer_dashboard.html @@ -82,5 +82,4 @@ {{ filter.form.media.js }} <script src="{% static 'js/url-search-params.js' %}"></script> <script src="{% static 'js/submission-filters.js' %}"></script> - <script src="{% static 'js/flag.js' %}"></script> {% endblock %} diff --git a/hypha/apply/flags/templates/flags/flags.html b/hypha/apply/flags/templates/flags/flags.html index ef79dcc58..00f1d92de 100644 --- a/hypha/apply/flags/templates/flags/flags.html +++ b/hypha/apply/flags/templates/flags/flags.html @@ -1,11 +1,54 @@ -{% load i18n flag_tags %} -<div class="sidebar__inner"> - <h5>{% trans "Flags" %}</h5> - <div class="wrapper wrapper--sidebar-buttons"> - <button class="button button--primary button--half-width button--flag {% if submission.is_archive %}is-disabled{% endif %} {% if submission|flagged_by:user %} flagged{% endif %}" data-id="{{ submission.id }}" data-type="user">{% trans "Flag" %}</button> +{% load i18n flag_tags heroicons %} +<form class="wrapper wrapper--sidebar-buttons flex gap-4" id="submission-flags"> + {% with submission|flagged_by:user as is_flagged %} + <button + class="button button--secondary flex items-center gap-4 !px-2 !py-3 w-full" + {% if submission.is_archive %} + disabled=true + {% else %} + hx-post="{% url 'apply:submissions:flags:create_submission_flag' submission.id "user" %}" + hx-swap="outerHTML" + hx-target="#submission-flags" + {% if is_flagged %} + data-tippy-content="Remove from your flagged submissions" + {% else %} + data-tippy-content="Add to your flagged submissions" + {% endif %} + {% endif %} + > + {% if is_flagged %} + {% heroicon_solid "flag" class="inline-block align-text-bottom fill-amber-400" size=18 %} + <span>{% trans "Flagged" %}</span> + {% else %} + {% trans "Flag" %} + {% endif %} + </button> + {% endwith %} - {% if request.user.is_apply_staff %} - <button class="button button--primary button--half-width button--flag {% if submission.is_archive %}is-disabled{% endif %} {% if submission|flagged_staff %} flagged{% endif %}" data-id="{{ submission.id }}" data-type="staff">{% trans "Staff flag" %}</button> - {% endif %} - </div> -</div> + {% if request.user.is_apply_staff %} + {% with submission|flagged_staff as is_flagged %} + <button + class="button button--secondary flex items-center gap-4 !px-2 !py-3 w-full whitespace-nowrap" + {% if submission.is_archive %} + disabled=true + {% else %} + hx-post="{% url 'apply:submissions:flags:create_submission_flag' submission.id "staff" %}" + hx-swap="outerHTML" + hx-target="#submission-flags" + {% if is_flagged %} + data-tippy-content="Remove staff flag" + {% else %} + data-tippy-content="Flag for staff review" + {% endif %} + {% endif %} + > + {% if is_flagged %} + {% heroicon_solid "flag" class="inline-block align-text-bottom fill-amber-500" size=18 %} + <span>{% trans "Staff Flagged" %}</span> + {% else %} + {% trans "Staff Flag" %} + {% endif %} + </button> + {% endwith %} + {% endif %} +</form> diff --git a/hypha/apply/flags/views.py b/hypha/apply/flags/views.py index 2de2db491..34f213922 100644 --- a/hypha/apply/flags/views.py +++ b/hypha/apply/flags/views.py @@ -1,7 +1,8 @@ from django.contrib.auth.decorators import login_required from django.contrib.auth.mixins import UserPassesTestMixin from django.contrib.contenttypes.models import ContentType -from django.http import HttpResponseNotAllowed, JsonResponse +from django.http import HttpResponseNotAllowed +from django.shortcuts import render from django.utils.decorators import method_decorator from django.views import View @@ -15,13 +16,11 @@ class FlagSubmissionCreateView(UserPassesTestMixin, View): model = Flag def post(self, request, type, submission_pk): - if request.headers.get("x-requested-with") != "XMLHttpRequest": - return HttpResponseNotAllowed() - # Only staff can create staff flags. if type == self.model.STAFF and not self.request.user.is_apply_staff: return HttpResponseNotAllowed() + submission = ApplicationSubmission.objects.get(pk=submission_pk) submission_type = ContentType.objects.get_for_model(ApplicationSubmission) # Trying to get a flag from the table, or create a new one flag, created = self.model.objects.get_or_create( @@ -35,7 +34,9 @@ class FlagSubmissionCreateView(UserPassesTestMixin, View): if not created: flag.delete() - return JsonResponse({"result": created}) + return render( + request, "flags/flags.html", {"flag": flag, "submission": submission} + ) def test_func(self): return self.request.user.is_apply_staff or self.request.user.is_reviewer diff --git a/hypha/apply/funds/tables.py b/hypha/apply/funds/tables.py index eb3323938..6500b16b4 100644 --- a/hypha/apply/funds/tables.py +++ b/hypha/apply/funds/tables.py @@ -247,14 +247,6 @@ class SummarySubmissionsTableWithRole(BaseAdminSubmissionsTable): return "" -class StaffFlaggedSubmissionsTable(SummarySubmissionsTable): - class Meta(SummarySubmissionsTable.Meta): - row_attrs = dict( - {"data-flag-type": "staff"}, **SummarySubmissionsTable._meta.row_attrs - ) - attrs = {"class": "all-submissions-table flagged-table"} - - class UserFlaggedSubmissionsTable(SummarySubmissionsTable): class Meta(SummarySubmissionsTable.Meta): row_attrs = dict( diff --git a/hypha/apply/funds/templates/funds/applicationsubmission_admin_detail.html b/hypha/apply/funds/templates/funds/applicationsubmission_admin_detail.html index 934d7fc75..c97edac95 100644 --- a/hypha/apply/funds/templates/funds/applicationsubmission_admin_detail.html +++ b/hypha/apply/funds/templates/funds/applicationsubmission_admin_detail.html @@ -36,7 +36,11 @@ {% endblock %} {% block flags %} - {% include 'flags/flags.html' with submission=object user=request.user %} + <div class="sidebar__inner"> + <h5>{% trans "Flags" %}</h5> + + {% include 'flags/flags.html' with submission=object user=request.user %} + </div> {% endblock %} {% block reviews %} diff --git a/hypha/apply/funds/templates/funds/applicationsubmission_detail.html b/hypha/apply/funds/templates/funds/applicationsubmission_detail.html index b569642b5..098fb102b 100644 --- a/hypha/apply/funds/templates/funds/applicationsubmission_detail.html +++ b/hypha/apply/funds/templates/funds/applicationsubmission_detail.html @@ -223,5 +223,4 @@ <script src="{% static 'js/tabs.js' %}"></script> <script src="{% static 'js/submission-text-cleanup.js' %}"></script> <script src="{% static 'js/edit-comment.js' %}"></script> - <script src="{% static 'js/flag.js' %}"></script> {% endblock %} diff --git a/hypha/apply/funds/templates/funds/applicationsubmission_reviewer_detail.html b/hypha/apply/funds/templates/funds/applicationsubmission_reviewer_detail.html index 614428db9..0926d50b9 100644 --- a/hypha/apply/funds/templates/funds/applicationsubmission_reviewer_detail.html +++ b/hypha/apply/funds/templates/funds/applicationsubmission_reviewer_detail.html @@ -2,7 +2,10 @@ {% load i18n static workflow_tags review_tags determination_tags %} {% block flags %} - {% include 'flags/flags.html' with submission=object user=request.user %} + <div class="sidebar__inner"> + <h5>{% trans "Flags" %}</h5> + {% include 'flags/flags.html' with submission=object user=request.user %} + </div> {% endblock %} {% block reviews %} diff --git a/hypha/apply/funds/templates/funds/grouped_application_list.html b/hypha/apply/funds/templates/funds/grouped_application_list.html index 06f15a88a..f49c626ad 100644 --- a/hypha/apply/funds/templates/funds/grouped_application_list.html +++ b/hypha/apply/funds/templates/funds/grouped_application_list.html @@ -25,5 +25,4 @@ <script src="{% static 'js/submission-filters.js' %}"></script> <script src="{% static 'js/tabs.js' %}"></script> <script src="{% static 'js/batch-actions.js' %}"></script> - <script src="{% static 'js/flag.js' %}"></script> {% endblock %} diff --git a/hypha/apply/funds/templates/funds/staff_assignments.html b/hypha/apply/funds/templates/funds/staff_assignments.html index 0be6503cc..f2fb4167f 100644 --- a/hypha/apply/funds/templates/funds/staff_assignments.html +++ b/hypha/apply/funds/templates/funds/staff_assignments.html @@ -21,5 +21,4 @@ {% block extra_js %} {{ filter.form.media.js }} <script src="{% static 'js/symbol-es6.min.js' %}"></script> - <script src="{% static 'js/flag.js' %}"></script> {% endblock %} diff --git a/hypha/apply/funds/templates/funds/submissions_overview.html b/hypha/apply/funds/templates/funds/submissions_overview.html index a7928172d..65d7fe64e 100644 --- a/hypha/apply/funds/templates/funds/submissions_overview.html +++ b/hypha/apply/funds/templates/funds/submissions_overview.html @@ -29,19 +29,6 @@ <a href="{% url 'apply:submissions:list' %}">{% trans "Show all" %}</a> </div> </div> - - {% if staff_flagged.table.data %} - <div class="wrapper wrapper--bottom-space"> - <h4 class="heading heading--normal">{% trans "Staff flagged submissions" %}</h4> - {% render_table staff_flagged.table %} - {% if staff_flagged.display_more %} - <div class="all-submissions-table__more"> - <a href="{% url 'apply:submissions:staff_flagged' %}">{% trans "Show all" %}</a> - </div> - {% endif %} - </div> - {% endif %} - {% endblock %} </div> {% endblock %} diff --git a/hypha/apply/funds/templates/funds/submissions_staff_flagged.html b/hypha/apply/funds/templates/funds/submissions_staff_flagged.html deleted file mode 100644 index 00436c3c9..000000000 --- a/hypha/apply/funds/templates/funds/submissions_staff_flagged.html +++ /dev/null @@ -1,29 +0,0 @@ -{% extends "funds/base_submissions_table.html" %} -{% load i18n static %} -{% load render_table from django_tables2 %} - -{% block title %}{% trans "Staff flagged submissions" %}{% endblock %} - -{% block content %} - - {% adminbar %} - {% slot header %} - {% trans "Staff flagged submissions" %}<span class="submissions-count"> ({{ table.rows|length }})</span> - {% endslot %} - {% slot sub_heading %}{% trans "Submissions flagged by staff" %}{% endslot %} - {% endadminbar %} - - - <div class="wrapper wrapper--large wrapper--inner-space-medium"> - {% block table %} - {% render_table table %} - {% endblock %} - </div> -{% endblock %} - -{% block extra_js %} - {{ filter.form.media.js }} - <script src="{% static 'js/all-submissions-table.js' %}"></script> - <script src="{% static 'js/symbol-es6.min.js' %}"></script> - <script src="{% static 'js/flag.js' %}"></script> -{% endblock %} diff --git a/hypha/apply/funds/templates/funds/submissions_user_flagged.html b/hypha/apply/funds/templates/funds/submissions_user_flagged.html deleted file mode 100644 index 05653fdf8..000000000 --- a/hypha/apply/funds/templates/funds/submissions_user_flagged.html +++ /dev/null @@ -1,22 +0,0 @@ -{% extends "funds/base_submissions_table.html" %} -{% load i18n static %} -{% load render_table from django_tables2 %} - -{% block title %}{% trans "Your flagged submissions" %}{% endblock %} - -{% block content %} - - {% adminbar %} - {% slot header %} - {% trans "Your flagged submissions" %} <span class="submissions-count">({{ table.rows|length }})</span> - {% endslot %} - {% slot sub_heading %}{% trans "Submissions flagged by you" %}{% endslot %} - {% endadminbar %} - - - <div class="wrapper wrapper--large wrapper--inner-space-medium"> - {% block table %} - {% render_table table %} - {% endblock %} - </div> -{% endblock %} diff --git a/hypha/apply/funds/urls.py b/hypha/apply/funds/urls.py index 58a0a7cb7..b5eec5780 100644 --- a/hypha/apply/funds/urls.py +++ b/hypha/apply/funds/urls.py @@ -26,8 +26,6 @@ from .views import ( SubmissionsByRound, SubmissionsByStatus, SubmissionSealedView, - SubmissionStaffFlaggedView, - SubmissionUserFlaggedView, partial_screening_card, submission_success, ) @@ -135,19 +133,6 @@ submission_urls = ( ), path("summary/", GroupingApplicationsListView.as_view(), name="summary"), path("result/", SubmissionResultView.as_view(), name="result"), - path( - "flagged/", - include( - [ - path("", SubmissionUserFlaggedView.as_view(), name="flagged"), - path( - "staff/", - SubmissionStaffFlaggedView.as_view(), - name="staff_flagged", - ), - ] - ), - ), path( "reviews/", include( diff --git a/hypha/apply/funds/views.py b/hypha/apply/funds/views.py index 204bc8261..0c70f9b7f 100644 --- a/hypha/apply/funds/views.py +++ b/hypha/apply/funds/views.py @@ -122,11 +122,9 @@ from .tables import ( RoundsFilter, RoundsTable, StaffAssignmentsTable, - StaffFlaggedSubmissionsTable, SubmissionFilterAndSearch, SubmissionReviewerFilterAndSearch, SummarySubmissionsTable, - UserFlaggedSubmissionsTable, ) from .utils import ( get_or_create_default_screening_statuses, @@ -496,8 +494,6 @@ class SubmissionOverviewView(BaseAdminSubmissionsTable): for status, data in PHASES_MAPPING.items() } - staff_flagged = self.get_staff_flagged() - return super().get_context_data( open_rounds=open_rounds, open_query=open_query, @@ -506,27 +502,9 @@ class SubmissionOverviewView(BaseAdminSubmissionsTable): closed_query=closed_query, rounds_title=rounds_title, status_counts=grouped_statuses, - staff_flagged=staff_flagged, **kwargs, ) - def get_staff_flagged(self): - qs = super().get_queryset().flagged_staff().order_by("-submit_time") - row_attrs = dict( - {"data-flag-type": "staff"}, **SummarySubmissionsTable._meta.row_attrs - ) - - limit = 5 - return { - "table": SummarySubmissionsTable( - qs[:limit], - prefix="staff-flagged-", - attrs={"class": "all-submissions-table flagged-table"}, - row_attrs=row_attrs, - ), - "display_more": qs.count() > limit, - } - class SubmissionAdminListView(BaseAdminSubmissionsTable, DelegateableListView): template_name = "funds/submissions.html" @@ -592,37 +570,6 @@ class SubmissionListView(ViewDispatcher): reviewer_view = SubmissionReviewerListView -@method_decorator(staff_required, name="dispatch") -class SubmissionStaffFlaggedView(BaseAdminSubmissionsTable): - table_class = StaffFlaggedSubmissionsTable - template_name = "funds/submissions_staff_flagged.html" - - def get_queryset(self): - return ( - self.filterset_class._meta.model.objects.current() - .for_table(self.request.user) - .flagged_staff() - .order_by("-submit_time") - ) - - -@method_decorator(login_required, name="dispatch") -class SubmissionUserFlaggedView(UserPassesTestMixin, BaseAdminSubmissionsTable): - table_class = UserFlaggedSubmissionsTable - template_name = "funds/submissions_user_flagged.html" - - def get_queryset(self): - return ( - self.filterset_class._meta.model.objects.current() - .for_table(self.request.user) - .flagged_by(self.request.user) - .order_by("-submit_time") - ) - - def test_func(self): - return self.request.user.is_apply_staff or self.request.user.is_reviewer - - @method_decorator(login_required, name="dispatch") class ExportSubmissionsByRound(UserPassesTestMixin, BaseAdminSubmissionsTable): def export_submissions(self, round_id): diff --git a/hypha/core/navigation.py b/hypha/core/navigation.py index d951d782e..7ffb7f251 100644 --- a/hypha/core/navigation.py +++ b/hypha/core/navigation.py @@ -7,70 +7,6 @@ from django.core.exceptions import PermissionDenied from django.urls import reverse_lazy from django.utils.translation import gettext_lazy as _ -DEFAULT_NAV_ITEMS = [ - { - "title": _("My Dashboard"), - "url": reverse_lazy("dashboard:dashboard"), - "permission_method": "hypha.apply.users.decorators.has_dashboard_access", - }, - { - "title": _("Submissions"), - # kind of basic url to figure out active tab - "url": reverse_lazy("apply:submissions:overview"), - "permission_method": "hypha.apply.users.decorators.is_apply_staff_or_reviewer_required", - "sub_items": [ - { - "title": _("All Submissions"), - "url": reverse_lazy("apply:submissions:list"), - "permission_method": "hypha.apply.users.decorators.is_apply_staff_or_reviewer_required", - }, - { - "title": _("Staff Assignments"), - "url": reverse_lazy("apply:submissions:staff_assignments"), - "permission_method": "hypha.apply.users.decorators.is_apply_staff", - }, - { - "title": _("Reviews"), - "url": reverse_lazy("apply:submissions:reviewer_leaderboard"), - "permission_method": "hypha.apply.users.decorators.is_apply_staff", - }, - { - "title": _("Results"), - "url": reverse_lazy("apply:submissions:result"), - "permission_method": "hypha.apply.users.decorators.is_apply_staff", - }, - { - "title": _("Staff flagged"), - "url": reverse_lazy("apply:submissions:staff_flagged"), - "permission_method": "hypha.apply.users.decorators.is_apply_staff", - }, - ], - }, - { - "title": _("Projects"), - # kind of basic url to figure out active tab - "url": reverse_lazy("apply:projects:overview"), - "permission_method": "hypha.apply.users.decorators.is_apply_staff_or_finance_or_contracting", - "sub_items": [ - { - "title": _("All Projects"), - "url": reverse_lazy("apply:projects:all"), - "permission_method": "hypha.apply.users.decorators.is_apply_staff_or_finance_or_contracting", - }, - { - "title": _("Invoices"), - "url": reverse_lazy("apply:projects:invoices"), - "permission_method": "hypha.apply.users.decorators.is_apply_staff_or_finance", - }, - { - "title": _("Reports"), - "url": reverse_lazy("apply:projects:reports:all"), - "permission_method": "hypha.apply.users.decorators.is_apply_staff_or_finance", - }, - ], - }, -] - def _check_permission(user, method: str) -> bool: """Resolve the method path and check if the user has permission. @@ -92,6 +28,71 @@ def _check_permission(user, method: str) -> bool: @functools.cache def get_primary_navigation_items(user): + DEFAULT_NAV_ITEMS = [ + { + "title": _("My Dashboard"), + "url": reverse_lazy("dashboard:dashboard"), + "permission_method": "hypha.apply.users.decorators.has_dashboard_access", + }, + { + "title": _("Submissions"), + # kind of basic url to figure out active tab + "url": reverse_lazy("apply:submissions:overview"), + "permission_method": "hypha.apply.users.decorators.is_apply_staff_or_reviewer_required", + "sub_items": [ + { + "title": _("All Submissions"), + "url": reverse_lazy("apply:submissions:list"), + "permission_method": "hypha.apply.users.decorators.is_apply_staff_or_reviewer_required", + }, + { + "title": _("Staff Assignments"), + "url": reverse_lazy("apply:submissions:staff_assignments"), + "permission_method": "hypha.apply.users.decorators.is_apply_staff", + }, + { + "title": _("Reviews"), + "url": reverse_lazy("apply:submissions:reviewer_leaderboard"), + "permission_method": "hypha.apply.users.decorators.is_apply_staff", + }, + { + "title": _("Results"), + "url": reverse_lazy("apply:submissions:result"), + "permission_method": "hypha.apply.users.decorators.is_apply_staff", + }, + { + "title": _("Staff flagged"), + "url": reverse_lazy("apply:submissions:list-alt") + + "?query=flagged:@staff", + "permission_method": "hypha.apply.users.decorators.is_apply_staff", + }, + ], + }, + { + "title": _("Projects"), + # kind of basic url to figure out active tab + "url": reverse_lazy("apply:projects:overview"), + "permission_method": "hypha.apply.users.decorators.is_apply_staff_or_finance_or_contracting", + "sub_items": [ + { + "title": _("All Projects"), + "url": reverse_lazy("apply:projects:all"), + "permission_method": "hypha.apply.users.decorators.is_apply_staff_or_finance_or_contracting", + }, + { + "title": _("Invoices"), + "url": reverse_lazy("apply:projects:invoices"), + "permission_method": "hypha.apply.users.decorators.is_apply_staff_or_finance", + }, + { + "title": _("Reports"), + "url": reverse_lazy("apply:projects:reports:all"), + "permission_method": "hypha.apply.users.decorators.is_apply_staff_or_finance", + }, + ], + }, + ] + """Get the primary navigation items based on user permissions.""" original_nav_items = copy.deepcopy( settings.APPLY_NAV_MENU_ITEMS or DEFAULT_NAV_ITEMS diff --git a/hypha/static_src/javascript/flag.js b/hypha/static_src/javascript/flag.js deleted file mode 100644 index f9a7fdf60..000000000 --- a/hypha/static_src/javascript/flag.js +++ /dev/null @@ -1,41 +0,0 @@ -(function ($) { - "use strict"; - - $(".flagged-table") - .find(".all-submissions-table__parent") - .each(function () { - var $flagged_item = $(this); - var submission_id = $flagged_item.data("record-id"); - var flag_type = $flagged_item.data("flag-type"); - var $button = - '<span class="button--float"><button class="button button--flag button--unflag flagged" data-id="' + - submission_id + - '" data-type="' + - flag_type + - '">Flag</button></span>'; - $flagged_item - .find("td.comments") - .css("position", "relative") - .append($button); - }); - - $(".button--flag").on("click", function (e) { - e.preventDefault(); - - var $current = $(this); - var id = $current.data("id"); - var type = $current.data("type"); - - $.ajax({ - url: "/apply/submissions/" + id + "/" + type + "/flag/", - type: "POST", - success: function (json) { - if (json.result) { - $current.addClass("flagged"); - } else { - $current.removeClass("flagged"); - } - }, - }); - }); -})(jQuery); diff --git a/hypha/static_src/sass/components/_button.scss b/hypha/static_src/sass/components/_button.scss index 186e88a83..760d0b2fe 100644 --- a/hypha/static_src/sass/components/_button.scss +++ b/hypha/static_src/sass/components/_button.scss @@ -411,12 +411,6 @@ } } - &--float { - position: absolute; - inset-block-start: 2px; - inset-inline-end: 2px; - } - // Two-factor &-info, &-link { -- GitLab