Merge pull request #1458 from atmire/w2p-85862-handling-very-long-strings

Handling very long strings for metadata and file names
This commit is contained in:
Tim Donohue
2021-12-17 10:05:45 -06:00
committed by GitHub
17 changed files with 61 additions and 22 deletions

View File

@@ -10,11 +10,11 @@
</nav> </nav>
<ng-template #breadcrumb let-text="text" let-url="url"> <ng-template #breadcrumb let-text="text" let-url="url">
<li class="breadcrumb-item"><a [routerLink]="url">{{text | translate}}</a></li> <li class="breadcrumb-item"><div class="breadcrumb-item-limiter"><a [routerLink]="url" class="text-truncate">{{text | translate}}</a></div></li>
</ng-template> </ng-template>
<ng-template #activeBreadcrumb let-text="text"> <ng-template #activeBreadcrumb let-text="text">
<li class="breadcrumb-item active" aria-current="page">{{text | translate}}</li> <li class="breadcrumb-item active" aria-current="page"><div class="breadcrumb-item-limiter"><div class="text-truncate">{{text | translate}}</div></div></li>
</ng-template> </ng-template>
</ng-container> </ng-container>

View File

@@ -10,6 +10,19 @@
background-color: var(--ds-breadcrumb-bg); background-color: var(--ds-breadcrumb-bg);
} }
li.breadcrumb-item {
display: flex;
}
.breadcrumb-item-limiter {
display: inline-block;
max-width: var(--ds-breadcrumb-max-length);
> * {
max-width: 100%;
display: block;
}
}
li.breadcrumb-item > a { li.breadcrumb-item > a {
color: var(--ds-breadcrumb-link-color) !important; color: var(--ds-breadcrumb-link-color) !important;
} }
@@ -18,5 +31,6 @@ li.breadcrumb-item.active {
} }
.breadcrumb-item+ .breadcrumb-item::before { .breadcrumb-item+ .breadcrumb-item::before {
display: block;
content: quote("") !important; content: quote("") !important;
} }

View File

@@ -72,7 +72,7 @@ describe('BreadcrumbsComponent', () => {
expect(breadcrumbs.length).toBe(3); expect(breadcrumbs.length).toBe(3);
expectBreadcrumb(breadcrumbs[0], 'home.breadcrumbs', '/'); expectBreadcrumb(breadcrumbs[0], 'home.breadcrumbs', '/');
expectBreadcrumb(breadcrumbs[1], 'bc 1', '/example.com'); expectBreadcrumb(breadcrumbs[1], 'bc 1', '/example.com');
expectBreadcrumb(breadcrumbs[2], 'bc 2', null); expectBreadcrumb(breadcrumbs[2].query(By.css('.text-truncate')), 'bc 2', null);
}); });
}); });

View File

@@ -1,10 +1,10 @@
<ds-type-badge *ngIf="showLabel" [object]="dso"></ds-type-badge> <ds-type-badge *ngIf="showLabel" [object]="dso"></ds-type-badge>
<ds-truncatable [id]="dso.id"> <ds-truncatable [id]="dso.id">
<a *ngIf="linkType != linkTypes.None" [target]="(linkType == linkTypes.ExternalLink) ? '_blank' : '_self'" rel="noopener noreferrer" <a *ngIf="linkType != linkTypes.None" [target]="(linkType == linkTypes.ExternalLink) ? '_blank' : '_self'" rel="noopener noreferrer"
[routerLink]="[itemPageRoute]" class="lead item-list-title" [routerLink]="[itemPageRoute]" class="lead item-list-title dont-break-out"
[innerHTML]="dsoTitle"></a> [innerHTML]="dsoTitle"></a>
<span *ngIf="linkType == linkTypes.None" <span *ngIf="linkType == linkTypes.None"
class="lead item-list-title" class="lead item-list-title dont-break-out"
[innerHTML]="dsoTitle"></span> [innerHTML]="dsoTitle"></span>
<span class="text-muted"> <span class="text-muted">
<ds-truncatable-part [id]="dso.id" [minLines]="1"> <ds-truncatable-part [id]="dso.id" [minLines]="1">

