Skip to content

Commit

Permalink
add saveTagsAlphabetically option
Browse files Browse the repository at this point in the history
  • Loading branch information
daiyam committed Aug 29, 2018
1 parent 5006aaa commit 8b4a9dd
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 2 deletions.
1 change: 1 addition & 0 deletions browser/main/Detail/MarkdownNoteDetail.js
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ class MarkdownNoteDetail extends React.Component {
<TagSelect
ref='tags'
value={this.state.note.tags}
saveTagsAlphabetically={config.ui.saveTagsAlphabetically}
showTagsAlphabetically={config.ui.showTagsAlphabetically}
onChange={this.handleUpdateTag.bind(this)}
/>
Expand Down
1 change: 1 addition & 0 deletions browser/main/Detail/SnippetNoteDetail.js
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,7 @@ class SnippetNoteDetail extends React.Component {
<TagSelect
ref='tags'
value={this.state.note.tags}
saveTagsAlphabetically={config.ui.saveTagsAlphabetically}
showTagsAlphabetically={config.ui.showTagsAlphabetically}
onChange={(e) => this.handleChange(e)}
/>
Expand Down
10 changes: 8 additions & 2 deletions browser/main/Detail/TagSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,14 @@ class TagSelect extends React.Component {
value = _.isArray(value)
? value.slice()
: []
value.push(newTag)
value = _.uniq(value)

if (!_.includes(value, newTag)) {
value.push(newTag)
}

if (this.props.saveTagsAlphabetically) {
value = _.sortBy(value)
}

this.setState({
newTag: ''
Expand Down
12 changes: 12 additions & 0 deletions browser/main/modals/PreferencesModal/UiTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class UiTab extends React.Component {
confirmDeletion: this.refs.confirmDeletion.checked,
showOnlyRelatedTags: this.refs.showOnlyRelatedTags.checked,
showTagsAlphabetically: this.refs.showTagsAlphabetically.checked,
saveTagsAlphabetically: this.refs.saveTagsAlphabetically.checked,
enableLiveNoteCounts: this.refs.enableLiveNoteCounts.checked,
disableDirectWrite: this.refs.uiD2w != null
? this.refs.uiD2w.checked
Expand Down Expand Up @@ -244,6 +245,17 @@ class UiTab extends React.Component {
}
<div styleName='group-header2'>Tags</div>

<div styleName='group-checkBoxSection'>
<label>
<input onChange={(e) => this.handleUIChange(e)}
checked={this.state.config.ui.saveTagsAlphabetically}
ref='saveTagsAlphabetically'
type='checkbox'
/>&nbsp;
{i18n.__('Save tags of a note in alphabetical order')}
</label>
</div>

<div styleName='group-checkBoxSection'>
<label>
<input onChange={(e) => this.handleUIChange(e)}
Expand Down
1 change: 1 addition & 0 deletions locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@
"Allow dangerous html tags": "Allow dangerous html tags",
"Convert textual arrows to beautiful signs. ⚠ This will interfere with using HTML comments in your Markdown.": "Convert textual arrows to beautiful signs. ⚠ This will interfere with using HTML comments in your Markdown.",
"⚠ You have pasted a link referring an attachment that could not be found in the storage location of this note. Pasting links referring attachments is only supported if the source and destination location is the same storage. Please Drag&Drop the attachment instead! ⚠": "⚠ You have pasted a link referring an attachment that could not be found in the storage location of this note. Pasting links referring attachments is only supported if the source and destination location is the same storage. Please Drag&Drop the attachment instead! ⚠",
"Save tags of a note in alphabetical order": "Save tags of a note in alphabetical order",
"Show tags of a note in alphabetical order": "Show tags of a note in alphabetical order",
"Enable live count of notes": "Enable live count of notes"
}
1 change: 1 addition & 0 deletions locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@
"Allow dangerous html tags": "Accepter les tags html dangereux",
"Convert textual arrows to beautiful signs. ⚠ This will interfere with using HTML comments in your Markdown.": "Convertir des flèches textuelles en jolis signes. ⚠ Cela va interferérer avec les éventuels commentaires HTML dans votre Markdown.",
"⚠ You have pasted a link referring an attachment that could not be found in the storage location of this note. Pasting links referring attachments is only supported if the source and destination location is the same storage. Please Drag&Drop the attachment instead! ⚠": "⚠ Vous avez collé un lien qui référence une pièce-jointe qui n'a pas pu être récupéré dans le dossier de stockage de la note. Coller des liens qui font référence à des pièces-jointes ne fonctionne que si la source et la destination et la même. Veuillez plutôt utiliser du Drag & Drop ! ⚠",
"Save tags of a note in alphabetical order": "Sauvegarder les tags d'une note en ordre alphabétique",
"Show tags of a note in alphabetical order": "Afficher les tags d'une note par ordre alphabétique",
"Enable live count of notes": "Activer le comptage live des notes"
}

0 comments on commit 8b4a9dd

Please sign in to comment.