mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
fix eslint warnigs for core project (#7506)
This commit is contained in:
@@ -21,16 +21,17 @@
|
|||||||
],
|
],
|
||||||
"rules": {
|
"rules": {
|
||||||
"jsdoc/newline-after-description": "warn",
|
"jsdoc/newline-after-description": "warn",
|
||||||
"@typescript-eslint/naming-convention": "warn",
|
"@typescript-eslint/naming-convention": "off",
|
||||||
"@typescript-eslint/consistent-type-assertions": "warn",
|
"@typescript-eslint/consistent-type-assertions": "warn",
|
||||||
"@typescript-eslint/prefer-for-of": "warn",
|
"@typescript-eslint/prefer-for-of": "off",
|
||||||
"no-underscore-dangle": ["warn", { "allowAfterThis": true }],
|
"@typescript-eslint/member-ordering": "off",
|
||||||
|
"no-underscore-dangle": ["error", { "allowAfterThis": true }],
|
||||||
"no-shadow": "warn",
|
"no-shadow": "warn",
|
||||||
"quote-props": "warn",
|
"quote-props": "warn",
|
||||||
"object-shorthand": "warn",
|
"object-shorthand": "warn",
|
||||||
"prefer-const": "warn",
|
"prefer-const": "warn",
|
||||||
"arrow-body-style": "warn",
|
"arrow-body-style": "warn",
|
||||||
"@angular-eslint/no-output-native": "warn",
|
"@angular-eslint/no-output-native": "off",
|
||||||
"space-before-function-paren": "warn",
|
"space-before-function-paren": "warn",
|
||||||
|
|
||||||
"@angular-eslint/component-selector": [
|
"@angular-eslint/component-selector": [
|
||||||
@@ -105,7 +106,7 @@
|
|||||||
"@angular-eslint/template/no-autofocus": "error",
|
"@angular-eslint/template/no-autofocus": "error",
|
||||||
"@angular-eslint/template/no-positive-tabindex": "error",
|
"@angular-eslint/template/no-positive-tabindex": "error",
|
||||||
|
|
||||||
"@angular-eslint/template/no-negated-async": "warn"
|
"@angular-eslint/template/no-negated-async": "off"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@@ -52,7 +52,7 @@ describe('AboutGithubLinkComponent', () => {
|
|||||||
expect(titleElement.innerText).toEqual('mock-application-name');
|
expect(titleElement.innerText).toEqual('mock-application-name');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should display version', async() => {
|
it('should display version', async () => {
|
||||||
component.version = aboutGithubDetails.version;
|
component.version = aboutGithubDetails.version;
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
await fixture.whenStable();
|
await fixture.whenStable();
|
||||||
@@ -60,14 +60,14 @@ describe('AboutGithubLinkComponent', () => {
|
|||||||
expect(version.innerText).toEqual('ABOUT.VERSION: 0.0.7');
|
expect(version.innerText).toEqual('ABOUT.VERSION: 0.0.7');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should display adf github link as default if url is not specified', async() => {
|
it('should display adf github link as default if url is not specified', async () => {
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
await fixture.whenStable();
|
await fixture.whenStable();
|
||||||
const githubUrl = fixture.nativeElement.querySelector('[data-automation-id="adf-github-url"]');
|
const githubUrl = fixture.nativeElement.querySelector('[data-automation-id="adf-github-url"]');
|
||||||
expect(githubUrl.innerText).toEqual(aboutGithubDetails.defualrUrl);
|
expect(githubUrl.innerText).toEqual(aboutGithubDetails.defualrUrl);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should display the github link', async() => {
|
it('should display the github link', async () => {
|
||||||
component.url = aboutGithubDetails.url;
|
component.url = aboutGithubDetails.url;
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
await fixture.whenStable();
|
await fixture.whenStable();
|
||||||
|
@@ -40,8 +40,8 @@ describe('AboutServerSettingsComponent', () => {
|
|||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
appConfigService = TestBed.inject(AppConfigService);
|
appConfigService = TestBed.inject(AppConfigService);
|
||||||
appConfigService.config = Object.assign(appConfigService.config, {
|
appConfigService.config = Object.assign(appConfigService.config, {
|
||||||
'ecmHost': aboutGithubDetails.ecmHost,
|
ecmHost: aboutGithubDetails.ecmHost,
|
||||||
'bpmHost': aboutGithubDetails.bpmHost
|
bpmHost: aboutGithubDetails.bpmHost
|
||||||
});
|
});
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
});
|
});
|
||||||
@@ -50,7 +50,7 @@ describe('AboutServerSettingsComponent', () => {
|
|||||||
fixture.destroy();
|
fixture.destroy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should fetch process and content hosts from the app.config.json file', async() => {
|
it('should fetch process and content hosts from the app.config.json file', async () => {
|
||||||
await fixture.whenStable();
|
await fixture.whenStable();
|
||||||
expect(component.bpmHost).toEqual(aboutGithubDetails.bpmHost);
|
expect(component.bpmHost).toEqual(aboutGithubDetails.bpmHost);
|
||||||
expect(component.ecmHost).toEqual(aboutGithubDetails.ecmHost);
|
expect(component.ecmHost).toEqual(aboutGithubDetails.ecmHost);
|
||||||
|
@@ -73,9 +73,7 @@ export class AboutComponent implements OnInit {
|
|||||||
this.dependencies = this.pkg?.dependencies;
|
this.dependencies = this.pkg?.dependencies;
|
||||||
|
|
||||||
if (this.dependencies) {
|
if (this.dependencies) {
|
||||||
const alfrescoPackages = Object.keys(this.dependencies).filter((val) => {
|
const alfrescoPackages = Object.keys(this.dependencies).filter((val) => new RegExp(this.regexp).test(val));
|
||||||
return new RegExp(this.regexp).test(val);
|
|
||||||
});
|
|
||||||
|
|
||||||
alfrescoPackages.forEach((val) => {
|
alfrescoPackages.forEach((val) => {
|
||||||
this.dependencyEntries.push({
|
this.dependencyEntries.push({
|
||||||
@@ -97,20 +95,16 @@ export class AboutComponent implements OnInit {
|
|||||||
this.discovery.getEcmProductInfo().subscribe((repository) => {
|
this.discovery.getEcmProductInfo().subscribe((repository) => {
|
||||||
this.repository = repository;
|
this.repository = repository;
|
||||||
|
|
||||||
this.statusEntries = Object.keys(repository.status).map((key) => {
|
this.statusEntries = Object.keys(repository.status).map((key) => ({
|
||||||
return {
|
property: key,
|
||||||
property: key,
|
value: repository.status[key]
|
||||||
value: repository.status[key]
|
}));
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
if (repository.license) {
|
if (repository.license) {
|
||||||
this.licenseEntries = Object.keys(repository.license).map((key) => {
|
this.licenseEntries = Object.keys(repository.license).map((key) => ({
|
||||||
return {
|
property: key,
|
||||||
property: key,
|
value: repository.license[key]
|
||||||
value: repository.license[key]
|
}));
|
||||||
};
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@@ -22,7 +22,7 @@ export const mockDependencies = {
|
|||||||
'@angular/mock-services': '8.0.0'
|
'@angular/mock-services': '8.0.0'
|
||||||
};
|
};
|
||||||
|
|
||||||
export const mockPlugins = <any> [
|
export const mockPlugins = [
|
||||||
{
|
{
|
||||||
$name: 'plugin1',
|
$name: 'plugin1',
|
||||||
$version: '1.0.0',
|
$version: '1.0.0',
|
||||||
|
@@ -44,7 +44,7 @@ describe('AppConfigService', () => {
|
|||||||
name: 'Custom Name'
|
name: 'Custom Name'
|
||||||
},
|
},
|
||||||
files: {
|
files: {
|
||||||
'excluded': ['excluded']
|
excluded: ['excluded']
|
||||||
},
|
},
|
||||||
logLevel: 'silent',
|
logLevel: 'silent',
|
||||||
alfrescoRepositoryName: 'alfresco-1'
|
alfrescoRepositoryName: 'alfresco-1'
|
||||||
|
@@ -23,6 +23,7 @@ import { map, distinctUntilChanged, take } from 'rxjs/operators';
|
|||||||
import { ExtensionConfig, ExtensionService, mergeObjects } from '@alfresco/adf-extensions';
|
import { ExtensionConfig, ExtensionService, mergeObjects } from '@alfresco/adf-extensions';
|
||||||
|
|
||||||
/* spellchecker: disable */
|
/* spellchecker: disable */
|
||||||
|
// eslint-disable-next-line no-shadow
|
||||||
export enum AppConfigValues {
|
export enum AppConfigValues {
|
||||||
APP_CONFIG_LANGUAGES_KEY = 'languages',
|
APP_CONFIG_LANGUAGES_KEY = 'languages',
|
||||||
PROVIDERS = 'providers',
|
PROVIDERS = 'providers',
|
||||||
@@ -44,6 +45,7 @@ export enum AppConfigValues {
|
|||||||
NOTIFY_DURATION = 'notificationDefaultDuration'
|
NOTIFY_DURATION = 'notificationDefaultDuration'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// eslint-disable-next-line no-shadow
|
||||||
export enum Status {
|
export enum Status {
|
||||||
INIT = 'init',
|
INIT = 'init',
|
||||||
LOADING = 'loading',
|
LOADING = 'loading',
|
||||||
@@ -81,6 +83,7 @@ export class AppConfigService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Requests notification of a property value when it is loaded.
|
* Requests notification of a property value when it is loaded.
|
||||||
|
*
|
||||||
* @param property The desired property value
|
* @param property The desired property value
|
||||||
* @returns Property value, when loaded
|
* @returns Property value, when loaded
|
||||||
*/
|
*/
|
||||||
@@ -94,6 +97,7 @@ export class AppConfigService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the value of a named property.
|
* Gets the value of a named property.
|
||||||
|
*
|
||||||
* @param key Name of the property
|
* @param key Name of the property
|
||||||
* @param defaultValue Value to return if the key is not found
|
* @param defaultValue Value to return if the key is not found
|
||||||
* @returns Value of the property
|
* @returns Value of the property
|
||||||
@@ -119,11 +123,12 @@ export class AppConfigService {
|
|||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
return <T> result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the location.protocol value.
|
* Gets the location.protocol value.
|
||||||
|
*
|
||||||
* @returns The location.protocol string
|
* @returns The location.protocol string
|
||||||
*/
|
*/
|
||||||
getLocationProtocol(): string {
|
getLocationProtocol(): string {
|
||||||
@@ -132,6 +137,7 @@ export class AppConfigService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the location.hostname property.
|
* Gets the location.hostname property.
|
||||||
|
*
|
||||||
* @returns Value of the property
|
* @returns Value of the property
|
||||||
*/
|
*/
|
||||||
getLocationHostname(): string {
|
getLocationHostname(): string {
|
||||||
@@ -140,6 +146,7 @@ export class AppConfigService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the location.port property.
|
* Gets the location.port property.
|
||||||
|
*
|
||||||
* @param prefix Text added before port value
|
* @param prefix Text added before port value
|
||||||
* @returns Port with prefix
|
* @returns Port with prefix
|
||||||
*/
|
*/
|
||||||
@@ -172,6 +179,7 @@ export class AppConfigService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads the config file.
|
* Loads the config file.
|
||||||
|
*
|
||||||
* @returns Notification when loading is complete
|
* @returns Notification when loading is complete
|
||||||
*/
|
*/
|
||||||
load(): Promise<any> {
|
load(): Promise<any> {
|
||||||
|
@@ -30,11 +30,11 @@ export class DebugAppConfigService extends AppConfigService {
|
|||||||
/** @override */
|
/** @override */
|
||||||
get<T>(key: string, defaultValue?: T): T {
|
get<T>(key: string, defaultValue?: T): T {
|
||||||
if (key === AppConfigValues.OAUTHCONFIG) {
|
if (key === AppConfigValues.OAUTHCONFIG) {
|
||||||
return <T> (JSON.parse(this.storage.getItem(key)) || super.get<T>(key, defaultValue));
|
return (JSON.parse(this.storage.getItem(key)) || super.get<T>(key, defaultValue));
|
||||||
} else if (key === AppConfigValues.APPLICATION) {
|
} else if (key === AppConfigValues.APPLICATION) {
|
||||||
return undefined;
|
return undefined;
|
||||||
} else {
|
} else {
|
||||||
return <T> (<any> this.storage.getItem(key) || super.get<T>(key, defaultValue));
|
return (this.storage.getItem(key) as any || super.get<T>(key, defaultValue));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -28,11 +28,12 @@ describe('CardViewArrayItemComponent', () => {
|
|||||||
let component: CardViewArrayItemComponent;
|
let component: CardViewArrayItemComponent;
|
||||||
let fixture: ComponentFixture<CardViewArrayItemComponent>;
|
let fixture: ComponentFixture<CardViewArrayItemComponent>;
|
||||||
|
|
||||||
const mockData = <CardViewArrayItem[]> [
|
const mockData = [
|
||||||
{ icon: 'person', value: 'Zlatan' },
|
{ icon: 'person', value: 'Zlatan' },
|
||||||
{ icon: 'group', value: 'Lionel Messi' },
|
{ icon: 'group', value: 'Lionel Messi' },
|
||||||
{ icon: 'person', value: 'Mohamed' },
|
{ icon: 'person', value: 'Mohamed' },
|
||||||
{ icon: 'person', value: 'Ronaldo' }];
|
{ icon: 'person', value: 'Ronaldo' }
|
||||||
|
] as CardViewArrayItem[];
|
||||||
|
|
||||||
const mockDefaultProps = {
|
const mockDefaultProps = {
|
||||||
label: 'Array of items',
|
label: 'Array of items',
|
||||||
|
@@ -184,7 +184,7 @@ describe('CardViewBoolItemComponent', () => {
|
|||||||
spyOn(cardViewUpdateService, 'update');
|
spyOn(cardViewUpdateService, 'update');
|
||||||
const property = { ... component.property };
|
const property = { ... component.property };
|
||||||
|
|
||||||
component.changed(<MatCheckboxChange> { checked: true });
|
component.changed({ checked: true } as MatCheckboxChange);
|
||||||
|
|
||||||
expect(cardViewUpdateService.update).toHaveBeenCalledWith(property, true);
|
expect(cardViewUpdateService.update).toHaveBeenCalledWith(property, true);
|
||||||
});
|
});
|
||||||
@@ -192,7 +192,7 @@ describe('CardViewBoolItemComponent', () => {
|
|||||||
it('should update the property value after a changed', async () => {
|
it('should update the property value after a changed', async () => {
|
||||||
component.property.value = true;
|
component.property.value = true;
|
||||||
|
|
||||||
component.changed(<MatCheckboxChange> { checked: false });
|
component.changed({ checked: false } as MatCheckboxChange);
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
await fixture.whenStable();
|
await fixture.whenStable();
|
||||||
|
@@ -40,7 +40,7 @@ export class CardViewBoolItemComponent extends BaseCardView<CardViewBoolItemMode
|
|||||||
}
|
}
|
||||||
|
|
||||||
changed(change: MatCheckboxChange) {
|
changed(change: MatCheckboxChange) {
|
||||||
this.cardViewUpdateService.update(<CardViewBoolItemModel> { ...this.property }, change.checked );
|
this.cardViewUpdateService.update({ ...this.property } as CardViewBoolItemModel, change.checked );
|
||||||
this.property.value = change.checked;
|
this.property.value = change.checked;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -86,7 +86,7 @@ export class CardViewDateItemComponent extends BaseCardView<CardViewDateItemMode
|
|||||||
this.property.locale = locale;
|
this.property.locale = locale;
|
||||||
});
|
});
|
||||||
|
|
||||||
(<MomentDateAdapter> this.dateAdapter).overrideDisplayFormat = 'MMM DD';
|
(this.dateAdapter as MomentDateAdapter).overrideDisplayFormat = 'MMM DD';
|
||||||
|
|
||||||
if (this.property.value) {
|
if (this.property.value) {
|
||||||
this.valueDate = moment(this.property.value, this.dateFormat);
|
this.valueDate = moment(this.property.value, this.dateFormat);
|
||||||
@@ -129,7 +129,7 @@ export class CardViewDateItemComponent extends BaseCardView<CardViewDateItemMode
|
|||||||
|
|
||||||
onDateClear() {
|
onDateClear() {
|
||||||
this.valueDate = null;
|
this.valueDate = null;
|
||||||
this.cardViewUpdateService.update(<CardViewDateItemModel> { ...this.property }, null);
|
this.cardViewUpdateService.update({ ...this.property } as CardViewDateItemModel, null);
|
||||||
this.property.value = null;
|
this.property.value = null;
|
||||||
this.property.default = null;
|
this.property.default = null;
|
||||||
}
|
}
|
||||||
@@ -155,6 +155,6 @@ export class CardViewDateItemComponent extends BaseCardView<CardViewDateItemMode
|
|||||||
}
|
}
|
||||||
|
|
||||||
update() {
|
update() {
|
||||||
this.cardViewUpdateService.update(<CardViewDateItemModel> { ...this.property }, this.property.value);
|
this.cardViewUpdateService.update({ ...this.property } as CardViewDateItemModel, this.property.value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -59,7 +59,7 @@ describe('CardViewItemDispatcherComponent', () => {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
fixture = TestBed.createComponent(CardViewItemDispatcherComponent);
|
fixture = TestBed.createComponent(CardViewItemDispatcherComponent);
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
component.property = <CardViewItem> {
|
component.property = {
|
||||||
type: 'shiny-custom-element',
|
type: 'shiny-custom-element',
|
||||||
label: 'Shiny custom element',
|
label: 'Shiny custom element',
|
||||||
value: null,
|
value: null,
|
||||||
@@ -111,7 +111,7 @@ describe('CardViewItemDispatcherComponent', () => {
|
|||||||
it('should update the subcomponent\'s input parameters', () => {
|
it('should update the subcomponent\'s input parameters', () => {
|
||||||
const expectedEditable = false;
|
const expectedEditable = false;
|
||||||
const expectedDisplayEmpty = true;
|
const expectedDisplayEmpty = true;
|
||||||
const expectedProperty = <CardViewItem> {};
|
const expectedProperty = {};
|
||||||
const expectedCustomInput = 1;
|
const expectedCustomInput = 1;
|
||||||
const expectedDisplayNoneOption = false;
|
const expectedDisplayNoneOption = false;
|
||||||
const expectedDisplayClearAction = false;
|
const expectedDisplayClearAction = false;
|
||||||
|
@@ -69,7 +69,7 @@ export class CardViewKeyValuePairsItemComponent extends BaseCardView<CardViewKey
|
|||||||
const validValues = this.values.filter((i) => i.name.length && i.value.length);
|
const validValues = this.values.filter((i) => i.name.length && i.value.length);
|
||||||
|
|
||||||
if (remove || validValues.length) {
|
if (remove || validValues.length) {
|
||||||
this.cardViewUpdateService.update(<CardViewKeyValuePairsItemModel> { ...this.property }, validValues);
|
this.cardViewUpdateService.update({ ...this.property } as CardViewKeyValuePairsItemModel, validValues);
|
||||||
this.property.value = validValues;
|
this.property.value = validValues;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -93,7 +93,7 @@ export class CardViewSelectItemComponent extends BaseCardView<CardViewSelectItem
|
|||||||
|
|
||||||
onChange(event: MatSelectChange): void {
|
onChange(event: MatSelectChange): void {
|
||||||
const selectedOption = event.value !== undefined ? event.value : null;
|
const selectedOption = event.value !== undefined ? event.value : null;
|
||||||
this.cardViewUpdateService.update(<CardViewSelectItemModel<string>> { ...this.property }, selectedOption);
|
this.cardViewUpdateService.update({ ...this.property } as CardViewSelectItemModel<string>, selectedOption);
|
||||||
this.property.value = selectedOption;
|
this.property.value = selectedOption;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -44,9 +44,9 @@ export class TestComponent {
|
|||||||
showInputFilter = true;
|
showInputFilter = true;
|
||||||
multiple = false;
|
multiple = false;
|
||||||
standardOptions = [
|
standardOptions = [
|
||||||
{ 'id': '1', 'name': 'one' },
|
{ id: '1', name: 'one' },
|
||||||
{ 'id': '2', 'name': 'two' },
|
{ id: '2', name: 'two' },
|
||||||
{ 'id': '3', 'name': 'three' }
|
{ id: '3', name: 'three' }
|
||||||
];
|
];
|
||||||
options = this.standardOptions;
|
options = this.standardOptions;
|
||||||
|
|
||||||
@@ -136,7 +136,7 @@ describe('SelectFilterInputComponent', () => {
|
|||||||
component.onModelChange('some-search-term');
|
component.onModelChange('some-search-term');
|
||||||
expect(component.term).toBe('some-search-term');
|
expect(component.term).toBe('some-search-term');
|
||||||
|
|
||||||
component.selectFilterInput.nativeElement.dispatchEvent(new KeyboardEvent('keydown', {'keyCode': ESCAPE} as any));
|
component.selectFilterInput.nativeElement.dispatchEvent(new KeyboardEvent('keydown', {keyCode: ESCAPE} as any));
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
expect(component.term).toBe('');
|
expect(component.term).toBe('');
|
||||||
});
|
});
|
||||||
@@ -152,10 +152,10 @@ describe('SelectFilterInputComponent', () => {
|
|||||||
afterEach(() => testFixture.destroy());
|
afterEach(() => testFixture.destroy());
|
||||||
|
|
||||||
it('should preserve the values for multiple search', async () => {
|
it('should preserve the values for multiple search', async () => {
|
||||||
const userSelection = [{ 'id': '3', 'name': 'three' }];
|
const userSelection = [{ id: '3', name: 'three' }];
|
||||||
const preSelected = [
|
const preSelected = [
|
||||||
{ 'id': '1', 'name': 'one' },
|
{ id: '1', name: 'one' },
|
||||||
{ 'id': '2', 'name': 'two' }
|
{ id: '2', name: 'two' }
|
||||||
];
|
];
|
||||||
testComponent.field.value = preSelected;
|
testComponent.field.value = preSelected;
|
||||||
testComponent.multiple = true;
|
testComponent.multiple = true;
|
||||||
|
@@ -25,7 +25,7 @@ import { takeUntil } from 'rxjs/operators';
|
|||||||
selector: 'adf-select-filter-input',
|
selector: 'adf-select-filter-input',
|
||||||
templateUrl: './select-filter-input.component.html',
|
templateUrl: './select-filter-input.component.html',
|
||||||
styleUrls: ['./select-filter-input.component.scss'],
|
styleUrls: ['./select-filter-input.component.scss'],
|
||||||
host: { 'class': 'adf-select-filter-input' },
|
host: { class: 'adf-select-filter-input' },
|
||||||
encapsulation: ViewEncapsulation.None
|
encapsulation: ViewEncapsulation.None
|
||||||
})
|
})
|
||||||
export class SelectFilterInputComponent implements OnInit, OnDestroy {
|
export class SelectFilterInputComponent implements OnInit, OnDestroy {
|
||||||
@@ -79,6 +79,7 @@ export class SelectFilterInputComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
this.previousSelected = values;
|
this.previousSelected = values;
|
||||||
if (restoreSelection) {
|
if (restoreSelection) {
|
||||||
|
// eslint-disable-next-line no-underscore-dangle
|
||||||
this.matSelect._onChange(values);
|
this.matSelect._onChange(values);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@@ -904,28 +904,28 @@ describe('CardViewTextItemComponent', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
function updateTextField(key, value) {
|
const updateTextField = (key, value) => {
|
||||||
const editInput = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-value-${key}"]`));
|
const editInput = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-value-${key}"]`));
|
||||||
editInput.nativeElement.value = value;
|
editInput.nativeElement.value = value;
|
||||||
editInput.nativeElement.dispatchEvent(new Event('input'));
|
editInput.nativeElement.dispatchEvent(new Event('input'));
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
}
|
};
|
||||||
|
|
||||||
function getTextFieldValue(key): string {
|
const getTextFieldValue = (key): string => {
|
||||||
const textItemInput = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-value-${key}"]`));
|
const textItemInput = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-value-${key}"]`));
|
||||||
expect(textItemInput).not.toBeNull();
|
expect(textItemInput).not.toBeNull();
|
||||||
return textItemInput.nativeElement.value;
|
return textItemInput.nativeElement.value;
|
||||||
}
|
};
|
||||||
|
|
||||||
function getTextField(key): DebugElement {
|
const getTextField = (key): DebugElement => {
|
||||||
const textItemInput = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-value-${key}"]`));
|
const textItemInput = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-value-${key}"]`));
|
||||||
expect(textItemInput).not.toBeNull();
|
expect(textItemInput).not.toBeNull();
|
||||||
return textItemInput;
|
return textItemInput;
|
||||||
}
|
};
|
||||||
|
|
||||||
function getTextFieldError(key): string {
|
const getTextFieldError = (key): string => {
|
||||||
const textItemInputError = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-error-${key}"] li`));
|
const textItemInputError = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-error-${key}"] li`));
|
||||||
expect(textItemInputError).not.toBeNull();
|
expect(textItemInputError).not.toBeNull();
|
||||||
return textItemInputError.nativeElement.innerText;
|
return textItemInputError.nativeElement.innerText;
|
||||||
}
|
};
|
||||||
});
|
});
|
||||||
|
@@ -132,7 +132,7 @@ export class CardViewTextItemComponent extends BaseCardView<CardViewTextItemMode
|
|||||||
update(): void {
|
update(): void {
|
||||||
if (this.property.isValid(this.editedValue)) {
|
if (this.property.isValid(this.editedValue)) {
|
||||||
this.property.value = this.prepareValueForUpload(this.property, this.editedValue);
|
this.property.value = this.prepareValueForUpload(this.property, this.editedValue);
|
||||||
this.cardViewUpdateService.update(<CardViewTextItemModel> { ...this.property }, this.property.value);
|
this.cardViewUpdateService.update({ ...this.property } as CardViewTextItemModel, this.property.value);
|
||||||
this.resetErrorMessages();
|
this.resetErrorMessages();
|
||||||
} else {
|
} else {
|
||||||
this.errors = this.property.getValidationErrors(this.editedValue);
|
this.errors = this.property.getValidationErrors(this.editedValue);
|
||||||
|
@@ -145,7 +145,7 @@ describe('CardViewComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should render the select element with the None option when not set in the properties', async () => {
|
it('should render the select element with the None option when not set in the properties', async () => {
|
||||||
const options: CardViewSelectItemOption<string>[] = [{'label' : 'Option 1', 'key': '1'}, {'label' : 'Option 2', 'key': '2'}];
|
const options: CardViewSelectItemOption<string>[] = [{label : 'Option 1', key: '1'}, {label : 'Option 2', key: '2'}];
|
||||||
component.properties = [new CardViewSelectItemModel({
|
component.properties = [new CardViewSelectItemModel({
|
||||||
label: 'My default label',
|
label: 'My default label',
|
||||||
value: '1',
|
value: '1',
|
||||||
@@ -173,7 +173,7 @@ describe('CardViewComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should render the select element with the None option when set true in the properties', async () => {
|
it('should render the select element with the None option when set true in the properties', async () => {
|
||||||
const options: CardViewSelectItemOption<string>[] = [{'label' : 'Option 1', 'key': '1'}, {'label' : 'Option 2', 'key': '2'}];
|
const options: CardViewSelectItemOption<string>[] = [{label : 'Option 1', key: '1'}, {label : 'Option 2', key: '2'}];
|
||||||
component.properties = [new CardViewSelectItemModel({
|
component.properties = [new CardViewSelectItemModel({
|
||||||
label: 'My default label',
|
label: 'My default label',
|
||||||
value: '1',
|
value: '1',
|
||||||
@@ -202,7 +202,7 @@ describe('CardViewComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should not render the select element with the None option when set false in the properties', async () => {
|
it('should not render the select element with the None option when set false in the properties', async () => {
|
||||||
const options: CardViewSelectItemOption<string>[] = [{'label' : 'Option 1', 'key': '1'}, {'label' : 'Option 2', 'key': '2'}];
|
const options: CardViewSelectItemOption<string>[] = [{label : 'Option 1', key: '1'}, {label : 'Option 2', key: '2'}];
|
||||||
component.properties = [new CardViewSelectItemModel({
|
component.properties = [new CardViewSelectItemModel({
|
||||||
label: 'My default label',
|
label: 'My default label',
|
||||||
value: '1',
|
value: '1',
|
||||||
|
@@ -44,9 +44,7 @@ export class CardViewTextItemModel extends CardViewBaseItemModel implements Card
|
|||||||
|
|
||||||
applyPipes(displayValue) {
|
applyPipes(displayValue) {
|
||||||
if (this.pipes.length) {
|
if (this.pipes.length) {
|
||||||
displayValue = this.pipes.reduce((accumulator, { pipe, params = [] }) => {
|
displayValue = this.pipes.reduce((accumulator, { pipe, params = [] }) => pipe.transform(accumulator, ...params), displayValue);
|
||||||
return pipe.transform(accumulator, ...params);
|
|
||||||
}, displayValue);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return displayValue;
|
return displayValue;
|
||||||
|
@@ -33,15 +33,15 @@ export class CardItemTypeService extends DynamicComponentMapper {
|
|||||||
protected defaultValue: Type<any> = CardViewTextItemComponent;
|
protected defaultValue: Type<any> = CardViewTextItemComponent;
|
||||||
|
|
||||||
protected types: { [key: string]: DynamicComponentResolveFunction } = {
|
protected types: { [key: string]: DynamicComponentResolveFunction } = {
|
||||||
'text': DynamicComponentResolver.fromType(CardViewTextItemComponent),
|
text: DynamicComponentResolver.fromType(CardViewTextItemComponent),
|
||||||
'select': DynamicComponentResolver.fromType(CardViewSelectItemComponent),
|
select: DynamicComponentResolver.fromType(CardViewSelectItemComponent),
|
||||||
'int': DynamicComponentResolver.fromType(CardViewTextItemComponent),
|
int: DynamicComponentResolver.fromType(CardViewTextItemComponent),
|
||||||
'float': DynamicComponentResolver.fromType(CardViewTextItemComponent),
|
float: DynamicComponentResolver.fromType(CardViewTextItemComponent),
|
||||||
'date': DynamicComponentResolver.fromType(CardViewDateItemComponent),
|
date: DynamicComponentResolver.fromType(CardViewDateItemComponent),
|
||||||
'datetime': DynamicComponentResolver.fromType(CardViewDateItemComponent),
|
datetime: DynamicComponentResolver.fromType(CardViewDateItemComponent),
|
||||||
'bool': DynamicComponentResolver.fromType(CardViewBoolItemComponent),
|
bool: DynamicComponentResolver.fromType(CardViewBoolItemComponent),
|
||||||
'map': DynamicComponentResolver.fromType(CardViewMapItemComponent),
|
map: DynamicComponentResolver.fromType(CardViewMapItemComponent),
|
||||||
'keyvaluepairs': DynamicComponentResolver.fromType(CardViewKeyValuePairsItemComponent),
|
keyvaluepairs: DynamicComponentResolver.fromType(CardViewKeyValuePairsItemComponent),
|
||||||
'array': DynamicComponentResolver.fromType(CardViewArrayItemComponent)
|
array: DynamicComponentResolver.fromType(CardViewArrayItemComponent)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@@ -50,14 +50,14 @@ describe('CardViewUpdateService', () => {
|
|||||||
describe('Service', () => {
|
describe('Service', () => {
|
||||||
|
|
||||||
let cardViewUpdateService: CardViewUpdateService;
|
let cardViewUpdateService: CardViewUpdateService;
|
||||||
const property: CardViewBaseItemModel = <CardViewBaseItemModel> {
|
const property: CardViewBaseItemModel = {
|
||||||
label: 'property-label',
|
label: 'property-label',
|
||||||
value: 'property-value',
|
value: 'property-value',
|
||||||
key: 'property-key',
|
key: 'property-key',
|
||||||
default: 'property-default',
|
default: 'property-default',
|
||||||
editable: false,
|
editable: false,
|
||||||
clickable: false
|
clickable: false
|
||||||
};
|
} as CardViewBaseItemModel;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
cardViewUpdateService = TestBed.inject(CardViewUpdateService);
|
cardViewUpdateService = TestBed.inject(CardViewUpdateService);
|
||||||
@@ -85,7 +85,7 @@ describe('CardViewUpdateService', () => {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
it('should send updated node when aspect changed', fakeAsync(() => {
|
it('should send updated node when aspect changed', fakeAsync(() => {
|
||||||
const fakeNode: MinimalNode = <MinimalNode> { id: 'Bigfoot'};
|
const fakeNode: MinimalNode = { id: 'Bigfoot'} as MinimalNode;
|
||||||
cardViewUpdateService.updatedAspect$.subscribe((node: MinimalNode) => {
|
cardViewUpdateService.updatedAspect$.subscribe((node: MinimalNode) => {
|
||||||
expect(node.id).toBe('Bigfoot');
|
expect(node.id).toBe('Bigfoot');
|
||||||
});
|
});
|
||||||
|
@@ -29,13 +29,11 @@ export interface ClickNotification {
|
|||||||
target: any;
|
target: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function transformKeyToObject(key: string, value): any {
|
export const transformKeyToObject = (key: string, value): any => {
|
||||||
const objectLevels: string[] = key.split('.').reverse();
|
const objectLevels: string[] = key.split('.').reverse();
|
||||||
|
|
||||||
return objectLevels.reduce<any>((previousValue, currentValue) => {
|
return objectLevels.reduce<any>((previousValue, currentValue) => ({ [currentValue]: previousValue}), value);
|
||||||
return { [currentValue]: previousValue};
|
};
|
||||||
}, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
@@ -62,6 +60,7 @@ export class CardViewUpdateService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the cardview items property
|
* Updates the cardview items property
|
||||||
|
*
|
||||||
* @param notification
|
* @param notification
|
||||||
*/
|
*/
|
||||||
updateElement(notification: CardViewBaseItemModel) {
|
updateElement(notification: CardViewBaseItemModel) {
|
||||||
|
@@ -101,14 +101,14 @@ describe('CopyClipboardDirective', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should show tooltip when hover element', (() => {
|
it('should show tooltip when hover element', (() => {
|
||||||
const spanHTMLElement: HTMLInputElement = <HTMLInputElement> element.querySelector('span');
|
const spanHTMLElement = element.querySelector<HTMLInputElement>('span');
|
||||||
spanHTMLElement.dispatchEvent(new Event('mouseenter'));
|
spanHTMLElement.dispatchEvent(new Event('mouseenter'));
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
expect(fixture.debugElement.nativeElement.querySelector('.adf-copy-tooltip')).not.toBeNull();
|
expect(fixture.debugElement.nativeElement.querySelector('.adf-copy-tooltip')).not.toBeNull();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should not show tooltip when element it is not hovered', (() => {
|
it('should not show tooltip when element it is not hovered', (() => {
|
||||||
const spanHTMLElement: HTMLInputElement = <HTMLInputElement> element.querySelector('span');
|
const spanHTMLElement = element.querySelector<HTMLInputElement>('span');
|
||||||
spanHTMLElement.dispatchEvent(new Event('mouseenter'));
|
spanHTMLElement.dispatchEvent(new Event('mouseenter'));
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
expect(fixture.debugElement.nativeElement.querySelector('.adf-copy-tooltip')).not.toBeNull();
|
expect(fixture.debugElement.nativeElement.querySelector('.adf-copy-tooltip')).not.toBeNull();
|
||||||
@@ -119,7 +119,7 @@ describe('CopyClipboardDirective', () => {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
it('should copy the content of element when click it', fakeAsync(() => {
|
it('should copy the content of element when click it', fakeAsync(() => {
|
||||||
const spanHTMLElement: HTMLInputElement = <HTMLInputElement> element.querySelector('span');
|
const spanHTMLElement = element.querySelector<HTMLInputElement>('span');
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
spyOn(document, 'execCommand');
|
spyOn(document, 'execCommand');
|
||||||
spanHTMLElement.dispatchEvent(new Event('click'));
|
spanHTMLElement.dispatchEvent(new Event('click'));
|
||||||
@@ -129,7 +129,7 @@ describe('CopyClipboardDirective', () => {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
it('should not copy the content of element when click it', fakeAsync(() => {
|
it('should not copy the content of element when click it', fakeAsync(() => {
|
||||||
const spanHTMLElement: HTMLInputElement = <HTMLInputElement> element.querySelector('span');
|
const spanHTMLElement = element.querySelector<HTMLInputElement>('span');
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
spyOn(document, 'execCommand');
|
spyOn(document, 'execCommand');
|
||||||
spanHTMLElement.dispatchEvent(new Event('mouseleave'));
|
spanHTMLElement.dispatchEvent(new Event('mouseleave'));
|
||||||
|
@@ -30,6 +30,7 @@ export class ClipboardService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the target element can have its text copied.
|
* Checks if the target element can have its text copied.
|
||||||
|
*
|
||||||
* @param target Target HTML element
|
* @param target Target HTML element
|
||||||
* @returns True if the text can be copied, false otherwise
|
* @returns True if the text can be copied, false otherwise
|
||||||
*/
|
*/
|
||||||
@@ -42,6 +43,7 @@ export class ClipboardService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Copies text from an HTML element to the clipboard.
|
* Copies text from an HTML element to the clipboard.
|
||||||
|
*
|
||||||
* @param target HTML element to be copied
|
* @param target HTML element to be copied
|
||||||
* @param message Snackbar message to alert when copying happens
|
* @param message Snackbar message to alert when copying happens
|
||||||
*/
|
*/
|
||||||
@@ -60,6 +62,7 @@ export class ClipboardService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Copies a text string to the clipboard.
|
* Copies a text string to the clipboard.
|
||||||
|
*
|
||||||
* @param content Text to copy
|
* @param content Text to copy
|
||||||
* @param message Snackbar message to alert when copying happens
|
* @param message Snackbar message to alert when copying happens
|
||||||
*/
|
*/
|
||||||
|
@@ -81,14 +81,14 @@ describe('CommentsComponent', () => {
|
|||||||
|
|
||||||
it('should load comments when taskId specified', () => {
|
it('should load comments when taskId specified', () => {
|
||||||
const change = new SimpleChange(null, '123', true);
|
const change = new SimpleChange(null, '123', true);
|
||||||
component.ngOnChanges({'taskId': change});
|
component.ngOnChanges({taskId: change});
|
||||||
|
|
||||||
expect(getProcessCommentsSpy).toHaveBeenCalled();
|
expect(getProcessCommentsSpy).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should load comments when nodeId specified', () => {
|
it('should load comments when nodeId specified', () => {
|
||||||
const change = new SimpleChange(null, '123', true);
|
const change = new SimpleChange(null, '123', true);
|
||||||
component.ngOnChanges({'nodeId': change});
|
component.ngOnChanges({nodeId: change});
|
||||||
|
|
||||||
expect(getContentCommentsSpy).toHaveBeenCalled();
|
expect(getContentCommentsSpy).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
@@ -98,7 +98,7 @@ describe('CommentsComponent', () => {
|
|||||||
getProcessCommentsSpy.and.returnValue(throwError({}));
|
getProcessCommentsSpy.and.returnValue(throwError({}));
|
||||||
|
|
||||||
const change = new SimpleChange(null, '123', true);
|
const change = new SimpleChange(null, '123', true);
|
||||||
component.ngOnChanges({'taskId': change});
|
component.ngOnChanges({taskId: change});
|
||||||
|
|
||||||
expect(emitSpy).toHaveBeenCalled();
|
expect(emitSpy).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
@@ -110,7 +110,7 @@ describe('CommentsComponent', () => {
|
|||||||
|
|
||||||
it('should display comments when the task has comments', async () => {
|
it('should display comments when the task has comments', async () => {
|
||||||
const change = new SimpleChange(null, '123', true);
|
const change = new SimpleChange(null, '123', true);
|
||||||
component.ngOnChanges({'taskId': change});
|
component.ngOnChanges({taskId: change});
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
await fixture.whenStable();
|
await fixture.whenStable();
|
||||||
@@ -121,7 +121,7 @@ describe('CommentsComponent', () => {
|
|||||||
|
|
||||||
it('should display comments count when the task has comments', async () => {
|
it('should display comments count when the task has comments', async () => {
|
||||||
const change = new SimpleChange(null, '123', true);
|
const change = new SimpleChange(null, '123', true);
|
||||||
component.ngOnChanges({'taskId': change});
|
component.ngOnChanges({taskId: change});
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
await fixture.whenStable();
|
await fixture.whenStable();
|
||||||
@@ -142,7 +142,7 @@ describe('CommentsComponent', () => {
|
|||||||
|
|
||||||
it('should display comments input by default', async () => {
|
it('should display comments input by default', async () => {
|
||||||
const change = new SimpleChange(null, '123', true);
|
const change = new SimpleChange(null, '123', true);
|
||||||
component.ngOnChanges({'taskId': change});
|
component.ngOnChanges({taskId: change});
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
await fixture.whenStable();
|
await fixture.whenStable();
|
||||||
@@ -169,7 +169,7 @@ describe('CommentsComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should fetch new comments when taskId changed', () => {
|
it('should fetch new comments when taskId changed', () => {
|
||||||
component.ngOnChanges({'taskId': change});
|
component.ngOnChanges({taskId: change});
|
||||||
expect(getProcessCommentsSpy).toHaveBeenCalledWith('456');
|
expect(getProcessCommentsSpy).toHaveBeenCalledWith('456');
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -179,7 +179,7 @@ describe('CommentsComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should not fetch new comments when taskId changed to null', () => {
|
it('should not fetch new comments when taskId changed to null', () => {
|
||||||
component.ngOnChanges({'taskId': nullChange});
|
component.ngOnChanges({taskId: nullChange});
|
||||||
expect(getProcessCommentsSpy).not.toHaveBeenCalled();
|
expect(getProcessCommentsSpy).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -194,7 +194,7 @@ describe('CommentsComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should fetch new comments when nodeId changed', () => {
|
it('should fetch new comments when nodeId changed', () => {
|
||||||
component.ngOnChanges({'nodeId': change});
|
component.ngOnChanges({nodeId: change});
|
||||||
expect(getContentCommentsSpy).toHaveBeenCalledWith('456');
|
expect(getContentCommentsSpy).toHaveBeenCalledWith('456');
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -204,7 +204,7 @@ describe('CommentsComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should not fetch new comments when nodeId changed to null', () => {
|
it('should not fetch new comments when nodeId changed to null', () => {
|
||||||
component.ngOnChanges({'nodeId': nullChange});
|
component.ngOnChanges({nodeId: nullChange});
|
||||||
expect(getContentCommentsSpy).not.toHaveBeenCalled();
|
expect(getContentCommentsSpy).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -276,7 +276,7 @@ describe('CommentsComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should clear comment when escape key is pressed', async () => {
|
it('should clear comment when escape key is pressed', async () => {
|
||||||
const event = new KeyboardEvent('keydown', {'key': 'Escape'});
|
const event = new KeyboardEvent('keydown', {key: 'Escape'});
|
||||||
let element = fixture.nativeElement.querySelector('#comment-input');
|
let element = fixture.nativeElement.querySelector('#comment-input');
|
||||||
element.dispatchEvent(event);
|
element.dispatchEvent(event);
|
||||||
|
|
||||||
@@ -363,7 +363,7 @@ describe('CommentsComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should clear comment when escape key is pressed', async () => {
|
it('should clear comment when escape key is pressed', async () => {
|
||||||
const event = new KeyboardEvent('keydown', {'key': 'Escape'});
|
const event = new KeyboardEvent('keydown', {key: 'Escape'});
|
||||||
let element = fixture.nativeElement.querySelector('#comment-input');
|
let element = fixture.nativeElement.querySelector('#comment-input');
|
||||||
element.dispatchEvent(event);
|
element.dispatchEvent(event);
|
||||||
|
|
||||||
|
@@ -29,10 +29,10 @@ describe('ContextMenuOverlayService', () => {
|
|||||||
let injector: Injector;
|
let injector: Injector;
|
||||||
const overlayConfig = {
|
const overlayConfig = {
|
||||||
panelClass: 'test-panel',
|
panelClass: 'test-panel',
|
||||||
source: <MouseEvent> {
|
source: {
|
||||||
clientY: 1,
|
clientY: 1,
|
||||||
clientX: 1
|
clientX: 1
|
||||||
}
|
} as MouseEvent
|
||||||
};
|
};
|
||||||
|
|
||||||
setupTestBed({
|
setupTestBed({
|
||||||
|
@@ -52,10 +52,12 @@ export class ContextMenuOverlayService {
|
|||||||
|
|
||||||
// prevent native contextmenu on overlay element if config.hasBackdrop is true
|
// prevent native contextmenu on overlay element if config.hasBackdrop is true
|
||||||
if (overlayConfig.hasBackdrop) {
|
if (overlayConfig.hasBackdrop) {
|
||||||
(<any> overlay)._backdropElement
|
// eslint-disable-next-line no-underscore-dangle
|
||||||
|
(overlay as any)._backdropElement
|
||||||
.addEventListener('contextmenu', (event) => {
|
.addEventListener('contextmenu', (event) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
(<any> overlay)._backdropClick.next(null);
|
// eslint-disable-next-line no-underscore-dangle
|
||||||
|
(overlay as any)._backdropClick.next(null);
|
||||||
}, true);
|
}, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,7 +98,7 @@ export class ContextMenuOverlayService {
|
|||||||
right: clientX,
|
right: clientX,
|
||||||
top: clientY,
|
top: clientY,
|
||||||
width: 0
|
width: 0
|
||||||
})
|
} as any)
|
||||||
};
|
};
|
||||||
|
|
||||||
const positionStrategy = this.overlay.position()
|
const positionStrategy = this.overlay.position()
|
||||||
|
@@ -47,9 +47,9 @@ describe('DataTableCellComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should use column format', () => {
|
it('should use column format', () => {
|
||||||
const component = new DateCellComponent(null, <any> {
|
const component = new DateCellComponent(null, {
|
||||||
nodeUpdated: new Subject<any>()
|
nodeUpdated: new Subject<any>()
|
||||||
}, appConfigService);
|
} as any, appConfigService);
|
||||||
component.column = {
|
component.column = {
|
||||||
key: 'created',
|
key: 'created',
|
||||||
type: 'date',
|
type: 'date',
|
||||||
@@ -72,7 +72,7 @@ describe('DataTableCellComponent', () => {
|
|||||||
type: 'text'
|
type: 'text'
|
||||||
};
|
};
|
||||||
|
|
||||||
component.row = <any> {
|
component.row = {
|
||||||
cache: {
|
cache: {
|
||||||
name: 'some-name'
|
name: 'some-name'
|
||||||
},
|
},
|
||||||
@@ -82,14 +82,14 @@ describe('DataTableCellComponent', () => {
|
|||||||
name: 'test-name'
|
name: 'test-name'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
} as any;
|
||||||
|
|
||||||
component.ngOnInit();
|
component.ngOnInit();
|
||||||
|
|
||||||
alfrescoApiService.nodeUpdated.next(<Node> {
|
alfrescoApiService.nodeUpdated.next({
|
||||||
id: 'id',
|
id: 'id',
|
||||||
name: 'updated-name'
|
name: 'updated-name'
|
||||||
});
|
} as Node);
|
||||||
|
|
||||||
expect(component.row['node'].entry.name).toBe('updated-name');
|
expect(component.row['node'].entry.name).toBe('updated-name');
|
||||||
expect(component.row['cache'].name).toBe('updated-name');
|
expect(component.row['cache'].name).toBe('updated-name');
|
||||||
@@ -107,7 +107,7 @@ describe('DataTableCellComponent', () => {
|
|||||||
type: 'text'
|
type: 'text'
|
||||||
};
|
};
|
||||||
|
|
||||||
component.row = <any> {
|
component.row = {
|
||||||
cache: {
|
cache: {
|
||||||
name: 'some-name'
|
name: 'some-name'
|
||||||
},
|
},
|
||||||
@@ -117,14 +117,14 @@ describe('DataTableCellComponent', () => {
|
|||||||
name: 'test-name'
|
name: 'test-name'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
} as any;
|
||||||
|
|
||||||
component.ngOnInit();
|
component.ngOnInit();
|
||||||
|
|
||||||
alfrescoApiService.nodeUpdated.next(<Node> {
|
alfrescoApiService.nodeUpdated.next({
|
||||||
id: 'id',
|
id: 'id',
|
||||||
name: 'updated-name'
|
name: 'updated-name'
|
||||||
});
|
} as Node);
|
||||||
|
|
||||||
expect(component.row['node'].entry.name).not.toBe('updated-name');
|
expect(component.row['node'].entry.name).not.toBe('updated-name');
|
||||||
expect(component.row['cache'].name).not.toBe('updated-name');
|
expect(component.row['cache'].name).not.toBe('updated-name');
|
||||||
@@ -142,7 +142,7 @@ describe('DataTableCellComponent', () => {
|
|||||||
type: 'text'
|
type: 'text'
|
||||||
};
|
};
|
||||||
|
|
||||||
component.row = <any> {
|
component.row = {
|
||||||
cache: {
|
cache: {
|
||||||
name: 'some-name'
|
name: 'some-name'
|
||||||
},
|
},
|
||||||
@@ -155,7 +155,7 @@ describe('DataTableCellComponent', () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
} as any;
|
||||||
|
|
||||||
component.ngOnInit();
|
component.ngOnInit();
|
||||||
|
|
||||||
|
@@ -66,13 +66,13 @@ class FakeDataRow implements DataRow {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function resolverFn(row: DataRow, col: DataColumn) {
|
export const resolverFn = (row: DataRow, col: DataColumn) => {
|
||||||
const value = row.getValue(col.key);
|
const value = row.getValue(col.key);
|
||||||
if (col.key === 'name') {
|
if (col.key === 'name') {
|
||||||
return `${row.getValue('firstName')} - ${row.getValue('lastName')}`;
|
return `${row.getValue('firstName')} - ${row.getValue('lastName')}`;
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
}
|
};
|
||||||
|
|
||||||
describe('DataTable', () => {
|
describe('DataTable', () => {
|
||||||
|
|
||||||
@@ -599,10 +599,10 @@ describe('DataTable', () => {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
dataTable.onRowClick(rows[0], <any> {
|
dataTable.onRowClick(rows[0], {
|
||||||
metaKey: true, preventDefault() {
|
metaKey: true,
|
||||||
}
|
preventDefault: () => {}
|
||||||
});
|
} as any);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should unselect the row searching it by row id, when row id is defined', () => {
|
it('should unselect the row searching it by row id, when row id is defined', () => {
|
||||||
@@ -724,7 +724,7 @@ describe('DataTable', () => {
|
|||||||
it('should initialize default adapter', () => {
|
it('should initialize default adapter', () => {
|
||||||
const table = new DataTableComponent(null, null);
|
const table = new DataTableComponent(null, null);
|
||||||
expect(table.data).toBeUndefined();
|
expect(table.data).toBeUndefined();
|
||||||
table.ngOnChanges({ 'data': new SimpleChange('123', {}, true) });
|
table.ngOnChanges({ data: new SimpleChange('123', {}, true) });
|
||||||
expect(table.data).toEqual(jasmine.any(ObjectDataTableAdapter));
|
expect(table.data).toEqual(jasmine.any(ObjectDataTableAdapter));
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -736,7 +736,7 @@ describe('DataTable', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should emit row click event', (done) => {
|
it('should emit row click event', (done) => {
|
||||||
const row = <DataRow> {};
|
const row = {} as DataRow;
|
||||||
dataTable.data = new ObjectDataTableAdapter([], []);
|
dataTable.data = new ObjectDataTableAdapter([], []);
|
||||||
|
|
||||||
dataTable.rowClick.subscribe((e) => {
|
dataTable.rowClick.subscribe((e) => {
|
||||||
@@ -751,7 +751,7 @@ describe('DataTable', () => {
|
|||||||
|
|
||||||
it('should emit double click if there are two single click in 250ms', (done) => {
|
it('should emit double click if there are two single click in 250ms', (done) => {
|
||||||
|
|
||||||
const row = <DataRow> {};
|
const row = {} as DataRow;
|
||||||
dataTable.data = new ObjectDataTableAdapter([], []);
|
dataTable.data = new ObjectDataTableAdapter([], []);
|
||||||
dataTable.ngOnChanges({});
|
dataTable.ngOnChanges({});
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
@@ -768,8 +768,7 @@ describe('DataTable', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should emit double click if there are more than two single click in 250ms', (done) => {
|
it('should emit double click if there are more than two single click in 250ms', (done) => {
|
||||||
|
const row = {} as DataRow;
|
||||||
const row = <DataRow> {};
|
|
||||||
dataTable.data = new ObjectDataTableAdapter([], []);
|
dataTable.data = new ObjectDataTableAdapter([], []);
|
||||||
dataTable.ngOnChanges({});
|
dataTable.ngOnChanges({});
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
@@ -788,8 +787,7 @@ describe('DataTable', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should emit single click if there are two single click in more than 250ms', (done) => {
|
it('should emit single click if there are two single click in more than 250ms', (done) => {
|
||||||
|
const row = {} as DataRow;
|
||||||
const row = <DataRow> {};
|
|
||||||
let clickCount = 0;
|
let clickCount = 0;
|
||||||
|
|
||||||
dataTable.data = new ObjectDataTableAdapter([], []);
|
dataTable.data = new ObjectDataTableAdapter([], []);
|
||||||
@@ -811,7 +809,7 @@ describe('DataTable', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should emit row-click dom event', (done) => {
|
it('should emit row-click dom event', (done) => {
|
||||||
const row = <DataRow> {};
|
const row = {} as DataRow;
|
||||||
dataTable.data = new ObjectDataTableAdapter([], []);
|
dataTable.data = new ObjectDataTableAdapter([], []);
|
||||||
|
|
||||||
fixture.nativeElement.addEventListener('row-click', (e) => {
|
fixture.nativeElement.addEventListener('row-click', (e) => {
|
||||||
@@ -825,7 +823,7 @@ describe('DataTable', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should emit row-dblclick dom event', (done) => {
|
it('should emit row-dblclick dom event', (done) => {
|
||||||
const row = <DataRow> {};
|
const row = {} as DataRow;
|
||||||
dataTable.data = new ObjectDataTableAdapter([], []);
|
dataTable.data = new ObjectDataTableAdapter([], []);
|
||||||
|
|
||||||
fixture.nativeElement.addEventListener('row-dblclick', (e) => {
|
fixture.nativeElement.addEventListener('row-dblclick', (e) => {
|
||||||
@@ -854,7 +852,7 @@ describe('DataTable', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should not sort if column is missing', () => {
|
it('should not sort if column is missing', () => {
|
||||||
dataTable.ngOnChanges({ 'data': new SimpleChange('123', {}, true) });
|
dataTable.ngOnChanges({ data: new SimpleChange('123', {}, true) });
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
dataTable.ngAfterViewInit();
|
dataTable.ngAfterViewInit();
|
||||||
const adapter = dataTable.data;
|
const adapter = dataTable.data;
|
||||||
@@ -864,7 +862,7 @@ describe('DataTable', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should not sort upon clicking non-sortable column header', () => {
|
it('should not sort upon clicking non-sortable column header', () => {
|
||||||
dataTable.ngOnChanges({ 'data': new SimpleChange('123', {}, true) });
|
dataTable.ngOnChanges({ data: new SimpleChange('123', {}, true) });
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
dataTable.ngAfterViewInit();
|
dataTable.ngAfterViewInit();
|
||||||
const adapter = dataTable.data;
|
const adapter = dataTable.data;
|
||||||
@@ -879,7 +877,7 @@ describe('DataTable', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should set sorting upon column header clicked', () => {
|
it('should set sorting upon column header clicked', () => {
|
||||||
dataTable.ngOnChanges({ 'data': new SimpleChange('123', {}, true) });
|
dataTable.ngOnChanges({ data: new SimpleChange('123', {}, true) });
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
dataTable.ngAfterViewInit();
|
dataTable.ngAfterViewInit();
|
||||||
const adapter = dataTable.data;
|
const adapter = dataTable.data;
|
||||||
@@ -900,7 +898,7 @@ describe('DataTable', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should invert sorting upon column header clicked', () => {
|
it('should invert sorting upon column header clicked', () => {
|
||||||
dataTable.ngOnChanges({ 'data': new SimpleChange('123', {}, true) });
|
dataTable.ngOnChanges({ data: new SimpleChange('123', {}, true) });
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
dataTable.ngAfterViewInit();
|
dataTable.ngAfterViewInit();
|
||||||
|
|
||||||
@@ -970,9 +968,9 @@ describe('DataTable', () => {
|
|||||||
|
|
||||||
it('should invert "select all" status', () => {
|
it('should invert "select all" status', () => {
|
||||||
expect(dataTable.isSelectAllChecked).toBeFalsy();
|
expect(dataTable.isSelectAllChecked).toBeFalsy();
|
||||||
dataTable.onSelectAllClick(<MatCheckboxChange> { checked: true });
|
dataTable.onSelectAllClick({ checked: true } as MatCheckboxChange);
|
||||||
expect(dataTable.isSelectAllChecked).toBeTruthy();
|
expect(dataTable.isSelectAllChecked).toBeTruthy();
|
||||||
dataTable.onSelectAllClick(<MatCheckboxChange> { checked: false });
|
dataTable.onSelectAllClick({ checked: false } as MatCheckboxChange);
|
||||||
expect(dataTable.isSelectAllChecked).toBeFalsy();
|
expect(dataTable.isSelectAllChecked).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -982,7 +980,7 @@ describe('DataTable', () => {
|
|||||||
dataTable.data = data;
|
dataTable.data = data;
|
||||||
dataTable.multiselect = true;
|
dataTable.multiselect = true;
|
||||||
dataTable.ngAfterContentInit();
|
dataTable.ngAfterContentInit();
|
||||||
dataTable.onSelectAllClick(<MatCheckboxChange> { checked: true });
|
dataTable.onSelectAllClick({ checked: true } as MatCheckboxChange);
|
||||||
|
|
||||||
expect(dataTable.selection.every((entry) => entry.isSelected));
|
expect(dataTable.selection.every((entry) => entry.isSelected));
|
||||||
|
|
||||||
@@ -1000,13 +998,13 @@ describe('DataTable', () => {
|
|||||||
dataTable.multiselect = true;
|
dataTable.multiselect = true;
|
||||||
dataTable.ngAfterContentInit();
|
dataTable.ngAfterContentInit();
|
||||||
|
|
||||||
dataTable.onSelectAllClick(<MatCheckboxChange> { checked: true });
|
dataTable.onSelectAllClick({ checked: true } as MatCheckboxChange);
|
||||||
expect(dataTable.isSelectAllChecked).toBe(true);
|
expect(dataTable.isSelectAllChecked).toBe(true);
|
||||||
for (let i = 0; i < rows.length; i++) {
|
for (let i = 0; i < rows.length; i++) {
|
||||||
expect(rows[i].isSelected).toBe(true);
|
expect(rows[i].isSelected).toBe(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
dataTable.onSelectAllClick(<MatCheckboxChange> { checked: false });
|
dataTable.onSelectAllClick({ checked: false } as MatCheckboxChange);
|
||||||
expect(dataTable.isSelectAllChecked).toBe(false);
|
expect(dataTable.isSelectAllChecked).toBe(false);
|
||||||
for (let i = 0; i < rows.length; i++) {
|
for (let i = 0; i < rows.length; i++) {
|
||||||
expect(rows[i].isSelected).toBe(false);
|
expect(rows[i].isSelected).toBe(false);
|
||||||
@@ -1015,9 +1013,9 @@ describe('DataTable', () => {
|
|||||||
|
|
||||||
it('should allow "select all" calls with no rows', () => {
|
it('should allow "select all" calls with no rows', () => {
|
||||||
dataTable.multiselect = true;
|
dataTable.multiselect = true;
|
||||||
dataTable.ngOnChanges({ 'data': new SimpleChange('123', {}, true) });
|
dataTable.ngOnChanges({ data: new SimpleChange('123', {}, true) });
|
||||||
|
|
||||||
dataTable.onSelectAllClick(<MatCheckboxChange> { checked: true });
|
dataTable.onSelectAllClick({ checked: true } as MatCheckboxChange);
|
||||||
expect(dataTable.isSelectAllChecked).toBe(true);
|
expect(dataTable.isSelectAllChecked).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1032,16 +1030,16 @@ describe('DataTable', () => {
|
|||||||
const rows = dataTable.data.getRows();
|
const rows = dataTable.data.getRows();
|
||||||
|
|
||||||
dataTable.multiselect = true;
|
dataTable.multiselect = true;
|
||||||
dataTable.onCheckboxChange(rows[0], <MatCheckboxChange> { checked: true });
|
dataTable.onCheckboxChange(rows[0], { checked: true } as MatCheckboxChange);
|
||||||
expect(dataTable.isSelectAllIndeterminate).toBe(true);
|
expect(dataTable.isSelectAllIndeterminate).toBe(true);
|
||||||
expect(dataTable.isSelectAllChecked).toBe(false);
|
expect(dataTable.isSelectAllChecked).toBe(false);
|
||||||
|
|
||||||
dataTable.onCheckboxChange(rows[1], <MatCheckboxChange> { checked: true });
|
dataTable.onCheckboxChange(rows[1], { checked: true } as MatCheckboxChange);
|
||||||
expect(dataTable.isSelectAllIndeterminate).toBe(false);
|
expect(dataTable.isSelectAllIndeterminate).toBe(false);
|
||||||
expect(dataTable.isSelectAllChecked).toBe(true);
|
expect(dataTable.isSelectAllChecked).toBe(true);
|
||||||
|
|
||||||
dataTable.onCheckboxChange(rows[0], <MatCheckboxChange> { checked: false });
|
dataTable.onCheckboxChange(rows[0], { checked: false } as MatCheckboxChange);
|
||||||
dataTable.onCheckboxChange(rows[1], <MatCheckboxChange> { checked: false });
|
dataTable.onCheckboxChange(rows[1], { checked: false } as MatCheckboxChange);
|
||||||
expect(dataTable.isSelectAllIndeterminate).toBe(false);
|
expect(dataTable.isSelectAllIndeterminate).toBe(false);
|
||||||
expect(dataTable.isSelectAllChecked).toBe(false);
|
expect(dataTable.isSelectAllChecked).toBe(false);
|
||||||
});
|
});
|
||||||
@@ -1051,16 +1049,16 @@ describe('DataTable', () => {
|
|||||||
const rows = data.getRows();
|
const rows = data.getRows();
|
||||||
|
|
||||||
dataTable.multiselect = true;
|
dataTable.multiselect = true;
|
||||||
dataTable.ngOnChanges({ 'data': new SimpleChange('123', data, true) });
|
dataTable.ngOnChanges({ data: new SimpleChange('123', data, true) });
|
||||||
|
|
||||||
expect(rows[0].isSelected).toBe(false);
|
expect(rows[0].isSelected).toBe(false);
|
||||||
expect(rows[1].isSelected).toBe(false);
|
expect(rows[1].isSelected).toBe(false);
|
||||||
|
|
||||||
dataTable.onCheckboxChange(rows[1], <MatCheckboxChange> { checked: true });
|
dataTable.onCheckboxChange(rows[1], { checked: true } as MatCheckboxChange);
|
||||||
expect(rows[0].isSelected).toBe(false);
|
expect(rows[0].isSelected).toBe(false);
|
||||||
expect(rows[1].isSelected).toBe(true);
|
expect(rows[1].isSelected).toBe(true);
|
||||||
|
|
||||||
dataTable.onCheckboxChange(rows[0], <MatCheckboxChange> { checked: true });
|
dataTable.onCheckboxChange(rows[0], { checked: true } as MatCheckboxChange);
|
||||||
expect(rows[0].isSelected).toBe(true);
|
expect(rows[0].isSelected).toBe(true);
|
||||||
expect(rows[1].isSelected).toBe(true);
|
expect(rows[1].isSelected).toBe(true);
|
||||||
});
|
});
|
||||||
@@ -1073,7 +1071,7 @@ describe('DataTable', () => {
|
|||||||
dataTable.multiselect = false;
|
dataTable.multiselect = false;
|
||||||
dataTable.ngAfterContentInit();
|
dataTable.ngAfterContentInit();
|
||||||
|
|
||||||
dataTable.onSelectAllClick(<MatCheckboxChange> { checked: true });
|
dataTable.onSelectAllClick({ checked: true } as MatCheckboxChange);
|
||||||
expect(dataTable.isSelectAllChecked).toBe(true);
|
expect(dataTable.isSelectAllChecked).toBe(true);
|
||||||
for (let i = 0; i < rows.length; i++) {
|
for (let i = 0; i < rows.length; i++) {
|
||||||
expect(rows[i].isSelected).toBe(false);
|
expect(rows[i].isSelected).toBe(false);
|
||||||
@@ -1082,53 +1080,45 @@ describe('DataTable', () => {
|
|||||||
|
|
||||||
it('should require row and column for icon value check', () => {
|
it('should require row and column for icon value check', () => {
|
||||||
expect(dataTable.isIconValue(null, null)).toBeFalsy();
|
expect(dataTable.isIconValue(null, null)).toBeFalsy();
|
||||||
expect(dataTable.isIconValue(<DataRow> {}, null)).toBeFalsy();
|
expect(dataTable.isIconValue({} as DataRow, null)).toBeFalsy();
|
||||||
expect(dataTable.isIconValue(null, <DataColumn> {})).toBeFalsy();
|
expect(dataTable.isIconValue(null, {} as DataColumn)).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should use special material url scheme', () => {
|
it('should use special material url scheme', () => {
|
||||||
const column = <DataColumn> {};
|
const column = {} as DataColumn;
|
||||||
|
|
||||||
const row: any = {
|
const row: any = {
|
||||||
getValue: function() {
|
getValue: () => 'material-icons://android'
|
||||||
return 'material-icons://android';
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(dataTable.isIconValue(row, column)).toBeTruthy();
|
expect(dataTable.isIconValue(row, column)).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not use special material url scheme', () => {
|
it('should not use special material url scheme', () => {
|
||||||
const column = <DataColumn> {};
|
const column = {} as DataColumn;
|
||||||
|
|
||||||
const row: any = {
|
const row: any = {
|
||||||
getValue: function() {
|
getValue: () => 'http://www.google.com'
|
||||||
return 'http://www.google.com';
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(dataTable.isIconValue(row, column)).toBeFalsy();
|
expect(dataTable.isIconValue(row, column)).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should parse icon value', () => {
|
it('should parse icon value', () => {
|
||||||
const column = <DataColumn> {};
|
const column = {} as DataColumn;
|
||||||
|
|
||||||
const row: any = {
|
const row: any = {
|
||||||
getValue: function() {
|
getValue: () => 'material-icons://android'
|
||||||
return 'material-icons://android';
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(dataTable.asIconValue(row, column)).toBe('android');
|
expect(dataTable.asIconValue(row, column)).toBe('android');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not parse icon value', () => {
|
it('should not parse icon value', () => {
|
||||||
const column = <DataColumn> {};
|
const column = {} as DataColumn;
|
||||||
|
|
||||||
const row: any = {
|
const row: any = {
|
||||||
getValue: function() {
|
getValue: () => 'http://www.google.com'
|
||||||
return 'http://www.google.com';
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(dataTable.asIconValue(row, column)).toBe(null);
|
expect(dataTable.asIconValue(row, column)).toBe(null);
|
||||||
@@ -1142,29 +1132,29 @@ describe('DataTable', () => {
|
|||||||
|
|
||||||
it('should require column and direction to evaluate sorting state', () => {
|
it('should require column and direction to evaluate sorting state', () => {
|
||||||
expect(dataTable.isColumnSorted(null, null)).toBeFalsy();
|
expect(dataTable.isColumnSorted(null, null)).toBeFalsy();
|
||||||
expect(dataTable.isColumnSorted(<DataColumn> {}, null)).toBeFalsy();
|
expect(dataTable.isColumnSorted({} as DataColumn, null)).toBeFalsy();
|
||||||
expect(dataTable.isColumnSorted(null, 'asc')).toBeFalsy();
|
expect(dataTable.isColumnSorted(null, 'asc')).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should require adapter sorting to evaluate sorting state', () => {
|
it('should require adapter sorting to evaluate sorting state', () => {
|
||||||
dataTable.ngOnChanges({ 'data': new SimpleChange('123', {}, true) });
|
dataTable.ngOnChanges({ data: new SimpleChange('123', {}, true) });
|
||||||
spyOn(dataTable.data, 'getSorting').and.returnValue(null);
|
spyOn(dataTable.data, 'getSorting').and.returnValue(null);
|
||||||
expect(dataTable.isColumnSorted(<DataColumn> {}, 'asc')).toBeFalsy();
|
expect(dataTable.isColumnSorted({} as DataColumn, 'asc')).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should evaluate column sorting state', () => {
|
it('should evaluate column sorting state', () => {
|
||||||
dataTable.ngOnChanges({ 'data': new SimpleChange('123', {}, true) });
|
dataTable.ngOnChanges({ data: new SimpleChange('123', {}, true) });
|
||||||
spyOn(dataTable.data, 'getSorting').and.returnValue(new DataSorting('column_1', 'asc'));
|
spyOn(dataTable.data, 'getSorting').and.returnValue(new DataSorting('column_1', 'asc'));
|
||||||
expect(dataTable.isColumnSorted(<DataColumn> { key: 'column_1' }, 'asc')).toBeTruthy();
|
expect(dataTable.isColumnSorted({ key: 'column_1' } as DataColumn, 'asc')).toBeTruthy();
|
||||||
expect(dataTable.isColumnSorted(<DataColumn> { key: 'column_2' }, 'desc')).toBeFalsy();
|
expect(dataTable.isColumnSorted({ key: 'column_2' } as DataColumn, 'desc')).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should replace image source with fallback thumbnail on error', () => {
|
it('should replace image source with fallback thumbnail on error', () => {
|
||||||
const event = <any> {
|
const event = {
|
||||||
target: {
|
target: {
|
||||||
src: 'missing-image'
|
src: 'missing-image'
|
||||||
}
|
}
|
||||||
};
|
} as any;
|
||||||
const row = new FakeDataRow();
|
const row = new FakeDataRow();
|
||||||
dataTable.fallbackThumbnail = '<fallback>';
|
dataTable.fallbackThumbnail = '<fallback>';
|
||||||
dataTable.onImageLoadingError(event, row);
|
dataTable.onImageLoadingError(event, row);
|
||||||
@@ -1173,11 +1163,11 @@ describe('DataTable', () => {
|
|||||||
|
|
||||||
it('should replace image source with miscellaneous icon when fallback is not available', () => {
|
it('should replace image source with miscellaneous icon when fallback is not available', () => {
|
||||||
const originalSrc = 'missing-image';
|
const originalSrc = 'missing-image';
|
||||||
const event = <any> {
|
const event = {
|
||||||
target: {
|
target: {
|
||||||
src: originalSrc
|
src: originalSrc
|
||||||
}
|
}
|
||||||
};
|
} as any;
|
||||||
const row = new FakeDataRow();
|
const row = new FakeDataRow();
|
||||||
dataTable.fallbackThumbnail = null;
|
dataTable.fallbackThumbnail = null;
|
||||||
dataTable.onImageLoadingError(event, row);
|
dataTable.onImageLoadingError(event, row);
|
||||||
@@ -1185,39 +1175,39 @@ describe('DataTable', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should not get cell tooltip when row is not provided', () => {
|
it('should not get cell tooltip when row is not provided', () => {
|
||||||
const col = <DataColumn> { key: 'name', type: 'text' };
|
const col = { key: 'name', type: 'text' } as DataColumn;
|
||||||
expect(dataTable.getCellTooltip(null, col)).toBeNull();
|
expect(dataTable.getCellTooltip(null, col)).toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not get cell tooltip when column is not provided', () => {
|
it('should not get cell tooltip when column is not provided', () => {
|
||||||
const row = <DataRow> {};
|
const row = {} as DataRow;
|
||||||
expect(dataTable.getCellTooltip(row, null)).toBeNull();
|
expect(dataTable.getCellTooltip(row, null)).toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not get cell tooltip when formatter is not provided', () => {
|
it('should not get cell tooltip when formatter is not provided', () => {
|
||||||
const col = <DataColumn> { key: 'name', type: 'text' };
|
const col = { key: 'name', type: 'text' } as DataColumn;
|
||||||
const row = <DataRow> {};
|
const row = {} as DataRow;
|
||||||
expect(dataTable.getCellTooltip(row, col)).toBeNull();
|
expect(dataTable.getCellTooltip(row, col)).toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should use formatter function to generate tooltip', () => {
|
it('should use formatter function to generate tooltip', () => {
|
||||||
const tooltip = 'tooltip value';
|
const tooltip = 'tooltip value';
|
||||||
const col = <DataColumn> {
|
const col = {
|
||||||
key: 'name',
|
key: 'name',
|
||||||
type: 'text',
|
type: 'text',
|
||||||
formatTooltip: () => tooltip
|
formatTooltip: () => tooltip
|
||||||
};
|
} as DataColumn;
|
||||||
const row = <DataRow> {};
|
const row = {} as DataRow;
|
||||||
expect(dataTable.getCellTooltip(row, col)).toBe(tooltip);
|
expect(dataTable.getCellTooltip(row, col)).toBe(tooltip);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return null value from the tooltip formatter', () => {
|
it('should return null value from the tooltip formatter', () => {
|
||||||
const col = <DataColumn> {
|
const col = {
|
||||||
key: 'name',
|
key: 'name',
|
||||||
type: 'text',
|
type: 'text',
|
||||||
formatTooltip: () => null
|
formatTooltip: () => null
|
||||||
};
|
} as DataColumn;
|
||||||
const row = <DataRow> {};
|
const row = {} as DataRow;
|
||||||
expect(dataTable.getCellTooltip(row, col)).toBeNull();
|
expect(dataTable.getCellTooltip(row, col)).toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1227,15 +1217,13 @@ describe('DataTable', () => {
|
|||||||
emitted++;
|
emitted++;
|
||||||
});
|
});
|
||||||
|
|
||||||
const column = <DataColumn> {};
|
const column = {} as any;
|
||||||
const row: any = {
|
const row: any = {
|
||||||
getValue: function() {
|
getValue: () => 'id'
|
||||||
return 'id';
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
dataTable.getRowActions(row, column);
|
dataTable.getRowActions(row, column);
|
||||||
dataTable.ngOnChanges({ 'data': new SimpleChange('123', {}, true) });
|
dataTable.ngOnChanges({ data: new SimpleChange('123', {}, true) });
|
||||||
dataTable.getRowActions(row, column);
|
dataTable.getRowActions(row, column);
|
||||||
|
|
||||||
expect(emitted).toBe(2);
|
expect(emitted).toBe(2);
|
||||||
@@ -1340,7 +1328,7 @@ describe('DataTable', () => {
|
|||||||
|
|
||||||
const newDataColumnsSchema = { key: 'new-column'};
|
const newDataColumnsSchema = { key: 'new-column'};
|
||||||
const columnsChange = new SimpleChange(null, [newDataColumnsSchema], false);
|
const columnsChange = new SimpleChange(null, [newDataColumnsSchema], false);
|
||||||
dataTable.ngOnChanges({ 'columns': columnsChange });
|
dataTable.ngOnChanges({ columns: columnsChange });
|
||||||
const expectedNewDataColumns = [new ObjectDataColumn(newDataColumnsSchema)];
|
const expectedNewDataColumns = [new ObjectDataColumn(newDataColumnsSchema)];
|
||||||
expect(dataTable.data.getColumns()).toEqual(expectedNewDataColumns);
|
expect(dataTable.data.getColumns()).toEqual(expectedNewDataColumns);
|
||||||
});
|
});
|
||||||
|
@@ -41,11 +41,13 @@ import { DataCellEvent } from '../data-cell.event';
|
|||||||
import { DataRowActionEvent } from '../data-row-action.event';
|
import { DataRowActionEvent } from '../data-row-action.event';
|
||||||
import { share, buffer, map, filter, debounceTime } from 'rxjs/operators';
|
import { share, buffer, map, filter, debounceTime } from 'rxjs/operators';
|
||||||
|
|
||||||
|
// eslint-disable-next-line no-shadow
|
||||||
export enum DisplayMode {
|
export enum DisplayMode {
|
||||||
List = 'list',
|
List = 'list',
|
||||||
Gallery = 'gallery'
|
Gallery = 'gallery'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// eslint-disable-next-line no-shadow
|
||||||
export enum ShowHeaderMode {
|
export enum ShowHeaderMode {
|
||||||
Never = 'never',
|
Never = 'never',
|
||||||
Always = 'always',
|
Always = 'always',
|
||||||
@@ -330,7 +332,7 @@ export class DataTableComponent implements AfterContentInit, OnChanges, DoCheck,
|
|||||||
|
|
||||||
this.singleClickStreamSub = singleClickStream.subscribe((dataRowEvents: DataRowEvent[]) => {
|
this.singleClickStreamSub = singleClickStream.subscribe((dataRowEvents: DataRowEvent[]) => {
|
||||||
const event: DataRowEvent = dataRowEvents[0];
|
const event: DataRowEvent = dataRowEvents[0];
|
||||||
this.handleRowSelection(event.value, <MouseEvent | KeyboardEvent> event.event);
|
this.handleRowSelection(event.value, event.event as any);
|
||||||
this.rowClick.emit(event);
|
this.rowClick.emit(event);
|
||||||
if (!event.defaultPrevented) {
|
if (!event.defaultPrevented) {
|
||||||
this.elementRef.nativeElement.dispatchEvent(
|
this.elementRef.nativeElement.dispatchEvent(
|
||||||
@@ -431,7 +433,7 @@ export class DataTableComponent implements AfterContentInit, OnChanges, DoCheck,
|
|||||||
public getSchemaFromHtml(): any {
|
public getSchemaFromHtml(): any {
|
||||||
let schema = [];
|
let schema = [];
|
||||||
if (this.columnList && this.columnList.columns && this.columnList.columns.length > 0) {
|
if (this.columnList && this.columnList.columns && this.columnList.columns.length > 0) {
|
||||||
schema = this.columnList.columns.map((c) => <DataColumn> c);
|
schema = this.columnList.columns.map((c) => c as DataColumn);
|
||||||
}
|
}
|
||||||
return schema;
|
return schema;
|
||||||
}
|
}
|
||||||
@@ -515,8 +517,8 @@ export class DataTableComponent implements AfterContentInit, OnChanges, DoCheck,
|
|||||||
onRowKeyUp(row: DataRow, keyboardEvent: KeyboardEvent) {
|
onRowKeyUp(row: DataRow, keyboardEvent: KeyboardEvent) {
|
||||||
const event = new CustomEvent('row-keyup', {
|
const event = new CustomEvent('row-keyup', {
|
||||||
detail: {
|
detail: {
|
||||||
row: row,
|
row,
|
||||||
keyboardEvent: keyboardEvent,
|
keyboardEvent,
|
||||||
sender: this
|
sender: this
|
||||||
},
|
},
|
||||||
bubbles: true
|
bubbles: true
|
||||||
@@ -613,7 +615,7 @@ export class DataTableComponent implements AfterContentInit, OnChanges, DoCheck,
|
|||||||
|
|
||||||
onImageLoadingError(event: Event, row: DataRow) {
|
onImageLoadingError(event: Event, row: DataRow) {
|
||||||
if (event) {
|
if (event) {
|
||||||
const element = <any> event.target;
|
const element = event.target as any;
|
||||||
|
|
||||||
if (this.fallbackThumbnail) {
|
if (this.fallbackThumbnail) {
|
||||||
element.src = this.fallbackThumbnail;
|
element.src = this.fallbackThumbnail;
|
||||||
@@ -749,9 +751,7 @@ export class DataTableComponent implements AfterContentInit, OnChanges, DoCheck,
|
|||||||
}
|
}
|
||||||
|
|
||||||
getSortableColumns() {
|
getSortableColumns() {
|
||||||
return this.data.getColumns().filter((column) => {
|
return this.data.getColumns().filter((column) => column.sortable === true);
|
||||||
return column.sortable === true;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
isEmpty() {
|
isEmpty() {
|
||||||
@@ -778,7 +778,7 @@ export class DataTableComponent implements AfterContentInit, OnChanges, DoCheck,
|
|||||||
private emitRowSelectionEvent(name: string, row: DataRow) {
|
private emitRowSelectionEvent(name: string, row: DataRow) {
|
||||||
const domEvent = new CustomEvent(name, {
|
const domEvent = new CustomEvent(name, {
|
||||||
detail: {
|
detail: {
|
||||||
row: row,
|
row,
|
||||||
selection: this.selection
|
selection: this.selection
|
||||||
},
|
},
|
||||||
bubbles: true
|
bubbles: true
|
||||||
@@ -823,9 +823,7 @@ export class DataTableComponent implements AfterContentInit, OnChanges, DoCheck,
|
|||||||
}
|
}
|
||||||
|
|
||||||
getNameColumnValue() {
|
getNameColumnValue() {
|
||||||
return this.data.getColumns().find( (el: any) => {
|
return this.data.getColumns().find( (el: any) => el.key.includes('name'));
|
||||||
return el.key.includes('name');
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getAutomationValue(row: DataRow): any {
|
getAutomationValue(row: DataRow): any {
|
||||||
|
@@ -47,9 +47,9 @@ describe('JsonCellComponent', () => {
|
|||||||
rowData = {
|
rowData = {
|
||||||
name: '1',
|
name: '1',
|
||||||
entity: {
|
entity: {
|
||||||
'name': 'test',
|
name: 'test',
|
||||||
'description': 'this is a test',
|
description: 'this is a test',
|
||||||
'version': 1
|
version: 1
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -67,7 +67,7 @@ export abstract class DataTableSchema {
|
|||||||
public getSchemaFromHtml(columnList: DataColumnListComponent): any {
|
public getSchemaFromHtml(columnList: DataColumnListComponent): any {
|
||||||
let schema = [];
|
let schema = [];
|
||||||
if (columnList && columnList.columns && columnList.columns.length > 0) {
|
if (columnList && columnList.columns && columnList.columns.length > 0) {
|
||||||
schema = columnList.columns.map((c) => <DataColumn> c);
|
schema = columnList.columns.map((c) => c as DataColumn);
|
||||||
}
|
}
|
||||||
return schema;
|
return schema;
|
||||||
}
|
}
|
||||||
|
@@ -28,7 +28,7 @@ export interface DataTableAdapter {
|
|||||||
setRows(rows: Array<DataRow>): void;
|
setRows(rows: Array<DataRow>): void;
|
||||||
getColumns(): Array<DataColumn>;
|
getColumns(): Array<DataColumn>;
|
||||||
setColumns(columns: Array<DataColumn>): void;
|
setColumns(columns: Array<DataColumn>): void;
|
||||||
getValue(row: DataRow, col: DataColumn, resolverFn?: (row: DataRow, col: DataColumn) => any): any;
|
getValue(row: DataRow, col: DataColumn, resolverFn?: (_row: DataRow, _col: DataColumn) => any): any;
|
||||||
getSorting(): DataSorting;
|
getSorting(): DataSorting;
|
||||||
setSorting(sorting: DataSorting): void;
|
setSorting(sorting: DataSorting): void;
|
||||||
sort(key?: string, direction?: string): void;
|
sort(key?: string, direction?: string): void;
|
||||||
|
@@ -47,8 +47,8 @@ describe('ObjectDataTableAdapter', () => {
|
|||||||
|
|
||||||
it('should map columns without rows', () => {
|
it('should map columns without rows', () => {
|
||||||
const adapter = new ObjectDataTableAdapter(null, [
|
const adapter = new ObjectDataTableAdapter(null, [
|
||||||
<DataColumn> {},
|
{} as DataColumn,
|
||||||
<DataColumn> {}
|
{} as DataColumn
|
||||||
]);
|
]);
|
||||||
const columns = adapter.getColumns();
|
const columns = adapter.getColumns();
|
||||||
|
|
||||||
@@ -64,10 +64,7 @@ describe('ObjectDataTableAdapter', () => {
|
|||||||
|
|
||||||
it('should apply new rows array', () => {
|
it('should apply new rows array', () => {
|
||||||
const adapter = new ObjectDataTableAdapter([], []);
|
const adapter = new ObjectDataTableAdapter([], []);
|
||||||
const newRows = [
|
const newRows = [{}, {}] as DataRow[];
|
||||||
<DataRow> {},
|
|
||||||
<DataRow> {}
|
|
||||||
];
|
|
||||||
|
|
||||||
adapter.setRows(newRows);
|
adapter.setRows(newRows);
|
||||||
expect(adapter.getRows()).toBe(newRows);
|
expect(adapter.getRows()).toBe(newRows);
|
||||||
@@ -102,10 +99,7 @@ describe('ObjectDataTableAdapter', () => {
|
|||||||
|
|
||||||
it('should apply new columns array', () => {
|
it('should apply new columns array', () => {
|
||||||
const adapter = new ObjectDataTableAdapter([], []);
|
const adapter = new ObjectDataTableAdapter([], []);
|
||||||
const columns = [
|
const columns = [{},{}] as DataColumn[];
|
||||||
<DataColumn> {},
|
|
||||||
<DataColumn> {}
|
|
||||||
];
|
|
||||||
|
|
||||||
adapter.setColumns(columns);
|
adapter.setColumns(columns);
|
||||||
expect(adapter.getColumns()).toBe(columns);
|
expect(adapter.getColumns()).toBe(columns);
|
||||||
@@ -123,8 +117,8 @@ describe('ObjectDataTableAdapter', () => {
|
|||||||
|
|
||||||
it('should reset columns by null value', () => {
|
it('should reset columns by null value', () => {
|
||||||
const adapter = new ObjectDataTableAdapter([], [
|
const adapter = new ObjectDataTableAdapter([], [
|
||||||
<DataColumn> {},
|
{} as DataColumn,
|
||||||
<DataColumn> {}
|
{} as DataColumn
|
||||||
]);
|
]);
|
||||||
expect(adapter.getColumns()).toBeDefined();
|
expect(adapter.getColumns()).toBeDefined();
|
||||||
expect(adapter.getColumns().length).toBe(2);
|
expect(adapter.getColumns().length).toBe(2);
|
||||||
@@ -144,7 +138,7 @@ describe('ObjectDataTableAdapter', () => {
|
|||||||
it('should fail getting value with column not defined', () => {
|
it('should fail getting value with column not defined', () => {
|
||||||
const adapter = new ObjectDataTableAdapter([], []);
|
const adapter = new ObjectDataTableAdapter([], []);
|
||||||
expect(() => {
|
expect(() => {
|
||||||
adapter.getValue(<DataRow> {}, null);
|
adapter.getValue({} as DataRow, null);
|
||||||
}).toThrowError('Column not found');
|
}).toThrowError('Column not found');
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -155,7 +149,7 @@ describe('ObjectDataTableAdapter', () => {
|
|||||||
row.getValue.and.returnValue(value);
|
row.getValue.and.returnValue(value);
|
||||||
|
|
||||||
const adapter = new ObjectDataTableAdapter([], []);
|
const adapter = new ObjectDataTableAdapter([], []);
|
||||||
const result = adapter.getValue(row, <DataColumn> { key: 'col1' });
|
const result = adapter.getValue(row, { key: 'col1' } as DataColumn);
|
||||||
|
|
||||||
expect(row.getValue).toHaveBeenCalledWith('col1');
|
expect(row.getValue).toHaveBeenCalledWith('col1');
|
||||||
expect(result).toBe(value);
|
expect(result).toBe(value);
|
||||||
@@ -206,7 +200,7 @@ describe('ObjectDataTableAdapter', () => {
|
|||||||
|
|
||||||
it('should take first sortable column by default', () => {
|
it('should take first sortable column by default', () => {
|
||||||
const adapter = new ObjectDataTableAdapter([], [
|
const adapter = new ObjectDataTableAdapter([], [
|
||||||
<DataColumn> { key: 'icon' },
|
{ key: 'icon' } as DataColumn,
|
||||||
new ObjectDataColumn({ key: 'id', sortable: true })
|
new ObjectDataColumn({ key: 'id', sortable: true })
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@@ -225,8 +219,8 @@ describe('ObjectDataTableAdapter', () => {
|
|||||||
{ id: 2, created: new Date(2016, 7, 6, 15, 7, 1) }
|
{ id: 2, created: new Date(2016, 7, 6, 15, 7, 1) }
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
<DataColumn> { key: 'id' },
|
{ key: 'id' } as DataColumn,
|
||||||
<DataColumn> { key: 'created' }
|
{ key: 'created' } as DataColumn
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -304,9 +298,7 @@ describe('ObjectDataTableAdapter', () => {
|
|||||||
describe('ObjectDataRow', () => {
|
describe('ObjectDataRow', () => {
|
||||||
|
|
||||||
it('should require object source', () => {
|
it('should require object source', () => {
|
||||||
expect(() => {
|
expect(() => new ObjectDataRow(null)).toThrowError('Object source not found');
|
||||||
return new ObjectDataRow(null);
|
|
||||||
}).toThrowError('Object source not found');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should get top level property value', () => {
|
it('should get top level property value', () => {
|
||||||
|
@@ -44,7 +44,7 @@ export class ObjectDataTableAdapter implements DataTableAdapter {
|
|||||||
if (rowToExaminate.hasOwnProperty(key)) {
|
if (rowToExaminate.hasOwnProperty(key)) {
|
||||||
schema.push({
|
schema.push({
|
||||||
type: 'text',
|
type: 'text',
|
||||||
key: key,
|
key,
|
||||||
title: key,
|
title: key,
|
||||||
sortable: false
|
sortable: false
|
||||||
});
|
});
|
||||||
@@ -61,15 +61,11 @@ export class ObjectDataTableAdapter implements DataTableAdapter {
|
|||||||
this._columns = [];
|
this._columns = [];
|
||||||
|
|
||||||
if (data && data.length > 0) {
|
if (data && data.length > 0) {
|
||||||
this._rows = data.map((item) => {
|
this._rows = data.map((item) => new ObjectDataRow(item));
|
||||||
return new ObjectDataRow(item);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (schema && schema.length > 0) {
|
if (schema && schema.length > 0) {
|
||||||
this._columns = schema.map((item) => {
|
this._columns = schema.map((item) => new ObjectDataColumn(item));
|
||||||
return new ObjectDataColumn(item);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Sort by first sortable or just first column
|
// Sort by first sortable or just first column
|
||||||
const sortable = this._columns.filter((column) => column.sortable);
|
const sortable = this._columns.filter((column) => column.sortable);
|
||||||
@@ -99,7 +95,7 @@ export class ObjectDataTableAdapter implements DataTableAdapter {
|
|||||||
this._columns = columns || [];
|
this._columns = columns || [];
|
||||||
}
|
}
|
||||||
|
|
||||||
getValue(row: DataRow, col: DataColumn, resolver?: (row: DataRow, col: DataColumn) => any ): any {
|
getValue(row: DataRow, col: DataColumn, resolver?: (_row: DataRow, _col: DataColumn) => any ): any {
|
||||||
if (!row) {
|
if (!row) {
|
||||||
throw new Error('Row not found');
|
throw new Error('Row not found');
|
||||||
}
|
}
|
||||||
|
@@ -93,41 +93,35 @@ describe('DownloadZipDialogComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should call cancelDownload when CANCEL button is clicked', () => {
|
it('should call cancelDownload when CANCEL button is clicked', () => {
|
||||||
spyOn(downloadZipService, 'createDownload').and.callFake(() => {
|
spyOn(downloadZipService, 'createDownload').and.callFake(() => new Observable((observer) => {
|
||||||
return new Observable((observer) => {
|
observer.next();
|
||||||
observer.next();
|
observer.complete();
|
||||||
observer.complete();
|
}));
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
spyOn(component, 'cancelDownload');
|
spyOn(component, 'cancelDownload');
|
||||||
|
|
||||||
const cancelButton: HTMLButtonElement = <HTMLButtonElement> element.querySelector('#cancel-button');
|
const cancelButton = element.querySelector<HTMLButtonElement>('#cancel-button');
|
||||||
cancelButton.click();
|
cancelButton.click();
|
||||||
|
|
||||||
expect(component.cancelDownload).toHaveBeenCalled();
|
expect(component.cancelDownload).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should call createDownload when component is initialize', () => {
|
it('should call createDownload when component is initialize', () => {
|
||||||
const createDownloadSpy = spyOn(downloadZipService, 'createDownload').and.callFake(() => {
|
const createDownloadSpy = spyOn(downloadZipService, 'createDownload').and.callFake(() => new Observable((observer) => {
|
||||||
return new Observable((observer) => {
|
observer.next();
|
||||||
observer.next();
|
observer.complete();
|
||||||
observer.complete();
|
}));
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
expect(createDownloadSpy).toHaveBeenCalled();
|
expect(createDownloadSpy).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should close dialog when download is completed', () => {
|
it('should close dialog when download is completed', () => {
|
||||||
spyOn(downloadZipService, 'createDownload').and.callFake(() => {
|
spyOn(downloadZipService, 'createDownload').and.callFake(() => new Observable((observer) => {
|
||||||
return new Observable((observer) => {
|
observer.next();
|
||||||
observer.next();
|
observer.complete();
|
||||||
observer.complete();
|
}));
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
component.download('fakeUrl', 'fileName');
|
component.download('fakeUrl', 'fileName');
|
||||||
spyOn(component, 'cancelDownload');
|
spyOn(component, 'cancelDownload');
|
||||||
@@ -136,12 +130,10 @@ describe('DownloadZipDialogComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should close dialog when download is cancelled', () => {
|
it('should close dialog when download is cancelled', () => {
|
||||||
spyOn(downloadZipService, 'createDownload').and.callFake(() => {
|
spyOn(downloadZipService, 'createDownload').and.callFake(() => new Observable((observer) => {
|
||||||
return new Observable((observer) => {
|
observer.next();
|
||||||
observer.next();
|
observer.complete();
|
||||||
observer.complete();
|
}));
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
component.download('url', 'filename');
|
component.download('url', 'filename');
|
||||||
@@ -159,7 +151,7 @@ describe('DownloadZipDialogComponent', () => {
|
|||||||
|
|
||||||
expect(component.downloadZip).toHaveBeenCalled();
|
expect(component.downloadZip).toHaveBeenCalled();
|
||||||
|
|
||||||
const cancelButton: HTMLButtonElement = <HTMLButtonElement> element.querySelector('#cancel-button');
|
const cancelButton = element.querySelector<HTMLButtonElement>('#cancel-button');
|
||||||
cancelButton.click();
|
cancelButton.click();
|
||||||
|
|
||||||
expect(component.cancelDownload).toHaveBeenCalled();
|
expect(component.cancelDownload).toHaveBeenCalled();
|
||||||
|
@@ -27,7 +27,7 @@ import { NodesApiService } from '../../services/nodes-api.service';
|
|||||||
selector: 'adf-download-zip-dialog',
|
selector: 'adf-download-zip-dialog',
|
||||||
templateUrl: './download-zip.dialog.html',
|
templateUrl: './download-zip.dialog.html',
|
||||||
styleUrls: ['./download-zip.dialog.scss'],
|
styleUrls: ['./download-zip.dialog.scss'],
|
||||||
host: { 'class': 'adf-download-zip-dialog' },
|
host: { class: 'adf-download-zip-dialog' },
|
||||||
encapsulation: ViewEncapsulation.None
|
encapsulation: ViewEncapsulation.None
|
||||||
})
|
})
|
||||||
export class DownloadZipDialogComponent implements OnInit {
|
export class DownloadZipDialogComponent implements OnInit {
|
||||||
|
@@ -43,7 +43,7 @@ describe('CheckAllowableOperationDirective', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
changeDetectorMock = <ChangeDetectorRef> { detectChanges: () => {} };
|
changeDetectorMock = { detectChanges: () => {} } as ChangeDetectorRef;
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('HTML nativeElement as subject', () => {
|
describe('HTML nativeElement as subject', () => {
|
||||||
@@ -107,7 +107,7 @@ describe('CheckAllowableOperationDirective', () => {
|
|||||||
const directive = new CheckAllowableOperationDirective(null, null, contentService, changeDetectorMock);
|
const directive = new CheckAllowableOperationDirective(null, null, contentService, changeDetectorMock);
|
||||||
spyOn(directive, 'enableElement').and.stub();
|
spyOn(directive, 'enableElement').and.stub();
|
||||||
|
|
||||||
directive.nodes = <any> [{}, {}];
|
directive.nodes = [{}, {}] as any[];
|
||||||
|
|
||||||
expect(directive.updateElement()).toBeTruthy();
|
expect(directive.updateElement()).toBeTruthy();
|
||||||
expect(directive.enableElement).toHaveBeenCalled();
|
expect(directive.enableElement).toHaveBeenCalled();
|
||||||
@@ -120,7 +120,7 @@ describe('CheckAllowableOperationDirective', () => {
|
|||||||
const directive = new CheckAllowableOperationDirective(null, null, contentService, changeDetectorMock);
|
const directive = new CheckAllowableOperationDirective(null, null, contentService, changeDetectorMock);
|
||||||
spyOn(directive, 'disableElement').and.stub();
|
spyOn(directive, 'disableElement').and.stub();
|
||||||
|
|
||||||
directive.nodes = <any> [{}, {}];
|
directive.nodes = [{}, {}] as any[];
|
||||||
|
|
||||||
expect(directive.updateElement()).toBeFalsy();
|
expect(directive.updateElement()).toBeFalsy();
|
||||||
expect(directive.disableElement).toHaveBeenCalled();
|
expect(directive.disableElement).toHaveBeenCalled();
|
||||||
@@ -137,7 +137,7 @@ describe('CheckAllowableOperationDirective', () => {
|
|||||||
const testComponent = new TestComponent();
|
const testComponent = new TestComponent();
|
||||||
testComponent.disabled = false;
|
testComponent.disabled = false;
|
||||||
const directive = new CheckAllowableOperationDirective(null, null, contentService, changeDetectorMock, testComponent);
|
const directive = new CheckAllowableOperationDirective(null, null, contentService, changeDetectorMock, testComponent);
|
||||||
directive.nodes = <any> [{}, {}];
|
directive.nodes = [{}, {}] as any[];
|
||||||
|
|
||||||
directive.updateElement();
|
directive.updateElement();
|
||||||
|
|
||||||
@@ -153,7 +153,7 @@ describe('CheckAllowableOperationDirective', () => {
|
|||||||
const testComponent = new TestComponent();
|
const testComponent = new TestComponent();
|
||||||
testComponent.disabled = true;
|
testComponent.disabled = true;
|
||||||
const directive = new CheckAllowableOperationDirective(null, null, contentService, changeDetectorMock, testComponent);
|
const directive = new CheckAllowableOperationDirective(null, null, contentService, changeDetectorMock, testComponent);
|
||||||
directive.nodes = <any> [{}, {}];
|
directive.nodes = [{}, {}] as any[];
|
||||||
|
|
||||||
directive.updateElement();
|
directive.updateElement();
|
||||||
|
|
||||||
|
@@ -116,7 +116,7 @@ describe('HighlightDirective', () => {
|
|||||||
const highlighter = TestBed.inject(HighlightTransformService);
|
const highlighter = TestBed.inject(HighlightTransformService);
|
||||||
spyOn(highlighter, 'highlight').and.callThrough();
|
spyOn(highlighter, 'highlight').and.callThrough();
|
||||||
|
|
||||||
const callback = function() {
|
const callback = () => {
|
||||||
component.highlightDirectives.first.highlight('raddish', '');
|
component.highlightDirectives.first.highlight('raddish', '');
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
};
|
};
|
||||||
|
@@ -50,7 +50,7 @@ export class LogoutDirective implements OnInit {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getRedirectUri () {
|
getRedirectUri() {
|
||||||
if (this.redirectUri === undefined ) {
|
if (this.redirectUri === undefined ) {
|
||||||
return this.appConfig.get<string>('loginRoute', '/login');
|
return this.appConfig.get<string>('loginRoute', '/login');
|
||||||
}
|
}
|
||||||
|
@@ -137,7 +137,7 @@ describe('NodeDeleteDirective', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should process node successfully', (done) => {
|
it('should process node successfully', (done) => {
|
||||||
component.selection = <any> [{ entry: { id: '1', name: 'name1' } }];
|
component.selection = [{ entry: { id: '1', name: 'name1' } }];
|
||||||
|
|
||||||
disposableDelete = component.deleteDirective.delete.subscribe((message) => {
|
disposableDelete = component.deleteDirective.delete.subscribe((message) => {
|
||||||
expect(message).toBe(
|
expect(message).toBe(
|
||||||
@@ -272,7 +272,7 @@ describe('NodeDeleteDirective', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should emit event when delete is done', (done) => {
|
it('should emit event when delete is done', (done) => {
|
||||||
component.selection = <any> [{ entry: { id: '1', name: 'name1' } }];
|
component.selection = [{ entry: { id: '1', name: 'name1' } }];
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
element.nativeElement.click();
|
element.nativeElement.click();
|
||||||
|
@@ -120,7 +120,7 @@ export class NodeDeleteDirective implements OnChanges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private deleteNode(node: NodeEntry | DeletedNodeEntity): Observable<ProcessedNodeData> {
|
private deleteNode(node: NodeEntry | DeletedNodeEntity): Observable<ProcessedNodeData> {
|
||||||
const id = (<any> node.entry).nodeId || node.entry.id;
|
const id = (node.entry as any).nodeId || node.entry.id;
|
||||||
|
|
||||||
let promise: Promise<any>;
|
let promise: Promise<any>;
|
||||||
|
|
||||||
|
@@ -59,6 +59,7 @@ export class NodeDownloadDirective {
|
|||||||
/**
|
/**
|
||||||
* Downloads multiple selected nodes.
|
* Downloads multiple selected nodes.
|
||||||
* Packs result into a .ZIP archive if there is more than one node selected.
|
* Packs result into a .ZIP archive if there is more than one node selected.
|
||||||
|
*
|
||||||
* @param selection Multiple selected nodes to download
|
* @param selection Multiple selected nodes to download
|
||||||
*/
|
*/
|
||||||
downloadNodes(selection: NodeEntry | Array<NodeEntry>) {
|
downloadNodes(selection: NodeEntry | Array<NodeEntry>) {
|
||||||
@@ -80,6 +81,7 @@ export class NodeDownloadDirective {
|
|||||||
/**
|
/**
|
||||||
* Downloads a single node.
|
* Downloads a single node.
|
||||||
* Packs result into a .ZIP archive is the node is a Folder.
|
* Packs result into a .ZIP archive is the node is a Folder.
|
||||||
|
*
|
||||||
* @param node Node to download
|
* @param node Node to download
|
||||||
*/
|
*/
|
||||||
downloadNode(node: NodeEntry) {
|
downloadNode(node: NodeEntry) {
|
||||||
@@ -95,7 +97,7 @@ export class NodeDownloadDirective {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check if there's nodeId for Shared Files
|
// Check if there's nodeId for Shared Files
|
||||||
if (!entry.isFile && !entry.isFolder && (<any> entry).nodeId) {
|
if (!entry.isFile && !entry.isFolder && (entry as any).nodeId) {
|
||||||
this.downloadFile(node);
|
this.downloadFile(node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -108,7 +110,7 @@ export class NodeDownloadDirective {
|
|||||||
private downloadFile(node: NodeEntry) {
|
private downloadFile(node: NodeEntry) {
|
||||||
if (node && node.entry) {
|
if (node && node.entry) {
|
||||||
// nodeId for Shared node
|
// nodeId for Shared node
|
||||||
const id = (<any> node.entry).nodeId || node.entry.id;
|
const id = (node.entry as any).nodeId || node.entry.id;
|
||||||
|
|
||||||
let url;
|
let url;
|
||||||
let fileName;
|
let fileName;
|
||||||
|
@@ -45,7 +45,7 @@ describe('NodeFavoriteDirective', () => {
|
|||||||
spyOn(directive, 'markFavoritesNodes');
|
spyOn(directive, 'markFavoritesNodes');
|
||||||
|
|
||||||
const change = new SimpleChange(null, [], true);
|
const change = new SimpleChange(null, [], true);
|
||||||
directive.ngOnChanges({'selection': change});
|
directive.ngOnChanges({selection: change});
|
||||||
|
|
||||||
expect(directive.markFavoritesNodes).not.toHaveBeenCalledWith();
|
expect(directive.markFavoritesNodes).not.toHaveBeenCalledWith();
|
||||||
});
|
});
|
||||||
@@ -56,7 +56,7 @@ describe('NodeFavoriteDirective', () => {
|
|||||||
let selection = [{ entry: { id: '1', name: 'name1' } }];
|
let selection = [{ entry: { id: '1', name: 'name1' } }];
|
||||||
|
|
||||||
let change = new SimpleChange(null, selection, true);
|
let change = new SimpleChange(null, selection, true);
|
||||||
directive.ngOnChanges({'selection': change});
|
directive.ngOnChanges({selection: change});
|
||||||
|
|
||||||
expect(directive.markFavoritesNodes).toHaveBeenCalledWith(selection);
|
expect(directive.markFavoritesNodes).toHaveBeenCalledWith(selection);
|
||||||
|
|
||||||
@@ -66,7 +66,7 @@ describe('NodeFavoriteDirective', () => {
|
|||||||
];
|
];
|
||||||
|
|
||||||
change = new SimpleChange(null, selection, true);
|
change = new SimpleChange(null, selection, true);
|
||||||
directive.ngOnChanges({'selection': change});
|
directive.ngOnChanges({selection: change});
|
||||||
|
|
||||||
expect(directive.markFavoritesNodes).toHaveBeenCalledWith(selection);
|
expect(directive.markFavoritesNodes).toHaveBeenCalledWith(selection);
|
||||||
});
|
});
|
||||||
@@ -79,13 +79,13 @@ describe('NodeFavoriteDirective', () => {
|
|||||||
];
|
];
|
||||||
|
|
||||||
let change = new SimpleChange(null, selection, true);
|
let change = new SimpleChange(null, selection, true);
|
||||||
directive.ngOnChanges({'selection': change});
|
directive.ngOnChanges({selection: change});
|
||||||
tick();
|
tick();
|
||||||
|
|
||||||
expect(directive.hasFavorites()).toBe(true);
|
expect(directive.hasFavorites()).toBe(true);
|
||||||
|
|
||||||
change = new SimpleChange(null, [], true);
|
change = new SimpleChange(null, [], true);
|
||||||
directive.ngOnChanges({'selection': change});
|
directive.ngOnChanges({selection: change});
|
||||||
tick();
|
tick();
|
||||||
|
|
||||||
expect(directive.hasFavorites()).toBe(false);
|
expect(directive.hasFavorites()).toBe(false);
|
||||||
@@ -107,7 +107,7 @@ describe('NodeFavoriteDirective', () => {
|
|||||||
];
|
];
|
||||||
|
|
||||||
const change = new SimpleChange(null, selection, true);
|
const change = new SimpleChange(null, selection, true);
|
||||||
directive.ngOnChanges({'selection': change});
|
directive.ngOnChanges({selection: change});
|
||||||
|
|
||||||
tick();
|
tick();
|
||||||
expect(favoritesApiSpy.calls.count()).toBe(2);
|
expect(favoritesApiSpy.calls.count()).toBe(2);
|
||||||
@@ -121,7 +121,7 @@ describe('NodeFavoriteDirective', () => {
|
|||||||
];
|
];
|
||||||
|
|
||||||
let change = new SimpleChange(null, selection, true);
|
let change = new SimpleChange(null, selection, true);
|
||||||
directive.ngOnChanges({'selection': change});
|
directive.ngOnChanges({selection: change});
|
||||||
|
|
||||||
tick();
|
tick();
|
||||||
expect(directive.favorites.length).toBe(2);
|
expect(directive.favorites.length).toBe(2);
|
||||||
@@ -134,7 +134,7 @@ describe('NodeFavoriteDirective', () => {
|
|||||||
];
|
];
|
||||||
|
|
||||||
change = new SimpleChange(null, selection, true);
|
change = new SimpleChange(null, selection, true);
|
||||||
directive.ngOnChanges({'selection': change});
|
directive.ngOnChanges({selection: change});
|
||||||
|
|
||||||
tick();
|
tick();
|
||||||
expect(directive.favorites.length).toBe(1);
|
expect(directive.favorites.length).toBe(1);
|
||||||
@@ -148,7 +148,7 @@ describe('NodeFavoriteDirective', () => {
|
|||||||
];
|
];
|
||||||
|
|
||||||
let change = new SimpleChange(null, selection, true);
|
let change = new SimpleChange(null, selection, true);
|
||||||
directive.ngOnChanges({'selection': change});
|
directive.ngOnChanges({selection: change});
|
||||||
|
|
||||||
tick();
|
tick();
|
||||||
|
|
||||||
@@ -164,7 +164,7 @@ describe('NodeFavoriteDirective', () => {
|
|||||||
];
|
];
|
||||||
|
|
||||||
change = new SimpleChange(null, selection, true);
|
change = new SimpleChange(null, selection, true);
|
||||||
directive.ngOnChanges({'selection': change});
|
directive.ngOnChanges({selection: change});
|
||||||
tick();
|
tick();
|
||||||
|
|
||||||
expect(directive.favorites.length).toBe(3);
|
expect(directive.favorites.length).toBe(3);
|
||||||
@@ -188,7 +188,7 @@ describe('NodeFavoriteDirective', () => {
|
|||||||
|
|
||||||
it('should not perform action if favorites collection is empty', fakeAsync(() => {
|
it('should not perform action if favorites collection is empty', fakeAsync(() => {
|
||||||
const change = new SimpleChange(null, [], true);
|
const change = new SimpleChange(null, [], true);
|
||||||
directive.ngOnChanges({'selection': change});
|
directive.ngOnChanges({selection: change});
|
||||||
tick();
|
tick();
|
||||||
|
|
||||||
directive.toggleFavorite();
|
directive.toggleFavorite();
|
||||||
@@ -333,7 +333,7 @@ describe('NodeFavoriteDirective', () => {
|
|||||||
];
|
];
|
||||||
|
|
||||||
const change = new SimpleChange(null, selection, true);
|
const change = new SimpleChange(null, selection, true);
|
||||||
directive.ngOnChanges({'selection': change});
|
directive.ngOnChanges({selection: change});
|
||||||
tick();
|
tick();
|
||||||
|
|
||||||
expect(directive.favorites[0].entry.isFavorite).toBe(true);
|
expect(directive.favorites[0].entry.isFavorite).toBe(true);
|
||||||
@@ -348,7 +348,7 @@ describe('NodeFavoriteDirective', () => {
|
|||||||
];
|
];
|
||||||
|
|
||||||
const change = new SimpleChange(null, selection, true);
|
const change = new SimpleChange(null, selection, true);
|
||||||
directive.ngOnChanges({'selection': change});
|
directive.ngOnChanges({selection: change});
|
||||||
tick();
|
tick();
|
||||||
|
|
||||||
expect(directive.favorites[0].entry.isFavorite).toBe(true);
|
expect(directive.favorites[0].entry.isFavorite).toBe(true);
|
||||||
@@ -362,7 +362,7 @@ describe('NodeFavoriteDirective', () => {
|
|||||||
];
|
];
|
||||||
|
|
||||||
const change = new SimpleChange(null, selection, true);
|
const change = new SimpleChange(null, selection, true);
|
||||||
directive.ngOnChanges({'selection': change});
|
directive.ngOnChanges({selection: change});
|
||||||
tick();
|
tick();
|
||||||
|
|
||||||
expect(directive.favorites[0].entry.isFavorite).toBe(false);
|
expect(directive.favorites[0].entry.isFavorite).toBe(false);
|
||||||
|
@@ -74,7 +74,7 @@ export class NodeFavoriteDirective implements OnChanges {
|
|||||||
if (every) {
|
if (every) {
|
||||||
const batch = this.favorites.map((selected: NodeEntry | SharedLinkEntry) => {
|
const batch = this.favorites.map((selected: NodeEntry | SharedLinkEntry) => {
|
||||||
// shared files have nodeId
|
// shared files have nodeId
|
||||||
const id = (<SharedLinkEntry> selected).entry.nodeId || selected.entry.id;
|
const id = (selected as SharedLinkEntry).entry.nodeId || selected.entry.id;
|
||||||
|
|
||||||
return from(this.favoritesApi.deleteFavorite('-me-', id));
|
return from(this.favoritesApi.deleteFavorite('-me-', id));
|
||||||
});
|
});
|
||||||
@@ -92,7 +92,7 @@ export class NodeFavoriteDirective implements OnChanges {
|
|||||||
const notFavorite = this.favorites.filter((node) => !node.entry.isFavorite);
|
const notFavorite = this.favorites.filter((node) => !node.entry.isFavorite);
|
||||||
const body: FavoriteBody[] = notFavorite.map((node) => this.createFavoriteBody(node));
|
const body: FavoriteBody[] = notFavorite.map((node) => this.createFavoriteBody(node));
|
||||||
|
|
||||||
from(this.favoritesApi.createFavorite('-me-', <any> body))
|
from(this.favoritesApi.createFavorite('-me-', body as any))
|
||||||
.subscribe(
|
.subscribe(
|
||||||
() => {
|
() => {
|
||||||
notFavorite.map((selected) => selected.entry.isFavorite = true);
|
notFavorite.map((selected) => selected.entry.isFavorite = true);
|
||||||
@@ -138,8 +138,8 @@ export class NodeFavoriteDirective implements OnChanges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ACS 5.x and 6.x without 'isFavorite' include
|
// ACS 5.x and 6.x without 'isFavorite' include
|
||||||
const { name, isFile, isFolder } = <Node> node;
|
const { name, isFile, isFolder } = node as Node;
|
||||||
const id = (<SharedLink> node).nodeId || node.id;
|
const id = (node as SharedLink).nodeId || node.id;
|
||||||
|
|
||||||
const promise = this.favoritesApi.getFavorite('-me-', id);
|
const promise = this.favoritesApi.getFavorite('-me-', id);
|
||||||
|
|
||||||
@@ -153,17 +153,15 @@ export class NodeFavoriteDirective implements OnChanges {
|
|||||||
isFavorite: true
|
isFavorite: true
|
||||||
}
|
}
|
||||||
})),
|
})),
|
||||||
catchError(() => {
|
catchError(() => of({
|
||||||
return of({
|
entry: {
|
||||||
entry: {
|
id,
|
||||||
id,
|
isFolder,
|
||||||
isFolder,
|
isFile,
|
||||||
isFile,
|
name,
|
||||||
name,
|
isFavorite: false
|
||||||
isFavorite: false
|
}
|
||||||
}
|
}))
|
||||||
});
|
|
||||||
})
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -69,9 +69,7 @@ describe('NodeRestoreDirective', () => {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
translationService = TestBed.inject(TranslationService);
|
translationService = TestBed.inject(TranslationService);
|
||||||
spyOn(translationService, 'instant').and.callFake((key) => {
|
spyOn(translationService, 'instant').and.callFake((key) => key);
|
||||||
return key;
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not restore when selection is empty', () => {
|
it('should not restore when selection is empty', () => {
|
||||||
@@ -240,9 +238,7 @@ describe('NodeRestoreDirective', () => {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
restoreNodeSpy.and.callFake(() => {
|
restoreNodeSpy.and.callFake(() => Promise.resolve());
|
||||||
return Promise.resolve();
|
|
||||||
});
|
|
||||||
|
|
||||||
component.selection = [
|
component.selection = [
|
||||||
{ entry: { id: '1', name: 'name1', path: ['somewhere-over-the-rainbow'] } },
|
{ entry: { id: '1', name: 'name1', path: ['somewhere-over-the-rainbow'] } },
|
||||||
|
@@ -256,9 +256,9 @@ export class NodeRestoreDirective {
|
|||||||
path = status.success[0].entry.path;
|
path = status.success[0].entry.path;
|
||||||
}
|
}
|
||||||
this.restore.emit({
|
this.restore.emit({
|
||||||
message: message,
|
message,
|
||||||
action: action,
|
action,
|
||||||
path: path
|
path
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -16,7 +16,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { ElementRef } from '@angular/core';
|
import { ElementRef } from '@angular/core';
|
||||||
import { FileInfo } from './../utils/file-utils';
|
|
||||||
import { UploadDirective } from './upload.directive';
|
import { UploadDirective } from './upload.directive';
|
||||||
|
|
||||||
describe('UploadDirective', () => {
|
describe('UploadDirective', () => {
|
||||||
@@ -89,21 +88,21 @@ describe('UploadDirective', () => {
|
|||||||
it('should prevent default event on drop', () => {
|
it('should prevent default event on drop', () => {
|
||||||
directive.enabled = true;
|
directive.enabled = true;
|
||||||
const event = jasmine.createSpyObj('event', ['preventDefault', 'stopPropagation']);
|
const event = jasmine.createSpyObj('event', ['preventDefault', 'stopPropagation']);
|
||||||
directive.onDrop(<DragEvent> event);
|
directive.onDrop(event);
|
||||||
expect(event.preventDefault).toHaveBeenCalled();
|
expect(event.preventDefault).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should stop default event propagation on drop', () => {
|
it('should stop default event propagation on drop', () => {
|
||||||
directive.enabled = true;
|
directive.enabled = true;
|
||||||
const event = jasmine.createSpyObj('event', ['preventDefault', 'stopPropagation']);
|
const event = jasmine.createSpyObj('event', ['preventDefault', 'stopPropagation']);
|
||||||
directive.onDrop(<DragEvent> event);
|
directive.onDrop(event);
|
||||||
expect(event.stopPropagation).toHaveBeenCalled();
|
expect(event.stopPropagation).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not prevent default event on drop when disabled', () => {
|
it('should not prevent default event on drop when disabled', () => {
|
||||||
directive.enabled = false;
|
directive.enabled = false;
|
||||||
const event = jasmine.createSpyObj('event', ['preventDefault', 'stopPropagation']);
|
const event = jasmine.createSpyObj('event', ['preventDefault', 'stopPropagation']);
|
||||||
directive.onDrop(<DragEvent> event);
|
directive.onDrop(event);
|
||||||
expect(event.preventDefault).not.toHaveBeenCalled();
|
expect(event.preventDefault).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -111,10 +110,7 @@ describe('UploadDirective', () => {
|
|||||||
directive.enabled = true;
|
directive.enabled = true;
|
||||||
const event = jasmine.createSpyObj('event', ['preventDefault', 'stopPropagation']);
|
const event = jasmine.createSpyObj('event', ['preventDefault', 'stopPropagation']);
|
||||||
spyOn(directive, 'getDataTransfer').and.returnValue({} as any);
|
spyOn(directive, 'getDataTransfer').and.returnValue({} as any);
|
||||||
spyOn(directive, 'getFilesDropped').and.returnValue(Promise.resolve([
|
spyOn(directive, 'getFilesDropped').and.returnValue(Promise.resolve([{}, {}]));
|
||||||
<FileInfo> {},
|
|
||||||
<FileInfo> {}
|
|
||||||
]));
|
|
||||||
spyOn(nativeElement, 'dispatchEvent').and.callFake((_) => {
|
spyOn(nativeElement, 'dispatchEvent').and.callFake((_) => {
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
@@ -123,9 +119,7 @@ describe('UploadDirective', () => {
|
|||||||
|
|
||||||
it('should provide dropped files in upload-files event', (done) => {
|
it('should provide dropped files in upload-files event', (done) => {
|
||||||
directive.enabled = true;
|
directive.enabled = true;
|
||||||
const files = [
|
const files = [{}];
|
||||||
<FileInfo> {}
|
|
||||||
];
|
|
||||||
const event = jasmine.createSpyObj('event', ['preventDefault', 'stopPropagation']);
|
const event = jasmine.createSpyObj('event', ['preventDefault', 'stopPropagation']);
|
||||||
spyOn(directive, 'getDataTransfer').and.returnValue({} as any);
|
spyOn(directive, 'getDataTransfer').and.returnValue({} as any);
|
||||||
spyOn(directive, 'getFilesDropped').and.returnValue(Promise.resolve(files));
|
spyOn(directive, 'getFilesDropped').and.returnValue(Promise.resolve(files));
|
||||||
@@ -141,10 +135,8 @@ describe('UploadDirective', () => {
|
|||||||
it('should reset input value after file upload', () => {
|
it('should reset input value after file upload', () => {
|
||||||
directive.enabled = true;
|
directive.enabled = true;
|
||||||
directive.mode = ['click'];
|
directive.mode = ['click'];
|
||||||
const files = [
|
const files = [{}];
|
||||||
<FileInfo> {}
|
const event = {currentTarget: {files}, target: {value: '/testpath/document.pdf'}};
|
||||||
];
|
|
||||||
const event = {'currentTarget': {'files': files}, 'target': {'value': '/testpath/document.pdf'}};
|
|
||||||
|
|
||||||
directive.onSelectFiles(event);
|
directive.onSelectFiles(event);
|
||||||
expect(event.target.value).toBe('');
|
expect(event.target.value).toBe('');
|
||||||
|
@@ -159,7 +159,7 @@ export class UploadDirective implements OnInit, OnDestroy {
|
|||||||
detail: {
|
detail: {
|
||||||
sender: this,
|
sender: this,
|
||||||
data: this.data,
|
data: this.data,
|
||||||
files: files
|
files
|
||||||
},
|
},
|
||||||
bubbles: true
|
bubbles: true
|
||||||
});
|
});
|
||||||
@@ -192,6 +192,7 @@ export class UploadDirective implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Extract files from the DataTransfer object used to hold the data that is being dragged during a drag and drop operation.
|
* Extract files from the DataTransfer object used to hold the data that is being dragged during a drag and drop operation.
|
||||||
|
*
|
||||||
* @param dataTransfer DataTransfer object
|
* @param dataTransfer DataTransfer object
|
||||||
*/
|
*/
|
||||||
getFilesDropped(dataTransfer: DataTransfer): Promise<FileInfo[]> {
|
getFilesDropped(dataTransfer: DataTransfer): Promise<FileInfo[]> {
|
||||||
@@ -206,7 +207,7 @@ export class UploadDirective implements OnInit, OnDestroy {
|
|||||||
const item = items[i].webkitGetAsEntry();
|
const item = items[i].webkitGetAsEntry();
|
||||||
if (item) {
|
if (item) {
|
||||||
if (item.isFile) {
|
if (item.isFile) {
|
||||||
iterations.push(Promise.resolve(<FileInfo> {
|
iterations.push(Promise.resolve({
|
||||||
entry: item,
|
entry: item,
|
||||||
file: items[i].getAsFile(),
|
file: items[i].getAsFile(),
|
||||||
relativeFolder: '/'
|
relativeFolder: '/'
|
||||||
@@ -218,7 +219,7 @@ export class UploadDirective implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
iterations.push(Promise.resolve(<FileInfo> {
|
iterations.push(Promise.resolve({
|
||||||
entry: null,
|
entry: null,
|
||||||
file: items[i].getAsFile(),
|
file: items[i].getAsFile(),
|
||||||
relativeFolder: '/'
|
relativeFolder: '/'
|
||||||
@@ -229,11 +230,11 @@ export class UploadDirective implements OnInit, OnDestroy {
|
|||||||
// safari or FF
|
// safari or FF
|
||||||
const files = FileUtils
|
const files = FileUtils
|
||||||
.toFileArray(dataTransfer.files)
|
.toFileArray(dataTransfer.files)
|
||||||
.map((file) => <FileInfo> {
|
.map((file) => ({
|
||||||
entry: null,
|
entry: null,
|
||||||
file: file,
|
file,
|
||||||
relativeFolder: '/'
|
relativeFolder: '/'
|
||||||
});
|
}));
|
||||||
|
|
||||||
iterations.push(Promise.resolve(files));
|
iterations.push(Promise.resolve(files));
|
||||||
}
|
}
|
||||||
@@ -247,17 +248,18 @@ export class UploadDirective implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Invoked when user selects files or folders by means of File Dialog
|
* Invoked when user selects files or folders by means of File Dialog
|
||||||
|
*
|
||||||
* @param event DOM event
|
* @param event DOM event
|
||||||
*/
|
*/
|
||||||
onSelectFiles(event: any): void {
|
onSelectFiles(event: any): void {
|
||||||
if (this.isClickMode()) {
|
if (this.isClickMode()) {
|
||||||
const input = (<HTMLInputElement> event.currentTarget);
|
const input = event.currentTarget;
|
||||||
const files = FileUtils.toFileArray(input.files);
|
const files = FileUtils.toFileArray(input.files);
|
||||||
this.onUploadFiles(files.map((file) => <FileInfo> {
|
this.onUploadFiles(files.map((file) => ({
|
||||||
entry: null,
|
entry: null,
|
||||||
file: file,
|
file,
|
||||||
relativeFolder: '/'
|
relativeFolder: '/'
|
||||||
}));
|
})));
|
||||||
event.target.value = '';
|
event.target.value = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -157,6 +157,7 @@ export abstract class FormBaseComponent {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Invoked when user clicks outcome button.
|
* Invoked when user clicks outcome button.
|
||||||
|
*
|
||||||
* @param outcome Form outcome model
|
* @param outcome Form outcome model
|
||||||
*/
|
*/
|
||||||
onOutcomeClicked(outcome: FormOutcomeModel): boolean {
|
onOutcomeClicked(outcome: FormOutcomeModel): boolean {
|
||||||
|
@@ -33,7 +33,6 @@ import {
|
|||||||
import { FormRenderingService } from './../../services/form-rendering.service';
|
import { FormRenderingService } from './../../services/form-rendering.service';
|
||||||
import { WidgetVisibilityService } from './../../services/widget-visibility.service';
|
import { WidgetVisibilityService } from './../../services/widget-visibility.service';
|
||||||
import { FormFieldModel } from './../widgets/core/form-field.model';
|
import { FormFieldModel } from './../widgets/core/form-field.model';
|
||||||
import { WidgetComponent } from './../widgets/widget.component';
|
|
||||||
|
|
||||||
declare const adf: any;
|
declare const adf: any;
|
||||||
|
|
||||||
@@ -93,7 +92,7 @@ export class FormFieldComponent implements OnInit, OnDestroy {
|
|||||||
if (componentType) {
|
if (componentType) {
|
||||||
const factory = this.componentFactoryResolver.resolveComponentFactory(componentType);
|
const factory = this.componentFactoryResolver.resolveComponentFactory(componentType);
|
||||||
this.componentRef = this.container.createComponent(factory);
|
this.componentRef = this.container.createComponent(factory);
|
||||||
const instance = <WidgetComponent> this.componentRef.instance;
|
const instance = this.componentRef.instance;
|
||||||
instance.field = this.field;
|
instance.field = this.field;
|
||||||
instance.fieldChanged.subscribe((field) => {
|
instance.fieldChanged.subscribe((field) => {
|
||||||
if (field && this.field.form) {
|
if (field && this.field.form) {
|
||||||
@@ -136,7 +135,7 @@ export class FormFieldComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
const metadata = {
|
const metadata = {
|
||||||
selector: `runtime-component-${type}`,
|
selector: `runtime-component-${type}`,
|
||||||
template: template
|
template
|
||||||
};
|
};
|
||||||
|
|
||||||
const factory = this.createComponentFactorySync(this.compiler, metadata, componentInfo.class);
|
const factory = this.createComponentFactorySync(this.compiler, metadata, componentInfo.class);
|
||||||
|
@@ -44,45 +44,45 @@ import { TextWidgetComponent } from './widgets';
|
|||||||
import { By } from '@angular/platform-browser';
|
import { By } from '@angular/platform-browser';
|
||||||
import { DebugElement } from '@angular/core';
|
import { DebugElement } from '@angular/core';
|
||||||
|
|
||||||
function typeIntoInput(targetInput: HTMLInputElement, message: string) {
|
const typeIntoInput = (targetInput: HTMLInputElement, message: string) => {
|
||||||
expect(targetInput).not.toBeNull('Expected input to set to be valid and not null');
|
expect(targetInput).not.toBeNull('Expected input to set to be valid and not null');
|
||||||
targetInput.value = message;
|
targetInput.value = message;
|
||||||
targetInput.dispatchEvent(new Event('input'));
|
targetInput.dispatchEvent(new Event('input'));
|
||||||
}
|
};
|
||||||
|
|
||||||
function typeIntoDate(targetInput: DebugElement, date: { srcElement: { value: string } }) {
|
const typeIntoDate = (targetInput: DebugElement, date: { srcElement: { value: string } }) => {
|
||||||
expect(targetInput).not.toBeNull('Expected input to set to be valid and not null');
|
expect(targetInput).not.toBeNull('Expected input to set to be valid and not null');
|
||||||
targetInput.triggerEventHandler('change', date);
|
targetInput.triggerEventHandler('change', date);
|
||||||
}
|
};
|
||||||
|
|
||||||
function expectElementToBeHidden(targetElement: HTMLElement): void {
|
const expectElementToBeHidden = (targetElement: HTMLElement): void => {
|
||||||
expect(targetElement).not.toBeNull();
|
expect(targetElement).not.toBeNull();
|
||||||
expect(targetElement).toBeDefined();
|
expect(targetElement).toBeDefined();
|
||||||
expect(targetElement.hidden).toBe(true, `${targetElement.id} should be hidden but it is not`);
|
expect(targetElement.hidden).toBe(true, `${targetElement.id} should be hidden but it is not`);
|
||||||
}
|
};
|
||||||
|
|
||||||
function expectElementToBeVisible(targetElement: HTMLElement): void {
|
const expectElementToBeVisible = (targetElement: HTMLElement): void => {
|
||||||
expect(targetElement).not.toBeNull();
|
expect(targetElement).not.toBeNull();
|
||||||
expect(targetElement).toBeDefined();
|
expect(targetElement).toBeDefined();
|
||||||
expect(targetElement.hidden).toBe(false, `${targetElement.id} should be visibile but it is not`);
|
expect(targetElement.hidden).toBe(false, `${targetElement.id} should be visibile but it is not`);
|
||||||
}
|
};
|
||||||
|
|
||||||
function expectInputElementValueIs(targetElement: HTMLInputElement, value: string): void {
|
const expectInputElementValueIs = (targetElement: HTMLInputElement, value: string): void => {
|
||||||
expect(targetElement).not.toBeNull();
|
expect(targetElement).not.toBeNull();
|
||||||
expect(targetElement).toBeDefined();
|
expect(targetElement).toBeDefined();
|
||||||
expect(targetElement.value).toBe(value, `invalid value for ${targetElement.name}`);
|
expect(targetElement.value).toBe(value, `invalid value for ${targetElement.name}`);
|
||||||
}
|
};
|
||||||
|
|
||||||
function expectElementToBeInvalid(fieldId: string, fixture: ComponentFixture<FormRendererComponent>): void {
|
const expectElementToBeInvalid = (fieldId: string, fixture: ComponentFixture<FormRendererComponent>): void => {
|
||||||
const invalidElementContainer = fixture.nativeElement.querySelector(`#field-${fieldId}-container .adf-invalid`);
|
const invalidElementContainer = fixture.nativeElement.querySelector(`#field-${fieldId}-container .adf-invalid`);
|
||||||
expect(invalidElementContainer).not.toBeNull();
|
expect(invalidElementContainer).not.toBeNull();
|
||||||
expect(invalidElementContainer).toBeDefined();
|
expect(invalidElementContainer).toBeDefined();
|
||||||
}
|
};
|
||||||
|
|
||||||
function expectElementToBeValid(fieldId: string, fixture: ComponentFixture<FormRendererComponent>): void {
|
const expectElementToBeValid = (fieldId: string, fixture: ComponentFixture<FormRendererComponent>): void => {
|
||||||
const invalidElementContainer = fixture.nativeElement.querySelector(`#field-${fieldId}-container .adf-invalid`);
|
const invalidElementContainer = fixture.nativeElement.querySelector(`#field-${fieldId}-container .adf-invalid`);
|
||||||
expect(invalidElementContainer).toBeNull();
|
expect(invalidElementContainer).toBeNull();
|
||||||
}
|
};
|
||||||
|
|
||||||
describe('Form Renderer Component', () => {
|
describe('Form Renderer Component', () => {
|
||||||
|
|
||||||
@@ -630,7 +630,7 @@ describe('Form Renderer Component', () => {
|
|||||||
describe('Custom Widget', () => {
|
describe('Custom Widget', () => {
|
||||||
|
|
||||||
it('Should be able to correctly display a custom process cloud widget', async () => {
|
it('Should be able to correctly display a custom process cloud widget', async () => {
|
||||||
formRenderingService.register({ 'bananaforevah': () => TextWidgetComponent }, true);
|
formRenderingService.register({ bananaforevah: () => TextWidgetComponent }, true);
|
||||||
formRendererComponent.formDefinition = formService.parseForm(customWidgetForm.formRepresentation.formDefinition);
|
formRendererComponent.formDefinition = formService.parseForm(customWidgetForm.formRepresentation.formDefinition);
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
await fixture.whenStable();
|
await fixture.whenStable();
|
||||||
@@ -641,7 +641,7 @@ describe('Form Renderer Component', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('Should be able to correctly use visibility in a custom process cloud widget ', async () => {
|
it('Should be able to correctly use visibility in a custom process cloud widget ', async () => {
|
||||||
formRenderingService.register({ 'bananaforevah': () => TextWidgetComponent }, true);
|
formRenderingService.register({ bananaforevah: () => TextWidgetComponent }, true);
|
||||||
formRendererComponent.formDefinition = formService.parseForm(customWidgetFormWithVisibility.formRepresentation.formDefinition);
|
formRendererComponent.formDefinition = formService.parseForm(customWidgetFormWithVisibility.formRepresentation.formDefinition);
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
await fixture.whenStable();
|
await fixture.whenStable();
|
||||||
|
@@ -32,7 +32,7 @@ export const formDisplayValueVisibility = {
|
|||||||
tab: null,
|
tab: null,
|
||||||
numberOfColumns: 2,
|
numberOfColumns: 2,
|
||||||
fields: {
|
fields: {
|
||||||
'1': [
|
1: [
|
||||||
{
|
{
|
||||||
id: 'Text0bq3ar',
|
id: 'Text0bq3ar',
|
||||||
name: 'Text',
|
name: 'Text',
|
||||||
@@ -47,7 +47,7 @@ export const formDisplayValueVisibility = {
|
|||||||
params: { existingColspan: 1, maxColspan: 2 }
|
params: { existingColspan: 1, maxColspan: 2 }
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
'2': [
|
2: [
|
||||||
{
|
{
|
||||||
id: 'Displayvalue0g6092',
|
id: 'Displayvalue0g6092',
|
||||||
name: 'Display value',
|
name: 'Display value',
|
||||||
@@ -101,7 +101,7 @@ export const formDisplayValueForm = {
|
|||||||
tab: null,
|
tab: null,
|
||||||
numberOfColumns: 2,
|
numberOfColumns: 2,
|
||||||
fields: {
|
fields: {
|
||||||
'1': [
|
1: [
|
||||||
{
|
{
|
||||||
id: 'DisplayValueColspan',
|
id: 'DisplayValueColspan',
|
||||||
name: 'DisplayValueColspan',
|
name: 'DisplayValueColspan',
|
||||||
@@ -240,7 +240,7 @@ export const formDisplayValueForm = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
'2': [
|
2: [
|
||||||
{
|
{
|
||||||
id: 'Text0howrc',
|
id: 'Text0howrc',
|
||||||
name: 'Text',
|
name: 'Text',
|
||||||
@@ -342,7 +342,7 @@ export const formDisplayValueCombinedVisibility = {
|
|||||||
tab: null,
|
tab: null,
|
||||||
numberOfColumns: 2,
|
numberOfColumns: 2,
|
||||||
fields: {
|
fields: {
|
||||||
'1': [
|
1: [
|
||||||
{
|
{
|
||||||
id: 'Text0bq3ar',
|
id: 'Text0bq3ar',
|
||||||
name: 'Text',
|
name: 'Text',
|
||||||
@@ -357,7 +357,7 @@ export const formDisplayValueCombinedVisibility = {
|
|||||||
params: { existingColspan: 1, maxColspan: 2 }
|
params: { existingColspan: 1, maxColspan: 2 }
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
'2': [
|
2: [
|
||||||
{
|
{
|
||||||
id: 'Displayvalue0g6092',
|
id: 'Displayvalue0g6092',
|
||||||
name: 'Display value',
|
name: 'Display value',
|
||||||
@@ -402,7 +402,7 @@ export const formDisplayValueCombinedVisibility = {
|
|||||||
tab: null,
|
tab: null,
|
||||||
numberOfColumns: 2,
|
numberOfColumns: 2,
|
||||||
fields: {
|
fields: {
|
||||||
'1': [
|
1: [
|
||||||
{
|
{
|
||||||
id: 'TextTwo',
|
id: 'TextTwo',
|
||||||
name: 'TextTwo',
|
name: 'TextTwo',
|
||||||
@@ -417,7 +417,7 @@ export const formDisplayValueCombinedVisibility = {
|
|||||||
params: { existingColspan: 1, maxColspan: 2 }
|
params: { existingColspan: 1, maxColspan: 2 }
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
'2': []
|
2: []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -445,7 +445,7 @@ export const formNumberWidgetVisibility = {
|
|||||||
tab: null,
|
tab: null,
|
||||||
numberOfColumns: 2,
|
numberOfColumns: 2,
|
||||||
fields: {
|
fields: {
|
||||||
'1': [
|
1: [
|
||||||
{
|
{
|
||||||
id: 'Number1',
|
id: 'Number1',
|
||||||
name: 'Number1',
|
name: 'Number1',
|
||||||
@@ -462,7 +462,7 @@ export const formNumberWidgetVisibility = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
'2': [
|
2: [
|
||||||
{
|
{
|
||||||
id: 'Number2',
|
id: 'Number2',
|
||||||
name: 'Number2',
|
name: 'Number2',
|
||||||
@@ -520,7 +520,7 @@ export const formNumberTextJson = {
|
|||||||
tab: null,
|
tab: null,
|
||||||
numberOfColumns: 2,
|
numberOfColumns: 2,
|
||||||
fields: {
|
fields: {
|
||||||
'1': [
|
1: [
|
||||||
{
|
{
|
||||||
id: 'NumberColspan',
|
id: 'NumberColspan',
|
||||||
name: 'NumberColspan',
|
name: 'NumberColspan',
|
||||||
@@ -582,7 +582,7 @@ export const formNumberTextJson = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
'2': [
|
2: [
|
||||||
{
|
{
|
||||||
id: 'Text',
|
id: 'Text',
|
||||||
name: 'Text',
|
name: 'Text',
|
||||||
@@ -763,7 +763,7 @@ export const formRequiredNumberWidget = {
|
|||||||
tab: null,
|
tab: null,
|
||||||
numberOfColumns: 2,
|
numberOfColumns: 2,
|
||||||
fields: {
|
fields: {
|
||||||
'1': [
|
1: [
|
||||||
{
|
{
|
||||||
id: 'Number1',
|
id: 'Number1',
|
||||||
name: 'Number1',
|
name: 'Number1',
|
||||||
@@ -780,7 +780,7 @@ export const formRequiredNumberWidget = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
'2': [
|
2: [
|
||||||
{
|
{
|
||||||
id: 'Number2',
|
id: 'Number2',
|
||||||
name: 'Number2',
|
name: 'Number2',
|
||||||
@@ -839,7 +839,7 @@ export const colspanForm = {
|
|||||||
tab: null,
|
tab: null,
|
||||||
numberOfColumns: 2,
|
numberOfColumns: 2,
|
||||||
fields: {
|
fields: {
|
||||||
'1': [
|
1: [
|
||||||
{
|
{
|
||||||
id: 'Number0u0kiv',
|
id: 'Number0u0kiv',
|
||||||
name: 'NumberColspan',
|
name: 'NumberColspan',
|
||||||
@@ -866,7 +866,7 @@ export const colspanForm = {
|
|||||||
tab: null,
|
tab: null,
|
||||||
numberOfColumns: 2,
|
numberOfColumns: 2,
|
||||||
fields: {
|
fields: {
|
||||||
'1': [
|
1: [
|
||||||
{
|
{
|
||||||
id: 'Number00fuuk',
|
id: 'Number00fuuk',
|
||||||
name: 'Number',
|
name: 'Number',
|
||||||
@@ -884,7 +884,7 @@ export const colspanForm = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
'2': [
|
2: [
|
||||||
{
|
{
|
||||||
id: 'Number03u9d4',
|
id: 'Number03u9d4',
|
||||||
name: 'Number',
|
name: 'Number',
|
||||||
@@ -911,7 +911,7 @@ export const colspanForm = {
|
|||||||
tab: null,
|
tab: null,
|
||||||
numberOfColumns: 2,
|
numberOfColumns: 2,
|
||||||
fields: {
|
fields: {
|
||||||
'1': [
|
1: [
|
||||||
{
|
{
|
||||||
id: 'Text04sjhr',
|
id: 'Text04sjhr',
|
||||||
name: 'Text',
|
name: 'Text',
|
||||||
@@ -957,7 +957,7 @@ export const numberNotRequiredForm = {
|
|||||||
tab: null,
|
tab: null,
|
||||||
numberOfColumns: 2,
|
numberOfColumns: 2,
|
||||||
fields: {
|
fields: {
|
||||||
'1': [
|
1: [
|
||||||
{
|
{
|
||||||
id: 'Number0x8cbv',
|
id: 'Number0x8cbv',
|
||||||
name: 'Number',
|
name: 'Number',
|
||||||
@@ -971,7 +971,7 @@ export const numberNotRequiredForm = {
|
|||||||
params: { existingColspan: 1, maxColspan: 2 }
|
params: { existingColspan: 1, maxColspan: 2 }
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
'2': []
|
2: []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -999,7 +999,7 @@ export const numberMinMaxForm = {
|
|||||||
tab: null,
|
tab: null,
|
||||||
numberOfColumns: 2,
|
numberOfColumns: 2,
|
||||||
fields: {
|
fields: {
|
||||||
'1': [
|
1: [
|
||||||
{
|
{
|
||||||
id: 'Number0him2z',
|
id: 'Number0him2z',
|
||||||
name: 'Number',
|
name: 'Number',
|
||||||
@@ -1016,7 +1016,7 @@ export const numberMinMaxForm = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
'2': []
|
2: []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -1043,7 +1043,7 @@ export const textWidgetVisibility = {
|
|||||||
tab: null,
|
tab: null,
|
||||||
numberOfColumns: 2,
|
numberOfColumns: 2,
|
||||||
fields: {
|
fields: {
|
||||||
'1': [
|
1: [
|
||||||
{
|
{
|
||||||
id: 'textOne',
|
id: 'textOne',
|
||||||
name: 'textOne',
|
name: 'textOne',
|
||||||
@@ -1058,7 +1058,7 @@ export const textWidgetVisibility = {
|
|||||||
params: { existingColspan: 1, maxColspan: 2 }
|
params: { existingColspan: 1, maxColspan: 2 }
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
'2': [
|
2: [
|
||||||
{
|
{
|
||||||
id: 'textTwo',
|
id: 'textTwo',
|
||||||
name: 'textTwo',
|
name: 'textTwo',
|
||||||
@@ -1091,7 +1091,7 @@ export const textWidgetVisibility = {
|
|||||||
tab: null,
|
tab: null,
|
||||||
numberOfColumns: 2,
|
numberOfColumns: 2,
|
||||||
fields: {
|
fields: {
|
||||||
'1': [
|
1: [
|
||||||
{
|
{
|
||||||
id: 'textThree',
|
id: 'textThree',
|
||||||
name: 'textThree',
|
name: 'textThree',
|
||||||
@@ -1125,7 +1125,7 @@ export const textWidgetVisibility = {
|
|||||||
params: { existingColspan: 1, maxColspan: 2 }
|
params: { existingColspan: 1, maxColspan: 2 }
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
'2': [
|
2: [
|
||||||
{
|
{
|
||||||
id: 'textFour',
|
id: 'textFour',
|
||||||
name: 'textFour',
|
name: 'textFour',
|
||||||
@@ -1187,7 +1187,7 @@ export const numberWidgetVisibilityForm = {
|
|||||||
tab: null,
|
tab: null,
|
||||||
numberOfColumns: 2,
|
numberOfColumns: 2,
|
||||||
fields: {
|
fields: {
|
||||||
'1': [
|
1: [
|
||||||
{
|
{
|
||||||
id: 'Text0hs0gt',
|
id: 'Text0hs0gt',
|
||||||
name: 'TextOne',
|
name: 'TextOne',
|
||||||
@@ -1236,7 +1236,7 @@ export const numberWidgetVisibilityForm = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
'2': [
|
2: [
|
||||||
{
|
{
|
||||||
id: 'Text0cuqet',
|
id: 'Text0cuqet',
|
||||||
name: 'TextTwo',
|
name: 'TextTwo',
|
||||||
@@ -1280,7 +1280,7 @@ export const radioWidgetVisibiltyForm = {
|
|||||||
tab: null,
|
tab: null,
|
||||||
numberOfColumns: 2,
|
numberOfColumns: 2,
|
||||||
fields: {
|
fields: {
|
||||||
'1': [
|
1: [
|
||||||
{
|
{
|
||||||
id: 'Text0cee7g',
|
id: 'Text0cee7g',
|
||||||
name: 'Text',
|
name: 'Text',
|
||||||
@@ -1295,7 +1295,7 @@ export const radioWidgetVisibiltyForm = {
|
|||||||
params: { existingColspan: 1, maxColspan: 2 }
|
params: { existingColspan: 1, maxColspan: 2 }
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
'2': [
|
2: [
|
||||||
{
|
{
|
||||||
id: 'Radiobuttons03rkbo',
|
id: 'Radiobuttons03rkbo',
|
||||||
name: 'Radio buttons',
|
name: 'Radio buttons',
|
||||||
@@ -1352,7 +1352,7 @@ export const customWidgetForm = {
|
|||||||
tab: null,
|
tab: null,
|
||||||
numberOfColumns: 2,
|
numberOfColumns: 2,
|
||||||
fields: {
|
fields: {
|
||||||
'1': [
|
1: [
|
||||||
{
|
{
|
||||||
id: 'Text0vdi18',
|
id: 'Text0vdi18',
|
||||||
name: 'herejustoshowstandardones',
|
name: 'herejustoshowstandardones',
|
||||||
@@ -1371,7 +1371,7 @@ export const customWidgetForm = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
'2': [
|
2: [
|
||||||
{
|
{
|
||||||
id: 'bananaforevah0k8gui',
|
id: 'bananaforevah0k8gui',
|
||||||
name: 'bananaforevah',
|
name: 'bananaforevah',
|
||||||
@@ -1416,7 +1416,7 @@ export const customWidgetFormWithVisibility = {
|
|||||||
tab: null,
|
tab: null,
|
||||||
numberOfColumns: 2,
|
numberOfColumns: 2,
|
||||||
fields: {
|
fields: {
|
||||||
'1': [
|
1: [
|
||||||
{
|
{
|
||||||
id: 'Text0vdi18',
|
id: 'Text0vdi18',
|
||||||
name: 'herejustoshowstandardones',
|
name: 'herejustoshowstandardones',
|
||||||
@@ -1435,7 +1435,7 @@ export const customWidgetFormWithVisibility = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
'2': [
|
2: [
|
||||||
{
|
{
|
||||||
id: 'bananaforevah0k8gui',
|
id: 'bananaforevah0k8gui',
|
||||||
name: 'bananaforevah',
|
name: 'bananaforevah',
|
||||||
@@ -1488,7 +1488,7 @@ export const formDateVisibility = {
|
|||||||
tab: null,
|
tab: null,
|
||||||
numberOfColumns: 2,
|
numberOfColumns: 2,
|
||||||
fields: {
|
fields: {
|
||||||
'1': [
|
1: [
|
||||||
{
|
{
|
||||||
id: 'Date0hwq20',
|
id: 'Date0hwq20',
|
||||||
name: 'Date',
|
name: 'Date',
|
||||||
@@ -1508,7 +1508,7 @@ export const formDateVisibility = {
|
|||||||
dateDisplayFormat: 'YYYY-MM-DD'
|
dateDisplayFormat: 'YYYY-MM-DD'
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
'2': [
|
2: [
|
||||||
{
|
{
|
||||||
id: 'Text0pqd1u',
|
id: 'Text0pqd1u',
|
||||||
name: 'Text',
|
name: 'Text',
|
||||||
@@ -1545,7 +1545,7 @@ export const formDateVisibility = {
|
|||||||
tab: null,
|
tab: null,
|
||||||
numberOfColumns: 2,
|
numberOfColumns: 2,
|
||||||
fields: {
|
fields: {
|
||||||
'1': [
|
1: [
|
||||||
{
|
{
|
||||||
id: 'Text0uyqd3',
|
id: 'Text0uyqd3',
|
||||||
name: 'Text',
|
name: 'Text',
|
||||||
@@ -1573,7 +1573,7 @@ export const formDateVisibility = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
'2': []
|
2: []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
@@ -46,7 +46,7 @@ describe('AmountWidgetComponent', () => {
|
|||||||
it('should setup currency from field', () => {
|
it('should setup currency from field', () => {
|
||||||
const currency = 'UAH';
|
const currency = 'UAH';
|
||||||
widget.field = new FormFieldModel(null, {
|
widget.field = new FormFieldModel(null, {
|
||||||
currency: currency
|
currency
|
||||||
});
|
});
|
||||||
|
|
||||||
widget.ngOnInit();
|
widget.ngOnInit();
|
||||||
|
@@ -37,7 +37,7 @@ export class ContainerWidgetComponentModel extends ContainerModel {
|
|||||||
let allowCollapse = false;
|
let allowCollapse = false;
|
||||||
|
|
||||||
if (this.isGroup() && this.field.params['allowCollapse']) {
|
if (this.isGroup() && this.field.params['allowCollapse']) {
|
||||||
allowCollapse = <boolean> this.field.params['allowCollapse'];
|
allowCollapse = this.field.params['allowCollapse'];
|
||||||
}
|
}
|
||||||
|
|
||||||
return allowCollapse;
|
return allowCollapse;
|
||||||
@@ -47,7 +47,7 @@ export class ContainerWidgetComponentModel extends ContainerModel {
|
|||||||
let collapseByDefault = false;
|
let collapseByDefault = false;
|
||||||
|
|
||||||
if (this.isCollapsible() && this.field.params['collapseByDefault']) {
|
if (this.isCollapsible() && this.field.params['collapseByDefault']) {
|
||||||
collapseByDefault = <boolean> this.field.params['collapseByDefault'];
|
collapseByDefault = this.field.params['collapseByDefault'];
|
||||||
}
|
}
|
||||||
|
|
||||||
return collapseByDefault;
|
return collapseByDefault;
|
||||||
|
@@ -123,9 +123,9 @@ describe('ContainerWidgetComponent', () => {
|
|||||||
type: 'container',
|
type: 'container',
|
||||||
tab: null,
|
tab: null,
|
||||||
fields: {
|
fields: {
|
||||||
'1' : [{ id: '1' }, { id: '2' }, { id: '3' }],
|
1 : [{ id: '1' }, { id: '2' }, { id: '3' }],
|
||||||
'2' : [{ id: '4' }, { id: '5' }],
|
2 : [{ id: '4' }, { id: '5' }],
|
||||||
'3' : [{ id: '6' }]
|
3 : [{ id: '6' }]
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -150,7 +150,7 @@ describe('ContainerWidgetComponent', () => {
|
|||||||
type: 'container',
|
type: 'container',
|
||||||
tab: null,
|
tab: null,
|
||||||
fields: {
|
fields: {
|
||||||
'1': [
|
1: [
|
||||||
{
|
{
|
||||||
id: 'a',
|
id: 'a',
|
||||||
colspan: 2,
|
colspan: 2,
|
||||||
@@ -192,7 +192,7 @@ describe('ContainerWidgetComponent', () => {
|
|||||||
rowspan: 1
|
rowspan: 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
'2': [
|
2: [
|
||||||
{
|
{
|
||||||
id: '1',
|
id: '1',
|
||||||
rowspan: 3,
|
rowspan: 3,
|
||||||
@@ -208,7 +208,7 @@ describe('ContainerWidgetComponent', () => {
|
|||||||
colspan: 2
|
colspan: 2
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
'3': [
|
3: [
|
||||||
{
|
{
|
||||||
id: 'white'
|
id: 'white'
|
||||||
},
|
},
|
||||||
@@ -265,8 +265,8 @@ describe('ContainerWidgetComponent', () => {
|
|||||||
widget.content = container;
|
widget.content = container;
|
||||||
|
|
||||||
expect(widget.getColumnWith(undefined)).toBe('25');
|
expect(widget.getColumnWith(undefined)).toBe('25');
|
||||||
expect(widget.getColumnWith(<FormFieldModel> { colspan: 1 })).toBe('25');
|
expect(widget.getColumnWith({ colspan: 1 } as FormFieldModel)).toBe('25');
|
||||||
expect(widget.getColumnWith(<FormFieldModel> { colspan: 3 })).toBe('75');
|
expect(widget.getColumnWith({ colspan: 3 } as FormFieldModel)).toBe('75');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -97,9 +97,8 @@ export class ContainerWidgetComponent extends WidgetComponent implements OnInit,
|
|||||||
private getMaxColumnFieldSize(): number {
|
private getMaxColumnFieldSize(): number {
|
||||||
let maxFieldSize = 0;
|
let maxFieldSize = 0;
|
||||||
if (this.content?.columns?.length > 0) {
|
if (this.content?.columns?.length > 0) {
|
||||||
maxFieldSize = this.content?.columns?.reduce((prevColumn, currentColumn) => {
|
maxFieldSize = this.content?.columns?.reduce((prevColumn, currentColumn) =>
|
||||||
return currentColumn.fields.length > prevColumn?.fields?.length ? currentColumn : prevColumn;
|
currentColumn.fields.length > prevColumn?.fields?.length ? currentColumn : prevColumn)?.fields?.length;
|
||||||
})?.fields?.length;
|
|
||||||
}
|
}
|
||||||
return maxFieldSize;
|
return maxFieldSize;
|
||||||
}
|
}
|
||||||
|
@@ -39,12 +39,12 @@ describe('ContentWidgetComponent', () => {
|
|||||||
let processContentService: ProcessContentService;
|
let processContentService: ProcessContentService;
|
||||||
let serviceContent: ContentService;
|
let serviceContent: ContentService;
|
||||||
|
|
||||||
function createFakeImageBlob() {
|
const createFakeImageBlob = () => {
|
||||||
const data = atob('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==');
|
const data = atob('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==');
|
||||||
return new Blob([data], { type: 'image/png' });
|
return new Blob([data], { type: 'image/png' });
|
||||||
}
|
};
|
||||||
|
|
||||||
function createFakePdfBlob(): Blob {
|
const createFakePdfBlob = (): Blob => {
|
||||||
const pdfData = atob(
|
const pdfData = atob(
|
||||||
'JVBERi0xLjcKCjEgMCBvYmogICUgZW50cnkgcG9pbnQKPDwKICAvVHlwZSAvQ2F0YWxvZwog' +
|
'JVBERi0xLjcKCjEgMCBvYmogICUgZW50cnkgcG9pbnQKPDwKICAvVHlwZSAvQ2F0YWxvZwog' +
|
||||||
'IC9QYWdlcyAyIDAgUgo+PgplbmRvYmoKCjIgMCBvYmoKPDwKICAvVHlwZSAvUGFnZXMKICAv' +
|
'IC9QYWdlcyAyIDAgUgo+PgplbmRvYmoKCjIgMCBvYmoKPDwKICAvVHlwZSAvUGFnZXMKICAv' +
|
||||||
@@ -60,7 +60,7 @@ describe('ContentWidgetComponent', () => {
|
|||||||
'MDAwIG4gCjAwMDAwMDAzODAgMDAwMDAgbiAKdHJhaWxlcgo8PAogIC9TaXplIDYKICAvUm9v' +
|
'MDAwIG4gCjAwMDAwMDAzODAgMDAwMDAgbiAKdHJhaWxlcgo8PAogIC9TaXplIDYKICAvUm9v' +
|
||||||
'dCAxIDAgUgo+PgpzdGFydHhyZWYKNDkyCiUlRU9G');
|
'dCAxIDAgUgo+PgpzdGFydHhyZWYKNDkyCiUlRU9G');
|
||||||
return new Blob([pdfData], { type: 'application/pdf' });
|
return new Blob([pdfData], { type: 'application/pdf' });
|
||||||
}
|
};
|
||||||
|
|
||||||
setupTestBed({
|
setupTestBed({
|
||||||
imports: [
|
imports: [
|
||||||
@@ -118,7 +118,7 @@ describe('ContentWidgetComponent', () => {
|
|||||||
|
|
||||||
const contentId = 1;
|
const contentId = 1;
|
||||||
const change = new SimpleChange(null, contentId, true);
|
const change = new SimpleChange(null, contentId, true);
|
||||||
component.ngOnChanges({ 'id': change });
|
component.ngOnChanges({ id: change });
|
||||||
|
|
||||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||||
status: 200,
|
status: 200,
|
||||||
@@ -129,7 +129,7 @@ describe('ContentWidgetComponent', () => {
|
|||||||
created: 1490354907883,
|
created: 1490354907883,
|
||||||
createdBy: {
|
createdBy: {
|
||||||
id: 2,
|
id: 2,
|
||||||
firstName: 'admin', 'lastName': 'admin', 'email': 'administrator@admin.com'
|
firstName: 'admin', lastName: 'admin', email: 'administrator@admin.com'
|
||||||
},
|
},
|
||||||
relatedContent: false,
|
relatedContent: false,
|
||||||
contentAvailable: true,
|
contentAvailable: true,
|
||||||
@@ -161,7 +161,7 @@ describe('ContentWidgetComponent', () => {
|
|||||||
|
|
||||||
const contentId = 1;
|
const contentId = 1;
|
||||||
const change = new SimpleChange(null, contentId, true);
|
const change = new SimpleChange(null, contentId, true);
|
||||||
component.ngOnChanges({ 'id': change });
|
component.ngOnChanges({ id: change });
|
||||||
|
|
||||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||||
status: 200,
|
status: 200,
|
||||||
@@ -172,7 +172,7 @@ describe('ContentWidgetComponent', () => {
|
|||||||
created: 1490354907883,
|
created: 1490354907883,
|
||||||
createdBy: {
|
createdBy: {
|
||||||
id: 2,
|
id: 2,
|
||||||
firstName: 'admin', 'lastName': 'admin', 'email': 'administrator@admin.com'
|
firstName: 'admin', lastName: 'admin', email: 'administrator@admin.com'
|
||||||
},
|
},
|
||||||
relatedContent: false,
|
relatedContent: false,
|
||||||
contentAvailable: true,
|
contentAvailable: true,
|
||||||
@@ -189,7 +189,7 @@ describe('ContentWidgetComponent', () => {
|
|||||||
|
|
||||||
const contentId = 1;
|
const contentId = 1;
|
||||||
const change = new SimpleChange(null, contentId, true);
|
const change = new SimpleChange(null, contentId, true);
|
||||||
component.ngOnChanges({ 'id': change });
|
component.ngOnChanges({ id: change });
|
||||||
|
|
||||||
component.contentLoaded.subscribe(() => {
|
component.contentLoaded.subscribe(() => {
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
@@ -211,7 +211,7 @@ describe('ContentWidgetComponent', () => {
|
|||||||
created: 1490354907883,
|
created: 1490354907883,
|
||||||
createdBy: {
|
createdBy: {
|
||||||
id: 2,
|
id: 2,
|
||||||
firstName: 'admin', 'lastName': 'admin', 'email': 'administrator@admin.com'
|
firstName: 'admin', lastName: 'admin', email: 'administrator@admin.com'
|
||||||
},
|
},
|
||||||
relatedContent: false,
|
relatedContent: false,
|
||||||
contentAvailable: false,
|
contentAvailable: false,
|
||||||
@@ -235,7 +235,7 @@ describe('ContentWidgetComponent', () => {
|
|||||||
created: 1490354907883,
|
created: 1490354907883,
|
||||||
createdBy: {
|
createdBy: {
|
||||||
id: 2,
|
id: 2,
|
||||||
firstName: 'admin', 'lastName': 'admin', 'email': 'administrator@admin.com'
|
firstName: 'admin', lastName: 'admin', email: 'administrator@admin.com'
|
||||||
},
|
},
|
||||||
relatedContent: false,
|
relatedContent: false,
|
||||||
contentAvailable: true,
|
contentAvailable: true,
|
||||||
@@ -271,7 +271,7 @@ describe('ContentWidgetComponent', () => {
|
|||||||
created: 1490354907883,
|
created: 1490354907883,
|
||||||
createdBy: {
|
createdBy: {
|
||||||
id: 2,
|
id: 2,
|
||||||
firstName: 'admin', 'lastName': 'admin', 'email': 'administrator@admin.com'
|
firstName: 'admin', lastName: 'admin', email: 'administrator@admin.com'
|
||||||
},
|
},
|
||||||
relatedContent: false,
|
relatedContent: false,
|
||||||
contentAvailable: true,
|
contentAvailable: true,
|
||||||
|
@@ -78,7 +78,7 @@ describe('FormFieldValidator', () => {
|
|||||||
required: true
|
required: true
|
||||||
});
|
});
|
||||||
|
|
||||||
field.emptyOption = <FormFieldOption> { id: '<empty>' };
|
field.emptyOption = { id: '<empty>' } as FormFieldOption;
|
||||||
expect(validator.validate(field)).toBeFalsy();
|
expect(validator.validate(field)).toBeFalsy();
|
||||||
|
|
||||||
field.value = '<non-empty>';
|
field.value = '<non-empty>';
|
||||||
@@ -94,7 +94,7 @@ describe('FormFieldValidator', () => {
|
|||||||
selectionType: 'multiple'
|
selectionType: 'multiple'
|
||||||
});
|
});
|
||||||
|
|
||||||
field.emptyOption = <FormFieldOption> { id: 'empty' };
|
field.emptyOption = { id: 'empty' } as FormFieldOption;
|
||||||
expect(validator.validate(field)).toBeFalsy();
|
expect(validator.validate(field)).toBeFalsy();
|
||||||
|
|
||||||
field.value = [];
|
field.value = [];
|
||||||
|
@@ -816,31 +816,31 @@ describe('FormFieldModel', () => {
|
|||||||
form = new FormModel({
|
form = new FormModel({
|
||||||
variables: [
|
variables: [
|
||||||
{
|
{
|
||||||
'id': 'bfca9766-7bc1-45cc-8ecf-cdad551e36e2',
|
id: 'bfca9766-7bc1-45cc-8ecf-cdad551e36e2',
|
||||||
'name': 'name2',
|
name: 'name2',
|
||||||
'type': 'string',
|
type: 'string',
|
||||||
'value': 'default hello'
|
value: 'default hello'
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
processVariables: [
|
processVariables: [
|
||||||
{
|
{
|
||||||
'serviceName': 'denys-variable-mapping-rb',
|
serviceName: 'denys-variable-mapping-rb',
|
||||||
'serviceFullName': 'denys-variable-mapping-rb',
|
serviceFullName: 'denys-variable-mapping-rb',
|
||||||
'serviceVersion': '',
|
serviceVersion: '',
|
||||||
'appName': 'denys-variable-mapping',
|
appName: 'denys-variable-mapping',
|
||||||
'appVersion': '',
|
appVersion: '',
|
||||||
'serviceType': null,
|
serviceType: null,
|
||||||
'id': 3,
|
id: 3,
|
||||||
'type': 'string',
|
type: 'string',
|
||||||
'name': 'variables.name1',
|
name: 'variables.name1',
|
||||||
'createTime': 1566989626284,
|
createTime: 1566989626284,
|
||||||
'lastUpdatedTime': 1566989626284,
|
lastUpdatedTime: 1566989626284,
|
||||||
'executionId': null,
|
executionId: null,
|
||||||
'value': 'hello',
|
value: 'hello',
|
||||||
'markedAsDeleted': false,
|
markedAsDeleted: false,
|
||||||
'processInstanceId': '1be4785f-c982-11e9-bdd8-96d6903e4e44',
|
processInstanceId: '1be4785f-c982-11e9-bdd8-96d6903e4e44',
|
||||||
'taskId': '1beab9f6-c982-11e9-bdd8-96d6903e4e44',
|
taskId: '1beab9f6-c982-11e9-bdd8-96d6903e4e44',
|
||||||
'taskVariable': true
|
taskVariable: true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
@@ -151,30 +151,30 @@ export class FormFieldModel extends FormWidgetModel {
|
|||||||
this.name = json.name;
|
this.name = json.name;
|
||||||
this.type = json.type;
|
this.type = json.type;
|
||||||
this.roles = json.roles;
|
this.roles = json.roles;
|
||||||
this._required = <boolean> json.required;
|
this._required = json.required;
|
||||||
this._readOnly = <boolean> json.readOnly || json.type === 'readonly';
|
this._readOnly = json.readOnly || json.type === 'readonly';
|
||||||
this.overrideId = <boolean> json.overrideId;
|
this.overrideId = json.overrideId;
|
||||||
this.tab = json.tab;
|
this.tab = json.tab;
|
||||||
this.restUrl = json.restUrl;
|
this.restUrl = json.restUrl;
|
||||||
this.restResponsePath = json.restResponsePath;
|
this.restResponsePath = json.restResponsePath;
|
||||||
this.restIdProperty = json.restIdProperty;
|
this.restIdProperty = json.restIdProperty;
|
||||||
this.restLabelProperty = json.restLabelProperty;
|
this.restLabelProperty = json.restLabelProperty;
|
||||||
this.colspan = <number> json.colspan;
|
this.colspan = json.colspan;
|
||||||
this.rowspan = <number> json.rowspan;
|
this.rowspan = json.rowspan;
|
||||||
this.minLength = <number> json.minLength || 0;
|
this.minLength = json.minLength || 0;
|
||||||
this.maxLength = <number> json.maxLength || 0;
|
this.maxLength = json.maxLength || 0;
|
||||||
this.minValue = json.minValue;
|
this.minValue = json.minValue;
|
||||||
this.maxValue = json.maxValue;
|
this.maxValue = json.maxValue;
|
||||||
this.regexPattern = json.regexPattern;
|
this.regexPattern = json.regexPattern;
|
||||||
this.options = <FormFieldOption[]> json.options || [];
|
this.options = json.options || [];
|
||||||
this.hasEmptyValue = <boolean> json.hasEmptyValue;
|
this.hasEmptyValue = json.hasEmptyValue;
|
||||||
this.className = json.className;
|
this.className = json.className;
|
||||||
this.optionType = json.optionType;
|
this.optionType = json.optionType;
|
||||||
this.params = <FormFieldMetadata> json.params || {};
|
this.params = json.params || {};
|
||||||
this.hyperlinkUrl = json.hyperlinkUrl;
|
this.hyperlinkUrl = json.hyperlinkUrl;
|
||||||
this.displayText = json.displayText;
|
this.displayText = json.displayText;
|
||||||
this.visibilityCondition = json.visibilityCondition ? new WidgetVisibilityModel(json.visibilityCondition) : undefined;
|
this.visibilityCondition = json.visibilityCondition ? new WidgetVisibilityModel(json.visibilityCondition) : undefined;
|
||||||
this.enableFractions = <boolean> json.enableFractions;
|
this.enableFractions = json.enableFractions;
|
||||||
this.currency = json.currency;
|
this.currency = json.currency;
|
||||||
this.dateDisplayFormat = json.dateDisplayFormat || this.getDefaultDateFormat(json);
|
this.dateDisplayFormat = json.dateDisplayFormat || this.getDefaultDateFormat(json);
|
||||||
this._value = this.parseValue(json);
|
this._value = this.parseValue(json);
|
||||||
@@ -256,7 +256,7 @@ export class FormFieldModel extends FormWidgetModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private containerFactory(json: any, form: any): void {
|
private containerFactory(json: any, form: any): void {
|
||||||
this.numberOfColumns = <number> json.numberOfColumns || 1;
|
this.numberOfColumns = json.numberOfColumns || 1;
|
||||||
|
|
||||||
this.fields = json.fields;
|
this.fields = json.fields;
|
||||||
|
|
||||||
@@ -453,6 +453,7 @@ export class FormFieldModel extends FormWidgetModel {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Skip the invalid field type
|
* Skip the invalid field type
|
||||||
|
*
|
||||||
* @param type
|
* @param type
|
||||||
*/
|
*/
|
||||||
isInvalidFieldType(type: string) {
|
isInvalidFieldType(type: string) {
|
||||||
|
@@ -363,9 +363,7 @@ describe('FormModel', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const field: any = {
|
const field: any = {
|
||||||
validate() {
|
validate: () => true
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
form.validateField(field);
|
form.validateField(field);
|
||||||
|
|
||||||
@@ -409,14 +407,10 @@ describe('FormModel', () => {
|
|||||||
|
|
||||||
spyOn(form, 'getFormFields').and.returnValue([testField]);
|
spyOn(form, 'getFormFields').and.returnValue([testField]);
|
||||||
|
|
||||||
const validator = <FormFieldValidator> {
|
const validator = {
|
||||||
isSupported(): boolean {
|
isSupported: (): boolean => true,
|
||||||
return true;
|
validate: (): boolean => true
|
||||||
},
|
} as FormFieldValidator;
|
||||||
validate(): boolean {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
spyOn(validator, 'validate').and.callThrough();
|
spyOn(validator, 'validate').and.callThrough();
|
||||||
|
|
||||||
@@ -449,7 +443,7 @@ describe('FormModel', () => {
|
|||||||
const defaultLength = FORM_FIELD_VALIDATORS.length;
|
const defaultLength = FORM_FIELD_VALIDATORS.length;
|
||||||
|
|
||||||
expect(form.fieldValidators.length).toBe(defaultLength);
|
expect(form.fieldValidators.length).toBe(defaultLength);
|
||||||
form.fieldValidators.push(<any> {});
|
form.fieldValidators.push({} as any);
|
||||||
|
|
||||||
expect(form.fieldValidators.length).toBe(defaultLength + 1);
|
expect(form.fieldValidators.length).toBe(defaultLength + 1);
|
||||||
expect(FORM_FIELD_VALIDATORS.length).toBe(defaultLength);
|
expect(FORM_FIELD_VALIDATORS.length).toBe(defaultLength);
|
||||||
@@ -461,63 +455,63 @@ describe('FormModel', () => {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
const variables = [
|
const variables = [
|
||||||
{
|
{
|
||||||
'id': 'bfca9766-7bc1-45cc-8ecf-cdad551e36e2',
|
id: 'bfca9766-7bc1-45cc-8ecf-cdad551e36e2',
|
||||||
'name': 'name1',
|
name: 'name1',
|
||||||
'type': 'string',
|
type: 'string',
|
||||||
'value': 'hello'
|
value: 'hello'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'id': '3ed9f28a-dbae-463f-b991-47ef06658bb6',
|
id: '3ed9f28a-dbae-463f-b991-47ef06658bb6',
|
||||||
'name': 'name2',
|
name: 'name2',
|
||||||
'type': 'date',
|
type: 'date',
|
||||||
'value': '29.09.2019'
|
value: '29.09.2019'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'id': 'booleanVar',
|
id: 'booleanVar',
|
||||||
'name': 'bool',
|
name: 'bool',
|
||||||
'type': 'boolean',
|
type: 'boolean',
|
||||||
'value': 'true'
|
value: 'true'
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
const processVariables = [
|
const processVariables = [
|
||||||
{
|
{
|
||||||
'serviceName': 'denys-variable-mapping-rb',
|
serviceName: 'denys-variable-mapping-rb',
|
||||||
'serviceFullName': 'denys-variable-mapping-rb',
|
serviceFullName: 'denys-variable-mapping-rb',
|
||||||
'serviceVersion': '',
|
serviceVersion: '',
|
||||||
'appName': 'denys-variable-mapping',
|
appName: 'denys-variable-mapping',
|
||||||
'appVersion': '',
|
appVersion: '',
|
||||||
'serviceType': null,
|
serviceType: null,
|
||||||
'id': 3,
|
id: 3,
|
||||||
'type': 'string',
|
type: 'string',
|
||||||
'name': 'variables.name1',
|
name: 'variables.name1',
|
||||||
'createTime': 1566989626284,
|
createTime: 1566989626284,
|
||||||
'lastUpdatedTime': 1566989626284,
|
lastUpdatedTime: 1566989626284,
|
||||||
'executionId': null,
|
executionId: null,
|
||||||
'value': 'hello',
|
value: 'hello',
|
||||||
'markedAsDeleted': false,
|
markedAsDeleted: false,
|
||||||
'processInstanceId': '1be4785f-c982-11e9-bdd8-96d6903e4e44',
|
processInstanceId: '1be4785f-c982-11e9-bdd8-96d6903e4e44',
|
||||||
'taskId': '1beab9f6-c982-11e9-bdd8-96d6903e4e44',
|
taskId: '1beab9f6-c982-11e9-bdd8-96d6903e4e44',
|
||||||
'taskVariable': true
|
taskVariable: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'serviceName': 'denys-variable-mapping-rb',
|
serviceName: 'denys-variable-mapping-rb',
|
||||||
'serviceFullName': 'denys-variable-mapping-rb',
|
serviceFullName: 'denys-variable-mapping-rb',
|
||||||
'serviceVersion': '',
|
serviceVersion: '',
|
||||||
'appName': 'denys-variable-mapping',
|
appName: 'denys-variable-mapping',
|
||||||
'appVersion': '',
|
appVersion: '',
|
||||||
'serviceType': null,
|
serviceType: null,
|
||||||
'id': 1,
|
id: 1,
|
||||||
'type': 'boolean',
|
type: 'boolean',
|
||||||
'name': 'booleanVar',
|
name: 'booleanVar',
|
||||||
'createTime': 1566989626283,
|
createTime: 1566989626283,
|
||||||
'lastUpdatedTime': 1566989626283,
|
lastUpdatedTime: 1566989626283,
|
||||||
'executionId': null,
|
executionId: null,
|
||||||
'value': 'true',
|
value: 'true',
|
||||||
'markedAsDeleted': false,
|
markedAsDeleted: false,
|
||||||
'processInstanceId': '1be4785f-c982-11e9-bdd8-96d6903e4e44',
|
processInstanceId: '1be4785f-c982-11e9-bdd8-96d6903e4e44',
|
||||||
'taskId': '1beab9f6-c982-11e9-bdd8-96d6903e4e44',
|
taskId: '1beab9f6-c982-11e9-bdd8-96d6903e4e44',
|
||||||
'taskVariable': true
|
taskVariable: true
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -624,7 +618,7 @@ describe('FormModel', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('setNodeIdValueForViewersLinkedToUploadWidget', () => {
|
describe('setNodeIdValueForViewersLinkedToUploadWidget', () => {
|
||||||
const fakeNodeWithProperties: Node = <Node> {
|
const fakeNodeWithProperties: Node = {
|
||||||
id: 'fake-properties',
|
id: 'fake-properties',
|
||||||
name: 'fake-properties-name',
|
name: 'fake-properties-name',
|
||||||
content: {
|
content: {
|
||||||
@@ -634,7 +628,7 @@ describe('FormModel', () => {
|
|||||||
'pfx:property_one': 'testValue',
|
'pfx:property_one': 'testValue',
|
||||||
'pfx:property_two': true
|
'pfx:property_two': true
|
||||||
}
|
}
|
||||||
};
|
} as Node;
|
||||||
let form: FormModel;
|
let form: FormModel;
|
||||||
|
|
||||||
it('should set the node id to the viewers linked to the upload widget in the event', () => {
|
it('should set the node id to the viewers linked to the upload widget in the event', () => {
|
||||||
|
@@ -248,6 +248,7 @@ export class FormModel implements ProcessFormModel {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a form variable that matches the identifier.
|
* Returns a form variable that matches the identifier.
|
||||||
|
*
|
||||||
* @param identifier The `name` or `id` value.
|
* @param identifier The `name` or `id` value.
|
||||||
*/
|
*/
|
||||||
getFormVariable(identifier: string): FormVariableModel {
|
getFormVariable(identifier: string): FormVariableModel {
|
||||||
@@ -264,6 +265,7 @@ export class FormModel implements ProcessFormModel {
|
|||||||
/**
|
/**
|
||||||
* Returns a value of the form variable that matches the identifier.
|
* Returns a value of the form variable that matches the identifier.
|
||||||
* Provides additional conversion of types (date, boolean).
|
* Provides additional conversion of types (date, boolean).
|
||||||
|
*
|
||||||
* @param identifier The `name` or `id` value
|
* @param identifier The `name` or `id` value
|
||||||
*/
|
*/
|
||||||
getFormVariableValue(identifier: string): any {
|
getFormVariableValue(identifier: string): any {
|
||||||
@@ -278,6 +280,7 @@ export class FormModel implements ProcessFormModel {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a process variable value.
|
* Returns a process variable value.
|
||||||
|
*
|
||||||
* @param name Variable name
|
* @param name Variable name
|
||||||
*/
|
*/
|
||||||
getProcessVariableValue(name: string): any {
|
getProcessVariableValue(name: string): any {
|
||||||
@@ -338,7 +341,7 @@ export class FormModel implements ProcessFormModel {
|
|||||||
const field = this.fields[i];
|
const field = this.fields[i];
|
||||||
|
|
||||||
if (field instanceof ContainerModel) {
|
if (field instanceof ContainerModel) {
|
||||||
const container = <ContainerModel> field;
|
const container = field;
|
||||||
formFieldModel.push(container.field);
|
formFieldModel.push(container.field);
|
||||||
|
|
||||||
container.field.columns.forEach((column) => {
|
container.field.columns.forEach((column) => {
|
||||||
@@ -356,24 +359,24 @@ export class FormModel implements ProcessFormModel {
|
|||||||
|
|
||||||
protected parseOutcomes() {
|
protected parseOutcomes() {
|
||||||
if (this.json.fields) {
|
if (this.json.fields) {
|
||||||
const saveOutcome = new FormOutcomeModel(<any> this, {
|
const saveOutcome = new FormOutcomeModel(this, {
|
||||||
id: FormModel.SAVE_OUTCOME,
|
id: FormModel.SAVE_OUTCOME,
|
||||||
name: 'SAVE',
|
name: 'SAVE',
|
||||||
isSystem: true
|
isSystem: true
|
||||||
});
|
});
|
||||||
const completeOutcome = new FormOutcomeModel(<any> this, {
|
const completeOutcome = new FormOutcomeModel(this, {
|
||||||
id: FormModel.COMPLETE_OUTCOME,
|
id: FormModel.COMPLETE_OUTCOME,
|
||||||
name: 'COMPLETE',
|
name: 'COMPLETE',
|
||||||
isSystem: true
|
isSystem: true
|
||||||
});
|
});
|
||||||
const startProcessOutcome = new FormOutcomeModel(<any> this, {
|
const startProcessOutcome = new FormOutcomeModel(this, {
|
||||||
id: FormModel.START_PROCESS_OUTCOME,
|
id: FormModel.START_PROCESS_OUTCOME,
|
||||||
name: 'START PROCESS',
|
name: 'START PROCESS',
|
||||||
isSystem: true
|
isSystem: true
|
||||||
});
|
});
|
||||||
|
|
||||||
const customOutcomes = (this.json.outcomes || []).map(
|
const customOutcomes = (this.json.outcomes || []).map(
|
||||||
(obj) => new FormOutcomeModel(<any> this, obj)
|
(obj) => new FormOutcomeModel(this, obj)
|
||||||
);
|
);
|
||||||
|
|
||||||
this.outcomes = [saveOutcome].concat(
|
this.outcomes = [saveOutcome].concat(
|
||||||
|
@@ -57,7 +57,7 @@ describe('DateTimeWidgetComponent', () => {
|
|||||||
id: 'date-id',
|
id: 'date-id',
|
||||||
name: 'date-name',
|
name: 'date-name',
|
||||||
type: 'datetime',
|
type: 'datetime',
|
||||||
minValue: minValue
|
minValue
|
||||||
});
|
});
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
@@ -81,7 +81,7 @@ describe('DateTimeWidgetComponent', () => {
|
|||||||
it('should setup max value for date picker', () => {
|
it('should setup max value for date picker', () => {
|
||||||
const maxValue = '1982-03-13T10:00:000Z';
|
const maxValue = '1982-03-13T10:00:000Z';
|
||||||
widget.field = new FormFieldModel(null, {
|
widget.field = new FormFieldModel(null, {
|
||||||
maxValue: maxValue
|
maxValue
|
||||||
});
|
});
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
@@ -157,14 +157,14 @@ describe('DateTimeWidgetComponent', () => {
|
|||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
await fixture.whenStable();
|
await fixture.whenStable();
|
||||||
|
|
||||||
let dateButton = <HTMLButtonElement> element.querySelector('button');
|
let dateButton = element.querySelector<HTMLButtonElement>('button');
|
||||||
expect(dateButton.disabled).toBeFalsy();
|
expect(dateButton.disabled).toBeFalsy();
|
||||||
|
|
||||||
widget.field.readOnly = true;
|
widget.field.readOnly = true;
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
await fixture.whenStable();
|
await fixture.whenStable();
|
||||||
|
|
||||||
dateButton = <HTMLButtonElement> element.querySelector('button');
|
dateButton = element.querySelector<HTMLButtonElement>('button');
|
||||||
expect(dateButton.disabled).toBeTruthy();
|
expect(dateButton.disabled).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -62,7 +62,7 @@ export class DateTimeWidgetComponent extends WidgetComponent implements OnInit,
|
|||||||
.pipe(takeUntil(this.onDestroy$))
|
.pipe(takeUntil(this.onDestroy$))
|
||||||
.subscribe(locale => this.dateAdapter.setLocale(locale));
|
.subscribe(locale => this.dateAdapter.setLocale(locale));
|
||||||
|
|
||||||
const momentDateAdapter = <MomentDateAdapter> this.dateAdapter;
|
const momentDateAdapter = this.dateAdapter as MomentDateAdapter;
|
||||||
momentDateAdapter.overrideDisplayFormat = this.field.dateDisplayFormat;
|
momentDateAdapter.overrideDisplayFormat = this.field.dateDisplayFormat;
|
||||||
|
|
||||||
if (this.field) {
|
if (this.field) {
|
||||||
|
@@ -49,7 +49,7 @@ describe('DateWidgetComponent', () => {
|
|||||||
widget.field = new FormFieldModel(null, {
|
widget.field = new FormFieldModel(null, {
|
||||||
id: 'date-id',
|
id: 'date-id',
|
||||||
name: 'date-name',
|
name: 'date-name',
|
||||||
minValue: minValue
|
minValue
|
||||||
});
|
});
|
||||||
|
|
||||||
widget.ngOnInit();
|
widget.ngOnInit();
|
||||||
@@ -61,7 +61,7 @@ describe('DateWidgetComponent', () => {
|
|||||||
it('should date field be present', () => {
|
it('should date field be present', () => {
|
||||||
const minValue = '13-03-1982';
|
const minValue = '13-03-1982';
|
||||||
widget.field = new FormFieldModel(null, {
|
widget.field = new FormFieldModel(null, {
|
||||||
minValue: minValue
|
minValue
|
||||||
});
|
});
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
@@ -73,7 +73,7 @@ describe('DateWidgetComponent', () => {
|
|||||||
it('should setup max value for date picker', () => {
|
it('should setup max value for date picker', () => {
|
||||||
const maxValue = '31-03-1982';
|
const maxValue = '31-03-1982';
|
||||||
widget.field = new FormFieldModel(null, {
|
widget.field = new FormFieldModel(null, {
|
||||||
maxValue: maxValue
|
maxValue
|
||||||
});
|
});
|
||||||
widget.ngOnInit();
|
widget.ngOnInit();
|
||||||
|
|
||||||
@@ -160,13 +160,13 @@ describe('DateWidgetComponent', () => {
|
|||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
await fixture.whenStable();
|
await fixture.whenStable();
|
||||||
|
|
||||||
let dateButton = <HTMLButtonElement> element.querySelector('button');
|
let dateButton = element.querySelector<HTMLButtonElement>('button');
|
||||||
expect(dateButton.disabled).toBeFalsy();
|
expect(dateButton.disabled).toBeFalsy();
|
||||||
|
|
||||||
widget.field.readOnly = true;
|
widget.field.readOnly = true;
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
dateButton = <HTMLButtonElement> element.querySelector('button');
|
dateButton = element.querySelector<HTMLButtonElement>('button');
|
||||||
expect(dateButton.disabled).toBeTruthy();
|
expect(dateButton.disabled).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -70,7 +70,7 @@ export class DateWidgetComponent extends WidgetComponent implements OnInit, OnDe
|
|||||||
.pipe(takeUntil(this.onDestroy$))
|
.pipe(takeUntil(this.onDestroy$))
|
||||||
.subscribe(locale => this.dateAdapter.setLocale(locale));
|
.subscribe(locale => this.dateAdapter.setLocale(locale));
|
||||||
|
|
||||||
const momentDateAdapter = <MomentDateAdapter> this.dateAdapter;
|
const momentDateAdapter = this.dateAdapter as MomentDateAdapter;
|
||||||
momentDateAdapter.overrideDisplayFormat = this.field.dateDisplayFormat;
|
momentDateAdapter.overrideDisplayFormat = this.field.dateDisplayFormat;
|
||||||
|
|
||||||
if (this.field) {
|
if (this.field) {
|
||||||
|
@@ -37,10 +37,10 @@ describe('DropdownWidgetComponent', () => {
|
|||||||
let fixture: ComponentFixture<DropdownWidgetComponent>;
|
let fixture: ComponentFixture<DropdownWidgetComponent>;
|
||||||
let element: HTMLElement;
|
let element: HTMLElement;
|
||||||
|
|
||||||
function openSelect() {
|
const openSelect = () => {
|
||||||
const dropdown = fixture.debugElement.nativeElement.querySelector('.mat-select-trigger');
|
const dropdown = fixture.debugElement.nativeElement.querySelector('.mat-select-trigger');
|
||||||
dropdown.click();
|
dropdown.click();
|
||||||
}
|
};
|
||||||
|
|
||||||
const fakeOptionList: FormFieldOption[] = [
|
const fakeOptionList: FormFieldOption[] = [
|
||||||
{ id: 'opt_1', name: 'option_1' },
|
{ id: 'opt_1', name: 'option_1' },
|
||||||
@@ -80,7 +80,7 @@ describe('DropdownWidgetComponent', () => {
|
|||||||
const fieldId = '<field-id>';
|
const fieldId = '<field-id>';
|
||||||
|
|
||||||
const form = new FormModel({
|
const form = new FormModel({
|
||||||
taskId: taskId
|
taskId
|
||||||
});
|
});
|
||||||
|
|
||||||
widget.field = new FormFieldModel(form, {
|
widget.field = new FormFieldModel(form, {
|
||||||
@@ -99,16 +99,14 @@ describe('DropdownWidgetComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should preserve empty option when loading fields', () => {
|
it('should preserve empty option when loading fields', () => {
|
||||||
const restFieldValue: FormFieldOption = <FormFieldOption> { id: '1', name: 'Option1' };
|
const restFieldValue: FormFieldOption = { id: '1', name: 'Option1' } as FormFieldOption;
|
||||||
spyOn(formService, 'getRestFieldValues').and.callFake(() => {
|
spyOn(formService, 'getRestFieldValues').and.callFake(() => new Observable((observer) => {
|
||||||
return new Observable((observer) => {
|
observer.next([restFieldValue]);
|
||||||
observer.next([restFieldValue]);
|
observer.complete();
|
||||||
observer.complete();
|
}));
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
const form = new FormModel({ taskId: '<id>' });
|
const form = new FormModel({ taskId: '<id>' });
|
||||||
const emptyOption: FormFieldOption = <FormFieldOption> { id: 'empty', name: 'Empty' };
|
const emptyOption: FormFieldOption = { id: 'empty', name: 'Empty' } as FormFieldOption;
|
||||||
widget.field = new FormFieldModel(form, {
|
widget.field = new FormFieldModel(form, {
|
||||||
id: '<id>',
|
id: '<id>',
|
||||||
restUrl: '/some/url/address',
|
restUrl: '/some/url/address',
|
||||||
@@ -167,9 +165,7 @@ describe('DropdownWidgetComponent', () => {
|
|||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
spyOn(visibilityService, 'refreshVisibility').and.stub();
|
spyOn(visibilityService, 'refreshVisibility').and.stub();
|
||||||
spyOn(formService, 'getRestFieldValues').and.callFake(() => {
|
spyOn(formService, 'getRestFieldValues').and.callFake(() => of(fakeOptionList));
|
||||||
return of(fakeOptionList);
|
|
||||||
});
|
|
||||||
widget.field = new FormFieldModel(new FormModel({ taskId: 'fake-task-id' }), {
|
widget.field = new FormFieldModel(new FormModel({ taskId: 'fake-task-id' }), {
|
||||||
id: 'dropdown-id',
|
id: 'dropdown-id',
|
||||||
name: 'date-name',
|
name: 'date-name',
|
||||||
@@ -230,9 +226,7 @@ describe('DropdownWidgetComponent', () => {
|
|||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
spyOn(visibilityService, 'refreshVisibility').and.stub();
|
spyOn(visibilityService, 'refreshVisibility').and.stub();
|
||||||
spyOn(formService, 'getRestFieldValuesByProcessId').and.callFake(() => {
|
spyOn(formService, 'getRestFieldValuesByProcessId').and.callFake(() => of(fakeOptionList));
|
||||||
return of(fakeOptionList);
|
|
||||||
});
|
|
||||||
widget.field = new FormFieldModel(new FormModel({ processDefinitionId: 'fake-process-id' }), {
|
widget.field = new FormFieldModel(new FormModel({ processDefinitionId: 'fake-process-id' }), {
|
||||||
id: 'dropdown-id',
|
id: 'dropdown-id',
|
||||||
name: 'date-name',
|
name: 'date-name',
|
||||||
@@ -300,7 +294,7 @@ describe('DropdownWidgetComponent', () => {
|
|||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
await fixture.whenStable();
|
await fixture.whenStable();
|
||||||
|
|
||||||
const dropDownElement: HTMLSelectElement = <HTMLSelectElement> element.querySelector('#dropdown-id');
|
const dropDownElement = element.querySelector<HTMLSelectElement>('#dropdown-id');
|
||||||
expect(dropDownElement).not.toBeNull();
|
expect(dropDownElement).not.toBeNull();
|
||||||
expect(dropDownElement.getAttribute('aria-disabled')).toBe('true');
|
expect(dropDownElement.getAttribute('aria-disabled')).toBe('true');
|
||||||
});
|
});
|
||||||
|
@@ -72,7 +72,7 @@ export class DynamicTableModel extends FormWidgetModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (field.json.value) {
|
if (field.json.value) {
|
||||||
this.rows = field.json.value.map((obj) => <DynamicTableRow> {selected: false, value: obj});
|
this.rows = field.json.value.map((obj) => ({ selected: false, value: obj } as DynamicTableRow));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,7 +91,7 @@ export class DynamicTableModel extends FormWidgetModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (definitions) {
|
if (definitions) {
|
||||||
return definitions.map((obj) => <DynamicTableColumn> obj);
|
return definitions.map((obj) => obj as DynamicTableColumn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@@ -107,7 +107,7 @@ describe('DynamicTableWidgetComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should select row on click', () => {
|
it('should select row on click', () => {
|
||||||
const row = <DynamicTableRow> {selected: false};
|
const row = {selected: false} as DynamicTableRow;
|
||||||
widget.onRowClicked(row);
|
widget.onRowClicked(row);
|
||||||
|
|
||||||
expect(row.selected).toBeTruthy();
|
expect(row.selected).toBeTruthy();
|
||||||
@@ -115,7 +115,7 @@ describe('DynamicTableWidgetComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should require table to select clicked row', () => {
|
it('should require table to select clicked row', () => {
|
||||||
const row = <DynamicTableRow> {selected: false};
|
const row = {selected: false} as DynamicTableRow;
|
||||||
widget.content = null;
|
widget.content = null;
|
||||||
widget.onRowClicked(row);
|
widget.onRowClicked(row);
|
||||||
|
|
||||||
@@ -123,7 +123,7 @@ describe('DynamicTableWidgetComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should reset selected row', () => {
|
it('should reset selected row', () => {
|
||||||
const row = <DynamicTableRow> {selected: false};
|
const row = {selected: false} as DynamicTableRow;
|
||||||
widget.content.rows.push(row);
|
widget.content.rows.push(row);
|
||||||
widget.content.selectedRow = row;
|
widget.content.selectedRow = row;
|
||||||
expect(widget.content.selectedRow).toBe(row);
|
expect(widget.content.selectedRow).toBe(row);
|
||||||
@@ -135,7 +135,7 @@ describe('DynamicTableWidgetComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should check selection', () => {
|
it('should check selection', () => {
|
||||||
const row = <DynamicTableRow> {selected: false};
|
const row = {selected: false} as DynamicTableRow;
|
||||||
widget.content.rows.push(row);
|
widget.content.rows.push(row);
|
||||||
widget.content.selectedRow = row;
|
widget.content.selectedRow = row;
|
||||||
expect(widget.hasSelection()).toBeTruthy();
|
expect(widget.hasSelection()).toBeTruthy();
|
||||||
@@ -153,8 +153,8 @@ describe('DynamicTableWidgetComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should move selection up', () => {
|
it('should move selection up', () => {
|
||||||
const row1 = <DynamicTableRow> {};
|
const row1 = {} as DynamicTableRow;
|
||||||
const row2 = <DynamicTableRow> {};
|
const row2 = {} as DynamicTableRow;
|
||||||
widget.content.rows.push(...[row1, row2]);
|
widget.content.rows.push(...[row1, row2]);
|
||||||
widget.content.selectedRow = row2;
|
widget.content.selectedRow = row2;
|
||||||
|
|
||||||
@@ -168,8 +168,8 @@ describe('DynamicTableWidgetComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should move selection down', () => {
|
it('should move selection down', () => {
|
||||||
const row1 = <DynamicTableRow> {};
|
const row1 = {} as DynamicTableRow;
|
||||||
const row2 = <DynamicTableRow> {};
|
const row2 = {} as DynamicTableRow;
|
||||||
widget.content.rows.push(...[row1, row2]);
|
widget.content.rows.push(...[row1, row2]);
|
||||||
widget.content.selectedRow = row1;
|
widget.content.selectedRow = row1;
|
||||||
|
|
||||||
@@ -183,7 +183,7 @@ describe('DynamicTableWidgetComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should delete selected row', () => {
|
it('should delete selected row', () => {
|
||||||
const row = <DynamicTableRow> {};
|
const row = {} as DynamicTableRow;
|
||||||
widget.content.rows.push(row);
|
widget.content.rows.push(row);
|
||||||
widget.content.selectedRow = row;
|
widget.content.selectedRow = row;
|
||||||
widget.deleteSelection();
|
widget.deleteSelection();
|
||||||
@@ -213,7 +213,7 @@ describe('DynamicTableWidgetComponent', () => {
|
|||||||
expect(widget.editMode).toBeFalsy();
|
expect(widget.editMode).toBeFalsy();
|
||||||
expect(widget.editRow).toBeFalsy();
|
expect(widget.editRow).toBeFalsy();
|
||||||
|
|
||||||
const row = <DynamicTableRow> {value: true};
|
const row = {value: true} as DynamicTableRow;
|
||||||
widget.content.selectedRow = row;
|
widget.content.selectedRow = row;
|
||||||
|
|
||||||
expect(widget.editSelection()).toBeTruthy();
|
expect(widget.editSelection()).toBeTruthy();
|
||||||
@@ -223,7 +223,7 @@ describe('DynamicTableWidgetComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should copy row', () => {
|
it('should copy row', () => {
|
||||||
const row = <DynamicTableRow> {value: {opt: {key: '1', value: 1}}};
|
const row = {value: {opt: {key: '1', value: 1}}} as DynamicTableRow;
|
||||||
const copy = widget.copyRow(row);
|
const copy = widget.copyRow(row);
|
||||||
expect(copy.value).toEqual(row.value);
|
expect(copy.value).toEqual(row.value);
|
||||||
});
|
});
|
||||||
@@ -235,14 +235,14 @@ describe('DynamicTableWidgetComponent', () => {
|
|||||||
|
|
||||||
it('should retrieve cell value', () => {
|
it('should retrieve cell value', () => {
|
||||||
const value = '<value>';
|
const value = '<value>';
|
||||||
const row = <DynamicTableRow> {value: {key: value}};
|
const row = {value: {key: value}} as DynamicTableRow;
|
||||||
const column = <DynamicTableColumn> {id: 'key'};
|
const column = {id: 'key'} as DynamicTableColumn;
|
||||||
|
|
||||||
expect(widget.getCellValue(row, column)).toBe(value);
|
expect(widget.getCellValue(row, column)).toBe(value);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should save changes and add new row', () => {
|
it('should save changes and add new row', () => {
|
||||||
const row = <DynamicTableRow> {isNew: true, value: {key: 'value'}};
|
const row = {isNew: true, value: {key: 'value'}} as DynamicTableRow;
|
||||||
widget.editMode = true;
|
widget.editMode = true;
|
||||||
widget.editRow = row;
|
widget.editRow = row;
|
||||||
|
|
||||||
@@ -255,7 +255,7 @@ describe('DynamicTableWidgetComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should save changes and update row', () => {
|
it('should save changes and update row', () => {
|
||||||
const row = <DynamicTableRow> {isNew: false, value: {key: 'value'}};
|
const row = {isNew: false, value: {key: 'value'}} as DynamicTableRow;
|
||||||
widget.editMode = true;
|
widget.editMode = true;
|
||||||
widget.editRow = row;
|
widget.editRow = row;
|
||||||
widget.content.selectedRow = row;
|
widget.content.selectedRow = row;
|
||||||
@@ -275,7 +275,7 @@ describe('DynamicTableWidgetComponent', () => {
|
|||||||
|
|
||||||
it('should cancel changes', () => {
|
it('should cancel changes', () => {
|
||||||
widget.editMode = true;
|
widget.editMode = true;
|
||||||
widget.editRow = <DynamicTableRow> {};
|
widget.editRow = {} as DynamicTableRow;
|
||||||
widget.onCancelChanges();
|
widget.onCancelChanges();
|
||||||
|
|
||||||
expect(widget.editMode).toBeFalsy();
|
expect(widget.editMode).toBeFalsy();
|
||||||
@@ -311,15 +311,15 @@ describe('DynamicTableWidgetComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should prepend default currency for amount columns', () => {
|
it('should prepend default currency for amount columns', () => {
|
||||||
const row = <DynamicTableRow> {value: {key: '100'}};
|
const row = {value: {key: '100'}} as DynamicTableRow;
|
||||||
const column = <DynamicTableColumn> {id: 'key', type: 'Amount'};
|
const column = {id: 'key', type: 'Amount'} as DynamicTableColumn;
|
||||||
const actual = widget.getCellValue(row, column);
|
const actual = widget.getCellValue(row, column);
|
||||||
expect(actual).toBe('$ 100');
|
expect(actual).toBe('$ 100');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should prepend custom currency for amount columns', () => {
|
it('should prepend custom currency for amount columns', () => {
|
||||||
const row = <DynamicTableRow> {value: {key: '100'}};
|
const row = {value: {key: '100'}} as DynamicTableRow;
|
||||||
const column = <DynamicTableColumn> {id: 'key', type: 'Amount', amountCurrency: 'GBP'};
|
const column = {id: 'key', type: 'Amount', amountCurrency: 'GBP'} as DynamicTableColumn;
|
||||||
const actual = widget.getCellValue(row, column);
|
const actual = widget.getCellValue(row, column);
|
||||||
expect(actual).toBe('GBP 100');
|
expect(actual).toBe('GBP 100');
|
||||||
});
|
});
|
||||||
@@ -357,7 +357,7 @@ describe('DynamicTableWidgetComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should focus on add button when a new row is saved', async () => {
|
it('should focus on add button when a new row is saved', async () => {
|
||||||
const addNewRowButton: HTMLButtonElement = <HTMLButtonElement> element.querySelector('#fake-dynamic-table-add-row');
|
const addNewRowButton = element.querySelector<HTMLButtonElement>('#fake-dynamic-table-add-row');
|
||||||
|
|
||||||
expect(element.querySelector('#dynamic-table-fake-dynamic-table')).not.toBeNull();
|
expect(element.querySelector('#dynamic-table-fake-dynamic-table')).not.toBeNull();
|
||||||
expect(addNewRowButton).not.toBeNull();
|
expect(addNewRowButton).not.toBeNull();
|
||||||
|
@@ -72,7 +72,7 @@ export class DynamicTableWidgetComponent extends WidgetComponent implements OnIn
|
|||||||
forceFocusOnAddButton() {
|
forceFocusOnAddButton() {
|
||||||
if (this.content) {
|
if (this.content) {
|
||||||
this.cd.detectChanges();
|
this.cd.detectChanges();
|
||||||
const buttonAddRow = <HTMLButtonElement> this.elementRef.nativeElement.querySelector('#' + this.content.id + '-add-row');
|
const buttonAddRow = this.elementRef.nativeElement.querySelector('#' + this.content.id + '-add-row');
|
||||||
if (this.isDynamicTableReady(buttonAddRow)) {
|
if (this.isDynamicTableReady(buttonAddRow)) {
|
||||||
buttonAddRow.focus();
|
buttonAddRow.focus();
|
||||||
}
|
}
|
||||||
@@ -139,7 +139,7 @@ export class DynamicTableWidgetComponent extends WidgetComponent implements OnIn
|
|||||||
|
|
||||||
addNewRow(): boolean {
|
addNewRow(): boolean {
|
||||||
if (this.content && !this.readOnly) {
|
if (this.content && !this.readOnly) {
|
||||||
this.editRow = <DynamicTableRow> {
|
this.editRow = {
|
||||||
isNew: true,
|
isNew: true,
|
||||||
selected: false,
|
selected: false,
|
||||||
value: {}
|
value: {}
|
||||||
@@ -195,9 +195,7 @@ export class DynamicTableWidgetComponent extends WidgetComponent implements OnIn
|
|||||||
}
|
}
|
||||||
|
|
||||||
copyRow(row: DynamicTableRow): DynamicTableRow {
|
copyRow(row: DynamicTableRow): DynamicTableRow {
|
||||||
return <DynamicTableRow> {
|
return { value: this.copyObject(row.value) } as DynamicTableRow;
|
||||||
value: this.copyObject(row.value)
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private copyObject(obj: any): any {
|
private copyObject(obj: any): any {
|
||||||
|
@@ -28,8 +28,8 @@ describe('AmountEditorComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should update row value on change', () => {
|
it('should update row value on change', () => {
|
||||||
const row = <DynamicTableRow> { value: {} };
|
const row = { value: {} } as DynamicTableRow;
|
||||||
const column = <DynamicTableColumn> { id: 'key' };
|
const column = { id: 'key' } as DynamicTableColumn;
|
||||||
|
|
||||||
const value = 100;
|
const value = 100;
|
||||||
const event = { target: { value } };
|
const event = { target: { value } };
|
||||||
|
@@ -45,7 +45,7 @@ export class AmountEditorComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onValueChanged(row: DynamicTableRow, column: DynamicTableColumn, event: any) {
|
onValueChanged(row: DynamicTableRow, column: DynamicTableColumn, event: any) {
|
||||||
const value: number = Number((<HTMLInputElement> event.target).value);
|
const value: number = Number(event.target.value);
|
||||||
row.value[column.id] = value;
|
row.value[column.id] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -29,8 +29,8 @@ describe('BooleanEditorComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should update row value on change', () => {
|
it('should update row value on change', () => {
|
||||||
const row = <DynamicTableRow> { value: {} };
|
const row = { value: {} } as DynamicTableRow;
|
||||||
const column = <DynamicTableColumn> { id: 'key' };
|
const column = { id: 'key' } as DynamicTableColumn;
|
||||||
const event = { checked: true } ;
|
const event = { checked: true } ;
|
||||||
|
|
||||||
component.onValueChanged(row, column, event);
|
component.onValueChanged(row, column, event);
|
||||||
|
@@ -39,7 +39,7 @@ export class BooleanEditorComponent {
|
|||||||
column: DynamicTableColumn;
|
column: DynamicTableColumn;
|
||||||
|
|
||||||
onValueChanged(row: DynamicTableRow, column: DynamicTableColumn, event: any) {
|
onValueChanged(row: DynamicTableRow, column: DynamicTableColumn, event: any) {
|
||||||
const value: boolean = (<HTMLInputElement> event).checked;
|
const value: boolean = event.checked;
|
||||||
row.value[column.id] = value;
|
row.value[column.id] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -45,8 +45,8 @@ describe('DateEditorComponent', () => {
|
|||||||
fixture = TestBed.createComponent(DateEditorComponent);
|
fixture = TestBed.createComponent(DateEditorComponent);
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
|
|
||||||
row = <DynamicTableRow> { value: { date: '1879-03-14T00:00:00.000Z' } };
|
row = { value: { date: '1879-03-14T00:00:00.000Z' } } as DynamicTableRow;
|
||||||
column = <DynamicTableColumn> { id: 'date', type: 'Date' };
|
column = { id: 'date', type: 'Date' } as DynamicTableColumn;
|
||||||
const field = new FormFieldModel(new FormModel());
|
const field = new FormFieldModel(new FormModel());
|
||||||
table = new DynamicTableModel(field, null);
|
table = new DynamicTableModel(field, null);
|
||||||
table.rows.push(row);
|
table.rows.push(row);
|
||||||
@@ -58,7 +58,7 @@ describe('DateEditorComponent', () => {
|
|||||||
|
|
||||||
describe('using Date Piker', () => {
|
describe('using Date Piker', () => {
|
||||||
it('should update row value on change', () => {
|
it('should update row value on change', () => {
|
||||||
const input = <MatDatepickerInputEvent<any>> {value: '14-03-2016' };
|
const input = {value: '14-03-2016' } as MatDatepickerInputEvent<any>;
|
||||||
|
|
||||||
component.ngOnInit();
|
component.ngOnInit();
|
||||||
component.onDateChanged(input);
|
component.onDateChanged(input);
|
||||||
@@ -69,7 +69,7 @@ describe('DateEditorComponent', () => {
|
|||||||
|
|
||||||
it('should flush value on user input', () => {
|
it('should flush value on user input', () => {
|
||||||
spyOn(table, 'flushValue').and.callThrough();
|
spyOn(table, 'flushValue').and.callThrough();
|
||||||
const input = <MatDatepickerInputEvent<any>> {value: '14-03-2016' };
|
const input = {value: '14-03-2016' } as MatDatepickerInputEvent<any>;
|
||||||
|
|
||||||
component.ngOnInit();
|
component.ngOnInit();
|
||||||
component.onDateChanged(input);
|
component.onDateChanged(input);
|
||||||
|
@@ -70,7 +70,7 @@ export class DateEditorComponent implements OnInit, OnDestroy {
|
|||||||
.pipe(takeUntil(this.onDestroy$))
|
.pipe(takeUntil(this.onDestroy$))
|
||||||
.subscribe(locale => this.dateAdapter.setLocale(locale));
|
.subscribe(locale => this.dateAdapter.setLocale(locale));
|
||||||
|
|
||||||
const momentDateAdapter = <MomentDateAdapter> this.dateAdapter;
|
const momentDateAdapter = this.dateAdapter as MomentDateAdapter;
|
||||||
momentDateAdapter.overrideDisplayFormat = this.DATE_FORMAT;
|
momentDateAdapter.overrideDisplayFormat = this.DATE_FORMAT;
|
||||||
|
|
||||||
this.value = moment(this.table.getCellValue(this.row, this.column), this.DATE_FORMAT);
|
this.value = moment(this.table.getCellValue(this.row, this.column), this.DATE_FORMAT);
|
||||||
|
@@ -44,8 +44,8 @@ describe('DateTimeEditorComponent', () => {
|
|||||||
fixture = TestBed.createComponent(DateTimeEditorComponent);
|
fixture = TestBed.createComponent(DateTimeEditorComponent);
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
|
|
||||||
row = <DynamicTableRow> { value: { date: '1879-03-14T00:00:00.000Z' } };
|
row = { value: { date: '1879-03-14T00:00:00.000Z' } } as DynamicTableRow;
|
||||||
column = <DynamicTableColumn> { id: 'datetime', type: 'Datetime' };
|
column = { id: 'datetime', type: 'Datetime' } as DynamicTableColumn;
|
||||||
const field = new FormFieldModel(new FormModel());
|
const field = new FormFieldModel(new FormModel());
|
||||||
table = new DynamicTableModel(field, null);
|
table = new DynamicTableModel(field, null);
|
||||||
table.rows.push(row);
|
table.rows.push(row);
|
||||||
|
@@ -73,7 +73,7 @@ export class DateTimeEditorComponent implements OnInit, OnDestroy {
|
|||||||
.pipe(takeUntil(this.onDestroy$))
|
.pipe(takeUntil(this.onDestroy$))
|
||||||
.subscribe(locale => this.dateAdapter.setLocale(locale));
|
.subscribe(locale => this.dateAdapter.setLocale(locale));
|
||||||
|
|
||||||
const momentDateAdapter = <MomentDateAdapter> this.dateAdapter;
|
const momentDateAdapter = this.dateAdapter as MomentDateAdapter;
|
||||||
momentDateAdapter.overrideDisplayFormat = this.DATE_TIME_FORMAT;
|
momentDateAdapter.overrideDisplayFormat = this.DATE_TIME_FORMAT;
|
||||||
|
|
||||||
this.value = moment(this.table.getCellValue(this.row, this.column), this.DATE_TIME_FORMAT);
|
this.value = moment(this.table.getCellValue(this.row, this.column), this.DATE_TIME_FORMAT);
|
||||||
|
@@ -51,14 +51,14 @@ describe('DropdownEditorComponent', () => {
|
|||||||
alfrescoApiService = TestBed.inject(AlfrescoApiService);
|
alfrescoApiService = TestBed.inject(AlfrescoApiService);
|
||||||
formService = new FormService(null, alfrescoApiService, null);
|
formService = new FormService(null, alfrescoApiService, null);
|
||||||
|
|
||||||
row = <DynamicTableRow> {value: {dropdown: 'one'}};
|
row = {value: {dropdown: 'one'}} as DynamicTableRow;
|
||||||
column = <DynamicTableColumn> {
|
column = {
|
||||||
id: 'dropdown',
|
id: 'dropdown',
|
||||||
options: [
|
options: [
|
||||||
<DynamicTableColumnOption> {id: '1', name: 'one'},
|
{id: '1', name: 'one'},
|
||||||
<DynamicTableColumnOption> {id: '2', name: 'two'}
|
{id: '2', name: 'two'}
|
||||||
]
|
]
|
||||||
};
|
} as DynamicTableColumn;
|
||||||
|
|
||||||
form = new FormModel({taskId: '<task-id>'});
|
form = new FormModel({taskId: '<task-id>'});
|
||||||
table = new DynamicTableModel(new FormFieldModel(form, {id: '<field-id>'}), formService);
|
table = new DynamicTableModel(new FormFieldModel(form, {id: '<field-id>'}), formService);
|
||||||
@@ -95,9 +95,9 @@ describe('DropdownEditorComponent', () => {
|
|||||||
column.optionType = 'rest';
|
column.optionType = 'rest';
|
||||||
row.value[column.id] = 'twelve';
|
row.value[column.id] = 'twelve';
|
||||||
|
|
||||||
const restResults = [
|
const restResults: DynamicTableColumnOption[] = [
|
||||||
<DynamicTableColumnOption> {id: '11', name: 'eleven'},
|
{id: '11', name: 'eleven'},
|
||||||
<DynamicTableColumnOption> {id: '12', name: 'twelve'}
|
{id: '12', name: 'twelve'}
|
||||||
];
|
];
|
||||||
|
|
||||||
spyOn(formService, 'getRestFieldValuesColumn').and.returnValue(
|
spyOn(formService, 'getRestFieldValuesColumn').and.returnValue(
|
||||||
@@ -192,11 +192,11 @@ describe('DropdownEditorComponent', () => {
|
|||||||
}, {id: 'opt_3', name: 'option_3'}];
|
}, {id: 'opt_3', name: 'option_3'}];
|
||||||
let dynamicTable: DynamicTableModel;
|
let dynamicTable: DynamicTableModel;
|
||||||
|
|
||||||
function openSelect() {
|
const openSelect = () => {
|
||||||
const dropdown = fixture.debugElement.query(By.css('.mat-select-trigger'));
|
const dropdown = fixture.debugElement.query(By.css('.mat-select-trigger'));
|
||||||
dropdown.triggerEventHandler('click', null);
|
dropdown.triggerEventHandler('click', null);
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
}
|
};
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
fixture = TestBed.createComponent(DropdownEditorComponent);
|
fixture = TestBed.createComponent(DropdownEditorComponent);
|
||||||
@@ -213,15 +213,15 @@ describe('DropdownEditorComponent', () => {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
stubFormService = fixture.debugElement.injector.get(FormService);
|
stubFormService = fixture.debugElement.injector.get(FormService);
|
||||||
spyOn(stubFormService, 'getRestFieldValuesColumn').and.returnValue(of(fakeOptionList));
|
spyOn(stubFormService, 'getRestFieldValuesColumn').and.returnValue(of(fakeOptionList));
|
||||||
row = <DynamicTableRow> {value: {dropdown: 'one'}};
|
row = {value: {dropdown: 'one'}} as DynamicTableRow;
|
||||||
column = <DynamicTableColumn> {
|
column = {
|
||||||
id: 'column-id',
|
id: 'column-id',
|
||||||
optionType: 'rest',
|
optionType: 'rest',
|
||||||
options: [
|
options: [
|
||||||
<DynamicTableColumnOption> {id: '1', name: 'one'},
|
{id: '1', name: 'one'},
|
||||||
<DynamicTableColumnOption> {id: '2', name: 'two'}
|
{id: '2', name: 'two'}
|
||||||
]
|
]
|
||||||
};
|
} as DynamicTableColumn;
|
||||||
form = new FormModel({taskId: '<task-id>'});
|
form = new FormModel({taskId: '<task-id>'});
|
||||||
dynamicTable = new DynamicTableModel(new FormFieldModel(form, {id: '<field-id>'}), formService);
|
dynamicTable = new DynamicTableModel(new FormFieldModel(form, {id: '<field-id>'}), formService);
|
||||||
dynamicTable.rows.push(row);
|
dynamicTable.rows.push(row);
|
||||||
@@ -261,15 +261,15 @@ describe('DropdownEditorComponent', () => {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
stubFormService = fixture.debugElement.injector.get(FormService);
|
stubFormService = fixture.debugElement.injector.get(FormService);
|
||||||
spyOn(stubFormService, 'getRestFieldValuesColumnByProcessId').and.returnValue(of(fakeOptionList));
|
spyOn(stubFormService, 'getRestFieldValuesColumnByProcessId').and.returnValue(of(fakeOptionList));
|
||||||
row = <DynamicTableRow> {value: {dropdown: 'one'}};
|
row = {value: {dropdown: 'one'}} as DynamicTableRow;
|
||||||
column = <DynamicTableColumn> {
|
column = {
|
||||||
id: 'column-id',
|
id: 'column-id',
|
||||||
optionType: 'rest',
|
optionType: 'rest',
|
||||||
options: [
|
options: [
|
||||||
<DynamicTableColumnOption> {id: '1', name: 'one'},
|
{id: '1', name: 'one'},
|
||||||
<DynamicTableColumnOption> {id: '2', name: 'two'}
|
{id: '2', name: 'two'}
|
||||||
]
|
]
|
||||||
};
|
} as DynamicTableColumn;
|
||||||
form = new FormModel({processDefinitionId: '<proc-id>'});
|
form = new FormModel({processDefinitionId: '<proc-id>'});
|
||||||
dynamicTable = new DynamicTableModel(new FormFieldModel(form, {id: '<field-id>'}), formService);
|
dynamicTable = new DynamicTableModel(new FormFieldModel(form, {id: '<field-id>'}), formService);
|
||||||
dynamicTable.rows.push(row);
|
dynamicTable.rows.push(row);
|
||||||
|
@@ -99,7 +99,7 @@ export class DropdownEditorComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onValueChanged(row: DynamicTableRow, column: DynamicTableColumn, event: any) {
|
onValueChanged(row: DynamicTableRow, column: DynamicTableColumn, event: any) {
|
||||||
let value: any = (<HTMLInputElement> event).value;
|
let value: any = event.value;
|
||||||
value = column.options.find((opt) => opt.name === value);
|
value = column.options.find((opt) => opt.name === value);
|
||||||
row.value[column.id] = value;
|
row.value[column.id] = value;
|
||||||
}
|
}
|
||||||
|
@@ -17,7 +17,6 @@
|
|||||||
|
|
||||||
import { FormFieldModel, FormModel } from '../../core';
|
import { FormFieldModel, FormModel } from '../../core';
|
||||||
import { FormService } from './../../../../services/form.service';
|
import { FormService } from './../../../../services/form.service';
|
||||||
import { DynamicRowValidationSummary } from './../dynamic-row-validation-summary.model';
|
|
||||||
import { DynamicTableColumn } from './../dynamic-table-column.model';
|
import { DynamicTableColumn } from './../dynamic-table-column.model';
|
||||||
import { DynamicTableRow } from './../dynamic-table-row.model';
|
import { DynamicTableRow } from './../dynamic-table-row.model';
|
||||||
import { DynamicTableModel } from './../dynamic-table.widget.model';
|
import { DynamicTableModel } from './../dynamic-table.widget.model';
|
||||||
@@ -45,8 +44,8 @@ describe('RowEditorComponent', () => {
|
|||||||
component = new RowEditorComponent();
|
component = new RowEditorComponent();
|
||||||
const field = new FormFieldModel(new FormModel());
|
const field = new FormFieldModel(new FormModel());
|
||||||
component.table = new DynamicTableModel(field, new FormService(null, alfrescoApiService, null));
|
component.table = new DynamicTableModel(field, new FormService(null, alfrescoApiService, null));
|
||||||
component.row = <DynamicTableRow> {};
|
component.row = {} as DynamicTableRow;
|
||||||
component.column = <DynamicTableColumn> {};
|
component.column = {} as DynamicTableColumn;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should be valid upon init', () => {
|
it('should be valid upon init', () => {
|
||||||
@@ -72,7 +71,7 @@ describe('RowEditorComponent', () => {
|
|||||||
|
|
||||||
it('should emit [save] event', (done) => {
|
it('should emit [save] event', (done) => {
|
||||||
spyOn(component.table, 'validateRow').and.returnValue(
|
spyOn(component.table, 'validateRow').and.returnValue(
|
||||||
<DynamicRowValidationSummary> {isValid: true, message: null}
|
{isValid: true, message: null}
|
||||||
);
|
);
|
||||||
component.save.subscribe((event) => {
|
component.save.subscribe((event) => {
|
||||||
expect(event.table).toBe(component.table);
|
expect(event.table).toBe(component.table);
|
||||||
@@ -85,7 +84,7 @@ describe('RowEditorComponent', () => {
|
|||||||
|
|
||||||
it('should not emit [save] event for invalid row', () => {
|
it('should not emit [save] event for invalid row', () => {
|
||||||
spyOn(component.table, 'validateRow').and.returnValue(
|
spyOn(component.table, 'validateRow').and.returnValue(
|
||||||
<DynamicRowValidationSummary> {isValid: false, message: 'error'}
|
{isValid: false, message: 'error'}
|
||||||
);
|
);
|
||||||
let raised = false;
|
let raised = false;
|
||||||
component.save.subscribe(() => raised = true);
|
component.save.subscribe(() => raised = true);
|
||||||
|
@@ -28,8 +28,8 @@ describe('TextEditorComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should update row value on change', () => {
|
it('should update row value on change', () => {
|
||||||
const row = <DynamicTableRow> { value: {} };
|
const row = { value: {} } as DynamicTableRow;
|
||||||
const column = <DynamicTableColumn> { id: 'key' };
|
const column = { id: 'key' } as DynamicTableColumn;
|
||||||
|
|
||||||
const value = '<value>';
|
const value = '<value>';
|
||||||
const event = { target: { value } };
|
const event = { target: { value } };
|
||||||
|
@@ -45,7 +45,7 @@ export class TextEditorComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onValueChanged(row: DynamicTableRow, column: DynamicTableColumn, event: any) {
|
onValueChanged(row: DynamicTableRow, column: DynamicTableColumn, event: any) {
|
||||||
const value: any = (<HTMLInputElement> event.target).value;
|
const value: any = event.target.value;
|
||||||
row.value[column.id] = value;
|
row.value[column.id] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -57,7 +57,7 @@ describe('FunctionalGroupWidgetComponent', () => {
|
|||||||
fixture.destroy();
|
fixture.destroy();
|
||||||
});
|
});
|
||||||
|
|
||||||
async function typeIntoInput(text: string) {
|
const typeIntoInput = async (text: string) => {
|
||||||
component.searchTerm.setValue(text);
|
component.searchTerm.setValue(text);
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
@@ -72,7 +72,7 @@ describe('FunctionalGroupWidgetComponent', () => {
|
|||||||
|
|
||||||
await fixture.whenStable();
|
await fixture.whenStable();
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
}
|
};
|
||||||
|
|
||||||
it('should setup text from underlying field on init', async () => {
|
it('should setup text from underlying field on init', async () => {
|
||||||
const group: GroupModel = { name: 'group-1'};
|
const group: GroupModel = { name: 'group-1'};
|
||||||
|
@@ -74,7 +74,7 @@ export class FunctionalGroupWidgetComponent extends WidgetComponent implements O
|
|||||||
|
|
||||||
const params = this.field.params;
|
const params = this.field.params;
|
||||||
if (params && params.restrictWithGroup) {
|
if (params && params.restrictWithGroup) {
|
||||||
const restrictWithGroup = <GroupModel> params.restrictWithGroup;
|
const restrictWithGroup = params.restrictWithGroup;
|
||||||
this.groupId = restrictWithGroup.id;
|
this.groupId = restrictWithGroup.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -185,7 +185,7 @@ describe('HyperlinkWidgetComponent', () => {
|
|||||||
const url = 'https://www.alfresco.com/';
|
const url = 'https://www.alfresco.com/';
|
||||||
widget.field = new FormFieldModel(new FormModel(), {
|
widget.field = new FormFieldModel(new FormModel(), {
|
||||||
hyperlinkUrl: url,
|
hyperlinkUrl: url,
|
||||||
displayText: displayText,
|
displayText,
|
||||||
type: FormFieldTypes.HYPERLINK
|
type: FormFieldTypes.HYPERLINK
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -201,7 +201,7 @@ describe('HyperlinkWidgetComponent', () => {
|
|||||||
widget.field = new FormFieldModel(new FormModel(), {
|
widget.field = new FormFieldModel(new FormModel(), {
|
||||||
id: 'hyperlink',
|
id: 'hyperlink',
|
||||||
hyperlinkUrl: url,
|
hyperlinkUrl: url,
|
||||||
displayText: displayText,
|
displayText,
|
||||||
type: FormFieldTypes.HYPERLINK,
|
type: FormFieldTypes.HYPERLINK,
|
||||||
tooltip: 'hyperlink widget'
|
tooltip: 'hyperlink widget'
|
||||||
});
|
});
|
||||||
|
@@ -48,12 +48,8 @@ describe('PeopleWidgetComponent', () => {
|
|||||||
formService = TestBed.inject(FormService);
|
formService = TestBed.inject(FormService);
|
||||||
|
|
||||||
translationService = TestBed.inject(TranslateService);
|
translationService = TestBed.inject(TranslateService);
|
||||||
spyOn(translationService, 'instant').and.callFake((key) => {
|
spyOn(translationService, 'instant').and.callFake((key) => key);
|
||||||
return key;
|
spyOn(translationService, 'get').and.callFake((key) => of(key));
|
||||||
});
|
|
||||||
spyOn(translationService, 'get').and.callFake((key) => {
|
|
||||||
return of(key);
|
|
||||||
});
|
|
||||||
|
|
||||||
element = fixture.nativeElement;
|
element = fixture.nativeElement;
|
||||||
widget = fixture.componentInstance;
|
widget = fixture.componentInstance;
|
||||||
@@ -193,7 +189,7 @@ describe('PeopleWidgetComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should show an error message if the user is invalid', async () => {
|
it('should show an error message if the user is invalid', async () => {
|
||||||
const peopleHTMLElement: HTMLInputElement = <HTMLInputElement> element.querySelector('input');
|
const peopleHTMLElement = element.querySelector<HTMLInputElement>('input');
|
||||||
peopleHTMLElement.focus();
|
peopleHTMLElement.focus();
|
||||||
peopleHTMLElement.value = 'K';
|
peopleHTMLElement.value = 'K';
|
||||||
peopleHTMLElement.dispatchEvent(new Event('keyup'));
|
peopleHTMLElement.dispatchEvent(new Event('keyup'));
|
||||||
@@ -207,7 +203,7 @@ describe('PeopleWidgetComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should show the people if the typed result match', async () => {
|
it('should show the people if the typed result match', async () => {
|
||||||
const peopleHTMLElement: HTMLInputElement = <HTMLInputElement> element.querySelector('input');
|
const peopleHTMLElement = element.querySelector<HTMLInputElement>('input');
|
||||||
peopleHTMLElement.focus();
|
peopleHTMLElement.focus();
|
||||||
peopleHTMLElement.value = 'T';
|
peopleHTMLElement.value = 'T';
|
||||||
peopleHTMLElement.dispatchEvent(new Event('keyup'));
|
peopleHTMLElement.dispatchEvent(new Event('keyup'));
|
||||||
@@ -221,7 +217,7 @@ describe('PeopleWidgetComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should hide result list if input is empty', async () => {
|
it('should hide result list if input is empty', async () => {
|
||||||
const peopleHTMLElement: HTMLInputElement = <HTMLInputElement> element.querySelector('input');
|
const peopleHTMLElement = element.querySelector<HTMLInputElement>('input');
|
||||||
peopleHTMLElement.focus();
|
peopleHTMLElement.focus();
|
||||||
peopleHTMLElement.value = '';
|
peopleHTMLElement.value = '';
|
||||||
peopleHTMLElement.dispatchEvent(new Event('keyup'));
|
peopleHTMLElement.dispatchEvent(new Event('keyup'));
|
||||||
@@ -238,7 +234,7 @@ describe('PeopleWidgetComponent', () => {
|
|||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
await fixture.whenStable();
|
await fixture.whenStable();
|
||||||
|
|
||||||
const peopleHTMLElement: HTMLInputElement = <HTMLInputElement> element.querySelector('input');
|
const peopleHTMLElement = element.querySelector<HTMLInputElement>('input');
|
||||||
peopleHTMLElement.focus();
|
peopleHTMLElement.focus();
|
||||||
peopleHTMLElement.value = 'T';
|
peopleHTMLElement.value = 'T';
|
||||||
peopleHTMLElement.dispatchEvent(new Event('keyup'));
|
peopleHTMLElement.dispatchEvent(new Event('keyup'));
|
||||||
@@ -253,7 +249,7 @@ describe('PeopleWidgetComponent', () => {
|
|||||||
|
|
||||||
it('should emit peopleSelected if option is valid', async () => {
|
it('should emit peopleSelected if option is valid', async () => {
|
||||||
const selectEmitSpy = spyOn(widget.peopleSelected, 'emit');
|
const selectEmitSpy = spyOn(widget.peopleSelected, 'emit');
|
||||||
const peopleHTMLElement: HTMLInputElement = <HTMLInputElement> element.querySelector('input');
|
const peopleHTMLElement = element.querySelector<HTMLInputElement>('input');
|
||||||
peopleHTMLElement.focus();
|
peopleHTMLElement.focus();
|
||||||
peopleHTMLElement.value = 'Test01 Test01';
|
peopleHTMLElement.value = 'Test01 Test01';
|
||||||
peopleHTMLElement.dispatchEvent(new Event('keyup'));
|
peopleHTMLElement.dispatchEvent(new Event('keyup'));
|
||||||
|
@@ -21,7 +21,6 @@ import { PeopleProcessService } from '../../../../services/people-process.servic
|
|||||||
import { UserProcessModel } from '../../../../models';
|
import { UserProcessModel } from '../../../../models';
|
||||||
import { Component, ElementRef, EventEmitter, OnInit, Output, ViewChild, ViewEncapsulation } from '@angular/core';
|
import { Component, ElementRef, EventEmitter, OnInit, Output, ViewChild, ViewEncapsulation } from '@angular/core';
|
||||||
import { FormService } from '../../../services/form.service';
|
import { FormService } from '../../../services/form.service';
|
||||||
import { GroupModel } from '../core/group.model';
|
|
||||||
import { WidgetComponent } from './../widget.component';
|
import { WidgetComponent } from './../widget.component';
|
||||||
import { FormControl } from '@angular/forms';
|
import { FormControl } from '@angular/forms';
|
||||||
import { Observable, of } from 'rxjs';
|
import { Observable, of } from 'rxjs';
|
||||||
@@ -97,7 +96,7 @@ export class PeopleWidgetComponent extends WidgetComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
const params = this.field.params;
|
const params = this.field.params;
|
||||||
if (params && params.restrictWithGroup) {
|
if (params && params.restrictWithGroup) {
|
||||||
const restrictWithGroup = <GroupModel> params.restrictWithGroup;
|
const restrictWithGroup = params.restrictWithGroup;
|
||||||
this.groupId = restrictWithGroup.id;
|
this.groupId = restrictWithGroup.id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -61,7 +61,7 @@ describe('RadioButtonsWidgetComponent', () => {
|
|||||||
const fieldId = '<field-id>';
|
const fieldId = '<field-id>';
|
||||||
|
|
||||||
const form = new FormModel({
|
const form = new FormModel({
|
||||||
taskId: taskId
|
taskId
|
||||||
});
|
});
|
||||||
|
|
||||||
widget.field = new FormFieldModel(form, {
|
widget.field = new FormFieldModel(form, {
|
||||||
@@ -82,7 +82,7 @@ describe('RadioButtonsWidgetComponent', () => {
|
|||||||
const fieldId = '<field-id>';
|
const fieldId = '<field-id>';
|
||||||
|
|
||||||
const form = new FormModel({
|
const form = new FormModel({
|
||||||
taskId: taskId
|
taskId
|
||||||
});
|
});
|
||||||
|
|
||||||
widget.field = new FormFieldModel(form, {
|
widget.field = new FormFieldModel(form, {
|
||||||
@@ -105,7 +105,7 @@ describe('RadioButtonsWidgetComponent', () => {
|
|||||||
const fieldId = '<field-id>';
|
const fieldId = '<field-id>';
|
||||||
|
|
||||||
const form = new FormModel({
|
const form = new FormModel({
|
||||||
taskId: taskId
|
taskId
|
||||||
});
|
});
|
||||||
|
|
||||||
widget.field = new FormFieldModel(form, {
|
widget.field = new FormFieldModel(form, {
|
||||||
@@ -204,13 +204,13 @@ describe('RadioButtonsWidgetComponent', () => {
|
|||||||
expect(widgetLabel.innerText).toBe('radio-name-label*');
|
expect(widgetLabel.innerText).toBe('radio-name-label*');
|
||||||
expect(radioButtonWidget.field.isValid).toBe(false);
|
expect(radioButtonWidget.field.isValid).toBe(false);
|
||||||
|
|
||||||
const option: HTMLElement = <HTMLElement> element.querySelector('#radio-id-opt-1 label');
|
const option = element.querySelector<HTMLElement>('#radio-id-opt-1 label');
|
||||||
option.click();
|
option.click();
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
await fixture.whenStable();
|
await fixture.whenStable();
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
const selectedOption: HTMLElement = <HTMLElement> element.querySelector('[class*="mat-radio-checked"]');
|
const selectedOption = element.querySelector<HTMLElement>('[class*="mat-radio-checked"]');
|
||||||
expect(selectedOption.innerText).toBe('opt-name-1');
|
expect(selectedOption.innerText).toBe('opt-name-1');
|
||||||
expect(radioButtonWidget.field.isValid).toBe(true);
|
expect(radioButtonWidget.field.isValid).toBe(true);
|
||||||
});
|
});
|
||||||
@@ -229,7 +229,7 @@ describe('RadioButtonsWidgetComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
const selectedOption: HTMLElement = <HTMLElement> element.querySelector('[class*="mat-radio-checked"]');
|
const selectedOption = element.querySelector<HTMLElement>('[class*="mat-radio-checked"]');
|
||||||
expect(selectedOption.innerText).toBe('opt-name-2');
|
expect(selectedOption.innerText).toBe('opt-name-2');
|
||||||
expect(radioButtonWidget.field.isValid).toBe(true);
|
expect(radioButtonWidget.field.isValid).toBe(true);
|
||||||
});
|
});
|
||||||
@@ -281,7 +281,7 @@ describe('RadioButtonsWidgetComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should trigger field changed event on click', fakeAsync(() => {
|
it('should trigger field changed event on click', fakeAsync(() => {
|
||||||
const option: HTMLElement = <HTMLElement> element.querySelector('#radio-id-opt-1-input');
|
const option = element.querySelector<HTMLElement>('#radio-id-opt-1-input');
|
||||||
expect(element.querySelector('#radio-id')).not.toBeNull();
|
expect(element.querySelector('#radio-id')).not.toBeNull();
|
||||||
expect(option).not.toBeNull();
|
expect(option).not.toBeNull();
|
||||||
option.click();
|
option.click();
|
||||||
|
@@ -51,11 +51,11 @@ export class InputMaskDirective implements OnChanges, ControlValueAccessor {
|
|||||||
};
|
};
|
||||||
|
|
||||||
private translationMask = {
|
private translationMask = {
|
||||||
'0': { pattern: /\d/ },
|
0: { pattern: /\d/ },
|
||||||
'9': { pattern: /\d/, optional: true },
|
9: { pattern: /\d/, optional: true },
|
||||||
'#': { pattern: /\d/, recursive: true },
|
'#': { pattern: /\d/, recursive: true },
|
||||||
'A': { pattern: /[a-zA-Z0-9]/ },
|
A: { pattern: /[a-zA-Z0-9]/ },
|
||||||
'S': { pattern: /[a-zA-Z]/ }
|
S: { pattern: /[a-zA-Z]/ }
|
||||||
};
|
};
|
||||||
|
|
||||||
private byPassKeys = [9, 16, 17, 18, 36, 37, 38, 39, 40, 91];
|
private byPassKeys = [9, 16, 17, 18, 36, 37, 38, 39, 40, 91];
|
||||||
|
@@ -47,12 +47,8 @@ describe('TypeaheadWidgetComponent', () => {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
alfrescoApiService = TestBed.inject(AlfrescoApiService);
|
alfrescoApiService = TestBed.inject(AlfrescoApiService);
|
||||||
translationService = TestBed.inject(TranslateService);
|
translationService = TestBed.inject(TranslateService);
|
||||||
spyOn(translationService, 'instant').and.callFake((key) => {
|
spyOn(translationService, 'instant').and.callFake((key) => key);
|
||||||
return key;
|
spyOn(translationService, 'get').and.callFake((key) => of(key));
|
||||||
});
|
|
||||||
spyOn(translationService, 'get').and.callFake((key) => {
|
|
||||||
return of(key);
|
|
||||||
});
|
|
||||||
|
|
||||||
formService = new FormService(null, alfrescoApiService, null);
|
formService = new FormService(null, alfrescoApiService, null);
|
||||||
widget = new TypeaheadWidgetComponent(formService, null);
|
widget = new TypeaheadWidgetComponent(formService, null);
|
||||||
@@ -65,7 +61,7 @@ describe('TypeaheadWidgetComponent', () => {
|
|||||||
const fieldId = '<field-id>';
|
const fieldId = '<field-id>';
|
||||||
|
|
||||||
const form = new FormModel({
|
const form = new FormModel({
|
||||||
taskId: taskId
|
taskId
|
||||||
});
|
});
|
||||||
|
|
||||||
widget.field = new FormFieldModel(form, {
|
widget.field = new FormFieldModel(form, {
|
||||||
@@ -86,7 +82,7 @@ describe('TypeaheadWidgetComponent', () => {
|
|||||||
const fieldId = '<field-id>';
|
const fieldId = '<field-id>';
|
||||||
|
|
||||||
const form = new FormModel({
|
const form = new FormModel({
|
||||||
taskId: taskId
|
taskId
|
||||||
});
|
});
|
||||||
|
|
||||||
widget.field = new FormFieldModel(form, {
|
widget.field = new FormFieldModel(form, {
|
||||||
@@ -103,7 +99,7 @@ describe('TypeaheadWidgetComponent', () => {
|
|||||||
const fieldId = '<field-id>';
|
const fieldId = '<field-id>';
|
||||||
|
|
||||||
const form = new FormModel({
|
const form = new FormModel({
|
||||||
taskId: taskId
|
taskId
|
||||||
});
|
});
|
||||||
|
|
||||||
widget.field = new FormFieldModel(form, {
|
widget.field = new FormFieldModel(form, {
|
||||||
@@ -125,7 +121,7 @@ describe('TypeaheadWidgetComponent', () => {
|
|||||||
const fieldId = '<field-id>';
|
const fieldId = '<field-id>';
|
||||||
|
|
||||||
const form = new FormModel({
|
const form = new FormModel({
|
||||||
processDefinitionId: processDefinitionId
|
processDefinitionId
|
||||||
});
|
});
|
||||||
|
|
||||||
widget.field = new FormFieldModel(form, {
|
widget.field = new FormFieldModel(form, {
|
||||||
@@ -301,7 +297,7 @@ describe('TypeaheadWidgetComponent', () => {
|
|||||||
|
|
||||||
it('should show typeahead options', async () => {
|
it('should show typeahead options', async () => {
|
||||||
const typeaheadElement = fixture.debugElement.query(By.css('#typeahead-id'));
|
const typeaheadElement = fixture.debugElement.query(By.css('#typeahead-id'));
|
||||||
const typeaheadHTMLElement = <HTMLInputElement> typeaheadElement.nativeElement;
|
const typeaheadHTMLElement = typeaheadElement.nativeElement as HTMLInputElement;
|
||||||
typeaheadHTMLElement.focus();
|
typeaheadHTMLElement.focus();
|
||||||
typeaheadWidgetComponent.value = 'F';
|
typeaheadWidgetComponent.value = 'F';
|
||||||
typeaheadHTMLElement.value = 'F';
|
typeaheadHTMLElement.value = 'F';
|
||||||
@@ -318,7 +314,7 @@ describe('TypeaheadWidgetComponent', () => {
|
|||||||
|
|
||||||
it('should hide the option when the value is empty', async () => {
|
it('should hide the option when the value is empty', async () => {
|
||||||
const typeaheadElement = fixture.debugElement.query(By.css('#typeahead-id'));
|
const typeaheadElement = fixture.debugElement.query(By.css('#typeahead-id'));
|
||||||
const typeaheadHTMLElement = <HTMLInputElement> typeaheadElement.nativeElement;
|
const typeaheadHTMLElement = typeaheadElement.nativeElement as HTMLInputElement;
|
||||||
typeaheadHTMLElement.focus();
|
typeaheadHTMLElement.focus();
|
||||||
typeaheadWidgetComponent.value = 'F';
|
typeaheadWidgetComponent.value = 'F';
|
||||||
typeaheadHTMLElement.value = 'F';
|
typeaheadHTMLElement.value = 'F';
|
||||||
|
@@ -31,50 +31,48 @@ import { TranslateModule } from '@ngx-translate/core';
|
|||||||
import { RelatedContentRepresentation } from '@alfresco/js-api';
|
import { RelatedContentRepresentation } from '@alfresco/js-api';
|
||||||
|
|
||||||
const fakePngAnswer = new RelatedContentRepresentation({
|
const fakePngAnswer = new RelatedContentRepresentation({
|
||||||
'id': 1155,
|
id: 1155,
|
||||||
'name': 'a_png_file.png',
|
name: 'a_png_file.png',
|
||||||
'created': '2017-07-25T17:17:37.099Z',
|
created: '2017-07-25T17:17:37.099Z',
|
||||||
'createdBy': { 'id': 1001, 'firstName': 'Admin', 'lastName': 'admin', 'email': 'admin' },
|
createdBy: { id: 1001, firstName: 'Admin', lastName: 'admin', email: 'admin' },
|
||||||
'relatedContent': false,
|
relatedContent: false,
|
||||||
'contentAvailable': true,
|
contentAvailable: true,
|
||||||
'link': false,
|
link: false,
|
||||||
'mimeType': 'image/png',
|
mimeType: 'image/png',
|
||||||
'simpleType': 'image',
|
simpleType: 'image',
|
||||||
'previewStatus': 'queued',
|
previewStatus: 'queued',
|
||||||
'thumbnailStatus': 'queued'
|
thumbnailStatus: 'queued'
|
||||||
});
|
});
|
||||||
|
|
||||||
const fakeJpgAnswer = {
|
const fakeJpgAnswer = {
|
||||||
'id': 1156,
|
id: 1156,
|
||||||
'name': 'a_jpg_file.jpg',
|
name: 'a_jpg_file.jpg',
|
||||||
'created': '2017-07-25T17:17:37.118Z',
|
created: '2017-07-25T17:17:37.118Z',
|
||||||
'createdBy': { 'id': 1001, 'firstName': 'Admin', 'lastName': 'admin', 'email': 'admin' },
|
createdBy: { id: 1001, firstName: 'Admin', lastName: 'admin', email: 'admin' },
|
||||||
'relatedContent': false,
|
relatedContent: false,
|
||||||
'contentAvailable': true,
|
contentAvailable: true,
|
||||||
'link': false,
|
link: false,
|
||||||
'mimeType': 'image/jpeg',
|
mimeType: 'image/jpeg',
|
||||||
'simpleType': 'image',
|
simpleType: 'image',
|
||||||
'previewStatus': 'queued',
|
previewStatus: 'queued',
|
||||||
'thumbnailStatus': 'queued'
|
thumbnailStatus: 'queued'
|
||||||
};
|
};
|
||||||
|
|
||||||
describe('UploadWidgetComponent', () => {
|
describe('UploadWidgetComponent', () => {
|
||||||
|
|
||||||
function fakeCreationFile (name: string, id: string | number) {
|
const fakeCreationFile = (name: string, id: string | number) => ({
|
||||||
return {
|
id,
|
||||||
'id': id,
|
name,
|
||||||
'name': name,
|
created: '2017-07-25T17:17:37.118Z',
|
||||||
'created': '2017-07-25T17:17:37.118Z',
|
createdBy: { id: 1001, firstName: 'Admin', lastName: 'admin', email: 'admin' },
|
||||||
'createdBy': { 'id': 1001, 'firstName': 'Admin', 'lastName': 'admin', 'email': 'admin' },
|
relatedContent: false,
|
||||||
'relatedContent': false,
|
contentAvailable: true,
|
||||||
'contentAvailable': true,
|
link: false,
|
||||||
'link': false,
|
mimeType: 'image/jpeg',
|
||||||
'mimeType': 'image/jpeg',
|
simpleType: 'image',
|
||||||
'simpleType': 'image',
|
previewStatus: 'queued',
|
||||||
'previewStatus': 'queued',
|
thumbnailStatus: 'queued'
|
||||||
'thumbnailStatus': 'queued'
|
});
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
let contentService: ProcessContentService;
|
let contentService: ProcessContentService;
|
||||||
|
|
||||||
@@ -231,7 +229,7 @@ describe('UploadWidgetComponent', () => {
|
|||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
await fixture.whenStable();
|
await fixture.whenStable();
|
||||||
|
|
||||||
const deleteButton = <HTMLInputElement> element.querySelector('#file-1155-remove');
|
const deleteButton = element.querySelector<HTMLInputElement>('#file-1155-remove');
|
||||||
deleteButton.click();
|
deleteButton.click();
|
||||||
|
|
||||||
expect(uploadWidgetComponent.field.updateForm).toHaveBeenCalled();
|
expect(uploadWidgetComponent.field.updateForm).toHaveBeenCalled();
|
||||||
@@ -261,7 +259,7 @@ describe('UploadWidgetComponent', () => {
|
|||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
await fixture.whenStable();
|
await fixture.whenStable();
|
||||||
|
|
||||||
inputElement = <HTMLInputElement> element.querySelector('#upload-id');
|
inputElement = element.querySelector<HTMLInputElement>('#upload-id');
|
||||||
expect(inputElement).toBeDefined();
|
expect(inputElement).toBeDefined();
|
||||||
expect(inputElement).not.toBeNull();
|
expect(inputElement).not.toBeNull();
|
||||||
expect(uploadWidgetComponent.field.value).not.toBeNull();
|
expect(uploadWidgetComponent.field.value).not.toBeNull();
|
||||||
@@ -379,7 +377,7 @@ describe('UploadWidgetComponent', () => {
|
|||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
await fixture.whenStable();
|
await fixture.whenStable();
|
||||||
|
|
||||||
const buttonElement = <HTMLButtonElement> element.querySelector('#file-1156-remove');
|
const buttonElement = element.querySelector<HTMLButtonElement>('#file-1156-remove');
|
||||||
buttonElement.click();
|
buttonElement.click();
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
const jpegElement = element.querySelector('#file-1156');
|
const jpegElement = element.querySelector('#file-1156');
|
||||||
|
@@ -26,13 +26,13 @@ export class FormDefinitionModel extends FormSaveRepresentation {
|
|||||||
constructor(id: string, name: any, lastUpdatedByFullName: string, lastUpdated: string, metadata: any) {
|
constructor(id: string, name: any, lastUpdatedByFullName: string, lastUpdated: string, metadata: any) {
|
||||||
super();
|
super();
|
||||||
this.formRepresentation = {
|
this.formRepresentation = {
|
||||||
id: id,
|
id,
|
||||||
name: name,
|
name,
|
||||||
description: '',
|
description: '',
|
||||||
version: 1,
|
version: 1,
|
||||||
lastUpdatedBy: 1,
|
lastUpdatedBy: 1,
|
||||||
lastUpdatedByFullName: lastUpdatedByFullName,
|
lastUpdatedByFullName,
|
||||||
lastUpdated: lastUpdated,
|
lastUpdated,
|
||||||
stencilSetId: 0,
|
stencilSetId: 0,
|
||||||
referenceId: null,
|
referenceId: null,
|
||||||
formDefinition: {
|
formDefinition: {
|
||||||
@@ -47,7 +47,7 @@ export class FormDefinitionModel extends FormSaveRepresentation {
|
|||||||
sizeY: 1,
|
sizeY: 1,
|
||||||
row: -1,
|
row: -1,
|
||||||
col: -1,
|
col: -1,
|
||||||
fields: {'1': this.metadataToFields(metadata)}
|
fields: {1: this.metadataToFields(metadata)}
|
||||||
}],
|
}],
|
||||||
gridsterForm: false,
|
gridsterForm: false,
|
||||||
javascriptEvents: [],
|
javascriptEvents: [],
|
||||||
@@ -64,7 +64,7 @@ export class FormDefinitionModel extends FormSaveRepresentation {
|
|||||||
private metadataToFields(metadata: any): any[] {
|
private metadataToFields(metadata: any): any[] {
|
||||||
const fields = [];
|
const fields = [];
|
||||||
if (metadata) {
|
if (metadata) {
|
||||||
metadata.forEach(function(property) {
|
metadata.forEach((property) => {
|
||||||
if (property) {
|
if (property) {
|
||||||
const field = {
|
const field = {
|
||||||
type: 'text',
|
type: 'text',
|
||||||
|
@@ -100,6 +100,7 @@ export class WidgetVisibilityModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// eslint-disable-next-line no-shadow
|
||||||
export enum WidgetTypeEnum {
|
export enum WidgetTypeEnum {
|
||||||
field = 'field',
|
field = 'field',
|
||||||
variable = 'variable',
|
variable = 'variable',
|
||||||
|
@@ -72,6 +72,7 @@ export class ActivitiContentService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a list of all the repositories configured
|
* Returns a list of all the repositories configured
|
||||||
|
*
|
||||||
* @param tenantId
|
* @param tenantId
|
||||||
* @param includeAccount
|
* @param includeAccount
|
||||||
*/
|
*/
|
||||||
|
@@ -52,7 +52,7 @@ describe('EcmModelService', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||||
'status': 200,
|
status: 200,
|
||||||
contentType: 'application/json',
|
contentType: 'application/json',
|
||||||
responseText: JSON.stringify({})
|
responseText: JSON.stringify({})
|
||||||
});
|
});
|
||||||
@@ -68,7 +68,7 @@ describe('EcmModelService', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||||
'status': 200,
|
status: 200,
|
||||||
contentType: 'application/json',
|
contentType: 'application/json',
|
||||||
responseText: JSON.stringify({})
|
responseText: JSON.stringify({})
|
||||||
});
|
});
|
||||||
@@ -87,7 +87,7 @@ describe('EcmModelService', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||||
'status': 200,
|
status: 200,
|
||||||
contentType: 'application/json',
|
contentType: 'application/json',
|
||||||
responseText: JSON.stringify({})
|
responseText: JSON.stringify({})
|
||||||
});
|
});
|
||||||
@@ -107,7 +107,7 @@ describe('EcmModelService', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||||
'status': 200,
|
status: 200,
|
||||||
contentType: 'application/json',
|
contentType: 'application/json',
|
||||||
responseText: JSON.stringify({})
|
responseText: JSON.stringify({})
|
||||||
});
|
});
|
||||||
@@ -146,7 +146,7 @@ describe('EcmModelService', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||||
'status': 200,
|
status: 200,
|
||||||
contentType: 'application/json',
|
contentType: 'application/json',
|
||||||
responseText: JSON.stringify({})
|
responseText: JSON.stringify({})
|
||||||
});
|
});
|
||||||
@@ -186,7 +186,7 @@ describe('EcmModelService', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||||
'status': 200,
|
status: 200,
|
||||||
contentType: 'application/json',
|
contentType: 'application/json',
|
||||||
responseText: JSON.stringify({})
|
responseText: JSON.stringify({})
|
||||||
});
|
});
|
||||||
@@ -201,7 +201,7 @@ describe('EcmModelService', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||||
'status': 200,
|
status: 200,
|
||||||
contentType: 'application/json',
|
contentType: 'application/json',
|
||||||
responseText: JSON.stringify({})
|
responseText: JSON.stringify({})
|
||||||
});
|
});
|
||||||
@@ -216,26 +216,22 @@ describe('EcmModelService', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||||
'status': 200,
|
status: 200,
|
||||||
contentType: 'application/json',
|
contentType: 'application/json',
|
||||||
responseText: JSON.stringify({})
|
responseText: JSON.stringify({})
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Should create an ECM type with properties', (done) => {
|
it('Should create an ECM type with properties', (done) => {
|
||||||
spyOn(service, 'createEcmType').and.callFake(() => {
|
spyOn(service, 'createEcmType').and.callFake(() => new Observable((observer) => {
|
||||||
return new Observable((observer) => {
|
observer.next();
|
||||||
observer.next();
|
observer.complete();
|
||||||
observer.complete();
|
}));
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
spyOn(service, 'addPropertyToAType').and.callFake(() => {
|
spyOn(service, 'addPropertyToAType').and.callFake(() => new Observable((observer) => {
|
||||||
return new Observable((observer) => {
|
observer.next();
|
||||||
observer.next();
|
observer.complete();
|
||||||
observer.complete();
|
}));
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
service.createEcmTypeWithProperties('nameType', new FormModel()).subscribe(() => {
|
service.createEcmTypeWithProperties('nameType', new FormModel()).subscribe(() => {
|
||||||
expect(service.createEcmType).toHaveBeenCalled();
|
expect(service.createEcmType).toHaveBeenCalled();
|
||||||
@@ -245,19 +241,15 @@ describe('EcmModelService', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('Should return the already existing type', (done) => {
|
it('Should return the already existing type', (done) => {
|
||||||
spyOn(service, 'searchEcmType').and.callFake(() => {
|
spyOn(service, 'searchEcmType').and.callFake(() => new Observable((observer) => {
|
||||||
return new Observable((observer) => {
|
observer.next({test: 'I-EXIST'});
|
||||||
observer.next({test: 'I-EXIST'});
|
observer.complete();
|
||||||
observer.complete();
|
}));
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
spyOn(service, 'createEcmTypeWithProperties').and.callFake(() => {
|
spyOn(service, 'createEcmTypeWithProperties').and.callFake(() => new Observable((observer) => {
|
||||||
return new Observable((observer) => {
|
observer.next();
|
||||||
observer.next();
|
observer.complete();
|
||||||
observer.complete();
|
}));
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
service.saveFomType('nameType', new FormModel()).subscribe(() => {
|
service.saveFomType('nameType', new FormModel()).subscribe(() => {
|
||||||
expect(service.searchEcmType).toHaveBeenCalled();
|
expect(service.searchEcmType).toHaveBeenCalled();
|
||||||
@@ -267,19 +259,15 @@ describe('EcmModelService', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('Should create an ECM type with properties if the ecm Type is not defined already', (done) => {
|
it('Should create an ECM type with properties if the ecm Type is not defined already', (done) => {
|
||||||
spyOn(service, 'searchEcmType').and.callFake(() => {
|
spyOn(service, 'searchEcmType').and.callFake(() => new Observable((observer) => {
|
||||||
return new Observable((observer) => {
|
observer.next();
|
||||||
observer.next();
|
observer.complete();
|
||||||
observer.complete();
|
}));
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
spyOn(service, 'createEcmTypeWithProperties').and.callFake(() => {
|
spyOn(service, 'createEcmTypeWithProperties').and.callFake(() => new Observable((observer) => {
|
||||||
return new Observable((observer) => {
|
observer.next();
|
||||||
observer.next();
|
observer.complete();
|
||||||
observer.complete();
|
}));
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
service.saveFomType('nameType', new FormModel()).subscribe(() => {
|
service.saveFomType('nameType', new FormModel()).subscribe(() => {
|
||||||
expect(service.searchEcmType).toHaveBeenCalled();
|
expect(service.searchEcmType).toHaveBeenCalled();
|
||||||
@@ -289,19 +277,15 @@ describe('EcmModelService', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('Should create an ECM model for the activiti if not defined already', (done) => {
|
it('Should create an ECM model for the activiti if not defined already', (done) => {
|
||||||
spyOn(service, 'searchActivitiEcmModel').and.callFake(() => {
|
spyOn(service, 'searchActivitiEcmModel').and.callFake(() => new Observable((observer) => {
|
||||||
return new Observable((observer) => {
|
observer.next();
|
||||||
observer.next();
|
observer.complete();
|
||||||
observer.complete();
|
}));
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
spyOn(service, 'createActivitiEcmModel').and.callFake(() => {
|
spyOn(service, 'createActivitiEcmModel').and.callFake(() => new Observable((observer) => {
|
||||||
return new Observable((observer) => {
|
observer.next();
|
||||||
observer.next();
|
observer.complete();
|
||||||
observer.complete();
|
}));
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
service.createEcmTypeForActivitiForm('nameType', new FormModel()).subscribe(() => {
|
service.createEcmTypeForActivitiForm('nameType', new FormModel()).subscribe(() => {
|
||||||
expect(service.searchActivitiEcmModel).toHaveBeenCalled();
|
expect(service.searchActivitiEcmModel).toHaveBeenCalled();
|
||||||
@@ -311,19 +295,15 @@ describe('EcmModelService', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('If a model for the activiti is already define has to save the new type', (done) => {
|
it('If a model for the activiti is already define has to save the new type', (done) => {
|
||||||
spyOn(service, 'searchActivitiEcmModel').and.callFake(() => {
|
spyOn(service, 'searchActivitiEcmModel').and.callFake(() => new Observable((observer) => {
|
||||||
return new Observable((observer) => {
|
observer.next({test: 'I-EXIST'});
|
||||||
observer.next({test: 'I-EXIST'});
|
observer.complete();
|
||||||
observer.complete();
|
}));
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
spyOn(service, 'saveFomType').and.callFake(() => {
|
spyOn(service, 'saveFomType').and.callFake(() => new Observable((observer) => {
|
||||||
return new Observable((observer) => {
|
observer.next();
|
||||||
observer.next();
|
observer.complete();
|
||||||
observer.complete();
|
}));
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
service.createEcmTypeForActivitiForm('nameType', new FormModel()).subscribe(() => {
|
service.createEcmTypeForActivitiForm('nameType', new FormModel()).subscribe(() => {
|
||||||
expect(service.searchActivitiEcmModel).toHaveBeenCalled();
|
expect(service.searchActivitiEcmModel).toHaveBeenCalled();
|
||||||
|
@@ -65,9 +65,7 @@ export class EcmModelService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
searchActivitiEcmModel() {
|
searchActivitiEcmModel() {
|
||||||
return this.getEcmModels().pipe(map(function (ecmModels: any) {
|
return this.getEcmModels().pipe(map((ecmModels: any) => ecmModels.list.entries.find((model) => model.entry.name === EcmModelService.MODEL_NAME)));
|
||||||
return ecmModels.list.entries.find((model) => model.entry.name === EcmModelService.MODEL_NAME);
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
createActivitiEcmModel(formName: string, form: FormModel): Observable<any> {
|
createActivitiEcmModel(formName: string, form: FormModel): Observable<any> {
|
||||||
@@ -129,9 +127,8 @@ export class EcmModelService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public searchEcmType(typeName: string, modelName: string): Observable<any> {
|
public searchEcmType(typeName: string, modelName: string): Observable<any> {
|
||||||
return this.getEcmType(modelName).pipe(map(function (customTypes: any) {
|
return this.getEcmType(modelName).pipe(map((customTypes: any) =>
|
||||||
return customTypes.list.entries.find((type) => type.entry.prefixedName === typeName || type.entry.title === typeName);
|
customTypes.list.entries.find((type) => type.entry.prefixedName === typeName || type.entry.title === typeName)));
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public activeEcmModel(modelName: string): Observable<any> {
|
public activeEcmModel(modelName: string): Observable<any> {
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user