Skip to content

Commit

Permalink
Add query on tax types, revert action changes
Browse files Browse the repository at this point in the history
Signed-off-by: Tomás Castillo <[email protected]>
  • Loading branch information
tomrndom committed Nov 20, 2024
1 parent f3b429b commit 3cc95cd
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 55 deletions.
5 changes: 1 addition & 4 deletions src/actions/attendee-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,7 @@ const parseFilters = (filters, term = null) => {
Array.isArray(filters.ticketTypeFilter) &&
filters.ticketTypeFilter.length > 0
) {
const ticketTypesIds = filters.ticketTypeFilter.map((tt) =>
tt.hasOwnProperty("id") ? tt.id : tt
);
filter.push(`ticket_type_id==${ticketTypesIds.join("||")}`);
filter.push(`ticket_type_id==${filters.ticketTypeFilter.join("||")}`);
}

if (filters?.companyFilter?.length > 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/actions/ticket-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ const parseFilters = (filters, term = null) => {
filters.ticketTypesFilter.reduce(
(accumulator, tt) =>
`${accumulator}${accumulator !== "" ? "," : ""}ticket_type_id==${
tt.id
tt.value
}`,
""
)
Expand Down
38 changes: 17 additions & 21 deletions src/components/forms/extra-question-form/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -412,28 +412,24 @@ class ExtraQuestionForm extends React.Component {
)}
</div>
<div className="row form-group">
{currentSummit?.ticket_types.length > 0 && (
<div className="col-md-4">
<label>
{T.translate("question_form.allowed_ticket_types")} &nbsp;
<i
className="fa fa-info-circle"
title={T.translate(
"question_form.allowed_ticket_types_info"
)}
/>
</label>
<TicketTypesInput
id="allowed_ticket_types"
value={entity?.allowed_ticket_types}
summitId={currentSummit.id}
onChange={this.handleChange}
optionsLimit={100}
defaultOptions
isMulti
<div className="col-md-4">
<label>
{T.translate("question_form.allowed_ticket_types")} &nbsp;
<i
className="fa fa-info-circle"
title={T.translate("question_form.allowed_ticket_types_info")}
/>
</div>
)}
</label>
<TicketTypesInput
id="allowed_ticket_types"
value={entity?.allowed_ticket_types}
summitId={currentSummit.id}
onChange={this.handleChange}
optionsLimit={100}
defaultOptions
isMulti
/>
</div>
{badge_features_ddl.length >= 0 && (
<>
<div className="col-md-2 col-md-offset-1">
Expand Down
31 changes: 17 additions & 14 deletions src/components/forms/tax-type-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
* */

import React from "react";
import T from "i18n-react/dist/i18n-react";
Expand All @@ -18,7 +18,9 @@ import {
Input,
SimpleLinkList
} from "openstack-uicore-foundation/lib/components";
import { queryTicketTypes } from "openstack-uicore-foundation/lib/utils/query-actions";
import { isEmpty, scrollToError, shallowEqual } from "../../utils/methods";
import { MILLISECONDS_TO_SECONDS } from "../../utils/constants";

class TaxTypeForm extends React.Component {
constructor(props) {
Expand All @@ -36,7 +38,7 @@ class TaxTypeForm extends React.Component {
this.handleSubmit = this.handleSubmit.bind(this);
}

componentDidUpdate(prevProps, prevState, snapshot) {
componentDidUpdate(prevProps) {
const state = {};
scrollToError(this.props.errors);

Expand All @@ -55,32 +57,32 @@ class TaxTypeForm extends React.Component {
}

handleChange(ev) {
let entity = { ...this.state.entity };
let errors = { ...this.state.errors };
const newEntity = { ...this.state.entity };
const newErrors = { ...this.state.errors };
let { value, id } = ev.target;

if (ev.target.type === "checkbox") {
value = ev.target.checked;
}

if (ev.target.type === "datetime") {
value = value.valueOf() / 1000;
value = value.valueOf() / MILLISECONDS_TO_SECONDS;
}

errors[id] = "";
entity[id] = value;
this.setState({ entity: entity, errors: errors });
newErrors[id] = "";
newEntity[id] = value;
this.setState({ entity: newEntity, errors: newErrors });
}

handleSubmit(ev) {
let entity = { ...this.state.entity };
const entity = { ...this.state.entity };
ev.preventDefault();

this.props.onSubmit(this.state.entity);
this.props.onSubmit(entity);
}

hasErrors(field) {
let { errors } = this.state;
const { errors } = this.state;
if (field in errors) {
return errors[field];
}
Expand Down Expand Up @@ -113,21 +115,22 @@ class TaxTypeForm extends React.Component {
const { entity } = this.state;
const { currentSummit } = this.props;

let ticketColumns = [
const ticketColumns = [
{ columnKey: "name", value: T.translate("edit_tax_type.name") },
{
columnKey: "description",
value: T.translate("edit_tax_type.description")
}
];

let ticketOptions = {
const ticketOptions = {
title: T.translate("edit_tax_type.ticket_types"),
valueKey: "name",
labelKey: "name",
defaultOptions: true,
actions: {
search: this.queryTickets,
search: (ev, callback) =>
queryTicketTypes(currentSummit.id, { name: ev }, callback, "v2"),
delete: { onClick: this.handleTicketUnLink },
add: { onClick: this.handleTicketLink }
}
Expand Down
34 changes: 24 additions & 10 deletions src/pages/attendees/summit-attendees-list-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ class SummitAttendeeListPage extends React.Component {
this.handleApplyEventFilters = this.handleApplyEventFilters.bind(this);
this.handleTermChange = this.handleTermChange.bind(this);
this.handleOrAndFilter = this.handleOrAndFilter.bind(this);
this.handleParseFilters = this.handleParseFilters.bind(this);
this.state = {
showModal: false,
modalTitle: "",
Expand All @@ -148,7 +149,7 @@ class SummitAttendeeListPage extends React.Component {
term,
order,
orderDir,
attendeeFilters,
this.handleParseFilters(attendeeFilters),
selectedColumns
);
}
Expand Down Expand Up @@ -253,7 +254,7 @@ class SummitAttendeeListPage extends React.Component {
DEFAULT_PER_PAGE,
order,
orderDir,
filters,
this.handleParseFilters(filters),
extraColumns
);
}
Expand Down Expand Up @@ -294,7 +295,7 @@ class SummitAttendeeListPage extends React.Component {
perPage,
order,
orderDir,
attendeeFilters,
this.handleParseFilters(attendeeFilters),
selectedColumns
);
}
Expand All @@ -309,7 +310,7 @@ class SummitAttendeeListPage extends React.Component {
perPage,
key,
dir,
attendeeFilters,
this.handleParseFilters(attendeeFilters),
selectedColumns
);
}
Expand All @@ -323,7 +324,7 @@ class SummitAttendeeListPage extends React.Component {
perPage,
order,
orderDir,
attendeeFilters,
this.handleParseFilters(attendeeFilters),
selectedColumns
);
}
Expand Down Expand Up @@ -362,7 +363,7 @@ class SummitAttendeeListPage extends React.Component {
perPage,
order,
orderDir,
attendeeFilters,
this.handleParseFilters(attendeeFilters),
selectedColumns
);
}
Expand Down Expand Up @@ -460,10 +461,13 @@ class SummitAttendeeListPage extends React.Component {
: `${ev.target.operator}${ev.target.value}`;
}
}
this.setState({
...this.state,
attendeeFilters: { ...this.state.attendeeFilters, [id]: value }
});
this.setState(
{
...this.state,
attendeeFilters: { ...this.state.attendeeFilters, [id]: value }
},
() => console.log("CHECK...", this.state.attendeeFilters)
);
}

handleOrAndFilter(ev) {
Expand All @@ -477,6 +481,16 @@ class SummitAttendeeListPage extends React.Component {
this.props.changeAttendeeListSearchTerm(term);
}

handleParseFilters(filters) {
const parsedFilters = { ...filters };
if (parsedFilters.ticketTypeFilter.length > 0) {
parsedFilters.ticketTypeFilter = filters.ticketTypeFilter.map(
(tt) => tt.id
);
}
return parsedFilters;
}

render() {
const {
currentSummit,
Expand Down
4 changes: 0 additions & 4 deletions src/pages/tickets/registration-invitations-list-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -560,10 +560,6 @@ class RegistrationInvitationsListPage extends React.Component {

if (!currentSummit.id) return <div />;

// const ticketTypesFilterDDL = currentSummit.ticket_types.map((t) => {
// return { label: t.name, value: t.id };
// });

const flowEventsDDL = [
{ label: "-- SELECT EMAIL EVENT --", value: "" },
{
Expand Down
2 changes: 1 addition & 1 deletion src/pages/tickets/ticket-list-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -1029,7 +1029,7 @@ class TicketListPage extends React.Component {
onChange={(ev) =>
this.handleFilterChange(
"ticketTypesFilter",
ev.target.value
ev.target.value.map((tt) => ({ ...tt, value: tt.id }))
)
}
isMulti
Expand Down

0 comments on commit 3cc95cd

Please sign in to comment.