-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Feature multiselect notes delete and move to another folder #1070
Conversation
I crucially wanted this feature. Thank you for your great contribution every time! |
Please commit |
Todo
|
I implemented follows in addition to multi deletions and multi move notes to other folder Multi Pins to topMulti Select with
|
@kazup01 Please review this pull request ^^ |
Great! Thank you :) |
browser/main/NoteList/index.js
Outdated
@@ -124,27 +144,49 @@ class NoteList extends React.Component { | |||
} | |||
} | |||
|
|||
focusNote (selectedNoteKeys, noteKey) { | |||
let { router } = this.context | |||
let { location } = this.props |
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.
plz use const
instead of let
🙏
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.
(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)
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.
I strongly agree with your suggestion! I changed
browser/main/NoteList/index.js
Outdated
}) | ||
if (!shiftKeyDown) { selectedNoteKeys = [] } | ||
const priorNote = Object.assign({}, this.notes[targetIndex]) | ||
const priorNoteKey = `${priorNote.storage}-${priorNote.key}` |
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.
You can use getNoteKey
for creating note key.
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.
I used that. Thanks.
browser/main/NoteList/index.js
Outdated
if (!shiftKeyDown) { selectedNoteKeys = [] } | ||
const priorNote = Object.assign({}, this.notes[targetIndex]) | ||
const priorNoteKey = `${priorNote.storage}-${priorNote.key}` | ||
if (selectedNoteKeys.includes(priorNoteKey)) { |
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.
You can use findNoteByKey
to check that note key exists in array or not.
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.
@sota1235
No, It findNoteByKey
is only for find note
not keys.
Currently I have state that only save selectedNoteKeys
not notes
browser/main/NoteList/index.js
Outdated
if (targetIndex === this.notes.length - 1) { | ||
if (targetIndex === this.notes.length - 1 && shiftKeyDown) { | ||
return | ||
} else if (targetIndex === this.notes.length - 1) { |
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.
Please add some variables to keep value of targetIndex === this.notes.length - 1
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.
I added variable. Thank you!
btw, this feature is so useful :) Thank you so much for your contributon! |
@sota1235 Thank you for review! I will check as soon as possible ^^ |
Thank you @voidsatisfaction :) |
browser/main/NoteList/index.js
Outdated
@@ -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) { |
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.
should add && shiftKeyDown
browser/main/NoteList/index.js
Outdated
@@ -124,27 +144,49 @@ class NoteList extends React.Component { | |||
} | |||
} | |||
|
|||
focusNote (selectedNoteKeys, noteKey) { | |||
let { router } = this.context | |||
let { location } = this.props |
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.
I strongly agree with your suggestion! I changed
browser/main/NoteList/index.js
Outdated
}) | ||
if (!shiftKeyDown) { selectedNoteKeys = [] } | ||
const priorNote = Object.assign({}, this.notes[targetIndex]) | ||
const priorNoteKey = `${priorNote.storage}-${priorNote.key}` |
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.
I used that. Thanks.
browser/main/NoteList/index.js
Outdated
if (!shiftKeyDown) { selectedNoteKeys = [] } | ||
const priorNote = Object.assign({}, this.notes[targetIndex]) | ||
const priorNoteKey = `${priorNote.storage}-${priorNote.key}` | ||
if (selectedNoteKeys.includes(priorNoteKey)) { |
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.
@sota1235
No, It findNoteByKey
is only for find note
not keys.
Currently I have state that only save selectedNoteKeys
not notes
browser/main/NoteList/index.js
Outdated
if (targetIndex === this.notes.length - 1) { | ||
if (targetIndex === this.notes.length - 1 && shiftKeyDown) { | ||
return | ||
} else if (targetIndex === this.notes.length - 1) { |
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.
I added variable. Thank you!
browser/main/NoteList/index.js
Outdated
}) | ||
const { selectedNoteKeys } = this.state | ||
const note = findNoteByKey(this.notes, uniqueKey) | ||
const noteKey = `${note.storage}-${note.key}` |
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.
Thank you for notice!
deleteNote () { | ||
const { dispatch } = this.props | ||
const { selectedNoteKeys } = this.state | ||
const notes = this.notes.map((note) => Object.assign({}, note)) |
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.
@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)) |
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.
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) |
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.
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..
browser/main/SideNav/StorageItem.js
Outdated
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 |
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.
Thank you for notice!
Hi @voidsatisfaction , I'm so sorry for our long absence. Could you fix conflicts? |
@kazup01 sure. I will do that. |
@kazup01 I fixed conflicts please check it :D |
Thanks @voidsatisfaction ;) |
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.
Thank you for fixing :)
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.
LGTM
Merged. Thanks @voidsatisfaction ! |
@kazup01 I'm really glad to hear that ^^ |
multiselect with |
WHY?
#1058
HOW?
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.