Menu buttons

This commit is contained in:
Mo Bitar
2018-01-05 21:33:53 -06:00
parent aabdb73c77
commit 2f6fe0e64e
6 changed files with 105 additions and 34 deletions

View File

@@ -9,7 +9,7 @@ class EditorMenu {
};
}
controller($scope, componentManager) {
controller($scope, componentManager, syncManager) {
'ngInject';
$scope.formData = {};
@@ -18,6 +18,8 @@ class EditorMenu {
$scope.isDesktop = isDesktopApplication();
$scope.defaultEditor = $scope.editors.filter((e) => {return e.isDefaultEditor()})[0];
$scope.selectEditor = function($event, editor) {
if(editor) {
editor.conflict_of = null; // clear conflict if applicable
@@ -29,8 +31,34 @@ class EditorMenu {
$scope.callback()(editor);
}
$scope.moreEditors = function() {
$scope.toggleDefaultForEditor = function(editor) {
console.log("Toggling editor", editor);
if($scope.defaultEditor == editor) {
$scope.removeEditorDefault(editor);
} else {
$scope.makeEditorDefault(editor);
}
}
$scope.makeEditorDefault = function(component) {
var currentDefault = componentManager.componentsForArea("editor-editor").filter((e) => {return e.isDefaultEditor()})[0];
if(currentDefault) {
currentDefault.setAppDataItem("defaultEditor", false);
currentDefault.setDirty(true);
}
component.setAppDataItem("defaultEditor", true);
component.setDirty(true);
syncManager.sync();
$scope.defaultEditor = component;
}
$scope.removeEditorDefault = function(component) {
component.setAppDataItem("defaultEditor", false);
component.setDirty(true);
syncManager.sync();
$scope.defaultEditor = null;
}
}

View File

@@ -133,22 +133,6 @@ class GlobalExtensionsMenu {
}
}
$scope.makeEditorDefault = function(component) {
var currentDefault = componentManager.componentsForArea("editor-editor").filter((e) => {return e.isDefaultEditor()})[0];
if(currentDefault) {
currentDefault.setAppDataItem("defaultEditor", false);
currentDefault.setDirty(true);
}
component.setAppDataItem("defaultEditor", true);
component.setDirty(true);
syncManager.sync();
}
$scope.removeEditorDefault = function(component) {
component.setAppDataItem("defaultEditor", false);
component.setDirty(true);
syncManager.sync();
}
// Installation

View File

@@ -7,13 +7,22 @@ class MenuRow {
this.scope = {
circle: "=",
title: "=",
subtite: "="
subtite: "=",
hasButton: "=",
buttonText: "=",
buttonClass: "=",
buttonAction: "&"
};
}
controller($scope, componentManager) {
'ngInject';
$scope.clickButton = function($event) {
$event.stopPropagation();
$scope.buttonAction();
}
}
}