Skip to content

Base tailwind table and styling and Opportunity List Table #557

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

Merged
merged 14 commits into from
May 1, 2025

Conversation

sravfeyn
Copy link
Member

This implements the base utils required to create a tailwind table

@sravfeyn sravfeyn requested a review from calellowitz April 11, 2025 02:06
Copy link
Collaborator

@calellowitz calellowitz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hard to fully understand without seeing it in use in an example table, but this looks reasonable

@@ -0,0 +1,18 @@
<div class="flex items-center gap-2 max-w-fit text-brand-deep-purple text-sm">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how is this used? basically how would we make a paginated table?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have updated the code. This is now removed with pagination now going into base_table itself

import django_tables2 as tables


class BaseTailwindTable(tables.Table):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this applies to most of the code, and can be done at the end if easier, but I don't think we want everything named tailwind like it is now. Much like we don't call existing tables "BootstrapTable," I don't think it adds anything, because when this gets merged, it will be the only table type

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we don't need it in the end. I have removed it and just declared the base-template in the settings.

@sravfeyn
Copy link
Member Author

Hard to fully understand without seeing it in use in an example table, but this looks reasonable

Should I club this with an OpportunityList page for the above reason?

@sravfeyn sravfeyn changed the title Base tailwind table and styling Base tailwind table and styling and Opportunity List Table Apr 22, 2025
{tooltip_text}
</div>
</div>
</div>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could potentially be turned into a component by introducing classes like tooltip-wrapper, tooltip-content etc. But this is the only place its used.

orderable=False,
template_code="""
<div class="flex justify-start text-sm font-normal text-brand-deep-purple w-fit"
x-data="{
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could potentially be turned into an alpinejs/tailwind plugin, but this is also the only place it's used.

Copy link
Collaborator

@calellowitz calellowitz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one nit and a few questions but this generally seems fine.

@@ -0,0 +1,29 @@
{% extends 'tailwind/base.html' %}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: template name change (opportunity -> opportunities) seems unnecessary

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, I will try to be wary of these for next pages

@@ -151,3 +172,92 @@ def get_payment_report_data(opportunity: Opportunity):
PaymentReportData(payment_unit.name, completed_work_count, user_payment_accrued, nm_payment_accrued)
)
return data, total_user_payment_accrued, total_nm_payment_accrued


def get_opportunity_list_data(organization, program_manager=False):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this performant? just making sure we aren't building something that will get too slow very quickly

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's likely this is not performant enough. We are setting aside time to look into this and other places with these kind of queries

{
"title": "View Workers",
"url": reverse("opportunity:detail", args=[record.organization.slug, record.id]),
# "url": reverse("opportunity:tw_worker_list", args=[record.organization.slug, record.id]),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need the commented out code?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this is updated in the followup PR here

template_name = "tailwind/pages/opportunities_list.html"
paginate_by = 15
base_columns = ["program", "start_date", "end_date", "status", "opportunity"]
pm_columns = ["active_workers", "total_deliveries", "verified_deliveries", "worker_earnings"]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are these for PMs only? They seem useful to everyone


if program_manager:
queryset = queryset.annotate(
active_workers=Count(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QFR: Why not include active_workers for NM as well?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFR: NM needs to see action oriented columns, PM needs to see performance columns

Base automatically changed from sr/ui-base to ui-main May 1, 2025 10:35
@calellowitz calellowitz merged commit d2c3e59 into ui-main May 1, 2025
@calellowitz calellowitz deleted the sr/ui-base-table branch May 1, 2025 11:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants