Improve edit repo

(cherry picked from commit 37ba504aaf5fb3500cbfe1634b0722ea9107c72d)
This commit is contained in:
Damien CORNEAU 2016-10-16 16:41:11 +09:00 committed by Anthony Corbacho
parent 9c1f99906c
commit 05a64de218
2 changed files with 20 additions and 3 deletions

View file

@ -28,11 +28,27 @@
// Public functions
function saveNotebookRepo(repo, data) {
return $http.post(baseUrlSrv.getRestApiBase() + '/notebook-repositories', {
function saveNotebookRepo(valueform, repo, data) {
console.log('data %o', data);
$http.put(baseUrlSrv.getRestApiBase() + '/notebook-repositories', {
'name': repo.className,
'settings': data
}).success(function(data) {
var index = _.findIndex(vm.notebookRepos, {'className': repo.className});
if (index >= 0) {
vm.notebookRepos[index] = data.body;
console.log('repos %o, data %o', vm.notebookRepos, data.body);
}
valueform.$show();
}).error(function() {
ngToast.danger({
content: 'We couldn\'t save that NotebookRepo\'s settings',
verticalPosition: 'bottom',
timeout: '3000'
});
});
return false;
}
function showDropdownSelected(setting) {
@ -50,6 +66,7 @@
$http.get(baseUrlSrv.getRestApiBase() + '/notebook-repositories')
.success(function(data, status, headers, config) {
vm.notebookRepos = data.body;
console.log('ya notebookRepos %o', vm.notebookRepos);
}).error(function(data, status, headers, config) {
if (status === 401) {
ngToast.danger({

View file

@ -77,7 +77,7 @@ limitations under the License.
</div>
<span style="float:right" ng-show="valueform.$visible">
<form editable-form name="valueform"
onbeforesave="noterepo.saveNotebookRepo(repo, $data)"
onbeforesave="noterepo.saveNotebookRepo(valueform, repo, $data)"
ng-show="valueform.$visible">
<button type="submit" class="btn btn-primary btn-xs">
<span class="fa fa-check"></span> Save