Skip to content

Commit

Permalink
Expand SelectedGA interface and add SelectableGA (#19)
Browse files Browse the repository at this point in the history
* Expand SelectedGA interface and add SelectableGA

* Update selectableObjects type and add test

* Refactoring + removed deprecated properties

---------

Co-authored-by: mroloux <[email protected]>
  • Loading branch information
mortendevold and mroloux authored Sep 3, 2024
1 parent 6866e3b commit 012e3f9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
6 changes: 3 additions & 3 deletions src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const fullChartRendererConfig: Required<ChartRendererConfigOptions> = {
amount: 4
},
],
selectableObjects: ['A-1', 'A-2'],
selectableObjects: ['A-1', 'A-2', { label: 'GA', amount: 4 }],
selectionValidators: [
{ type: 'minimumSelectedPlaces', minimum: 4 },
{ type: 'consecutiveSeats' },
Expand Down Expand Up @@ -434,8 +434,8 @@ new seatsio.SeatingChartDesigner({
})

// Seating chart tests
seatingChart.selectObjects(['A1', { id: 'someId', ticketType: 'aTicketType', amount: 2}])
seatingChart.deselectObjects(['A1', { id: 'someId', ticketType: 'aTicketType', amount: 2}])
seatingChart.selectObjects(['A1', { label: 'someLabel', ticketType: 'aTicketType', amount: 2 }, { label: 'anotherLabel', amount: 2 }])
seatingChart.deselectObjects(['A1', { label: 'someLabel', ticketType: 'aTicketType', amount: 2 }])

seatingChart.listSelectedObjects().then(objects => {
objects.forEach(obj => {
Expand Down
21 changes: 8 additions & 13 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,11 @@ export interface ChartRendererConfigOptions extends DeprecatedConfigProperties,
/**
* Render the chart with the specified objects selected (if they are still free). {@link https://docs.seats.io/docs/renderer/config-selectedobjects See documentation}
*/
selectedObjects?: (string | SelectedObject | SelectedGA)[]
selectedObjects?: (string | SelectedAmount)[]
/**
* Render the chart with the specified objects selectable. {@link https://docs.seats.io/docs/renderer/selectableobjects See documentation}
*/
selectableObjects?: string[]
selectableObjects?: (string | SelectableAmount)[]
/**
* Selection validators run every time a seat is selected or deselected. They check whether there are no orphan seats, and/or whether all selected seats are consecutive (meaning: next to each other and in the same category). {@link https://docs.seats.io/docs/renderer/config-selectionvalidators See documentation}
*/
Expand Down Expand Up @@ -418,7 +418,7 @@ export interface EventManagerSelectModeConfigOptions extends BaseEventManagerCon
maxSelectedObjects?: SelectionLimiter
numberOfPlacesToSelect?: number
isObjectSelectable?: (object: SelectableObject) => boolean
selectedObjects?: (string | SelectedObject | SelectedGA)[]
selectedObjects?: (string | SelectedAmount)[]
selectionBy?: 'places' | 'objects'
ticketTypes?: TicketTypeJsonWithoutPrice[]
tooltipContents?: (object: object) => string
Expand Down Expand Up @@ -1149,12 +1149,7 @@ interface SelectionValidatorMinimumSelectedPlaces {
minimum: number
}

export interface SelectedObject {
label: string
ticketType: string
}

export interface SelectedGA {
export interface SelectableAmount {
label: string
amount: number
}
Expand Down Expand Up @@ -1319,7 +1314,7 @@ export interface SeatingChart {
changeConfig: (config: ConfigChange) => Promise<void>
clearSelection: () => Promise<void>
deselectCategories: (categoryIds: string[]) => Promise<void>
deselectObjects: (objects: (string | Selection)[]) => Promise<void>
deselectObjects: (objects: (string | SelectedAmount)[]) => Promise<void>
destroy: () => void
findObject: (label: string) => Promise<SelectableObject>
getReportBySelectability: () => Promise<Object>
Expand All @@ -1331,7 +1326,7 @@ export interface SeatingChart {
resetView: () => Promise<void>
selectCategories: (categoryIds: string[]) => Promise<void>
selectedObjects: string[]
selectObjects: (objects: (string | Selection)[]) => Promise<void>
selectObjects: (objects: (string | SelectedAmount)[]) => Promise<void>
pulse: (objects: string []) => Promise<void>
unpulse: (objects: string []) => Promise<void>
startNewSession: () => Promise<void>
Expand Down Expand Up @@ -1374,8 +1369,8 @@ export interface Channel {
index: number
}

export type Selection = {
id: string
export type SelectedAmount = {
label: string
ticketType?: string
amount?: number
}
Expand Down

0 comments on commit 012e3f9

Please sign in to comment.