mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
#68 url file is a mandatory attribute
This commit is contained in:
@@ -104,11 +104,10 @@ bootstrap(MyDemoApp, [
|
|||||||
|
|
||||||
#### Options
|
#### Options
|
||||||
|
|
||||||
Attribute | Options | Default | Description
|
Attribute | Options | Default | Description | Mandatory
|
||||||
--- | --- | --- | ---
|
--- | --- | --- | ---
|
||||||
`urlFile` | *string* | | Url where load the file
|
`urlFile` | *string* | | Url where to load the file | mandatory
|
||||||
--- | --- | --- | ---
|
`overlayMode` | *boolean* | `false` | if true Show the Viewer full page over the present content |
|
||||||
`overlayMode` | *boolean* | `false` | if true Show the Viewer full page over the present content
|
|
||||||
|
|
||||||
|
|
||||||
## Build from sources
|
## Build from sources
|
||||||
|
@@ -36,13 +36,13 @@ describe('Ng2-alfresco-viewer', () => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('shadow overlay shoudl be present if overlay is true', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
it('shadow overlay should be present if overlay is true', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||||
return tcb
|
return tcb
|
||||||
.createAsync(ViewerComponent)
|
.createAsync(ViewerComponent)
|
||||||
.then((fixture) => {
|
.then((fixture) => {
|
||||||
let element = fixture.nativeElement;
|
let element = fixture.nativeElement;
|
||||||
let component = fixture.componentInstance;
|
let component = fixture.componentInstance;
|
||||||
|
component.urlFile = 'fake-url-file';
|
||||||
component.overlayMode = true;
|
component.overlayMode = true;
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
@@ -90,7 +90,7 @@ describe('Ng2-alfresco-viewer', () => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('Name File should be showed', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
it('Name File should be present', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||||
return tcb
|
return tcb
|
||||||
.createAsync(ViewerComponent)
|
.createAsync(ViewerComponent)
|
||||||
.then((fixture) => {
|
.then((fixture) => {
|
||||||
@@ -108,4 +108,18 @@ describe('Ng2-alfresco-viewer', () => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('Attribute', () => {
|
||||||
|
it('Url File should be mandatory', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||||
|
return tcb
|
||||||
|
.createAsync(ViewerComponent)
|
||||||
|
.then((fixture) => {
|
||||||
|
let component = fixture.componentInstance;
|
||||||
|
|
||||||
|
expect(() => {
|
||||||
|
component.urlFile = 'fake-url-file';
|
||||||
|
}).toThrow();
|
||||||
|
});
|
||||||
|
}));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@@ -40,6 +40,12 @@ export class ViewerComponent {
|
|||||||
displayPage: number;
|
displayPage: number;
|
||||||
totalPages: number;
|
totalPages: number;
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
if (!this.urlFile) {
|
||||||
|
throw new Error('Attribute urlFile is required');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ngOnChanges(changes: {[urlFile: string]: SimpleChange}) {
|
ngOnChanges(changes: {[urlFile: string]: SimpleChange}) {
|
||||||
if (this.urlFile) {
|
if (this.urlFile) {
|
||||||
this.nameFile = this.getPDFJS().getFilenameFromUrl(this.urlFile);
|
this.nameFile = this.getPDFJS().getFilenameFromUrl(this.urlFile);
|
||||||
@@ -53,8 +59,6 @@ export class ViewerComponent {
|
|||||||
this.displayPage = 1;
|
this.displayPage = 1;
|
||||||
this.loadPage(this.currentPdfDocument);
|
this.loadPage(this.currentPdfDocument);
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
console.log('Url File is a required value');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user