View File

@@ -1,10 +1,10 @@
<ds-type-badge *ngIf="showLabel" [object]="dso"></ds-type-badge> <ds-type-badge *ngIf="showLabel" [object]="dso"></ds-type-badge>
<ds-truncatable [id]="dso.id"> <ds-truncatable [id]="dso.id">
<a *ngIf="linkType != linkTypes.None" [target]="(linkType == linkTypes.ExternalLink) ? '_blank' : '_self'" rel="noopener noreferrer" <a *ngIf="linkType != linkTypes.None" [target]="(linkType == linkTypes.ExternalLink) ? '_blank' : '_self'" rel="noopener noreferrer"
[routerLink]="[itemPageRoute]" class="lead item-list-title" [routerLink]="[itemPageRoute]" class="lead item-list-title dont-break-out"
[innerHTML]="dsoTitle"></a> [innerHTML]="dsoTitle"></a>
<span *ngIf="linkType == linkTypes.None" <span *ngIf="linkType == linkTypes.None"
class="lead item-list-title" class="lead item-list-title dont-break-out"
[innerHTML]="dsoTitle"></span> [innerHTML]="dsoTitle"></span>
<span class="text-muted"> <span class="text-muted">
<ds-truncatable-part [id]="dso.id" [minLines]="1"> <ds-truncatable-part [id]="dso.id" [minLines]="1">

View File

@@ -1,10 +1,10 @@
<ds-type-badge *ngIf="showLabel" [object]="dso"></ds-type-badge> <ds-type-badge *ngIf="showLabel" [object]="dso"></ds-type-badge>
<ds-truncatable [id]="dso.id"> <ds-truncatable [id]="dso.id">
<a *ngIf="linkType != linkTypes.None" [target]="(linkType == linkTypes.ExternalLink) ? '_blank' : '_self'" rel="noopener noreferrer" <a *ngIf="linkType != linkTypes.None" [target]="(linkType == linkTypes.ExternalLink) ? '_blank' : '_self'" rel="noopener noreferrer"
[routerLink]="[itemPageRoute]" class="lead item-list-title" [routerLink]="[itemPageRoute]" class="lead item-list-title dont-break-out"
[innerHTML]="dsoTitle"></a> [innerHTML]="dsoTitle"></a>
<span *ngIf="linkType == linkTypes.None" <span *ngIf="linkType == linkTypes.None"
class="lead item-list-title" class="lead item-list-title dont-break-out"
[innerHTML]="dsoTitle"></span> [innerHTML]="dsoTitle"></span>
<span class="text-muted"> <span class="text-muted">
<ds-truncatable-part [id]="dso.id" [minLines]="1"> <ds-truncatable-part [id]="dso.id" [minLines]="1">

View File

@@ -1,10 +1,10 @@
<ds-truncatable [id]="dso.id"> <ds-truncatable [id]="dso.id">
<ds-type-badge *ngIf="showLabel" [object]="dso"></ds-type-badge> <ds-type-badge *ngIf="showLabel" [object]="dso"></ds-type-badge>
<a *ngIf="linkType != linkTypes.None" [target]="(linkType == linkTypes.ExternalLink) ? '_blank' : '_self'" rel="noopener noreferrer" <a *ngIf="linkType != linkTypes.None" [target]="(linkType == linkTypes.ExternalLink) ? '_blank' : '_self'" rel="noopener noreferrer"
[routerLink]="[itemPageRoute]" class="lead item-list-title" [routerLink]="[itemPageRoute]" class="lead item-list-title dont-break-out"
[innerHTML]="dsoTitle"></a> [innerHTML]="dsoTitle"></a>
<span *ngIf="linkType == linkTypes.None" <span *ngIf="linkType == linkTypes.None"
class="lead item-list-title" class="lead item-list-title dont-break-out"
[innerHTML]="dsoTitle"></span> [innerHTML]="dsoTitle"></span>
<!--<span class="text-muted">--> <!--<span class="text-muted">-->
<!--<ds-truncatable-part [id]="dso.id" [minLines]="1">--> <!--<ds-truncatable-part [id]="dso.id" [minLines]="1">-->

