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

Feature multiselect notes delete and move to another folder #1070

Merged

Conversation

voidsatisfaction
Copy link
Contributor

@voidsatisfaction voidsatisfaction commented Nov 5, 2017

WHY?

#1058

HOW?

multi_delete_and_drag_notes

  • multi selection with shift key
  • multi delete
  • multi drag and drop

I made it by giving state to NoteList

I changed lots of codes so that there would be mistakes.. If so, please let me know then I will fix it.

@voidsatisfaction voidsatisfaction changed the title Feature add multiselect notes then delete and move to another folder Feature multiselect notes delete and move to another folder Nov 5, 2017
@kazup01
Copy link
Member

kazup01 commented Nov 5, 2017

I crucially wanted this feature. Thank you for your great contribution every time!
We will check it!

@kazup01 kazup01 requested a review from sota1235 November 5, 2017 15:06
@tatoosh
Copy link

tatoosh commented Nov 6, 2017

Please commit

@voidsatisfaction
Copy link
Contributor Author

voidsatisfaction commented Nov 6, 2017

Todo

  • Support multiple notes shortcut delete
  • Support multiple pin to top
  • Refactor from saving state of note-id to note object refactor codes

@voidsatisfaction voidsatisfaction changed the title Feature multiselect notes delete and move to another folder [WIP]Feature multiselect notes delete and move to another folder Nov 6, 2017
@voidsatisfaction voidsatisfaction changed the title [WIP]Feature multiselect notes delete and move to another folder [WIP] Feature multiselect notes delete and move to another folder Nov 6, 2017
@kazup01 kazup01 added the awaiting changes 🖊️ Pull request has been reviewed, but contributor needs to make changes. label Nov 7, 2017
@voidsatisfaction voidsatisfaction changed the title [WIP] Feature multiselect notes delete and move to another folder Feature multiselect notes delete and move to another folder Nov 7, 2017
@voidsatisfaction
Copy link
Contributor Author

I implemented follows in addition to multi deletions and multi move notes to other folder

Multi Pins to top

multi-pintotop

Multi Select with shift + arrow-down(up as well) + Multi Delete with shift + d

multi-delete-with-arrows

I tried Ctrl + leftClick to multi selection. But it pops up context menu therefore I thought it is also okay to use shift instead

@voidsatisfaction
Copy link
Contributor Author

@kazup01 Please review this pull request ^^

@kazup01
Copy link
Member

kazup01 commented Nov 7, 2017

Great! Thank you :)

@kazup01 kazup01 added awaiting review ❇️ Pull request is awaiting a review. and removed awaiting changes 🖊️ Pull request has been reviewed, but contributor needs to make changes. labels Nov 7, 2017
@@ -124,27 +144,49 @@ class NoteList extends React.Component {
}
}

focusNote (selectedNoteKeys, noteKey) {
let { router } = this.context
let { location } = this.props
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

plz use const instead of let 🙏

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(we know there are many let in existing code. but it doesn't make sense, so we want to use const as possible as we can)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I strongly agree with your suggestion! I changed

})
if (!shiftKeyDown) { selectedNoteKeys = [] }
const priorNote = Object.assign({}, this.notes[targetIndex])
const priorNoteKey = `${priorNote.storage}-${priorNote.key}`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use getNoteKey for creating note key.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used that. Thanks.

if (!shiftKeyDown) { selectedNoteKeys = [] }
const priorNote = Object.assign({}, this.notes[targetIndex])
const priorNoteKey = `${priorNote.storage}-${priorNote.key}`
if (selectedNoteKeys.includes(priorNoteKey)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use findNoteByKey to check that note key exists in array or not.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sota1235
No, It findNoteByKeyis only for find note not keys.

Currently I have state that only save selectedNoteKeys not notes

if (targetIndex === this.notes.length - 1) {
if (targetIndex === this.notes.length - 1 && shiftKeyDown) {
return
} else if (targetIndex === this.notes.length - 1) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add some variables to keep value of targetIndex === this.notes.length - 1

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added variable. Thank you!

@sota1235
Copy link
Contributor

sota1235 commented Nov 13, 2017

btw, this feature is so useful :) Thank you so much for your contributon!

@voidsatisfaction
Copy link
Contributor Author

@sota1235 Thank you for review! I will check as soon as possible ^^

@kazup01 kazup01 added awaiting changes 🖊️ Pull request has been reviewed, but contributor needs to make changes. and removed awaiting review ❇️ Pull request is awaiting a review. labels Nov 14, 2017
@voidsatisfaction
Copy link
Contributor Author

@sota1235 @kazup01 I reviewed feedbacks.

@kazup01
Copy link
Member

kazup01 commented Nov 15, 2017

Thank you @voidsatisfaction :)

