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