-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Move note between folders #374
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
Changes from 7 commits
720f07f
50cd0b7
25685dc
b73f0a8
f8b7b7d
43cb290
9c1179a
b86cdb4
e6047ed
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,7 @@ import CreateFolderModal from 'browser/main/modals/CreateFolderModal' | |
| import RenameFolderModal from 'browser/main/modals/RenameFolderModal' | ||
| import dataApi from 'browser/main/lib/dataApi' | ||
| import StorageItemChild from 'browser/components/StorageItem' | ||
| import eventEmitter from 'browser/main/lib/eventEmitter' | ||
|
|
||
| const { remote } = require('electron') | ||
| const { Menu, MenuItem, dialog } = remote | ||
|
|
@@ -131,8 +132,54 @@ class StorageItem extends React.Component { | |
| } | ||
| } | ||
|
|
||
| handleDragEnter (e) { | ||
| e.dataTransfer.setData('defaultColor', e.target.style.backgroundColor) | ||
| e.target.style.backgroundColor = 'rgba(129, 130, 131, 0.08)' | ||
| } | ||
|
|
||
| handleDragLeave (e) { | ||
| e.target.style.opacity = '1' | ||
| e.target.style.backgroundColor = e.dataTransfer.getData('defaultColor') | ||
| } | ||
|
|
||
| handleDrop (e, storage, folder, dispatch, location) { | ||
| e.target.style.opacity = '1' | ||
| e.target.style.backgroundColor = e.dataTransfer.getData('defaultColor') | ||
| const noteData = JSON.parse(e.dataTransfer.getData('note')) | ||
| const newNoteData = Object.assign({}, noteData, {storage: storage, folder: folder.key}) | ||
| if (folder.key === noteData.folder) return | ||
| dataApi | ||
| .createNote(storage.key, newNoteData) | ||
| .then((note) => { | ||
| dataApi | ||
| .deleteNote(noteData.storage, noteData.key) | ||
| .then((data) => { | ||
|
||
| let dispatchHandler = () => { | ||
| dispatch({ | ||
| type: 'DELETE_NOTE', | ||
| storageKey: data.storageKey, | ||
| noteKey: data.noteKey | ||
| }) | ||
| } | ||
| eventEmitter.once('list:moved', dispatchHandler) | ||
| eventEmitter.emit('list:next') | ||
| }) | ||
| .catch((err) => { | ||
| console.error(err) | ||
| }) | ||
| dispatch({ | ||
| type: 'UPDATE_NOTE', | ||
| note: note | ||
| }) | ||
| hashHistory.push({ | ||
| pathname: location.pathname, | ||
| query: {key: note.storage + '-' + note.key} | ||
|
||
| }) | ||
| }) | ||
| } | ||
|
|
||
| render () { | ||
| let { storage, location, isFolded, data } = this.props | ||
| let { storage, location, isFolded, data, dispatch } = this.props | ||
| let { folderNoteMap } = data | ||
| let folderList = storage.folders.map((folder) => { | ||
| let isActive = !!(location.pathname.match(new RegExp('\/storages\/' + storage.key + '\/folders\/' + folder.key))) | ||
|
|
@@ -151,6 +198,9 @@ class StorageItem extends React.Component { | |
| folderColor={folder.color} | ||
| isFolded={isFolded} | ||
| noteCount={noteCount} | ||
| handleDrop={(e) => this.handleDrop(e, storage, folder, dispatch, location)} | ||
| handleDragEnter={this.handleDragEnter} | ||
| handleDragLeave={this.handleDragLeave} | ||
| /> | ||
| ) | ||
| }) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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.
Could you change the background-color? Because it's hard to find the target folder.
Uh oh!
There was an error while loading. Please reload this page.
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.
@sosukesuzuki what do you think about this?
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.
Thanks for commenting @asmsuechan !
Even now, the background color of the folder that is hover while dragging is supposed to change. How do you want the background color to change?
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.
Oh, I didn't confirm the color changed.