This commit is contained in:
Mo Bitar
2020-02-08 20:37:07 -06:00
parent 8822580e7a
commit 5226d57623
7 changed files with 55 additions and 97 deletions

View File

@@ -11,7 +11,8 @@ import { AlertManager } from '@/services/alertManager';
import { WebDeviceInterface } from '@/web_device_interface'; import { WebDeviceInterface } from '@/web_device_interface';
export class Application extends SNApplication { export class Application extends SNApplication {
constructor() { /* @ngInject */
constructor($compile, $rootScope) {
const deviceInterface = new WebDeviceInterface(); const deviceInterface = new WebDeviceInterface();
super({ super({
environment: Environments.Web, environment: Environments.Web,
@@ -26,6 +27,8 @@ export class Application extends SNApplication {
} }
] ]
}); });
this.$compile = $compile;
this.$rootScope = $rootScope;
deviceInterface.setApplication(this); deviceInterface.setApplication(this);
this.overrideComponentManagerFunctions(); this.overrideComponentManagerFunctions();
} }
@@ -45,7 +48,7 @@ export class Application extends SNApplication {
const el = this.$compile("<permissions-modal component='component' permissions-string='permissionsString' callback='callback' class='sk-modal'></permissions-modal>")(scope); const el = this.$compile("<permissions-modal component='component' permissions-string='permissionsString' callback='callback' class='sk-modal'></permissions-modal>")(scope);
angular.element(document.body).append(el); angular.element(document.body).append(el);
} }
this.componentManager.openModalComponent = openModalComponent; this.componentManager.openModalComponent = openModalComponent.bind(this);
this.componentManager.presentPermissionsDialog = presentPermissionsDialog; this.componentManager.presentPermissionsDialog = presentPermissionsDialog.bind(this);
} }
} }

View File

@@ -504,7 +504,6 @@ class NotesCtrl extends PureCtrl {
async createNewNote() { async createNewNote() {
const selectedTag = this.appState.getSelectedTag(); const selectedTag = this.appState.getSelectedTag();
if (!selectedTag) { if (!selectedTag) {
debugger;
throw 'Attempting to create note with no selected tag'; throw 'Attempting to create note with no selected tag';
} }
if (this.state.selectedNote && this.state.selectedNote.dummy) { if (this.state.selectedNote && this.state.selectedNote.dummy) {
@@ -516,7 +515,8 @@ class NotesCtrl extends PureCtrl {
content: { content: {
text: '', text: '',
title: title title: title
} },
add: true
}); });
newNote.client_updated_at = new Date(); newNote.client_updated_at = new Date();
newNote.dummy = true; newNote.dummy = true;

View File

@@ -5,12 +5,12 @@ class ActionsMenuCtrl extends PureCtrl {
/* @ngInject */ /* @ngInject */
constructor( constructor(
$timeout, $timeout,
actionsManager, application,
godService godService
) { ) {
super($timeout); super($timeout);
this.$timeout = $timeout; this.$timeout = $timeout;
this.actionsManager = actionsManager; this.application = application;
this.godService = godService; this.godService = godService;
} }
@@ -22,12 +22,12 @@ class ActionsMenuCtrl extends PureCtrl {
}; };
async loadExtensions() { async loadExtensions() {
const extensions = this.actionsManager.extensions.sort((a, b) => { const extensions = this.application.actionsManager.getExtensions().sort((a, b) => {
return a.name.toLowerCase() < b.name.toLowerCase() ? -1 : 1; return a.name.toLowerCase() < b.name.toLowerCase() ? -1 : 1;
}); });
for (const extension of extensions) { for (const extension of extensions) {
extension.loading = true; extension.loading = true;
await this.actionsManager.loadExtensionInContextOfItem(extension, this.props.item); await this.application.actionsManager.loadExtensionInContextOfItem(extension, this.props.item);
extension.loading = false; extension.loading = false;
} }
this.setState({ this.setState({
@@ -45,7 +45,7 @@ class ActionsMenuCtrl extends PureCtrl {
return; return;
} }
action.running = true; action.running = true;
const result = await this.actionsManager.executeAction( const result = await this.application.actionsManager.executeAction(
action, action,
extension, extension,
this.props.item this.props.item
@@ -55,7 +55,7 @@ class ActionsMenuCtrl extends PureCtrl {
} }
action.running = false; action.running = false;
this.handleActionResult(action, result); this.handleActionResult(action, result);
await this.actionsManager.loadExtensionInContextOfItem(extension, this.props.item); await this.application.actionsManager.loadExtensionInContextOfItem(extension, this.props.item);
this.setState({ this.setState({
extensions: this.state.extensions extensions: this.state.extensions
}); });

View File

@@ -56,7 +56,7 @@ class ComponentViewCtrl {
identifier: this.themeHandlerIdentifier, identifier: this.themeHandlerIdentifier,
areas: ['themes'], areas: ['themes'],
activationHandler: (component) => { activationHandler: (component) => {
this.reloadThemeStatus();
} }
}); });
@@ -130,7 +130,7 @@ class ComponentViewCtrl {
if(this.expired && doManualReload) { if(this.expired && doManualReload) {
this.$rootScope.$broadcast('reload-ext-dat'); this.$rootScope.$broadcast('reload-ext-dat');
} }
this.reloadThemeStatus();
this.$timeout(() => { this.$timeout(() => {
this.reloading = false; this.reloading = false;
}, 500); }, 500);
@@ -215,27 +215,8 @@ class ComponentViewCtrl {
} }
} }
reloadThemeStatus() {
if(this.component.acceptsThemes()) {
return;
}
if(this.themeManager.hasActiveTheme()) {
if(!this.dismissedNoThemesMessage) {
this.showNoThemesMessage = true;
}
} else {
this.showNoThemesMessage = false;
}
}
dismissNoThemesMessage() {
this.showNoThemesMessage = false;
this.dismissedNoThemesMessage = true;
}
disableActiveTheme() { disableActiveTheme() {
this.themeManager.deactivateAllThemes(); this.themeManager.deactivateAllThemes();
this.dismissNoThemesMessage();
} }
getUrl() { getUrl() {

View File

@@ -7,16 +7,6 @@
.sk-app-bar-item(ng-click='ctrl.reloadComponent()') .sk-app-bar-item(ng-click='ctrl.reloadComponent()')
.sk-button.info .sk-button.info
.sk-label Reload .sk-label Reload
.sn-component(ng-if='ctrl.showNoThemesMessage')
.sk-app-bar.no-edges.no-top-edge.dynamic-height
.left
.sk-app-bar-item
.sk-label.warning This extension does not support themes.
.right
.sk-app-bar-item(ng-click='ctrl.dismissNoThemesMessage()')
.sk-label Dismiss
.sk-app-bar-item(ng-click='ctrl.disableActiveTheme()')
.sk-label Disable Active Theme
.sn-component(ng-if='ctrl.expired') .sn-component(ng-if='ctrl.expired')
.sk-app-bar.no-edges.no-top-edge.dynamic-height .sk-app-bar.no-edges.no-top-edge.dynamic-height
.left .left

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long