Skip to content
This repository has been archived by the owner on Jan 7, 2020. It is now read-only.

Commit

Permalink
Merge pull request #39 from bryan-gilbert/master
Browse files Browse the repository at this point in the history
Refactor doc manager directive
  • Loading branch information
marklise authored Mar 22, 2017
2 parents 8129da6 + 35c8c6d commit 039e983
Show file tree
Hide file tree
Showing 7 changed files with 927 additions and 908 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
'use strict';
angular.module('documents')

.directive('documentMgrAddFolder', ['$rootScope', '$modal', '$log', '_', 'DocumentMgrService', 'AlertService', 'TreeModel', function ($rootScope, $modal, $log, _, DocumentMgrService, AlertService, TreeModel) {
return {
restrict: 'A',
scope: {
project: '=',
node: '='
},
link: function (scope, element, attrs) {
element.on('click', function () {
$modal.open({
animation: true,
templateUrl: 'modules/documents/client/views/document-manager-add.html',
resolve: {},
controllerAs: 'addFolder',
controller: function ($scope, $modalInstance) {
var self = this;

$scope.project = scope.project;
$scope.node = scope.node;

self.entryText = '';
self.title = "Add Folder to '" + $scope.node.model.name + "'";
if ($scope.node.model.name === 'ROOT') {
self.title = "Add Folder to '" + $scope.project.name + "'";
}

self.cancel = function () {
$modalInstance.dismiss('cancel');
};

self.ok = function () {
DocumentMgrService.addDirectory($scope.project, $scope.node, self.entryText)
.then(
function (result) {
$modalInstance.close(result.data);
},
function (err) {
//$log.error('addDirectory error: ', JSON.stringify(err));
AlertService.error("Could not add folder");
}
);
};

}
}).result.then(function (data) {
$rootScope.$broadcast('documentMgrRefreshNode', { directoryStructure: data });
})
.catch(function (err) {
//$log.error(err);
});
});
}
};
}])
;
Loading

0 comments on commit 039e983

Please sign in to comment.