1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-13 17:56:25 +00:00

Added folder labels to note items when viewing a specific storage

This commit is contained in:
pfftdammitchris
2018-02-22 17:31:31 -08:00
parent 8b4c1a6c38
commit 2a26e8a010
2 changed files with 28 additions and 8 deletions

View File

@@ -48,14 +48,15 @@ const TagElementList = (tags) => {
*/
const NoteItem = ({
isActive,
isAllNotesView,
note,
dateDisplay,
handleNoteClick,
handleNoteContextMenu,
handleDragStart,
pathname,
storage
storageName,
folderName,
viewType
}) => (
<div styleName={isActive
? 'item--active'
@@ -78,12 +79,13 @@ const NoteItem = ({
: <span styleName='item-title-empty'>Empty</span>
}
</div>
{isAllNotesView && <div styleName='item-middle'>
{['ALL', 'STORAGE'].includes(viewType) && <div styleName='item-middle'>
<div styleName='item-middle-time'>{dateDisplay}</div>
<div styleName='item-middle-app-meta'>
<div style={{display: 'inline-block'}}>
<span styleName='item-middle-app-meta-label'>
{storage.name}
{viewType === 'ALL' && storageName}
{viewType === 'STORAGE' && folderName}
</span>
</div>
</div>

View File

@@ -67,6 +67,8 @@ class NoteList extends React.Component {
this.focusNote = this.focusNote.bind(this)
this.pinToTop = this.pinToTop.bind(this)
this.getNoteStorage = this.getNoteStorage.bind(this)
this.getNoteFolder = this.getNoteFolder.bind(this)
this.getViewType = this.getViewType.bind(this)
// TODO: not Selected noteKeys but SelectedNote(for reusing)
this.state = {
@@ -696,6 +698,20 @@ class NoteList extends React.Component {
return this.props.data.storageMap.toJS()[note.storage]
}
getNoteFolder (note) { // note.folder = folder key
return _.find(this.getNoteStorage(note).folders, ({ key }) => key === note.folder)
}
getViewType () {
const { pathname } = this.props.location
const folder = /\/folders\/[a-zA-Z0-9]+/.test(pathname)
const storage = /\/storages\/[a-zA-Z0-9]+/.test(pathname) && !folder
const allNotes = pathname === '/home'
if (allNotes) return 'ALL'
if (folder) return 'FOLDER'
if (storage) return 'STORAGE'
}
render () {
const { location, config } = this.props
let { notes } = this.props
@@ -750,7 +766,6 @@ class NoteList extends React.Component {
return (
<NoteItem
isActive={isActive}
isAllNotesView={location.pathname === '/home'}
note={note}
dateDisplay={dateDisplay}
key={uniqueKey}
@@ -758,7 +773,9 @@ class NoteList extends React.Component {
handleNoteClick={this.handleNoteClick.bind(this)}
handleDragStart={this.handleDragStart.bind(this)}
pathname={location.pathname}
storage={this.getNoteStorage(note)}
folderName={this.getNoteFolder(note).name}
storageName={this.getNoteStorage(note).name}
viewType={this.getViewType()}
/>
)
}
@@ -766,14 +783,15 @@ class NoteList extends React.Component {
return (
<NoteItemSimple
isActive={isActive}
isAllNotesView={location.pathname === '/home'}
note={note}
key={uniqueKey}
handleNoteContextMenu={this.handleNoteContextMenu.bind(this)}
handleNoteClick={this.handleNoteClick.bind(this)}
handleDragStart={this.handleDragStart.bind(this)}
pathname={location.pathname}
storage={this.getNoteStorage(note)}
folderName={this.getNoteFolder(note).name}
storageName={this.getNoteStorage(note).name}
viewType={this.getViewType()}
/>
)
})