|
|
@ -26,17 +26,20 @@ |
|
|
|
// See doc/COPYRIGHT.rdoc for more details.
|
|
|
|
// See doc/COPYRIGHT.rdoc for more details.
|
|
|
|
//++
|
|
|
|
//++
|
|
|
|
|
|
|
|
|
|
|
|
// TODO move to UI components
|
|
|
|
import {wpTabsModule} from "../../../angular-modules"; |
|
|
|
module.exports = function($http, PathHelper) { |
|
|
|
|
|
|
|
|
|
|
|
declare const URI; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function addWpRelationDirective($http, PathHelper) { |
|
|
|
return { |
|
|
|
return { |
|
|
|
restrict: 'E', |
|
|
|
restrict: 'E', |
|
|
|
templateUrl: '/templates/work_packages/tabs/_add_work_package_relation.html', |
|
|
|
templateUrl: '/components/wp-relations/add-wp-relation/add-wp-relation.directive.html', |
|
|
|
link: function(scope, element, attributes) { |
|
|
|
|
|
|
|
|
|
|
|
link: function (scope) { |
|
|
|
scope.relationToAddId = null; |
|
|
|
scope.relationToAddId = null; |
|
|
|
scope.autocompleteWorkPackages = function(term) { |
|
|
|
scope.autocompleteWorkPackages = function (term) { |
|
|
|
if (!term) { |
|
|
|
if (!term) return; |
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
var params = { |
|
|
|
var params = { |
|
|
|
q: term, |
|
|
|
q: term, |
|
|
|
scope: 'relatable', |
|
|
|
scope: 'relatable', |
|
|
@ -44,15 +47,17 @@ module.exports = function($http, PathHelper) { |
|
|
|
id: scope.handler.workPackage.props.id, |
|
|
|
id: scope.handler.workPackage.props.id, |
|
|
|
'project_id': scope.handler.workPackage.embedded.project.props.id |
|
|
|
'project_id': scope.handler.workPackage.embedded.project.props.id |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
return $http({ |
|
|
|
return $http({ |
|
|
|
method: 'GET', |
|
|
|
method: 'GET', |
|
|
|
url: URI(PathHelper.workPackageJsonAutoCompletePath()) |
|
|
|
url: URI(PathHelper.workPackageJsonAutoCompletePath()).search(params).toString() |
|
|
|
.search(params) |
|
|
|
} |
|
|
|
.toString() |
|
|
|
).then(function (response) { |
|
|
|
}).then(function(response) { |
|
|
|
|
|
|
|
scope.options = response.data; |
|
|
|
scope.options = response.data; |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wpTabsModule.directive('addWpRelation', addWpRelationDirective); |