mirror of
https://github.com/ansible/awx.git
synced 2026-05-10 19:07:36 -02:30
Add truncate component
This commit is contained in:
@@ -19,6 +19,7 @@ import panelBody from './panel/body.directive';
|
|||||||
import popover from './popover/popover.directive';
|
import popover from './popover/popover.directive';
|
||||||
import tab from './tabs/tab.directive';
|
import tab from './tabs/tab.directive';
|
||||||
import tabGroup from './tabs/group.directive';
|
import tabGroup from './tabs/group.directive';
|
||||||
|
import truncate from './truncate/truncate.directive';
|
||||||
|
|
||||||
import BaseInputController from './input/base.controller';
|
import BaseInputController from './input/base.controller';
|
||||||
import ComponentsStrings from './components.strings';
|
import ComponentsStrings from './components.strings';
|
||||||
@@ -46,7 +47,8 @@ angular
|
|||||||
.directive('atPopover', popover)
|
.directive('atPopover', popover)
|
||||||
.directive('atTab', tab)
|
.directive('atTab', tab)
|
||||||
.directive('atTabGroup', tabGroup)
|
.directive('atTabGroup', tabGroup)
|
||||||
.service('BaseInputController', BaseInputController)
|
.directive('atTruncate', truncate)
|
||||||
.service('ComponentsStrings', ComponentsStrings);
|
.service('ComponentsStrings', ComponentsStrings)
|
||||||
|
.service('BaseInputController', BaseInputController);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
43
awx/ui/client/lib/components/truncate/truncate.directive.js
Normal file
43
awx/ui/client/lib/components/truncate/truncate.directive.js
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
function atTruncateLink (scope, el, attr, ctrl) {
|
||||||
|
let truncateController = ctrl;
|
||||||
|
let string = attr.atTruncate;
|
||||||
|
let maxlength = attr.maxlength;
|
||||||
|
|
||||||
|
truncateController.init(scope, string, maxlength);
|
||||||
|
}
|
||||||
|
|
||||||
|
function AtTruncateController ($filter) {
|
||||||
|
let vm = this;
|
||||||
|
|
||||||
|
let string,
|
||||||
|
maxlength;
|
||||||
|
|
||||||
|
vm.init = (scope, _string_, _maxlength_) => {
|
||||||
|
string = _string_;
|
||||||
|
maxlength = _maxlength_;
|
||||||
|
vm.truncatedString = $filter('limitTo')(string, maxlength, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function atTruncate($filter) {
|
||||||
|
return {
|
||||||
|
restrict: 'EA',
|
||||||
|
replace: true,
|
||||||
|
transclude: true,
|
||||||
|
template: '<span>{{vm.truncatedString}}</span>',
|
||||||
|
controller: AtTruncateController,
|
||||||
|
controllerAs: 'vm',
|
||||||
|
link: atTruncateLink,
|
||||||
|
scope: {
|
||||||
|
maxLength: '@'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
atTruncate.$inject = [
|
||||||
|
'$filter'
|
||||||
|
];
|
||||||
|
|
||||||
|
export default atTruncate;
|
||||||
@@ -10,13 +10,12 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.RevisionHash-copy {
|
.RevisionHash-copy {
|
||||||
color: @default-link;
|
color: @b7grey;
|
||||||
text-transform: uppercase;
|
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
font-size: 11px;
|
|
||||||
margin-left: 10px;
|
margin-left: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.RevisionHash-copy:hover {
|
.RevisionHash-copy:hover {
|
||||||
color: @default-link-hov;
|
color: @default-link;
|
||||||
}
|
}
|
||||||
@@ -1,20 +1,14 @@
|
|||||||
export default
|
export default
|
||||||
[ 'templateUrl',
|
[ 'templateUrl', function(templateUrl) {
|
||||||
'Rest',
|
|
||||||
'$q',
|
|
||||||
'$filter',
|
|
||||||
function(templateUrl, Rest, $q, $filter) {
|
|
||||||
return {
|
return {
|
||||||
restrict: 'E',
|
restrict: 'E',
|
||||||
templateUrl: templateUrl('projects/revisions/revisions'),
|
templateUrl: templateUrl('projects/revisions/revisions'),
|
||||||
link: function(scope) {
|
link: function(scope) {
|
||||||
let full_revision = scope.project.scm_revision;
|
|
||||||
scope.revisionHash = $filter('limitTo')(full_revision, 7, 0);
|
|
||||||
scope.count = scope.project.scm_revision.length;
|
|
||||||
|
|
||||||
scope.copyRevisionHash = function() {
|
scope.copy = function() {
|
||||||
scope.$emit('copied');
|
scope.$emit('copied');
|
||||||
|
|
||||||
|
let full_revision = scope.project.scm_revision;
|
||||||
let textArea = document.createElement("textarea");
|
let textArea = document.createElement("textarea");
|
||||||
|
|
||||||
// Place in top-left corner of screen regardless of scroll position.
|
// Place in top-left corner of screen regardless of scroll position.
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<div class="RevisionHash-tag">
|
<div class="RevisionHash-tag">
|
||||||
<span class="RevisionHash-name">{{revisionHash}}</span>
|
<span at-truncate="{{project.scm_revision}}" maxLength="7" class="RevisionHash-name"></span>
|
||||||
</div>
|
</div>
|
||||||
<div class="RevisionHash-copy" ng-if="count > 7" aw-tool-tip="{{project.tooltipContent}}" data-tip-watch="project.tooltipContent"
|
<div class="RevisionHash-copy" aw-tool-tip="{{project.tooltipContent}}" data-tip-watch="project.tooltipContent"
|
||||||
data-placement="top" ng-click="copyRevisionHash()">
|
data-placement="top" ng-click="copy()">
|
||||||
<i class="fa fa-clone"></i>
|
<i class="fa fa-clone"></i>
|
||||||
</div>
|
</div>
|
||||||
Reference in New Issue
Block a user