Merge pull request #1574 from opf/fix/path-helper-refactor

Added static paths to PathHelper and using them in wp templates.
pull/1582/head
Till Breuer 10 years ago
commit 1b71e45e4f
  1. 2
      app/assets/javascripts/angular/api/hal-api-resource.js
  2. 45
      app/assets/javascripts/angular/helpers/components/path-helper.js
  3. 4
      app/assets/javascripts/angular/work_packages/controllers/work-package-details-controller.js
  4. 6
      app/assets/javascripts/angular/work_packages/directives/work-package-column-directive.js
  5. 4
      app/assets/javascripts/angular/work_packages/directives/work-packages-table-directive.js
  6. 44
      app/assets/javascripts/angular/work_packages/tabs/user-activity-directive.js
  7. 4
      app/assets/javascripts/angular/work_packages/tabs/user_field-directive.js
  8. 2
      public/templates/work_packages.list.details.html
  9. 15
      public/templates/work_packages/tabs/_user_activity.html
  10. 2
      public/templates/work_packages/tabs/_user_field.html
  11. 26
      public/templates/work_packages/tabs/activity.html
  12. 19
      public/templates/work_packages/tabs/overview.html
  13. 3
      public/templates/work_packages/tabs/watchers.html
  14. 2
      public/templates/work_packages/work_packages_table.html

@ -12,7 +12,7 @@ angular.module('openproject.api')
setup: function(uri) {
HALAPIResource.configure();
return new Hyperagent.Resource({
url: PathHelper.apiPrefixV3 + '/' + uri,
url: PathHelper.apiV3 + '/' + uri,
});
}
}

@ -31,9 +31,10 @@ angular.module('openproject.helpers')
.service('PathHelper', [function() {
PathHelper = {
apiPrefixV2: '/api/v2',
apiPrefixExperimental: '/api/experimental',
apiPrefixV3: '/api/v3',
apiV2: '/api/v2',
apiExperimental: '/api/experimental',
apiV3: '/api/v3',
staticBase: window.appBasePath ? window.appBasePath : '',
activityPath: function(projectIdentifier, from) {
var link = '/activity';
@ -126,7 +127,7 @@ angular.module('openproject.helpers')
return PathHelper.apiQueriesPath() + '/grouped';
},
apiGroupsPath: function() {
return PathHelper.apiPrefixExperimental + '/groups';
return PathHelper.apiExperimental + '/groups';
},
apiProjectAvailableColumnsPath: function(projectIdentifier) {
return PathHelper.apiProjectPath(projectIdentifier) + '/queries/available_columns';
@ -138,7 +139,7 @@ angular.module('openproject.helpers')
return PathHelper.apiProjectPath(projectIdentifier) + '/queries/grouped';
},
apiProjectPath: function(projectIdentifier) {
return PathHelper.apiPrefixExperimental + PathHelper.projectPath(projectIdentifier);
return PathHelper.apiExperimental + PathHelper.projectPath(projectIdentifier);
},
apiProjectQueriesPath: function(projectIdentifier) {
return PathHelper.apiProjectPath(projectIdentifier) + '/queries';
@ -147,7 +148,7 @@ angular.module('openproject.helpers')
return PathHelper.apiProjectPath(projectIdentifier) + PathHelper.queryPath(queryIdentifier);
},
apiProjectsPath: function(){
return PathHelper.apiPrefixExperimental + PathHelper.projectsPath();
return PathHelper.apiExperimental + PathHelper.projectsPath();
},
apiProjectSubProjectsPath: function(projectIdentifier) {
return PathHelper.apiProjectPath(projectIdentifier) + PathHelper.subProjectsPath();
@ -165,23 +166,23 @@ angular.module('openproject.helpers')
return PathHelper.apiProjectPath(projectIdentifier) + PathHelper.workPackagesPath() + '/column_sums';
},
apiQueriesPath: function() {
return PathHelper.apiPrefixExperimental + '/queries';
return PathHelper.apiExperimental + '/queries';
},
apiQueryPath: function(query_id) {
return PathHelper.apiQueriesPath() + '/' + query_id;
},
apiRolesPath: function() {
return PathHelper.apiPrefixExperimental + '/roles';
return PathHelper.apiExperimental + '/roles';
},
apiUsersPath: function() {
// experimantal, TODO: Migrate to V3
return PathHelper.apiPrefixExperimental + PathHelper.usersPath();
return PathHelper.apiExperimental + PathHelper.usersPath();
},
apiWorkPackagesColumnDataPath: function() {
return PathHelper.apiWorkPackagesPath() + '/column_data';
},
apiWorkPackagesPath: function() {
return PathHelper.apiPrefixExperimental + '/work_packages';
return PathHelper.apiExperimental + '/work_packages';
},
apiWorkPackagesSumsPath: function() {
return PathHelper.apiWorkPackagesPath() + '/column_sums';
@ -189,7 +190,7 @@ angular.module('openproject.helpers')
// API V2
apiPrioritiesPath: function() {
return PathHelper.apiPrefixV2 + '/planning_element_priorities';
return PathHelper.apiV2 + '/planning_element_priorities';
},
apiProjectStatusesPath: function(projectIdentifier) {
return PathHelper.apiV2ProjectPath(projectIdentifier) + '/statuses';
@ -198,13 +199,13 @@ angular.module('openproject.helpers')
return PathHelper.apiV2ProjectPath(projectIdentifier) + '/planning_element_types';
},
apiStatusesPath: function() {
return PathHelper.apiPrefixV2 + '/statuses';
return PathHelper.apiV2 + '/statuses';
},
apiV2ProjectPath: function(projectIdentifier) {
return PathHelper.apiPrefixV2 + PathHelper.projectPath(projectIdentifier);
return PathHelper.apiV2 + PathHelper.projectPath(projectIdentifier);
},
apiWorkPackageTypesPath: function() {
return PathHelper.apiPrefixV2 + '/planning_element_types';
return PathHelper.apiV2 + '/planning_element_types';
},
// API V3
@ -215,8 +216,22 @@ angular.module('openproject.helpers')
return PathHelper.apiV3QueryPath(queryId) + '/unstar';
},
apiV3QueryPath: function(queryId) {
return PathHelper.apiPrefixV3 + PathHelper.queryPath(queryId);
return PathHelper.apiV3 + PathHelper.queryPath(queryId);
},
// Static
staticUserPath: function(userId) {
return PathHelper.staticBase + PathHelper.userPath(userId);
},
staticWorkPackagePath: function(workPackageId) {
return PathHelper.staticBase + PathHelper.workPackagePath(workPackageId);
},
staticProjectPath: function(projectId) {
return PathHelper.staticBase + PathHelper.projectPath(projectId);
},
staticVersionPath: function(versionId) {
return PathHelper.staticBase + PathHelper.versionPath(versionId);
}
};
return PathHelper;

@ -43,9 +43,10 @@ angular.module('openproject.workPackages.controllers')
'DEFAULT_WORK_PACKAGE_PROPERTIES',
'USER_TYPE',
'WorkPackagesHelper',
'PathHelper',
'UserService',
'$q',
function($scope, workPackage, I18n, DEFAULT_WORK_PACKAGE_PROPERTIES, USER_TYPE, WorkPackagesHelper, UserService, $q) {
function($scope, workPackage, I18n, DEFAULT_WORK_PACKAGE_PROPERTIES, USER_TYPE, WorkPackagesHelper, PathHelper, UserService, $q) {
// initialization
$scope.I18n = I18n;
$scope.workPackage = workPackage;
@ -60,6 +61,7 @@ angular.module('openproject.workPackages.controllers')
// work package properties
$scope.presentWorkPackageProperties = [];
$scope.emptyWorkPackageProperties = [];
$scope.userPath = PathHelper.staticUserPath;
var workPackageProperties = DEFAULT_WORK_PACKAGE_PROPERTIES;

@ -126,11 +126,11 @@ angular.module('openproject.workPackages.directives')
} else if (scope.workPackage[scope.column.name]) {
switch (link_meta.model_type) {
case 'user':
return PathHelper.userPath(scope.workPackage[scope.column.name].id);
return PathHelper.staticUserPath(scope.workPackage[scope.column.name].id);
case 'version':
return PathHelper.versionPath(scope.workPackage[scope.column.name].id);
return PathHelper.staticVersionPath(scope.workPackage[scope.column.name].id);
case 'project':
return PathHelper.projectPath(scope.workPackage.project.identifier);
return PathHelper.staticProjectPath(scope.workPackage.project.identifier);
default:
return '';
}

@ -32,7 +32,8 @@ angular.module('openproject.workPackages.directives')
'I18n',
'WorkPackagesTableService',
'flags',
function(I18n, WorkPackagesTableService, flags){
'PathHelper',
function(I18n, WorkPackagesTableService, flags, PathHelper){
return {
restrict: 'E',
@ -55,6 +56,7 @@ angular.module('openproject.workPackages.directives')
link: function(scope, element, attributes) {
scope.I18n = I18n;
scope.workPackagesTableData = WorkPackagesTableService.getWorkPackagesTableData();
scope.workPackagePath = PathHelper.staticWorkPackagePath;
var topMenuHeight = angular.element('#top-menu').prop('offsetHeight') || 0;
scope.adaptVerticalPosition = function(event) {

@ -0,0 +1,44 @@
//-- 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.
//++
angular.module('openproject.workPackages.tabs')
.directive('userActivity', ['PathHelper', function(PathHelper) {
return {
restrict: 'E',
replace: true,
templateUrl: '/templates/work_packages/tabs/_user_activity.html',
scope: {
activity: '=',
currentAnchor: '='
},
link: function(scope) {
scope.userPath = PathHelper.staticUserPath;
}
};
}]);

@ -28,7 +28,7 @@
angular.module('openproject.workPackages.tabs')
.directive('userField', [function() {
.directive('userField', ['PathHelper', function(PathHelper) {
return {
restrict: 'E',
replace: true,
@ -41,6 +41,8 @@ angular.module('openproject.workPackages.tabs')
scope.userName = scope.user.props.firstName + ' ' + scope.user.props.lastName;
}
});
scope.userPath = PathHelper.staticUserPath;
}
};
}]);

@ -33,7 +33,7 @@
<i class="star icon-star1"/>
<a href>#{{ workPackage.props.id }}</a>
<span ng-bind="I18n.t('js.label_added_by')"/>
<a href ng-bind="workPackage.props.authorName"/>.
<a ng-href="{{ userPath(workPackage.embedded.author.props.id) }}" ng-bind="workPackage.embedded.author.props.firstName + ' ' + workPackage.embedded.author.props.lastName"/>.
<span ng-bind="I18n.t('js.label_last_updated_on')"/>
<span ng-bind="workPackage.props.updatedAt|date:'longDate'"/>.
</span>

@ -0,0 +1,15 @@
<div class="work-package-details-activities-activity-contents">
<div class="comments-number"><a ng-href="#{{ currentAnchor }}" ng-bind="'#' + ($index+1)"></a>
</div>
<img class="avatar" ng-src="{{ activity.props.userAvatar }}" />
<span class="user"><a ng-href="{{ userPath(activity.props.userId) }}" name="{{ currentAnchor }}" ng-bind="activity.props.userName"></a></span>
<span class="date">commented on <span ng-bind="activity.props.createdAt | date:'short'"/></span>
<span class="comment">
<span class="message" ng-show="activity.props._type == 'Activity::Comment'">{{ activity.props.comment }}</span>
<ul class="work-package-details-activities-messages">
<li ng-repeat="detail in activity.props.htmlDetails track by $index">
<span class="message" ng-bind-html="detail"/>
</li>
</ul>
</span>
</div>

@ -3,7 +3,7 @@
<img class="avatar"
ng-if="user.props.avatar"
ng-src="{{user.props.avatar}}" />
<span class="user"><a href ng-bind="userName"/></span>
<span class="user"><a ng-href="{{ userPath(user.props.id) }}" ng-bind="userName"/></span>
<span class="role" ng-if="user.props.role" ng-bind="user.props.role"/>
</span>
<span ng-if="!userName"> - </span>

@ -4,31 +4,13 @@
<li ng-repeat="activity in activities"
class="work-package-details-activities-activity"
ng-init="currentDate = (activity.props.createdAt|date:'longDate');
currentNote = 'note-' + ($index+1)">
currentAnchor = 'note-' + ($index+1)">
<h3 class="activity-date"
ng-if="currentDate !== (activities[$index-1].props.createdAt | date:'longDate')"
ng-bind="currentDate"/>
<div class="work-package-details-activities-activity-contents">
<div class="comments-number"><a ng-href="#{{currentNote}}" ng-bind="'#' + ($index+1)"></a>
<!-- Temporarily deactivated comment / edit actions
<div class="comments-icons">
<icon-wrapper icon-name="quote" icon-title="{{I18n.t('js.button_quote')}}"></icon-wrapper>
<icon-wrapper icon-name="edit" icon-title="{{I18n.t('js.button_edit')}}"></icon-wrapper>
</div>
-->
</div>
<img class="avatar" ng-src="{{ activity.props.userAvatar }}" />
<span class="user"><a href name="{{currentNote}}" ng-bind="activity.props.userName"></a></span>
<span class="date">commented on <span ng-bind="activity.props.createdAt | date:'short'"/></span>
<span class="comment">
<span class="message" ng-show="activity.props._type == 'Activity::Comment'">{{activity.props.comment}}</span>
<ul class="work-package-details-activities-messages">
<li ng-repeat="detail in activity.props.htmlDetails track by $index">
<span class="message" ng-bind-html="detail"/>
</li>
</ul>
</span>
</div>
<user-activity activity="activity"
currentAnchor="currentAnchor">
</user-activity>
</li>
</ul>
</div>

@ -49,22 +49,9 @@
<ul>
<li ng-repeat="activity in latestActitivies"
class="work-package-details-activities-activity"
ng-init="currentNote = 'note-' + ($index+1)">
<div class="work-package-details-activities-activity-contents">
<div class="comments-number"><a ng-href="#{{currentNote}}" ng-bind="'#' + ($index+1)"></a>
</div>
<img class="avatar" ng-src="{{ activity.props.userAvatar }}" />
<span class="user"><a href name="{{currentNote}}" ng-bind="activity.props.userName"></a></span>
<span class="date">commented on <span ng-bind="activity.props.createdAt | date:'short'"/></span>
<span class="comment">
<span class="message" ng-show="activity.props._type == 'Activity::Comment'">{{activity.props.comment}}</span>
<ul class="work-package-details-activities-messages">
<li ng-repeat="detail in activity.props.htmlDetails track by $index">
<span class="message" ng-bind-html="detail"/>
</li>
</ul>
</span>
</div>
ng-init="currentAnchor = 'note-' + ($index+1)">
<user-activity activity="activity"
currentAnchor="currentAnchor">
</li>
</ul>
</div>

@ -2,8 +2,7 @@
<div class="detail-panel-watchers">
<ul>
<li ng-repeat="user in watchers">
<img class="avatar" ng-src="{{ user.props.userAvatar }}" />
<span class="user"><a ng-href="/users/{{ user.props.id }}" ng-bind="user.props.firstname + user.props.lastname"></a></span>
<user-field user="user"></user-field>
</li>
</ul>
</div>

@ -121,7 +121,7 @@
<td class="id">
<span ng-if="workPackage.parent_id" class="hidden-for-sighted" ng-bind="parentWorkPackageHiddenText">
</span>
<a ng-href="/work_packages/{{row.object.id}}">{{row.object.id}}</a>
<a ng-href="{{ workPackagePath(row.object.id) }}">{{row.object.id}}</a>
</td>
<td ng-repeat="column in columns" class="{{column.name}}" lang="{{column.custom_field && column.custom_field.name_locale || I18n.locale}}">

Loading…
Cancel
Save