Tags fixes

This commit is contained in:
Mo Bitar
2020-04-14 18:16:46 -05:00
parent 9cf99896a5
commit d91b7bc449
8 changed files with 483 additions and 277 deletions

View File

@@ -166,7 +166,6 @@ export class AppState {
}
}
}
if (this.selectedTag) {
const matchingTag = items.find((candidate) => candidate.uuid === this.selectedTag!.uuid);
if (matchingTag) {

View File

@@ -8,7 +8,7 @@ export class Editor {
private _onNoteChange?: () => void
private _onNoteValueChange?: (note: SNNote, source?: PayloadSource) => void
private removeStreamObserver: () => void
public isTemplateNote = true
public isTemplateNote = false
constructor(
application: WebApplication,

View File

@@ -440,7 +440,6 @@ class EditorViewCtrl extends PureViewCtrl implements EditorViewScope {
) {
this.performFirefoxPinnedTabFix();
const note = this.note;
if (note.deleted) {
this.application.alertService!.alert(
STRING_DELETED_NOTE
@@ -448,7 +447,16 @@ class EditorViewCtrl extends PureViewCtrl implements EditorViewScope {
return;
}
if (this.editor.isTemplateNote) {
console.log("is template");
await this.editor.insertTemplatedNote();
if (this.appState.selectedTag) {
await this.application.changeItem(
this.appState.selectedTag!.uuid,
(mutator) => {
mutator.addItemAsRelationship(note);
}
)
}
}
if (!this.application.findItem(note.uuid)) {
this.application.alertService!.alert(
@@ -473,11 +481,9 @@ class EditorViewCtrl extends PureViewCtrl implements EditorViewScope {
noteMutator.preview_html = undefined;
}
}, isUserModified)
if (this.saveTimeout) {
this.$timeout.cancel(this.saveTimeout);
}
const noDebounce = bypassDebouncer || this.application.noAccount();
const syncDebouceMs = noDebounce
? SAVE_TIMEOUT_NO_DEBOUNCE
@@ -813,7 +819,7 @@ class EditorViewCtrl extends PureViewCtrl implements EditorViewScope {
}
}
for (const tag of removeTags) {
this.application.changeItem(tag.uuid, (mutator) => {
await this.application.changeItem(tag.uuid, (mutator) => {
mutator.removeItemAsRelationship(note);
})
}
@@ -829,9 +835,14 @@ class EditorViewCtrl extends PureViewCtrl implements EditorViewScope {
);
}
}
this.application.changeAndSaveItems(Uuids(newRelationships), (mutator) => {
mutator.addItemAsRelationship(note);
})
if (newRelationships.length > 0) {
await this.application.changeAndSaveItems(
Uuids(newRelationships),
(mutator) => {
mutator.addItemAsRelationship(note);
}
)
}
this.reloadTagsString();
}

View File

@@ -7,7 +7,8 @@ import {
removeFromArray,
SNNote,
SNTag,
WebPrefKey
WebPrefKey,
findInArray
} from 'snjs';
import { PureViewCtrl } from '@Views/abstract/pure_view_ctrl';
import { AppStateEvent } from '@/services/state';
@@ -23,7 +24,6 @@ import { UuidString } from '@/../../../../snjs/dist/@types/types';
type NotesState = {
panelTitle: string
tag?: SNTag
notes?: SNNote[]
renderedNotes?: SNNote[]
sortBy?: string
@@ -214,15 +214,19 @@ class NotesViewCtrl extends PureViewCtrl {
} else {
this.selectFirstNote();
}
/** Note has changed values, reset its flags */
const notes = items.filter((item) => item.content_type === ContentType.Note) as SNNote[];
const notes = items.filter((item) => {
return item.content_type === ContentType.Note
}) as SNNote[];
for (const note of notes) {
if (note.deleted) {
continue;
}
this.loadFlagsForNote(note);
}
if (findInArray(items, 'uuid', this.appState.selectedTag?.uuid)) {
this.reloadPanelTitle();
}
}
);
}
@@ -240,8 +244,6 @@ class NotesViewCtrl extends PureViewCtrl {
}
async handleTagChange(tag: SNTag) {
await this.setNotesState({ tag });
this.resetScrollPosition();
this.setShowMenuFalse();
await this.setNoteFilterText('');
@@ -290,7 +292,7 @@ class NotesViewCtrl extends PureViewCtrl {
}
async performPeloadNotes() {
const tag = this.getState().tag!;
const tag = this.appState.selectedTag!;
if (!tag) {
return;
}
@@ -435,8 +437,8 @@ class NotesViewCtrl extends PureViewCtrl {
if (this.isFiltering()) {
const resultCount = this.getState().notes!.length;
title = `${resultCount} search results`;
} else if (this.getState().tag) {
title = `${this.getState().tag!.title}`;
} else if (this.appState.selectedTag) {
title = `${this.appState.selectedTag.title}`;
}
this.setNotesState({
panelTitle: title
@@ -564,7 +566,7 @@ class NotesViewCtrl extends PureViewCtrl {
const note = this.getFirstNonProtectedNote();
if (note) {
this.selectNote(note);
} else if (!this.getState().tag || !this.getState().tag!.isSmartTag()) {
} else if (!this.appState.selectedTag|| !this.appState.selectedTag.isSmartTag()) {
this.createPlaceholderNote();
} else {
this.appState.closeActiveEditor();

View File

@@ -48,7 +48,7 @@
ng-class="{'editing' : self.state.editingTag == tag}",
ng-click='self.selectTag(tag)',
ng-keyup='$event.keyCode == 13 && $event.target.blur()',
should-focus='self.state.newTag || self.state.editingTag == tag',
should-focus='self.state.templateTag || self.state.editingTag == tag',
sn-autofocus='true',
spellcheck='false'
)

View File

@@ -20,6 +20,20 @@ import { TagMutator } from '@/../../../../snjs/dist/@types/models/app/tag';
type NoteCounts = Partial<Record<string, number>>
type TagState = {
tags: SNTag[]
smartTags: SNSmartTag[]
noteCounts: NoteCounts
selectedTag: SNTag
/** If creating a new tag, the previously selected tag will be set here, so that if new
* tag creation is canceled, the previous tag is re-selected */
previousTag?: SNTag
/** If a tag is in edit state, it will be set as the editingTag */
editingTag?: SNTag
/** If a tag is new and not yet saved, it will be set as the template tag */
templateTag?: SNTag
}
class TagsViewCtrl extends PureViewCtrl {
/** Passed through template */
@@ -27,6 +41,7 @@ class TagsViewCtrl extends PureViewCtrl {
private readonly panelPuppet: PanelPuppet
private unregisterComponent?: any
component?: SNComponent
/** The original name of the edtingTag before it began editing */
private editingOriginalName?: string
formData: { tagTitle?: string } = {}
titles: Partial<Record<UuidString, string>> = {}
@@ -55,6 +70,14 @@ class TagsViewCtrl extends PureViewCtrl {
};
}
getState() {
return this.state as TagState;
}
async setTagState(state: Partial<TagState>) {
return this.setState(state);
}
async onAppStart() {
super.onAppStart();
this.registerComponentHandler();
@@ -65,7 +88,7 @@ class TagsViewCtrl extends PureViewCtrl {
this.loadPreferences();
this.beginStreamingItems();
const smartTags = this.application.getSmartTags();
this.setState({
this.setTagState({
smartTags: smartTags,
});
this.selectTag(smartTags[0]);
@@ -92,23 +115,25 @@ class TagsViewCtrl extends PureViewCtrl {
this.application.streamItems(
ContentType.Tag,
async (items) => {
await this.setState({
await this.setTagState({
tags: this.getMappedTags(),
smartTags: this.application.getSmartTags(),
});
this.reloadTitles(items as SNTag[]);
this.reloadNoteCounts();
if (this.state.selectedTag) {
if (this.getState().selectedTag) {
/** If the selected tag has been deleted, revert to All view. */
const matchingTag = items.find((tag) => {
return tag.uuid === this.state.selectedTag.uuid;
});
if (!matchingTag || matchingTag.deleted) {
this.selectTag(this.state.smartTags[0]);
} else {
this.setState({
selectedTag: matchingTag
})
return tag.uuid === this.getState().selectedTag.uuid;
}) as SNTag;
if (matchingTag) {
if (matchingTag.deleted) {
this.selectTag(this.getState().smartTags[0]);
} else {
this.setTagState({
selectedTag: matchingTag
})
}
}
}
}
@@ -116,7 +141,7 @@ class TagsViewCtrl extends PureViewCtrl {
}
reloadTitles(tags: Array<SNTag | SNSmartTag>) {
for(const tag of tags) {
for (const tag of tags) {
this.titles[tag.uuid] = tag.title;
}
}
@@ -126,7 +151,7 @@ class TagsViewCtrl extends PureViewCtrl {
if (eventName === AppStateEvent.PreferencesChanged) {
this.loadPreferences();
} else if (eventName === AppStateEvent.TagChanged) {
this.setState({
this.setTagState({
selectedTag: this.application.getAppState().getSelectedTag()
});
}
@@ -149,11 +174,11 @@ class TagsViewCtrl extends PureViewCtrl {
reloadNoteCounts() {
let allTags: Array<SNTag | SNSmartTag> = [];
if (this.state.tags) {
allTags = allTags.concat(this.state.tags);
if (this.getState().tags) {
allTags = allTags.concat(this.getState().tags);
}
if (this.state.smartTags) {
allTags = allTags.concat(this.state.smartTags);
if (this.getState().smartTags) {
allTags = allTags.concat(this.getState().smartTags);
}
const noteCounts: NoteCounts = {};
for (const tag of allTags) {
@@ -168,7 +193,7 @@ class TagsViewCtrl extends PureViewCtrl {
noteCounts[tag.uuid] = notes.length;
}
}
this.setState({
this.setTagState({
noteCounts: noteCounts
});
}
@@ -232,7 +257,7 @@ class TagsViewCtrl extends PureViewCtrl {
});
}
} else if (action === ComponentAction.ClearSelection) {
this.selectTag(this.state.smartTags[0]);
this.selectTag(this.getState().smartTags[0]);
}
}
});
@@ -248,77 +273,91 @@ class TagsViewCtrl extends PureViewCtrl {
}
async clickedAddNewTag() {
if (this.state.editingTag) {
if (this.getState().editingTag) {
return;
}
const newTag = await this.application.createTemplateItem(
ContentType.Tag
);
this.setState({
tags: [newTag].concat(this.state.tags),
previousTag: this.state.selectedTag,
) as SNTag;
this.setTagState({
tags: [newTag].concat(this.getState().tags),
previousTag: this.getState().selectedTag,
selectedTag: newTag,
editingTag: newTag,
newTag: newTag
templateTag: newTag
});
}
onTagTitleChange(tag: SNTag | SNSmartTag) {
this.setState({
this.setTagState({
editingTag: tag
});
}
async saveTag($event: Event, tag: SNTag) {
($event.target! as HTMLInputElement).blur();
await this.setState({
editingTag: null,
});
if (this.getState().templateTag) {
return this.saveNewTag();
} else {
return this.saveTagRename(tag);
}
}
if (!tag.title || tag.title.length === 0) {
let newSelectedTag = this.state.selectedTag;
if (this.state.editingTag) {
this.titles[tag.uuid] = this.editingOriginalName;
this.editingOriginalName = undefined;
} else if (this.state.newTag) {
newSelectedTag = this.state.previousTag;
}
this.setState({
newTag: null,
selectedTag: newSelectedTag,
tags: this.getMappedTags()
});
async saveTagRename(tag: SNTag) {
const newTitle = this.titles[tag.uuid] || '';
if (newTitle.length === 0) {
this.titles[tag.uuid] = this.editingOriginalName;
this.editingOriginalName = undefined;
return;
}
this.editingOriginalName = undefined;
const matchingTag = this.application.findTagByTitle(tag.title);
const alreadyExists = matchingTag && matchingTag !== tag;
if (this.state.newTag === tag && alreadyExists) {
const existingTag = this.application.findTagByTitle(newTitle);
if (existingTag && existingTag.uuid !== tag.uuid) {
this.application.alertService!.alert(
"A tag with this name already exists."
);
this.setState({
newTag: null,
tags: this.getMappedTags(),
selectedTag: this.state.previousTag
return;
};
await this.application.changeAndSaveItem(tag.uuid, (mutator) => {
const tagMutator = mutator as TagMutator;
tagMutator.title = newTitle;
});
await this.setTagState({
editingTag: undefined
});
}
async saveNewTag() {
const newTag = this.getState().templateTag!;
const newTitle = this.titles[newTag.uuid] || '';
if (newTitle.length === 0) {
await this.setTagState({
templateTag: undefined
});
return;
}
this.application.changeAndSaveItem(tag.uuid, (mutator) => {
const tagMutator = mutator as TagMutator;
tagMutator.title = this.titles[tag.uuid]!;
const existingTag = this.application.findTagByTitle(newTitle);
if (existingTag) {
this.application.alertService!.alert(
"A tag with this name already exists."
);
return;
};
const insertedTag = await this.application.insertItem(newTag);
const changedTag = await this.application.changeItem(insertedTag.uuid, (m) => {
const mutator = m as TagMutator;
mutator.title = newTitle
});
this.selectTag(tag);
this.setState({
newTag: null
await this.setTagState({
templateTag: undefined,
editingTag: undefined
});
this.selectTag(changedTag as SNTag);
await this.application.saveItem(changedTag!.uuid);
}
async selectedRenameTag(tag: SNTag) {
this.editingOriginalName = tag.title;
await this.setState({
await this.setTagState({
editingTag: tag
});
document.getElementById('tag-' + tag.uuid)!.focus();
@@ -337,7 +376,7 @@ class TagsViewCtrl extends PureViewCtrl {
() => {
/* On confirm */
this.application.deleteItem(tag);
this.selectTag(this.state.smartTags[0]);
this.selectTag(this.getState().smartTags[0]);
},
undefined,
true,

View File

@@ -1031,7 +1031,7 @@ var entry=new historyItemClass(payload);return entry;}/***/},/***/"./lib/service
*/},{key:"duplicateItem",value:function(){var _duplicateItem=_asyncToGenerator(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default.a.mark(function _callee14(uuid){var isConflict,item,payload,resultingPayloads,duplicate,_args14=arguments;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default.a.wrap(function _callee14$(_context14){while(1){switch(_context14.prev=_context14.next){case 0:isConflict=_args14.length>1&&_args14[1]!==undefined?_args14[1]:false;item=this.findItem(uuid);payload=Object(_Payloads_generator__WEBPACK_IMPORTED_MODULE_15__["CreateMaxPayloadFromAnyObject"])(item);_context14.next=5;return Object(_Payloads_functions__WEBPACK_IMPORTED_MODULE_8__["PayloadsByDuplicating"])(payload,this.modelManager.getMasterCollection(),isConflict);case 5:resultingPayloads=_context14.sent;_context14.next=8;return this.modelManager.emitPayloads(resultingPayloads,_protocol_payloads_sources__WEBPACK_IMPORTED_MODULE_17__["PayloadSource"].LocalChanged);case 8:duplicate=this.findItem(resultingPayloads[0].uuid);return _context14.abrupt("return",duplicate);case 10:case"end":return _context14.stop();}}},_callee14,this);}));function duplicateItem(_x33){return _duplicateItem.apply(this,arguments);}return duplicateItem;}()/**
* Creates an item and conditionally maps it and marks it as dirty.
* @param needsSync - Whether to mark the item as needing sync
*/},{key:"createItem",value:function(){var _createItem=_asyncToGenerator(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default.a.mark(function _callee15(contentType,content){var needsSync,override,payload,_args15=arguments;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default.a.wrap(function _callee15$(_context15){while(1){switch(_context15.prev=_context15.next){case 0:needsSync=_args15.length>2&&_args15[2]!==undefined?_args15[2]:false;override=_args15.length>3?_args15[3]:undefined;if(contentType){_context15.next=4;break;}throw'Attempting to create item with no contentType';case 4:_context15.t0=_Payloads_generator__WEBPACK_IMPORTED_MODULE_15__["CreateMaxPayloadFromAnyObject"];_context15.next=7;return _uuid__WEBPACK_IMPORTED_MODULE_7__["Uuid"].GenerateUuid();case 7:_context15.t1=_context15.sent;_context15.t2=contentType;_context15.t3=content?Object(_Models_functions__WEBPACK_IMPORTED_MODULE_11__["FillItemContent"])(content):undefined;_context15.t4=needsSync;_context15.t5={uuid:_context15.t1,content_type:_context15.t2,content:_context15.t3,dirty:_context15.t4};_context15.t6=undefined;_context15.t7=undefined;_context15.t8=override;payload=(0,_context15.t0)(_context15.t5,_context15.t6,_context15.t7,_context15.t8);_context15.next=18;return this.modelManager.emitPayload(payload,_protocol_payloads_sources__WEBPACK_IMPORTED_MODULE_17__["PayloadSource"].Constructor);case 18:return _context15.abrupt("return",this.findItem(payload.uuid));case 19:case"end":return _context15.stop();}}},_callee15,this);}));function createItem(_x34,_x35){return _createItem.apply(this,arguments);}return createItem;}()},{key:"createTemplateItem",value:function(){var _createTemplateItem=_asyncToGenerator(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default.a.mark(function _callee16(contentType,content){var payload;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default.a.wrap(function _callee16$(_context16){while(1){switch(_context16.prev=_context16.next){case 0:_context16.t0=_Payloads_generator__WEBPACK_IMPORTED_MODULE_15__["CreateMaxPayloadFromAnyObject"];_context16.next=3;return _uuid__WEBPACK_IMPORTED_MODULE_7__["Uuid"].GenerateUuid();case 3:_context16.t1=_context16.sent;_context16.t2=contentType;_context16.t3=content?Object(_Models_functions__WEBPACK_IMPORTED_MODULE_11__["FillItemContent"])(content):undefined;_context16.t4={uuid:_context16.t1,content_type:_context16.t2,content:_context16.t3};payload=(0,_context16.t0)(_context16.t4);return _context16.abrupt("return",Object(_Models_generator__WEBPACK_IMPORTED_MODULE_10__["CreateItemFromPayload"])(payload));case 9:case"end":return _context16.stop();}}},_callee16);}));function createTemplateItem(_x36,_x37){return _createTemplateItem.apply(this,arguments);}return createTemplateItem;}()},{key:"emitItemFromPayload",value:function(){var _emitItemFromPayload=_asyncToGenerator(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default.a.mark(function _callee17(payload){var source,_args17=arguments;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default.a.wrap(function _callee17$(_context17){while(1){switch(_context17.prev=_context17.next){case 0:source=_args17.length>1&&_args17[1]!==undefined?_args17[1]:_protocol_payloads_sources__WEBPACK_IMPORTED_MODULE_17__["PayloadSource"].Constructor;_context17.next=3;return this.modelManager.emitPayload(payload,source);case 3:return _context17.abrupt("return",this.findItem(payload.uuid));case 4:case"end":return _context17.stop();}}},_callee17,this);}));function emitItemFromPayload(_x38){return _emitItemFromPayload.apply(this,arguments);}return emitItemFromPayload;}()},{key:"emitItemsFromPayloads",value:function(){var _emitItemsFromPayloads=_asyncToGenerator(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default.a.mark(function _callee18(payloads){var source,uuids,_args18=arguments;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default.a.wrap(function _callee18$(_context18){while(1){switch(_context18.prev=_context18.next){case 0:source=_args18.length>1&&_args18[1]!==undefined?_args18[1]:_protocol_payloads_sources__WEBPACK_IMPORTED_MODULE_17__["PayloadSource"].Constructor;_context18.next=3;return this.modelManager.emitPayloads(payloads,source);case 3:uuids=Object(_Models_functions__WEBPACK_IMPORTED_MODULE_11__["Uuids"])(payloads);return _context18.abrupt("return",this.findItems(uuids));case 5:case"end":return _context18.stop();}}},_callee18,this);}));function emitItemsFromPayloads(_x39){return _emitItemsFromPayloads.apply(this,arguments);}return emitItemsFromPayloads;}()/**
*/},{key:"createItem",value:function(){var _createItem=_asyncToGenerator(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default.a.mark(function _callee15(contentType,content){var needsSync,override,payload,_args15=arguments;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default.a.wrap(function _callee15$(_context15){while(1){switch(_context15.prev=_context15.next){case 0:needsSync=_args15.length>2&&_args15[2]!==undefined?_args15[2]:false;override=_args15.length>3?_args15[3]:undefined;if(contentType){_context15.next=4;break;}throw'Attempting to create item with no contentType';case 4:_context15.t0=_Payloads_generator__WEBPACK_IMPORTED_MODULE_15__["CreateMaxPayloadFromAnyObject"];_context15.next=7;return _uuid__WEBPACK_IMPORTED_MODULE_7__["Uuid"].GenerateUuid();case 7:_context15.t1=_context15.sent;_context15.t2=contentType;_context15.t3=content?Object(_Models_functions__WEBPACK_IMPORTED_MODULE_11__["FillItemContent"])(content):undefined;_context15.t4=needsSync;_context15.t5={uuid:_context15.t1,content_type:_context15.t2,content:_context15.t3,dirty:_context15.t4};_context15.t6=undefined;_context15.t7=undefined;_context15.t8=override;payload=(0,_context15.t0)(_context15.t5,_context15.t6,_context15.t7,_context15.t8);_context15.next=18;return this.modelManager.emitPayload(payload,_protocol_payloads_sources__WEBPACK_IMPORTED_MODULE_17__["PayloadSource"].Constructor);case 18:return _context15.abrupt("return",this.findItem(payload.uuid));case 19:case"end":return _context15.stop();}}},_callee15,this);}));function createItem(_x34,_x35){return _createItem.apply(this,arguments);}return createItem;}()},{key:"createTemplateItem",value:function(){var _createTemplateItem=_asyncToGenerator(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default.a.mark(function _callee16(contentType,content){var payload;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default.a.wrap(function _callee16$(_context16){while(1){switch(_context16.prev=_context16.next){case 0:_context16.t0=_Payloads_generator__WEBPACK_IMPORTED_MODULE_15__["CreateMaxPayloadFromAnyObject"];_context16.next=3;return _uuid__WEBPACK_IMPORTED_MODULE_7__["Uuid"].GenerateUuid();case 3:_context16.t1=_context16.sent;_context16.t2=contentType;_context16.t3=Object(_Models_functions__WEBPACK_IMPORTED_MODULE_11__["FillItemContent"])(content||{});_context16.t4={uuid:_context16.t1,content_type:_context16.t2,content:_context16.t3};payload=(0,_context16.t0)(_context16.t4);return _context16.abrupt("return",Object(_Models_generator__WEBPACK_IMPORTED_MODULE_10__["CreateItemFromPayload"])(payload));case 9:case"end":return _context16.stop();}}},_callee16);}));function createTemplateItem(_x36,_x37){return _createTemplateItem.apply(this,arguments);}return createTemplateItem;}()},{key:"emitItemFromPayload",value:function(){var _emitItemFromPayload=_asyncToGenerator(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default.a.mark(function _callee17(payload){var source,_args17=arguments;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default.a.wrap(function _callee17$(_context17){while(1){switch(_context17.prev=_context17.next){case 0:source=_args17.length>1&&_args17[1]!==undefined?_args17[1]:_protocol_payloads_sources__WEBPACK_IMPORTED_MODULE_17__["PayloadSource"].Constructor;_context17.next=3;return this.modelManager.emitPayload(payload,source);case 3:return _context17.abrupt("return",this.findItem(payload.uuid));case 4:case"end":return _context17.stop();}}},_callee17,this);}));function emitItemFromPayload(_x38){return _emitItemFromPayload.apply(this,arguments);}return emitItemFromPayload;}()},{key:"emitItemsFromPayloads",value:function(){var _emitItemsFromPayloads=_asyncToGenerator(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default.a.mark(function _callee18(payloads){var source,uuids,_args18=arguments;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default.a.wrap(function _callee18$(_context18){while(1){switch(_context18.prev=_context18.next){case 0:source=_args18.length>1&&_args18[1]!==undefined?_args18[1]:_protocol_payloads_sources__WEBPACK_IMPORTED_MODULE_17__["PayloadSource"].Constructor;_context18.next=3;return this.modelManager.emitPayloads(payloads,source);case 3:uuids=Object(_Models_functions__WEBPACK_IMPORTED_MODULE_11__["Uuids"])(payloads);return _context18.abrupt("return",this.findItems(uuids));case 5:case"end":return _context18.stop();}}},_callee18,this);}));function emitItemsFromPayloads(_x39){return _emitItemsFromPayloads.apply(this,arguments);}return emitItemsFromPayloads;}()/**
* Marks the item as deleted and needing sync.
*/},{key:"setItemToBeDeleted",value:function(){var _setItemToBeDeleted=_asyncToGenerator(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default.a.mark(function _callee19(uuid){var referencingIds,item,changedItem,_iteratorNormalCompletion4,_didIteratorError4,_iteratorError4,_iterator4,_step4,referencingId,referencingItem;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default.a.wrap(function _callee19$(_context19){while(1){switch(_context19.prev=_context19.next){case 0:/** Capture referencing ids before we delete the item below, otherwise
* the index may be updated before we get a chance to act on it */referencingIds=this.collection.uuidsThatReferenceUuid(uuid);item=this.findItem(uuid);_context19.next=4;return this.changeItem(uuid,function(mutator){mutator.setDeleted();});case 4:changedItem=_context19.sent;/** Handle indirect relationships.
@@ -14294,7 +14294,7 @@ var Editor = /*#__PURE__*/function () {
_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_4___default()(this, "removeStreamObserver", void 0);
_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_4___default()(this, "isTemplateNote", true);
_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_4___default()(this, "isTemplateNote", false);
this.application = application;
@@ -16556,23 +16556,35 @@ var EditorViewCtrl = /*#__PURE__*/function (_PureViewCtrl) {
case 9:
if (!this.editor.isTemplateNote) {
_context5.next = 12;
_context5.next = 16;
break;
}
_context5.next = 12;
console.log("is template");
_context5.next = 13;
return this.editor.insertTemplatedNote();
case 12:
case 13:
if (!this.appState.selectedTag) {
_context5.next = 16;
break;
}
_context5.next = 16;
return this.application.changeItem(this.appState.selectedTag.uuid, function (mutator) {
mutator.addItemAsRelationship(note);
});
case 16:
if (this.application.findItem(note.uuid)) {
_context5.next = 15;
_context5.next = 19;
break;
}
this.application.alertService.alert(_strings__WEBPACK_IMPORTED_MODULE_19__["STRING_INVALID_NOTE"]);
return _context5.abrupt("return");
case 15:
case 19:
this.showSavingStatus();
this.application.changeItem(note.uuid, function (mutator) {
var noteMutator = mutator;
@@ -16604,7 +16616,7 @@ var EditorViewCtrl = /*#__PURE__*/function (_PureViewCtrl) {
_this4.application.sync();
}, syncDebouceMs);
case 21:
case 25:
case "end":
return _context5.stop();
}
@@ -17004,23 +17016,36 @@ var EditorViewCtrl = /*#__PURE__*/function (_PureViewCtrl) {
return _context7.finish(17);
case 25:
for (_i2 = 0, _removeTags = removeTags; _i2 < _removeTags.length; _i2++) {
_tag = _removeTags[_i2];
this.application.changeItem(_tag.uuid, function (mutator) {
mutator.removeItemAsRelationship(note);
});
_i2 = 0, _removeTags = removeTags;
case 26:
if (!(_i2 < _removeTags.length)) {
_context7.next = 33;
break;
}
_tag = _removeTags[_i2];
_context7.next = 30;
return this.application.changeItem(_tag.uuid, function (mutator) {
mutator.removeItemAsRelationship(note);
});
case 30:
_i2++;
_context7.next = 26;
break;
case 33:
newRelationships = [];
_iteratorNormalCompletion3 = true;
_didIteratorError3 = false;
_iteratorError3 = undefined;
_context7.prev = 30;
_context7.prev = 37;
_iterator3 = strings[Symbol.iterator]();
case 32:
case 39:
if (_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done) {
_context7.next = 44;
_context7.next = 51;
break;
}
@@ -17030,70 +17055,78 @@ var EditorViewCtrl = /*#__PURE__*/function (_PureViewCtrl) {
});
if (existingRelationship) {
_context7.next = 41;
_context7.next = 48;
break;
}
_context7.t1 = newRelationships;
_context7.next = 39;
_context7.next = 46;
return this.application.findOrCreateTag(title);
case 39:
case 46:
_context7.t2 = _context7.sent;
_context7.t1.push.call(_context7.t1, _context7.t2);
case 41:
case 48:
_iteratorNormalCompletion3 = true;
_context7.next = 32;
_context7.next = 39;
break;
case 44:
_context7.next = 50;
case 51:
_context7.next = 57;
break;
case 46:
_context7.prev = 46;
_context7.t3 = _context7["catch"](30);
case 53:
_context7.prev = 53;
_context7.t3 = _context7["catch"](37);
_didIteratorError3 = true;
_iteratorError3 = _context7.t3;
case 50:
_context7.prev = 50;
_context7.prev = 51;
case 57:
_context7.prev = 57;
_context7.prev = 58;
if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
_iterator3.return();
}
case 53:
_context7.prev = 53;
case 60:
_context7.prev = 60;
if (!_didIteratorError3) {
_context7.next = 56;
_context7.next = 63;
break;
}
throw _iteratorError3;
case 56:
return _context7.finish(53);
case 63:
return _context7.finish(60);
case 57:
return _context7.finish(50);
case 64:
return _context7.finish(57);
case 58:
this.application.changeAndSaveItems(Object(snjs__WEBPACK_IMPORTED_MODULE_12__["Uuids"])(newRelationships), function (mutator) {
case 65:
if (!(newRelationships.length > 0)) {
_context7.next = 68;
break;
}
_context7.next = 68;
return this.application.changeAndSaveItems(Object(snjs__WEBPACK_IMPORTED_MODULE_12__["Uuids"])(newRelationships), function (mutator) {
mutator.addItemAsRelationship(note);
});
case 68:
this.reloadTagsString();
case 60:
case 69:
case "end":
return _context7.stop();
}
}
}, _callee7, this, [[9, 13, 17, 25], [18,, 20, 24], [30, 46, 50, 58], [51,, 53, 57]]);
}, _callee7, this, [[9, 13, 17, 25], [18,, 20, 24], [37, 53, 57, 65], [58,, 60, 64]]);
}));
function saveTagsFromStrings(_x4) {
@@ -18950,6 +18983,8 @@ var NotesViewCtrl = /*#__PURE__*/function (_PureViewCtrl) {
this.application.streamItems([snjs__WEBPACK_IMPORTED_MODULE_13__["ContentType"].Note, snjs__WEBPACK_IMPORTED_MODULE_13__["ContentType"].Tag], /*#__PURE__*/function () {
var _ref = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()( /*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default.a.mark(function _callee6(items) {
var _this4$appState$selec;
var activeNote, discarded, notes, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, note;
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default.a.wrap(function _callee6$(_context6) {
@@ -19041,6 +19076,11 @@ var NotesViewCtrl = /*#__PURE__*/function (_PureViewCtrl) {
return _context6.finish(24);
case 32:
if (Object(snjs__WEBPACK_IMPORTED_MODULE_13__["findInArray"])(items, 'uuid', (_this4$appState$selec = _this4.appState.selectedTag) === null || _this4$appState$selec === void 0 ? void 0 : _this4$appState$selec.uuid)) {
_this4.reloadPanelTitle();
}
case 33:
case "end":
return _context6.stop();
}
@@ -19117,28 +19157,22 @@ var NotesViewCtrl = /*#__PURE__*/function (_PureViewCtrl) {
while (1) {
switch (_context9.prev = _context9.next) {
case 0:
_context9.next = 2;
return this.setNotesState({
tag: tag
});
case 2:
this.resetScrollPosition();
this.setShowMenuFalse();
_context9.next = 6;
_context9.next = 4;
return this.setNoteFilterText('');
case 6:
case 4:
this.application.getDesktopService().searchText();
this.resetPagination();
/* Capture db load state before beginning reloadNotes,
since this status may change during reload */
dbLoaded = this.application.isDatabaseLoaded();
_context9.next = 11;
_context9.next = 9;
return this.reloadNotes();
case 11:
case 9:
if (this.getState().notes.length > 0) {
this.selectFirstNote();
} else if (dbLoaded) {
@@ -19149,7 +19183,7 @@ var NotesViewCtrl = /*#__PURE__*/function (_PureViewCtrl) {
}
}
case 12:
case 10:
case "end":
return _context9.stop();
}
@@ -19239,7 +19273,7 @@ var NotesViewCtrl = /*#__PURE__*/function (_PureViewCtrl) {
while (1) {
switch (_context12.prev = _context12.next) {
case 0:
tag = this.getState().tag;
tag = this.appState.selectedTag;
if (tag) {
_context12.next = 3;
@@ -19442,8 +19476,8 @@ var NotesViewCtrl = /*#__PURE__*/function (_PureViewCtrl) {
if (this.isFiltering()) {
var resultCount = this.getState().notes.length;
title = "".concat(resultCount, " search results");
} else if (this.getState().tag) {
title = "".concat(this.getState().tag.title);
} else if (this.appState.selectedTag) {
title = "".concat(this.appState.selectedTag.title);
}
this.setNotesState({
@@ -19602,7 +19636,7 @@ var NotesViewCtrl = /*#__PURE__*/function (_PureViewCtrl) {
if (note) {
this.selectNote(note);
} else if (!this.getState().tag || !this.getState().tag.isSmartTag()) {
} else if (!this.appState.selectedTag || !this.appState.selectedTag.isSmartTag()) {
this.createPlaceholderNote();
} else {
this.appState.closeActiveEditor();
@@ -19941,6 +19975,8 @@ var TagsViewCtrl = /*#__PURE__*/function (_PureViewCtrl) {
/** Passed through template */
/** The original name of the edtingTag before it began editing */
/* @ngInject */
function TagsViewCtrl($timeout) {
var _this;
@@ -19995,12 +20031,41 @@ var TagsViewCtrl = /*#__PURE__*/function (_PureViewCtrl) {
};
}
}, {
key: "onAppStart",
key: "getState",
value: function getState() {
return this.state;
}
}, {
key: "setTagState",
value: function () {
var _onAppStart = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()( /*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default.a.mark(function _callee() {
var _setTagState = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()( /*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default.a.mark(function _callee(state) {
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default.a.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
return _context.abrupt("return", this.setState(state));
case 1:
case "end":
return _context.stop();
}
}
}, _callee, this);
}));
function setTagState(_x) {
return _setTagState.apply(this, arguments);
}
return setTagState;
}()
}, {
key: "onAppStart",
value: function () {
var _onAppStart = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()( /*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default.a.mark(function _callee2() {
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default.a.wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
_babel_runtime_helpers_get__WEBPACK_IMPORTED_MODULE_7___default()(_babel_runtime_helpers_getPrototypeOf__WEBPACK_IMPORTED_MODULE_6___default()(TagsViewCtrl.prototype), "onAppStart", this).call(this);
@@ -20008,10 +20073,10 @@ var TagsViewCtrl = /*#__PURE__*/function (_PureViewCtrl) {
case 2:
case "end":
return _context.stop();
return _context2.stop();
}
}
}, _callee, this);
}, _callee2, this);
}));
function onAppStart() {
@@ -20023,28 +20088,28 @@ var TagsViewCtrl = /*#__PURE__*/function (_PureViewCtrl) {
}, {
key: "onAppLaunch",
value: function () {
var _onAppLaunch = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()( /*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default.a.mark(function _callee2() {
var _onAppLaunch = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()( /*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default.a.mark(function _callee3() {
var smartTags;
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default.a.wrap(function _callee2$(_context2) {
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default.a.wrap(function _callee3$(_context3) {
while (1) {
switch (_context2.prev = _context2.next) {
switch (_context3.prev = _context3.next) {
case 0:
_babel_runtime_helpers_get__WEBPACK_IMPORTED_MODULE_7___default()(_babel_runtime_helpers_getPrototypeOf__WEBPACK_IMPORTED_MODULE_6___default()(TagsViewCtrl.prototype), "onAppLaunch", this).call(this);
this.loadPreferences();
this.beginStreamingItems();
smartTags = this.application.getSmartTags();
this.setState({
this.setTagState({
smartTags: smartTags
});
this.selectTag(smartTags[0]);
case 6:
case "end":
return _context2.stop();
return _context3.stop();
}
}
}, _callee2, this);
}, _callee3, this);
}));
function onAppLaunch() {
@@ -20081,14 +20146,14 @@ var TagsViewCtrl = /*#__PURE__*/function (_PureViewCtrl) {
var _this2 = this;
this.application.streamItems(snjs__WEBPACK_IMPORTED_MODULE_11__["ContentType"].Tag, /*#__PURE__*/function () {
var _ref = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()( /*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default.a.mark(function _callee3(items) {
var _ref = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()( /*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default.a.mark(function _callee4(items) {
var matchingTag;
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default.a.wrap(function _callee3$(_context3) {
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default.a.wrap(function _callee4$(_context4) {
while (1) {
switch (_context3.prev = _context3.next) {
switch (_context4.prev = _context4.next) {
case 0:
_context3.next = 2;
return _this2.setState({
_context4.next = 2;
return _this2.setTagState({
tags: _this2.getMappedTags(),
smartTags: _this2.application.getSmartTags()
});
@@ -20098,30 +20163,32 @@ var TagsViewCtrl = /*#__PURE__*/function (_PureViewCtrl) {
_this2.reloadNoteCounts();
if (_this2.state.selectedTag) {
if (_this2.getState().selectedTag) {
/** If the selected tag has been deleted, revert to All view. */
matchingTag = items.find(function (tag) {
return tag.uuid === _this2.state.selectedTag.uuid;
return tag.uuid === _this2.getState().selectedTag.uuid;
});
if (!matchingTag || matchingTag.deleted) {
_this2.selectTag(_this2.state.smartTags[0]);
} else {
_this2.setState({
selectedTag: matchingTag
});
if (matchingTag) {
if (matchingTag.deleted) {
_this2.selectTag(_this2.getState().smartTags[0]);
} else {
_this2.setTagState({
selectedTag: matchingTag
});
}
}
}
case 5:
case "end":
return _context3.stop();
return _context4.stop();
}
}
}, _callee3);
}, _callee4);
}));
return function (_x) {
return function (_x2) {
return _ref.apply(this, arguments);
};
}());
@@ -20161,7 +20228,7 @@ var TagsViewCtrl = /*#__PURE__*/function (_PureViewCtrl) {
if (eventName === _services_state__WEBPACK_IMPORTED_MODULE_13__["AppStateEvent"].PreferencesChanged) {
this.loadPreferences();
} else if (eventName === _services_state__WEBPACK_IMPORTED_MODULE_13__["AppStateEvent"].TagChanged) {
this.setState({
this.setTagState({
selectedTag: this.application.getAppState().getSelectedTag()
});
}
@@ -20171,11 +20238,11 @@ var TagsViewCtrl = /*#__PURE__*/function (_PureViewCtrl) {
}, {
key: "onAppEvent",
value: function () {
var _onAppEvent = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()( /*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default.a.mark(function _callee4(eventName) {
var _onAppEvent = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()( /*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default.a.mark(function _callee5(eventName) {
var syncStatus, stats;
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default.a.wrap(function _callee4$(_context4) {
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default.a.wrap(function _callee5$(_context5) {
while (1) {
switch (_context4.prev = _context4.next) {
switch (_context5.prev = _context5.next) {
case 0:
_babel_runtime_helpers_get__WEBPACK_IMPORTED_MODULE_7___default()(_babel_runtime_helpers_getPrototypeOf__WEBPACK_IMPORTED_MODULE_6___default()(TagsViewCtrl.prototype), "onAppEvent", this).call(this, eventName);
@@ -20192,13 +20259,13 @@ var TagsViewCtrl = /*#__PURE__*/function (_PureViewCtrl) {
case 2:
case "end":
return _context4.stop();
return _context5.stop();
}
}
}, _callee4, this);
}, _callee5, this);
}));
function onAppEvent(_x2) {
function onAppEvent(_x3) {
return _onAppEvent.apply(this, arguments);
}
@@ -20209,12 +20276,12 @@ var TagsViewCtrl = /*#__PURE__*/function (_PureViewCtrl) {
value: function reloadNoteCounts() {
var allTags = [];
if (this.state.tags) {
allTags = allTags.concat(this.state.tags);
if (this.getState().tags) {
allTags = allTags.concat(this.getState().tags);
}
if (this.state.smartTags) {
allTags = allTags.concat(this.state.smartTags);
if (this.getState().smartTags) {
allTags = allTags.concat(this.getState().smartTags);
}
var noteCounts = {};
@@ -20252,7 +20319,7 @@ var TagsViewCtrl = /*#__PURE__*/function (_PureViewCtrl) {
}
}
this.setState({
this.setTagState({
noteCounts: noteCounts
});
}
@@ -20301,7 +20368,7 @@ var TagsViewCtrl = /*#__PURE__*/function (_PureViewCtrl) {
});
}
} else if (action === snjs__WEBPACK_IMPORTED_MODULE_11__["ComponentAction"].ClearSelection) {
_this3.selectTag(_this3.state.smartTags[0]);
_this3.selectTag(_this3.getState().smartTags[0]);
}
}
});
@@ -20309,10 +20376,10 @@ var TagsViewCtrl = /*#__PURE__*/function (_PureViewCtrl) {
}, {
key: "selectTag",
value: function () {
var _selectTag = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()( /*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default.a.mark(function _callee5(tag) {
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default.a.wrap(function _callee5$(_context5) {
var _selectTag = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()( /*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default.a.mark(function _callee6(tag) {
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default.a.wrap(function _callee6$(_context6) {
while (1) {
switch (_context5.prev = _context5.next) {
switch (_context6.prev = _context6.next) {
case 0:
if (tag.conflictOf) {
this.application.changeAndSaveItem(tag.uuid, function (mutator) {
@@ -20324,13 +20391,13 @@ var TagsViewCtrl = /*#__PURE__*/function (_PureViewCtrl) {
case 2:
case "end":
return _context5.stop();
return _context6.stop();
}
}
}, _callee5, this);
}, _callee6, this);
}));
function selectTag(_x3) {
function selectTag(_x4) {
return _selectTag.apply(this, arguments);
}
@@ -20339,39 +20406,39 @@ var TagsViewCtrl = /*#__PURE__*/function (_PureViewCtrl) {
}, {
key: "clickedAddNewTag",
value: function () {
var _clickedAddNewTag = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()( /*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default.a.mark(function _callee6() {
var _clickedAddNewTag = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()( /*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default.a.mark(function _callee7() {
var newTag;
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default.a.wrap(function _callee6$(_context6) {
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default.a.wrap(function _callee7$(_context7) {
while (1) {
switch (_context6.prev = _context6.next) {
switch (_context7.prev = _context7.next) {
case 0:
if (!this.state.editingTag) {
_context6.next = 2;
if (!this.getState().editingTag) {
_context7.next = 2;
break;
}
return _context6.abrupt("return");
return _context7.abrupt("return");
case 2:
_context6.next = 4;
_context7.next = 4;
return this.application.createTemplateItem(snjs__WEBPACK_IMPORTED_MODULE_11__["ContentType"].Tag);
case 4:
newTag = _context6.sent;
this.setState({
tags: [newTag].concat(this.state.tags),
previousTag: this.state.selectedTag,
newTag = _context7.sent;
this.setTagState({
tags: [newTag].concat(this.getState().tags),
previousTag: this.getState().selectedTag,
selectedTag: newTag,
editingTag: newTag,
newTag: newTag
templateTag: newTag
});
case 6:
case "end":
return _context6.stop();
return _context7.stop();
}
}
}, _callee6, this);
}, _callee7, this);
}));
function clickedAddNewTag() {
@@ -20383,102 +20450,190 @@ var TagsViewCtrl = /*#__PURE__*/function (_PureViewCtrl) {
}, {
key: "onTagTitleChange",
value: function onTagTitleChange(tag) {
this.setState({
this.setTagState({
editingTag: tag
});
}
}, {
key: "saveTag",
value: function () {
var _saveTag = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()( /*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default.a.mark(function _callee7($event, tag) {
var _this4 = this;
var newSelectedTag, matchingTag, alreadyExists;
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default.a.wrap(function _callee7$(_context7) {
var _saveTag = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()( /*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default.a.mark(function _callee8($event, tag) {
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default.a.wrap(function _callee8$(_context8) {
while (1) {
switch (_context7.prev = _context7.next) {
switch (_context8.prev = _context8.next) {
case 0:
$event.target.blur();
_context7.next = 3;
return this.setState({
editingTag: null
});
case 3:
if (!(!tag.title || tag.title.length === 0)) {
_context7.next = 8;
if (!this.getState().templateTag) {
_context8.next = 5;
break;
}
newSelectedTag = this.state.selectedTag;
return _context8.abrupt("return", this.saveNewTag());
if (this.state.editingTag) {
this.titles[tag.uuid] = this.editingOriginalName;
this.editingOriginalName = undefined;
} else if (this.state.newTag) {
newSelectedTag = this.state.previousTag;
}
case 5:
return _context8.abrupt("return", this.saveTagRename(tag));
this.setState({
newTag: null,
selectedTag: newSelectedTag,
tags: this.getMappedTags()
});
return _context7.abrupt("return");
case 8:
this.editingOriginalName = undefined;
matchingTag = this.application.findTagByTitle(tag.title);
alreadyExists = matchingTag && matchingTag !== tag;
if (!(this.state.newTag === tag && alreadyExists)) {
_context7.next = 15;
break;
}
this.application.alertService.alert("A tag with this name already exists.");
this.setState({
newTag: null,
tags: this.getMappedTags(),
selectedTag: this.state.previousTag
});
return _context7.abrupt("return");
case 15:
this.application.changeAndSaveItem(tag.uuid, function (mutator) {
var tagMutator = mutator;
tagMutator.title = _this4.titles[tag.uuid];
});
this.selectTag(tag);
this.setState({
newTag: null
});
case 18:
case 6:
case "end":
return _context7.stop();
return _context8.stop();
}
}
}, _callee7, this);
}, _callee8, this);
}));
function saveTag(_x4, _x5) {
function saveTag(_x5, _x6) {
return _saveTag.apply(this, arguments);
}
return saveTag;
}()
}, {
key: "saveTagRename",
value: function () {
var _saveTagRename = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()( /*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default.a.mark(function _callee9(tag) {
var newTitle, existingTag;
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default.a.wrap(function _callee9$(_context9) {
while (1) {
switch (_context9.prev = _context9.next) {
case 0:
newTitle = this.titles[tag.uuid] || '';
if (!(newTitle.length === 0)) {
_context9.next = 5;
break;
}
this.titles[tag.uuid] = this.editingOriginalName;
this.editingOriginalName = undefined;
return _context9.abrupt("return");
case 5:
existingTag = this.application.findTagByTitle(newTitle);
if (!(existingTag && existingTag.uuid !== tag.uuid)) {
_context9.next = 9;
break;
}
this.application.alertService.alert("A tag with this name already exists.");
return _context9.abrupt("return");
case 9:
;
_context9.next = 12;
return this.application.changeAndSaveItem(tag.uuid, function (mutator) {
var tagMutator = mutator;
tagMutator.title = newTitle;
});
case 12:
_context9.next = 14;
return this.setTagState({
editingTag: undefined
});
case 14:
case "end":
return _context9.stop();
}
}
}, _callee9, this);
}));
function saveTagRename(_x7) {
return _saveTagRename.apply(this, arguments);
}
return saveTagRename;
}()
}, {
key: "saveNewTag",
value: function () {
var _saveNewTag = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()( /*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default.a.mark(function _callee10() {
var newTag, newTitle, existingTag, insertedTag, changedTag;
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default.a.wrap(function _callee10$(_context10) {
while (1) {
switch (_context10.prev = _context10.next) {
case 0:
newTag = this.getState().templateTag;
newTitle = this.titles[newTag.uuid] || '';
if (!(newTitle.length === 0)) {
_context10.next = 6;
break;
}
_context10.next = 5;
return this.setTagState({
templateTag: undefined
});
case 5:
return _context10.abrupt("return");
case 6:
existingTag = this.application.findTagByTitle(newTitle);
if (!existingTag) {
_context10.next = 10;
break;
}
this.application.alertService.alert("A tag with this name already exists.");
return _context10.abrupt("return");
case 10:
;
_context10.next = 13;
return this.application.insertItem(newTag);
case 13:
insertedTag = _context10.sent;
_context10.next = 16;
return this.application.changeItem(insertedTag.uuid, function (m) {
var mutator = m;
mutator.title = newTitle;
});
case 16:
changedTag = _context10.sent;
_context10.next = 19;
return this.setTagState({
templateTag: undefined,
editingTag: undefined
});
case 19:
this.selectTag(changedTag);
_context10.next = 22;
return this.application.saveItem(changedTag.uuid);
case 22:
case "end":
return _context10.stop();
}
}
}, _callee10, this);
}));
function saveNewTag() {
return _saveNewTag.apply(this, arguments);
}
return saveNewTag;
}()
}, {
key: "selectedRenameTag",
value: function () {
var _selectedRenameTag = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()( /*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default.a.mark(function _callee8(tag) {
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default.a.wrap(function _callee8$(_context8) {
var _selectedRenameTag = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()( /*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default.a.mark(function _callee11(tag) {
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default.a.wrap(function _callee11$(_context11) {
while (1) {
switch (_context8.prev = _context8.next) {
switch (_context11.prev = _context11.next) {
case 0:
this.editingOriginalName = tag.title;
_context8.next = 3;
return this.setState({
_context11.next = 3;
return this.setTagState({
editingTag: tag
});
@@ -20487,13 +20642,13 @@ var TagsViewCtrl = /*#__PURE__*/function (_PureViewCtrl) {
case 4:
case "end":
return _context8.stop();
return _context11.stop();
}
}
}, _callee8, this);
}, _callee11, this);
}));
function selectedRenameTag(_x6) {
function selectedRenameTag(_x8) {
return _selectedRenameTag.apply(this, arguments);
}
@@ -20507,13 +20662,13 @@ var TagsViewCtrl = /*#__PURE__*/function (_PureViewCtrl) {
}, {
key: "removeTag",
value: function removeTag(tag) {
var _this5 = this;
var _this4 = this;
this.application.alertService.confirm(_strings__WEBPACK_IMPORTED_MODULE_15__["STRING_DELETE_TAG"], undefined, undefined, undefined, function () {
/* On confirm */
_this5.application.deleteItem(tag);
_this4.application.deleteItem(tag);
_this5.selectTag(_this5.state.smartTags[0]);
_this4.selectTag(_this4.getState().smartTags[0]);
}, undefined, true);
}
}]);
@@ -20525,21 +20680,21 @@ var TagsView = /*#__PURE__*/function (_WebDirective) {
_babel_runtime_helpers_inherits__WEBPACK_IMPORTED_MODULE_8___default()(TagsView, _WebDirective);
function TagsView() {
var _this6;
var _this5;
_babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_2___default()(this, TagsView);
_this6 = _babel_runtime_helpers_possibleConstructorReturn__WEBPACK_IMPORTED_MODULE_4___default()(this, _babel_runtime_helpers_getPrototypeOf__WEBPACK_IMPORTED_MODULE_6___default()(TagsView).call(this));
_this6.restrict = 'E';
_this6.scope = {
_this5 = _babel_runtime_helpers_possibleConstructorReturn__WEBPACK_IMPORTED_MODULE_4___default()(this, _babel_runtime_helpers_getPrototypeOf__WEBPACK_IMPORTED_MODULE_6___default()(TagsView).call(this));
_this5.restrict = 'E';
_this5.scope = {
application: '='
};
_this6.template = _tags_view_pug__WEBPACK_IMPORTED_MODULE_12___default.a;
_this6.replace = true;
_this6.controller = TagsViewCtrl;
_this6.controllerAs = 'self';
_this6.bindToController = true;
return _this6;
_this5.template = _tags_view_pug__WEBPACK_IMPORTED_MODULE_12___default.a;
_this5.replace = true;
_this5.controller = TagsViewCtrl;
_this5.controllerAs = 'self';
_this5.bindToController = true;
return _this5;
}
return TagsView;
@@ -80599,7 +80754,7 @@ module.exports = template;
var pug = __webpack_require__(/*! ../../../../../node_modules/pug-runtime/index.js */ "./node_modules/pug-runtime/index.js");
function template(locals) {var pug_html = "", pug_mixins = {}, pug_interp;pug_html = pug_html + "\u003Cdiv class=\"sn-component section tags\" id=\"tags-column\" aria-label=\"Tags\"\u003E\u003Cdiv class=\"component-view-container\" ng-if=\"self.component.active\"\u003E\u003Ccomponent-view class=\"component-view\" component=\"self.component\" application=\"self.application\"\u003E\u003C\u002Fcomponent-view\u003E\u003C\u002Fdiv\u003E\u003Cdiv class=\"content\" id=\"tags-content\" ng-if=\"!(self.component &amp;&amp; self.component.active)\"\u003E\u003Cdiv class=\"tags-title-section section-title-bar\"\u003E\u003Cdiv class=\"section-title-bar-header\"\u003E\u003Cdiv class=\"sk-h3 title\"\u003E\u003Cspan class=\"sk-bold\"\u003EViews\u003C\u002Fspan\u003E\u003C\u002Fdiv\u003E\u003Cdiv class=\"sk-button sk-secondary-contrast wide\" ng-click=\"self.clickedAddNewTag()\" title=\"Create a new tag\"\u003E\u003Cdiv class=\"sk-label\"\u003E\u003Ci class=\"icon ion-plus add-button\"\u003E\u003C\u002Fi\u003E\u003C\u002Fdiv\u003E\u003C\u002Fdiv\u003E\u003C\u002Fdiv\u003E\u003C\u002Fdiv\u003E\u003Cdiv class=\"scrollable\"\u003E\u003Cdiv class=\"infinite-scroll\"\u003E\u003Cdiv class=\"tag\" ng-class=\"{'selected' : self.state.selectedTag == tag, 'faded' : !tag.isAllTag}\" ng-click=\"self.selectTag(tag)\" ng-repeat=\"tag in self.state.smartTags track by tag.uuid\"\u003E\u003Cdiv class=\"tag-info\"\u003E\u003Cinput class=\"title\" ng-disabled=\"true\" ng-change=\"self.onTagTitleChange(tag)\" ng-model=\"tag.title\"\u003E\u003Cdiv class=\"count\" ng-show=\"tag.isAllTag\"\u003E{{self.state.noteCounts[tag.uuid]}}\u003C\u002Fdiv\u003E\u003C\u002Fdiv\u003E\u003C\u002Fdiv\u003E\u003Cdiv class=\"tags-title-section section-title-bar\"\u003E\u003Cdiv class=\"section-title-bar-header\"\u003E\u003Cdiv class=\"sk-h3 title\"\u003E\u003Cspan class=\"sk-bold\"\u003ETags\u003C\u002Fspan\u003E\u003C\u002Fdiv\u003E\u003C\u002Fdiv\u003E\u003C\u002Fdiv\u003E\u003Cdiv class=\"tag\" ng-class=\"{'selected' : self.state.selectedTag == tag}\" ng-click=\"self.selectTag(tag)\" ng-repeat=\"tag in self.state.tags track by tag.uuid\"\u003E\u003Cdiv class=\"tag-info\"\u003E\u003Cdiv class=\"tag-icon\"\u003E#\u003C\u002Fdiv\u003E\u003Cinput class=\"title\" ng-attr-id=\"tag-{{tag.uuid}}\" ng-blur=\"self.saveTag($event, tag)\" ng-change=\"self.onTagTitleChange(tag)\" ng-model=\"self.titles[tag.uuid]\" ng-class=\"{'editing' : self.state.editingTag == tag}\" ng-click=\"self.selectTag(tag)\" ng-keyup=\"$event.keyCode == 13 &amp;&amp; $event.target.blur()\" should-focus=\"self.state.newTag || self.state.editingTag == tag\" sn-autofocus=\"true\" spellcheck=\"false\"\u003E\u003Cdiv class=\"count\"\u003E{{self.state.noteCounts[tag.uuid]}}\u003C\u002Fdiv\u003E\u003C\u002Fdiv\u003E\u003Cdiv class=\"danger small-text bold\" ng-show=\"tag.conflictOf\"\u003EConflicted Copy\u003C\u002Fdiv\u003E\u003Cdiv class=\"danger small-text bold\" ng-show=\"tag.errorDecrypting &amp;&amp; !tag.waitingForKey\"\u003EMissing Keys\u003C\u002Fdiv\u003E\u003Cdiv class=\"info small-text bold\" ng-show=\"tag.errorDecrypting &amp;&amp; tag.waitingForKey\"\u003EWaiting For Keys\u003C\u002Fdiv\u003E\u003Cdiv class=\"menu\" ng-show=\"self.state.selectedTag == tag\"\u003E\u003Ca class=\"item\" ng-click=\"self.selectedRenameTag(tag)\" ng-show=\"!self.state.editingTag\"\u003ERename\u003C\u002Fa\u003E\u003Ca class=\"item\" ng-click=\"self.saveTag($event, tag)\" ng-show=\"self.state.editingTag\"\u003ESave\u003C\u002Fa\u003E\u003Ca class=\"item\" ng-click=\"self.selectedDeleteTag(tag)\"\u003EDelete\u003C\u002Fa\u003E\u003C\u002Fdiv\u003E\u003C\u002Fdiv\u003E\u003Cdiv class=\"no-tags-placeholder\" ng-show=\"self.state.tags.length == 0\"\u003ENo tags. Create one using the add button above.\u003C\u002Fdiv\u003E\u003C\u002Fdiv\u003E\u003C\u002Fdiv\u003E\u003C\u002Fdiv\u003E\u003Cpanel-resizer collapsable=\"true\" control=\"self.panelPuppet\" default-width=\"150\" hoverable=\"true\" on-resize-finish=\"self.onPanelResize()\" panel-id=\"'tags-column'\"\u003E\u003C\u002Fpanel-resizer\u003E\u003C\u002Fdiv\u003E";;return pug_html;};
function template(locals) {var pug_html = "", pug_mixins = {}, pug_interp;pug_html = pug_html + "\u003Cdiv class=\"sn-component section tags\" id=\"tags-column\" aria-label=\"Tags\"\u003E\u003Cdiv class=\"component-view-container\" ng-if=\"self.component.active\"\u003E\u003Ccomponent-view class=\"component-view\" component=\"self.component\" application=\"self.application\"\u003E\u003C\u002Fcomponent-view\u003E\u003C\u002Fdiv\u003E\u003Cdiv class=\"content\" id=\"tags-content\" ng-if=\"!(self.component &amp;&amp; self.component.active)\"\u003E\u003Cdiv class=\"tags-title-section section-title-bar\"\u003E\u003Cdiv class=\"section-title-bar-header\"\u003E\u003Cdiv class=\"sk-h3 title\"\u003E\u003Cspan class=\"sk-bold\"\u003EViews\u003C\u002Fspan\u003E\u003C\u002Fdiv\u003E\u003Cdiv class=\"sk-button sk-secondary-contrast wide\" ng-click=\"self.clickedAddNewTag()\" title=\"Create a new tag\"\u003E\u003Cdiv class=\"sk-label\"\u003E\u003Ci class=\"icon ion-plus add-button\"\u003E\u003C\u002Fi\u003E\u003C\u002Fdiv\u003E\u003C\u002Fdiv\u003E\u003C\u002Fdiv\u003E\u003C\u002Fdiv\u003E\u003Cdiv class=\"scrollable\"\u003E\u003Cdiv class=\"infinite-scroll\"\u003E\u003Cdiv class=\"tag\" ng-class=\"{'selected' : self.state.selectedTag == tag, 'faded' : !tag.isAllTag}\" ng-click=\"self.selectTag(tag)\" ng-repeat=\"tag in self.state.smartTags track by tag.uuid\"\u003E\u003Cdiv class=\"tag-info\"\u003E\u003Cinput class=\"title\" ng-disabled=\"true\" ng-change=\"self.onTagTitleChange(tag)\" ng-model=\"tag.title\"\u003E\u003Cdiv class=\"count\" ng-show=\"tag.isAllTag\"\u003E{{self.state.noteCounts[tag.uuid]}}\u003C\u002Fdiv\u003E\u003C\u002Fdiv\u003E\u003C\u002Fdiv\u003E\u003Cdiv class=\"tags-title-section section-title-bar\"\u003E\u003Cdiv class=\"section-title-bar-header\"\u003E\u003Cdiv class=\"sk-h3 title\"\u003E\u003Cspan class=\"sk-bold\"\u003ETags\u003C\u002Fspan\u003E\u003C\u002Fdiv\u003E\u003C\u002Fdiv\u003E\u003C\u002Fdiv\u003E\u003Cdiv class=\"tag\" ng-class=\"{'selected' : self.state.selectedTag == tag}\" ng-click=\"self.selectTag(tag)\" ng-repeat=\"tag in self.state.tags track by tag.uuid\"\u003E\u003Cdiv class=\"tag-info\"\u003E\u003Cdiv class=\"tag-icon\"\u003E#\u003C\u002Fdiv\u003E\u003Cinput class=\"title\" ng-attr-id=\"tag-{{tag.uuid}}\" ng-blur=\"self.saveTag($event, tag)\" ng-change=\"self.onTagTitleChange(tag)\" ng-model=\"self.titles[tag.uuid]\" ng-class=\"{'editing' : self.state.editingTag == tag}\" ng-click=\"self.selectTag(tag)\" ng-keyup=\"$event.keyCode == 13 &amp;&amp; $event.target.blur()\" should-focus=\"self.state.templateTag || self.state.editingTag == tag\" sn-autofocus=\"true\" spellcheck=\"false\"\u003E\u003Cdiv class=\"count\"\u003E{{self.state.noteCounts[tag.uuid]}}\u003C\u002Fdiv\u003E\u003C\u002Fdiv\u003E\u003Cdiv class=\"danger small-text bold\" ng-show=\"tag.conflictOf\"\u003EConflicted Copy\u003C\u002Fdiv\u003E\u003Cdiv class=\"danger small-text bold\" ng-show=\"tag.errorDecrypting &amp;&amp; !tag.waitingForKey\"\u003EMissing Keys\u003C\u002Fdiv\u003E\u003Cdiv class=\"info small-text bold\" ng-show=\"tag.errorDecrypting &amp;&amp; tag.waitingForKey\"\u003EWaiting For Keys\u003C\u002Fdiv\u003E\u003Cdiv class=\"menu\" ng-show=\"self.state.selectedTag == tag\"\u003E\u003Ca class=\"item\" ng-click=\"self.selectedRenameTag(tag)\" ng-show=\"!self.state.editingTag\"\u003ERename\u003C\u002Fa\u003E\u003Ca class=\"item\" ng-click=\"self.saveTag($event, tag)\" ng-show=\"self.state.editingTag\"\u003ESave\u003C\u002Fa\u003E\u003Ca class=\"item\" ng-click=\"self.selectedDeleteTag(tag)\"\u003EDelete\u003C\u002Fa\u003E\u003C\u002Fdiv\u003E\u003C\u002Fdiv\u003E\u003Cdiv class=\"no-tags-placeholder\" ng-show=\"self.state.tags.length == 0\"\u003ENo tags. Create one using the add button above.\u003C\u002Fdiv\u003E\u003C\u002Fdiv\u003E\u003C\u002Fdiv\u003E\u003C\u002Fdiv\u003E\u003Cpanel-resizer collapsable=\"true\" control=\"self.panelPuppet\" default-width=\"150\" hoverable=\"true\" on-resize-finish=\"self.onPanelResize()\" panel-id=\"'tags-column'\"\u003E\u003C\u002Fpanel-resizer\u003E\u003C\u002Fdiv\u003E";;return pug_html;};
module.exports = template;
/***/ }),

File diff suppressed because one or more lines are too long