diff --git a/src/actions/ticket-actions.js b/src/actions/ticket-actions.js index 0179683e7..6d199ed32 100644 --- a/src/actions/ticket-actions.js +++ b/src/actions/ticket-actions.js @@ -172,89 +172,106 @@ const parseFilters = (filters, term = null) => { const filter = []; - if (filters.hasOwnProperty('showOnlyPendingRefundRequests') && filters.showOnlyPendingRefundRequests) { + if (filters?.showOnlyPendingRefundRequests) { filter.push('has_requested_refund_requests==1'); } - if (filters.hasOwnProperty('showOnlyPrintable') && filters.showOnlyPrintable) { + if (filters?.showOnlyPrintable) { filter.push('is_printable==1'); } - if (filters.hasOwnProperty('hasOwnerFilter') && filters.hasOwnerFilter) { + if (filters?.hasOwnerFilter) { if (filters.hasOwnerFilter === 'HAS_OWNER') filter.push(`has_owner==1`); if (filters.hasOwnerFilter === 'HAS_NO_OWNER') filter.push(`has_owner==0`) } - if(filters.hasOwnProperty('hasBadgeFilter') && filters.hasBadgeFilter){ + if (filters?.hasBadgeFilter) { if (filters.hasBadgeFilter === 'HAS_BADGE') filter.push(`has_badge==1`); if (filters.hasBadgeFilter === 'HAS_NO_BADGE') filter.push(`has_badge==0`) } - if(filters.hasOwnProperty('ticketTypesFilter') && Array.isArray(filters.ticketTypesFilter) && filters.ticketTypesFilter.length > 0){ + if (filters?.ticketTypesFilter?.length > 0) { filter.push(filters.ticketTypesFilter.reduce( (accumulator, tt) => accumulator +(accumulator !== '' ? ',':'') +`ticket_type_id==${tt.value}`, '' )); } - if(filters.hasOwnProperty('badgeTypesFilter') && Array.isArray(filters.badgeTypesFilter) && filters.badgeTypesFilter.length > 0) { + if (filters?.badgeTypesFilter?.length > 0) { filter.push(filters.badgeTypesFilter.reduce( (accumulator, tt) => accumulator +(accumulator !== '' ? ',':'') +`badge_type_id==${tt.value}`, '' )); } - if(filters.hasOwnProperty('viewTypesFilter') && Array.isArray(filters.viewTypesFilter) && filters.viewTypesFilter.length > 0){ + if (filters?.viewTypesFilter?.length > 0) { filter.push(filters.viewTypesFilter.reduce( (accumulator, tt) => accumulator +(accumulator !== '' ? ',':'') +`view_type_id==${tt.value}`, '' )); } - if(filters.promocodesFilter?.length > 0){ + if (filters.promocodesFilter?.length > 0) { filter.push(filters.promocodesFilter.reduce( (accumulator, tt) => accumulator +(accumulator !== '' ? ',':'') +`promo_code_id==${tt.id}`, '' )); } - if(filters.hasOwnProperty('completedFilter') && filters.completedFilter){ + if (filters?.completedFilter) { filter.push(`owner_status==${filters.completedFilter}`); } - if (filters.hasOwnProperty('amountFilter') && filters.amountFilter) { + if (filters?.amountFilter) { if (filters.amountFilter === 'Paid') filter.push(`final_amount>0`); if (filters.amountFilter === 'Free') filter.push(`final_amount==0`) } - if(filters.hasOwnProperty('ownerFullNameStartWithFilter') && Array.isArray(filters.ownerFullNameStartWithFilter) && filters.ownerFullNameStartWithFilter.length > 0){ + if (filters.ownerFullNameStartWithFilter?.length > 0) { filter.push(filters.ownerFullNameStartWithFilter.reduce( (accumulator, alpha) => accumulator +(accumulator !== '' ? ',':'') +`owner_first_name@@${alpha.value}`, '' )); } - if(filters.hasOwnProperty('audienceFilter') && Array.isArray(filters.audienceFilter) && filters.audienceFilter.length > 0){ + if (filters?.ownerCompany?.length > 0) { + const nonTBD = filters?.ownerCompany.filter(of => of.id !== 'NULL'); + let ownerCompany = []; + + // has tbd + if (nonTBD.length < filters?.ownerCompany?.length) { + ownerCompany.push('has_owner_company==0'); + } + + if (nonTBD.length > 0) { + ownerCompany.push('owner_company=='+nonTBD.map(of => encodeURIComponent(of.name)).join('||')); + } + + filter.push(ownerCompany.join(',')); + } + + + if (filters.audienceFilter?.length > 0) { filter.push(filters.audienceFilter.reduce( (accumulator, aud) => accumulator +(accumulator !== '' ? ',':'') +`audience==${aud}`, '' )); } - if(filters.promocodeTagsFilter?.length > 0){ + if (filters.promocodeTagsFilter?.length > 0) { filter.push(filters.promocodeTagsFilter.reduce( (accumulator, t) => accumulator +(accumulator !== '' ? ',':'') +`promo_code_tag==${t.tag}`, '' )); } - if(term) { + if (term) { const escapedTerm = escapeFilterValue(term); let searchString = `number=@${escapedTerm},owner_email=@${escapedTerm},owner_name=@${escapedTerm},owner_company=@${escapedTerm},promo_code=@${escapedTerm},promo_code_description=@${escapedTerm},promo_code_tag=@${escapedTerm}`; searchString = isNumericString(escapedTerm) ? `${searchString},promo_code_tag_id==${escapedTerm}` : searchString; diff --git a/src/i18n/en.json b/src/i18n/en.json index 1e497fe7f..18834ad8d 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -1543,6 +1543,7 @@ "search_tickets": "Search by Ticket #, Buyer, Assignee, Promo Code, Promo Code Description", "ticket_types": "Filter By Ticket Types ...", "owner_first_name": "First name starts with ...", + "owner_company": "Select Company", "view_types": "Filter by View Types ...", "view_type": "Select a View Type ...", "promocodes": "Select a Promo Code ...", diff --git a/src/pages/tickets/ticket-list-page.js b/src/pages/tickets/ticket-list-page.js index 588d96339..beb348063 100644 --- a/src/pages/tickets/ticket-list-page.js +++ b/src/pages/tickets/ticket-list-page.js @@ -1,4 +1,4 @@ -/** + /** * Copyright 2018 OpenStack Foundation * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,8 @@ import { SelectableTable, Dropdown, PromocodeInput, - TagInput + TagInput, + CompanyInput } from 'openstack-uicore-foundation/lib/components'; import { getSummitById } from '../../actions/summit-actions'; import { @@ -100,6 +101,7 @@ class TicketListPage extends React.Component { showOnlyPendingRefundRequests: false, ticketTypesFilter : [], ownerFullNameStartWithFilter:[], + ownerCompany: [], viewTypesFilter: [], hasOwnerFilter : null, completedFilter : null, @@ -260,6 +262,7 @@ class TicketListPage extends React.Component { showOnlyPendingRefundRequests: false, ticketTypesFilter : [], ownerFullNameStartWithFilter:[], + ownerCompany: null, viewTypesFilter: [], hasOwnerFilter : null, completedFilter : null, @@ -371,6 +374,7 @@ class TicketListPage extends React.Component { {label: 'Badge', value: 'hasBadgeFilter'}, {label: 'Amount', value: 'amountFilter'}, {label: 'Assignee Name', value: 'ownerFullNameStartWithFilter'}, + {label: 'Owner Company', value: 'ownerCompany'}, {label: 'View Type', value: 'viewTypesFilter'}, {label: 'Ticket Type', value: 'ticketTypesFilter'}, {label: 'Promo Code', value: 'promocodesFilter'}, @@ -456,7 +460,9 @@ class TicketListPage extends React.Component { /> -
+ {enabledFilters?.length > 0 && +
+
{enabledFilters.includes('hasOwnerFilter') &&
this.handleFilterChange('hasOwnerFilter', val)} - className="ticket-list-segment" + className="segmentFilter" />
} @@ -481,7 +487,7 @@ class TicketListPage extends React.Component { { label: T.translate("ticket_list.incomplete"), value: "Incomplete",default: ticketFilters.completedFilter === "Incomplete" }, ]} setValue={val => this.handleFilterChange('completedFilter', val)} - className="ticket-list-segment" + className="segmentFilter" />
} @@ -495,7 +501,7 @@ class TicketListPage extends React.Component { { label: T.translate("ticket_list.has_no_badge"), value: "HAS_NO_BADGE",default: ticketFilters.hasBadgeFilter === "HAS_NO_BADGE" }, ]} setValue={newValue => this.handleFilterChange('hasBadgeFilter', newValue)} - className="ticket-list-segment" + className="segmentFilter" />
} @@ -509,7 +515,7 @@ class TicketListPage extends React.Component { { label: T.translate("ticket_list.free"), value: "Free",default: ticketFilters.amountFilter === "Free" }, ]} setValue={val => this.handleFilterChange('amountFilter', val)} - className="ticket-list-segment" + className="segmentFilter" /> } @@ -523,10 +529,23 @@ class TicketListPage extends React.Component { options={alphabet} isClearable={true} isMulti - className="ticket-types-filter" + className="dropdownFilter" /> } + {enabledFilters.includes('ownerCompany') && +
+ this.handleFilterChange('ownerCompany', ev.target.value)} + extraOptions={[{value: 'NULL', label: 'TBD'}]} + multi + /> +
+ } {enabledFilters.includes('viewTypesFilter') &&