ACS-8366: Move CoreAutomationService to demo shell app (#9935)

This commit is contained in:
Denys Vuika
2024-07-09 16:57:00 -04:00
committed by GitHub
parent c6b121a698
commit eaa489ae8d
17 changed files with 733 additions and 3235 deletions

View File

@@ -22,7 +22,7 @@ import { NgChartsModule } from 'ng2-charts';
import { HttpClientModule } from '@angular/common/http';
import { BrowserAnimationsModule, NoopAnimationsModule } from '@angular/platform-browser/animations';
import { TranslateModule } from '@ngx-translate/core';
import { AppConfigService, DebugAppConfigService, CoreModule, CoreAutomationService, AuthModule, provideTranslations } from '@alfresco/adf-core';
import { AppConfigService, DebugAppConfigService, CoreModule, AuthModule, provideTranslations } from '@alfresco/adf-core';
import { ExtensionsModule } from '@alfresco/adf-extensions';
import { AppComponent } from './app.component';
import { MaterialModule } from './material.module';
@@ -69,6 +69,7 @@ import { UserInfoComponent } from './components/app-layout/user-info/user-info.c
import { FolderDirectiveModule } from './folder-directive';
import { ContentUserInfoModule } from './components/app-layout/user-info/content-user-info';
import { PROCESS_USER_INFO_DIRECTIVES } from './components/app-layout/user-info/process-user-info';
import { CoreAutomationService } from '../testing/automation.service';
@NgModule({
imports: [

View File

@@ -16,32 +16,18 @@
*/
import { Component, OnDestroy, OnInit } from '@angular/core';
import {
CoreAutomationService,
FormFieldModel,
FormModel,
FormRenderingService,
NotificationService
} from '@alfresco/adf-core';
import {
CloudFormRenderingService,
FormCloudService
} from '@alfresco/adf-process-services-cloud';
import { FormFieldModel, FormModel, FormRenderingService, NotificationService } from '@alfresco/adf-core';
import { CloudFormRenderingService, FormCloudService } from '@alfresco/adf-process-services-cloud';
import { Subscription } from 'rxjs';
import {
CustomEditorComponent,
CustomWidgetComponent
} from '../../../cloud/custom-form-components/custom-editor.component';
import { CustomEditorComponent, CustomWidgetComponent } from '../../../cloud/custom-form-components/custom-editor.component';
import { CoreAutomationService } from '../../../../../testing/automation.service';
@Component({
templateUrl: './cloud-form-demo.component.html',
styleUrls: ['./cloud-form-demo.component.scss'],
providers: [
{ provide: FormRenderingService, useClass: CloudFormRenderingService }
]
providers: [{ provide: FormRenderingService, useClass: CloudFormRenderingService }]
})
export class FormCloudDemoComponent implements OnInit, OnDestroy {
form: FormModel;
errorFields: FormFieldModel[] = [];
formConfig: string;
@@ -61,7 +47,8 @@ export class FormCloudDemoComponent implements OnInit, OnDestroy {
private notificationService: NotificationService,
private formService: FormCloudService,
private automationService: CoreAutomationService,
private formRenderingService: FormRenderingService) {
private formRenderingService: FormRenderingService
) {
this.formRenderingService.register({
'demo-widget': () => CustomEditorComponent,
'custom-editor': () => CustomEditorComponent,

View File

@@ -16,19 +16,12 @@
*/
import { Component, inject, OnDestroy, OnInit, ViewEncapsulation } from '@angular/core';
import {
FormModel,
FormFieldModel,
FormService,
FormOutcomeEvent,
NotificationService,
CoreAutomationService,
FormRenderingService
} from '@alfresco/adf-core';
import { FormModel, FormFieldModel, FormService, FormOutcomeEvent, NotificationService, FormRenderingService } from '@alfresco/adf-core';
import { ProcessFormRenderingService } from '@alfresco/adf-process-services';
import { InMemoryFormService } from '../../services/in-memory-form.service';
import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
import { CoreAutomationService } from '../../../testing/automation.service';
@Component({
selector: 'app-form',

View File

@@ -16,18 +16,13 @@
*/
import { Injectable } from '@angular/core';
import { AppConfigService } from '../app-config/app-config.service';
import { AlfrescoApiService } from '../services/alfresco-api.service';
import { StorageService } from '../common/services/storage.service';
import { UserPreferencesService } from '../common/services/user-preferences.service';
import { DemoForm } from '../mock/form/demo-form.mock';
import { AuthenticationService } from '../auth/services/authentication.service';
import { AppConfigService, AlfrescoApiService, StorageService, UserPreferencesService, AuthenticationService } from '@alfresco/adf-core';
import { DemoForm } from './demo-form.mock';
@Injectable({
providedIn: 'root'
})
export class CoreAutomationService {
public forms = new DemoForm();
constructor(
@@ -36,8 +31,7 @@ export class CoreAutomationService {
private userPreferencesService: UserPreferencesService,
private storageService: StorageService,
private auth: AuthenticationService
) {
}
) {}
setup() {
const adfProxy = window['adf'] || {};

View File

@@ -4,28 +4,24 @@ Added: v3.3.0
Status: Active
---
# [Localized Date pipe](../../../lib/core/src/lib/pipes/localized-date.pipe.ts "Defined in localized-date.pipe.ts")
# Localized Date Pipe
Converts a date to a given format and locale.
## Basic Usage
<!-- {% raw %} -->
```HTML
<div>
Created date: {{ date | adfLocalizedDate }}
</div>
```
<!-- {% endraw %} -->
### Properties
| Name | Type | Default value | Description |
| ---- | ---- | ------------- | ----------- |
| format | string | 'medium' | A format to apply to the date value. [Date Pipe Formats.](https://angular.io/api/common/DatePipe#custom-format-options) |
| locale | string | 'en-US' | A locale id for the locale format rules to use. |
| Name | Type | Default value | Description |
|--------|--------|---------------|-------------------------------------------------------------------------------------------------------------------------|
| format | string | 'medium' | A format to apply to the date value. [Date Pipe Formats.](https://angular.io/api/common/DatePipe#custom-format-options) |
| locale | string | 'en-US' | A locale id for the locale format rules to use. |
## Details
@@ -33,14 +29,9 @@ The pipe takes a date and formats it and localizes it so the date is displayed i
To localize the dates in your application, you will need to add the specific locale file for your region in order to use it. Read more about internationalization [here](https://angular.io/guide/i18n#i18n-pipes).
For example, if you want add the japanese date localization in your ADF app you can add in your `app.module.ts`:
For example, if you want to add the japanese date localization in your ADF app you can add in your `app.module.ts`:
```typescript
import { AppConfigService, TRANSLATION_PROVIDER, DebugAppConfigService, CoreModule, CoreAutomationService } from '@alfresco/adf-core';
.....
.....
import { registerLocaleData } from '@angular/common';
import localeJa from '@angular/common/locales/ja';
@@ -52,17 +43,19 @@ registerLocaleData(localeJa);
You can overwrite the default values of this pipe by adding these properties to your `app.config.json`:
```json
"dateValues": {
"defaultDateFormat": "mediumDate",
"defaultDateTimeFormat": "MMM d, y, H:mm",
"defaultLocale": "en-US"
}
{
"dateValues": {
"defaultDateFormat": "mediumDate",
"defaultDateTimeFormat": "MMM d, y, H:mm",
"defaultLocale": "en-US"
}
}
```
| Name | Type | Description |
| ---- | ---- | ----------- |
| defaultDateFormat | string | The format to apply to date values |
| Name | Type | Description |
|-----------------------|--------|-----------------------------------------|
| defaultDateFormat | string | The format to apply to date values |
| defaultDateTimeFormat | string | The format to apply to date-time values |
| defaultLocale | string | The locale id to apply |
| defaultLocale | string | The locale id to apply |
This configuration overwrites the values in the [localized date pipe](../../core/pipes/localized-date.pipe.md) as well as other components to have more consistency across your app. However, you can still overwrite these values any time by using the pipe in your code.

View File

@@ -71,43 +71,12 @@ export const results = {
}
};
export const folderResult = {
list: {
entries: [
{
entry: {
id: '123',
name: 'MyFolder',
isFile: false,
isFolder: true,
createdByUser: {
displayName: 'John Doe'
},
modifiedByUser: {
displayName: 'John Doe'
}
}
}
]
}
};
export const noResult = {
list: {
entries: []
}
};
export const errorJson = {
error: {
errorKey: 'Search failed',
statusCode: 400,
briefSummary: '08220082 search failed',
stackTrace: 'For security reasons the stack trace is no longer displayed, but the property is kept for previous versions.',
descriptionURL: 'https://api-explorer.alfresco.com'
}
};
@Component({
template: `
<adf-search

View File

@@ -27,8 +27,6 @@ import { DataTableComponent, ShowHeaderMode } from './datatable.component';
import { CoreTestingModule } from '../../../testing/core.testing.module';
import { DataColumnListComponent } from '../../data-column/data-column-list.component';
import { DataColumnComponent } from '../../data-column/data-column.component';
import { domSanitizerMock } from '../../../mock/dom-sanitizer-mock';
import { matIconRegistryMock } from '../../../mock/mat-icon-registry-mock';
import { CdkDrag, CdkDragDrop, CdkDropList } from '@angular/cdk/drag-drop';
import { take } from 'rxjs/operators';
import { By } from '@angular/platform-browser';
@@ -40,6 +38,7 @@ import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';
class CustomColumnTemplateComponent {
@ViewChild('tmplRef', { static: true }) templateRef: TemplateRef<any>;
}
@Component({
selector: 'adf-custom-column-header-component',
template: ` <ng-template #tmplRef> CUSTOM HEADER </ng-template> `
@@ -633,7 +632,7 @@ describe('DataTable', () => {
});
it('should initialize default adapter', () => {
const table = new DataTableComponent(null, null, matIconRegistryMock, domSanitizerMock);
const table = TestBed.createComponent(DataTableComponent).componentInstance;
expect(table.data).toBeUndefined();
table.ngOnChanges({ data: new SimpleChange('123', {}, true) });
expect(table.data).toEqual(jasmine.any(ObjectDataTableAdapter));

View File

@@ -1,28 +0,0 @@
/*!
* @license
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* 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.
*/
export class AlfrescoApiMock {
login() {
return Promise.resolve('TICKET_4479f4d3bb155195879bfbb8d5206f433488a1b1');
}
logout() {
return Promise.resolve('logout');
}
changeConfig() {}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,22 +0,0 @@
/*!
* @license
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* 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 { DomSanitizer } from '@angular/platform-browser';
export const domSanitizerMock = {
bypassSecurityTrustResourceUrl: () => {}
} as any as DomSanitizer;

File diff suppressed because it is too large Load Diff

View File

@@ -1,22 +0,0 @@
/*!
* @license
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* 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 { MatIconRegistry } from '@angular/material/icon';
export const matIconRegistryMock = {
addSvgIconInNamespace: () => {}
} as any as MatIconRegistry;

View File

@@ -15,7 +15,6 @@
* limitations under the License.
*/
export * from './alfresco-api.mock';
export * from './cookie.service.mock';
export * from './event.mock';
export * from './translation.service.mock';
@@ -25,7 +24,6 @@ export * from './form/form.component.mock';
export * from './form/form-definition.mock';
export * from './form/form-definition-readonly.mock';
export * from './form/form-definition-visibility.mock';
export * from './form/start-form.component.mock';
export * from './form/form.service.mock';
export * from './form/widget-visibility.service.mock';

View File

@@ -1,45 +0,0 @@
/*!
* @license
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* 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.
*/
export const userAccessMock = {
globalAccess: {
roles: [
'MOCK_GLOBAL_USER_ROLE'
]
},
applicationAccess: [
{
name: 'mockApp1',
roles: [
'MOCK_USER_ROLE_APP_1'
]
},
{
name: 'mockApp2',
roles: [
'MOCK_USER_ROLE_APP_2'
]
},
{
name: 'mockApp3',
roles: [
'MOCK_USER_ROLE_APP_3',
'MOCK_ADMIN_ROLE_APP_3'
]
}
]
};

View File

@@ -17,4 +17,3 @@
export * from './setup-test-bed';
export * from './core.testing.module';
export * from './automation.service';