Skip to content

Commit

Permalink
#123 Save now works - yay!
Browse files Browse the repository at this point in the history
  • Loading branch information
jstrachan committed May 23, 2013
1 parent d48ac0c commit 2380731
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 3 deletions.
4 changes: 2 additions & 2 deletions hawtio-web/src/main/webapp/app/wiki/html/camelCanvas.html
Expand Up @@ -71,9 +71,9 @@
}
</style>

<ng-include src="'app/wiki/html/camelNavBar.html'"></ng-include>

<div ng-controller="Wiki.CamelCanvasController">
<ng-include src="'app/wiki/html/camelNavBar.html'"></ng-include>

<div class="row-fluid">
<div class="span12">
<ul class="nav nav-tabs">
Expand Down
40 changes: 39 additions & 1 deletion hawtio-web/src/main/webapp/app/wiki/js/camelCanvas.ts
@@ -1,5 +1,5 @@
module Wiki {
export function CamelCanvasController($scope, $element, workspace:Workspace, jolokia) {
export function CamelCanvasController($scope, $element, workspace:Workspace, jolokia, wikiRepository:GitWikiRepository) {
$scope.selectedFolder = null;
$scope.addDialog = new Core.Dialog();
$scope.propertiesDialog = new Core.Dialog();
Expand Down Expand Up @@ -65,9 +65,46 @@ module Wiki {
treeModified();
};

$scope.save = () => {
// generate the new XML
if ($scope.rootFolder) {
var xmlNode = Camel.generateXmlFromFolder($scope.rootFolder);
if (xmlNode) {
var text = Core.xmlNodeToString(xmlNode);
if (text) {
// lets save the file...
var commitMessage = $scope.commitMessage || "Updated page " + $scope.pageId;
wikiRepository.putPage($scope.branch, $scope.pageId, text, commitMessage, (status) => {
Wiki.onComplete(status);
goToView();
Core.$apply($scope);
});
}
}
};

$scope.cancel = () => {
console.log("cancelling...");
// TODO show dialog if folks are about to lose changes...
};

$scope.$watch("selectedRouteId", onRouteSelectionChanged);


function goToView() {
// TODO lets navigate to the view if we have a separate view one day :)
/*
if ($scope.breadcrumbs && $scope.breadcrumbs.length > 1) {
var viewLink = $scope.breadcrumbs[$scope.breadcrumbs.length - 2];
console.log("goToView has found view " + viewLink);
var path = Core.trimLeading(viewLink, "#");
$location.path(path);
} else {
console.log("goToView has no breadcrumbs!");
}
*/
}

function addNewNode(nodeModel) {
var parentFolder = $scope.selectedFolder || $scope.rootFolder;
var key = nodeModel["_id"];
Expand Down Expand Up @@ -338,6 +375,7 @@ module Wiki {
$scope.propertiesTemplate = "app/wiki/html/camelPropertiesEdit.html";
}
}

}

function getWidth() {
Expand Down

0 comments on commit 2380731

Please sign in to comment.