-
Notifications
You must be signed in to change notification settings - Fork 21
Test dnd #27
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
Open
momonomonoto
wants to merge
7
commits into
romabelka:master
Choose a base branch
from
momonomonoto:test_dnd
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Test dnd #27
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
36b38eb
Events list
momonomonoto 71b62e6
Add style for basket and TableEventList
momonomonoto e2dc95f
Add draggable list
momonomonoto b534789
Add dropable
momonomonoto a0ce4c6
Delete event
momonomonoto 50ee074
delete by redux
momonomonoto f536bf2
Fixes
momonomonoto File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| import React, { Component } from 'react' | ||
| import {Link} from 'react-router-dom' | ||
| import {DropTarget} from 'react-dnd' | ||
| import {connect} from 'react-redux' | ||
| import {deleteEvent} from '../../ducks/events' | ||
|
|
||
|
|
||
| class Basket extends Component { | ||
| static propTypes = { | ||
|
|
||
| }; | ||
|
|
||
| render() { | ||
| const {connectDropTarget, hovered, canDrop, people} = this.props | ||
| const dropStyle = { | ||
| border: `4px solid ${canDrop?`black`:`transparent`}` | ||
| } | ||
| return connectDropTarget( | ||
| <div style={{width:'200px',height:'100px ',backgroundColor:'#a68585',...dropStyle}}> | ||
| Drag event here to delete! | ||
| </div> | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| const collect = (connect, monitor) => ({ | ||
| connectDropTarget: connect.dropTarget(), | ||
| canDrop: monitor.canDrop(), | ||
| hovered: monitor.isOver() | ||
| }) | ||
|
|
||
| const spec = { | ||
| drop(props, monitor) { | ||
| const eventDragUid = monitor.getItem().uid | ||
| console.log(eventDragUid,'eventDragUid'); | ||
| console.log('start'); | ||
| props.deleteEvent(eventDragUid); | ||
| return { eventDragUid } | ||
| } | ||
| } | ||
|
|
||
| export default connect(null, {deleteEvent}) (DropTarget ('event',spec, collect)(Basket)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| import React, {Component} from 'react' | ||
| import {Link} from 'react-router-dom' | ||
| import {DragSource} from 'react-dnd' | ||
|
|
||
| class TableEventCard extends Component { | ||
| static propTypes = {}; | ||
|
|
||
| render() { | ||
|
|
||
| const {connectDragSource,isDragging, event: {uid, title, where, month}} = this.props; | ||
| const dragStyle = { | ||
| backgroundColor:isDragging?'gray':'white' | ||
| } | ||
| return this.props.connectDragSource( | ||
| <div style={{border:'1px solid black',...dragStyle}} key={uid} onClick={()=>console.log('onClick')} className="test--event-list__row" > | ||
| <span>{title}</span> | ||
| <span>{where}</span> | ||
| <span>{month}</span> | ||
| </div> | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| const spec = { | ||
| beginDrag(props) { | ||
| return { | ||
| uid:props.event.uid | ||
| } | ||
| } | ||
| } | ||
|
|
||
| const collect = (connect, monitor) => ({ | ||
| connectDragSource: connect.dragSource(), | ||
| connectPreview: connect.dragPreview(), | ||
| isDragging: monitor.isDragging(), | ||
| }) | ||
|
|
||
| export default DragSource('event', spec, collect)(TableEventCard) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,49 +1,56 @@ | ||
| import React, { Component } from 'react' | ||
| import React, {Component} from 'react' | ||
| import {connect} from 'react-redux' | ||
| import {moduleName, fetchAll, selectEvent, eventListSelector} from '../../ducks/events' | ||
| import {List, InfiniteLoader} from 'react-virtualized' | ||
| import {moduleName, fetchLazy, selectEvent, eventListSelector} from '../../ducks/events' | ||
| import Loader from '../common/Loader' | ||
| import TableEventCard from './TableEventCard' | ||
|
|
||
| export class EventList extends Component { | ||
| static propTypes = { | ||
|
|
||
| }; | ||
| static propTypes = {}; | ||
|
|
||
| componentDidMount() { | ||
| this.props.fetchAll() | ||
| this.props.fetchLazy() | ||
| } | ||
|
|
||
| isRowLoaded = ({index}) => index < this.props.events.length | ||
| loadMoreRows = () => { | ||
| console.log('---', 'load more') | ||
| this.props.fetchLazy() | ||
| } | ||
| render() { | ||
|
|
||
| const {loaded, events} = this.props | ||
| console.log(events.length,'events.length'); | ||
| if (this.props.loading) return <Loader/> | ||
| return ( | ||
| <div> | ||
| <table> | ||
| <tbody> | ||
| {this.getRows()} | ||
| </tbody> | ||
| </table> | ||
| </div> | ||
| <InfiniteLoader | ||
| isRowLoaded={this.isRowLoaded} | ||
| rowCount={loaded ? events.length : events.length + 1} | ||
| loadMoreRows={this.loadMoreRows} | ||
| > | ||
| {({onRowsRendered, registerChild}) => | ||
| <List | ||
| rowCount={events.length} | ||
| rowHeight={100} | ||
| height={300} | ||
| width={600} | ||
| rowRenderer={this.getRows} | ||
| /> | ||
| } | ||
| </InfiniteLoader> | ||
| ) | ||
| } | ||
|
|
||
| getRows() { | ||
| return this.props.events.map(this.getRow) | ||
| } | ||
|
|
||
| getRow = (event) => { | ||
| return <tr key={event.uid} className="test--event-list__row" onClick={this.handleRowClick(event.uid)}> | ||
| <td>{event.title}</td> | ||
| <td>{event.where}</td> | ||
| <td>{event.month}</td> | ||
| </tr> | ||
| getRows = (event) => { | ||
| return this.props.events.map(event => <TableEventCard event={event}/>) | ||
| } | ||
|
|
||
| handleRowClick = (uid) => () => { | ||
| const {selectEvent} = this.props | ||
| selectEvent && selectEvent(uid) | ||
| } | ||
| } | ||
|
|
||
| export default connect(state => ({ | ||
| events: eventListSelector(state), | ||
| loading: state[moduleName].loading | ||
| }), {fetchAll, selectEvent})(EventList) | ||
| }), {fetchLazy, selectEvent})(EventList) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,13 @@ | ||
| import firebase from 'firebase' | ||
|
|
||
| export const appName = "advreact-21-08" | ||
| export const appName = "advreact-21-081" | ||
| export const firebaseConfig = { | ||
| apiKey: "AIzaSyDjA6CeIHuni5lNm4ML1b-TSxJltsYUO8g", | ||
| authDomain: `${appName}.firebaseapp.com`, | ||
| databaseURL: `https://${appName}.firebaseio.com`, | ||
| projectId: appName, | ||
| storageBucket: `${appName}.appspot.com`, | ||
| messagingSenderId: "789814589283" | ||
| apiKey: "AIzaSyC0hcpDsBhr85usoHIwloBeYbkDHeUcqKo", | ||
| authDomain: "advreact-21-081.firebaseapp.com", | ||
| databaseURL: "https://advreact-21-081.firebaseio.com", | ||
| projectId: "advreact-21-081", | ||
| storageBucket: "advreact-21-081.appspot.com", | ||
| messagingSenderId: "450237050585" | ||
| } | ||
|
|
||
| firebase.initializeApp(firebaseConfig) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Функция для отправки текущего event в TableEventCard