Move addWpRelation directive to components

pull/4471/head
Alex Dik 9 years ago
parent 5a201b4df5
commit 6fed1a7b90
  1. 0
      frontend/app/components/wp-relations/add-wp-relation/add-wp-relation.directive.html
  2. 29
      frontend/app/components/wp-relations/add-wp-relation/add-wp-relation.directive.ts
  3. 2
      frontend/app/components/wp-relations/wp-relations.directive.html
  4. 2
      frontend/app/work_packages/tabs/index.js

@ -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);

@ -72,7 +72,7 @@
<!-- Add WP relation --> <!-- Add WP relation -->
<add-work-package-relation ng-switch-default></add-work-package-relation> <add-wp-relation ng-switch-default></add-wp-relation>
</div> </div>
</div> </div>
</div> </div>

@ -27,8 +27,6 @@
//++ //++
angular.module('openproject.workPackages.tabs') angular.module('openproject.workPackages.tabs')
.directive('addWorkPackageRelation', require(
'./add-work-package-relation-directive'))
.directive('panelExpander', require('./panel-expander-directive')) .directive('panelExpander', require('./panel-expander-directive'))
.directive('relatedWorkPackageTableRow', [ .directive('relatedWorkPackageTableRow', [
'I18n', 'I18n',

Loading…
Cancel
Save