View File

@@ -1,18 +1,24 @@
<ng-template #bitstreamView> <ng-template #bitstreamView>
<div class="{{columnSizes.columns[0].buildClasses()}} row-element d-flex"> <div class="{{columnSizes.columns[0].buildClasses()}} row-element d-flex">
<ng-content select="[slot=drag-handle]"></ng-content> <ng-content select="[slot=drag-handle]"></ng-content>
<div class="float-left d-flex align-items-center"> <div class="float-left d-flex align-items-center overflow-hidden">
{{ bitstreamName }} <span class="text-truncate">
{{ bitstreamName }}
</span>
</div> </div>
</div> </div>
<div class="{{columnSizes.columns[1].buildClasses()}} row-element d-flex align-items-center"> <div class="{{columnSizes.columns[1].buildClasses()}} row-element d-flex align-items-center">
<div class="w-100"> <div class="w-100">
<span class="text-truncate">
{{ bitstream?.firstMetadataValue('dc.description') }} {{ bitstream?.firstMetadataValue('dc.description') }}
</span>
</div> </div>
</div> </div>
<div class="{{columnSizes.columns[2].buildClasses()}} row-element d-flex align-items-center"> <div class="{{columnSizes.columns[2].buildClasses()}} row-element d-flex align-items-center">
<div class="text-center w-100"> <div class="text-center w-100">
{{ (format$ | async)?.shortDescription }} <span class="text-truncate">
{{ (format$ | async)?.shortDescription }}
</span>
</div> </div>
</div> </div>
<div class="{{columnSizes.columns[3].buildClasses()}} row-element d-flex align-items-center"> <div class="{{columnSizes.columns[3].buildClasses()}} row-element d-flex align-items-center">

View File

@@ -26,7 +26,7 @@
<td class="w-100"> <td class="w-100">
<div class="value-field"> <div class="value-field">
<div *ngIf="!(editable | async)"> <div *ngIf="!(editable | async)">
<span>{{metadata?.value}}</span> <span class="dont-break-out">{{metadata?.value}}</span>
</div> </div>
<div *ngIf="(editable | async)" class="field-container"> <div *ngIf="(editable | async)" class="field-container">
<textarea class="form-control" type="textarea" attr.aria-labelledby="fieldValue" [(ngModel)]="metadata.value" [dsDebounce] <textarea class="form-control" type="textarea" attr.aria-labelledby="fieldValue" [(ngModel)]="metadata.value" [dsDebounce]

View File

@@ -1,5 +1,5 @@
<ds-metadata-field-wrapper [label]="label | translate"> <ds-metadata-field-wrapper [label]="label | translate">
<a *ngFor="let mdValue of mdValues; let last=last;" [href]="mdValue.value"> <a class="dont-break-out" *ngFor="let mdValue of mdValues; let last=last;" [href]="mdValue.value">
{{ linktext || mdValue.value }}<span *ngIf="!last" [innerHTML]="separator"></span> {{ linktext || mdValue.value }}<span *ngIf="!last" [innerHTML]="separator"></span>
</a> </a>
</ds-metadata-field-wrapper> </ds-metadata-field-wrapper>

View File

@@ -1,5 +1,5 @@
<ds-metadata-field-wrapper [label]="label | translate"> <ds-metadata-field-wrapper [label]="label | translate">
<span *ngFor="let mdValue of mdValues; let last=last;"> <span class="dont-break-out" *ngFor="let mdValue of mdValues; let last=last;">
{{mdValue.value}}<span *ngIf="!last" [innerHTML]="separator"></span> {{mdValue.value}}<span *ngIf="!last" [innerHTML]="separator"></span>
</span> </span>
</ds-metadata-field-wrapper> </ds-metadata-field-wrapper>

View File

