This commit is contained in:
Mo Bitar
2018-01-25 13:16:22 -06:00
parent 8f8c22daa9
commit 7a68f64116
10 changed files with 47 additions and 54 deletions

View File

@@ -21,7 +21,7 @@ class ComponentModal {
$scope.dismiss = function(callback) { $scope.dismiss = function(callback) {
$scope.el.remove(); $scope.el.remove();
$scope.$destroy(); $scope.$destroy();
$scope.onDismiss && $scope.onDismiss()($scope.component); $scope.onDismiss && $scope.onDismiss() && $scope.onDismiss()($scope.component);
callback && callback(); callback && callback();
} }
} }

View File

@@ -17,7 +17,7 @@ class ComponentView {
$scope.identifier = "component-view-" + Math.random(); $scope.identifier = "component-view-" + Math.random();
console.log("Registering handler", $scope.identifier, $scope.component.name); // console.log("Registering handler", $scope.identifier, $scope.component.name);
this.componentManager.registerHandler({identifier: $scope.identifier, areas: [$scope.component.area], activationHandler: (component) => { this.componentManager.registerHandler({identifier: $scope.identifier, areas: [$scope.component.area], activationHandler: (component) => {
if(component.active) { if(component.active) {
@@ -86,7 +86,7 @@ class ComponentView {
} }
$scope.$on("$destroy", function() { $scope.$on("$destroy", function() {
console.log("Deregistering handler", $scope.identifier, $scope.component.name); // console.log("Deregistering handler", $scope.identifier, $scope.component.name);
componentManager.deregisterHandler($scope.identifier); componentManager.deregisterHandler($scope.identifier);
if($scope.component && !$scope.manualDealloc) { if($scope.component && !$scope.manualDealloc) {
componentManager.deactivateComponent($scope.component); componentManager.deactivateComponent($scope.component);

View File

@@ -278,6 +278,8 @@ class ComponentManager {
this.handleToggleComponentMessage(component, componentToToggle, message); this.handleToggleComponentMessage(component, componentToToggle, message);
} else if(message.action === "request-permissions") { } else if(message.action === "request-permissions") {
this.handleRequestPermissionsMessage(component, message); this.handleRequestPermissionsMessage(component, message);
} else if(message.action === "install-local-component") {
this.handleInstallLocalComponentMessage(component, message);
} }
// Notify observers // Notify observers
@@ -516,6 +518,16 @@ class ComponentManager {
} }
} }
handleInstallLocalComponentMessage(sourceComponent, message) {
// Only extensions manager has this permission
if(!this.sysExtManager.isSystemExtension(sourceComponent)) {
return;
}
let targetComponent = this.modelManager.findItem(message.data.uuid);
this.desktopManager.installComponent(targetComponent);
}
runWithPermissions(component, requiredPermissions, runFunction) { runWithPermissions(component, requiredPermissions, runFunction) {
if(!component.permissions) { if(!component.permissions) {
@@ -625,28 +637,10 @@ class ComponentManager {
openModalComponent(component) { openModalComponent(component) {
var scope = this.$rootScope.$new(true); var scope = this.$rootScope.$new(true);
scope.component = component; scope.component = component;
scope.onDismiss = () => {
}
var el = this.$compile( "<component-modal component='component' class='modal'></component-modal>" )(scope); var el = this.$compile( "<component-modal component='component' class='modal'></component-modal>" )(scope);
angular.element(document.body).append(el); angular.element(document.body).append(el);
} }
installComponent(url) {
var name = getParameterByName("name", url);
var area = getParameterByName("area", url);
var component = this.modelManager.createItem({
content_type: "SN|Component",
url: url,
name: name,
area: area
})
this.modelManager.addItem(component);
component.setDirty(true);
this.syncManager.sync("installComponent");
}
activateComponent(component) { activateComponent(component) {
var didChange = component.active != true; var didChange = component.active != true;

View File

@@ -37,7 +37,6 @@ class DesktopManager {
// All `components` should be installed // All `components` should be installed
syncComponentsInstallation(components) { syncComponentsInstallation(components) {
// console.log("Web Syncing Components", components);
if(!this.isDesktop) return; if(!this.isDesktop) return;
var data = components.map((component) => { var data = components.map((component) => {
@@ -46,18 +45,22 @@ class DesktopManager {
this.installationSyncHandler(data); this.installationSyncHandler(data);
} }
desktop_onComponentInstallationComplete(componentData) { installComponent(component) {
console.log("Web|Component Installation Complete", componentData); this.installComponentHandler(this.convertComponentForTransmission(component));
var component = this.modelManager.mapResponseItemsToLocalModels([componentData], ModelManager.MappingSourceDesktopInstalled)[0];
component.setDirty(true);
this.syncManager.sync("desktop_onComponentInstallationComplete");
} }
desktop_updateComponentComplete(componentData) { desktop_onComponentInstallationComplete(componentData, error) {
console.log("Web|Component Update Complete", componentData); console.log("Web|Component Installation/Update Complete", componentData, error);
var component = this.modelManager.mapResponseItemsToLocalModels([componentData], ModelManager.MappingSourceDesktopInstalled)[0]; var component = this.modelManager.findItem(componentData.uuid);
if(error) {
component = this.modelManager.findItem(componentData.uuid);
component.setAppDataItem("installError", error);
} else {
component = this.modelManager.mapResponseItemsToLocalModels([componentData], ModelManager.MappingSourceDesktopInstalled)[0];
component.setAppDataItem("installError", null);
}
component.setDirty(true); component.setDirty(true);
this.syncManager.sync("desktop_updateComponentComplete"); this.syncManager.sync("onComponentInstallationComplete");
} }
/* Used to resolve "sn://" */ /* Used to resolve "sn://" */
@@ -69,8 +72,8 @@ class DesktopManager {
this.installationSyncHandler = handler; this.installationSyncHandler = handler;
} }
desktop_setOfflineComponentInstallationHandler(handler) { desktop_setInstallComponentHandler(handler) {
this.componentInstallationHandler = handler; this.installComponentHandler = handler;
} }
desktop_setInitialDataLoadHandler(handler) { desktop_setInitialDataLoadHandler(handler) {

View File

@@ -160,18 +160,20 @@ $footer-height: 32px;
} }
> .add-button { > .add-button {
$button-bg: #e9e9e9;
color: lighten($main-text-color, 40%);
font-size: 18px; font-size: 18px;
width: 45px; width: 45px;
height: 24px; height: 24px;
cursor: pointer; cursor: pointer;
background-color: #e9e9e9; background-color: $button-bg;
border-radius: 4px; border-radius: 4px;
font-weight: normal; font-weight: normal;
text-align: center; text-align: center;
&:hover { &:hover {
background-color: rgba(#e9e9e9, 0.8); background-color: darken($button-bg, 5%);
color: lighten($main-text-color, 40%);
} }
} }
} }

View File

@@ -9,11 +9,8 @@
"circle" => "selectedEditor === editor && 'success'", "circle" => "selectedEditor === editor && 'success'",
"has-button" => "selectedEditor == editor || defaultEditor == editor", "button-text" => "defaultEditor == editor ? 'Undefault' : 'Set Default'", "has-button" => "selectedEditor == editor || defaultEditor == editor", "button-text" => "defaultEditor == editor ? 'Undefault' : 'Set Default'",
"button-action" => "toggleDefaultForEditor(editor)", "button-class" => "defaultEditor == editor ? 'warning' : 'info'"} "button-action" => "toggleDefaultForEditor(editor)", "button-class" => "defaultEditor == editor ? 'warning' : 'info'"}
.row{"ng-if" => "component.conflict_of || offlineAvailableForComponent(editor)"} .column{"ng-if" => "component.conflict_of"}
.column %strong.red.medium{"ng-if" => "editor.conflict_of"} Conflicted copy
%strong.red.medium{"ng-if" => "editor.conflict_of"} Conflicted copy
.sublabel{"ng-if" => "offlineAvailableForComponent(editor)"}
Available Offline
%a.no-decoration{"ng-if" => "editors.length == 0", "href" => "https://standardnotes.org/extensions", "target" => "blank"} %a.no-decoration{"ng-if" => "editors.length == 0", "href" => "https://standardnotes.org/extensions", "target" => "blank"}
%menu-row{"title" => "'Download More Editors'"} %menu-row{"title" => "'Download More Editors'"}
@@ -22,8 +19,5 @@
%h4.title Editor Stack %h4.title Editor Stack
%menu-row{"ng-repeat" => "component in stack", "ng-click" => "selectComponent($event, component)", "title" => "component.name", %menu-row{"ng-repeat" => "component in stack", "ng-click" => "selectComponent($event, component)", "title" => "component.name",
"circle" => "component.active ? 'success' : 'danger'"} "circle" => "component.active ? 'success' : 'danger'"}
.row{"ng-if" => "component.conflict_of || offlineAvailableForComponent(component)"} .column{"ng-if" => "component.conflict_of"}
.column %strong.red.medium{"ng-if" => "component.conflict_of"} Conflicted copy
%strong.red.medium{"ng-if" => "component.conflict_of"} Conflicted copy
.sublabel{"ng-if" => "offlineAvailableForComponent(component)"}
Available Offline

View File

@@ -22,13 +22,13 @@
.section .section
.header .header
%h4.title Note Options %h4.title Note Options
%menu-row{"title" => "ctrl.note.pinned ? 'Unpin' : 'Pin'", "ng-click" => "ctrl.selectedMenuItem($event); ctrl.togglePin()"} %menu-row{"title" => "ctrl.note.pinned ? 'Unpin' : 'Pin'", "ng-click" => "ctrl.selectedMenuItem($event, true); ctrl.togglePin()"}
%menu-row{"title" => "ctrl.note.archived ? 'Unarchive' : 'Archive'", "ng-click" => "ctrl.selectedMenuItem($event); ctrl.toggleArchiveNote()"} %menu-row{"title" => "ctrl.note.archived ? 'Unarchive' : 'Archive'", "ng-click" => "ctrl.selectedMenuItem($event, true); ctrl.toggleArchiveNote()"}
%menu-row{"title" => "'Delete'", "ng-click" => "ctrl.selectedMenuItem($event); ctrl.deleteNote()"} %menu-row{"title" => "'Delete'", "ng-click" => "ctrl.selectedMenuItem($event); ctrl.deleteNote()"}
.section{"ng-if" => "!ctrl.selectedEditor"} .section{"ng-if" => "!ctrl.selectedEditor"}
.header .header
%h4.title Display %h4.title Global Display
%menu-row{"title" => "'Monospace Font'", "circle" => "ctrl.monospaceFont ? 'success' : 'default'", "ng-click" => "ctrl.selectedMenuItem($event, true); ctrl.toggleKey('monospaceFont')"} %menu-row{"title" => "'Monospace Font'", "circle" => "ctrl.monospaceFont ? 'success' : 'default'", "ng-click" => "ctrl.selectedMenuItem($event, true); ctrl.toggleKey('monospaceFont')"}
%menu-row{"title" => "'Spellcheck'", "circle" => "ctrl.spellcheck ? 'success' : 'default'", "ng-click" => "ctrl.selectedMenuItem($event, true); ctrl.toggleKey('spellcheck')"} %menu-row{"title" => "'Spellcheck'", "circle" => "ctrl.spellcheck ? 'success' : 'default'", "ng-click" => "ctrl.selectedMenuItem($event, true); ctrl.toggleKey('spellcheck')"}

View File

@@ -9,7 +9,7 @@
%account-menu{"ng-click" => "$event.stopPropagation()", "ng-if" => "ctrl.showAccountMenu", "on-successful-auth" => "ctrl.onAuthSuccess", "close-function" => "ctrl.closeAccountMenu"} %account-menu{"ng-click" => "$event.stopPropagation()", "ng-if" => "ctrl.showAccountMenu", "on-successful-auth" => "ctrl.onAuthSuccess", "close-function" => "ctrl.closeAccountMenu"}
.item .item
.label.title{"href" => "https://standardnotes.org/help", "target" => "_blank"} %a.no-decoration.label.title{"href" => "https://standardnotes.org/help", "target" => "_blank"}
Help Help
.item.border .item.border

6
package-lock.json generated
View File

@@ -5781,9 +5781,9 @@
"dev": true "dev": true
}, },
"sn-stylekit": { "sn-stylekit": {
"version": "1.0.1192", "version": "1.0.1195",
"resolved": "https://registry.npmjs.org/sn-stylekit/-/sn-stylekit-1.0.1192.tgz", "resolved": "https://registry.npmjs.org/sn-stylekit/-/sn-stylekit-1.0.1195.tgz",
"integrity": "sha512-qvR1rPI1FeG+Us2+P+0XZ0kndd5D9gg93Xla8aqopNbJ3xB2vh3OXvl/3XRSL4xKNrG+4Ub7u5Xg/J5NPPNRoA==", "integrity": "sha512-XPutiDkA0Jbf3fGHjC6avoWbMsLJKLOXnPJDpE2VFA2/HUf87sjyTvvhg8mrRT2IiE8Cr0gJFQr/ALnoP+u1EQ==",
"dev": true "dev": true
}, },
"snake-case": { "snake-case": {

View File

@@ -33,7 +33,7 @@
"karma-cli": "^1.0.1", "karma-cli": "^1.0.1",
"karma-jasmine": "^1.1.0", "karma-jasmine": "^1.1.0",
"karma-phantomjs-launcher": "^1.0.2", "karma-phantomjs-launcher": "^1.0.2",
"sn-stylekit": "^1.0.1192" "sn-stylekit": "^1.0.1195"
}, },
"license": "GPL-3.0" "license": "GPL-3.0"
} }