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:
@@ -48,14 +48,15 @@ const TagElementList = (tags) => {
|
|||||||
*/
|
*/
|
||||||
const NoteItem = ({
|
const NoteItem = ({
|
||||||
isActive,
|
isActive,
|
||||||
isAllNotesView,
|
|
||||||
note,
|
note,
|
||||||
dateDisplay,
|
dateDisplay,
|
||||||
handleNoteClick,
|
handleNoteClick,
|
||||||
handleNoteContextMenu,
|
handleNoteContextMenu,
|
||||||
handleDragStart,
|
handleDragStart,
|
||||||
pathname,
|
pathname,
|
||||||
storage
|
storageName,
|
||||||
|
folderName,
|
||||||
|
viewType
|
||||||
}) => (
|
}) => (
|
||||||
<div styleName={isActive
|
<div styleName={isActive
|
||||||
? 'item--active'
|
? 'item--active'
|
||||||
@@ -78,12 +79,13 @@ const NoteItem = ({
|
|||||||
: <span styleName='item-title-empty'>Empty</span>
|
: <span styleName='item-title-empty'>Empty</span>
|
||||||
}
|
}
|
||||||
</div>
|
</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-time'>{dateDisplay}</div>
|
||||||
<div styleName='item-middle-app-meta'>
|
<div styleName='item-middle-app-meta'>
|
||||||
<div style={{display: 'inline-block'}}>
|
<div style={{display: 'inline-block'}}>
|
||||||
<span styleName='item-middle-app-meta-label'>
|
<span styleName='item-middle-app-meta-label'>
|
||||||
{storage.name}
|
{viewType === 'ALL' && storageName}
|
||||||
|
{viewType === 'STORAGE' && folderName}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -67,6 +67,8 @@ class NoteList extends React.Component {
|
|||||||
this.focusNote = this.focusNote.bind(this)
|
this.focusNote = this.focusNote.bind(this)
|
||||||
this.pinToTop = this.pinToTop.bind(this)
|
this.pinToTop = this.pinToTop.bind(this)
|
||||||
this.getNoteStorage = this.getNoteStorage.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)
|
// TODO: not Selected noteKeys but SelectedNote(for reusing)
|
||||||
this.state = {
|
this.state = {
|
||||||
@@ -696,6 +698,20 @@ class NoteList extends React.Component {
|
|||||||
return this.props.data.storageMap.toJS()[note.storage]
|
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 () {
|
render () {
|
||||||
const { location, config } = this.props
|
const { location, config } = this.props
|
||||||
let { notes } = this.props
|
let { notes } = this.props
|
||||||
@@ -750,7 +766,6 @@ class NoteList extends React.Component {
|
|||||||
return (
|
return (
|
||||||
<NoteItem
|
<NoteItem
|
||||||
isActive={isActive}
|
isActive={isActive}
|
||||||
isAllNotesView={location.pathname === '/home'}
|
|
||||||
note={note}
|
note={note}
|
||||||
dateDisplay={dateDisplay}
|
dateDisplay={dateDisplay}
|
||||||
key={uniqueKey}
|
key={uniqueKey}
|
||||||
@@ -758,7 +773,9 @@ class NoteList extends React.Component {
|
|||||||
handleNoteClick={this.handleNoteClick.bind(this)}
|
handleNoteClick={this.handleNoteClick.bind(this)}
|
||||||
handleDragStart={this.handleDragStart.bind(this)}
|
handleDragStart={this.handleDragStart.bind(this)}
|
||||||
pathname={location.pathname}
|
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 (
|
return (
|
||||||
<NoteItemSimple
|
<NoteItemSimple
|
||||||
isActive={isActive}
|
isActive={isActive}
|
||||||
isAllNotesView={location.pathname === '/home'}
|
|
||||||
note={note}
|
note={note}
|
||||||
key={uniqueKey}
|
key={uniqueKey}
|
||||||
handleNoteContextMenu={this.handleNoteContextMenu.bind(this)}
|
handleNoteContextMenu={this.handleNoteContextMenu.bind(this)}
|
||||||
handleNoteClick={this.handleNoteClick.bind(this)}
|
handleNoteClick={this.handleNoteClick.bind(this)}
|
||||||
handleDragStart={this.handleDragStart.bind(this)}
|
handleDragStart={this.handleDragStart.bind(this)}
|
||||||
pathname={location.pathname}
|
pathname={location.pathname}
|
||||||
storage={this.getNoteStorage(note)}
|
folderName={this.getNoteFolder(note).name}
|
||||||
|
storageName={this.getNoteStorage(note).name}
|
||||||
|
viewType={this.getViewType()}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user