Component improvements
This commit is contained in:
@@ -17,7 +17,6 @@ export class WebApplication extends SNApplication {
|
|||||||
environment: Environments.Web,
|
environment: Environments.Web,
|
||||||
platform: platformFromString(getPlatformString()),
|
platform: platformFromString(getPlatformString()),
|
||||||
namespace: '',
|
namespace: '',
|
||||||
host: window._default_sync_server,
|
|
||||||
deviceInterface: deviceInterface,
|
deviceInterface: deviceInterface,
|
||||||
swapClasses: [
|
swapClasses: [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -69,7 +69,9 @@ class ApplicationViewCtrl extends PureCtrl {
|
|||||||
onAppStart() {
|
onAppStart() {
|
||||||
super.onAppStart();
|
super.onAppStart();
|
||||||
this.overrideComponentManagerFunctions();
|
this.overrideComponentManagerFunctions();
|
||||||
this.application.componentManager.setDesktopManager(this.application.getDesktopService());
|
this.application.componentManager.setDesktopManager(
|
||||||
|
this.application.getDesktopService()
|
||||||
|
);
|
||||||
this.setState({
|
this.setState({
|
||||||
ready: true,
|
ready: true,
|
||||||
needsUnlock: this.application.hasPasscode()
|
needsUnlock: this.application.hasPasscode()
|
||||||
@@ -112,7 +114,7 @@ class ApplicationViewCtrl extends PureCtrl {
|
|||||||
}
|
}
|
||||||
} else if (eventName === ApplicationEvents.InvalidSyncSession) {
|
} else if (eventName === ApplicationEvents.InvalidSyncSession) {
|
||||||
this.showInvalidSessionAlert();
|
this.showInvalidSessionAlert();
|
||||||
} else if(eventName === ApplicationEvents.LocalDatabaseReadError) {
|
} else if (eventName === ApplicationEvents.LocalDatabaseReadError) {
|
||||||
this.application.alertService.alert({
|
this.application.alertService.alert({
|
||||||
text: 'Unable to load local database. Please restart the app and try again.'
|
text: 'Unable to load local database. Please restart the app and try again.'
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,4 +1,10 @@
|
|||||||
import { SNNote, SNSmartTag, ContentTypes, ApplicationEvents } from 'snjs';
|
import {
|
||||||
|
SNNote,
|
||||||
|
SNSmartTag,
|
||||||
|
ContentTypes,
|
||||||
|
ApplicationEvents,
|
||||||
|
ComponentActions
|
||||||
|
} from 'snjs';
|
||||||
import template from '%/tags.pug';
|
import template from '%/tags.pug';
|
||||||
import { AppStateEvents } from '@/services/state';
|
import { AppStateEvents } from '@/services/state';
|
||||||
import { PANEL_NAME_TAGS } from '@/controllers/constants';
|
import { PANEL_NAME_TAGS } from '@/controllers/constants';
|
||||||
@@ -47,6 +53,7 @@ class TagsPanelCtrl extends PureCtrl {
|
|||||||
this.selectTag(smartTags[0]);
|
this.selectTag(smartTags[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @override */
|
||||||
onAppSync() {
|
onAppSync() {
|
||||||
super.onAppSync();
|
super.onAppSync();
|
||||||
this.reloadNoteCounts();
|
this.reloadNoteCounts();
|
||||||
@@ -169,18 +176,22 @@ class TagsPanelCtrl extends PureCtrl {
|
|||||||
contextRequestHandler: (component) => {
|
contextRequestHandler: (component) => {
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
actionHandler: (component, action, data) => {
|
actionHandler: (_, action, data) => {
|
||||||
if (action === 'select-item') {
|
if (action === ComponentActions.SelectItem) {
|
||||||
if (data.item.content_type === 'Tag') {
|
if (data.item.content_type === ContentTypes.Tag) {
|
||||||
const tag = this.application.findItem({ uuid: data.item.uuid });
|
const tag = this.application.findItem({ uuid: data.item.uuid });
|
||||||
if (tag) {
|
if (tag) {
|
||||||
this.selectTag(tag);
|
this.selectTag(tag);
|
||||||
}
|
}
|
||||||
} else if (data.item.content_type === 'SN|SmartTag') {
|
} else if (data.item.content_type === ContentTypes.SmartTag) {
|
||||||
const smartTag = new SNSmartTag(data.item);
|
this.application.createTemplateItem({
|
||||||
this.selectTag(smartTag);
|
contentType: ContentTypes.SmartTag,
|
||||||
|
content: data.item.content
|
||||||
|
}).then(smartTag => {
|
||||||
|
this.selectTag(smartTag);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
} else if (action === 'clear-selection') {
|
} else if (action === ComponentActions.ClearSelection) {
|
||||||
this.selectTag(this.state.smartTags[0]);
|
this.selectTag(this.state.smartTags[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -96,6 +96,11 @@ class AccountMenuCtrl extends PureCtrl {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onHostInputChange() {
|
||||||
|
const url = this.state.formData.url;
|
||||||
|
this.application.setHost(url);
|
||||||
|
}
|
||||||
|
|
||||||
async loadBackupsAvailability() {
|
async loadBackupsAvailability() {
|
||||||
const hasUser = !isNullOrUndefined(this.application.getUser());
|
const hasUser = !isNullOrUndefined(this.application.getUser());
|
||||||
const hasPasscode = this.application.hasPasscode();
|
const hasPasscode = this.application.hasPasscode();
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ export class ComponentModalCtrl {
|
|||||||
this.$element = $element;
|
this.$element = $element;
|
||||||
}
|
}
|
||||||
|
|
||||||
dismiss(callback) {
|
dismiss() {
|
||||||
if(this.onDismiss) {
|
if(this.onDismiss) {
|
||||||
this.onDismiss(this.component);
|
this.onDismiss(this.component);
|
||||||
}
|
}
|
||||||
@@ -29,7 +29,8 @@ export class ComponentModal {
|
|||||||
show: '=',
|
show: '=',
|
||||||
component: '=',
|
component: '=',
|
||||||
callback: '=',
|
callback: '=',
|
||||||
onDismiss: '&'
|
onDismiss: '&',
|
||||||
|
application: '='
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,9 +18,6 @@ class ComponentViewCtrl {
|
|||||||
this.$rootScope = $rootScope;
|
this.$rootScope = $rootScope;
|
||||||
this.$timeout = $timeout;
|
this.$timeout = $timeout;
|
||||||
this.componentValid = true;
|
this.componentValid = true;
|
||||||
this.cleanUpWatch = $scope.$watch('ctrl.component', (component, prevComponent) => {
|
|
||||||
this.componentValueDidSet(component, prevComponent);
|
|
||||||
});
|
|
||||||
this.cleanUpOn = $scope.$on('ext-reload-complete', () => {
|
this.cleanUpOn = $scope.$on('ext-reload-complete', () => {
|
||||||
this.reloadStatus(false);
|
this.reloadStatus(false);
|
||||||
});
|
});
|
||||||
@@ -30,17 +27,19 @@ class ComponentViewCtrl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$onDestroy() {
|
$onDestroy() {
|
||||||
this.cleanUpWatch();
|
|
||||||
this.cleanUpOn();
|
this.cleanUpOn();
|
||||||
this.cleanUpWatch = null;
|
|
||||||
this.cleanUpOn = null;
|
this.cleanUpOn = null;
|
||||||
this.unregisterThemeHandler();
|
|
||||||
this.unregisterComponentHandler();
|
this.unregisterComponentHandler();
|
||||||
this.unregisterThemeHandler = null;
|
|
||||||
this.unregisterComponentHandler = null;
|
this.unregisterComponentHandler = null;
|
||||||
if (this.component && !this.manualDealloc) {
|
if (this.component && !this.manualDealloc) {
|
||||||
const dontSync = true;
|
const dontSync = true;
|
||||||
this.application.componentManager.deactivateComponent(this.component, dontSync);
|
/* application and componentManager may be destroyed if this onDestroy is part of
|
||||||
|
the entire application being destroyed rather than part of just a single component
|
||||||
|
view being removed */
|
||||||
|
if (this.application && this.application.componentManager) {
|
||||||
|
this.application.componentManager
|
||||||
|
.deactivateComponent(this.component, dontSync);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.unregisterDesktopObserver();
|
this.unregisterDesktopObserver();
|
||||||
this.unregisterDesktopObserver = null;
|
this.unregisterDesktopObserver = null;
|
||||||
@@ -53,11 +52,32 @@ class ComponentViewCtrl {
|
|||||||
this.application = null;
|
this.application = null;
|
||||||
this.onVisibilityChange = null;
|
this.onVisibilityChange = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$onInit() {
|
$onChanges() {
|
||||||
this.registerComponentHandlers();
|
if(!this.didRegisterObservers) {
|
||||||
this.registerPackageUpdateObserver();
|
this.didRegisterObservers = true;
|
||||||
};
|
this.registerComponentHandlers();
|
||||||
|
this.registerPackageUpdateObserver();
|
||||||
|
}
|
||||||
|
const newComponent = this.component;
|
||||||
|
const oldComponent = this.lastComponentValue;
|
||||||
|
this.lastComponentValue = newComponent;
|
||||||
|
const dontSync = true;
|
||||||
|
if (oldComponent && oldComponent !== newComponent) {
|
||||||
|
this.application.componentManager.deactivateComponent(
|
||||||
|
oldComponent,
|
||||||
|
dontSync
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (newComponent && newComponent !== oldComponent) {
|
||||||
|
this.application.componentManager.activateComponent(
|
||||||
|
newComponent,
|
||||||
|
dontSync
|
||||||
|
).then(() => {
|
||||||
|
this.reloadStatus();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
registerPackageUpdateObserver() {
|
registerPackageUpdateObserver() {
|
||||||
this.unregisterDesktopObserver = this.application.getDesktopService()
|
this.unregisterDesktopObserver = this.application.getDesktopService()
|
||||||
@@ -69,14 +89,6 @@ class ComponentViewCtrl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
registerComponentHandlers() {
|
registerComponentHandlers() {
|
||||||
this.unregisterThemeHandler = this.application.componentManager.registerHandler({
|
|
||||||
identifier: 'component-view-' + Math.random(),
|
|
||||||
areas: ['themes'],
|
|
||||||
activationHandler: (component) => {
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
this.unregisterComponentHandler = this.application.componentManager.registerHandler({
|
this.unregisterComponentHandler = this.application.componentManager.registerHandler({
|
||||||
identifier: 'component-view-' + Math.random(),
|
identifier: 'component-view-' + Math.random(),
|
||||||
areas: [this.component.area],
|
areas: [this.component.area],
|
||||||
@@ -153,7 +165,7 @@ class ComponentViewCtrl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleActivation() {
|
handleActivation() {
|
||||||
if (!this.component.active) {
|
if (!this.component || !this.component.active) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const iframe = this.application.componentManager.iframeForComponent(
|
const iframe = this.application.componentManager.iframeForComponent(
|
||||||
@@ -215,23 +227,6 @@ class ComponentViewCtrl {
|
|||||||
}, avoidFlickerTimeout);
|
}, avoidFlickerTimeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
componentValueDidSet(component, prevComponent) {
|
|
||||||
const dontSync = true;
|
|
||||||
if (prevComponent && component !== prevComponent) {
|
|
||||||
this.application.componentManager.deactivateComponent(
|
|
||||||
prevComponent,
|
|
||||||
dontSync
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (component) {
|
|
||||||
this.application.componentManager.activateComponent(
|
|
||||||
component,
|
|
||||||
dontSync
|
|
||||||
);
|
|
||||||
this.reloadStatus();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
disableActiveTheme() {
|
disableActiveTheme() {
|
||||||
this.application.getThemeService().deactivateAllThemes();
|
this.application.getThemeService().deactivateAllThemes();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,6 +75,7 @@
|
|||||||
input.sk-input.mt-5.sk-base(
|
input.sk-input.mt-5.sk-base(
|
||||||
name='server',
|
name='server',
|
||||||
ng-model='self.state.formData.url',
|
ng-model='self.state.formData.url',
|
||||||
|
ng-change='self.onHostInputChange()'
|
||||||
placeholder='Server URL',
|
placeholder='Server URL',
|
||||||
required='',
|
required='',
|
||||||
type='text'
|
type='text'
|
||||||
|
|||||||
@@ -12,5 +12,5 @@
|
|||||||
a.sk-a.info.close-button(ng-click="ctrl.dismiss()") Close
|
a.sk-a.info.close-button(ng-click="ctrl.dismiss()") Close
|
||||||
component-view.component-view(
|
component-view.component-view(
|
||||||
component="ctrl.component",
|
component="ctrl.component",
|
||||||
application='self.application'
|
application='ctrl.application'
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
.sk-menu-panel-column(
|
.sk-menu-panel-column(
|
||||||
ng-if='editor.content.conflict_of || self.shouldDisplayRunningLocallyLabel(editor)'
|
ng-if='editor.content.conflict_of || self.shouldDisplayRunningLocallyLabel(editor)'
|
||||||
)
|
)
|
||||||
strong.danger.medium-text(
|
.info(
|
||||||
ng-if='editor.content.conflict_of'
|
ng-if='editor.content.conflict_of'
|
||||||
) Conflicted copy
|
) Conflicted copy
|
||||||
.sk-sublabel(
|
.sk-sublabel(
|
||||||
|
|||||||
@@ -24,5 +24,5 @@
|
|||||||
component-view.component-view(
|
component-view.component-view(
|
||||||
component="ctrl.editor"
|
component="ctrl.editor"
|
||||||
ng-if="ctrl.editor",
|
ng-if="ctrl.editor",
|
||||||
application='self.application'
|
application='ctrl.application'
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -35,7 +35,8 @@
|
|||||||
component-view.component-view(
|
component-view.component-view(
|
||||||
component='self.state.tagsComponent',
|
component='self.state.tagsComponent',
|
||||||
ng-class="{'locked' : self.state.note.locked}",
|
ng-class="{'locked' : self.state.note.locked}",
|
||||||
ng-style="self.state.note.locked && {'pointer-events' : 'none'}"
|
ng-style="self.state.note.locked && {'pointer-events' : 'none'}",
|
||||||
|
application='self.application'
|
||||||
)
|
)
|
||||||
input.tags-input(
|
input.tags-input(
|
||||||
ng-blur='self.saveTags()',
|
ng-blur='self.saveTags()',
|
||||||
|
|||||||
@@ -33,7 +33,7 @@
|
|||||||
component='room',
|
component='room',
|
||||||
ng-if='room.showRoom',
|
ng-if='room.showRoom',
|
||||||
on-dismiss='ctrl.onRoomDismiss()',
|
on-dismiss='ctrl.onRoomDismiss()',
|
||||||
application='self.application'
|
application='ctrl.application'
|
||||||
)
|
)
|
||||||
.center
|
.center
|
||||||
.sk-app-bar-item(ng-if='ctrl.arbitraryStatusMessage')
|
.sk-app-bar-item(ng-if='ctrl.arbitraryStatusMessage')
|
||||||
@@ -64,7 +64,7 @@
|
|||||||
close-function='ctrl.toggleSyncResolutionMenu()',
|
close-function='ctrl.toggleSyncResolutionMenu()',
|
||||||
ng-click='$event.stopPropagation();',
|
ng-click='$event.stopPropagation();',
|
||||||
ng-if='ctrl.showSyncResolution',
|
ng-if='ctrl.showSyncResolution',
|
||||||
application='self.application'
|
application='ctrl.application'
|
||||||
)
|
)
|
||||||
.sk-app-bar-item(ng-if='ctrl.lastSyncDate && ctrl.isRefreshing')
|
.sk-app-bar-item(ng-if='ctrl.lastSyncDate && ctrl.isRefreshing')
|
||||||
.sk-spinner.small
|
.sk-spinner.small
|
||||||
|
|||||||
315
dist/javascripts/app.js
vendored
315
dist/javascripts/app.js
vendored
File diff suppressed because one or more lines are too long
2
dist/javascripts/app.js.map
vendored
2
dist/javascripts/app.js.map
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user