Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .boostnoterc.sample
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"lineNumber": true
},
"sortBy": "UPDATED_AT",
"sortTagsBy": "ALPHABETICAL",
"ui": {
"defaultNote": "ALWAYS_ASK",
"disableDirectWrite": false,
Expand Down
32 changes: 27 additions & 5 deletions browser/main/SideNav/SideNav.styl
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,33 @@
display flex
flex-direction column

.tag-title
padding-left 15px
padding-bottom 13px
p
color $ui-button-default-color
.tag-control
display flex
height 30px
line-height 25px
overflow hidden
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is this the correct way to hide the selector when the sidebar is too narrow?

Copy link
Member

Choose a reason for hiding this comment

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

I think so. :)

.tag-control-title
padding-left 15px
padding-bottom 13px
flex 1
p
color $ui-button-default-color
.tag-control-sortTagsBy
user-select none
font-size 12px
color $ui-inactive-text-color
margin-left 12px
margin-right 12px
.tag-control-sortTagsBy-select
appearance: none;
margin-left 5px
color $ui-inactive-text-color
padding 0
border none
background-color transparent
outline none
cursor pointer
font-size 12px

.tagList
overflow-y auto
Expand Down
47 changes: 40 additions & 7 deletions browser/main/SideNav/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class SideNav extends React.Component {
}

SideNavComponent (isFolded, storageList) {
const { location, data } = this.props
const { location, data, config } = this.props

const isHomeActive = !!location.pathname.match(/^\/home$/)
const isStarredActive = !!location.pathname.match(/^\/starred$/)
Expand Down Expand Up @@ -115,8 +115,23 @@ class SideNav extends React.Component {
} else {
component = (
<div styleName='tabBody'>
<div styleName='tag-title'>
<p>{i18n.__('Tags')}</p>
<div styleName='tag-control'>
<div styleName='tag-control-title'>
<p>{i18n.__('Tags')}</p>
</div>
<div styleName='tag-control-sortTagsBy'>
<i className='fa fa-angle-down' />
<select styleName='tag-control-sortTagsBy-select'
title={i18n.__('Select filter mode')}
value={config.sortTagsBy}
onChange={(e) => this.handleSortTagsByChange(e)}
>
<option title='Sort alphabetically'
value='ALPHABETICAL'>{i18n.__('Alphabetically')}</option>
<option title='Sort by update time'
value='COUNTER'>{i18n.__('Counter')}</option>
</select>
</div>
</div>
<div styleName='tagList'>
{this.tagListComponent(data)}
Expand All @@ -129,10 +144,14 @@ class SideNav extends React.Component {
}

tagListComponent () {
const { data, location } = this.props
const tagList = _.sortBy(data.tagNoteMap.map((tag, name) => {
return { name, size: tag.size }
}), ['name'])
const { data, location, config } = this.props
let tagList = _.sortBy(data.tagNoteMap.map(
(tag, name) => ({name, size: tag.size})),
['name']
)
if (config.sortTagsBy === 'COUNTER') {
tagList = _.sortBy(tagList, item => (0 - item.size))
}
return (
tagList.map(tag => {
return (
Expand All @@ -159,6 +178,20 @@ class SideNav extends React.Component {
router.push(`/tags/${name}`)
}

handleSortTagsByChange (e) {
const { dispatch } = this.props

const config = {
sortTagsBy: e.target.value
}

ConfigManager.set(config)
dispatch({
type: 'SET_CONFIG',
config
})
}

emptyTrash (entries) {
const { dispatch } = this.props
const deletionPromises = entries.map((note) => {
Expand Down
1 change: 1 addition & 0 deletions browser/main/lib/ConfigManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const DEFAULT_CONFIG = {
listWidth: 280,
navWidth: 200,
sortBy: 'UPDATED_AT', // 'CREATED_AT', 'UPDATED_AT', 'APLHABETICAL'
sortTagsBy: 'ALPHABETICAL', // 'ALPHABETICAL', 'COUNTER'
listStyle: 'DEFAULT', // 'DEFAULT', 'SMALL'
amaEnabled: true,
hotkey: {
Expand Down
1 change: 1 addition & 0 deletions locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
"Updated": "Updated",
"Created": "Created",
"Alphabetically": "Alphabetically",
"Counter": "Counter",
"Default View": "Default View",
"Compressed View": "Compressed View",
"Search": "Search",
Expand Down
1 change: 1 addition & 0 deletions locales/hu.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
"Updated": "Módosítás",
"Created": "Létrehozás",
"Alphabetically": "Ábécé sorrendben",
"Counter": "Számláló",
"Default View": "Alapértelmezett Nézet",
"Compressed View": "Tömörített Nézet",
"Search": "Keresés",
Expand Down
1 change: 1 addition & 0 deletions tests/lib/boostnoterc/.boostnoterc.all
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"lineNumber": true
},
"sortBy": "UPDATED_AT",
"sortTagsBy": "ALPHABETICAL",
"ui": {
"defaultNote": "ALWAYS_ASK",
"disableDirectWrite": false,
Expand Down