Sha256: 71449dd39ec21207b473a16c940f21f554308edb863c82227b0c3d230ec06664

Contents?: true

Size: 1.96 KB

Versions: 3

Compression:

Stored size: 1.96 KB

Contents

##= require ./PopoverMiniControls
##= require ./EditEntry

class Skr.Screens.TimeTracking.Popover extends Lanes.React.Component

    componentWillReceiveProps: (nextProps) ->
        if @state.editing and nextProps.editing is false
            @onCancel()
        else
            @setState(isCanceled: false)

    onCancel: ->
        if @state.editing?.get('entry').isNew()
            @state.editing.remove()
        @props.entries.stopEditing()
        @setState(isCanceled: true, editing: null)

    onAddEntry: ->
        event = @props.entries.addEvent(@props.date)
        @setState(editing: event)

    onEditEvent: (event) ->
        @setState(editing: event)

    EditEntry: ->
        return null unless @state.editing
        <Skr.Screens.TimeTracking.EditEntry
            event={@state.editing}
            entries={@props.entries}
            date={@props.date}
            onCancel={@onCancel}
        />

    MiniControls: ->
        return null if @state.editing
        <Skr.Screens.TimeTracking.MiniControls
            date={@props.date}
            event={@props.event}
            onCancel={@onCancel}
            onAddEntry={@onAddEntry}
            onEditEvent={@onEditEvent}
        />

    render: ->
        return null if @state.isCanceled or not @props.date

        classes = _.classnames('edit-control', 'in')
        {x, y} = @props.position
        [width, height] = if @state.editing
            [320, 400]
        else
            [175, 60]

        # expand to show edit button
        width += 60 if @props.event and not @state.editing

        placement = if x > (this.props.bounds.width / 2) then 'left' else 'right'

        x -= width if placement is 'left'

        <BS.Popover className={classes}
            style={{width, height}}
            id='edit-controls'
            placement={placement}
            positionLeft={x}
            positionTop={y - (height / 2)}
        >
            <@MiniControls />
            <@EditEntry />
        </BS.Popover>

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
stockor-0.4.0 client/skr/screens/time-tracking/Popover.cjsx
stockor-0.3.0 client/skr/screens/time-tracking/Popover.cjsx
stockor-0.2 client/skr/screens/time-tracking/Popover.cjsx