Skip to content

Commit 3cc5bdf

Browse files
authored
Auto focus on element select + open sidebar on double element click (#462)
1 parent e09def9 commit 3cc5bdf

8 files changed

Lines changed: 46 additions & 11 deletions

File tree

app/angular/conceptual/conceptual.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,10 @@ const controller = function (ModelAPI, $stateParams, $rootScope, $timeout, $uibM
379379
elementActions.render();
380380
});
381381

382+
paper.on('element:pointerdblclick', () => {
383+
$rootScope.$broadcast("command:openmenu");
384+
});
385+
382386
configs.paper.on('link:mouseenter', (linkView) => {
383387
const conectionType = ctrl.shapeLinker.getConnectionTypeFromLink(linkView.model);
384388
const toolsView = ctrl.toolsViewService.getToolsView(conectionType);

app/angular/conceptual/sidebarControl.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<div class="form-group">
1818
<label for="entry-name">{{ 'Name' | translate }}</label>
1919
<input id="entry-name" type="text" class="form-control" data-ng-model="$ctrl.selectedElement.value"
20-
ng-change="$ctrl.updateName($ctrl.selectedElement.value)" />
20+
ng-change="$ctrl.updateName($ctrl.selectedElement.value)" autofocus/>
2121
</div><!-- End .form-group -->
2222

2323
<div class="form-group clearfix">
@@ -74,7 +74,7 @@
7474
<div class="form-group">
7575
<label for="entry-name">{{ 'Name' | translate }}</label>
7676
<input id="entry-name" type="text" class="form-control" data-ng-model="$ctrl.selectedElement.value.name"
77-
ng-change="$ctrl.updateAttributeName($ctrl.selectedElement.value.name)" />
77+
ng-change="$ctrl.updateAttributeName($ctrl.selectedElement.value.name)" autofocus/>
7878
</div>
7979
<div class="form-group clearfix">
8080
<label for="">{{ 'Cardinality' | translate }}</label>
@@ -98,14 +98,14 @@
9898
<div class="form-group" ng-if="($ctrl.configuration.key)">
9999
<label for="entry-name">{{ 'Name' | translate }}</label>
100100
<input id="entry-name" type="text" class="form-control" data-ng-model="$ctrl.selectedElement.value"
101-
ng-change="$ctrl.updateName($ctrl.selectedElement.value)" />
101+
ng-change="$ctrl.updateName($ctrl.selectedElement.value)" autofocus/>
102102
</div><!-- End .form-group -->
103103

104104
<div class="form-group" ng-if="($ctrl.configuration.relationship)">
105105
<div class="form-group">
106106
<label for="entry-name">{{ 'Name' | translate }}</label>
107107
<input id="entry-name" type="text" class="form-control" data-ng-model="$ctrl.selectedElement.value"
108-
ng-change="$ctrl.updateName($ctrl.selectedElement.value)" />
108+
ng-change="$ctrl.updateName($ctrl.selectedElement.value)" autofocus/>
109109
</div><!-- End .form-group -->
110110

111111
<div class="form-group">

app/angular/conceptual/sidebarControl.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,17 @@ const configurator = () => {
5252
}
5353

5454

55-
const controller = function () {
55+
const controller = function($rootScope, $timeout) {
5656
const $ctrl = this;
5757
$ctrl.visible = true;
5858
$ctrl.selectedElement = {}
5959

60+
$rootScope.$on('command:openmenu', () => {
61+
$timeout(() => {
62+
$ctrl.visible = true;
63+
});
64+
});
65+
6066
$ctrl.$onInit = () => {
6167
$ctrl.configuration = configurator().emptyState();
6268
}

app/angular/index.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import "../sass/app.scss";
1515
import "oclazyload";
1616

1717
import sidebarControlConceptual from "./conceptual/sidebarControl";
18+
import sidebarControlLogic from "./logic/sidebarControl";
1819
import authService from "./service/authService";
1920
import modelService from "./service/modelAPI";
2021
import dropdownComponent from "./components/dropdown";
@@ -44,6 +45,7 @@ const app = angular.module("app", [
4445
logicFactory,
4546
sidebarControlConceptual,
4647
dropdownIconComponent,
48+
sidebarControlLogic
4749
]);
4850

4951
app.config([
@@ -226,5 +228,17 @@ app.config(function () {
226228
};
227229
});
228230

231+
232+
app.directive('autofocus', function($timeout) {
233+
return {
234+
restrict: 'A',
235+
link: function(_scope, _element) {
236+
$timeout(function(){
237+
_element[0].focus();
238+
}, 100);
239+
}
240+
};
241+
});
242+
229243
app.$inject = ["$scope", "$http", "$cookies", "$uibModalInstance"];
230244

app/angular/logic/sidebarControl.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
</div><!-- End .form-group -->
1414
</div>
1515

16-
<div class="properties-content" ng-show="$ctrl.selectedElement != null && $ctrl.selectedType === 'uml.Class'">
16+
<div class="properties-content" ng-if="$ctrl.selectedElement != null && $ctrl.selectedType === 'uml.Class'">
1717
<section class="sidebar-panel">
1818
<header class="panel-header" ng-click="$ctrl.toggleSection('tableProperties')">
1919
<h3>{{ 'Table properties' | translate }}</h3>
@@ -29,6 +29,7 @@ <h3>{{ 'Table properties' | translate }}</h3>
2929
class="form-control"
3030
ng-model="$ctrl.selectedName"
3131
ng-change="$ctrl.changeName()"
32+
autofocus
3233
/>
3334
</div><!-- End .form-group -->
3435
</div>

app/angular/logic/sidebarControl.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ import angular from "angular";
22
import template from "./sidebarControl.html";
33
import Column from "../service/Column";
44

5-
const app = angular.module("app.sidebarControl", []);
6-
7-
const Controller = function (LogicService) {
5+
const Controller = function (LogicService, $rootScope, $timeout) {
86
const $ctrl = this;
97

108
$ctrl.visible = true;
@@ -16,6 +14,12 @@ const Controller = function (LogicService) {
1614
views: false,
1715
}
1816

17+
$rootScope.$on('command:openmenu', () => {
18+
$timeout(() => {
19+
$ctrl.visible = true;
20+
});
21+
});
22+
1923
$ctrl.toggleSection = (section) => {
2024
$ctrl.sections[section] = !$ctrl.sections[section];
2125
}
@@ -148,7 +152,8 @@ const Controller = function (LogicService) {
148152
}
149153
};
150154

151-
export default app.component("sidebarControlLogical", {
155+
export default angular.module("app.sidebarControl", [])
156+
.component("sidebarControlLogical", {
152157
template: template,
153158
bindings: {
154159
selected: "<",

app/angular/service/logicService.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ const logicService = ($rootScope, ModelAPI, LogicFactory, LogicConversorService)
8282

8383
});
8484

85+
ls.paper.on('element:pointerdblclick', () => {
86+
$rootScope.$broadcast("command:openmenu");
87+
});
88+
8589
ls.applyResizePage();
8690
ls.applyDragAndDrop();
8791
ls.applyComponentSelection();

app/angular/view/view.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
</button>
1010

1111
<div class="views" ng-show="$ctrl.formVisible || $ctrl.isEdit">
12-
12+
1313
<div class="form-group">
1414
<label for="view-name">{{ 'Name' | translate }}</label>
1515
<input
@@ -18,6 +18,7 @@
1818
class="form-control"
1919
ng-model="$ctrl.view.name"
2020
ng-change="$ctrl.changeName()"
21+
autofocus
2122
/>
2223
</div>
2324

0 commit comments

Comments
 (0)