Skip to content

Commit

Permalink
#445 partial fix for editting dozer files; need to keep track fo real…
Browse files Browse the repository at this point in the history
… changes in the entity bound to the forms though
  • Loading branch information
jstrachan committed Aug 1, 2013
1 parent 3ee31f9 commit 303c6da
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
Expand Up @@ -15,6 +15,7 @@
-->
<li class="pull-right">
<a href="" id="saveButton" ng-disabled="!isValid()" ng-click="save()"
ng-class="{'nav-primary' : modified}"
title="Saves the Mappings document">
<i class="icon-save"></i> Save</a>
</li>
Expand Down
30 changes: 30 additions & 0 deletions hawtio-web/src/main/webapp/app/wiki/js/dozerMappings.ts
Expand Up @@ -8,6 +8,7 @@ module Wiki {
$scope.propertiesDialog = new Core.Dialog();
$scope.deleteDialog = false;
$scope.unmappedFieldsHasValid = false;
$scope.modified = false;

$scope.selectedItems = [];
$scope.mappings = [];
Expand Down Expand Up @@ -52,6 +53,7 @@ module Wiki {
added.expand(true);
added.select(true);
added.activate(true);
onTreeModified();
}
}
};
Expand Down Expand Up @@ -87,6 +89,7 @@ module Wiki {
added.expand(true);
added.select(true);
added.activate(true);
onTreeModified();
}
} else {
console.log("No treenode and folder for mapping node! treeNode " + treeNode + " mappingFolder " + mappingFolder);
Expand Down Expand Up @@ -117,6 +120,7 @@ module Wiki {
$scope.treeNode.remove();
$scope.selectedFolder = null;
$scope.treeNode = null;
onTreeModified();
}
};

Expand All @@ -129,6 +133,7 @@ module Wiki {
var commitMessage = $scope.commitMessage || "Updated page " + $scope.pageId;
wikiRepository.putPage($scope.branch, $scope.pageId, text, commitMessage, (status) => {
Wiki.onComplete(status);
$scope.modified = false;
notification("success", "Saved " + $scope.pageId)
goToView();
Core.$apply($scope);
Expand All @@ -155,6 +160,13 @@ module Wiki {
$scope.selectedMapping = null;
$scope.selectedMappingTreeNode = null;
$scope.selectedMappingFolder = null;
// now the model is bound, lets add a listener
if ($scope.removeModelChangeListener) {
console.log("Removing old form listener: " + $scope.removeModelChangeListener())
$scope.removeModelChangeListener();
$scope.removeModelChangeListener = null;
}

if (folder) {
var entity = folder.entity;
$scope.dozerEntity = entity;
Expand All @@ -177,7 +189,20 @@ module Wiki {
$scope.selectedMappingFolder = folder;
$scope.selectedMappingTreeNode = treeNode;
}
if ($scope.selectedMapping && !$scope.removeModelChangeListener) {
/*
TODO problem is we have many forms here so we end up creating lots of change events when really we don't change things!: )
// maybe watch the entity instead?
console.log("Adding onTreeModified form listener");
$scope.removeModelChangeListener = $scope.$on("hawtio.form.modelChange", () => {
console.log("form modified!");
onTreeModified();
});
*/
}
}

Core.$apply($scope);
};

Expand Down Expand Up @@ -238,6 +263,11 @@ module Wiki {
Core.$applyLater($scope);
}

function onTreeModified() {
console.log("tree modified!");
$scope.modified = true;
}

function goToView() {
// TODO lets navigate to the view if we have a separate view one day :)
/*
Expand Down
2 changes: 2 additions & 0 deletions hawtio-web/src/main/webapp/app/wiki/js/edit.ts
Expand Up @@ -18,6 +18,7 @@ module Wiki {
}
};
$scope.codeMirrorOptions = CodeEditor.createEditorSettings(options);
$scope.modified = false;


$scope.isValid = () => $scope.fileName;
Expand Down Expand Up @@ -124,6 +125,7 @@ module Wiki {
//console.log("About to write contents '" + contents + "'");
wikiRepository.putPage($scope.branch, path, contents, commitMessage, (status) => {
Wiki.onComplete(status);
$scope.modified = false;
notification("success", "Saved " + path);
goToView();
Core.$apply($scope);
Expand Down

0 comments on commit 303c6da

Please sign in to comment.