modify settings only when saving

This commit is contained in:
Athou
2013-04-04 13:13:08 +02:00
parent 62bc54fcb7
commit 92bc5a7586
2 changed files with 27 additions and 21 deletions

View File

@@ -346,6 +346,9 @@ module.controller('ManageUserCtrl', function($scope, $state, $stateParams,
module.controller('SettingsCtrl', function($scope, $location, SettingsService) { module.controller('SettingsCtrl', function($scope, $location, SettingsService) {
$scope.settingsService = SettingsService; $scope.settingsService = SettingsService;
$scope.$watch('settingsService.settings', function(value) {
$scope.settings = angular.copy(value);
});
$scope.codeMirrorConfig = { $scope.codeMirrorConfig = {
mode : 'css', mode : 'css',
lineNumbers : true lineNumbers : true
@@ -356,8 +359,9 @@ module.controller('SettingsCtrl', function($scope, $location, SettingsService) {
}); });
}; };
$scope.save = function() { $scope.save = function() {
SettingsService.settings = $scope.settings;
SettingsService.save(function() { SettingsService.save(function() {
$location.path('/'); window.location.href = window.location.href.substring(0, window.location.href.lastIndexOf('#'));
}); });
}; };
}); });

View File

@@ -2,6 +2,7 @@
<div class="page-header"> <div class="page-header">
<h1>Settings</h1> <h1>Settings</h1>
</div> </div>
<form name="settingsForm" ng-submit="save()">
<div class="row"> <div class="row">
<div class="span2"> <div class="span2">
<ul class="nav nav-pills nav-stacked"> <ul class="nav nav-pills nav-stacked">
@@ -15,14 +16,15 @@
Placeholder for general settings Placeholder for general settings
</div> </div>
<div class="tab-pane" id="custom-css"> <div class="tab-pane" id="custom-css">
<textarea ui-codemirror="codeMirrorConfig" ng-model="settingsService.settings.customCss" ui-refresh="refreshCodemirror"> <textarea ui-codemirror="codeMirrorConfig" ng-model="settings.customCss" ui-refresh="refreshCodemirror">
</textarea> </textarea>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div class="form-actions"> <div class="form-actions">
<button type="button" class="btn btn-primary" ng-click="save()">Save</button> <button type="submit" class="btn btn-primary">Save</button>
<button type="button" class="btn" ng-click="cancel()">Cancel</button> <button type="button" class="btn" ng-click="cancel()">Cancel</button>
</div> </div>
</form>
</div> </div>