version view check for defining project

pull/2687/head
Mihail Maxacov 10 years ago
parent 1617a11d7b
commit 171006982f
  1. 8
      frontend/app/services/version-service.js
  2. 3
      frontend/app/templates/components/inplace_editor/display/user.html
  3. 11
      frontend/app/templates/components/inplace_editor/display/version.html
  4. 9
      frontend/app/ui_components/index.js
  5. 9
      frontend/app/ui_components/inplace-editor-dispatcher.js

@ -29,6 +29,8 @@
module.exports = function($http, PathHelper) { module.exports = function($http, PathHelper) {
var VersionService = { var VersionService = {
// TODO: check if code invoked anywere
getVersions: function(projectIdentifier) { getVersions: function(projectIdentifier) {
var url; var url;
@ -46,6 +48,12 @@ module.exports = function($http, PathHelper) {
.then(function(response){ .then(function(response){
return _.sortBy(response.data.versions, 'name'); return _.sortBy(response.data.versions, 'name');
}); });
},
isVersionFieldViewable: function (workPackage, fieldName) {
return workPackage.links[fieldName].fetch().then(function(response) {
return response.links.definingProject && response.links.definingProject.href;
});
} }
}; };

@ -1 +1,2 @@
<user-field user="readValue"></user-field> <span ng-if="!readValue.props">{{ readValue }}</span>
<user-field ng-if="readValue.props" user="readValue"></user-field>

@ -1,8 +1,9 @@
<span ng-if="entity.links.version.href"> <span ng-if="!readValue.props">{{ readValue }}</span>
<a href="{{pathHelper.versionPath(entity.embedded.version.props.id)}}"> <span ng-if="readValue.props && isVersionFieldViewable">
{{entity.links.version.props.title}} <a href="{{pathHelper.versionPath(readValue.props.id)}}">
{{readValue.props.name}}
</a> </a>
</span> </span>
<span ng-if="!entity.links.version.href"> <span ng-if="readValue.props && !isVersionFieldViewable">
{{readValue}} {{readValue.props.name}}
</span> </span>

@ -81,7 +81,14 @@ angular.module('openproject.uiComponents')
'OverviewTabInplaceEditorConfig', 'OverviewTabInplaceEditorConfig',
require('./inplace-editor-directive') require('./inplace-editor-directive')
]) ])
.service('InplaceEditorDispatcher', require('./inplace-editor-dispatcher')) .service('InplaceEditorDispatcher', [
'$sce',
'$http',
'$timeout',
'AutoCompleteHelper',
'TextileService',
'VersionService',
require('./inplace-editor-dispatcher')])
.directive('modal', [require('./modal-directive')]) .directive('modal', [require('./modal-directive')])
.directive('modalLoading', ['I18n', require('./modal-loading-directive')]) .directive('modalLoading', ['I18n', require('./modal-loading-directive')])
.directive('progressBar', ['I18n', require('./progress-bar-directive')]) .directive('progressBar', ['I18n', require('./progress-bar-directive')])

@ -26,7 +26,7 @@
// See doc/COPYRIGHT.rdoc for more details. // See doc/COPYRIGHT.rdoc for more details.
//++ //++
module.exports = function($sce, $http, $timeout, AutoCompleteHelper, TextileService) { module.exports = function($sce, $http, $timeout, AutoCompleteHelper, TextileService, VersionService) {
function enableAutoCompletion(element) { function enableAutoCompletion(element) {
var textarea = element.find('.inplace-edit--write-value input, .inplace-edit--write-value textarea'); var textarea = element.find('.inplace-edit--write-value input, .inplace-edit--write-value textarea');
@ -214,8 +214,13 @@ module.exports = function($sce, $http, $timeout, AutoCompleteHelper, TextileServ
if ($scope.isEditable && isOptionListEmbedded($scope)) { if ($scope.isEditable && isOptionListEmbedded($scope)) {
this._setEmbeddedOptions($scope); this._setEmbeddedOptions($scope);
} }
if ($scope.displayStrategy == 'user' || $scope.displayStrategy == 'version') { if ($scope.displayStrategy === 'user' || $scope.displayStrategy === 'version') {
$scope.readValue = $scope.entity.embedded[$scope.attribute]; $scope.readValue = $scope.entity.embedded[$scope.attribute];
if ($scope.displayStrategy === 'version') {
VersionService.isVersionFieldViewable($scope.entity, getAttribute($scope)).then(function(isViewable) {
$scope.isVersionFieldViewable = isViewable;
});
}
} else { } else {
$scope.readValue = this._getReadAttributeValue($scope); $scope.readValue = this._getReadAttributeValue($scope);
} }

Loading…
Cancel
Save