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

Add selector to sort tags by counter or alphabetically

![screencast](https://i.imgur.com/XUkTyRe.gif)
This commit is contained in:
bimlas
2018-03-24 10:56:01 +01:00
parent 02095ac155
commit 2a23d19321
7 changed files with 77 additions and 3 deletions

View File

@@ -23,6 +23,7 @@
"lineNumber": true "lineNumber": true
}, },
"sortBy": "UPDATED_AT", "sortBy": "UPDATED_AT",
"sortTagsBy": "ALPHABETICAL",
"ui": { "ui": {
"defaultNote": "ALWAYS_ASK", "defaultNote": "ALWAYS_ASK",
"disableDirectWrite": false, "disableDirectWrite": false,

View File

@@ -8,6 +8,29 @@
display: flex display: flex
flex-direction column flex-direction column
.control
user-select none
height $control-height
font-size 12px
line-height 25px
display flex
color $ui-inactive-text-color
.control-sortTagsBy
flex 1
padding-left 15px
.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
.top .top
padding-bottom 15px padding-bottom 15px
@@ -82,6 +105,10 @@ body[data-theme="white"]
background-color #f9f9f9 background-color #f9f9f9
color $ui-text-color color $ui-text-color
.control
background-color $ui-white-backgroundColor
border-color $ui-white-borderColor
body[data-theme="dark"] body[data-theme="dark"]
.root, .root--folded .root, .root--folded
border-right 1px solid $ui-dark-borderColor border-right 1px solid $ui-dark-borderColor
@@ -91,7 +118,15 @@ body[data-theme="dark"]
.top .top
border-color $ui-dark-borderColor border-color $ui-dark-borderColor
.control
background-color $ui-dark-backgroundColor
border-color $ui-dark-borderColor
body[data-theme="solarized-dark"] body[data-theme="solarized-dark"]
.root, .root--folded .root, .root--folded
background-color $ui-solarized-dark-backgroundColor background-color $ui-solarized-dark-backgroundColor
border-right 1px solid $ui-solarized-dark-borderColor border-right 1px solid $ui-solarized-dark-borderColor
.control
background-color $ui-solarized-dark-backgroundColor
border-color $ui-solarized-dark-borderColor

View File

@@ -82,7 +82,7 @@ class SideNav extends React.Component {
} }
SideNavComponent (isFolded, storageList) { SideNavComponent (isFolded, storageList) {
const { location, data } = this.props const { location, data, config } = this.props
const isHomeActive = !!location.pathname.match(/^\/home$/) const isHomeActive = !!location.pathname.match(/^\/home$/)
const isStarredActive = !!location.pathname.match(/^\/starred$/) const isStarredActive = !!location.pathname.match(/^\/starred$/)
@@ -119,6 +119,21 @@ class SideNav extends React.Component {
<p>{i18n.__('Tags')}</p> <p>{i18n.__('Tags')}</p>
</div> </div>
<div styleName='tagList'> <div styleName='tagList'>
<div styleName='control'>
<div styleName='control-sortTagsBy'>
<i className='fa fa-angle-down' />
<select styleName='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>
{this.tagListComponent(data)} {this.tagListComponent(data)}
</div> </div>
</div> </div>
@@ -129,10 +144,15 @@ class SideNav extends React.Component {
} }
tagListComponent () { tagListComponent () {
const { data, location } = this.props const { data, location, config } = this.props
const tagList = _.sortBy(data.tagNoteMap.map((tag, name) => { let tagList = _.sortBy(data.tagNoteMap.map((tag, name) => {
return { name, size: tag.size } return { name, size: tag.size }
}), ['name']) }), ['name'])
if (config.sortTagsBy === 'COUNTER') {
tagList = _.sortBy(tagList, function (item) {
return 0 - item.size
})
}
return ( return (
tagList.map(tag => { tagList.map(tag => {
return ( return (
@@ -159,6 +179,20 @@ class SideNav extends React.Component {
router.push(`/tags/${name}`) 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) { emptyTrash (entries) {
const { dispatch } = this.props const { dispatch } = this.props
const deletionPromises = entries.map((note) => { const deletionPromises = entries.map((note) => {

View File

@@ -16,6 +16,7 @@ export const DEFAULT_CONFIG = {
listWidth: 280, listWidth: 280,
navWidth: 200, navWidth: 200,
sortBy: 'UPDATED_AT', // 'CREATED_AT', 'UPDATED_AT', 'APLHABETICAL' sortBy: 'UPDATED_AT', // 'CREATED_AT', 'UPDATED_AT', 'APLHABETICAL'
sortTagsBy: 'ALPHABETICAL', // 'ALPHABETICAL', 'COUNTER'
listStyle: 'DEFAULT', // 'DEFAULT', 'SMALL' listStyle: 'DEFAULT', // 'DEFAULT', 'SMALL'
amaEnabled: true, amaEnabled: true,
hotkey: { hotkey: {

View File

@@ -111,6 +111,7 @@
"Updated": "Updated", "Updated": "Updated",
"Created": "Created", "Created": "Created",
"Alphabetically": "Alphabetically", "Alphabetically": "Alphabetically",
"Counter": "Counter",
"Default View": "Default View", "Default View": "Default View",
"Compressed View": "Compressed View", "Compressed View": "Compressed View",
"Search": "Search", "Search": "Search",

View File

@@ -111,6 +111,7 @@
"Updated": "Módosítás", "Updated": "Módosítás",
"Created": "Létrehozás", "Created": "Létrehozás",
"Alphabetically": "Ábécé sorrendben", "Alphabetically": "Ábécé sorrendben",
"Counter": "Számláló",
"Default View": "Alapértelmezett Nézet", "Default View": "Alapértelmezett Nézet",
"Compressed View": "Tömörített Nézet", "Compressed View": "Tömörített Nézet",
"Search": "Keresés", "Search": "Keresés",

View File

@@ -23,6 +23,7 @@
"lineNumber": true "lineNumber": true
}, },
"sortBy": "UPDATED_AT", "sortBy": "UPDATED_AT",
"sortTagsBy": "ALPHABETICAL",
"ui": { "ui": {
"defaultNote": "ALWAYS_ASK", "defaultNote": "ALWAYS_ASK",
"disableDirectWrite": false, "disableDirectWrite": false,