Skip to content
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

Enforce resizable prop #1796

Merged
merged 1 commit into from
Nov 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/DateContentRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ class DateContentRow extends React.Component {
resourceId,
longPressThreshold,
isAllDay,
resizable,
} = this.props

if (renderForMeasure) return this.renderDummy()
Expand All @@ -137,6 +138,7 @@ class DateContentRow extends React.Component {
onKeyPress,
resourceId,
slotMetrics: metrics,
resizable,
}

return (
Expand Down Expand Up @@ -187,6 +189,7 @@ DateContentRow.propTypes = {
range: PropTypes.array.isRequired,

rtl: PropTypes.bool,
resizable: PropTypes.bool,
resourceId: PropTypes.any,
renderForMeasure: PropTypes.bool,
renderHeader: PropTypes.func,
Expand Down
3 changes: 3 additions & 0 deletions src/DayColumn.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ class DayColumn extends React.Component {
step,
timeslots,
dayLayoutAlgorithm,
resizable,
} = this.props

const { slotMetrics } = this
Expand Down Expand Up @@ -233,6 +234,7 @@ class DayColumn extends React.Component {
onClick={e => this._select(event, e)}
onDoubleClick={e => this._doubleClick(event, e)}
onKeyPress={e => this._keyPress(event, e)}
resizable={resizable}
/>
)
})
Expand Down Expand Up @@ -388,6 +390,7 @@ DayColumn.propTypes = {
isNow: PropTypes.bool,

rtl: PropTypes.bool,
resizable: PropTypes.bool,

accessors: PropTypes.object.isRequired,
components: PropTypes.object.isRequired,
Expand Down
2 changes: 2 additions & 0 deletions src/EventCell.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class EventCell extends React.Component {
slotEnd,
...props
} = this.props
delete props.resizable

let title = accessors.title(event)
let tooltip = accessors.tooltip(event)
Expand Down Expand Up @@ -84,6 +85,7 @@ EventCell.propTypes = {
slotStart: PropTypes.instanceOf(Date),
slotEnd: PropTypes.instanceOf(Date),

resizable: PropTypes.bool,
selected: PropTypes.bool,
isAllDay: PropTypes.bool,
continuesPrior: PropTypes.bool,
Expand Down
2 changes: 2 additions & 0 deletions src/EventRowMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export default {
localizer,
slotMetrics,
components,
resizable,
} = props

let continuesPrior = slotMetrics.continuesPrior(event)
Expand All @@ -58,6 +59,7 @@ export default {
slotStart={slotMetrics.first}
slotEnd={slotMetrics.last}
selected={isSelected(event, selected)}
resizable={resizable}
/>
)
},
Expand Down
2 changes: 2 additions & 0 deletions src/Month.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ class MonthView extends React.Component {
onSelectSlot={this.handleSelectSlot}
longPressThreshold={longPressThreshold}
rtl={this.props.rtl}
resizable={this.props.resizable}
/>
)
}
Expand Down Expand Up @@ -323,6 +324,7 @@ MonthView.propTypes = {

scrollToTime: PropTypes.instanceOf(Date),
rtl: PropTypes.bool,
resizable: PropTypes.bool,
width: PropTypes.number,

accessors: PropTypes.object.isRequired,
Expand Down
3 changes: 3 additions & 0 deletions src/TimeGrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ export default class TimeGrid extends Component {
max,
showMultiDayTimes,
longPressThreshold,
resizable,
} = this.props

width = width || this.state.gutterWidth
Expand Down Expand Up @@ -225,6 +226,7 @@ export default class TimeGrid extends Component {
onKeyPressEvent={this.props.onKeyPressEvent}
onDrillDown={this.props.onDrillDown}
getDrilldownView={this.props.getDrilldownView}
resizable={resizable}
/>
<div
ref={this.contentRef}
Expand Down Expand Up @@ -322,6 +324,7 @@ TimeGrid.propTypes = {
showMultiDayTimes: PropTypes.bool,

rtl: PropTypes.bool,
resizable: PropTypes.bool,
width: PropTypes.number,

accessors: PropTypes.object.isRequired,
Expand Down
5 changes: 5 additions & 0 deletions src/TimeGridHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class TimeGridHeader extends React.Component {
localizer,
accessors,
components,
resizable,
} = this.props

const resourceId = accessors.resourceId(resource)
Expand Down Expand Up @@ -99,6 +100,7 @@ class TimeGridHeader extends React.Component {
onKeyPress={this.props.onKeyPressEvent}
onSelectSlot={this.props.onSelectSlot}
longPressThreshold={this.props.longPressThreshold}
resizable={resizable}
/>
)
}
Expand All @@ -122,6 +124,7 @@ class TimeGridHeader extends React.Component {
timeGutterHeader: TimeGutterHeader,
resourceHeader: ResourceHeaderComponent = ResourceHeader,
},
resizable,
} = this.props

let style = {}
Expand Down Expand Up @@ -184,6 +187,7 @@ class TimeGridHeader extends React.Component {
onKeyPress={this.props.onKeyPressEvent}
onSelectSlot={this.props.onSelectSlot}
longPressThreshold={this.props.longPressThreshold}
resizable={resizable}
/>
</div>
))}
Expand All @@ -200,6 +204,7 @@ TimeGridHeader.propTypes = {
isOverflowing: PropTypes.bool,

rtl: PropTypes.bool,
resizable: PropTypes.bool,
width: PropTypes.number,

localizer: PropTypes.object.isRequired,
Expand Down
14 changes: 10 additions & 4 deletions src/addons/dragAndDrop/EventWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class EventWrapper extends React.Component {
continuesAfter: PropTypes.bool,
isDragging: PropTypes.bool,
isResizing: PropTypes.bool,
resizable: PropTypes.bool,
}

handleResizeUp = e => {
Expand Down Expand Up @@ -68,7 +69,13 @@ class EventWrapper extends React.Component {
}

render() {
const { event, type, continuesPrior, continuesAfter } = this.props
const {
event,
type,
continuesPrior,
continuesAfter,
resizable,
} = this.props

let { children } = this.props

Expand Down Expand Up @@ -111,9 +118,8 @@ class EventWrapper extends React.Component {
* in the middle of events when showMultiDay is true, and to
* events at the edges of the calendar's min/max location.
*/
const isResizable = resizableAccessor
? !!get(event, resizableAccessor)
: true
const isResizable =
resizable && (resizableAccessor ? !!get(event, resizableAccessor) : true)

if (isResizable || isDraggable) {
/*
Expand Down
4 changes: 3 additions & 1 deletion src/addons/dragAndDrop/withDragAndDrop.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ import { mergeComponents } from './common'
* export default withDragAndDrop(Calendar)
* ```
*
* Set `resizable` to true in your calendar if you want events to be resizable.
* Set `resizable` to false in your calendar if you don't want events to be resizable.
* `resizable` is set to true by default.
*
* The HOC adds `onEventDrop`, `onEventResize`, and `onDragStart` callback properties if the events are
* moved or resized. These callbacks are called with these signatures:
Expand Down Expand Up @@ -89,6 +90,7 @@ export default function withDragAndDrop(Calendar) {
components: {},
draggableAccessor: null,
resizableAccessor: null,
resizable: true,
step: 30,
}

Expand Down