Feature: Enhanced templating for filename format (#7836)

Co-authored-by: shamoon <4887959+shamoon@users.noreply.github.com>
This commit is contained in:
Trenton H
2024-10-06 12:54:01 -07:00
committed by GitHub
parent e49ed58f1a
commit 7c11a37150
29 changed files with 1299 additions and 615 deletions

View File

@@ -38,7 +38,7 @@
<th scope="col" class="fw-normal d-none d-sm-table-cell" pngxSortable="matching_algorithm" [currentSortField]="sortField" [currentSortReverse]="sortReverse" (sort)="onSort($event)" i18n>Matching</th>
<th scope="col" class="fw-normal" pngxSortable="document_count" [currentSortField]="sortField" [currentSortReverse]="sortReverse" (sort)="onSort($event)" i18n>Document count</th>
@for (column of extraColumns; track column) {
<th scope="col" class="fw-normal" pngxSortable="{{column.key}}" [currentSortField]="sortField" [currentSortReverse]="sortReverse" (sort)="onSort($event)">{{column.name}}</th>
<th scope="col" class="fw-normal" [ngClass]="{ 'd-none d-sm-table-cell' : column.hideOnMobile }" pngxSortable="{{column.key}}" [currentSortField]="sortField" [currentSortReverse]="sortReverse" (sort)="onSort($event)">{{column.name}}</th>
}
<th scope="col" class="fw-normal" i18n>Actions</th>
</tr>
@@ -64,7 +64,7 @@
<td scope="row" class="d-none d-sm-table-cell">{{ getMatching(object) }}</td>
<td scope="row">{{ object.document_count }}</td>
@for (column of extraColumns; track column) {
<td scope="row">
<td scope="row" [ngClass]="{ 'd-none d-sm-table-cell' : column.hideOnMobile }">
@if (column.rendersHtml) {
<div [innerHtml]="column.valueFn.call(null, object) | safeHtml"></div>
} @else {

View File

@@ -44,6 +44,8 @@ export interface ManagementListColumn {
valueFn: any
rendersHtml?: boolean
hideOnMobile?: boolean
}
@Directive()

View File

@@ -11,6 +11,8 @@ import { PageHeaderComponent } from '../../common/page-header/page-header.compon
import { StoragePathListComponent } from './storage-path-list.component'
import { NgxBootstrapIconsModule, allIcons } from 'ngx-bootstrap-icons'
import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http'
import { SafeHtmlPipe } from 'src/app/pipes/safehtml.pipe'
import { StoragePath } from 'src/app/data/storage-path'
describe('StoragePathListComponent', () => {
let component: StoragePathListComponent
@@ -24,6 +26,7 @@ describe('StoragePathListComponent', () => {
SortableDirective,
PageHeaderComponent,
IfPermissionsDirective,
SafeHtmlPipe,
],
imports: [
NgbPaginationModule,
@@ -71,4 +74,15 @@ describe('StoragePathListComponent', () => {
'Do you really want to delete the storage path "StoragePath1"?'
)
})
it('should truncate path if necessary', () => {
const path: StoragePath = {
id: 1,
name: 'StoragePath1',
path: 'a'.repeat(100),
}
expect(component.extraColumns[0].valueFn(path)).toEqual(
`<code>${'a'.repeat(49)}...</code>`
)
})
})

View File

@@ -40,8 +40,10 @@ export class StoragePathListComponent extends ManagementListComponent<StoragePat
{
key: 'path',
name: $localize`Path`,
rendersHtml: true,
hideOnMobile: true,
valueFn: (c: StoragePath) => {
return c.path
return `<code>${c.path?.slice(0, 49)}${c.path?.length > 50 ? '...' : ''}</code>`
},
},
]