diff --git a/opentech/apply/dashboard/templates/dashboard/dashboard.html b/opentech/apply/dashboard/templates/dashboard/dashboard.html index 6ea1264452db08ae4f07ebe54d03179ca1d40fc2..dc4ca09908509d0adf3d883ba171d476271299f1 100644 --- a/opentech/apply/dashboard/templates/dashboard/dashboard.html +++ b/opentech/apply/dashboard/templates/dashboard/dashboard.html @@ -113,4 +113,5 @@ <script src="{% static 'js/apply/submission-filters.js' %}"></script> <script src="{% static 'js/apply/submission-tooltips.js' %}"></script> <script src="{% static 'js/apply/tabs.js' %}"></script> + <script src="{% static 'js/apply/flag.js' %}"></script> {% endblock %} diff --git a/opentech/apply/dashboard/views.py b/opentech/apply/dashboard/views.py index 7834568e01acf69584c725d0a8e28032d74e8137..9b963a58f1b778eafe431a0da02875d55bd3a9d1 100644 --- a/opentech/apply/dashboard/views.py +++ b/opentech/apply/dashboard/views.py @@ -123,10 +123,11 @@ class AdminDashboardView(TemplateView): def get_my_flagged(self, request, qs): qs = qs.flagged_by(request.user).order_by('-submit_time') + row_attrs = dict({'data-flag-type': 'user'}, **SummarySubmissionsTable._meta.row_attrs) limit = 5 return { - 'table': SummarySubmissionsTable(qs[:limit], prefix='my-flagged-'), + 'table': SummarySubmissionsTable(qs[:limit], prefix='my-flagged-', attrs={'class': 'all-submissions-table flagged-table'}, row_attrs=row_attrs), 'display_more': qs.count() > limit, } diff --git a/opentech/apply/funds/templates/funds/base_submissions_table.html b/opentech/apply/funds/templates/funds/base_submissions_table.html index 6b6e6d4763412ff71ed8510cbe604ee26db1417c..cbc14661e487df5828230ddd2cfb7dc624f198c8 100644 --- a/opentech/apply/funds/templates/funds/base_submissions_table.html +++ b/opentech/apply/funds/templates/funds/base_submissions_table.html @@ -26,4 +26,5 @@ <script src="{% static 'js/apply/submission-tooltips.js' %}"></script> <script src="{% static 'js/apply/tabs.js' %}"></script> <script src="{% static 'js/apply/batch-actions.js' %}"></script> + <script src="{% static 'js/apply/flag.js' %}"></script> {% endblock %} diff --git a/opentech/apply/funds/views.py b/opentech/apply/funds/views.py index c214a8a5596dbf94557322004cd997a7400115b6..bd85a504b60df71597c0aa34a736f5c7eaa1ddc2 100644 --- a/opentech/apply/funds/views.py +++ b/opentech/apply/funds/views.py @@ -282,10 +282,11 @@ class SubmissionOverviewView(BaseAdminSubmissionsTable): 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-'), + 'table': SummarySubmissionsTable(qs[:limit], prefix='staff-flagged-', attrs={'class': 'all-submissions-table flagged-table'}, row_attrs=row_attrs), 'display_more': qs.count() > limit, } diff --git a/opentech/static_src/src/javascript/apply/flag.js b/opentech/static_src/src/javascript/apply/flag.js index b3038aeda353836edde4bdeb5ef34ff18a6c12a1..932622b582da6ea26d9931ce63d774060f1db262 100644 --- a/opentech/static_src/src/javascript/apply/flag.js +++ b/opentech/static_src/src/javascript/apply/flag.js @@ -2,6 +2,14 @@ '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(); @@ -21,7 +29,6 @@ } } }); - }); })(jQuery); diff --git a/opentech/static_src/src/sass/apply/abstracts/_mixins.scss b/opentech/static_src/src/sass/apply/abstracts/_mixins.scss index e1beb948c3a18d620144909ed2d2eba0bf56887f..ec269cd16c687695bcba7835739154ed2a8aae54 100644 --- a/opentech/static_src/src/sass/apply/abstracts/_mixins.scss +++ b/opentech/static_src/src/sass/apply/abstracts/_mixins.scss @@ -106,6 +106,16 @@ } } +// Small button mixin +@mixin button--small { + padding: 2px; + font-size: 12px; + + @include media-query(tablet-landscape) { + padding: 3px 5px; + } +} + // Viewport sized typography mixin that takes a min and max pixel-based value @mixin responsive-font-sizes($min, $max) { diff --git a/opentech/static_src/src/sass/apply/components/_button.scss b/opentech/static_src/src/sass/apply/components/_button.scss index 3732382b5900abf99ae3843e80492ad4aa056648..18cf4fd45886a46f511e7dc5bd4563a6f03f62ce 100644 --- a/opentech/static_src/src/sass/apply/components/_button.scss +++ b/opentech/static_src/src/sass/apply/components/_button.scss @@ -342,4 +342,28 @@ } } } + + &--unflag { + @include button($color--light-blue, $color--dark-blue); + @include button--small; + padding-right: 18px; + + @include media-query(tablet-landscape) { + padding-right: 18px; + } + + &.flagged { + &::after { + top: 2px; + padding-left: 3px; + font-size: map-get($font-sizes, zeta); + } + } + } + + &--float { + position: absolute; + top: 2px; + right: 2px; + } }