[AAE-15839] Fix file object input in viewers (#8804)

* [AAE-15839] Fix file object input in viewers

* [AAE-15839] Attend review comments

* [AAE-15839] Remove duplication

* [AAE-15839] Fix package-lock.json

* [AAE-15839] Fix package.json

* [AAE-15839] Remove duplication

* [AAE-15839] Remove duplication
This commit is contained in:
Pablo Martinez Garcia
2023-08-09 13:30:50 +02:00
committed by GitHub
parent 1f96c3452c
commit 04803c1815
6 changed files with 37 additions and 66 deletions

View File

@@ -15,10 +15,10 @@
* limitations under the License.
*/
import { Component, OnInit, ViewEncapsulation } from '@angular/core';
import { WidgetComponent, FormService } from '@alfresco/adf-core';
import { Component, ViewEncapsulation } from '@angular/core';
import { FormService, BaseViewerWidgetComponent } from '@alfresco/adf-core';
/* eslint-disable @angular-eslint/component-selector */
/* eslint-disable @angular-eslint/component-selector */
@Component({
selector: 'file-viewer-widget',
@@ -37,18 +37,8 @@ import { WidgetComponent, FormService } from '@alfresco/adf-core';
},
encapsulation: ViewEncapsulation.None
})
export class FileViewerWidgetComponent extends WidgetComponent implements OnInit {
export class FileViewerWidgetComponent extends BaseViewerWidgetComponent {
constructor(formService: FormService) {
super(formService);
}
ngOnInit(): void {
if (this.field &&
this.field.value &&
Array.isArray(this.field.value) &&
this.field.value.length) {
const file = this.field.value[0];
this.field.value = file.id;
}
}
}

View File

@@ -15,8 +15,8 @@
* limitations under the License.
*/
import { Component, EventEmitter, OnInit, Output, ViewEncapsulation } from '@angular/core';
import { FormService, WidgetComponent } from '@alfresco/adf-core';
import { Component, EventEmitter, Output, ViewEncapsulation } from '@angular/core';
import { BaseViewerWidgetComponent, FormService } from '@alfresco/adf-core';
import { Node } from '@alfresco/js-api';
/* eslint-disable @angular-eslint/component-selector */
@@ -38,7 +38,7 @@ import { Node } from '@alfresco/js-api';
},
encapsulation: ViewEncapsulation.None
})
export class PropertiesViewerWidgetComponent extends WidgetComponent implements OnInit {
export class PropertiesViewerWidgetComponent extends BaseViewerWidgetComponent {
@Output()
nodeContentLoaded: EventEmitter<Node> = new EventEmitter();
@@ -47,16 +47,6 @@ export class PropertiesViewerWidgetComponent extends WidgetComponent implements
super(formService);
}
ngOnInit(): void {
if (this.field &&
this.field.value &&
Array.isArray(this.field.value) &&
this.field.value.length) {
const file = this.field.value[0];
this.field.value = file.id;
}
}
onNodeContentLoaded(node: Node) {
this.nodeContentLoaded.emit(node);
}