Skip to content

Commit b021bb7

Browse files
authored
Merge pull request #2498 from daiyam/create-note-with-tags
create note with selected tags
2 parents c76b653 + c13746f commit b021bb7

File tree

6 files changed

+42
-12
lines changed

6 files changed

+42
-12
lines changed

browser/lib/newNote.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,21 @@ import dataApi from 'browser/main/lib/dataApi'
33
import ee from 'browser/main/lib/eventEmitter'
44
import AwsMobileAnalyticsConfig from 'browser/main/lib/AwsMobileAnalyticsConfig'
55

6-
export function createMarkdownNote (storage, folder, dispatch, location) {
6+
export function createMarkdownNote (storage, folder, dispatch, location, params, config) {
77
AwsMobileAnalyticsConfig.recordDynamicCustomEvent('ADD_MARKDOWN')
88
AwsMobileAnalyticsConfig.recordDynamicCustomEvent('ADD_ALLNOTE')
9+
10+
let tags = []
11+
if (config.ui.tagNewNoteWithFilteringTags && location.pathname.match(/\/tags/)) {
12+
tags = params.tagname.split(' ')
13+
}
14+
915
return dataApi
1016
.createNote(storage, {
1117
type: 'MARKDOWN_NOTE',
1218
folder: folder,
1319
title: '',
20+
tags,
1421
content: ''
1522
})
1623
.then(note => {
@@ -29,14 +36,21 @@ export function createMarkdownNote (storage, folder, dispatch, location) {
2936
})
3037
}
3138

32-
export function createSnippetNote (storage, folder, dispatch, location, config) {
39+
export function createSnippetNote (storage, folder, dispatch, location, params, config) {
3340
AwsMobileAnalyticsConfig.recordDynamicCustomEvent('ADD_SNIPPET')
3441
AwsMobileAnalyticsConfig.recordDynamicCustomEvent('ADD_ALLNOTE')
42+
43+
let tags = []
44+
if (config.ui.tagNewNoteWithFilteringTags && location.pathname.match(/\/tags/)) {
45+
tags = params.tagname.split(' ')
46+
}
47+
3548
return dataApi
3649
.createNote(storage, {
3750
type: 'SNIPPET_NOTE',
3851
folder: folder,
3952
title: '',
53+
tags,
4054
description: '',
4155
snippets: [
4256
{

browser/main/NewNoteButton/index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,20 @@ class NewNoteButton extends React.Component {
3535
}
3636

3737
handleNewNoteButtonClick (e) {
38-
const { location, dispatch, config } = this.props
38+
const { location, params, dispatch, config } = this.props
3939
const { storage, folder } = this.resolveTargetFolder()
4040

4141
if (config.ui.defaultNote === 'MARKDOWN_NOTE') {
42-
createMarkdownNote(storage.key, folder.key, dispatch, location)
42+
createMarkdownNote(storage.key, folder.key, dispatch, location, params, config)
4343
} else if (config.ui.defaultNote === 'SNIPPET_NOTE') {
44-
createSnippetNote(storage.key, folder.key, dispatch, location, config)
44+
createSnippetNote(storage.key, folder.key, dispatch, location, params, config)
4545
} else {
4646
modal.open(NewNoteModal, {
4747
storage: storage.key,
4848
folder: folder.key,
4949
dispatch,
5050
location,
51+
params,
5152
config
5253
})
5354
}

browser/main/modals/NewNoteModal.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ class NewNoteModal extends React.Component {
2121
}
2222

2323
handleMarkdownNoteButtonClick (e) {
24-
const { storage, folder, dispatch, location } = this.props
25-
createMarkdownNote(storage, folder, dispatch, location).then(() => {
24+
const { storage, folder, dispatch, location, params, config } = this.props
25+
createMarkdownNote(storage, folder, dispatch, location, params, config).then(() => {
2626
setTimeout(this.props.close, 200)
2727
})
2828
}
@@ -35,8 +35,8 @@ class NewNoteModal extends React.Component {
3535
}
3636

3737
handleSnippetNoteButtonClick (e) {
38-
const { storage, folder, dispatch, location, config } = this.props
39-
createSnippetNote(storage, folder, dispatch, location, config).then(() => {
38+
const { storage, folder, dispatch, location, params, config } = this.props
39+
createSnippetNote(storage, folder, dispatch, location, params, config).then(() => {
4040
setTimeout(this.props.close, 200)
4141
})
4242
}

browser/main/modals/PreferencesModal/UiTab.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ class UiTab extends React.Component {
6868
theme: this.refs.uiTheme.value,
6969
language: this.refs.uiLanguage.value,
7070
defaultNote: this.refs.defaultNote.value,
71+
tagNewNoteWithFilteringTags: this.refs.tagNewNoteWithFilteringTags.checked,
7172
showCopyNotification: this.refs.showCopyNotification.checked,
7273
confirmDeletion: this.refs.confirmDeletion.checked,
7374
showOnlyRelatedTags: this.refs.showOnlyRelatedTags.checked,
@@ -268,6 +269,7 @@ class UiTab extends React.Component {
268269
</div>
269270
: null
270271
}
272+
271273
<div styleName='group-header2'>Tags</div>
272274

273275
<div styleName='group-checkBoxSection'>
@@ -314,6 +316,17 @@ class UiTab extends React.Component {
314316
</label>
315317
</div>
316318

319+
<div styleName='group-checkBoxSection'>
320+
<label>
321+
<input onChange={(e) => this.handleUIChange(e)}
322+
checked={this.state.config.ui.tagNewNoteWithFilteringTags}
323+
ref='tagNewNoteWithFilteringTags'
324+
type='checkbox'
325+
/>&nbsp;
326+
{i18n.__('New notes are tagged with the filtering tags')}
327+
</label>
328+
</div>
329+
317330
<div styleName='group-header2'>Editor</div>
318331

319332
<div styleName='group-section'>

locales/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,5 +183,6 @@
183183
"Save tags of a note in alphabetical order": "Save tags of a note in alphabetical order",
184184
"Enable live count of notes": "Enable live count of notes",
185185
"Enable smart table editor": "Enable smart table editor",
186-
"Snippet Default Language": "Snippet Default Language"
186+
"Snippet Default Language": "Snippet Default Language",
187+
"New notes are tagged with the filtering tags": "New notes are tagged with the filtering tags"
187188
}

locales/fr.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@
167167
"New Snippet": "Nouveau snippet",
168168
"Custom CSS": "CSS personnalisé",
169169
"Snippet name": "Nom du snippet",
170-
"Snippet prefix": "Préfixe du snippet"
171-
"Delete Note": "Supprimer la note"
170+
"Snippet prefix": "Préfixe du snippet",
171+
"Delete Note": "Supprimer la note",
172+
"New notes are tagged with the filtering tags": "Les nouvelles notes sont taggées avec les tags de filtrage"
172173
}

0 commit comments

Comments
 (0)