Merge pull request #367 from standardnotes/issue-364

Create a new note from search
This commit is contained in:
Mo Bitar
2020-02-13 13:47:40 -06:00
committed by GitHub
2 changed files with 62 additions and 57 deletions

View File

@@ -247,7 +247,7 @@ class NotesCtrl extends PureCtrl {
selectedTag: this.state.tag, selectedTag: this.state.tag,
showArchived: this.state.showArchived, showArchived: this.state.showArchived,
hidePinned: this.state.hidePinned, hidePinned: this.state.hidePinned,
filterText: this.state.noteFilter.text, filterText: this.state.noteFilter.text.toLowerCase(),
sortBy: this.state.sortBy, sortBy: this.state.sortBy,
reverse: this.state.sortReverse reverse: this.state.sortReverse
}); });
@@ -532,10 +532,16 @@ class NotesCtrl extends PureCtrl {
} }
createNewNote() { createNewNote() {
if (this.state.selectedNote && this.state.selectedNote.dummy) { let title;
let isDummyNote = true;
if (this.isFiltering()) {
title = this.state.noteFilter.text;
isDummyNote = false;
} else if (this.state.selectedNote && this.state.selectedNote.dummy) {
return; return;
} else {
title = `Note ${this.state.notes.length + 1}`;
} }
const title = "Note" + (this.state.notes ? (" " + (this.state.notes.length + 1)) : "");
const newNote = this.modelManager.createItem({ const newNote = this.modelManager.createItem({
content_type: 'Note', content_type: 'Note',
content: { content: {
@@ -544,7 +550,7 @@ class NotesCtrl extends PureCtrl {
} }
}); });
newNote.client_updated_at = new Date(); newNote.client_updated_at = new Date();
newNote.dummy = true; newNote.dummy = isDummyNote;
this.modelManager.addItem(newNote); this.modelManager.addItem(newNote);
this.modelManager.setItemDirty(newNote); this.modelManager.setItemDirty(newNote);
const selectedTag = this.appState.getSelectedTag(); const selectedTag = this.appState.getSelectedTag();

View File

@@ -12,7 +12,6 @@
i.icon.ion-plus.add-button i.icon.ion-plus.add-button
.filter-section(role='search') .filter-section(role='search')
input#search-bar.filter-bar( input#search-bar.filter-bar(
lowercase='true',
ng-blur='self.onFilterEnter()', ng-blur='self.onFilterEnter()',
ng-change='self.filterTextChanged()', ng-change='self.filterTextChanged()',
ng-keyup='$event.keyCode == 13 && self.onFilterEnter();', ng-keyup='$event.keyCode == 13 && self.onFilterEnter();',