Skip to content

Commit 07fa60f

Browse files
Merge pull request #326 from davidwatkins73/waltz-323-stat-bookmarks
Waltz 323 stat bookmarks
2 parents 2fc1f16 + 657642f commit 07fa60f

4 files changed

Lines changed: 48 additions & 33 deletions

File tree

waltz-ng/client/bookmarks/bookmark-editor.js

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,14 @@ import angular from "angular";
1515
import {kindToViewState} from "../common";
1616

1717

18-
function getParentRef(params) {
19-
return {
20-
id: params.entityId,
21-
kind: params.kind,
22-
name: params.parentName
23-
};
24-
}
25-
26-
27-
function controller(bookmarkStore, notification, params, $state) {
18+
function controller($state,
19+
$stateParams,
20+
$window,
21+
bookmarkStore,
22+
notification) {
2823
const vm = this;
2924

30-
const parentRef = getParentRef(params);
25+
const parentRef = getParentRef($stateParams);
3126

3227
vm.save = (b) => {
3328
b.parent = parentRef;
@@ -79,19 +74,31 @@ function controller(bookmarkStore, notification, params, $state) {
7974
vm.parentRef = parentRef;
8075

8176
vm.goToParent = () => {
82-
const nextState = kindToViewState(parentRef.kind);
83-
$state.go(nextState, parentRef);
84-
}
85-
77+
try {
78+
const nextState = kindToViewState(parentRef.kind);
79+
$state.go(nextState, parentRef);
80+
} catch (e) {
81+
$window.history.back();
82+
}
83+
};
8684
}
8785

8886

87+
function getParentRef(params) {
88+
return {
89+
id: params.entityId,
90+
kind: params.kind,
91+
name: params.parentName
92+
};
93+
}
94+
8995

9096
controller.$inject = [
91-
'BookmarkStore',
92-
'Notification',
97+
'$state',
9398
'$stateParams',
94-
'$state'
99+
'$window',
100+
'BookmarkStore',
101+
'Notification'
95102
];
96103

97104

waltz-ng/client/common/services/display_names.js

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,3 @@
1-
2-
/*
3-
* Waltz
4-
* Copyright (c) David Watkins. All rights reserved.
5-
* The use and distribution terms for this software are covered by the
6-
* Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
7-
* which can be found in the file epl-v10.html at the root of this distribution.
8-
* By using this software in any fashion, you are agreeing to be bound by
9-
* the terms of this license.
10-
* You must not remove this notice, or any other, from this software.
11-
*
12-
*/
13-
14-
151
export const applicationKindDisplayNames = {
162
IN_HOUSE: 'In House',
173
INTERNALLY_HOSTED: 'Hosted Internally',
@@ -107,6 +93,7 @@ export const entityNames = {
10793
CHANGE_INITIATIVE: 'Change Initiative',
10894
DATABASE: 'Database',
10995
END_USER_APPLICATION: 'End User App',
96+
ENTITY_STATISTIC: 'Statistic',
11097
INVOLVEMENT: 'Involvement',
11198
LOGICAL_DATA_FLOW: "Logical Data Flow",
11299
ORG_UNIT: 'Org Unit',

waltz-ng/client/entity-statistics/entity-statistic-view.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,15 @@ <h3>Related Indicators</h3>
6767

6868
</div>
6969

70+
71+
<br>
72+
73+
<!-- BOOKMARKS -->
74+
<waltz-bookmarks-section bookmarks="ctrl.bookmarks"
75+
entity-id="{{ ctrl.statistic.definition.id }}"
76+
kind="ENTITY_STATISTIC"
77+
parent-name="{{ ctrl.statistic.definition.name }}"
78+
source-data-ratings="ctrl.sourceDataRatings">
79+
</waltz-bookmarks-section>
80+
7081
</div>

waltz-ng/client/entity-statistics/entity-statistic-view.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ function hasRelatedDefinitions(defs) {
3737
function controller($q,
3838
$state,
3939
$stateParams,
40+
bookmarkStore,
4041
entityStatisticUtilities,
4142
entityStatisticStore) {
4243

@@ -45,6 +46,14 @@ function controller($q,
4546
const entityKind = $stateParams.kind;
4647
const entityId = $stateParams.id;
4748

49+
const statRef = {
50+
id: statId,
51+
kind: 'ENTITY_STATISTIC'
52+
};
53+
54+
bookmarkStore
55+
.findByParent(statRef)
56+
.then(bs => vm.bookmarks = bs);
4857

4958
const definitionPromise = entityStatisticStore
5059
.findRelatedStatDefinitions(statId)
@@ -90,14 +99,15 @@ function controller($q,
9099
const stateName = kindToViewState(entityKind);
91100
const navId = vm.selectedNavItem.id;
92101
$state.go(stateName, { id: navId });
93-
}
102+
};
94103
}
95104

96105

97106
controller.$inject = [
98107
'$q',
99108
'$state',
100109
'$stateParams',
110+
'BookmarkStore',
101111
'EntityStatisticUtilities',
102112
'EntityStatisticStore'
103113
];

0 commit comments

Comments
 (0)