add a small directive to display an icon in the file list

Signed-off-by: Florian Kraft <f.kraft@finn.de>
pull/3245/head
Florian Kraft 9 years ago
parent 077d8e5fab
commit dd61288bbe
  1. 36
      frontend/app/ui_components/attachment-icon-directive.js
  2. 1
      frontend/app/ui_components/index.js

@ -0,0 +1,36 @@
module.exports = function() {
return {
restrict: 'E',
replace: true,
scope: {
type: '&'
},
template: '<i class="icon-{{icon}}"></i>',
link: function(scope) {
var icon, type = scope.type();
switch(type) {
// images
case 'image/png':
case 'image/jpg':
case 'image/gif':
icon = 'image1'
break;
// documents
case 'application/pdf':
icon = 'page-pdf';
break;
case 'application/excel':
case 'application/vnd.ms-excel':
case 'application/x-excel':
case 'application/x-msexcel':
icon = 'page-xls';
break;
default:
icon = 'ticket';
break;
}
scope.icon = icon;
}
}
}

@ -107,5 +107,6 @@ angular.module('openproject.uiComponents')
.directive('notifications', [require('./notifications-directive')]) .directive('notifications', [require('./notifications-directive')])
.directive('notificationBox', [require('./notification-box-directive')]) .directive('notificationBox', [require('./notification-box-directive')])
.directive('uploadProgress', [require('./upload-progress-directive')]) .directive('uploadProgress', [require('./upload-progress-directive')])
.directive('attachmentIcon', [require('./attachment-icon-directive')])
.filter('ancestorsExpanded', require('./filters/ancestors-expanded-filter')) .filter('ancestorsExpanded', require('./filters/ancestors-expanded-filter'))
.filter('latestItems', require('./filters/latest-items-filter')); .filter('latestItems', require('./filters/latest-items-filter'));

Loading…
Cancel
Save