From 17bfc3d263817ef1a3ca6b32694141e6acc74768 Mon Sep 17 00:00:00 2001 From: Hagen Schink Date: Mon, 4 Aug 2014 16:23:09 +0200 Subject: [PATCH] Extract relation specific add controls --- .../work_packages/models/relations-handler.js | 2 + .../add-work-package-relation-directive.js | 37 +++++++++++++++++++ .../tabs/work-package-relations-directive.js | 4 +- .../tabs/_add_work_package_relation.html | 12 ++++++ .../tabs/_work_package_relations.html | 15 +------- 5 files changed, 56 insertions(+), 14 deletions(-) create mode 100644 app/assets/javascripts/angular/work_packages/tabs/add-work-package-relation-directive.js create mode 100644 public/templates/work_packages/tabs/_add_work_package_relation.html diff --git a/app/assets/javascripts/angular/work_packages/models/relations-handler.js b/app/assets/javascripts/angular/work_packages/models/relations-handler.js index 70f4897e27..61ebcdab92 100644 --- a/app/assets/javascripts/angular/work_packages/models/relations-handler.js +++ b/app/assets/javascripts/angular/work_packages/models/relations-handler.js @@ -39,6 +39,8 @@ angular.module('openproject.models') this.workPackage = workPackage; this.relations = relations; this.relationsId = relationsId; + + this.type = "relation"; } CommonRelationsHandler.prototype = { diff --git a/app/assets/javascripts/angular/work_packages/tabs/add-work-package-relation-directive.js b/app/assets/javascripts/angular/work_packages/tabs/add-work-package-relation-directive.js new file mode 100644 index 0000000000..3f35154d6b --- /dev/null +++ b/app/assets/javascripts/angular/work_packages/tabs/add-work-package-relation-directive.js @@ -0,0 +1,37 @@ +//-- copyright +// OpenProject is a project management system. +// Copyright (C) 2012-2014 the OpenProject Foundation (OPF) +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License version 3. +// +// OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: +// Copyright (C) 2006-2013 Jean-Philippe Lang +// Copyright (C) 2010-2013 the ChiliProject Team +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// See doc/COPYRIGHT.rdoc for more details. +//++ + +// TODO move to UI components +angular.module('openproject.workPackages.tabs') + +.directive('addWorkPackageRelation', [function() { + return { + restrict: 'E', + templateUrl: '/templates/work_packages/tabs/_add_work_package_relation.html', + }; +}]); diff --git a/app/assets/javascripts/angular/work_packages/tabs/work-package-relations-directive.js b/app/assets/javascripts/angular/work_packages/tabs/work-package-relations-directive.js index 65cbbda082..1670cea9c6 100644 --- a/app/assets/javascripts/angular/work_packages/tabs/work-package-relations-directive.js +++ b/app/assets/javascripts/angular/work_packages/tabs/work-package-relations-directive.js @@ -70,7 +70,9 @@ angular.module('openproject.workPackages.tabs') scope.expand = !scope.expand; }; - scope.handler.applyCustomExtensions(); + $timeout(function() { + scope.handler.applyCustomExtensions(); + }); } }; }]); diff --git a/public/templates/work_packages/tabs/_add_work_package_relation.html b/public/templates/work_packages/tabs/_add_work_package_relation.html new file mode 100644 index 0000000000..dfe5097ab3 --- /dev/null +++ b/public/templates/work_packages/tabs/_add_work_package_relation.html @@ -0,0 +1,12 @@ + + + diff --git a/public/templates/work_packages/tabs/_work_package_relations.html b/public/templates/work_packages/tabs/_work_package_relations.html index cd400d9ba7..d934b5534c 100644 --- a/public/templates/work_packages/tabs/_work_package_relations.html +++ b/public/templates/work_packages/tabs/_work_package_relations.html @@ -45,19 +45,8 @@ No relation exists -
- - - +
+