mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-3794] Update individual rows without reloading DocumentList (#4213)
* reload table cells on node updates * update unit tests * update dynamic columns * fix value type * fix tests * update code as per review * update variable name * test fixes, core automation service * fix test
This commit is contained in:
committed by
Eugenio Romano
parent
e85e634685
commit
e75335a06d
@@ -23,7 +23,7 @@ import { ChartsModule } from 'ng2-charts';
|
||||
import { HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http';
|
||||
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
||||
|
||||
import { AppConfigService, TRANSLATION_PROVIDER, DebugAppConfigService, CoreModule } from '@alfresco/adf-core';
|
||||
import { AppConfigService, TRANSLATION_PROVIDER, DebugAppConfigService, CoreModule, CoreAutomationService } from '@alfresco/adf-core';
|
||||
import { ExtensionsModule } from '@alfresco/adf-extensions';
|
||||
import { AppComponent } from './app.component';
|
||||
import { MaterialModule } from './material.module';
|
||||
@@ -172,7 +172,8 @@ import { NestedMenuPositionDirective } from './components/app-layout/cloud/direc
|
||||
source: 'resources/lazy-loading'
|
||||
}
|
||||
},
|
||||
PreviewService
|
||||
PreviewService,
|
||||
CoreAutomationService
|
||||
],
|
||||
entryComponents: [
|
||||
VersionManagerDialogAdapterComponent,
|
||||
@@ -180,4 +181,8 @@ import { NestedMenuPositionDirective } from './components/app-layout/cloud/direc
|
||||
],
|
||||
bootstrap: [AppComponent]
|
||||
})
|
||||
export class AppModule {}
|
||||
export class AppModule {
|
||||
constructor(automationService: CoreAutomationService) {
|
||||
automationService.setup();
|
||||
}
|
||||
}
|
||||
|
@@ -214,10 +214,6 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
|
||||
@Optional() private route: ActivatedRoute,
|
||||
public authenticationService: AuthenticationService,
|
||||
public alfrescoApiService: AlfrescoApiService) {
|
||||
|
||||
this.alfrescoApiService.nodeUpdated.subscribe(() => {
|
||||
this.documentList.reload();
|
||||
});
|
||||
}
|
||||
|
||||
showFile(event) {
|
||||
|
@@ -15,13 +15,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { browser } from 'protractor';
|
||||
|
||||
import { LoginPage } from '../../pages/adf/loginPage';
|
||||
import { ViewerPage } from '../../pages/adf/viewerPage';
|
||||
import { MetadataViewPage } from '../../pages/adf/metadataViewPage';
|
||||
import { NavigationBarPage } from '../../pages/adf/navigationBarPage';
|
||||
import { ConfigEditorPage } from '../../pages/adf/configEditorPage';
|
||||
|
||||
import { AcsUserModel } from '../../models/ACS/acsUserModel';
|
||||
import { FileModel } from '../../models/ACS/fileModel';
|
||||
@@ -33,6 +30,7 @@ import { AlfrescoApiCompatibility as AlfrescoApi } from '@alfresco/js-api';
|
||||
import { UploadActions } from '../../actions/ACS/upload.actions';
|
||||
import { ContentServicesPage } from '../../pages/adf/contentServicesPage';
|
||||
import { check } from '../../util/material';
|
||||
import { setConfigField } from '../../proxy';
|
||||
|
||||
describe('Aspect oriented config', () => {
|
||||
|
||||
@@ -40,7 +38,6 @@ describe('Aspect oriented config', () => {
|
||||
const viewerPage = new ViewerPage();
|
||||
const metadataViewPage = new MetadataViewPage();
|
||||
const navigationBarPage = new NavigationBarPage();
|
||||
const configEditorPage = new ConfigEditorPage();
|
||||
const contentServicesPage = new ContentServicesPage();
|
||||
const modelOneName = 'modelOne', emptyAspectName = 'emptyAspect';
|
||||
const defaultModel = 'cm', defaultEmptyPropertiesAspect = 'taggable', aspectName = 'Taggable';
|
||||
@@ -53,7 +50,6 @@ describe('Aspect oriented config', () => {
|
||||
});
|
||||
|
||||
beforeAll(async (done) => {
|
||||
|
||||
const uploadActions = new UploadActions();
|
||||
|
||||
this.alfrescoJsApi = new AlfrescoApi({
|
||||
@@ -92,35 +88,33 @@ describe('Aspect oriented config', () => {
|
||||
done();
|
||||
});
|
||||
|
||||
beforeEach(async (done) => {
|
||||
navigationBarPage.clickConfigEditorButton();
|
||||
configEditorPage.clickClearButton();
|
||||
done();
|
||||
});
|
||||
|
||||
afterEach(async (done) => {
|
||||
viewerPage.clickCloseButton();
|
||||
contentServicesPage.checkAcsContainer();
|
||||
browser.refresh();
|
||||
contentServicesPage.checkAcsContainer();
|
||||
done();
|
||||
});
|
||||
|
||||
it('[C261117] Should be possible restrict the display properties of one an aspect', () => {
|
||||
it('[C261117] Should be possible restrict the display properties of one an aspect', async () => {
|
||||
|
||||
configEditorPage.enterBigConfigurationText('{ "presets": {' +
|
||||
' "default": [{' +
|
||||
' "title": "IMAGE",' +
|
||||
' "items": [' +
|
||||
' {' +
|
||||
' "aspect": "exif:exif", "properties": [ "exif:pixelXDimension", "exif:pixelYDimension", "exif:isoSpeedRatings"]' +
|
||||
' }' +
|
||||
' ]' +
|
||||
' }]' +
|
||||
' }' +
|
||||
' }');
|
||||
|
||||
configEditorPage.clickSaveButton();
|
||||
await setConfigField('content-metadata', JSON.stringify({
|
||||
presets: {
|
||||
default: [
|
||||
{
|
||||
title: 'IMAGE',
|
||||
items: [
|
||||
{
|
||||
aspect: 'exif:exif',
|
||||
properties: [
|
||||
'exif:pixelXDimension',
|
||||
'exif:pixelYDimension',
|
||||
'exif:isoSpeedRatings'
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}));
|
||||
|
||||
navigationBarPage.clickContentServicesButton();
|
||||
|
||||
@@ -141,19 +135,17 @@ describe('Aspect oriented config', () => {
|
||||
metadataViewPage.checkPropertyIsVisible('properties.exif:isoSpeedRatings', 'textitem');
|
||||
});
|
||||
|
||||
it('[C260185] Should ignore not existing aspect when present in the configuration', () => {
|
||||
it('[C260185] Should ignore not existing aspect when present in the configuration', async () => {
|
||||
|
||||
configEditorPage.enterBigConfigurationText(' {' +
|
||||
' "presets": {' +
|
||||
' "default": {' +
|
||||
' "exif:exif": "*",' +
|
||||
' "cm:versionable": "*",' +
|
||||
' "not:exists": "*"' +
|
||||
' }' +
|
||||
' }' +
|
||||
' }');
|
||||
|
||||
configEditorPage.clickSaveButton();
|
||||
await setConfigField('content-metadata', JSON.stringify({
|
||||
presets: {
|
||||
default: {
|
||||
'exif:exif': '*',
|
||||
'cm:versionable': '*',
|
||||
'not:exists': '*'
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
||||
navigationBarPage.clickContentServicesButton();
|
||||
|
||||
@@ -170,11 +162,9 @@ describe('Aspect oriented config', () => {
|
||||
metadataViewPage.checkMetadataGroupIsNotPresent('exists');
|
||||
});
|
||||
|
||||
it('[C260183] Should show all the aspect if the content-metadata configuration is NOT provided', () => {
|
||||
it('[C260183] Should show all the aspect if the content-metadata configuration is NOT provided', async () => {
|
||||
|
||||
configEditorPage.enterBigConfigurationText('{ }');
|
||||
|
||||
configEditorPage.clickSaveButton();
|
||||
await setConfigField('content-metadata', '{}');
|
||||
|
||||
navigationBarPage.clickContentServicesButton();
|
||||
|
||||
@@ -190,15 +180,13 @@ describe('Aspect oriented config', () => {
|
||||
metadataViewPage.checkMetadataGroupIsPresent('Versionable');
|
||||
});
|
||||
|
||||
it('[C260182] Should show all the aspects if the default configuration contains the star symbol', () => {
|
||||
it('[C260182] Should show all the aspects if the default configuration contains the star symbol', async () => {
|
||||
|
||||
configEditorPage.enterBigConfigurationText('{' +
|
||||
' "presets": {' +
|
||||
' "default": "*"' +
|
||||
' }' +
|
||||
'}');
|
||||
|
||||
configEditorPage.clickSaveButton();
|
||||
await setConfigField('content-metadata', JSON.stringify({
|
||||
presets: {
|
||||
default: '*'
|
||||
}
|
||||
}));
|
||||
|
||||
navigationBarPage.clickContentServicesButton();
|
||||
|
||||
@@ -215,9 +203,9 @@ describe('Aspect oriented config', () => {
|
||||
metadataViewPage.checkMetadataGroupIsPresent('Versionable');
|
||||
});
|
||||
|
||||
it('[C268899] Should be possible use a Translation key as Title of a metadata group', () => {
|
||||
it('[C268899] Should be possible use a Translation key as Title of a metadata group', async () => {
|
||||
|
||||
configEditorPage.enterBigConfigurationText('{' +
|
||||
await setConfigField('content-metadata', '{' +
|
||||
' "presets": {' +
|
||||
' "default": [' +
|
||||
' {' +
|
||||
@@ -242,8 +230,6 @@ describe('Aspect oriented config', () => {
|
||||
' }' +
|
||||
'}');
|
||||
|
||||
configEditorPage.clickSaveButton();
|
||||
|
||||
navigationBarPage.clickContentServicesButton();
|
||||
|
||||
viewerPage.viewFile(pngFileModel.name);
|
||||
@@ -262,9 +248,9 @@ describe('Aspect oriented config', () => {
|
||||
|
||||
});
|
||||
|
||||
it('[C279968] Should be possible use a custom preset', () => {
|
||||
it('[C279968] Should be possible use a custom preset', async () => {
|
||||
|
||||
configEditorPage.enterBigConfigurationText('{' +
|
||||
await setConfigField('content-metadata', '{' +
|
||||
' "presets": {' +
|
||||
' "custom-preset": {' +
|
||||
' "exif:exif": "*",' +
|
||||
@@ -273,8 +259,6 @@ describe('Aspect oriented config', () => {
|
||||
' }' +
|
||||
'}');
|
||||
|
||||
configEditorPage.clickSaveButton();
|
||||
|
||||
navigationBarPage.clickContentServicesButton();
|
||||
|
||||
viewerPage.viewFile(pngFileModel.name);
|
||||
@@ -294,9 +278,9 @@ describe('Aspect oriented config', () => {
|
||||
metadataViewPage.checkMetadataGroupIsPresent('Versionable');
|
||||
});
|
||||
|
||||
it('[C299186] The aspect without properties is not displayed', () => {
|
||||
it('[C299186] The aspect without properties is not displayed', async () => {
|
||||
|
||||
configEditorPage.enterBigConfigurationText('{' +
|
||||
await setConfigField('content-metadata', '{' +
|
||||
' "presets": { "' + modelOneName +
|
||||
' ": { "' + modelOneName + ':' + emptyAspectName +
|
||||
' ":"*"' +
|
||||
@@ -304,8 +288,6 @@ describe('Aspect oriented config', () => {
|
||||
' }' +
|
||||
'}');
|
||||
|
||||
configEditorPage.clickSaveButton();
|
||||
|
||||
navigationBarPage.clickContentServicesButton();
|
||||
|
||||
viewerPage.viewFile(pngFileModel.name);
|
||||
@@ -319,9 +301,9 @@ describe('Aspect oriented config', () => {
|
||||
metadataViewPage.checkMetadataGroupIsNotPresent(emptyAspectName);
|
||||
});
|
||||
|
||||
it('[C299187] The aspect with empty properties is displayed when edit', () => {
|
||||
it('[C299187] The aspect with empty properties is displayed when edit', async () => {
|
||||
|
||||
configEditorPage.enterBigConfigurationText('{' +
|
||||
await setConfigField('content-metadata', '{' +
|
||||
' "presets": { "' + defaultModel +
|
||||
' ": { "' + defaultModel + ':' + defaultEmptyPropertiesAspect +
|
||||
' ":"*"' +
|
||||
@@ -329,8 +311,6 @@ describe('Aspect oriented config', () => {
|
||||
' }' +
|
||||
'}');
|
||||
|
||||
configEditorPage.clickSaveButton();
|
||||
|
||||
navigationBarPage.clickContentServicesButton();
|
||||
|
||||
viewerPage.viewFile(pngFileModel.name);
|
||||
|
@@ -32,6 +32,7 @@ import dateFormat = require('dateformat');
|
||||
import { AlfrescoApiCompatibility as AlfrescoApi } from '@alfresco/js-api';
|
||||
import { UploadActions } from '../../actions/ACS/upload.actions';
|
||||
import { NavigationBarPage } from '../../pages/adf/navigationBarPage';
|
||||
import { setConfigField } from '../../proxy';
|
||||
|
||||
describe('Metadata component', () => {
|
||||
|
||||
@@ -95,6 +96,16 @@ describe('Metadata component', () => {
|
||||
|
||||
describe('Viewer Metadata', () => {
|
||||
|
||||
beforeAll(async() => {
|
||||
await setConfigField('content-metadata', JSON.stringify({
|
||||
presets: {
|
||||
default: {
|
||||
'exif:exif': '*'
|
||||
}
|
||||
}
|
||||
}));
|
||||
});
|
||||
|
||||
beforeEach(async (done) => {
|
||||
viewerPage.viewFile(pngFileModel.name);
|
||||
viewerPage.checkFileIsLoaded();
|
||||
@@ -194,9 +205,10 @@ describe('Metadata component', () => {
|
||||
await metadataViewPage.clickUpdatePropertyIcon('properties.cm:description');
|
||||
expect(metadataViewPage.getPropertyText('properties.cm:description')).toEqual('example description');
|
||||
|
||||
viewerPage.clickCloseButton();
|
||||
await viewerPage.clickCloseButton();
|
||||
contentServicesPage.waitForTableBody();
|
||||
|
||||
viewerPage.viewFile('exampleText.png');
|
||||
viewerPage.viewFile(resources.Files.ADF_DOCUMENTS.PNG.file_name);
|
||||
viewerPage.clickInfoButton();
|
||||
viewerPage.checkInfoSideBarIsDisplayed();
|
||||
metadataViewPage.clickOnPropertiesTab();
|
||||
@@ -260,6 +272,7 @@ describe('Metadata component', () => {
|
||||
|
||||
browser.controlFlow().execute(async () => {
|
||||
await metadataViewPage.editIconClick();
|
||||
|
||||
metadataViewPage.clickEditPropertyIcons('properties.exif:software');
|
||||
metadataViewPage.enterPropertyText('properties.exif:software', 'test custom text software');
|
||||
await metadataViewPage.clickUpdatePropertyIcon('properties.exif:software');
|
||||
@@ -303,6 +316,7 @@ describe('Metadata component', () => {
|
||||
|
||||
browser.controlFlow().execute(async () => {
|
||||
await metadataViewPage.editIconClick();
|
||||
|
||||
metadataViewPage.clickEditPropertyIcons('name');
|
||||
metadataViewPage.enterPropertyText('name', 'newnameFolder');
|
||||
await metadataViewPage.clickClearPropertyIcon('name');
|
||||
|
24
e2e/proxy.ts
Normal file
24
e2e/proxy.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
/*!
|
||||
* @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 { browser } from 'protractor';
|
||||
|
||||
export async function setConfigField(field: string, value: string) {
|
||||
return browser.executeScript(
|
||||
`window.adf.setConfigField('${field}', '${value}');`
|
||||
);
|
||||
}
|
@@ -16,75 +16,112 @@
|
||||
*/
|
||||
|
||||
import {
|
||||
Component,
|
||||
ChangeDetectionStrategy,
|
||||
ViewEncapsulation,
|
||||
OnInit,
|
||||
Input,
|
||||
ElementRef
|
||||
Component,
|
||||
ChangeDetectionStrategy,
|
||||
ViewEncapsulation,
|
||||
OnInit,
|
||||
Input,
|
||||
ElementRef,
|
||||
OnDestroy
|
||||
} from '@angular/core';
|
||||
import { NodeEntry } from '@alfresco/js-api';
|
||||
import { NodeEntry, Node, Site } from '@alfresco/js-api';
|
||||
import { ShareDataRow } from '../../data/share-data-row.model';
|
||||
import { AlfrescoApiService } from '@alfresco/adf-core';
|
||||
import { BehaviorSubject, Subscription } from 'rxjs';
|
||||
|
||||
@Component({
|
||||
selector: 'adf-library-name-column',
|
||||
template: `
|
||||
<span title="{{ displayTooltip }}" (click)="onClick()">
|
||||
{{ displayText }}
|
||||
</span>
|
||||
`,
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
encapsulation: ViewEncapsulation.None,
|
||||
host: { class: 'adf-datatable-cell adf-datatable-link adf-library-name-column' }
|
||||
selector: 'adf-library-name-column',
|
||||
template: `
|
||||
<span title="{{ displayTooltip$ | async }}" (click)="onClick()">
|
||||
{{ displayText$ | async }}
|
||||
</span>
|
||||
`,
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
encapsulation: ViewEncapsulation.None,
|
||||
host: {
|
||||
class: 'adf-datatable-cell adf-datatable-link adf-library-name-column'
|
||||
}
|
||||
})
|
||||
export class LibraryNameColumnComponent implements OnInit {
|
||||
@Input()
|
||||
context: any;
|
||||
export class LibraryNameColumnComponent implements OnInit, OnDestroy {
|
||||
@Input()
|
||||
context: any;
|
||||
|
||||
displayTooltip: string;
|
||||
displayText: string;
|
||||
node: NodeEntry;
|
||||
displayTooltip$ = new BehaviorSubject<string>('');
|
||||
displayText$ = new BehaviorSubject<string>('');
|
||||
node: NodeEntry;
|
||||
|
||||
constructor(private element: ElementRef) {}
|
||||
private sub: Subscription;
|
||||
|
||||
ngOnInit() {
|
||||
this.node = this.context.row.node;
|
||||
const rows: Array<ShareDataRow> = this.context.data.rows || [];
|
||||
if (this.node && this.node.entry) {
|
||||
this.displayText = this.makeLibraryTitle(this.node.entry, rows);
|
||||
this.displayTooltip = this.makeLibraryTooltip(this.node.entry);
|
||||
constructor(
|
||||
private element: ElementRef,
|
||||
private alfrescoApiService: AlfrescoApiService
|
||||
) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.updateValue();
|
||||
|
||||
this.sub = this.alfrescoApiService.nodeUpdated.subscribe(
|
||||
(node: Node) => {
|
||||
const row: ShareDataRow = this.context.row;
|
||||
if (row) {
|
||||
const { entry } = row.node;
|
||||
|
||||
if (entry === node) {
|
||||
row.node = { entry };
|
||||
this.updateValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
onClick() {
|
||||
this.element.nativeElement.dispatchEvent(
|
||||
new CustomEvent('name-click', {
|
||||
bubbles: true,
|
||||
detail: {
|
||||
node: this.node
|
||||
protected updateValue() {
|
||||
this.node = this.context.row.node;
|
||||
const rows: Array<ShareDataRow> = this.context.data.rows || [];
|
||||
if (this.node && this.node.entry) {
|
||||
this.displayText$.next(
|
||||
this.makeLibraryTitle(<any> this.node.entry, rows)
|
||||
);
|
||||
this.displayTooltip$.next(this.makeLibraryTooltip(this.node.entry));
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
makeLibraryTooltip(library: any): string {
|
||||
const { description, title } = library;
|
||||
|
||||
return description || title || '';
|
||||
}
|
||||
|
||||
makeLibraryTitle(library: any, rows: Array<ShareDataRow>): string {
|
||||
const entries = rows.map((r: ShareDataRow) => r.node.entry);
|
||||
const { title, id } = library;
|
||||
|
||||
let isDuplicate = false;
|
||||
|
||||
if (entries) {
|
||||
isDuplicate = entries.some((entry: any) => {
|
||||
return entry.id !== id && entry.title === title;
|
||||
});
|
||||
}
|
||||
|
||||
return isDuplicate ? `${title} (${id})` : `${title}`;
|
||||
}
|
||||
onClick() {
|
||||
this.element.nativeElement.dispatchEvent(
|
||||
new CustomEvent('name-click', {
|
||||
bubbles: true,
|
||||
detail: {
|
||||
node: this.node
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
makeLibraryTooltip(library: any): string {
|
||||
const { description, title } = library;
|
||||
|
||||
return description || title || '';
|
||||
}
|
||||
|
||||
makeLibraryTitle(library: Site, rows: Array<ShareDataRow>): string {
|
||||
const entries = rows.map((row: ShareDataRow) => row.node.entry);
|
||||
const { title, id } = library;
|
||||
|
||||
let isDuplicate = false;
|
||||
|
||||
if (entries) {
|
||||
isDuplicate = entries.some((entry: any) => {
|
||||
return entry.id !== id && entry.title === title;
|
||||
});
|
||||
}
|
||||
|
||||
return isDuplicate ? `${title} (${id})` : `${title}`;
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
if (this.sub) {
|
||||
this.sub.unsubscribe();
|
||||
this.sub = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -39,39 +39,59 @@ describe('LibraryNameColumnComponent', () => {
|
||||
component.context = {
|
||||
row: { node: { entry: { role: 'SiteManager' } } }
|
||||
};
|
||||
|
||||
let value = '';
|
||||
component.displayText$.subscribe((val) => value = val);
|
||||
|
||||
fixture.detectChanges();
|
||||
expect(component.displayText).toBe('LIBRARY.ROLE.MANAGER');
|
||||
expect(value).toBe('LIBRARY.ROLE.MANAGER');
|
||||
});
|
||||
|
||||
it('should render Collaborator', () => {
|
||||
component.context = {
|
||||
row: { node: { entry: { role: 'SiteCollaborator' } } }
|
||||
};
|
||||
|
||||
let value = '';
|
||||
component.displayText$.subscribe((val) => value = val);
|
||||
|
||||
fixture.detectChanges();
|
||||
expect(component.displayText).toBe('LIBRARY.ROLE.COLLABORATOR');
|
||||
expect(value).toBe('LIBRARY.ROLE.COLLABORATOR');
|
||||
});
|
||||
|
||||
it('should render Contributor', () => {
|
||||
component.context = {
|
||||
row: { node: { entry: { role: 'SiteContributor' } } }
|
||||
};
|
||||
|
||||
let value = '';
|
||||
component.displayText$.subscribe((val) => value = val);
|
||||
|
||||
fixture.detectChanges();
|
||||
expect(component.displayText).toBe('LIBRARY.ROLE.CONTRIBUTOR');
|
||||
expect(value).toBe('LIBRARY.ROLE.CONTRIBUTOR');
|
||||
});
|
||||
|
||||
it('should render Consumer', () => {
|
||||
component.context = {
|
||||
row: { node: { entry: { role: 'SiteConsumer' } } }
|
||||
};
|
||||
|
||||
let value = '';
|
||||
component.displayText$.subscribe((val) => value = val);
|
||||
|
||||
fixture.detectChanges();
|
||||
expect(component.displayText).toBe('LIBRARY.ROLE.CONSUMER');
|
||||
expect(value).toBe('LIBRARY.ROLE.CONSUMER');
|
||||
});
|
||||
|
||||
it('should not render text for unknown', () => {
|
||||
component.context = {
|
||||
row: { node: { entry: { role: 'ROLE' } } }
|
||||
};
|
||||
|
||||
let value = '';
|
||||
component.displayText$.subscribe((val) => value = val);
|
||||
|
||||
fixture.detectChanges();
|
||||
expect(component.displayText).toBe('');
|
||||
expect(value).toBe('');
|
||||
});
|
||||
});
|
||||
|
@@ -15,44 +15,84 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Component, OnInit, Input } from '@angular/core';
|
||||
import {
|
||||
Component,
|
||||
OnInit,
|
||||
Input,
|
||||
ChangeDetectionStrategy,
|
||||
ViewEncapsulation,
|
||||
OnDestroy
|
||||
} from '@angular/core';
|
||||
import { Subscription, BehaviorSubject } from 'rxjs';
|
||||
import { AlfrescoApiService } from '@alfresco/adf-core';
|
||||
import { Node, SiteEntry, Site } from '@alfresco/js-api';
|
||||
import { ShareDataRow } from '../../data/share-data-row.model';
|
||||
|
||||
@Component({
|
||||
selector: 'adf-library-role-column',
|
||||
template: `
|
||||
<span title="{{ displayText | translate }}">
|
||||
{{ displayText | translate }}
|
||||
</span>
|
||||
`,
|
||||
host: { class: 'adf-library-role-column' }
|
||||
selector: 'adf-library-role-column',
|
||||
template: `
|
||||
<span title="{{ (displayText$ | async) | translate }}">
|
||||
{{ (displayText$ | async) | translate }}
|
||||
</span>
|
||||
`,
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
encapsulation: ViewEncapsulation.None,
|
||||
host: { class: 'adf-library-role-column' }
|
||||
})
|
||||
export class LibraryRoleColumnComponent implements OnInit {
|
||||
@Input()
|
||||
context: any;
|
||||
export class LibraryRoleColumnComponent implements OnInit, OnDestroy {
|
||||
@Input()
|
||||
context: any;
|
||||
|
||||
displayText: string;
|
||||
displayText$ = new BehaviorSubject<string>('');
|
||||
|
||||
ngOnInit() {
|
||||
const node = this.context.row.node;
|
||||
if (node && node.entry) {
|
||||
const role: string = node.entry.role;
|
||||
switch (role) {
|
||||
case 'SiteManager':
|
||||
this.displayText = 'LIBRARY.ROLE.MANAGER';
|
||||
break;
|
||||
case 'SiteCollaborator':
|
||||
this.displayText = 'LIBRARY.ROLE.COLLABORATOR';
|
||||
break;
|
||||
case 'SiteContributor':
|
||||
this.displayText = 'LIBRARY.ROLE.CONTRIBUTOR';
|
||||
break;
|
||||
case 'SiteConsumer':
|
||||
this.displayText = 'LIBRARY.ROLE.CONSUMER';
|
||||
break;
|
||||
default:
|
||||
this.displayText = '';
|
||||
break;
|
||||
}
|
||||
private sub: Subscription;
|
||||
|
||||
constructor(private api: AlfrescoApiService) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.updateValue();
|
||||
|
||||
this.sub = this.api.nodeUpdated.subscribe((node: Node) => {
|
||||
const row: ShareDataRow = this.context.row;
|
||||
if (row) {
|
||||
const { entry } = row.node;
|
||||
|
||||
if (entry === node) {
|
||||
row.node = { entry };
|
||||
this.updateValue();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected updateValue() {
|
||||
const node: SiteEntry = this.context.row.node;
|
||||
if (node && node.entry) {
|
||||
const role: string = node.entry.role;
|
||||
switch (role) {
|
||||
case Site.RoleEnum.SiteManager:
|
||||
this.displayText$.next('LIBRARY.ROLE.MANAGER');
|
||||
break;
|
||||
case Site.RoleEnum.SiteCollaborator:
|
||||
this.displayText$.next('LIBRARY.ROLE.COLLABORATOR');
|
||||
break;
|
||||
case Site.RoleEnum.SiteContributor:
|
||||
this.displayText$.next('LIBRARY.ROLE.CONTRIBUTOR');
|
||||
break;
|
||||
case Site.RoleEnum.SiteConsumer:
|
||||
this.displayText$.next('LIBRARY.ROLE.CONSUMER');
|
||||
break;
|
||||
default:
|
||||
this.displayText$.next('');
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
if (this.sub) {
|
||||
this.sub.unsubscribe();
|
||||
this.sub = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -15,42 +15,73 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Component, Input, OnInit } from '@angular/core';
|
||||
import { Component, Input, OnInit, OnDestroy } from '@angular/core';
|
||||
import { AlfrescoApiService } from '@alfresco/adf-core';
|
||||
import { Subscription, BehaviorSubject } from 'rxjs';
|
||||
import { Node, Site, SiteEntry } from '@alfresco/js-api';
|
||||
import { ShareDataRow } from '../../data/share-data-row.model';
|
||||
|
||||
@Component({
|
||||
selector: 'adf-library-status-column',
|
||||
template: `
|
||||
<span title="{{ displayText | translate }}">
|
||||
{{ displayText | translate }}
|
||||
</span>
|
||||
`,
|
||||
host: { class: 'adf-library-status-column' }
|
||||
selector: 'adf-library-status-column',
|
||||
template: `
|
||||
<span title="{{ (displayText$ | async) | translate }}">
|
||||
{{ (displayText$ | async) | translate }}
|
||||
</span>
|
||||
`,
|
||||
host: { class: 'adf-library-status-column' }
|
||||
})
|
||||
export class LibraryStatusColumnComponent implements OnInit {
|
||||
@Input()
|
||||
context: any;
|
||||
export class LibraryStatusColumnComponent implements OnInit, OnDestroy {
|
||||
@Input()
|
||||
context: any;
|
||||
|
||||
displayText: string;
|
||||
displayText$ = new BehaviorSubject<string>('');
|
||||
|
||||
ngOnInit() {
|
||||
const node = this.context.row.node;
|
||||
if (node && node.entry) {
|
||||
const visibility: string = node.entry.visibility;
|
||||
private sub: Subscription;
|
||||
|
||||
switch (visibility.toUpperCase()) {
|
||||
case 'PUBLIC':
|
||||
this.displayText = 'LIBRARY.VISIBILITY.PUBLIC';
|
||||
break;
|
||||
case 'PRIVATE':
|
||||
this.displayText = 'LIBRARY.VISIBILITY.PRIVATE';
|
||||
break;
|
||||
case 'MODERATED':
|
||||
this.displayText = 'LIBRARY.VISIBILITY.MODERATED';
|
||||
break;
|
||||
default:
|
||||
this.displayText = 'UNKNOWN';
|
||||
break;
|
||||
}
|
||||
constructor(private api: AlfrescoApiService) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.updateValue();
|
||||
|
||||
this.sub = this.api.nodeUpdated.subscribe((node: Node) => {
|
||||
const row: ShareDataRow = this.context.row;
|
||||
if (row) {
|
||||
const { entry } = row.node;
|
||||
|
||||
if (entry === node) {
|
||||
row.node = { entry };
|
||||
this.updateValue();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected updateValue() {
|
||||
const node: SiteEntry = this.context.row.node;
|
||||
if (node && node.entry) {
|
||||
const visibility: string = node.entry.visibility;
|
||||
|
||||
switch (visibility) {
|
||||
case Site.VisibilityEnum.PUBLIC:
|
||||
this.displayText$.next('LIBRARY.VISIBILITY.PUBLIC');
|
||||
break;
|
||||
case Site.VisibilityEnum.PRIVATE:
|
||||
this.displayText$.next('LIBRARY.VISIBILITY.PRIVATE');
|
||||
break;
|
||||
case Site.VisibilityEnum.MODERATED:
|
||||
this.displayText$.next('LIBRARY.VISIBILITY.MODERATED');
|
||||
break;
|
||||
default:
|
||||
this.displayText$.next('UNKNOWN');
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
if (this.sub) {
|
||||
this.sub.unsubscribe();
|
||||
this.sub = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -16,50 +16,81 @@
|
||||
*/
|
||||
|
||||
import {
|
||||
Component,
|
||||
Input,
|
||||
OnInit,
|
||||
ChangeDetectionStrategy,
|
||||
ViewEncapsulation,
|
||||
ElementRef
|
||||
Component,
|
||||
Input,
|
||||
OnInit,
|
||||
ChangeDetectionStrategy,
|
||||
ViewEncapsulation,
|
||||
ElementRef,
|
||||
OnDestroy
|
||||
} from '@angular/core';
|
||||
import { NodeEntry } from '@alfresco/js-api';
|
||||
import { BehaviorSubject, Subscription } from 'rxjs';
|
||||
import { AlfrescoApiService } from '@alfresco/adf-core';
|
||||
import { Node } from '@alfresco/js-api';
|
||||
import { ShareDataRow } from '../../data/share-data-row.model';
|
||||
|
||||
@Component({
|
||||
selector: 'adf-name-column',
|
||||
template: `
|
||||
<span title="{{ node | adfNodeNameTooltip }}" (click)="onClick()">
|
||||
{{ displayText }}
|
||||
</span>
|
||||
`,
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
encapsulation: ViewEncapsulation.None,
|
||||
host: { class: 'adf-datatable-cell adf-datatable-link adf-name-column' }
|
||||
selector: 'adf-name-column',
|
||||
template: `
|
||||
<span title="{{ node | adfNodeNameTooltip }}" (click)="onClick()">
|
||||
{{ displayText$ | async }}
|
||||
</span>
|
||||
`,
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
encapsulation: ViewEncapsulation.None,
|
||||
host: { class: 'adf-datatable-cell adf-datatable-link adf-name-column' }
|
||||
})
|
||||
export class NameColumnComponent implements OnInit {
|
||||
@Input()
|
||||
context: any;
|
||||
export class NameColumnComponent implements OnInit, OnDestroy {
|
||||
@Input()
|
||||
context: any;
|
||||
|
||||
displayText: string;
|
||||
node: NodeEntry;
|
||||
displayText$ = new BehaviorSubject<string>('');
|
||||
node: NodeEntry;
|
||||
|
||||
constructor(private element: ElementRef) {}
|
||||
private sub: Subscription;
|
||||
|
||||
ngOnInit() {
|
||||
this.node = this.context.row.node;
|
||||
if (this.node && this.node.entry) {
|
||||
this.displayText = this.node.entry.name || this.node.entry.id;
|
||||
constructor(private element: ElementRef, private alfrescoApiService: AlfrescoApiService) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.updateValue();
|
||||
|
||||
this.sub = this.alfrescoApiService.nodeUpdated.subscribe((node: Node) => {
|
||||
const row: ShareDataRow = this.context.row;
|
||||
if (row) {
|
||||
const { entry } = row.node;
|
||||
|
||||
if (entry === node) {
|
||||
row.node = { entry };
|
||||
this.updateValue();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
onClick() {
|
||||
this.element.nativeElement.dispatchEvent(
|
||||
new CustomEvent('name-click', {
|
||||
bubbles: true,
|
||||
detail: {
|
||||
node: this.node
|
||||
protected updateValue() {
|
||||
this.node = this.context.row.node;
|
||||
|
||||
if (this.node && this.node.entry) {
|
||||
this.displayText$.next(this.node.entry.name || this.node.entry.id);
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
onClick() {
|
||||
this.element.nativeElement.dispatchEvent(
|
||||
new CustomEvent('name-click', {
|
||||
bubbles: true,
|
||||
detail: {
|
||||
node: this.node
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
if (this.sub) {
|
||||
this.sub.unsubscribe();
|
||||
this.sub = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -32,6 +32,11 @@ export class ShareDataRow implements DataRow {
|
||||
return this.obj;
|
||||
}
|
||||
|
||||
set node(value: NodeEntry) {
|
||||
this.obj = value;
|
||||
this.cache = {};
|
||||
}
|
||||
|
||||
constructor(private obj: NodeEntry,
|
||||
private contentService: ContentService,
|
||||
private permissionsStyle: PermissionStyleModel[],
|
||||
|
@@ -16,15 +16,18 @@
|
||||
*/
|
||||
|
||||
import { DateCellComponent } from './date-cell.component';
|
||||
import { Subject } from 'rxjs';
|
||||
|
||||
describe('DataTableCellComponent', () => {
|
||||
it('should use medium format by default', () => {
|
||||
const component = new DateCellComponent(null);
|
||||
const component = new DateCellComponent(null, null);
|
||||
expect(component.format).toBe('medium');
|
||||
});
|
||||
|
||||
it('should use column format', () => {
|
||||
const component = new DateCellComponent(null);
|
||||
const component = new DateCellComponent(null, <any> {
|
||||
nodeUpdated: new Subject<any>()
|
||||
});
|
||||
component.column = {
|
||||
key: 'created',
|
||||
type: 'date',
|
||||
|
@@ -15,23 +15,38 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { ChangeDetectionStrategy, Component, Input, OnInit, ViewEncapsulation } from '@angular/core';
|
||||
import {
|
||||
ChangeDetectionStrategy,
|
||||
Component,
|
||||
Input,
|
||||
OnInit,
|
||||
ViewEncapsulation,
|
||||
OnDestroy
|
||||
} from '@angular/core';
|
||||
import { DataColumn } from '../../data/data-column.model';
|
||||
import { DataRow } from '../../data/data-row.model';
|
||||
import { DataTableAdapter } from '../../data/datatable-adapter';
|
||||
import { AlfrescoApiService } from '../../../services/alfresco-api.service';
|
||||
import { Subscription, BehaviorSubject } from 'rxjs';
|
||||
import { Node } from '@alfresco/js-api';
|
||||
|
||||
@Component({
|
||||
selector: 'adf-datatable-cell',
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
template: `
|
||||
<ng-container>
|
||||
<span [attr.aria-label]="value" [title]="tooltip" class="adf-datatable-cell-value">{{value}}</span>
|
||||
</ng-container>`,
|
||||
<span
|
||||
[attr.aria-label]="value$ | async"
|
||||
[title]="tooltip"
|
||||
class="adf-datatable-cell-value"
|
||||
>{{ value$ | async }}</span
|
||||
>
|
||||
</ng-container>
|
||||
`,
|
||||
encapsulation: ViewEncapsulation.None,
|
||||
host: { class: 'adf-datatable-cell' }
|
||||
})
|
||||
export class DataTableCellComponent implements OnInit {
|
||||
|
||||
export class DataTableCellComponent implements OnInit, OnDestroy {
|
||||
@Input()
|
||||
data: DataTableAdapter;
|
||||
|
||||
@@ -41,20 +56,46 @@ export class DataTableCellComponent implements OnInit {
|
||||
@Input()
|
||||
row: DataRow;
|
||||
|
||||
@Input()
|
||||
value: any;
|
||||
value$ = new BehaviorSubject<any>('');
|
||||
|
||||
@Input()
|
||||
tooltip: string;
|
||||
|
||||
private sub: Subscription;
|
||||
|
||||
constructor(protected alfrescoApiService: AlfrescoApiService) {}
|
||||
|
||||
ngOnInit() {
|
||||
if (!this.value && this.column && this.column.key && this.row && this.data) {
|
||||
this.value = this.data.getValue(this.row, this.column);
|
||||
this.updateValue();
|
||||
|
||||
this.sub = this.alfrescoApiService.nodeUpdated.subscribe((node: Node) => {
|
||||
if (this.row) {
|
||||
const { entry } = this.row['node'];
|
||||
|
||||
if (entry === node) {
|
||||
this.row['node'] = { entry };
|
||||
this.updateValue();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected updateValue() {
|
||||
if (this.column && this.column.key && this.row && this.data) {
|
||||
const value = this.data.getValue(this.row, this.column);
|
||||
|
||||
this.value$.next(value);
|
||||
|
||||
if (!this.tooltip) {
|
||||
this.tooltip = this.value;
|
||||
this.tooltip = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
if (this.sub) {
|
||||
this.sub.unsubscribe();
|
||||
this.sub = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -21,19 +21,27 @@ import {
|
||||
UserPreferencesService,
|
||||
UserPreferenceValues
|
||||
} from '../../../services/user-preferences.service';
|
||||
import { AlfrescoApiService } from '../../../services/alfresco-api.service';
|
||||
|
||||
@Component({
|
||||
selector: 'adf-date-cell',
|
||||
|
||||
template: `
|
||||
<ng-container>
|
||||
<span title="{{ tooltip | date:'medium' }}" *ngIf="format === 'timeAgo' else standard_date" [attr.aria-label]=" value | adfTimeAgo: currentLocale ">
|
||||
{{ value | adfTimeAgo: currentLocale }}
|
||||
<span
|
||||
[attr.aria-label]="value$ | async | adfTimeAgo: currentLocale"
|
||||
title="{{ tooltip | date: 'medium' }}"
|
||||
*ngIf="format === 'timeAgo'; else standard_date"
|
||||
>
|
||||
{{ value$ | async | adfTimeAgo: currentLocale }}
|
||||
</span>
|
||||
</ng-container>
|
||||
<ng-template #standard_date>
|
||||
<span [attr.aria-label]=" value | date:format " title="{{ tooltip | date:format }}">
|
||||
{{ value | date:format }}
|
||||
<span
|
||||
title="{{ tooltip | date: format }}"
|
||||
[attr.aria-label]="value$ | async | date: format"
|
||||
>
|
||||
{{ value$ | async | date: format }}
|
||||
</span>
|
||||
</ng-template>
|
||||
`,
|
||||
@@ -41,7 +49,7 @@ import {
|
||||
host: { class: 'adf-date-cell' }
|
||||
})
|
||||
export class DateCellComponent extends DataTableCellComponent {
|
||||
currentLocale;
|
||||
currentLocale: string;
|
||||
|
||||
get format(): string {
|
||||
if (this.column) {
|
||||
@@ -50,8 +58,11 @@ export class DateCellComponent extends DataTableCellComponent {
|
||||
return 'medium';
|
||||
}
|
||||
|
||||
constructor(userPreferenceService: UserPreferencesService) {
|
||||
super();
|
||||
constructor(
|
||||
userPreferenceService: UserPreferencesService,
|
||||
alfrescoApiService: AlfrescoApiService
|
||||
) {
|
||||
super(alfrescoApiService);
|
||||
|
||||
if (userPreferenceService) {
|
||||
userPreferenceService
|
||||
|
@@ -17,15 +17,24 @@
|
||||
|
||||
import { Component, ViewEncapsulation } from '@angular/core';
|
||||
import { DataTableCellComponent } from './datatable-cell.component';
|
||||
import { AlfrescoApiService } from '../../../services/alfresco-api.service';
|
||||
|
||||
@Component({
|
||||
selector: 'adf-filesize-cell',
|
||||
template: `
|
||||
<ng-container>
|
||||
<span [attr.aria-label]=" value | adfFileSize " [title]="tooltip">{{ value | adfFileSize }}</span>
|
||||
<span
|
||||
[title]="tooltip"
|
||||
[attr.aria-label]="value$ | async | adfFileSize"
|
||||
>{{ value$ | async | adfFileSize }}</span
|
||||
>
|
||||
</ng-container>
|
||||
`,
|
||||
encapsulation: ViewEncapsulation.None,
|
||||
host: { class: 'adf-filesize-cell' }
|
||||
})
|
||||
export class FileSizeCellComponent extends DataTableCellComponent {}
|
||||
export class FileSizeCellComponent extends DataTableCellComponent {
|
||||
constructor(alfrescoApiService: AlfrescoApiService) {
|
||||
super(alfrescoApiService);
|
||||
}
|
||||
}
|
||||
|
@@ -69,12 +69,6 @@ describe('LocationCellComponent', () => {
|
||||
fixture.destroy();
|
||||
});
|
||||
|
||||
it('should set displayText', () => {
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(component.displayText).toBe('location');
|
||||
});
|
||||
|
||||
it('should set tooltip', () => {
|
||||
fixture.detectChanges();
|
||||
|
||||
@@ -87,24 +81,32 @@ describe('LocationCellComponent', () => {
|
||||
expect(component.link).toEqual([ columnData.format , rowData.path.elements[2].id ]);
|
||||
});
|
||||
|
||||
it('should not setup cell when path has no data', () => {
|
||||
it('should not setup cell when path has no data', (done) => {
|
||||
rowData.path = {};
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(component.displayText).toBe('');
|
||||
expect(component.tooltip).toBeUndefined();
|
||||
expect(component.link).toEqual([]);
|
||||
component.value$.subscribe((value) => {
|
||||
expect(value).toBe('');
|
||||
done();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
it('should not setup cell when path is missing required properties', () => {
|
||||
it('should not setup cell when path is missing required properties', (done) => {
|
||||
rowData.path = { someProp: '' };
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(component.displayText).toBe('');
|
||||
expect(component.tooltip).toBeUndefined();
|
||||
expect(component.link).toEqual([]);
|
||||
|
||||
component.value$.subscribe((value) => {
|
||||
expect(value).toBe('');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should not setup cell when path data is missing one of the property', () => {
|
||||
@@ -112,9 +114,15 @@ describe('LocationCellComponent', () => {
|
||||
name: 'some-name'
|
||||
};
|
||||
|
||||
let value = '';
|
||||
|
||||
component.value$.subscribe((val) => {
|
||||
value = val;
|
||||
});
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(component.displayText).toBe('');
|
||||
expect(value).toBe('');
|
||||
expect(component.tooltip).toBeUndefined();
|
||||
expect(component.link).toEqual([]);
|
||||
|
||||
@@ -124,7 +132,7 @@ describe('LocationCellComponent', () => {
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(component.displayText).toBe('');
|
||||
expect(value).toBe('');
|
||||
expect(component.tooltip).toBeUndefined();
|
||||
expect(component.link).toEqual([]);
|
||||
});
|
||||
|
@@ -15,9 +15,16 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { ChangeDetectionStrategy, Component, Input, OnInit, ViewEncapsulation } from '@angular/core';
|
||||
import {
|
||||
ChangeDetectionStrategy,
|
||||
Component,
|
||||
Input,
|
||||
OnInit,
|
||||
ViewEncapsulation
|
||||
} from '@angular/core';
|
||||
import { PathInfoEntity } from '@alfresco/js-api';
|
||||
import { DataTableCellComponent } from './datatable-cell.component';
|
||||
import { AlfrescoApiService } from '../../../services/alfresco-api.service';
|
||||
|
||||
@Component({
|
||||
selector: 'adf-location-cell',
|
||||
@@ -25,7 +32,7 @@ import { DataTableCellComponent } from './datatable-cell.component';
|
||||
template: `
|
||||
<ng-container>
|
||||
<a href="" [title]="tooltip" [routerLink]="link">
|
||||
{{ displayText }}
|
||||
{{ value$ | async }}
|
||||
</a>
|
||||
</ng-container>
|
||||
`,
|
||||
@@ -33,28 +40,30 @@ import { DataTableCellComponent } from './datatable-cell.component';
|
||||
host: { class: 'adf-location-cell' }
|
||||
})
|
||||
export class LocationCellComponent extends DataTableCellComponent implements OnInit {
|
||||
|
||||
@Input()
|
||||
link: any[];
|
||||
|
||||
@Input()
|
||||
displayText: string = '';
|
||||
constructor(alfrescoApiService: AlfrescoApiService) {
|
||||
super(alfrescoApiService);
|
||||
}
|
||||
|
||||
/** @override */
|
||||
ngOnInit() {
|
||||
if (!this.value && this.column && this.column.key && this.row && this.data) {
|
||||
const path: PathInfoEntity = this.data.getValue(this.row, this.column);
|
||||
if (this.column && this.column.key && this.row && this.data) {
|
||||
const path: PathInfoEntity = this.data.getValue(
|
||||
this.row,
|
||||
this.column
|
||||
);
|
||||
|
||||
if (path && path.name && path.elements) {
|
||||
this.value = path;
|
||||
this.displayText = path.name.split('/').pop();
|
||||
this.value$.next(path.name.split('/').pop());
|
||||
|
||||
if (!this.tooltip) {
|
||||
this.tooltip = path.name;
|
||||
}
|
||||
|
||||
const parent = path.elements[path.elements.length - 1];
|
||||
this.link = [ this.column.format, parent.id ];
|
||||
this.link = [this.column.format, parent.id];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
37
lib/core/services/automation.service.ts
Normal file
37
lib/core/services/automation.service.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
/*!
|
||||
* @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 { Injectable } from '@angular/core';
|
||||
import { AppConfigService } from '../app-config/app-config.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class CoreAutomationService {
|
||||
constructor(private appConfigService: AppConfigService) {
|
||||
}
|
||||
|
||||
setup() {
|
||||
const adfProxy = window['adf'] || {};
|
||||
|
||||
adfProxy.setConfigField = (field: string, value: string) => {
|
||||
this.appConfigService.config[field] = JSON.parse(value);
|
||||
};
|
||||
|
||||
window['adf'] = adfProxy;
|
||||
}
|
||||
}
|
@@ -53,3 +53,4 @@ export * from './login-dialog.service';
|
||||
export * from './external-alfresco-api.service';
|
||||
export * from './jwt-helper.service';
|
||||
export * from './download-zip.service';
|
||||
export * from './automation.service';
|
||||
|
Reference in New Issue
Block a user