Skip to content

Commit

Permalink
viewing the message detail view now selects the current item so we ca…
Browse files Browse the repository at this point in the history
…n move/delete it from the detail view; also after move/delete we switch back to the table view as the selection usually disappears
  • Loading branch information
jstrachan committed May 1, 2013
1 parent 93f9e82 commit ab96ff1
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 14 deletions.
Expand Up @@ -37,7 +37,7 @@ <h4>{{row.JMSMessageID}}</h4>
</div>
<div class="pull-right">
<form class="form-horizontal no-bottom-margin">
<div class="btn-group" hawtio-pager="messages" row="row" row-index="rowIndex"></div>
<div class="btn-group" hawtio-pager="messages" on-index-change="selectRowIndex" row-index="rowIndex"></div>
<button class="btn" ng-click="messageDialog.close()" title="Closes the message detail view">
<i class="icon-eject"></i></button>
</form>
Expand Down
19 changes: 17 additions & 2 deletions hawtio-web/src/main/webapp/app/activemq/js/browse.ts
Expand Up @@ -80,13 +80,27 @@ module ActiveMQ {
});

$scope.openMessageDialog = (message) => {
$scope.rowIndex = Core.pathGet(message, ["rowIndex"]);
$scope.row = Core.pathGet(message, ["entity"]);
var idx = Core.pathGet(message, ["rowIndex"]);
$scope.selectRowIndex(idx);
if ($scope.row) {
$scope.messageDialog.open();
}
};

$scope.selectRowIndex = (idx) => {
$scope.rowIndex = idx;
var selected = $scope.gridOptions.selectedItems;
selected.splice(0, selected.length);
if (idx >= 0 && idx < $scope.messages.length) {
$scope.row = $scope.messages[idx];
if ($scope.row) {
selected.push($scope.row);
}
} else {
$scope.row = null;
}
};

$scope.moveMessages = () => {
var selection = workspace.selection;
var mbean = selection.objectName;
Expand Down Expand Up @@ -178,6 +192,7 @@ module ActiveMQ {
}

function deleteSuccess() {
$scope.messageDialog.close();
notification("success", $scope.message);
setTimeout(loadTable, 50);
}
Expand Down
19 changes: 8 additions & 11 deletions hawtio-web/src/main/webapp/app/forms/js/tablePager.ts
Expand Up @@ -12,7 +12,7 @@ module Forms {
public element = null;
public attrs = null;
public tableName:string = null;
public rowName:string = null;
public setRowIndexName:string = null;
public rowIndexName:string = null;

constructor() {
Expand All @@ -27,7 +27,7 @@ module Forms {
this.element = element;
this.attrs = attrs;
this.tableName = attrs["hawtioPager"] || attrs["array"] || "data";
this.rowName = attrs["row"] || "row";
this.setRowIndexName = attrs["onIndexChange"] || "onIndexChange";
this.rowIndexName = attrs["rowIndex"] || "rowIndex";

scope.first = () => {
Expand Down Expand Up @@ -74,16 +74,13 @@ module Forms {
}

public goToIndex(idx:number) {
var data = this.tableData();
if (!data) {
console.log("No data for idx: " + idx);
} else if (idx >= 0 && idx < data.length) {
//console.log("Navigating to index: " + idx);
var scope = this.$scope.$parent;
scope[this.rowName] = data[idx];
scope[this.rowIndexName] = idx;
var name = this.setRowIndexName;
var fn = this.$scope[name];
if (angular.isFunction(fn)) {
fn(idx);
} else {
console.log("Ignoring idx out of range: " + idx);
console.log("No function defined in scope for " + name + " but was " + fn);
this.$scope[this.rowIndexName] = idx;
}
}
}
Expand Down

0 comments on commit ab96ff1

Please sign in to comment.