1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-13 01:36:22 +00:00

Move note between folders

This commit is contained in:
Sosuke Suzuki
2017-04-01 02:36:48 +09:00
parent 6904c192e4
commit 720f07f62c
5 changed files with 71 additions and 7 deletions

View File

@@ -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 ee from 'browser/main/lib/eventEmitter'
const { remote } = require('electron')
const { Menu, MenuItem, dialog } = remote
@@ -131,8 +132,52 @@ class StorageItem extends React.Component {
}
}
handleDrop (e, storage, folder, dispatch, location) {
const noteData = JSON.parse(e.dataTransfer.getData("note"))
if (folder.key !== noteData.folder) {
dataApi
.createNote(storage.key, {
content: noteData.content,
createdAt: noteData.createdAt,
folder: folder.key,
isStarred: noteData.isStarred,
storage: storage,
title: noteData.title,
tags: noteData.tags,
type: noteData.type,
updatedAt: noteData.updatedAt,
description: noteData.description,
snippets: noteData.snippets
})
.then((note) => {
dispatch({
type: 'UPDATE_NOTE',
note: note
})
hashHistory.push({
pathname: location.pathname,
query: {key: note.storage + '-' + note.key}
})
})
dataApi
.deleteNote(noteData.storage, noteData.key)
.then((data) => {
let dispatchHandler = () => {
dispatch({
type: 'DELETE_NOTE',
storageKey: data.storageKey,
noteKey: data.noteKey
})
}
ee.once('list:moved', dispatchHandler)
ee.emit('list:next')
})
}
}
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 +196,7 @@ class StorageItem extends React.Component {
folderColor={folder.color}
isFolded={isFolded}
noteCount={noteCount}
handleDrop={(e) => this.handleDrop(e, storage, folder, dispatch, location)}
/>
)
})