mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[AAE-9190] - ATTACH FILE: view file content directly by clicking (#7693)
* [AAE-9190] ATTACH FILE: view file content directly by clicking * unit test added * fix * delete comment * fix CR * fix * fix identation * delete extra spaces * change import in unit test * fix * fix space lint
This commit is contained in:
committed by
GitHub
parent
ad9a468b11
commit
1b027c3a86
@@ -18,8 +18,12 @@
|
|||||||
<ng-container matColumnDef="fileName">
|
<ng-container matColumnDef="fileName">
|
||||||
<th mat-header-cell *matHeaderCellDef>{{ 'FORM.FIELD.FILE_NAME' | translate }}</th>
|
<th mat-header-cell *matHeaderCellDef>{{ 'FORM.FIELD.FILE_NAME' | translate }}</th>
|
||||||
<td mat-cell *matCellDef="let element">
|
<td mat-cell *matCellDef="let element">
|
||||||
<span matLine id="{{'file-'+element?.id}}" role="button" tabindex="0" class="adf-file"
|
<span matLine id="{{'file-'+element?.id}}"
|
||||||
(click)="onRowClicked(element)">{{element.name}}</span>
|
role="button"
|
||||||
|
tabindex="0"
|
||||||
|
class="adf-file"
|
||||||
|
(click)="onAttachFileClicked(element)"
|
||||||
|
>{{element.name}}</span>
|
||||||
</td>
|
</td>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
|
@@ -4,6 +4,14 @@
|
|||||||
border: 1px solid var(--theme-border-color);
|
border: 1px solid var(--theme-border-color);
|
||||||
box-shadow: none;
|
box-shadow: none;
|
||||||
|
|
||||||
|
.adf-file {
|
||||||
|
cursor: pointer;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.adf-datatable-selected {
|
.adf-datatable-selected {
|
||||||
padding: 6px;
|
padding: 6px;
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,92 @@
|
|||||||
|
/*!
|
||||||
|
* @license
|
||||||
|
* Copyright 2019 Alfresco Software, Ltd.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { ProcessServiceCloudTestingModule } from '../../../../testing/process-service-cloud.testing.module';
|
||||||
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
|
import { FilePropertiesTableCloudComponent } from './file-properties-table-cloud.component';
|
||||||
|
import { By } from '@angular/platform-browser';
|
||||||
|
import { MatTableModule } from '@angular/material/table';
|
||||||
|
import { MatIconModule } from '@angular/material/icon';
|
||||||
|
|
||||||
|
describe('FilePropertiesTableCloudComponent', () => {
|
||||||
|
let widget: FilePropertiesTableCloudComponent;
|
||||||
|
let fixture: ComponentFixture<FilePropertiesTableCloudComponent>;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
imports: [
|
||||||
|
TranslateModule.forRoot(),
|
||||||
|
ProcessServiceCloudTestingModule,
|
||||||
|
MatTableModule,
|
||||||
|
MatIconModule
|
||||||
|
],
|
||||||
|
declarations: [FilePropertiesTableCloudComponent]
|
||||||
|
}).compileComponents();
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(FilePropertiesTableCloudComponent);
|
||||||
|
widget = fixture.componentInstance;
|
||||||
|
|
||||||
|
widget.uploadedFiles = [{
|
||||||
|
id: 'id',
|
||||||
|
name: 'download.png',
|
||||||
|
mimeType: 'image/png',
|
||||||
|
isExternal: true,
|
||||||
|
isFile: true,
|
||||||
|
isFolder: false,
|
||||||
|
content: {
|
||||||
|
mimeType: 'image/png'
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
id: 'id2',
|
||||||
|
name: 'download2.png',
|
||||||
|
mimeType: 'image/png',
|
||||||
|
isExternal: true,
|
||||||
|
isFile: true,
|
||||||
|
isFolder: false,
|
||||||
|
content: {
|
||||||
|
mimeType: 'image/png'
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
|
||||||
|
widget.hasFile = true;
|
||||||
|
|
||||||
|
widget.displayedColumns = [
|
||||||
|
'icon',
|
||||||
|
'fileName'
|
||||||
|
];
|
||||||
|
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
fixture.destroy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should emit attachFileClick', () => {
|
||||||
|
const attachFileClickSpy = spyOn(widget.attachFileClick, 'emit').and.callThrough();
|
||||||
|
|
||||||
|
const attachedFile = fixture.debugElement.query(By.css('#file-id')).nativeElement as HTMLButtonElement;
|
||||||
|
attachedFile.click();
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
expect(attachFileClickSpy).toHaveBeenCalledWith(widget.uploadedFiles[0]);
|
||||||
|
});
|
||||||
|
});
|
Reference in New Issue
Block a user