@@ -1,4 +1,4 @@
<a [routerLink]="(bitstreamPath$| async)?.routerLink" [queryParams]="(bitstreamPath$| async)?.queryParams" [target]="isBlank ? '_blank': '_self'" [ngClass]="cssClasses"> <a [routerLink]="(bitstreamPath$| async)?.routerLink" class="dont-break-out" [queryParams]="(bitstreamPath$| async)?.queryParams" [target]="isBlank ? '_blank': '_self'" [ngClass]="cssClasses">
<span *ngIf="!(canDownload$ |async)"><i class="fas fa-lock"></i></span> <span *ngIf="!(canDownload$ |async)"><i class="fas fa-lock"></i></span>
<ng-container *ngTemplateOutlet="content"></ng-container> <ng-container *ngTemplateOutlet="content"></ng-container>
</a> </a>

View File

@@ -1,3 +1,3 @@
<div> <div>
<span>{{metadataRepresentation.getValue()}}</span> <span class="dont-break-out">{{metadataRepresentation.getValue()}}</span>
</div> </div>

View File

@@ -2,9 +2,9 @@
<ds-truncatable [id]="dso.id" *ngIf="object !== undefined && object !== null"> <ds-truncatable [id]="dso.id" *ngIf="object !== undefined && object !== null">
<a *ngIf="linkType != linkTypes.None" [target]="(linkType == linkTypes.ExternalLink) ? '_blank' : '_self'" rel="noopener noreferrer" <a *ngIf="linkType != linkTypes.None" [target]="(linkType == linkTypes.ExternalLink) ? '_blank' : '_self'" rel="noopener noreferrer"
[routerLink]="[itemPageRoute]" class="lead item-list-title" [routerLink]="[itemPageRoute]" class="lead item-list-title dont-break-out"
[innerHTML]="dsoTitle"></a> [innerHTML]="dsoTitle"></a>
<span *ngIf="linkType == linkTypes.None" class="lead item-list-title" <span *ngIf="linkType == linkTypes.None" class="lead item-list-title dont-break-out"
[innerHTML]="dsoTitle"></span> [innerHTML]="dsoTitle"></span>
<span class="text-muted"> <span class="text-muted">
<ds-truncatable-part [id]="dso.id" [minLines]="1"> <ds-truncatable-part [id]="dso.id" [minLines]="1">

View File

@@ -1,5 +1,5 @@
<div class="clamp-{{background}}-{{lines}} min-{{minLines}} {{type}} {{fixedHeight ? 'fixedHeight' : ''}}"> <div class="clamp-{{background}}-{{lines}} min-{{minLines}} {{type}} {{fixedHeight ? 'fixedHeight' : ''}}">
<div class="content"> <div class="content dont-break-out">
<ng-content></ng-content> <ng-content></ng-content>
</div> </div>
</div> </div>

View File

@@ -79,6 +79,7 @@
--ds-breadcrumb-bg: #{$gray-200} !important; --ds-breadcrumb-bg: #{$gray-200} !important;
--ds-breadcrumb-link-color: #{$cyan}; --ds-breadcrumb-link-color: #{$cyan};
--ds-breadcrumb-link-active-color: #{darken($cyan, 30%)}; --ds-breadcrumb-link-active-color: #{darken($cyan, 30%)};
--ds-breadcrumb-max-length: 200px;
--ds-slider-color: #{$green}; --ds-slider-color: #{$green};
--ds-slider-handle-width: 18px; --ds-slider-handle-width: 18px;

View File

@@ -74,3 +74,21 @@ ngb-modal-backdrop {
} }
} }
.dont-break-out {
/* These are technically the same, but use both */
overflow-wrap: break-word;
word-wrap: break-word;
-ms-word-break: break-all;
/* This is the dangerous one in WebKit, as it breaks things wherever */
word-break: break-all;
/* Instead use this non-standard one: */
word-break: break-word;
/* Adds a hyphen where the word breaks, if supported (No Blink) */
-ms-hyphens: auto;
-moz-hyphens: auto;
-webkit-hyphens: auto;
hyphens: auto;
}