Skip to content

Commit

Permalink
Merge pull request #6 from chialin/edit
Browse files Browse the repository at this point in the history
add edit folder content
  • Loading branch information
yurenju committed Jul 16, 2015
2 parents c8245b7 + 338bac7 commit daf634f
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
6 changes: 3 additions & 3 deletions app/dialog-instance-controller.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use strict';

module.exports = function($scope, $modalInstance) {
$scope.title = '';
$scope.url = '';
module.exports = function($scope, $modalInstance, data) {
$scope.title = data.title || '';
$scope.url = data.url || '';

$scope.ok = function () {
$modalInstance.close({title: $scope.title, url: $scope.url});
Expand Down
3 changes: 3 additions & 0 deletions app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ <h1>{{title}}</h1>
<a class="pull-right btn btn-danger btn-xs" data-nodrag ng-click="removeItem(this)">
<span class="glyphicon glyphicon-remove"></span>
</a>
<a class="pull-right btn btn-info btn-xs" data-nodrag ng-click="edit(this)">
<span class="glyphicon glyphicon-edit"></span>
</a>
<a class="pull-right btn btn-primary btn-xs" data-nodrag ng-if="item.first" ng-click="open($index)" style="margin-right: 8px;">
<span class="glyphicon glyphicon-plus"></span>
</a>
Expand Down
27 changes: 25 additions & 2 deletions app/main-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,12 @@ module.exports = function($http, $scope, $modal) {
var modalInstance = $modal.open({
animation: true,
templateUrl: 'dialogContent.html',
controller: 'DialogInstanceController'
controller: 'DialogInstanceController',
resolve: {
data: function () {
return {title: '', url: ''};
}
}
});

modalInstance.result.then(function (data) {
Expand All @@ -101,7 +106,25 @@ module.exports = function($http, $scope, $modal) {
var nodeData = $scope.list[pos];
nodeData.items.push(current);
}
$scope.$broadcast('success', 'Add a new folder. Please press "Save" button to save change!');
});
};

$scope.edit = function(scope) {
var editContent = scope.$modelValue;
var modalInstance = $modal.open({
animation: true,
templateUrl: 'dialogContent.html',
controller: 'DialogInstanceController',
resolve: {
data: function () {
return {title: editContent.title, url: editContent.url};
}
}
});

modalInstance.result.then(function (data) {
scope.$modelValue.title = data.title || 'New folder';
scope.$modelValue.url = data.url || '';
});
};
};

0 comments on commit daf634f

Please sign in to comment.