@kazup01 kazup01 added awaiting review ❇️ Pull request is awaiting a review. and removed awaiting changes 🖊️ Pull request has been reviewed, but contributor needs to make changes. labels Nov 15, 2017
@@ -176,22 +182,30 @@ class NoteList extends React.Component {
}
let { router } = this.context
let { location } = this.props
let { selectedNoteKeys } = this.state
let { selectedNoteKeys, shiftKeyDown } = this.state

let targetIndex = this.getTargetIndex()

if (targetIndex === this.notes.length - 1) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should add && shiftKeyDown

@@ -124,27 +144,49 @@ class NoteList extends React.Component {
}
}

focusNote (selectedNoteKeys, noteKey) {
let { router } = this.context
let { location } = this.props
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I strongly agree with your suggestion! I changed

})
if (!shiftKeyDown) { selectedNoteKeys = [] }
const priorNote = Object.assign({}, this.notes[targetIndex])
const priorNoteKey = `${priorNote.storage}-${priorNote.key}`
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used that. Thanks.

if (!shiftKeyDown) { selectedNoteKeys = [] }
const priorNote = Object.assign({}, this.notes[targetIndex])
const priorNoteKey = `${priorNote.storage}-${priorNote.key}`
if (selectedNoteKeys.includes(priorNoteKey)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sota1235
No, It findNoteByKeyis only for find note not keys.

Currently I have state that only save selectedNoteKeys not notes

if (targetIndex === this.notes.length - 1) {
if (targetIndex === this.notes.length - 1 && shiftKeyDown) {
return
} else if (targetIndex === this.notes.length - 1) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added variable. Thank you!

})
const { selectedNoteKeys } = this.state
const note = findNoteByKey(this.notes, uniqueKey)
const noteKey = `${note.storage}-${note.key}`
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for notice!

deleteNote () {
const { dispatch } = this.props
const { selectedNoteKeys } = this.state
const notes = this.notes.map((note) => Object.assign({}, note))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sota1235
If I simply put const notes = this.notes and then delete note, It will not update store because a note is object and note.isTrashed = true makes store's note value also change(mutable)

So, I made new note objects with same content not to influence store's note

deleteNote () {
const { dispatch } = this.props
const { selectedNoteKeys } = this.state
const notes = this.notes.map((note) => Object.assign({}, note))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is hard to explain but You will notice why I did this if you just try it :D

})
})
.catch((err) => {
console.error('Cannot Delete note: ' + err)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great suggestion! however, I think making new modal window task should be done with another branch because it only handles multi-selection and such things..

dropNote (storage, folder, dispatch, location, noteData) {
noteData = noteData.filter((note) => folder.key !== note.folder)
const newNoteData = noteData.map((note) => Object.assign({}, note, {storage: storage, folder: folder.key}))
if (noteData.length === 0) return
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for notice!

@kazup01
Copy link
Member

kazup01 commented Nov 26, 2017

Hi @voidsatisfaction , I'm so sorry for our long absence. Could you fix conflicts?

@voidsatisfaction
Copy link
Contributor Author

@kazup01 sure. I will do that.

@voidsatisfaction
Copy link
Contributor Author

@kazup01 I fixed conflicts please check it :D

@kazup01
Copy link
Member

kazup01 commented Nov 27, 2017

Thanks @voidsatisfaction ;)

Copy link
Contributor

@sota1235 sota1235 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for fixing :)

Copy link
Member

@kazup01 kazup01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kazup01 kazup01 merged commit edfc8d9 into BoostIO:master Nov 28, 2017
@kazup01
Copy link
Member

kazup01 commented Nov 28, 2017

Merged. Thanks @voidsatisfaction !
I will write this pull request to the v0.8.18 release note :)

@kazup01 kazup01 added next release (v0.8.18) and removed awaiting review ❇️ Pull request is awaiting a review. Next Release labels Nov 28, 2017
@voidsatisfaction
Copy link
Contributor Author

@kazup01 I'm really glad to hear that ^^

@voidsatisfaction voidsatisfaction deleted the feature/add_multiselect_notes_delete branch November 28, 2017 07:15
@kohei-takata kohei-takata mentioned this pull request Dec 3, 2017
@ghost
Copy link

ghost commented Aug 22, 2018

multiselect with shift works, but as soon as I try to drag I lose my selected notes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants