Merges master

This commit is contained in:
Mo Bitar
2020-03-14 12:05:38 -05:00
18 changed files with 1453 additions and 89822 deletions

View File

@@ -39,7 +39,7 @@ class LockScreenCtrl extends PureCtrl {
}
}
async submitPasscodeForm($event) {
async submitPasscodeForm() {
if (
!this.formData.passcode ||
this.formData.passcode.length === 0
@@ -78,4 +78,4 @@ export class LockScreen {
puppet: '='
};
}
}
}

View File

@@ -133,8 +133,7 @@ class NotesCtrl extends PureCtrl {
const selectedNote = this.state.selectedNote;
if (selectedNote) {
const discarded = selectedNote.deleted || selectedNote.content.trashed;
const notIncluded = !this.state.notes.includes(selectedNote);
if (notIncluded || discarded) {
if (discarded) {
this.selectNextOrCreateNew();
}
} else {
@@ -165,7 +164,7 @@ class NotesCtrl extends PureCtrl {
});
this.resetScrollPosition();
this.setShowMenuFalse();
this.setNoteFilterText('');
await this.setNoteFilterText('');
this.desktopManager.searchText();
this.resetPagination();
@@ -193,9 +192,9 @@ class NotesCtrl extends PureCtrl {
}
}
/**
/**
* @template
* @internal
* @internal
*/
async selectNote(note) {
this.appState.setSelectedNote(note);
@@ -219,7 +218,7 @@ class NotesCtrl extends PureCtrl {
selectedTag: this.state.tag,
showArchived: this.state.showArchived,
hidePinned: this.state.hidePinned,
filterText: this.state.noteFilter.text,
filterText: this.state.noteFilter.text.toLowerCase(),
sortBy: this.state.sortBy,
reverse: this.state.sortReverse
});
@@ -514,10 +513,16 @@ class NotesCtrl extends PureCtrl {
if (!selectedTag) {
throw 'Attempting to create note with no selected tag';
}
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;
} else {
title = `Note ${this.state.notes.length + 1}`;
}
const title = "Note" + (this.state.notes ? (" " + (this.state.notes.length + 1)) : "");
const newNote = await this.application.createItem({
contentType: ContentTypes.Note,
content: {
@@ -527,7 +532,7 @@ class NotesCtrl extends PureCtrl {
add: true
});
newNote.client_updated_at = new Date();
newNote.dummy = true;
newNote.dummy = isDummyNote;
this.application.setItemNeedsSync({ item: newNote });
if (!selectedTag.isSmartTag()) {
selectedTag.addItemAsRelationship(newNote);
@@ -562,9 +567,6 @@ class NotesCtrl extends PureCtrl {
this.searchSubmitted = false;
}
await this.reloadNotes();
if (!this.state.notes.includes(this.state.selectedNote)) {
this.selectFirstNote();
}
}
onFilterEnter() {

View File

@@ -254,40 +254,29 @@ class RootCtrl extends PureCtrl {
}, false);
}
handleAutoSignInFromParams() {
const urlParam = (key) => {
return this.$location.search()[key];
};
async handleAutoSignInFromParams() {
const params = this.$location.search();
const server = params.server;
const email = params.email;
const password = params.pw;
if (!server || !email || !password) return;
const autoSignInFromParams = async () => {
const server = urlParam('server');
const email = urlParam('email');
const pw = urlParam('pw');
if (!this.application.getUser()) {
if (
await this.application.getHost() === server
&& this.application.getUser().email === email
) {
/** Already signed in, return */
// eslint-disable-next-line no-useless-return
return;
} else {
/** Sign out */
await this.application.signOut();
await this.application.restart();
}
const user = this.application.getUser();
if (user) {
if (user.email === email && await this.application.getHost() === server) {
/** Already signed in, return */
return;
} else {
await this.application.setHost(server);
this.application.signIn({
email: email,
password: pw,
});
/** Sign out */
await this.application.signOut();
await this.application.restart();
}
};
if (urlParam('server')) {
autoSignInFromParams();
}
await this.application.setHost(server);
this.application.signIn({
email: email,
password: password,
});
}
}

View File

@@ -199,6 +199,7 @@ class AccountMenuCtrl extends PureCtrl {
}
await this.setFormDataState({
status: null,
user_password: null
});
const error = response
? response.error
@@ -462,6 +463,19 @@ class AccountMenuCtrl extends PureCtrl {
}
}
hidePasswordForm() {
this.setFormDataState({
showLogin: false,
showRegister: false,
user_password: null,
password_conf: null
});
}
hasPasscode() {
return this.passcodeManager.hasPasscode();
}
addPasscodeClicked() {
this.setFormDataState({
showPasscodeForm: true

View File

@@ -42,7 +42,7 @@ class EditorMenuCtrl extends PureCtrl {
}
toggleDefaultForEditor(editor) {
if(this.defaultEditor === editor) {
if(this.state.defaultEditor === editor) {
this.removeEditorDefault(editor);
} else {
this.makeEditorDefault(editor);

View File

@@ -338,10 +338,7 @@
.sk-panel-row
.sk-p.left.neutral.faded {{self.state.appVersion}}
a.sk-a.right(
ng-click=`
self.state.formData.showLogin = false;
self.state.formData.showRegister = false;
`,
ng-click='self.hidePasswordForm()',
ng-if='self.state.formData.showLogin || self.state.formData.showRegister'
)
| Cancel

View File

@@ -5,31 +5,30 @@
.section-title-bar-header
.title {{self.state.panelTitle}}
.sk-button.contrast.wide(
ng-click='self.createNewNote()',
ng-click='self.createNewNote()',
title='Create a new note in the selected tag'
)
.sk-label
i.icon.ion-plus.add-button
.filter-section(role='search')
input#search-bar.filter-bar(
lowercase='true',
ng-blur='self.onFilterEnter()',
ng-change='self.filterTextChanged()',
ng-keyup='$event.keyCode == 13 && self.onFilterEnter();',
ng-blur='self.onFilterEnter()',
ng-change='self.filterTextChanged()',
ng-keyup='$event.keyCode == 13 && self.onFilterEnter();',
ng-model='self.state.noteFilter.text',
placeholder='Search',
select-on-click='true',
placeholder='Search',
select-on-click='true',
title='Searches notes in the currently selected tag'
)
#search-clear-button(
ng-click='self.clearFilterText();',
ng-click='self.clearFilterText();',
ng-show='self.state.noteFilter.text'
) ✕
#notes-menu-bar.sn-component
.sk-app-bar.no-edges
.left
.sk-app-bar-item(
ng-class="{'selected' : self.state.mutable.showMenu}",
ng-class="{'selected' : self.state.mutable.showMenu}",
ng-click='self.state.mutable.showMenu = !self.state.mutable.showMenu'
)
.sk-app-bar-item-column
@@ -45,67 +44,67 @@
a.info.sk-h5(ng-click='self.toggleReverseSort()')
| {{self.state.sortReverse === true ? 'Disable Reverse Sort' : 'Enable Reverse Sort'}}
menu-row(
action="self.selectedMenuItem(); self.selectedSortByCreated()"
circle="self.state.sortBy == 'created_at' && 'success'"
desc="'Sort notes by newest first'"
action="self.selectedMenuItem(); self.selectedSortByCreated()"
circle="self.state.sortBy == 'created_at' && 'success'"
desc="'Sort notes by newest first'"
label="'Date Added'"
)
menu-row(
action="self.selectedMenuItem(); self.selectedSortByUpdated()"
circle="self.state.sortBy == 'client_updated_at' && 'success'"
desc="'Sort notes with the most recently updated first'"
action="self.selectedMenuItem(); self.selectedSortByUpdated()"
circle="self.state.sortBy == 'client_updated_at' && 'success'"
desc="'Sort notes with the most recently updated first'"
label="'Date Modified'"
)
menu-row(
action="self.selectedMenuItem(); self.selectedSortByTitle()"
circle="self.state.sortBy == 'title' && 'success'"
desc="'Sort notes alphabetically by their title'"
action="self.selectedMenuItem(); self.selectedSortByTitle()"
circle="self.state.sortBy == 'title' && 'success'"
desc="'Sort notes alphabetically by their title'"
label="'Title'"
)
.sk-menu-panel-section
.sk-menu-panel-header
.sk-menu-panel-header-title Display
menu-row(
action="self.selectedMenuItem(); self.togglePrefKey('showArchived')"
circle="self.state.showArchived ? 'success' : 'danger'"
desc=`'Archived notes are usually hidden.
action="self.selectedMenuItem(); self.togglePrefKey('showArchived')"
circle="self.state.showArchived ? 'success' : 'danger'"
desc=`'Archived notes are usually hidden.
You can explicitly show them with this option.'`
faded="!self.state.showArchived"
faded="!self.state.showArchived"
label="'Archived Notes'"
)
menu-row(
action="self.selectedMenuItem(); self.togglePrefKey('hidePinned')"
circle="self.state.hidePinned ? 'danger' : 'success'"
action="self.selectedMenuItem(); self.togglePrefKey('hidePinned')"
circle="self.state.hidePinned ? 'danger' : 'success'"
desc=`'Pinned notes always appear on top. You can hide them temporarily
with this option so you can focus on other notes in the list.'`
faded="self.state.hidePinned"
faded="self.state.hidePinned"
label="'Pinned Notes'"
)
menu-row(
action="self.selectedMenuItem(); self.togglePrefKey('hideNotePreview')"
circle="self.state.hideNotePreview ? 'danger' : 'success'"
desc="'Hide the note preview for a more condensed list of notes'"
faded="self.state.hideNotePreview"
action="self.selectedMenuItem(); self.togglePrefKey('hideNotePreview')"
circle="self.state.hideNotePreview ? 'danger' : 'success'"
desc="'Hide the note preview for a more condensed list of notes'"
faded="self.state.hideNotePreview"
label="'Note Preview'"
)
menu-row(
action="self.selectedMenuItem(); self.togglePrefKey('hideDate')"
circle="self.state.hideDate ? 'danger' : 'success'"
desc="'Hide the date displayed in each row'"
faded="self.state.hideDate"
action="self.selectedMenuItem(); self.togglePrefKey('hideDate')"
circle="self.state.hideDate ? 'danger' : 'success'"
desc="'Hide the date displayed in each row'"
faded="self.state.hideDate"
label="'Date'"
)
menu-row(
action="self.selectedMenuItem(); self.togglePrefKey('hideTags')"
circle="self.state.hideTags ? 'danger' : 'success'"
desc="'Hide the list of tags associated with each note'"
faded="self.state.hideTags"
action="self.selectedMenuItem(); self.togglePrefKey('hideTags')"
circle="self.state.hideTags ? 'danger' : 'success'"
desc="'Hide the list of tags associated with each note'"
faded="self.state.hideTags"
label="'Tags'"
)
.scrollable
#notes-scrollable.infinite-scroll(
can-load='true',
infinite-scroll='self.paginate()',
can-load='true',
infinite-scroll='self.paginate()',
threshold='200'
)
.note(
@@ -120,12 +119,12 @@
| {{note.title}}
.note-preview(
ng-if=`
!self.state.hideNotePreview &&
!note.content.hidePreview &&
!self.state.hideNotePreview &&
!note.content.hidePreview &&
!note.content.protected`
)
.html-preview(
ng-bind-html='note.content.preview_html',
ng-bind-html='note.content.preview_html',
ng-show='note.content.preview_html'
)
.plain-preview(
@@ -135,9 +134,9 @@
ng-show='!note.content.preview_html && !note.content.preview_plain'
) {{note.text}}
.date.faded(ng-show='!self.state.hideDate')
span(ng-show="self.state.sortBy == 'client_updated_at'")
span(ng-show="self.state.sortBy == 'client_updated_at'")
| Modified {{note.cachedUpdatedAtString || 'Now'}}
span(ng-show="self.state.sortBy != 'client_updated_at'")
span(ng-show="self.state.sortBy != 'client_updated_at'")
| {{note.cachedCreatedAtString || 'Now'}}
.tags-string(ng-show='note.shouldShowTags')
.faded {{note.savedTagsString || note.tagsString()}}