This repository has been archived by the owner on Jan 7, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #39 from bryan-gilbert/master
Refactor doc manager directive
- Loading branch information
Showing
7 changed files
with
927 additions
and
908 deletions.
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
modules/documents/client/directives/documents.manager.add.directive.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
}); | ||
} | ||
}; | ||
}]) | ||
; |
Oops, something went wrong.