From 6fed1a7b9082c68e6d6f800a2d938d521f934f77 Mon Sep 17 00:00:00 2001 From: Alex Dik Date: Thu, 2 Jun 2016 15:18:42 +0200 Subject: [PATCH] Move addWpRelation directive to components --- .../add-wp-relation.directive.html} | 0 .../add-wp-relation.directive.ts} | 33 +++++++++++-------- .../wp-relations/wp-relations.directive.html | 2 +- frontend/app/work_packages/tabs/index.js | 2 -- 4 files changed, 20 insertions(+), 17 deletions(-) rename frontend/app/{templates/work_packages/tabs/_add_work_package_relation.html => components/wp-relations/add-wp-relation/add-wp-relation.directive.html} (100%) rename frontend/app/{work_packages/tabs/add-work-package-relation-directive.js => components/wp-relations/add-wp-relation/add-wp-relation.directive.ts} (73%) diff --git a/frontend/app/templates/work_packages/tabs/_add_work_package_relation.html b/frontend/app/components/wp-relations/add-wp-relation/add-wp-relation.directive.html similarity index 100% rename from frontend/app/templates/work_packages/tabs/_add_work_package_relation.html rename to frontend/app/components/wp-relations/add-wp-relation/add-wp-relation.directive.html diff --git a/frontend/app/work_packages/tabs/add-work-package-relation-directive.js b/frontend/app/components/wp-relations/add-wp-relation/add-wp-relation.directive.ts similarity index 73% rename from frontend/app/work_packages/tabs/add-work-package-relation-directive.js rename to frontend/app/components/wp-relations/add-wp-relation/add-wp-relation.directive.ts index 0ba9dc09e7..f459c1af10 100644 --- a/frontend/app/work_packages/tabs/add-work-package-relation-directive.js +++ b/frontend/app/components/wp-relations/add-wp-relation/add-wp-relation.directive.ts @@ -26,17 +26,20 @@ // See doc/COPYRIGHT.rdoc for more details. //++ -// TODO move to UI components -module.exports = function($http, PathHelper) { +import {wpTabsModule} from "../../../angular-modules"; + +declare const URI; + +function addWpRelationDirective($http, PathHelper) { return { restrict: 'E', - templateUrl: '/templates/work_packages/tabs/_add_work_package_relation.html', - link: function(scope, element, attributes) { + templateUrl: '/components/wp-relations/add-wp-relation/add-wp-relation.directive.html', + + link: function (scope) { scope.relationToAddId = null; - scope.autocompleteWorkPackages = function(term) { - if (!term) { - return; - } + scope.autocompleteWorkPackages = function (term) { + if (!term) return; + var params = { q: term, scope: 'relatable', @@ -44,15 +47,17 @@ module.exports = function($http, PathHelper) { id: scope.handler.workPackage.props.id, 'project_id': scope.handler.workPackage.embedded.project.props.id }; + return $http({ - method: 'GET', - url: URI(PathHelper.workPackageJsonAutoCompletePath()) - .search(params) - .toString() - }).then(function(response) { + method: 'GET', + url: URI(PathHelper.workPackageJsonAutoCompletePath()).search(params).toString() + } + ).then(function (response) { scope.options = response.data; }); } } }; -}; +} + +wpTabsModule.directive('addWpRelation', addWpRelationDirective); diff --git a/frontend/app/components/wp-relations/wp-relations.directive.html b/frontend/app/components/wp-relations/wp-relations.directive.html index 044e937aef..631f996eb0 100644 --- a/frontend/app/components/wp-relations/wp-relations.directive.html +++ b/frontend/app/components/wp-relations/wp-relations.directive.html @@ -72,7 +72,7 @@ - + diff --git a/frontend/app/work_packages/tabs/index.js b/frontend/app/work_packages/tabs/index.js index c2008080a3..44b5b3e3e9 100644 --- a/frontend/app/work_packages/tabs/index.js +++ b/frontend/app/work_packages/tabs/index.js @@ -27,8 +27,6 @@ //++ angular.module('openproject.workPackages.tabs') - .directive('addWorkPackageRelation', require( - './add-work-package-relation-directive')) .directive('panelExpander', require('./panel-expander-directive')) .directive('relatedWorkPackageTableRow', [ 'I18n',