mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-12 17:04:57 +00:00
Improved ESLint configuration, integrated spellcheck and error fixes (#8931)
* integrate cspell with eslint, improved configuration * core: fix linting errors * core: fix lint warnings * content: lint fixes * process service lint fixes * lint: process services cloud * lint: insights * lint: extensions * [ci:force] lint: cli fixes * [ci:force] comment out dead code * [ci:force] exclude dead code * fix code and tests * rollback some changes * fix testing lib * fix demo shell * minor lint warning fixes * minor lint fixes * fix process services
This commit is contained in:
parent
8370a3de66
commit
ef551a9c71
21
.eslintrc.js
21
.eslintrc.js
@ -1,4 +1,3 @@
|
|||||||
path = require('path');
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
root: true,
|
root: true,
|
||||||
ignorePatterns: [
|
ignorePatterns: [
|
||||||
@ -11,20 +10,36 @@ module.exports = {
|
|||||||
'**/scripts',
|
'**/scripts',
|
||||||
'**/docs'
|
'**/docs'
|
||||||
],
|
],
|
||||||
|
plugins: ['@nrwl/nx'],
|
||||||
overrides: [
|
overrides: [
|
||||||
{
|
{
|
||||||
files: ['*.ts'],
|
files: ['*.ts'],
|
||||||
parserOptions: {
|
parserOptions: {
|
||||||
project: [path.join(__dirname, 'tsconfig.json'), path.join(__dirname, 'e2e/tsconfig.e2e.json')],
|
project: ['tsconfig.json', 'e2e/tsconfig.e2e.json'],
|
||||||
createDefaultProgram: true
|
createDefaultProgram: true
|
||||||
},
|
},
|
||||||
extends: [
|
extends: [
|
||||||
|
'plugin:@nrwl/nx/typescript',
|
||||||
|
'plugin:@nrwl/nx/angular',
|
||||||
|
'plugin:@cspell/recommended',
|
||||||
'plugin:@angular-eslint/ng-cli-compat',
|
'plugin:@angular-eslint/ng-cli-compat',
|
||||||
'plugin:@angular-eslint/ng-cli-compat--formatting-add-on',
|
'plugin:@angular-eslint/ng-cli-compat--formatting-add-on',
|
||||||
'plugin:@angular-eslint/template/process-inline-templates'
|
'plugin:@angular-eslint/template/process-inline-templates'
|
||||||
],
|
],
|
||||||
plugins: ['eslint-plugin-unicorn', 'eslint-plugin-rxjs', 'ban', 'license-header'],
|
plugins: [
|
||||||
|
'eslint-plugin-unicorn',
|
||||||
|
'eslint-plugin-rxjs',
|
||||||
|
'prettier',
|
||||||
|
'ban',
|
||||||
|
'license-header',
|
||||||
|
'@cspell',
|
||||||
|
'eslint-plugin-import',
|
||||||
|
'@angular-eslint/eslint-plugin',
|
||||||
|
'@typescript-eslint'
|
||||||
|
],
|
||||||
rules: {
|
rules: {
|
||||||
|
// Uncomment this to enable prettier checks as part of the ESLint
|
||||||
|
// 'prettier/prettier': 'error',
|
||||||
'ban/ban': [
|
'ban/ban': [
|
||||||
'error',
|
'error',
|
||||||
{ name: 'eval', message: 'Calls to eval is not allowed.' },
|
{ name: 'eval', message: 'Calls to eval is not allowed.' },
|
||||||
|
81
angular.json
81
angular.json
@ -210,16 +210,6 @@
|
|||||||
"demo-shell/**/*.html"
|
"demo-shell/**/*.html"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
|
||||||
"spellcheck": {
|
|
||||||
"executor": "nx:run-commands",
|
|
||||||
"options": {
|
|
||||||
"commands": [
|
|
||||||
{
|
|
||||||
"command": "npx cspell 'demo-shell/**/*.ts'"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -346,16 +336,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"spellcheck": {
|
|
||||||
"executor": "nx:run-commands",
|
|
||||||
"options": {
|
|
||||||
"commands": [
|
|
||||||
{
|
|
||||||
"command": "npx cspell 'lib/core/**/*.ts'"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"stylelint": {
|
"stylelint": {
|
||||||
"executor": "nx:run-commands",
|
"executor": "nx:run-commands",
|
||||||
"options": {
|
"options": {
|
||||||
@ -484,16 +464,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"spellcheck": {
|
|
||||||
"executor": "nx:run-commands",
|
|
||||||
"options": {
|
|
||||||
"commands": [
|
|
||||||
{
|
|
||||||
"command": "npx cspell 'lib/content-services/**/*.ts'"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"stylelint": {
|
"stylelint": {
|
||||||
"executor": "nx:run-commands",
|
"executor": "nx:run-commands",
|
||||||
"options": {
|
"options": {
|
||||||
@ -560,26 +530,6 @@
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"spellcheck": {
|
|
||||||
"executor": "nx:run-commands",
|
|
||||||
"options": {
|
|
||||||
"commands": [
|
|
||||||
{
|
|
||||||
"command": "npx cspell 'lib/process-services/**/*.ts'"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"stylelint": {
|
|
||||||
"executor": "nx:run-commands",
|
|
||||||
"options": {
|
|
||||||
"commands": [
|
|
||||||
{
|
|
||||||
"command": "npx stylelint lib/process-services/**/*.scss --config stylelint-config.json"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"stylelint": {
|
"stylelint": {
|
||||||
"executor": "nx:run-commands",
|
"executor": "nx:run-commands",
|
||||||
"options": {
|
"options": {
|
||||||
@ -699,16 +649,6 @@
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"spellcheck": {
|
|
||||||
"executor": "nx:run-commands",
|
|
||||||
"options": {
|
|
||||||
"commands": [
|
|
||||||
{
|
|
||||||
"command": "npx cspell 'lib/process-services-cloud/**/*.ts'"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"stylelint": {
|
"stylelint": {
|
||||||
"executor": "nx:run-commands",
|
"executor": "nx:run-commands",
|
||||||
"options": {
|
"options": {
|
||||||
@ -775,16 +715,6 @@
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"spellcheck": {
|
|
||||||
"executor": "nx:run-commands",
|
|
||||||
"options": {
|
|
||||||
"commands": [
|
|
||||||
{
|
|
||||||
"command": "npx cspell 'lib/insights/**/*.ts'"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"stylelint": {
|
"stylelint": {
|
||||||
"executor": "nx:run-commands",
|
"executor": "nx:run-commands",
|
||||||
"options": {
|
"options": {
|
||||||
@ -848,17 +778,6 @@
|
|||||||
"lib/extensions/**/*.ts",
|
"lib/extensions/**/*.ts",
|
||||||
"lib/extensions/**/*.html"
|
"lib/extensions/**/*.html"
|
||||||
]
|
]
|
||||||
},
|
|
||||||
"dependsOn": ["spellcheck"]
|
|
||||||
},
|
|
||||||
"spellcheck": {
|
|
||||||
"executor": "nx:run-commands",
|
|
||||||
"options": {
|
|
||||||
"commands": [
|
|
||||||
{
|
|
||||||
"command": "npx cspell 'lib/extensions/**/*.ts'"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"npm-publish": {
|
"npm-publish": {
|
||||||
|
@ -139,7 +139,8 @@
|
|||||||
"webscript",
|
"webscript",
|
||||||
"Whitespaces",
|
"Whitespaces",
|
||||||
"xdescribe",
|
"xdescribe",
|
||||||
"xsrf"
|
"xsrf",
|
||||||
|
"Undeployed"
|
||||||
],
|
],
|
||||||
"dictionaries": [
|
"dictionaries": [
|
||||||
"html",
|
"html",
|
||||||
|
@ -53,7 +53,7 @@ export class CloudFiltersDemoComponent implements OnInit {
|
|||||||
this.currentProcessFilter$ = this.cloudLayoutService.processFilter$;
|
this.currentProcessFilter$ = this.cloudLayoutService.processFilter$;
|
||||||
|
|
||||||
let root = '';
|
let root = '';
|
||||||
if (this.route.snapshot && this.route.snapshot.firstChild) {
|
if (this.route.snapshot?.firstChild) {
|
||||||
root = this.route.snapshot.firstChild.url[0].path;
|
root = this.route.snapshot.firstChild.url[0].path;
|
||||||
if (root === 'tasks') {
|
if (root === 'tasks') {
|
||||||
this.expandTaskFilter = true;
|
this.expandTaskFilter = true;
|
||||||
|
@ -41,7 +41,7 @@ export class CloudLayoutComponent implements OnInit {
|
|||||||
this.appName = params.appName;
|
this.appName = params.appName;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (this.route.snapshot && this.route.snapshot.firstChild) {
|
if (this.route.snapshot?.firstChild) {
|
||||||
root = this.route.snapshot.firstChild.url[0].path;
|
root = this.route.snapshot.firstChild.url[0].path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,7 +185,7 @@ export class ProcessesCloudDemoComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private loadFilter(model: ProcessFilterCloudModel) {
|
private loadFilter(model: ProcessFilterCloudModel) {
|
||||||
if (model && model.appName && model.id) {
|
if (model?.appName && model.id) {
|
||||||
this.editedFilter = model;
|
this.editedFilter = model;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,7 @@ export class FileViewComponent implements OnInit {
|
|||||||
if (id) {
|
if (id) {
|
||||||
this.nodeApiService.getNode(id).subscribe(
|
this.nodeApiService.getNode(id).subscribe(
|
||||||
(node) => {
|
(node) => {
|
||||||
if (node && node.isFile) {
|
if (node?.isFile) {
|
||||||
this.isCommentEnabled = this.contentServices.hasPermissions(node, PermissionsEnum.NOT_CONSUMER) ||
|
this.isCommentEnabled = this.contentServices.hasPermissions(node, PermissionsEnum.NOT_CONSUMER) ||
|
||||||
this.contentServices.hasAllowableOperations(node, AllowableOperationsEnum.UPDATE);
|
this.contentServices.hasAllowableOperations(node, AllowableOperationsEnum.UPDATE);
|
||||||
this.nodeId = id;
|
this.nodeId = id;
|
||||||
|
@ -231,7 +231,7 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
|
|
||||||
showFile(event) {
|
showFile(event) {
|
||||||
const entry = event.value.entry;
|
const entry = event.value.entry;
|
||||||
if (entry && entry.isFile) {
|
if (entry?.isFile) {
|
||||||
this.preview.showResource(entry.id);
|
this.preview.showResource(entry.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -296,7 +296,7 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnChanges(changes: SimpleChanges) {
|
ngOnChanges(changes: SimpleChanges) {
|
||||||
if (changes.nodeResult && changes.nodeResult.currentValue) {
|
if (changes.nodeResult?.currentValue) {
|
||||||
this.nodeResult = changes.nodeResult.currentValue;
|
this.nodeResult = changes.nodeResult.currentValue;
|
||||||
this.pagination = this.nodeResult.list.pagination;
|
this.pagination = this.nodeResult.list.pagination;
|
||||||
}
|
}
|
||||||
@ -468,7 +468,7 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
if (selection && selection.length === 1) {
|
if (selection && selection.length === 1) {
|
||||||
const entry = selection[0].entry;
|
const entry = selection[0].entry;
|
||||||
|
|
||||||
if (entry && entry.isFolder) {
|
if (entry?.isFolder) {
|
||||||
return this.contentService.hasAllowableOperations(entry, 'update');
|
return this.contentService.hasAllowableOperations(entry, 'update');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -570,7 +570,7 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
searchResultsHighlight(search: SearchEntry): string {
|
searchResultsHighlight(search: SearchEntry): string {
|
||||||
if (search && search.highlight) {
|
if (search?.highlight) {
|
||||||
return search.highlight.map((currentHighlight) => currentHighlight.snippets).join(', ');
|
return search.highlight.map((currentHighlight) => currentHighlight.snippets).join(', ');
|
||||||
}
|
}
|
||||||
return '';
|
return '';
|
||||||
@ -588,7 +588,7 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
const objectFromMap = {};
|
const objectFromMap = {};
|
||||||
activeFilters.forEach((filter: FilterSearch) => {
|
activeFilters.forEach((filter: FilterSearch) => {
|
||||||
let paramValue = null;
|
let paramValue = null;
|
||||||
if (filter.value && filter.value.from && filter.value.to) {
|
if (filter.value?.from && filter.value.to) {
|
||||||
paramValue = `${filter.value.from}||${filter.value.to}`;
|
paramValue = `${filter.value.from}||${filter.value.to}`;
|
||||||
} else {
|
} else {
|
||||||
paramValue = filter.value;
|
paramValue = filter.value;
|
||||||
|
@ -41,9 +41,9 @@ export class VersionManagerDialogAdapterComponent {
|
|||||||
private containingDialog?: MatDialogRef<VersionManagerDialogAdapterComponent>
|
private containingDialog?: MatDialogRef<VersionManagerDialogAdapterComponent>
|
||||||
) {
|
) {
|
||||||
this.contentEntry = data.contentEntry;
|
this.contentEntry = data.contentEntry;
|
||||||
this.newFileVersion = data.hasOwnProperty('newFileVersion') ? data.newFileVersion : this.newFileVersion;
|
this.newFileVersion = Object.prototype.hasOwnProperty.call(data, 'newFileVersion') ? data.newFileVersion : this.newFileVersion;
|
||||||
this.showComments = data.hasOwnProperty('showComments') ? data.showComments : this.showComments;
|
this.showComments = Object.prototype.hasOwnProperty.call(data, 'showComments') ? data.showComments : this.showComments;
|
||||||
this.allowDownload = data.hasOwnProperty('allowDownload') ? data.allowDownload : this.allowDownload;
|
this.allowDownload = Object.prototype.hasOwnProperty.call(data, 'allowDownload') ? data.allowDownload : this.allowDownload;
|
||||||
}
|
}
|
||||||
|
|
||||||
uploadError(event: FileUploadErrorEvent) {
|
uploadError(event: FileUploadErrorEvent) {
|
||||||
|
@ -124,7 +124,7 @@ export class ProcessListDemoComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
isFormValid() {
|
isFormValid() {
|
||||||
return this.processListForm && this.processListForm.dirty && this.processListForm.valid;
|
return this.processListForm?.dirty && this.processListForm.valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
resetProcessForm() {
|
resetProcessForm() {
|
||||||
|
@ -93,7 +93,7 @@ export class ProcessAttachmentsComponent implements OnInit, OnChanges, OnDestroy
|
|||||||
}
|
}
|
||||||
|
|
||||||
isCompletedProcess(): boolean {
|
isCompletedProcess(): boolean {
|
||||||
return this.processInstance && this.processInstance.ended !== undefined && this.processInstance.ended !== null;
|
return this.processInstance?.ended != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -180,7 +180,7 @@ export class ProcessServiceComponent implements AfterViewInit, OnDestroy, OnInit
|
|||||||
.subscribe(
|
.subscribe(
|
||||||
(validateDynamicTableRowEvent: ValidateDynamicTableRowEvent) => {
|
(validateDynamicTableRowEvent: ValidateDynamicTableRowEvent) => {
|
||||||
const row: DynamicTableRow = validateDynamicTableRowEvent.row;
|
const row: DynamicTableRow = validateDynamicTableRowEvent.row;
|
||||||
if (row && row.value && row.value.name === 'admin') {
|
if (row?.value && row.value.name === 'admin') {
|
||||||
validateDynamicTableRowEvent.summary.isValid = false;
|
validateDynamicTableRowEvent.summary.isValid = false;
|
||||||
validateDynamicTableRowEvent.summary.message = 'Sorry, wrong value. You cannot use "admin".';
|
validateDynamicTableRowEvent.summary.message = 'Sorry, wrong value. You cannot use "admin".';
|
||||||
validateDynamicTableRowEvent.preventDefault();
|
validateDynamicTableRowEvent.preventDefault();
|
||||||
|
@ -92,7 +92,7 @@ export class TaskAttachmentsComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
isCompletedTask(): boolean {
|
isCompletedTask(): boolean {
|
||||||
return this.taskDetails && this.taskDetails.endDate !== undefined && this.taskDetails.endDate !== null;
|
return this.taskDetails?.endDate != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ export class SearchFilterChipsComponent implements OnInit, OnDestroy {
|
|||||||
.pipe(takeUntil(this.onDestroy$))
|
.pipe(takeUntil(this.onDestroy$))
|
||||||
.subscribe(([params, searchConfig]) => {
|
.subscribe(([params, searchConfig]) => {
|
||||||
this.updateSearchSetting(searchConfig);
|
this.updateSearchSetting(searchConfig);
|
||||||
this.searchedWord = params.hasOwnProperty(this.queryParamName) ? params[this.queryParamName] : null;
|
this.searchedWord = Object.prototype.hasOwnProperty.call(params, this.queryParamName) ? params[this.queryParamName] : null;
|
||||||
const query = this.formatSearchQuery(this.searchedWord, searchConfig['app:fields']);
|
const query = this.formatSearchQuery(this.searchedWord, searchConfig['app:fields']);
|
||||||
if (query) {
|
if (query) {
|
||||||
this.queryBuilder.userQuery = query;
|
this.queryBuilder.userQuery = query;
|
||||||
@ -87,7 +87,7 @@ export class SearchFilterChipsComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
if (this.route) {
|
if (this.route) {
|
||||||
this.route.params.forEach((params: Params) => {
|
this.route.params.forEach((params: Params) => {
|
||||||
this.searchedWord = params.hasOwnProperty(this.queryParamName) ? params[this.queryParamName] : null;
|
this.searchedWord = Object.prototype.hasOwnProperty.call(params, this.queryParamName) ? params[this.queryParamName] : null;
|
||||||
if (this.searchedWord) {
|
if (this.searchedWord) {
|
||||||
this.queryBuilder.update();
|
this.queryBuilder.update();
|
||||||
} else {
|
} else {
|
||||||
|
@ -50,7 +50,7 @@ export class SearchResultComponent implements OnInit, OnDestroy {
|
|||||||
combineLatest([this.route.params, this.queryBuilder.configUpdated])
|
combineLatest([this.route.params, this.queryBuilder.configUpdated])
|
||||||
.pipe(takeUntil(this.onDestroy$))
|
.pipe(takeUntil(this.onDestroy$))
|
||||||
.subscribe(([params, searchConfig]) => {
|
.subscribe(([params, searchConfig]) => {
|
||||||
this.searchedWord = params.hasOwnProperty(this.queryParamName) ? params[this.queryParamName] : null;
|
this.searchedWord = Object.prototype.hasOwnProperty.call(params, this.queryParamName) ? params[this.queryParamName] : null;
|
||||||
const query = this.formatSearchQuery(this.searchedWord, searchConfig['app:fields']);
|
const query = this.formatSearchQuery(this.searchedWord, searchConfig['app:fields']);
|
||||||
if (query) {
|
if (query) {
|
||||||
this.queryBuilder.userQuery = query;
|
this.queryBuilder.userQuery = query;
|
||||||
@ -86,7 +86,7 @@ export class SearchResultComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
if (this.route) {
|
if (this.route) {
|
||||||
this.route.params.forEach((params: Params) => {
|
this.route.params.forEach((params: Params) => {
|
||||||
this.searchedWord = params.hasOwnProperty(this.queryParamName) ? params[this.queryParamName] : null;
|
this.searchedWord = Object.prototype.hasOwnProperty.call(params, this.queryParamName) ? params[this.queryParamName] : null;
|
||||||
if (this.searchedWord) {
|
if (this.searchedWord) {
|
||||||
this.queryBuilder.update();
|
this.queryBuilder.update();
|
||||||
} else {
|
} else {
|
||||||
|
@ -21,7 +21,7 @@ import { AppConfigService, AppConfigValues, StorageService, AlfrescoApiService,
|
|||||||
import { ENTER } from '@angular/cdk/keycodes';
|
import { ENTER } from '@angular/cdk/keycodes';
|
||||||
import { MAT_FORM_FIELD_DEFAULT_OPTIONS } from '@angular/material/form-field';
|
import { MAT_FORM_FIELD_DEFAULT_OPTIONS } from '@angular/material/form-field';
|
||||||
|
|
||||||
export const HOST_REGEX = '^(http|https):\/\/.*[^/]$';
|
export const HOST_REGEX = '^(http|https)://.*[^/]$';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
providers: [{ provide: MAT_FORM_FIELD_DEFAULT_OPTIONS, useValue: { floatLabel: 'always' } }],
|
providers: [{ provide: MAT_FORM_FIELD_DEFAULT_OPTIONS, useValue: { floatLabel: 'always' } }],
|
||||||
|
@ -190,7 +190,7 @@ export class TaskListDemoComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
isFormValid() {
|
isFormValid() {
|
||||||
return this.taskListForm && this.taskListForm.dirty && this.taskListForm.valid;
|
return this.taskListForm?.dirty && this.taskListForm.valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
private getControl<T extends AbstractControl>(key: string): T {
|
private getControl<T extends AbstractControl>(key: string): T {
|
||||||
|
@ -15,9 +15,9 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { AlfrescoApi, NodesApi, UploadApi } from '@alfresco/js-api';
|
import { AlfrescoApi /*, NodesApi, UploadApi*/ } from '@alfresco/js-api';
|
||||||
import { argv, exit } from 'node:process';
|
import { argv, exit } from 'node:process';
|
||||||
import { Buffer } from 'node:buffer';
|
// import { Buffer } from 'node:buffer';
|
||||||
const program = require('commander');
|
const program = require('commander');
|
||||||
import { logger } from './logger';
|
import { logger } from './logger';
|
||||||
const MAX_RETRY = 3;
|
const MAX_RETRY = 3;
|
||||||
@ -71,7 +71,8 @@ async function checkEnv() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// @ts-ignore
|
// TODO: https://alfresco.atlassian.net/browse/ACS-5873
|
||||||
|
/*
|
||||||
async function checkDiskSpaceFullEnv() {
|
async function checkDiskSpaceFullEnv() {
|
||||||
logger.info(`Start Check disk full space`);
|
logger.info(`Start Check disk full space`);
|
||||||
|
|
||||||
@ -108,6 +109,7 @@ async function checkDiskSpaceFullEnv() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
function sleep(delay: number) {
|
function sleep(delay: number) {
|
||||||
const start = new Date().getTime();
|
const start = new Date().getTime();
|
||||||
|
@ -497,7 +497,7 @@ async function checkDescriptorExist(name: string): Promise<boolean> {
|
|||||||
logger.info(`Check descriptor ${name} exist in the list `);
|
logger.info(`Check descriptor ${name} exist in the list `);
|
||||||
const descriptorList = await getDescriptors();
|
const descriptorList = await getDescriptors();
|
||||||
|
|
||||||
if (descriptorList && descriptorList.list && descriptorList.entries) {
|
if (descriptorList?.list && descriptorList.entries) {
|
||||||
for (const descriptor of descriptorList.list.entries) {
|
for (const descriptor of descriptorList.list.entries) {
|
||||||
if (descriptor.entry.name === name) {
|
if (descriptor.entry.name === name) {
|
||||||
if (descriptor.entry.deployed === false) {
|
if (descriptor.entry.deployed === false) {
|
||||||
|
@ -56,27 +56,32 @@ async function initializeDefaultFiles() {
|
|||||||
for (let j = 0; j < ACS_DEFAULT.files.length; j++) {
|
for (let j = 0; j < ACS_DEFAULT.files.length; j++) {
|
||||||
const fileInfo = ACS_DEFAULT.files[j];
|
const fileInfo = ACS_DEFAULT.files[j];
|
||||||
switch (fileInfo.action) {
|
switch (fileInfo.action) {
|
||||||
case 'UPLOAD':
|
case 'UPLOAD': {
|
||||||
await uploadFile(fileInfo.name, parentFolderId);
|
await uploadFile(fileInfo.name, parentFolderId);
|
||||||
break;
|
break;
|
||||||
case 'LOCK':
|
}
|
||||||
|
case 'LOCK': {
|
||||||
const fileToLock = await uploadFile(fileInfo.name, parentFolderId);
|
const fileToLock = await uploadFile(fileInfo.name, parentFolderId);
|
||||||
await lockFile(fileToLock.entry.id);
|
await lockFile(fileToLock.entry.id);
|
||||||
break;
|
break;
|
||||||
case 'SHARE':
|
}
|
||||||
|
case 'SHARE': {
|
||||||
const fileToShare = await uploadFile(fileInfo.name, parentFolderId);
|
const fileToShare = await uploadFile(fileInfo.name, parentFolderId);
|
||||||
await shareFile(fileToShare.entry.id);
|
await shareFile(fileToShare.entry.id);
|
||||||
break;
|
break;
|
||||||
case 'FAVORITE':
|
}
|
||||||
|
case 'FAVORITE': {
|
||||||
const fileToFav = await uploadFile(fileInfo.name, parentFolderId);
|
const fileToFav = await uploadFile(fileInfo.name, parentFolderId);
|
||||||
await favoriteFile(fileToFav.entry.id);
|
await favoriteFile(fileToFav.entry.id);
|
||||||
break;
|
break;
|
||||||
default:
|
}
|
||||||
|
default: {
|
||||||
logger.error('No action found for file ', fileInfo.name, parentFolderId);
|
logger.error('No action found for file ', fileInfo.name, parentFolderId);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function createFolder(folderName: string, parentId: string) {
|
async function createFolder(folderName: string, parentId: string) {
|
||||||
let createdFolder: NodeEntry;
|
let createdFolder: NodeEntry;
|
||||||
|
@ -117,8 +117,8 @@ async function main() {
|
|||||||
async function initializeDefaultApps() {
|
async function initializeDefaultApps() {
|
||||||
for (let x = 0; x < ACTIVITI_APPS.apps.length; x++) {
|
for (let x = 0; x < ACTIVITI_APPS.apps.length; x++) {
|
||||||
const appInfo = ACTIVITI_APPS.apps[x];
|
const appInfo = ACTIVITI_APPS.apps[x];
|
||||||
const isDefaultAppDepl = await isDefaultAppDeployed(appInfo.name);
|
const isDeployed = await isDefaultAppDeployed(appInfo.name);
|
||||||
if (isDefaultAppDepl !== undefined && !isDefaultAppDepl) {
|
if (isDeployed !== undefined && !isDeployed) {
|
||||||
const appDefinition = await importPublishApp(`${appInfo.name}`);
|
const appDefinition = await importPublishApp(`${appInfo.name}`);
|
||||||
await deployApp(appDefinition.appDefinition.id);
|
await deployApp(appDefinition.appDefinition.id);
|
||||||
} else {
|
} else {
|
||||||
@ -248,7 +248,7 @@ async function isDefaultAppDeployed(appName: string) {
|
|||||||
try {
|
try {
|
||||||
const runtimeAppDefinitionsApi = new RuntimeAppDefinitionsApi(alfrescoJsApi);
|
const runtimeAppDefinitionsApi = new RuntimeAppDefinitionsApi(alfrescoJsApi);
|
||||||
const availableApps = await runtimeAppDefinitionsApi.getAppDefinitions();
|
const availableApps = await runtimeAppDefinitionsApi.getAppDefinitions();
|
||||||
const defaultApp = availableApps.data && availableApps.data.filter(app => app.name && app.name.includes(appName));
|
const defaultApp = availableApps.data?.filter(app => app.name?.includes(appName));
|
||||||
return defaultApp && defaultApp.length > 0;
|
return defaultApp && defaultApp.length > 0;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error(`Aps app failed to import/Publish!`);
|
logger.error(`Aps app failed to import/Publish!`);
|
||||||
@ -262,8 +262,8 @@ async function importPublishApp(appName: string) {
|
|||||||
const fileContent = createReadStream(pathFile);
|
const fileContent = createReadStream(pathFile);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const appdefinitionsApi = new AppDefinitionsApi(alfrescoJsApi);
|
const appDefinitionsApi = new AppDefinitionsApi(alfrescoJsApi);
|
||||||
const result = await appdefinitionsApi.importAndPublishApp(fileContent, {renewIdmEntries: true});
|
const result = await appDefinitionsApi.importAndPublishApp(fileContent, {renewIdmEntries: true});
|
||||||
logger.info(`Aps app imported and published!`);
|
logger.info(`Aps app imported and published!`);
|
||||||
return result;
|
return result;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -398,7 +398,7 @@ async function authorizeUserToContentRepo(user: any) {
|
|||||||
['application/json'],
|
['application/json'],
|
||||||
['application/json']
|
['application/json']
|
||||||
);
|
);
|
||||||
logger.info(`Found ${content.data && content.data.length} contents`);
|
logger.info(`Found ${content.data?.length} contents`);
|
||||||
if (content.data) {
|
if (content.data) {
|
||||||
for (let i = 0; i < content.data.length; i++) {
|
for (let i = 0; i < content.data.length; i++) {
|
||||||
if (content.data[i].authenticationType === 'basic') {
|
if (content.data[i].authenticationType === 'basic') {
|
||||||
|
@ -63,6 +63,7 @@ export const deletePod = (args: KubeArgs) => {
|
|||||||
export const getNamespaces = (): string[] => {
|
export const getNamespaces = (): string[] => {
|
||||||
logger.info('Perform get namespaces name...');
|
logger.info('Perform get namespaces name...');
|
||||||
const result = exec('kubectl', [`get`, `namespaces`, `-l`, `type=application`, `-o`, `name`], {});
|
const result = exec('kubectl', [`get`, `namespaces`, `-l`, `type=application`, `-o`, `name`], {});
|
||||||
|
// eslint-disable-next-line no-useless-escape
|
||||||
const namespaces = result.replace(/namespace[\/]+/g, '').split(/\r?\n/);
|
const namespaces = result.replace(/namespace[\/]+/g, '').split(/\r?\n/);
|
||||||
logger.info(`namespaces found: ${namespaces}`);
|
logger.info(`namespaces found: ${namespaces}`);
|
||||||
return namespaces;
|
return namespaces;
|
||||||
|
@ -51,12 +51,12 @@ const missingRepositories = {
|
|||||||
function licenseWithMDLinks(licenseExp: string): string {
|
function licenseWithMDLinks(licenseExp: string): string {
|
||||||
let licenseUrl = '';
|
let licenseUrl = '';
|
||||||
|
|
||||||
if (licenseList[licenseExp] && licenseList[licenseExp]['url']) {
|
if (licenseList[licenseExp]?.['url']) {
|
||||||
licenseUrl = licenseList[licenseExp]['url'];
|
licenseUrl = licenseList[licenseExp]['url'];
|
||||||
} else {
|
} else {
|
||||||
const substituteLicString = nonStandardLicenses[licenseExp.toLowerCase()];
|
const substituteLicString = nonStandardLicenses[licenseExp.toLowerCase()];
|
||||||
|
|
||||||
if (licenseList[substituteLicString] && licenseList[substituteLicString]['url']) {
|
if (licenseList[substituteLicString]?.['url']) {
|
||||||
licenseUrl = licenseList[substituteLicString]['url'];
|
licenseUrl = licenseList[substituteLicString]['url'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -125,7 +125,7 @@ export default function main(_args: string[], workingDir: string) {
|
|||||||
const pack = packages[packageName];
|
const pack = packages[packageName];
|
||||||
pack['licenseExp'] = pack['licenses'].toString()
|
pack['licenseExp'] = pack['licenses'].toString()
|
||||||
.replace(/\*/, '')
|
.replace(/\*/, '')
|
||||||
.replace(/[a-zA-Z0-9\-\.]+/g, (match: string) => {
|
.replace(/[a-zA-Z0-9\-.]+/g, (match: string) => {
|
||||||
const lowerMatch = match.toLowerCase();
|
const lowerMatch = match.toLowerCase();
|
||||||
|
|
||||||
if ((lowerMatch !== 'and') && (lowerMatch !== 'or') && (lowerMatch !== 'with')) {
|
if ((lowerMatch !== 'and') && (lowerMatch !== 'or') && (lowerMatch !== 'with')) {
|
||||||
|
@ -32,7 +32,7 @@ export class ProcessAutomationHealth {
|
|||||||
const url = `${this.plugInInfo.host}/${this.plugInInfo.appName}/ui/${this.plugInInfo.uiName}/app.config.json`;
|
const url = `${this.plugInInfo.host}/${this.plugInInfo.appName}/ui/${this.plugInInfo.uiName}/app.config.json`;
|
||||||
const appConfig = await this.config.getAppConfig(url);
|
const appConfig = await this.config.getAppConfig(url);
|
||||||
let isEnabled = true;
|
let isEnabled = true;
|
||||||
if (appConfig && appConfig.plugins && appConfig.plugins[this.plugInInfo.name]) {
|
if (appConfig?.plugins?.[this.plugInInfo.name]) {
|
||||||
logger.info(`The plugin ${this.plugInInfo.name} has been correctly configured in app.config.json`);
|
logger.info(`The plugin ${this.plugInInfo.name} has been correctly configured in app.config.json`);
|
||||||
} else {
|
} else {
|
||||||
this.logConfigurationError();
|
this.logConfigurationError();
|
||||||
|
@ -32,7 +32,7 @@ export class ProcessServiceHealth {
|
|||||||
const url = `${this.plugInInfo.host}/app.config.json`;
|
const url = `${this.plugInInfo.host}/app.config.json`;
|
||||||
const appConfig = await this.config.getAppConfig(url);
|
const appConfig = await this.config.getAppConfig(url);
|
||||||
let isEnabled = true;
|
let isEnabled = true;
|
||||||
if (appConfig && appConfig.plugins && appConfig.plugins[this.plugInInfo.name]) {
|
if (appConfig?.plugins?.[this.plugInInfo.name]) {
|
||||||
logger.info(`The plugin ${this.plugInInfo.name} has been correctly configured in app.config.json`);
|
logger.info(`The plugin ${this.plugInInfo.name} has been correctly configured in app.config.json`);
|
||||||
} else {
|
} else {
|
||||||
this.logConfigurationError();
|
this.logConfigurationError();
|
||||||
|
@ -38,6 +38,7 @@ function getSha(args: CommitArgs): string {
|
|||||||
function replacePerform(args: CommitArgs, sha: string) {
|
function replacePerform(args: CommitArgs, sha: string) {
|
||||||
logger.info(`Replace commit ${sha} in package...`);
|
logger.info(`Replace commit ${sha} in package...`);
|
||||||
|
|
||||||
|
// eslint-disable-next-line no-useless-escape
|
||||||
const sedRule = `s/\"commit\": \".*\"/\"commit\": \"${sha}\"/g`;
|
const sedRule = `s/\"commit\": \".*\"/\"commit\": \"${sha}\"/g`;
|
||||||
|
|
||||||
if (args.skipGnu) {
|
if (args.skipGnu) {
|
||||||
|
@ -129,9 +129,9 @@ describe('AspectListComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should show the loading spinner when result is loading', () => {
|
it('should show the loading spinner when result is loading', () => {
|
||||||
const delayReusult = of(null).pipe(delay(0));
|
const delayResult = of(null).pipe(delay(0));
|
||||||
spyOn(nodeService, 'getNode').and.returnValue(delayReusult);
|
spyOn(nodeService, 'getNode').and.returnValue(delayResult);
|
||||||
spyOn(aspectListService, 'getAspects').and.returnValue(delayReusult);
|
spyOn(aspectListService, 'getAspects').and.returnValue(delayResult);
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
const spinner = fixture.nativeElement.querySelector('#adf-aspect-spinner');
|
const spinner = fixture.nativeElement.querySelector('#adf-aspect-spinner');
|
||||||
expect(spinner).toBeDefined();
|
expect(spinner).toBeDefined();
|
||||||
|
@ -140,9 +140,9 @@ describe('CategoriesManagementComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should unassign/remove specific category after clicking at remove icon and emit categories change', () => {
|
it('should unassign/remove specific category after clicking at remove icon and emit categories change', () => {
|
||||||
const removeBtns = getRemoveCategoryButtons();
|
const removeButtons = getRemoveCategoryButtons();
|
||||||
const categoriesChangeSpy = spyOn(component.categoriesChange, 'emit');
|
const categoriesChangeSpy = spyOn(component.categoriesChange, 'emit');
|
||||||
removeBtns[0].click();
|
removeButtons[0].click();
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
@ -156,9 +156,9 @@ describe('CategoriesManagementComponent', () => {
|
|||||||
it('should disable unassigning/removing categories when disableRemoval is set', () => {
|
it('should disable unassigning/removing categories when disableRemoval is set', () => {
|
||||||
component.disableRemoval = true;
|
component.disableRemoval = true;
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
const removeBtns = getRemoveCategoryButtons();
|
const removeButtons = getRemoveCategoryButtons();
|
||||||
const allBtnsDisabled = removeBtns.every((removeBtn) => removeBtn.disabled);
|
const allButtonsDisabled = removeButtons.every((removeBtn) => removeBtn.disabled);
|
||||||
expect(allBtnsDisabled).toBeTrue();
|
expect(allButtonsDisabled).toBeTrue();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -269,8 +269,8 @@ describe('CategoriesManagementComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should have correct remove category title', () => {
|
it('should have correct remove category title', () => {
|
||||||
const removeBtns = getRemoveCategoryButtons();
|
const removeButtons = getRemoveCategoryButtons();
|
||||||
const isTitleCorrect = removeBtns.every((removeBtn) => removeBtn.attributes.getNamedItem('title').textContent === 'CATEGORIES_MANAGEMENT.UNASSIGN_CATEGORY');
|
const isTitleCorrect = removeButtons.every((removeBtn) => removeBtn.attributes.getNamedItem('title').textContent === 'CATEGORIES_MANAGEMENT.UNASSIGN_CATEGORY');
|
||||||
expect(isTitleCorrect).toBeTrue();
|
expect(isTitleCorrect).toBeTrue();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -329,8 +329,8 @@ describe('CategoriesManagementComponent', () => {
|
|||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
const categoriesChangeSpy = spyOn(component.categoriesChange, 'emit').and.callThrough();
|
const categoriesChangeSpy = spyOn(component.categoriesChange, 'emit').and.callThrough();
|
||||||
const removeCategoryBtns = getRemoveCategoryButtons();
|
const removeCategoryButtons = getRemoveCategoryButtons();
|
||||||
removeCategoryBtns[2].click();
|
removeCategoryButtons[2].click();
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
expect(component.categories.length).toBe(2);
|
expect(component.categories.length).toBe(2);
|
||||||
@ -345,8 +345,8 @@ describe('CategoriesManagementComponent', () => {
|
|||||||
typeCategory('test');
|
typeCategory('test');
|
||||||
expect(component.existingCategories.length).toBe(2);
|
expect(component.existingCategories.length).toBe(2);
|
||||||
const categoriesChangeSpy = spyOn(component.categoriesChange, 'emit').and.callThrough();
|
const categoriesChangeSpy = spyOn(component.categoriesChange, 'emit').and.callThrough();
|
||||||
const removeCategoryBtns = getRemoveCategoryButtons();
|
const removeCategoryButtons = getRemoveCategoryButtons();
|
||||||
removeCategoryBtns[0].click();
|
removeCategoryButtons[0].click();
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
expect(component.categories.length).toBe(1);
|
expect(component.categories.length).toBe(1);
|
||||||
@ -375,8 +375,8 @@ describe('CategoriesManagementComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should have correct remove category title', () => {
|
it('should have correct remove category title', () => {
|
||||||
const removeBtns = getRemoveCategoryButtons();
|
const removeButtons = getRemoveCategoryButtons();
|
||||||
const isTitleCorrect = removeBtns.every((removeBtn) => removeBtn.attributes.getNamedItem('title').textContent === 'CATEGORIES_MANAGEMENT.DELETE_CATEGORY');
|
const isTitleCorrect = removeButtons.every((removeBtn) => removeBtn.attributes.getNamedItem('title').textContent === 'CATEGORIES_MANAGEMENT.DELETE_CATEGORY');
|
||||||
expect(isTitleCorrect).toBeTrue();
|
expect(isTitleCorrect).toBeTrue();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -434,8 +434,8 @@ describe('CategoriesManagementComponent', () => {
|
|||||||
createCategory('test');
|
createCategory('test');
|
||||||
|
|
||||||
const categoriesChangeSpy = spyOn(component.categoriesChange, 'emit');
|
const categoriesChangeSpy = spyOn(component.categoriesChange, 'emit');
|
||||||
const removeCategoryBtns = getRemoveCategoryButtons();
|
const removeCategoryButtons = getRemoveCategoryButtons();
|
||||||
removeCategoryBtns[2].click();
|
removeCategoryButtons[2].click();
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
expect(component.categories.length).toBe(2);
|
expect(component.categories.length).toBe(2);
|
||||||
|
@ -64,8 +64,7 @@ export class CategoryTreeDatasourceService extends TreeService<CategoryNode> {
|
|||||||
.join(pathSeparator);
|
.join(pathSeparator);
|
||||||
|
|
||||||
return this.categoryService.getCategory(category.entry.id).pipe(
|
return this.categoryService.getCategory(category.entry.id).pipe(
|
||||||
map((res) => {
|
map((res) => ({
|
||||||
return {
|
|
||||||
id: category.entry.id,
|
id: category.entry.id,
|
||||||
nodeName: path ? `${path}/${category.entry.name}` : category.entry.name,
|
nodeName: path ? `${path}/${category.entry.name}` : category.entry.name,
|
||||||
parentId: category.entry.parentId,
|
parentId: category.entry.parentId,
|
||||||
@ -73,8 +72,7 @@ export class CategoryTreeDatasourceService extends TreeService<CategoryNode> {
|
|||||||
nodeType: TreeNodeType.RegularNode,
|
nodeType: TreeNodeType.RegularNode,
|
||||||
hasChildren: res.entry.hasChildren,
|
hasChildren: res.entry.hasChildren,
|
||||||
isLoading: false
|
isLoading: false
|
||||||
};
|
}))
|
||||||
})
|
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
toArray(),
|
toArray(),
|
||||||
|
@ -610,7 +610,7 @@ describe('ContentMetadataComponent', () => {
|
|||||||
let classesApi: ClassesApi;
|
let classesApi: ClassesApi;
|
||||||
let expectedNode: Node;
|
let expectedNode: Node;
|
||||||
|
|
||||||
const versionableResponse: PropertyGroup = {
|
const verResponse: PropertyGroup = {
|
||||||
name: 'cm:versionable',
|
name: 'cm:versionable',
|
||||||
title: 'Versionable',
|
title: 'Versionable',
|
||||||
properties: {
|
properties: {
|
||||||
@ -705,7 +705,7 @@ describe('ContentMetadataComponent', () => {
|
|||||||
'cm:versionable': '*'
|
'cm:versionable': '*'
|
||||||
});
|
});
|
||||||
|
|
||||||
spyOn(classesApi, 'getClass').and.returnValue(Promise.resolve(versionableResponse));
|
spyOn(classesApi, 'getClass').and.returnValue(Promise.resolve(verResponse));
|
||||||
|
|
||||||
component.ngOnChanges({ node: new SimpleChange(node, expectedNode, false) });
|
component.ngOnChanges({ node: new SimpleChange(node, expectedNode, false) });
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
@ -713,9 +713,9 @@ describe('ContentMetadataComponent', () => {
|
|||||||
await component.groupedProperties$.toPromise();
|
await component.groupedProperties$.toPromise();
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
const versionableProp = queryDom(fixture, 'Versionable');
|
const verProp = queryDom(fixture, 'Versionable');
|
||||||
|
|
||||||
expect(versionableProp).toBeTruthy();
|
expect(verProp).toBeTruthy();
|
||||||
expect(classesApi.getClass).toHaveBeenCalledWith('cm_versionable');
|
expect(classesApi.getClass).toHaveBeenCalledWith('cm_versionable');
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -725,7 +725,7 @@ describe('ContentMetadataComponent', () => {
|
|||||||
'cm:versionable': '*'
|
'cm:versionable': '*'
|
||||||
});
|
});
|
||||||
|
|
||||||
spyOn(classesApi, 'getClass').and.returnValue(Promise.resolve(versionableResponse));
|
spyOn(classesApi, 'getClass').and.returnValue(Promise.resolve(verResponse));
|
||||||
|
|
||||||
component.ngOnChanges({ node: new SimpleChange(node, expectedNode, false) });
|
component.ngOnChanges({ node: new SimpleChange(node, expectedNode, false) });
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
@ -733,9 +733,9 @@ describe('ContentMetadataComponent', () => {
|
|||||||
await component.groupedProperties$.toPromise();
|
await component.groupedProperties$.toPromise();
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
const versionableProps = fixture.debugElement.queryAll(By.css('[data-automation-id="adf-metadata-group-Versionable"]'));
|
const verProps = fixture.debugElement.queryAll(By.css('[data-automation-id="adf-metadata-group-Versionable"]'));
|
||||||
|
|
||||||
expect(versionableProps.length).toEqual(2);
|
expect(verProps.length).toEqual(2);
|
||||||
expect(classesApi.getClass).toHaveBeenCalledWith('cm_versionable');
|
expect(classesApi.getClass).toHaveBeenCalledWith('cm_versionable');
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -745,7 +745,7 @@ describe('ContentMetadataComponent', () => {
|
|||||||
exclude: 'cm:versionable'
|
exclude: 'cm:versionable'
|
||||||
});
|
});
|
||||||
|
|
||||||
spyOn(classesApi, 'getClass').and.returnValue(Promise.resolve(versionableResponse));
|
spyOn(classesApi, 'getClass').and.returnValue(Promise.resolve(verResponse));
|
||||||
|
|
||||||
component.ngOnChanges({ node: new SimpleChange(node, expectedNode, false) });
|
component.ngOnChanges({ node: new SimpleChange(node, expectedNode, false) });
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
@ -753,9 +753,9 @@ describe('ContentMetadataComponent', () => {
|
|||||||
await component.groupedProperties$.toPromise();
|
await component.groupedProperties$.toPromise();
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
const versionableProp = queryDom(fixture, 'Versionable');
|
const verProp = queryDom(fixture, 'Versionable');
|
||||||
|
|
||||||
expect(versionableProp).toBeNull();
|
expect(verProp).toBeNull();
|
||||||
expect(classesApi.getClass).toHaveBeenCalledWith('cm_versionable');
|
expect(classesApi.getClass).toHaveBeenCalledWith('cm_versionable');
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -766,7 +766,7 @@ describe('ContentMetadataComponent', () => {
|
|||||||
'cm:versionable': '*'
|
'cm:versionable': '*'
|
||||||
});
|
});
|
||||||
|
|
||||||
spyOn(classesApi, 'getClass').and.returnValue(Promise.resolve(versionableResponse));
|
spyOn(classesApi, 'getClass').and.returnValue(Promise.resolve(verResponse));
|
||||||
|
|
||||||
component.ngOnChanges({ node: new SimpleChange(node, expectedNode, false) });
|
component.ngOnChanges({ node: new SimpleChange(node, expectedNode, false) });
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
@ -774,9 +774,9 @@ describe('ContentMetadataComponent', () => {
|
|||||||
await component.groupedProperties$.toPromise();
|
await component.groupedProperties$.toPromise();
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
const versionableProp = queryDom(fixture, 'Versionable');
|
const verProp = queryDom(fixture, 'Versionable');
|
||||||
|
|
||||||
expect(versionableProp).toBeTruthy();
|
expect(verProp).toBeTruthy();
|
||||||
expect(classesApi.getClass).toHaveBeenCalledWith('cm_versionable');
|
expect(classesApi.getClass).toHaveBeenCalledWith('cm_versionable');
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -786,7 +786,7 @@ describe('ContentMetadataComponent', () => {
|
|||||||
exclude: ['cm:versionable', 'cm:auditable']
|
exclude: ['cm:versionable', 'cm:auditable']
|
||||||
});
|
});
|
||||||
|
|
||||||
spyOn(classesApi, 'getClass').and.returnValue(Promise.resolve(versionableResponse));
|
spyOn(classesApi, 'getClass').and.returnValue(Promise.resolve(verResponse));
|
||||||
|
|
||||||
component.ngOnChanges({ node: new SimpleChange(node, expectedNode, false) });
|
component.ngOnChanges({ node: new SimpleChange(node, expectedNode, false) });
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
@ -794,8 +794,8 @@ describe('ContentMetadataComponent', () => {
|
|||||||
await component.groupedProperties$.toPromise();
|
await component.groupedProperties$.toPromise();
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
const versionableProp = queryDom(fixture, 'Versionable');
|
const verProp = queryDom(fixture, 'Versionable');
|
||||||
expect(versionableProp).toBeNull();
|
expect(verProp).toBeNull();
|
||||||
|
|
||||||
const auditableProp = queryDom(fixture, 'Auditable');
|
const auditableProp = queryDom(fixture, 'Auditable');
|
||||||
expect(auditableProp).toBeNull();
|
expect(auditableProp).toBeNull();
|
||||||
@ -825,17 +825,17 @@ describe('ContentMetadataComponent', () => {
|
|||||||
|
|
||||||
exifProp.nativeElement.click();
|
exifProp.nativeElement.click();
|
||||||
|
|
||||||
const pixelXDimentionElement = fixture.debugElement.query(
|
const pixelXDimensionElement = fixture.debugElement.query(
|
||||||
By.css('[data-automation-id="card-textitem-label-properties.exif:pixelXDimension"]')
|
By.css('[data-automation-id="card-textitem-label-properties.exif:pixelXDimension"]')
|
||||||
);
|
);
|
||||||
expect(pixelXDimentionElement).toBeTruthy();
|
expect(pixelXDimensionElement).toBeTruthy();
|
||||||
expect(pixelXDimentionElement.nativeElement.textContent.trim()).toEqual('Image Width');
|
expect(pixelXDimensionElement.nativeElement.textContent.trim()).toEqual('Image Width');
|
||||||
|
|
||||||
const pixelYDimentionElement = fixture.debugElement.query(
|
const pixelYDimensionElement = fixture.debugElement.query(
|
||||||
By.css('[data-automation-id="card-textitem-label-properties.exif:pixelYDimension"]')
|
By.css('[data-automation-id="card-textitem-label-properties.exif:pixelYDimension"]')
|
||||||
);
|
);
|
||||||
expect(pixelYDimentionElement).toBeTruthy();
|
expect(pixelYDimensionElement).toBeTruthy();
|
||||||
expect(pixelYDimentionElement.nativeElement.textContent.trim()).toEqual('Image Height');
|
expect(pixelYDimensionElement.nativeElement.textContent.trim()).toEqual('Image Height');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should show Exif twice when includeAll is set to true', async () => {
|
it('should show Exif twice when includeAll is set to true', async () => {
|
||||||
|
@ -330,7 +330,7 @@ export class ContentMetadataComponent implements OnChanges, OnInit, OnDestroy {
|
|||||||
this.loadTagsForNode(this.node.id);
|
this.loadTagsForNode(this.node.id);
|
||||||
}
|
}
|
||||||
if (this.displayCategories && !!result.LinkingCategories) {
|
if (this.displayCategories && !!result.LinkingCategories) {
|
||||||
this.assignedCategories = !!result.LinkingCategories.list ?
|
this.assignedCategories = result.LinkingCategories.list ?
|
||||||
result.LinkingCategories.list.entries.map((entry: CategoryEntry) => entry.entry) :
|
result.LinkingCategories.list.entries.map((entry: CategoryEntry) => entry.entry) :
|
||||||
[result.LinkingCategories.entry];
|
[result.LinkingCategories.entry];
|
||||||
}
|
}
|
||||||
|
@ -110,7 +110,7 @@ describe('ContentMetaDataService', () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const versionableResponse: PropertyGroup = {
|
const verResponse: PropertyGroup = {
|
||||||
name: 'cm:versionable',
|
name: 'cm:versionable',
|
||||||
title: 'Versionable',
|
title: 'Versionable',
|
||||||
properties: {
|
properties: {
|
||||||
@ -232,7 +232,7 @@ describe('ContentMetaDataService', () => {
|
|||||||
'cm:versionable': '*'
|
'cm:versionable': '*'
|
||||||
});
|
});
|
||||||
|
|
||||||
spyOn(classesApi, 'getClass').and.returnValue(Promise.resolve(versionableResponse));
|
spyOn(classesApi, 'getClass').and.returnValue(Promise.resolve(verResponse));
|
||||||
|
|
||||||
const groupedProperties = await service.getGroupedProperties(fakeContentNode).toPromise();
|
const groupedProperties = await service.getGroupedProperties(fakeContentNode).toPromise();
|
||||||
|
|
||||||
@ -249,7 +249,7 @@ describe('ContentMetaDataService', () => {
|
|||||||
'cm:versionable': '*'
|
'cm:versionable': '*'
|
||||||
});
|
});
|
||||||
|
|
||||||
spyOn(classesApi, 'getClass').and.returnValue(Promise.resolve(versionableResponse));
|
spyOn(classesApi, 'getClass').and.returnValue(Promise.resolve(verResponse));
|
||||||
|
|
||||||
const groupedProperties = await service.getGroupedProperties(fakeContentNode).toPromise();
|
const groupedProperties = await service.getGroupedProperties(fakeContentNode).toPromise();
|
||||||
|
|
||||||
@ -267,7 +267,7 @@ describe('ContentMetaDataService', () => {
|
|||||||
exclude: 'cm:versionable'
|
exclude: 'cm:versionable'
|
||||||
});
|
});
|
||||||
|
|
||||||
spyOn(classesApi, 'getClass').and.returnValue(Promise.resolve(versionableResponse));
|
spyOn(classesApi, 'getClass').and.returnValue(Promise.resolve(verResponse));
|
||||||
|
|
||||||
const groupedProperties = await service.getGroupedProperties(fakeContentNode).toPromise();
|
const groupedProperties = await service.getGroupedProperties(fakeContentNode).toPromise();
|
||||||
expect(groupedProperties.length).toEqual(0);
|
expect(groupedProperties.length).toEqual(0);
|
||||||
@ -283,7 +283,7 @@ describe('ContentMetaDataService', () => {
|
|||||||
'cm:versionable': '*'
|
'cm:versionable': '*'
|
||||||
});
|
});
|
||||||
|
|
||||||
spyOn(classesApi, 'getClass').and.returnValue(Promise.resolve(versionableResponse));
|
spyOn(classesApi, 'getClass').and.returnValue(Promise.resolve(verResponse));
|
||||||
|
|
||||||
const groupedProperties = await service.getGroupedProperties(fakeContentNode).toPromise();
|
const groupedProperties = await service.getGroupedProperties(fakeContentNode).toPromise();
|
||||||
expect(groupedProperties.length).toEqual(1);
|
expect(groupedProperties.length).toEqual(1);
|
||||||
@ -299,7 +299,7 @@ describe('ContentMetaDataService', () => {
|
|||||||
exclude: ['cm:versionable', 'cm:auditable']
|
exclude: ['cm:versionable', 'cm:auditable']
|
||||||
});
|
});
|
||||||
|
|
||||||
spyOn(classesApi, 'getClass').and.returnValue(Promise.resolve(versionableResponse));
|
spyOn(classesApi, 'getClass').and.returnValue(Promise.resolve(verResponse));
|
||||||
|
|
||||||
const groupedProperties = await service.getGroupedProperties(fakeContentNode).toPromise();
|
const groupedProperties = await service.getGroupedProperties(fakeContentNode).toPromise();
|
||||||
expect(groupedProperties.length).toEqual(0);
|
expect(groupedProperties.length).toEqual(0);
|
||||||
|
@ -147,9 +147,9 @@ describe('Content Type Dialog Component', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should show the property with the aspect prefix not the inherited ones', async () => {
|
it('should show the property with the aspect prefix not the inherited ones', async () => {
|
||||||
const showPropertyAccordon: HTMLButtonElement = fixture.nativeElement.querySelector('.adf-content-type-accordion .mat-expansion-panel-header');
|
const showPropertyAccordion: HTMLButtonElement = fixture.nativeElement.querySelector('.adf-content-type-accordion .mat-expansion-panel-header');
|
||||||
expect(showPropertyAccordon).toBeDefined();
|
expect(showPropertyAccordion).toBeDefined();
|
||||||
showPropertyAccordon.click();
|
showPropertyAccordion.click();
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
await fixture.whenStable();
|
await fixture.whenStable();
|
||||||
const propertyShowed: NodeList = fixture.nativeElement.querySelectorAll('.adf-content-type-table .mat-row');
|
const propertyShowed: NodeList = fixture.nativeElement.querySelectorAll('.adf-content-type-table .mat-row');
|
||||||
|
@ -20,6 +20,7 @@ import { UntypedFormControl } from '@angular/forms';
|
|||||||
const I18N_ERRORS_PATH = 'CORE.FOLDER_DIALOG.FOLDER_NAME.ERRORS';
|
const I18N_ERRORS_PATH = 'CORE.FOLDER_DIALOG.FOLDER_NAME.ERRORS';
|
||||||
|
|
||||||
export const forbidSpecialCharacters = ({ value }: UntypedFormControl) => {
|
export const forbidSpecialCharacters = ({ value }: UntypedFormControl) => {
|
||||||
|
// eslint-disable-next-line no-useless-escape
|
||||||
const specialCharacters: RegExp = /([\*\"\<\>\\\/\?\:\|])/;
|
const specialCharacters: RegExp = /([\*\"\<\>\\\/\?\:\|])/;
|
||||||
const isValid: boolean = !specialCharacters.test(value);
|
const isValid: boolean = !specialCharacters.test(value);
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ export class NodeLockDialogComponent implements OnInit {
|
|||||||
isLocked: node.isLocked || false,
|
isLocked: node.isLocked || false,
|
||||||
allowOwner: node.properties['cm:lockType'] === 'WRITE_LOCK',
|
allowOwner: node.properties['cm:lockType'] === 'WRITE_LOCK',
|
||||||
isTimeLock: !!node.properties['cm:expiryDate'],
|
isTimeLock: !!node.properties['cm:expiryDate'],
|
||||||
time: !!node.properties['cm:expiryDate'] ? moment(node.properties['cm:expiryDate']) : moment()
|
time: node.properties['cm:expiryDate'] ? moment(node.properties['cm:expiryDate']) : moment()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,10 +24,10 @@ import { TranslateModule } from '@ngx-translate/core';
|
|||||||
@Component({
|
@Component({
|
||||||
template: `<div tabindex="0" adf-auto-focus> Test</div>`
|
template: `<div tabindex="0" adf-auto-focus> Test</div>`
|
||||||
})
|
})
|
||||||
class AutoFoucsTestComponent {}
|
class AutoFocusTestComponent {}
|
||||||
|
|
||||||
describe('AutoFocusDirective', () => {
|
describe('AutoFocusDirective', () => {
|
||||||
let fixture: ComponentFixture<AutoFoucsTestComponent>;
|
let fixture: ComponentFixture<AutoFocusTestComponent>;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
@ -36,10 +36,10 @@ describe('AutoFocusDirective', () => {
|
|||||||
],
|
],
|
||||||
declarations: [
|
declarations: [
|
||||||
AutoFocusDirective,
|
AutoFocusDirective,
|
||||||
AutoFoucsTestComponent
|
AutoFocusTestComponent
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
fixture = TestBed.createComponent(AutoFoucsTestComponent);
|
fixture = TestBed.createComponent(AutoFocusTestComponent);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should focus the element after content is initialized', fakeAsync(() => {
|
it('should focus the element after content is initialized', fakeAsync(() => {
|
||||||
|
@ -118,7 +118,7 @@ export class NodeDeleteDirective implements OnChanges {
|
|||||||
|
|
||||||
let promise: Promise<any>;
|
let promise: Promise<any>;
|
||||||
|
|
||||||
if (node.entry.hasOwnProperty('archivedAt') && node.entry['archivedAt']) {
|
if (Object.prototype.hasOwnProperty.call(node.entry, 'archivedAt') && node.entry['archivedAt']) {
|
||||||
promise = this.trashcanApi.deleteDeletedNode(id);
|
promise = this.trashcanApi.deleteDeletedNode(id);
|
||||||
} else {
|
} else {
|
||||||
promise = this.nodesApi.deleteNode(id, { permanent: this.permanent });
|
promise = this.nodesApi.deleteNode(id, { permanent: this.permanent });
|
||||||
|
@ -130,7 +130,7 @@ export class NodeFavoriteDirective implements OnChanges {
|
|||||||
const node: Node | SharedLink = selected.entry;
|
const node: Node | SharedLink = selected.entry;
|
||||||
|
|
||||||
// ACS 6.x with 'isFavorite' include
|
// ACS 6.x with 'isFavorite' include
|
||||||
if (node?.hasOwnProperty('isFavorite')) {
|
if (node && Object.prototype.hasOwnProperty.call(node, 'isFavorite')) {
|
||||||
return of(selected);
|
return of(selected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,11 +39,11 @@ export class ContentActionModel {
|
|||||||
this.permission = obj.permission;
|
this.permission = obj.permission;
|
||||||
this.disableWithNoPermission = obj.disableWithNoPermission;
|
this.disableWithNoPermission = obj.disableWithNoPermission;
|
||||||
|
|
||||||
if (obj.hasOwnProperty('disabled')) {
|
if (Object.prototype.hasOwnProperty.call(obj, 'disabled')) {
|
||||||
this.disabled = obj.disabled;
|
this.disabled = obj.disabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (obj.hasOwnProperty('visible')) {
|
if (Object.prototype.hasOwnProperty.call(obj, 'visible')) {
|
||||||
this.visible = obj.visible;
|
this.visible = obj.visible;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ export class AddPermissionDialogComponent {
|
|||||||
|
|
||||||
this.selectedMembers.forEach((member) => {
|
this.selectedMembers.forEach((member) => {
|
||||||
const existingMember = this.existingMembers.find(({authorityId}) => authorityId === member.id);
|
const existingMember = this.existingMembers.find(({authorityId}) => authorityId === member.id);
|
||||||
if (!!existingMember) {
|
if (existingMember) {
|
||||||
member.role = existingMember.name;
|
member.role = existingMember.name;
|
||||||
member.accessStatus = existingMember.accessStatus;
|
member.accessStatus = existingMember.accessStatus;
|
||||||
member.readonly = true; // make role non editable
|
member.readonly = true; // make role non editable
|
||||||
@ -66,7 +66,7 @@ export class AddPermissionDialogComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
canCloseDialog() {
|
canCloseDialog() {
|
||||||
if (!!this.selectedMembers.length) {
|
if (this.selectedMembers.length) {
|
||||||
this.disableSearch();
|
this.disableSearch();
|
||||||
} else {
|
} else {
|
||||||
this.dialogRef.close();
|
this.dialogRef.close();
|
||||||
|
@ -54,7 +54,7 @@ export class SearchPermissionConfigurationService implements SearchConfiguration
|
|||||||
if (this.queryProvider?.query) {
|
if (this.queryProvider?.query) {
|
||||||
query = this.queryProvider.query.replace(new RegExp(/\${([^}]+)}/g), searchTerm);
|
query = this.queryProvider.query.replace(new RegExp(/\${([^}]+)}/g), searchTerm);
|
||||||
} else {
|
} else {
|
||||||
query = `(email:*${searchTerm}* OR firstName:*${searchTerm}* OR lastName:*${searchTerm}* OR displayName:*${searchTerm}* OR authorityName:*${searchTerm}* OR authorityDisplayName:*${searchTerm}*) AND ANAME:(\"0/APP.DEFAULT\")`;
|
query = `(email:*${searchTerm}* OR firstName:*${searchTerm}* OR lastName:*${searchTerm}* OR displayName:*${searchTerm}* OR authorityName:*${searchTerm}* OR authorityDisplayName:*${searchTerm}*) AND ANAME:("0/APP.DEFAULT")`;
|
||||||
}
|
}
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
@ -65,6 +65,7 @@ export class NodePermissionService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get permissions for a given node
|
* Get permissions for a given node
|
||||||
|
*
|
||||||
* @param node Node to check permissions for
|
* @param node Node to check permissions for
|
||||||
*/
|
*/
|
||||||
getNodePermissions(node: Node): PermissionDisplayModel[] {
|
getNodePermissions(node: Node): PermissionDisplayModel[] {
|
||||||
|
@ -89,7 +89,7 @@ export class SearchLogicalFilterComponent implements SearchWidget, OnInit {
|
|||||||
fieldQuery += field + '"' + this.searchCondition[key].trim() + '"';
|
fieldQuery += field + '"' + this.searchCondition[key].trim() + '"';
|
||||||
} else {
|
} else {
|
||||||
this.searchCondition[key].split(' ').filter((condition: string) => condition !== '').forEach((phrase: string) => {
|
this.searchCondition[key].split(' ').filter((condition: string) => condition !== '').forEach((phrase: string) => {
|
||||||
const refinedPhrase = '\"' + phrase + '\"';
|
const refinedPhrase = '"' + phrase + '"';
|
||||||
fieldQuery += fieldQuery === '(' ?
|
fieldQuery += fieldQuery === '(' ?
|
||||||
`${key === LogicalSearchFields.EXCLUDE ? 'NOT ' : ''}${field}${refinedPhrase}` :
|
`${key === LogicalSearchFields.EXCLUDE ? 'NOT ' : ''}${field}${refinedPhrase}` :
|
||||||
` ${connector} ${field}${refinedPhrase}`;
|
` ${connector} ${field}${refinedPhrase}`;
|
||||||
|
@ -49,15 +49,15 @@ export class SearchSliderComponent implements SearchWidget, OnInit {
|
|||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
if (this.settings) {
|
if (this.settings) {
|
||||||
if (this.settings.hasOwnProperty('min')) {
|
if (Object.prototype.hasOwnProperty.call(this.settings, 'min')) {
|
||||||
this.min = this.settings['min'];
|
this.min = this.settings['min'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.settings.hasOwnProperty('max')) {
|
if (Object.prototype.hasOwnProperty.call(this.settings, 'max')) {
|
||||||
this.max = this.settings['max'];
|
this.max = this.settings['max'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.settings.hasOwnProperty('step')) {
|
if (Object.prototype.hasOwnProperty.call(this.settings, 'step')) {
|
||||||
this.step = this.settings['step'];
|
this.step = this.settings['step'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,7 +150,7 @@ export abstract class BaseQueryBuilderService {
|
|||||||
default: configuration.default || false,
|
default: configuration.default || false,
|
||||||
selected: this.selectedConfiguration !== undefined ? index === this.selectedConfiguration : configuration.default
|
selected: this.selectedConfiguration !== undefined ? index === this.selectedConfiguration : configuration.default
|
||||||
}));
|
}));
|
||||||
} else if (!!configurations) {
|
} else if (configurations) {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
index: 0,
|
index: 0,
|
||||||
|
@ -103,7 +103,7 @@ export abstract class UploadBase implements OnInit, OnDestroy {
|
|||||||
*/
|
*/
|
||||||
uploadFiles(files: File[]): void {
|
uploadFiles(files: File[]): void {
|
||||||
const filteredFiles: FileModel[] = files
|
const filteredFiles: FileModel[] = files
|
||||||
.map<FileModel>((file: File) => this.createFileModel(file, this.rootFolderId, ((file as any).webkitRelativePath || '').replace(/\/[^\/]*$/, '')));
|
.map<FileModel>((file: File) => this.createFileModel(file, this.rootFolderId, ((file as any).webkitRelativePath || '').replace(/\/[^/]*$/, '')));
|
||||||
|
|
||||||
this.uploadQueue(filteredFiles);
|
this.uploadQueue(filteredFiles);
|
||||||
}
|
}
|
||||||
|
@ -306,7 +306,7 @@ describe('UploadDragAreaComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should upload a file to a specific target folder when dropped onto one', () => {
|
it('should upload a file to a specific target folder when dropped onto one', () => {
|
||||||
const fakePippoItem = {
|
const fakePngItem = {
|
||||||
fullPath: '/folder-fake/file-fake.png',
|
fullPath: '/folder-fake/file-fake.png',
|
||||||
isDirectory: false,
|
isDirectory: false,
|
||||||
isFile: true,
|
isFile: true,
|
||||||
@ -321,7 +321,7 @@ describe('UploadDragAreaComponent', () => {
|
|||||||
const fakeCustomEvent: CustomEvent = new CustomEvent('CustomEvent', {
|
const fakeCustomEvent: CustomEvent = new CustomEvent('CustomEvent', {
|
||||||
detail: {
|
detail: {
|
||||||
data: getFakeShareDataRow(),
|
data: getFakeShareDataRow(),
|
||||||
files: [fakePippoItem]
|
files: [fakePngItem]
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ export class UploadVersionButtonComponent extends UploadButtonComponent implemen
|
|||||||
node: Node;
|
node: Node;
|
||||||
|
|
||||||
protected createFileModel(file: File): FileModel {
|
protected createFileModel(file: File): FileModel {
|
||||||
const fileModel = super.createFileModel(file, this.rootFolderId, ((file as any).webkitRelativePath || '').replace(/\/[^\/]*$/, ''), this.node.id);
|
const fileModel = super.createFileModel(file, this.rootFolderId, ((file as any).webkitRelativePath || '').replace(/\/[^/]*$/, ''), this.node.id);
|
||||||
|
|
||||||
if (!this.isFileAcceptable(fileModel)) {
|
if (!this.isFileAcceptable(fileModel)) {
|
||||||
const message = this.translationService.instant('FILE_UPLOAD.VERSION.MESSAGES.INCOMPATIBLE_VERSION');
|
const message = this.translationService.instant('FILE_UPLOAD.VERSION.MESSAGES.INCOMPATIBLE_VERSION');
|
||||||
|
@ -52,7 +52,7 @@ describe('VersionCompatibilityDirective', () => {
|
|||||||
let fixture: ComponentFixture<TestComponent>;
|
let fixture: ComponentFixture<TestComponent>;
|
||||||
let versionCompatibilityService: VersionCompatibilityService;
|
let versionCompatibilityService: VersionCompatibilityService;
|
||||||
|
|
||||||
const acsResponceMock = new VersionInfo({
|
const acsResponseMock = new VersionInfo({
|
||||||
display: '7.0.1',
|
display: '7.0.1',
|
||||||
major: '7',
|
major: '7',
|
||||||
minor: '0',
|
minor: '0',
|
||||||
@ -70,7 +70,7 @@ describe('VersionCompatibilityDirective', () => {
|
|||||||
});
|
});
|
||||||
fixture = TestBed.createComponent(TestComponent);
|
fixture = TestBed.createComponent(TestComponent);
|
||||||
versionCompatibilityService = TestBed.inject(VersionCompatibilityService);
|
versionCompatibilityService = TestBed.inject(VersionCompatibilityService);
|
||||||
spyOn(versionCompatibilityService, 'getAcsVersion').and.returnValue(acsResponceMock);
|
spyOn(versionCompatibilityService, 'getAcsVersion').and.returnValue(acsResponseMock);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should display component when the version is supported', () => {
|
it('should display component when the version is supported', () => {
|
||||||
|
@ -28,7 +28,7 @@ describe('VersionCompatibilityService', () => {
|
|||||||
let discoveryApiService: DiscoveryApiService;
|
let discoveryApiService: DiscoveryApiService;
|
||||||
const mockProductInfo = new BehaviorSubject<RepositoryInfo>(null);
|
const mockProductInfo = new BehaviorSubject<RepositoryInfo>(null);
|
||||||
|
|
||||||
const acsResponceMock = {
|
const acsResponseMock = {
|
||||||
version: {
|
version: {
|
||||||
display: '7.0.1',
|
display: '7.0.1',
|
||||||
major: '7',
|
major: '7',
|
||||||
@ -54,7 +54,7 @@ describe('VersionCompatibilityService', () => {
|
|||||||
});
|
});
|
||||||
discoveryApiService = TestBed.inject(DiscoveryApiService);
|
discoveryApiService = TestBed.inject(DiscoveryApiService);
|
||||||
versionCompatibilityService = TestBed.inject(VersionCompatibilityService);
|
versionCompatibilityService = TestBed.inject(VersionCompatibilityService);
|
||||||
mockProductInfo.next(acsResponceMock as RepositoryInfo);
|
mockProductInfo.next(acsResponseMock as RepositoryInfo);
|
||||||
versionCompatibilityService = new VersionCompatibilityService(discoveryApiService);
|
versionCompatibilityService = new VersionCompatibilityService(discoveryApiService);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -151,18 +151,22 @@ export class AdfHttpClient implements ee.Emitter,JsApiHttpClient {
|
|||||||
private addPromiseListeners<T = any>(promise: Promise<T>, eventEmitter: any) {
|
private addPromiseListeners<T = any>(promise: Promise<T>, eventEmitter: any) {
|
||||||
const eventPromise = Object.assign(promise, {
|
const eventPromise = Object.assign(promise, {
|
||||||
on() {
|
on() {
|
||||||
|
// eslint-disable-next-line prefer-spread, prefer-rest-params
|
||||||
eventEmitter.on.apply(eventEmitter, arguments);
|
eventEmitter.on.apply(eventEmitter, arguments);
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
once() {
|
once() {
|
||||||
|
// eslint-disable-next-line prefer-spread, prefer-rest-params
|
||||||
eventEmitter.once.apply(eventEmitter, arguments);
|
eventEmitter.once.apply(eventEmitter, arguments);
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
emit() {
|
emit() {
|
||||||
|
// eslint-disable-next-line prefer-spread, prefer-rest-params
|
||||||
eventEmitter.emit.apply(eventEmitter, arguments);
|
eventEmitter.emit.apply(eventEmitter, arguments);
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
off() {
|
off() {
|
||||||
|
// eslint-disable-next-line prefer-spread, prefer-rest-params
|
||||||
eventEmitter.off.apply(eventEmitter, arguments);
|
eventEmitter.off.apply(eventEmitter, arguments);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -52,8 +52,8 @@ describe('AppLayoutComponent', () => {
|
|||||||
hideSidenavConditions: [],
|
hideSidenavConditions: [],
|
||||||
minimizeSidenavConditions: [],
|
minimizeSidenavConditions: [],
|
||||||
preferencesService: {
|
preferencesService: {
|
||||||
get: (_key: string) => 'true',
|
get: () => 'true',
|
||||||
set: (_key: string, _value: any) => {}
|
set: () => {}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -27,10 +27,7 @@ describe('AboutGithubLinkComponent', () => {
|
|||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [
|
imports: [TranslateModule.forRoot(), CoreTestingModule]
|
||||||
TranslateModule.forRoot(),
|
|
||||||
CoreTestingModule
|
|
||||||
]
|
|
||||||
});
|
});
|
||||||
fixture = TestBed.createComponent(AboutGithubLinkComponent);
|
fixture = TestBed.createComponent(AboutGithubLinkComponent);
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
@ -62,7 +59,7 @@ describe('AboutGithubLinkComponent', () => {
|
|||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
await fixture.whenStable();
|
await fixture.whenStable();
|
||||||
const githubUrl = fixture.nativeElement.querySelector('[data-automation-id="adf-github-url"]');
|
const githubUrl = fixture.nativeElement.querySelector('[data-automation-id="adf-github-url"]');
|
||||||
expect(githubUrl.innerText).toEqual(aboutGithubDetails.defualrUrl);
|
expect(githubUrl.innerText).toEqual(aboutGithubDetails.defaultUrl);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should display the github link', async () => {
|
it('should display the github link', async () => {
|
||||||
|
@ -43,7 +43,7 @@ export const mockPlugins = [
|
|||||||
|
|
||||||
export const aboutGithubDetails = {
|
export const aboutGithubDetails = {
|
||||||
url: 'https://github.com/componany/repository/commits/',
|
url: 'https://github.com/componany/repository/commits/',
|
||||||
defualrUrl: 'https://github.com/Alfresco/alfresco-ng2-components/commits/',
|
defaultUrl: 'https://github.com/Alfresco/alfresco-ng2-components/commits/',
|
||||||
version: '0.0.7',
|
version: '0.0.7',
|
||||||
ecmHost: 'https://mock.ecmhost.com',
|
ecmHost: 'https://mock.ecmhost.com',
|
||||||
bpmHost: 'https://mock.bpmhost.com',
|
bpmHost: 'https://mock.bpmhost.com',
|
||||||
|
@ -185,7 +185,7 @@ export class AppConfigService {
|
|||||||
* @returns Notification when loading is complete
|
* @returns Notification when loading is complete
|
||||||
*/
|
*/
|
||||||
load(): Promise<any> {
|
load(): Promise<any> {
|
||||||
return new Promise(async (resolve) => {
|
return new Promise((resolve) => {
|
||||||
const configUrl = `app.config.json?v=${Date.now()}`;
|
const configUrl = `app.config.json?v=${Date.now()}`;
|
||||||
|
|
||||||
if (this.status === Status.INIT) {
|
if (this.status === Status.INIT) {
|
||||||
@ -218,7 +218,7 @@ export class AppConfigService {
|
|||||||
* @returns Discovery configuration
|
* @returns Discovery configuration
|
||||||
*/
|
*/
|
||||||
loadWellKnown(hostIdp: string): Promise<OpenidConfiguration> {
|
loadWellKnown(hostIdp: string): Promise<OpenidConfiguration> {
|
||||||
return new Promise(async (resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this.http
|
this.http
|
||||||
.get<OpenidConfiguration>(`${hostIdp}/.well-known/openid-configuration`)
|
.get<OpenidConfiguration>(`${hostIdp}/.well-known/openid-configuration`)
|
||||||
.subscribe({
|
.subscribe({
|
||||||
|
@ -40,7 +40,7 @@ export class AuthBearerInterceptor implements HttpInterceptor {
|
|||||||
|
|
||||||
this.authService = this.injector.get(AuthenticationService);
|
this.authService = this.injector.get(AuthenticationService);
|
||||||
|
|
||||||
if (!this.authService || !this.authService.getBearerExcludedUrls()) {
|
if (!this.authService?.getBearerExcludedUrls()) {
|
||||||
return next.handle(req);
|
return next.handle(req);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,10 +97,10 @@ describe('JwtHelperService', () => {
|
|||||||
|
|
||||||
spyOn(jwtHelperService, 'decodeToken').and.returnValue(
|
spyOn(jwtHelperService, 'decodeToken').and.returnValue(
|
||||||
{
|
{
|
||||||
resource_access: { fakeapp: { roles: ['role1'] } }
|
resource_access: { fakeApp: { roles: ['role1'] } }
|
||||||
});
|
});
|
||||||
|
|
||||||
const result = jwtHelperService.hasRealmRolesForClientRole('fakeapp', ['role1']);
|
const result = jwtHelperService.hasRealmRolesForClientRole('fakeApp', ['role1']);
|
||||||
expect(result).toBeTruthy();
|
expect(result).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -109,10 +109,10 @@ describe('JwtHelperService', () => {
|
|||||||
|
|
||||||
spyOn(jwtHelperService, 'decodeToken').and.returnValue(
|
spyOn(jwtHelperService, 'decodeToken').and.returnValue(
|
||||||
{
|
{
|
||||||
resource_access: { fakeapp: { roles: ['role1'] } }
|
resource_access: { fakeApp: { roles: ['role1'] } }
|
||||||
});
|
});
|
||||||
|
|
||||||
const result = jwtHelperService.hasRealmRolesForClientRole('fakeapp', ['role1', 'role2']);
|
const result = jwtHelperService.hasRealmRolesForClientRole('fakeApp', ['role1', 'role2']);
|
||||||
expect(result).toBeTruthy();
|
expect(result).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -120,9 +120,9 @@ describe('JwtHelperService', () => {
|
|||||||
spyOn(jwtHelperService, 'getAccessToken').and.returnValue('my-access_token');
|
spyOn(jwtHelperService, 'getAccessToken').and.returnValue('my-access_token');
|
||||||
spyOn(jwtHelperService, 'decodeToken').and.returnValue(
|
spyOn(jwtHelperService, 'decodeToken').and.returnValue(
|
||||||
{
|
{
|
||||||
resource_access: { fakeapp: { roles: ['role3'] } }
|
resource_access: { fakeApp: { roles: ['role3'] } }
|
||||||
});
|
});
|
||||||
const result = jwtHelperService.hasRealmRolesForClientRole('fakeapp', ['role1', 'role2']);
|
const result = jwtHelperService.hasRealmRolesForClientRole('fakeApp', ['role1', 'role2']);
|
||||||
expect(result).toBeFalsy();
|
expect(result).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -130,9 +130,9 @@ describe('JwtHelperService', () => {
|
|||||||
spyOn(jwtHelperService, 'getAccessToken').and.returnValue('my-access_token');
|
spyOn(jwtHelperService, 'getAccessToken').and.returnValue('my-access_token');
|
||||||
spyOn(jwtHelperService, 'decodeToken').and.returnValue(
|
spyOn(jwtHelperService, 'decodeToken').and.returnValue(
|
||||||
{
|
{
|
||||||
resource_access: { anotherfakeapp: { roles: ['role1'] } }
|
resource_access: { anotherFakeApp: { roles: ['role1'] } }
|
||||||
});
|
});
|
||||||
const result = jwtHelperService.hasRealmRolesForClientRole('fakeapp', ['role1', 'role2']);
|
const result = jwtHelperService.hasRealmRolesForClientRole('fakeApp', ['role1', 'role2']);
|
||||||
expect(result).toBeFalsy();
|
expect(result).toBeFalsy();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -46,10 +46,7 @@ describe('CardViewArrayItemComponent', () => {
|
|||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [
|
imports: [TranslateModule.forRoot(), CoreTestingModule]
|
||||||
TranslateModule.forRoot(),
|
|
||||||
CoreTestingModule
|
|
||||||
]
|
|
||||||
});
|
});
|
||||||
fixture = TestBed.createComponent(CardViewArrayItemComponent);
|
fixture = TestBed.createComponent(CardViewArrayItemComponent);
|
||||||
service = TestBed.inject(CardViewUpdateService);
|
service = TestBed.inject(CardViewUpdateService);
|
||||||
@ -87,8 +84,8 @@ describe('CardViewArrayItemComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should NOT call service on chip list container click', () => {
|
it('should NOT call service on chip list container click', () => {
|
||||||
const chiplistContainer: HTMLElement = fixture.nativeElement.querySelector('[data-automation-id="card-arrayitem-chip-list-container"]');
|
const chipListContainer: HTMLElement = fixture.nativeElement.querySelector('[data-automation-id="card-arrayitem-chip-list-container"]');
|
||||||
chiplistContainer.dispatchEvent(new Event('click'));
|
chipListContainer.dispatchEvent(new Event('click'));
|
||||||
|
|
||||||
expect(serviceSpy).not.toHaveBeenCalled();
|
expect(serviceSpy).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
@ -110,11 +107,11 @@ describe('CardViewArrayItemComponent', () => {
|
|||||||
});
|
});
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
const chiplistContainer = fixture.debugElement.query(By.css('[data-automation-id="card-arrayitem-chip-list-container"]'));
|
const chipListContainer = fixture.debugElement.query(By.css('[data-automation-id="card-arrayitem-chip-list-container"]'));
|
||||||
const chip1 = fixture.nativeElement.querySelector('[data-automation-id="card-arrayitem-chip-Zlatan"] span');
|
const chip1 = fixture.nativeElement.querySelector('[data-automation-id="card-arrayitem-chip-Zlatan"] span');
|
||||||
const chip2 = fixture.nativeElement.querySelector('[data-automation-id="card-arrayitem-chip-Lionel Messi"] span');
|
const chip2 = fixture.nativeElement.querySelector('[data-automation-id="card-arrayitem-chip-Lionel Messi"] span');
|
||||||
|
|
||||||
expect(chiplistContainer).not.toBeNull();
|
expect(chipListContainer).not.toBeNull();
|
||||||
expect(chip1.innerText).toEqual('Zlatan');
|
expect(chip1.innerText).toEqual('Zlatan');
|
||||||
expect(chip2.innerText).toEqual('Lionel Messi');
|
expect(chip2.innerText).toEqual('Lionel Messi');
|
||||||
});
|
});
|
||||||
@ -126,13 +123,13 @@ describe('CardViewArrayItemComponent', () => {
|
|||||||
});
|
});
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
const chiplistContainer = fixture.debugElement.query(By.css('[data-automation-id="card-arrayitem-chip-list-container"]'));
|
const chipListContainer = fixture.debugElement.query(By.css('[data-automation-id="card-arrayitem-chip-list-container"]'));
|
||||||
const chip1 = fixture.nativeElement.querySelector('[data-automation-id="card-arrayitem-chip-Zlatan"] span');
|
const chip1 = fixture.nativeElement.querySelector('[data-automation-id="card-arrayitem-chip-Zlatan"] span');
|
||||||
const chip1Icon = fixture.nativeElement.querySelector('[data-automation-id="card-arrayitem-chip-Zlatan"] mat-icon');
|
const chip1Icon = fixture.nativeElement.querySelector('[data-automation-id="card-arrayitem-chip-Zlatan"] mat-icon');
|
||||||
const chip2 = fixture.nativeElement.querySelector('[data-automation-id="card-arrayitem-chip-Lionel Messi"] span');
|
const chip2 = fixture.nativeElement.querySelector('[data-automation-id="card-arrayitem-chip-Lionel Messi"] span');
|
||||||
const chip2Icon = fixture.nativeElement.querySelector('[data-automation-id="card-arrayitem-chip-Lionel Messi"] mat-icon');
|
const chip2Icon = fixture.nativeElement.querySelector('[data-automation-id="card-arrayitem-chip-Lionel Messi"] mat-icon');
|
||||||
|
|
||||||
expect(chiplistContainer).not.toBeNull();
|
expect(chipListContainer).not.toBeNull();
|
||||||
expect(chip1.innerText).toEqual('Zlatan');
|
expect(chip1.innerText).toEqual('Zlatan');
|
||||||
expect(chip1Icon.innerText).toEqual('person');
|
expect(chip1Icon.innerText).toEqual('person');
|
||||||
expect(chip2.innerText).toEqual('Lionel Messi');
|
expect(chip2.innerText).toEqual('Lionel Messi');
|
||||||
@ -145,9 +142,9 @@ describe('CardViewArrayItemComponent', () => {
|
|||||||
clickable: true
|
clickable: true
|
||||||
});
|
});
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
const editicon = fixture.nativeElement.querySelector('[data-automation-id="card-array-item-clickable-icon-array"]');
|
const editIcon = fixture.nativeElement.querySelector('[data-automation-id="card-array-item-clickable-icon-array"]');
|
||||||
expect(editicon).toBeDefined();
|
expect(editIcon).toBeDefined();
|
||||||
expect(editicon.innerText).toBe('edit');
|
expect(editIcon.innerText).toBe('edit');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not render defined icon if clickable set to false', () => {
|
it('should not render defined icon if clickable set to false', () => {
|
||||||
@ -156,18 +153,18 @@ describe('CardViewArrayItemComponent', () => {
|
|||||||
clickable: false
|
clickable: false
|
||||||
});
|
});
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
const editicon = fixture.nativeElement.querySelector('[data-automation-id="card-array-item-clickable-icon-array"]');
|
const editIcon = fixture.nativeElement.querySelector('[data-automation-id="card-array-item-clickable-icon-array"]');
|
||||||
expect(editicon).toBeNull();
|
expect(editIcon).toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should render all values if noOfItemsToDisplay is not defined', () => {
|
it('should render all values if noOfItemsToDisplay is not defined', () => {
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
const chiplistContainer = fixture.debugElement.query(By.css('[data-automation-id="card-arrayitem-chip-list-container"]'));
|
const chipListContainer = fixture.debugElement.query(By.css('[data-automation-id="card-arrayitem-chip-list-container"]'));
|
||||||
const moreElement = fixture.debugElement.query(By.css('[data-automation-id="card-arrayitem-more-chip"]'));
|
const moreElement = fixture.debugElement.query(By.css('[data-automation-id="card-arrayitem-more-chip"]'));
|
||||||
const chip = fixture.nativeElement.querySelectorAll('mat-chip');
|
const chip = fixture.nativeElement.querySelectorAll('mat-chip');
|
||||||
|
|
||||||
expect(chiplistContainer).not.toBeNull();
|
expect(chipListContainer).not.toBeNull();
|
||||||
expect(moreElement).toBeNull();
|
expect(moreElement).toBeNull();
|
||||||
expect(chip.length).toBe(4);
|
expect(chip.length).toBe(4);
|
||||||
});
|
});
|
||||||
@ -179,10 +176,10 @@ describe('CardViewArrayItemComponent', () => {
|
|||||||
});
|
});
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
const chiplistContainer = fixture.debugElement.query(By.css('[data-automation-id="card-arrayitem-chip-list-container"]'));
|
const chipListContainer = fixture.debugElement.query(By.css('[data-automation-id="card-arrayitem-chip-list-container"]'));
|
||||||
const chip = fixture.debugElement.queryAll(By.css('mat-chip'));
|
const chip = fixture.debugElement.queryAll(By.css('mat-chip'));
|
||||||
|
|
||||||
expect(chiplistContainer).not.toBeNull();
|
expect(chipListContainer).not.toBeNull();
|
||||||
expect(chip.length).toBe(3);
|
expect(chip.length).toBe(3);
|
||||||
expect(chip[2].nativeElement.innerText).toBe('2 CORE.CARDVIEW.MORE');
|
expect(chip[2].nativeElement.innerText).toBe('2 CORE.CARDVIEW.MORE');
|
||||||
});
|
});
|
||||||
|
@ -41,7 +41,7 @@ describe('CardViewBoolItemComponent', () => {
|
|||||||
component.property = new CardViewBoolItemModel({
|
component.property = new CardViewBoolItemModel({
|
||||||
label: 'Boolean label',
|
label: 'Boolean label',
|
||||||
value: true,
|
value: true,
|
||||||
key: 'boolkey',
|
key: 'boolKey',
|
||||||
default: false,
|
default: false,
|
||||||
editable: false
|
editable: false
|
||||||
});
|
});
|
||||||
@ -207,7 +207,7 @@ describe('CardViewBoolItemComponent', () => {
|
|||||||
const disposableUpdate = cardViewUpdateService.itemUpdated$.subscribe(
|
const disposableUpdate = cardViewUpdateService.itemUpdated$.subscribe(
|
||||||
(updateNotification) => {
|
(updateNotification) => {
|
||||||
expect(updateNotification.target).toEqual(property);
|
expect(updateNotification.target).toEqual(property);
|
||||||
expect(updateNotification.changed).toEqual({ boolkey: true });
|
expect(updateNotification.changed).toEqual({ boolKey: true });
|
||||||
disposableUpdate.unsubscribe();
|
disposableUpdate.unsubscribe();
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
|
@ -118,6 +118,7 @@ export class CardViewItemDispatcherComponent implements OnChanges {
|
|||||||
|
|
||||||
private proxy(methodName, ...args) {
|
private proxy(methodName, ...args) {
|
||||||
if (this.componentReference.instance[methodName]) {
|
if (this.componentReference.instance[methodName]) {
|
||||||
|
// eslint-disable-next-line prefer-spread
|
||||||
this.componentReference.instance[methodName].apply(this.componentReference.instance, args);
|
this.componentReference.instance[methodName].apply(this.componentReference.instance, args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ describe('CardViewBaseItemModel', () => {
|
|||||||
expect(itemModel.data).toBe(properties.data);
|
expect(itemModel.data).toBe(properties.data);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should persist the params\' properties as own properties', () => {
|
it('should persist the params properties as own properties', () => {
|
||||||
const allProperties = {
|
const allProperties = {
|
||||||
...properties,
|
...properties,
|
||||||
default: 'default-value',
|
default: 'default-value',
|
||||||
|
@ -40,6 +40,7 @@ export class HighlightTransformService {
|
|||||||
let result = text;
|
let result = text;
|
||||||
|
|
||||||
if (search && text) {
|
if (search && text) {
|
||||||
|
// eslint-disable-next-line no-useless-escape
|
||||||
let pattern = search.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
|
let pattern = search.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
|
||||||
pattern = pattern.split(' ').filter((t) => t.length > 0).join('|');
|
pattern = pattern.split(' ').filter((t) => t.length > 0).join('|');
|
||||||
|
|
||||||
|
@ -24,12 +24,7 @@ interface TestSortableByCategoryItem extends SortableByCategoryItem {
|
|||||||
describe('SortByCategoryMapperService', () => {
|
describe('SortByCategoryMapperService', () => {
|
||||||
let mapper: SortByCategoryMapperService<TestSortableByCategoryItem>;
|
let mapper: SortByCategoryMapperService<TestSortableByCategoryItem>;
|
||||||
|
|
||||||
const DEFAULT_CATEGORIES = [
|
const DEFAULT_CATEGORIES = ['', 'DefaultCategory1', 'DefaultCategory2', 'DefaultCategory3'];
|
||||||
'',
|
|
||||||
'DefaultCategory1',
|
|
||||||
'DefaultCategory2',
|
|
||||||
'DefaultCategory3'
|
|
||||||
];
|
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
mapper = new SortByCategoryMapperService();
|
mapper = new SortByCategoryMapperService();
|
||||||
@ -57,25 +52,29 @@ describe('SortByCategoryMapperService', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should set all items under default category', () => {
|
it('should set all items under default category', () => {
|
||||||
const defaulValues: TestSortableByCategoryItem[] = [{
|
const defaultValues: TestSortableByCategoryItem[] = [
|
||||||
|
{
|
||||||
name: 'name-a',
|
name: 'name-a',
|
||||||
id: 'id',
|
id: 'id',
|
||||||
category: DEFAULT_CATEGORIES[1]
|
category: DEFAULT_CATEGORIES[1]
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
name: 'name-b',
|
name: 'name-b',
|
||||||
id: 'id2',
|
id: 'id2',
|
||||||
category: DEFAULT_CATEGORIES[2]
|
category: DEFAULT_CATEGORIES[2]
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
name: 'name-c',
|
name: 'name-c',
|
||||||
id: 'id3',
|
id: 'id3',
|
||||||
category: DEFAULT_CATEGORIES[0]
|
category: DEFAULT_CATEGORIES[0]
|
||||||
}];
|
}
|
||||||
|
];
|
||||||
|
|
||||||
const result = mapper.mapItems(defaulValues, DEFAULT_CATEGORIES);
|
const result = mapper.mapItems(defaultValues, DEFAULT_CATEGORIES);
|
||||||
|
|
||||||
expect(result.length).toBe(1);
|
expect(result.length).toBe(1);
|
||||||
expect(result[0].category).toBe('');
|
expect(result[0].category).toBe('');
|
||||||
expect(result[0].items.length).toBe(defaulValues.length);
|
expect(result[0].items.length).toBe(defaultValues.length);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should work if no items are present', () => {
|
it('should work if no items are present', () => {
|
||||||
|
@ -21,7 +21,6 @@ import { Injectable } from '@angular/core';
|
|||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
})
|
})
|
||||||
export class StorageService {
|
export class StorageService {
|
||||||
|
|
||||||
private memoryStore: { [key: string]: any } = {};
|
private memoryStore: { [key: string]: any } = {};
|
||||||
private readonly useLocalStorage: boolean = false;
|
private readonly useLocalStorage: boolean = false;
|
||||||
private _prefix: string = '';
|
private _prefix: string = '';
|
||||||
@ -48,7 +47,7 @@ export class StorageService {
|
|||||||
if (this.useLocalStorage) {
|
if (this.useLocalStorage) {
|
||||||
return localStorage.getItem(this.prefix + key);
|
return localStorage.getItem(this.prefix + key);
|
||||||
} else {
|
} else {
|
||||||
return this.memoryStore.hasOwnProperty(this.prefix + key) ? this.memoryStore[this.prefix + key] : null;
|
return Object.prototype.hasOwnProperty.call(this.memoryStore, this.prefix + key) ? this.memoryStore[this.prefix + key] : null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,9 +95,9 @@ export class StorageService {
|
|||||||
*/
|
*/
|
||||||
hasItem(key: string): boolean {
|
hasItem(key: string): boolean {
|
||||||
if (this.useLocalStorage) {
|
if (this.useLocalStorage) {
|
||||||
return localStorage.getItem(this.prefix + key) ? true : false;
|
return !!localStorage.getItem(this.prefix + key);
|
||||||
} else {
|
} else {
|
||||||
return this.memoryStore.hasOwnProperty(key);
|
return Object.prototype.hasOwnProperty.call(this.memoryStore, key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ export class FileUtils {
|
|||||||
files.push({
|
files.push({
|
||||||
entry,
|
entry,
|
||||||
file,
|
file,
|
||||||
relativeFolder: entry.fullPath.replace(/\/[^\/]*$/, '')
|
relativeFolder: entry.fullPath.replace(/\/[^/]*$/, '')
|
||||||
});
|
});
|
||||||
resolveFile();
|
resolveFile();
|
||||||
});
|
});
|
||||||
|
@ -34,19 +34,13 @@ import { CdkDragDrop } from '@angular/cdk/drag-drop';
|
|||||||
import { take } from 'rxjs/operators';
|
import { take } from 'rxjs/operators';
|
||||||
import { By } from '@angular/platform-browser';
|
import { By } from '@angular/platform-browser';
|
||||||
|
|
||||||
@Component({selector: 'adf-custom-column-template-component', template: `
|
@Component({ selector: 'adf-custom-column-template-component', template: ` <ng-template #tmplRef></ng-template> ` })
|
||||||
<ng-template #tmplRef></ng-template>
|
|
||||||
`})
|
|
||||||
class CustomColumnTemplateComponent {
|
class CustomColumnTemplateComponent {
|
||||||
@ViewChild('tmplRef', { static: true }) templateRef: TemplateRef<any>;
|
@ViewChild('tmplRef', { static: true }) templateRef: TemplateRef<any>;
|
||||||
}
|
}
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'adf-custom-column-header-component',
|
selector: 'adf-custom-column-header-component',
|
||||||
template: `
|
template: ` <ng-template #tmplRef> CUSTOM HEADER </ng-template> `
|
||||||
<ng-template #tmplRef>
|
|
||||||
CUSTOM HEADER
|
|
||||||
</ng-template>
|
|
||||||
`
|
|
||||||
})
|
})
|
||||||
class CustomColumnHeaderComponent {
|
class CustomColumnHeaderComponent {
|
||||||
@ViewChild('tmplRef', { static: true }) templateRef: TemplateRef<any>;
|
@ViewChild('tmplRef', { static: true }) templateRef: TemplateRef<any>;
|
||||||
@ -79,7 +73,6 @@ export const resolverFn = (row: DataRow, col: DataColumn) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
describe('DataTable', () => {
|
describe('DataTable', () => {
|
||||||
|
|
||||||
let fixture: ComponentFixture<DataTableComponent>;
|
let fixture: ComponentFixture<DataTableComponent>;
|
||||||
let dataTable: DataTableComponent;
|
let dataTable: DataTableComponent;
|
||||||
let element: any;
|
let element: any;
|
||||||
@ -141,16 +134,12 @@ describe('DataTable', () => {
|
|||||||
|
|
||||||
tick(tickTime);
|
tick(tickTime);
|
||||||
|
|
||||||
|
|
||||||
expect(doubleClickCount).toBe(1);
|
expect(doubleClickCount).toBe(1);
|
||||||
};
|
};
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [
|
imports: [TranslateModule.forRoot(), CoreTestingModule],
|
||||||
TranslateModule.forRoot(),
|
|
||||||
CoreTestingModule
|
|
||||||
],
|
|
||||||
declarations: [CustomColumnHeaderComponent]
|
declarations: [CustomColumnHeaderComponent]
|
||||||
});
|
});
|
||||||
fixture = TestBed.createComponent(DataTableComponent);
|
fixture = TestBed.createComponent(DataTableComponent);
|
||||||
@ -163,10 +152,7 @@ describe('DataTable', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should preserve the historical selection order', () => {
|
it('should preserve the historical selection order', () => {
|
||||||
dataTable.data = new ObjectDataTableAdapter(
|
dataTable.data = new ObjectDataTableAdapter([{ id: 0 }, { id: 1 }, { id: 2 }], [new ObjectDataColumn({ key: 'id' })]);
|
||||||
[{ id: 0 }, { id: 1 }, { id: 2 }],
|
|
||||||
[new ObjectDataColumn({ key: 'id' })]
|
|
||||||
);
|
|
||||||
|
|
||||||
const rows = dataTable.data.getRows();
|
const rows = dataTable.data.getRows();
|
||||||
|
|
||||||
@ -181,7 +167,6 @@ describe('DataTable', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should update schema if columns change', fakeAsync(() => {
|
it('should update schema if columns change', fakeAsync(() => {
|
||||||
|
|
||||||
dataTable.columnList = new DataColumnListComponent();
|
dataTable.columnList = new DataColumnListComponent();
|
||||||
dataTable.columnList.columns = new QueryList<DataColumnComponent>();
|
dataTable.columnList.columns = new QueryList<DataColumnComponent>();
|
||||||
dataTable.data = new ObjectDataTableAdapter([], []);
|
dataTable.data = new ObjectDataTableAdapter([], []);
|
||||||
@ -198,13 +183,7 @@ describe('DataTable', () => {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
it('should use the cardview style if cardview is true', () => {
|
it('should use the cardview style if cardview is true', () => {
|
||||||
const newData = new ObjectDataTableAdapter(
|
const newData = new ObjectDataTableAdapter([{ name: '1' }, { name: '2' }], [new ObjectDataColumn({ key: 'name' })]);
|
||||||
[
|
|
||||||
{ name: '1' },
|
|
||||||
{ name: '2' }
|
|
||||||
],
|
|
||||||
[new ObjectDataColumn({ key: 'name' })]
|
|
||||||
);
|
|
||||||
|
|
||||||
dataTable.display = 'gallery';
|
dataTable.display = 'gallery';
|
||||||
dataTable.ngOnChanges({
|
dataTable.ngOnChanges({
|
||||||
@ -218,13 +197,7 @@ describe('DataTable', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should use the cardview style if cardview is false', () => {
|
it('should use the cardview style if cardview is false', () => {
|
||||||
const newData = new ObjectDataTableAdapter(
|
const newData = new ObjectDataTableAdapter([{ name: '1' }, { name: '2' }], [new ObjectDataColumn({ key: 'name' })]);
|
||||||
[
|
|
||||||
{ name: '1' },
|
|
||||||
{ name: '2' }
|
|
||||||
],
|
|
||||||
[new ObjectDataColumn({ key: 'name' })]
|
|
||||||
);
|
|
||||||
|
|
||||||
dataTable.ngOnChanges({
|
dataTable.ngOnChanges({
|
||||||
data: new SimpleChange(null, newData, false)
|
data: new SimpleChange(null, newData, false)
|
||||||
@ -237,18 +210,10 @@ describe('DataTable', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('Header modes', () => {
|
describe('Header modes', () => {
|
||||||
|
const newData = new ObjectDataTableAdapter([{ name: '1' }, { name: '2' }], [new ObjectDataColumn({ key: 'name' })]);
|
||||||
const newData = new ObjectDataTableAdapter(
|
|
||||||
[
|
|
||||||
{ name: '1' },
|
|
||||||
{ name: '2' }
|
|
||||||
],
|
|
||||||
[new ObjectDataColumn({ key: 'name' })]
|
|
||||||
);
|
|
||||||
const emptyData = new ObjectDataTableAdapter();
|
const emptyData = new ObjectDataTableAdapter();
|
||||||
|
|
||||||
it('should show the header if showHeader is `Data` and there is data', () => {
|
it('should show the header if showHeader is `Data` and there is data', () => {
|
||||||
|
|
||||||
dataTable.showHeader = ShowHeaderMode.Data;
|
dataTable.showHeader = ShowHeaderMode.Data;
|
||||||
dataTable.loading = false;
|
dataTable.loading = false;
|
||||||
dataTable.ngOnChanges({
|
dataTable.ngOnChanges({
|
||||||
@ -261,7 +226,6 @@ describe('DataTable', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should hide the header if showHeader is `Data` and there is no data', () => {
|
it('should hide the header if showHeader is `Data` and there is no data', () => {
|
||||||
|
|
||||||
dataTable.showHeader = ShowHeaderMode.Data;
|
dataTable.showHeader = ShowHeaderMode.Data;
|
||||||
dataTable.loading = false;
|
dataTable.loading = false;
|
||||||
dataTable.ngOnChanges({
|
dataTable.ngOnChanges({
|
||||||
@ -274,7 +238,6 @@ describe('DataTable', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should always show the header if showHeader is `Always`', () => {
|
it('should always show the header if showHeader is `Always`', () => {
|
||||||
|
|
||||||
dataTable.showHeader = ShowHeaderMode.Always;
|
dataTable.showHeader = ShowHeaderMode.Always;
|
||||||
dataTable.loading = false;
|
dataTable.loading = false;
|
||||||
|
|
||||||
@ -292,7 +255,6 @@ describe('DataTable', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should never show the header if showHeader is `Never`', () => {
|
it('should never show the header if showHeader is `Never`', () => {
|
||||||
|
|
||||||
dataTable.showHeader = ShowHeaderMode.Never;
|
dataTable.showHeader = ShowHeaderMode.Never;
|
||||||
dataTable.loading = false;
|
dataTable.loading = false;
|
||||||
dataTable.ngOnChanges({
|
dataTable.ngOnChanges({
|
||||||
@ -313,14 +275,12 @@ describe('DataTable', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should never show the header if noPermission is true', () => {
|
it('should never show the header if noPermission is true', () => {
|
||||||
|
|
||||||
dataTable.loading = false;
|
dataTable.loading = false;
|
||||||
dataTable.noPermission = true;
|
dataTable.noPermission = true;
|
||||||
testNotShownHeader(emptyData);
|
testNotShownHeader(emptyData);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should never show the header if loading is true', () => {
|
it('should never show the header if loading is true', () => {
|
||||||
|
|
||||||
dataTable.loading = true;
|
dataTable.loading = true;
|
||||||
testNotShownHeader(emptyData);
|
testNotShownHeader(emptyData);
|
||||||
});
|
});
|
||||||
@ -328,13 +288,7 @@ describe('DataTable', () => {
|
|||||||
|
|
||||||
it('should emit "sorting-changed" DOM event', (done) => {
|
it('should emit "sorting-changed" DOM event', (done) => {
|
||||||
const column = new ObjectDataColumn({ key: 'name', sortable: true, direction: 'asc', sortingKey: 'displayName' });
|
const column = new ObjectDataColumn({ key: 'name', sortable: true, direction: 'asc', sortingKey: 'displayName' });
|
||||||
dataTable.data = new ObjectDataTableAdapter(
|
dataTable.data = new ObjectDataTableAdapter([{ name: '1' }, { name: '2' }], [column]);
|
||||||
[
|
|
||||||
{ name: '1' },
|
|
||||||
{ name: '2' }
|
|
||||||
],
|
|
||||||
[column]
|
|
||||||
);
|
|
||||||
dataTable.data.setSorting(new DataSorting('name', 'desc'));
|
dataTable.data.setSorting(new DataSorting('name', 'desc'));
|
||||||
|
|
||||||
fixture.nativeElement.addEventListener('sorting-changed', (event: CustomEvent) => {
|
fixture.nativeElement.addEventListener('sorting-changed', (event: CustomEvent) => {
|
||||||
@ -346,27 +300,15 @@ describe('DataTable', () => {
|
|||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
dataTable.ngAfterViewInit();
|
dataTable.ngAfterViewInit();
|
||||||
const hedaderColumns = fixture.debugElement.nativeElement.querySelectorAll('.adf-datatable-cell-header-content');
|
const headerColumns = fixture.debugElement.nativeElement.querySelectorAll('.adf-datatable-cell-header-content');
|
||||||
|
|
||||||
hedaderColumns[0].click();
|
headerColumns[0].click();
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should change the rows on changing of the data', () => {
|
it('should change the rows on changing of the data', () => {
|
||||||
const newData = new ObjectDataTableAdapter(
|
const newData = new ObjectDataTableAdapter([{ name: 'TEST' }, { name: 'FAKE' }], [new ObjectDataColumn({ key: 'name' })]);
|
||||||
[
|
dataTable.data = new ObjectDataTableAdapter([{ name: '1' }, { name: '2' }], [new ObjectDataColumn({ key: 'name' })]);
|
||||||
{ name: 'TEST' },
|
|
||||||
{ name: 'FAKE' }
|
|
||||||
],
|
|
||||||
[new ObjectDataColumn({ key: 'name' })]
|
|
||||||
);
|
|
||||||
dataTable.data = new ObjectDataTableAdapter(
|
|
||||||
[
|
|
||||||
{ name: '1' },
|
|
||||||
{ name: '2' }
|
|
||||||
],
|
|
||||||
[new ObjectDataColumn({ key: 'name' })]
|
|
||||||
);
|
|
||||||
|
|
||||||
dataTable.ngOnChanges({
|
dataTable.ngOnChanges({
|
||||||
data: new SimpleChange(null, newData, false)
|
data: new SimpleChange(null, newData, false)
|
||||||
@ -378,16 +320,8 @@ describe('DataTable', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should set rows to the data when rows defined', () => {
|
it('should set rows to the data when rows defined', () => {
|
||||||
const dataRows =
|
const dataRows = [{ name: 'test1' }, { name: 'test2' }, { name: 'test3' }, { name: 'test4' }];
|
||||||
[
|
dataTable.data = new ObjectDataTableAdapter([], [new ObjectDataColumn({ key: 'name' })]);
|
||||||
{ name: 'test1' },
|
|
||||||
{ name: 'test2' },
|
|
||||||
{ name: 'test3' },
|
|
||||||
{ name: 'test4' }
|
|
||||||
];
|
|
||||||
dataTable.data = new ObjectDataTableAdapter([],
|
|
||||||
[new ObjectDataColumn({ key: 'name' })]
|
|
||||||
);
|
|
||||||
|
|
||||||
dataTable.ngOnChanges({
|
dataTable.ngOnChanges({
|
||||||
rows: new SimpleChange(null, dataRows, false)
|
rows: new SimpleChange(null, dataRows, false)
|
||||||
@ -404,12 +338,9 @@ describe('DataTable', () => {
|
|||||||
code: 'Enter',
|
code: 'Enter',
|
||||||
key: 'Enter'
|
key: 'Enter'
|
||||||
} as KeyboardEventInit);
|
} as KeyboardEventInit);
|
||||||
const dataRows =
|
const dataRows = [{ name: 'test1' }, { name: 'test2' }];
|
||||||
[ { name: 'test1'}, { name: 'test2' } ];
|
|
||||||
|
|
||||||
dataTable.data = new ObjectDataTableAdapter([],
|
dataTable.data = new ObjectDataTableAdapter([], [new ObjectDataColumn({ key: 'name' })]);
|
||||||
[new ObjectDataColumn({ key: 'name' })]
|
|
||||||
);
|
|
||||||
|
|
||||||
dataTable.ngOnChanges({
|
dataTable.ngOnChanges({
|
||||||
rows: new SimpleChange(null, dataRows, false)
|
rows: new SimpleChange(null, dataRows, false)
|
||||||
@ -429,13 +360,7 @@ describe('DataTable', () => {
|
|||||||
|
|
||||||
it('should set custom sort order', () => {
|
it('should set custom sort order', () => {
|
||||||
const dataSortObj = new DataSorting('dummyName', 'asc');
|
const dataSortObj = new DataSorting('dummyName', 'asc');
|
||||||
const dataRows =
|
const dataRows = [{ name: 'test1' }, { name: 'test2' }, { name: 'test3' }, { name: 'test4' }];
|
||||||
[
|
|
||||||
{ name: 'test1' },
|
|
||||||
{ name: 'test2' },
|
|
||||||
{ name: 'test3' },
|
|
||||||
{ name: 'test4' }
|
|
||||||
];
|
|
||||||
dataTable.sorting = ['dummyName', 'asc'];
|
dataTable.sorting = ['dummyName', 'asc'];
|
||||||
dataTable.ngOnChanges({
|
dataTable.ngOnChanges({
|
||||||
rows: new SimpleChange(null, dataRows, false)
|
rows: new SimpleChange(null, dataRows, false)
|
||||||
@ -448,13 +373,7 @@ describe('DataTable', () => {
|
|||||||
it('should reset selection on mode change', () => {
|
it('should reset selection on mode change', () => {
|
||||||
spyOn(dataTable, 'resetSelection').and.callThrough();
|
spyOn(dataTable, 'resetSelection').and.callThrough();
|
||||||
|
|
||||||
dataTable.data = new ObjectDataTableAdapter(
|
dataTable.data = new ObjectDataTableAdapter([{ name: '1' }, { name: '2' }], [new ObjectDataColumn({ key: 'name' })]);
|
||||||
[
|
|
||||||
{ name: '1' },
|
|
||||||
{ name: '2' }
|
|
||||||
],
|
|
||||||
[new ObjectDataColumn({ key: 'name' })]
|
|
||||||
);
|
|
||||||
const rows = dataTable.data.getRows();
|
const rows = dataTable.data.getRows();
|
||||||
rows[0].isSelected = true;
|
rows[0].isSelected = true;
|
||||||
rows[1].isSelected = true;
|
rows[1].isSelected = true;
|
||||||
@ -470,14 +389,8 @@ describe('DataTable', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should select the row where isSelected is true', () => {
|
it('should select the row where isSelected is true', () => {
|
||||||
dataTable.rows = [
|
dataTable.rows = [{ name: 'TEST1' }, { name: 'FAKE2' }, { name: 'TEST2', isSelected: true }, { name: 'FAKE2' }];
|
||||||
{ name: 'TEST1' },
|
dataTable.data = new ObjectDataTableAdapter([], [new ObjectDataColumn({ key: 'name' })]);
|
||||||
{ name: 'FAKE2' },
|
|
||||||
{ name: 'TEST2', isSelected: true },
|
|
||||||
{ name: 'FAKE2' }];
|
|
||||||
dataTable.data = new ObjectDataTableAdapter([],
|
|
||||||
[new ObjectDataColumn({ key: 'name' })]
|
|
||||||
);
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
const rows = dataTable.data.getRows();
|
const rows = dataTable.data.getRows();
|
||||||
expect(rows[0].isSelected).toBeFalsy();
|
expect(rows[0].isSelected).toBeFalsy();
|
||||||
@ -487,15 +400,8 @@ describe('DataTable', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should not select any row when isSelected is not defined', () => {
|
it('should not select any row when isSelected is not defined', () => {
|
||||||
const dataRows =
|
const dataRows = [{ name: 'TEST1' }, { name: 'FAKE2' }, { name: 'TEST2' }];
|
||||||
[
|
dataTable.data = new ObjectDataTableAdapter(dataRows, [new ObjectDataColumn({ key: 'name' })]);
|
||||||
{ name: 'TEST1' },
|
|
||||||
{ name: 'FAKE2' },
|
|
||||||
{ name: 'TEST2' }
|
|
||||||
];
|
|
||||||
dataTable.data = new ObjectDataTableAdapter(dataRows,
|
|
||||||
[new ObjectDataColumn({ key: 'name' })]
|
|
||||||
);
|
|
||||||
|
|
||||||
dataTable.ngOnChanges({
|
dataTable.ngOnChanges({
|
||||||
rows: new SimpleChange(null, dataRows, false)
|
rows: new SimpleChange(null, dataRows, false)
|
||||||
@ -509,46 +415,34 @@ describe('DataTable', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should select only one row with [single] selection mode', (done) => {
|
it('should select only one row with [single] selection mode', (done) => {
|
||||||
const rows = testIfRowIsSelected([
|
const rows = testIfRowIsSelected([{ name: '1', isSelected: true }, { name: '2' }], done);
|
||||||
{ name: '1', isSelected: true },
|
|
||||||
{ name: '2' }
|
|
||||||
], done);
|
|
||||||
dataTable.onRowClick(rows[1], new MouseEvent('click'));
|
dataTable.onRowClick(rows[1], new MouseEvent('click'));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should select only one row with [single] selection mode and key modifier', (done) => {
|
it('should select only one row with [single] selection mode and key modifier', (done) => {
|
||||||
const rows = testIfRowIsSelected([
|
const rows = testIfRowIsSelected([{ name: '1', isSelected: true }, { name: '2' }], done);
|
||||||
{ name: '1', isSelected: true },
|
dataTable.onRowClick(
|
||||||
{ name: '2' }
|
rows[1],
|
||||||
], done);
|
new MouseEvent('click', {
|
||||||
dataTable.onRowClick(rows[1], new MouseEvent('click', {
|
|
||||||
metaKey: true
|
metaKey: true
|
||||||
}));
|
})
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should select only one row with [single] selection mode pressing enter key', () => {
|
it('should select only one row with [single] selection mode pressing enter key', () => {
|
||||||
const rows = testIfRowIsSelected([
|
const rows = testIfRowIsSelected([{ name: '1' }, { name: '2' }]);
|
||||||
{ name: '1' },
|
dataTable.onEnterKeyPressed(rows[0], new KeyboardEvent('enter'));
|
||||||
{ name: '2' }
|
|
||||||
]);
|
|
||||||
dataTable.onEnterKeyPressed(rows[0], null);
|
|
||||||
expect(rows[0].isSelected).toBeTruthy();
|
expect(rows[0].isSelected).toBeTruthy();
|
||||||
expect(rows[1].isSelected).toBeFalsy();
|
expect(rows[1].isSelected).toBeFalsy();
|
||||||
|
|
||||||
dataTable.onEnterKeyPressed(rows[1], null);
|
dataTable.onEnterKeyPressed(rows[1], new KeyboardEvent('enter'));
|
||||||
expect(rows[0].isSelected).toBeFalsy();
|
expect(rows[0].isSelected).toBeFalsy();
|
||||||
expect(rows[1].isSelected).toBeTruthy();
|
expect(rows[1].isSelected).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should select multiple rows with [multiple] selection mode pressing enter key', () => {
|
it('should select multiple rows with [multiple] selection mode pressing enter key', () => {
|
||||||
dataTable.selectionMode = 'multiple';
|
dataTable.selectionMode = 'multiple';
|
||||||
dataTable.data = new ObjectDataTableAdapter(
|
dataTable.data = new ObjectDataTableAdapter([{ name: '1' }, { name: '2' }], [new ObjectDataColumn({ key: 'name' })]);
|
||||||
[
|
|
||||||
{ name: '1' },
|
|
||||||
{ name: '2' }
|
|
||||||
],
|
|
||||||
[new ObjectDataColumn({ key: 'name' })]
|
|
||||||
);
|
|
||||||
const rows = dataTable.data.getRows();
|
const rows = dataTable.data.getRows();
|
||||||
|
|
||||||
const event = new KeyboardEvent('enter', {
|
const event = new KeyboardEvent('enter', {
|
||||||
@ -565,13 +459,7 @@ describe('DataTable', () => {
|
|||||||
|
|
||||||
it('should unselect the row with [single] selection mode', (done) => {
|
it('should unselect the row with [single] selection mode', (done) => {
|
||||||
dataTable.selectionMode = 'single';
|
dataTable.selectionMode = 'single';
|
||||||
dataTable.data = new ObjectDataTableAdapter(
|
dataTable.data = new ObjectDataTableAdapter([{ name: '1' }, { name: '2' }], [new ObjectDataColumn({ key: 'name' })]);
|
||||||
[
|
|
||||||
{name: '1'},
|
|
||||||
{ name: '2' }
|
|
||||||
],
|
|
||||||
[new ObjectDataColumn({ key: 'name' })]
|
|
||||||
);
|
|
||||||
const rows = dataTable.data.getRows();
|
const rows = dataTable.data.getRows();
|
||||||
dataTable.ngOnChanges({});
|
dataTable.ngOnChanges({});
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
@ -590,10 +478,7 @@ describe('DataTable', () => {
|
|||||||
|
|
||||||
it('should unselect the row with [multiple] selection mode and modifier key', (done) => {
|
it('should unselect the row with [multiple] selection mode and modifier key', (done) => {
|
||||||
dataTable.selectionMode = 'multiple';
|
dataTable.selectionMode = 'multiple';
|
||||||
dataTable.data = new ObjectDataTableAdapter(
|
dataTable.data = new ObjectDataTableAdapter([{ name: '1', isSelected: true }], [new ObjectDataColumn({ key: 'name' })]);
|
||||||
[{ name: '1', isSelected: true }],
|
|
||||||
[new ObjectDataColumn({ key: 'name' })]
|
|
||||||
);
|
|
||||||
const rows = dataTable.data.getRows();
|
const rows = dataTable.data.getRows();
|
||||||
rows[0].isSelected = true;
|
rows[0].isSelected = true;
|
||||||
|
|
||||||
@ -613,9 +498,7 @@ describe('DataTable', () => {
|
|||||||
|
|
||||||
it('should unselect the row searching it by row id, when row id is defined', () => {
|
it('should unselect the row searching it by row id, when row id is defined', () => {
|
||||||
const findSelectionByIdSpy = spyOn(dataTable, 'findSelectionById');
|
const findSelectionByIdSpy = spyOn(dataTable, 'findSelectionById');
|
||||||
dataTable.data = new ObjectDataTableAdapter([],
|
dataTable.data = new ObjectDataTableAdapter([], [new ObjectDataColumn({ key: 'name' })]);
|
||||||
[new ObjectDataColumn({ key: 'name' })]
|
|
||||||
);
|
|
||||||
|
|
||||||
const fakeDataRows = [new FakeDataRow(), new FakeDataRow()];
|
const fakeDataRows = [new FakeDataRow(), new FakeDataRow()];
|
||||||
fakeDataRows[0].id = 'fakeRowId';
|
fakeDataRows[0].id = 'fakeRowId';
|
||||||
@ -633,9 +516,7 @@ describe('DataTable', () => {
|
|||||||
|
|
||||||
it('should unselect the row by searching for the exact same reference of it (indexOf), when row id is not defined ', () => {
|
it('should unselect the row by searching for the exact same reference of it (indexOf), when row id is not defined ', () => {
|
||||||
const findSelectionByIdSpy = spyOn(dataTable, 'findSelectionById');
|
const findSelectionByIdSpy = spyOn(dataTable, 'findSelectionById');
|
||||||
dataTable.data = new ObjectDataTableAdapter([],
|
dataTable.data = new ObjectDataTableAdapter([], [new ObjectDataColumn({ key: 'name' })]);
|
||||||
[new ObjectDataColumn({ key: 'name' })]
|
|
||||||
);
|
|
||||||
|
|
||||||
const fakeDataRows = [new FakeDataRow(), new FakeDataRow()];
|
const fakeDataRows = [new FakeDataRow(), new FakeDataRow()];
|
||||||
dataTable.data.setRows(fakeDataRows);
|
dataTable.data.setRows(fakeDataRows);
|
||||||
@ -652,13 +533,7 @@ describe('DataTable', () => {
|
|||||||
|
|
||||||
it('should select multiple rows with [multiple] selection mode and modifier key', (done) => {
|
it('should select multiple rows with [multiple] selection mode and modifier key', (done) => {
|
||||||
dataTable.selectionMode = 'multiple';
|
dataTable.selectionMode = 'multiple';
|
||||||
dataTable.data = new ObjectDataTableAdapter(
|
dataTable.data = new ObjectDataTableAdapter([{ name: '1', isSelected: true }, { name: '2' }], [new ObjectDataColumn({ key: 'name' })]);
|
||||||
[
|
|
||||||
{ name: '1', isSelected: true },
|
|
||||||
{ name: '2' }
|
|
||||||
],
|
|
||||||
[new ObjectDataColumn({ key: 'name' })]
|
|
||||||
);
|
|
||||||
const rows = dataTable.data.getRows();
|
const rows = dataTable.data.getRows();
|
||||||
rows[0].isSelected = true;
|
rows[0].isSelected = true;
|
||||||
|
|
||||||
@ -678,12 +553,7 @@ describe('DataTable', () => {
|
|||||||
|
|
||||||
it('should put actions menu to the right by default', () => {
|
it('should put actions menu to the right by default', () => {
|
||||||
dataTable.data = new ObjectDataTableAdapter(
|
dataTable.data = new ObjectDataTableAdapter(
|
||||||
[
|
[{ name: '1' }, { name: '2' }, { name: '3' }, { name: '4' }],
|
||||||
{ name: '1' },
|
|
||||||
{ name: '2' },
|
|
||||||
{ name: '3' },
|
|
||||||
{ name: '4' }
|
|
||||||
],
|
|
||||||
[new ObjectDataColumn({ key: 'name' })]
|
[new ObjectDataColumn({ key: 'name' })]
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -696,12 +566,7 @@ describe('DataTable', () => {
|
|||||||
|
|
||||||
it('should put actions menu to the left', () => {
|
it('should put actions menu to the left', () => {
|
||||||
dataTable.data = new ObjectDataTableAdapter(
|
dataTable.data = new ObjectDataTableAdapter(
|
||||||
[
|
[{ name: '1' }, { name: '2' }, { name: '3' }, { name: '4' }],
|
||||||
{ name: '1' },
|
|
||||||
{ name: '2' },
|
|
||||||
{ name: '3' },
|
|
||||||
{ name: '4' }
|
|
||||||
],
|
|
||||||
[new ObjectDataColumn({ key: 'name' })]
|
[new ObjectDataColumn({ key: 'name' })]
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -779,8 +644,7 @@ describe('DataTable', () => {
|
|||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
dataTable.onRowClick(row, new MouseEvent('click'));
|
dataTable.onRowClick(row, new MouseEvent('click'));
|
||||||
}
|
}, 260);
|
||||||
, 260);
|
|
||||||
|
|
||||||
tick(510);
|
tick(510);
|
||||||
|
|
||||||
@ -834,50 +698,37 @@ describe('DataTable', () => {
|
|||||||
it('should not sort upon clicking non-sortable column header', () => {
|
it('should not sort upon clicking non-sortable column header', () => {
|
||||||
dataTable.data = new ObjectDataTableAdapter(
|
dataTable.data = new ObjectDataTableAdapter(
|
||||||
[{ name: '1' }, { name: '2' }],
|
[{ name: '1' }, { name: '2' }],
|
||||||
[
|
[new ObjectDataColumn({ key: 'name', sortable: false }), new ObjectDataColumn({ key: 'other', sortable: true })]
|
||||||
new ObjectDataColumn({ key: 'name', sortable: false }),
|
|
||||||
new ObjectDataColumn({ key: 'other', sortable: true })
|
|
||||||
]
|
|
||||||
);
|
);
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
dataTable.ngAfterViewInit();
|
dataTable.ngAfterViewInit();
|
||||||
const adapter = dataTable.data;
|
const adapter = dataTable.data;
|
||||||
spyOn(adapter, 'setSorting').and.callThrough();
|
spyOn(adapter, 'setSorting').and.callThrough();
|
||||||
|
|
||||||
const hedaderColumns = fixture.debugElement.nativeElement.querySelectorAll('.adf-datatable-cell-header-content');
|
const headerColumns = fixture.debugElement.nativeElement.querySelectorAll('.adf-datatable-cell-header-content');
|
||||||
hedaderColumns[0].click();
|
headerColumns[0].click();
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
expect(adapter.setSorting).not.toHaveBeenCalled();
|
expect(adapter.setSorting).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should set sorting upon column header clicked', () => {
|
it('should set sorting upon column header clicked', () => {
|
||||||
dataTable.data = new ObjectDataTableAdapter(
|
dataTable.data = new ObjectDataTableAdapter([{ name: '1' }], [new ObjectDataColumn({ key: 'column_1', sortable: true })]);
|
||||||
[{ name: '1' }],
|
|
||||||
[
|
|
||||||
new ObjectDataColumn({ key: 'column_1', sortable: true })
|
|
||||||
]
|
|
||||||
);
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
dataTable.ngAfterViewInit();
|
dataTable.ngAfterViewInit();
|
||||||
const adapter = dataTable.data;
|
const adapter = dataTable.data;
|
||||||
spyOn(adapter, 'setSorting').and.callThrough();
|
spyOn(adapter, 'setSorting').and.callThrough();
|
||||||
spyOn(dataTable.data, 'getSorting').and.returnValue(new DataSorting('column_1', 'desc'));
|
spyOn(dataTable.data, 'getSorting').and.returnValue(new DataSorting('column_1', 'desc'));
|
||||||
|
|
||||||
const hedaderColumns = fixture.debugElement.nativeElement.querySelectorAll('.adf-datatable-cell-header-content');
|
const headerColumns = fixture.debugElement.nativeElement.querySelectorAll('.adf-datatable-cell-header-content');
|
||||||
hedaderColumns[0].click();
|
headerColumns[0].click();
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
expect(adapter.setSorting).toHaveBeenCalledWith(new DataSorting('column_1', 'asc'));
|
expect(adapter.setSorting).toHaveBeenCalledWith(new DataSorting('column_1', 'asc'));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should invert sorting upon column header clicked', () => {
|
it('should invert sorting upon column header clicked', () => {
|
||||||
dataTable.data = new ObjectDataTableAdapter(
|
dataTable.data = new ObjectDataTableAdapter([{ name: '1' }], [new ObjectDataColumn({ key: 'column_1', sortable: true })]);
|
||||||
[{ name: '1' }],
|
|
||||||
[
|
|
||||||
new ObjectDataColumn({ key: 'column_1', sortable: true })
|
|
||||||
]
|
|
||||||
);
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
dataTable.ngAfterViewInit();
|
dataTable.ngAfterViewInit();
|
||||||
|
|
||||||
@ -885,17 +736,17 @@ describe('DataTable', () => {
|
|||||||
const sorting = new DataSorting('column_1', 'asc');
|
const sorting = new DataSorting('column_1', 'asc');
|
||||||
spyOn(adapter, 'setSorting').and.callThrough();
|
spyOn(adapter, 'setSorting').and.callThrough();
|
||||||
spyOn(adapter, 'getSorting').and.returnValue(sorting);
|
spyOn(adapter, 'getSorting').and.returnValue(sorting);
|
||||||
const hedaderColumns = fixture.debugElement.nativeElement.querySelectorAll('.adf-datatable-cell-header-content');
|
const headerColumns = fixture.debugElement.nativeElement.querySelectorAll('.adf-datatable-cell-header-content');
|
||||||
|
|
||||||
// // check first click on the header
|
// // check first click on the header
|
||||||
hedaderColumns[0].click();
|
headerColumns[0].click();
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
expect(adapter.setSorting).toHaveBeenCalledWith(new DataSorting('column_1', 'desc'));
|
expect(adapter.setSorting).toHaveBeenCalledWith(new DataSorting('column_1', 'desc'));
|
||||||
|
|
||||||
// check second click on the header
|
// check second click on the header
|
||||||
sorting.direction = 'desc';
|
sorting.direction = 'desc';
|
||||||
hedaderColumns[0].click();
|
headerColumns[0].click();
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
expect(adapter.setSorting).toHaveBeenCalledWith(new DataSorting('column_1', 'asc'));
|
expect(adapter.setSorting).toHaveBeenCalledWith(new DataSorting('column_1', 'asc'));
|
||||||
@ -904,18 +755,15 @@ describe('DataTable', () => {
|
|||||||
it('should indicate column that has sorting applied', () => {
|
it('should indicate column that has sorting applied', () => {
|
||||||
dataTable.data = new ObjectDataTableAdapter(
|
dataTable.data = new ObjectDataTableAdapter(
|
||||||
[{ name: '1' }, { name: '2' }],
|
[{ name: '1' }, { name: '2' }],
|
||||||
[
|
[new ObjectDataColumn({ key: 'name', sortable: true }), new ObjectDataColumn({ key: 'other', sortable: true })]
|
||||||
new ObjectDataColumn({ key: 'name', sortable: true }),
|
|
||||||
new ObjectDataColumn({ key: 'other', sortable: true })
|
|
||||||
]
|
|
||||||
);
|
);
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
dataTable.ngAfterViewInit();
|
dataTable.ngAfterViewInit();
|
||||||
|
|
||||||
const [col1, col2] = dataTable.getSortableColumns();
|
const [col1, col2] = dataTable.getSortableColumns();
|
||||||
const hedaderColumns = fixture.debugElement.nativeElement.querySelectorAll('.adf-datatable-cell-header-content');
|
const headerColumns = fixture.debugElement.nativeElement.querySelectorAll('.adf-datatable-cell-header-content');
|
||||||
|
|
||||||
hedaderColumns[1].click();
|
headerColumns[1].click();
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
expect(dataTable.isColumnSortActive(col1)).toBe(false);
|
expect(dataTable.isColumnSortActive(col1)).toBe(false);
|
||||||
@ -925,10 +773,7 @@ describe('DataTable', () => {
|
|||||||
it('should return false for columns that have no sorting', () => {
|
it('should return false for columns that have no sorting', () => {
|
||||||
dataTable.data = new ObjectDataTableAdapter(
|
dataTable.data = new ObjectDataTableAdapter(
|
||||||
[{ name: '1' }, { name: '2' }],
|
[{ name: '1' }, { name: '2' }],
|
||||||
[
|
[new ObjectDataColumn({ key: 'name', sortable: false }), new ObjectDataColumn({ key: 'other', sortable: false })]
|
||||||
new ObjectDataColumn({ key: 'name', sortable: false }),
|
|
||||||
new ObjectDataColumn({ key: 'other', sortable: false })
|
|
||||||
]
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const [col1, col2] = dataTable.getSortableColumns();
|
const [col1, col2] = dataTable.getSortableColumns();
|
||||||
@ -977,10 +822,7 @@ describe('DataTable', () => {
|
|||||||
it('should have indeterminate state for "select all" when at least 1 row is selected or not all rows', () => {
|
it('should have indeterminate state for "select all" when at least 1 row is selected or not all rows', () => {
|
||||||
dataTable.data = new ObjectDataTableAdapter(
|
dataTable.data = new ObjectDataTableAdapter(
|
||||||
[{ name: '1' }, { name: '2' }],
|
[{ name: '1' }, { name: '2' }],
|
||||||
[
|
[new ObjectDataColumn({ key: 'name', sortable: false }), new ObjectDataColumn({ key: 'other', sortable: false })]
|
||||||
new ObjectDataColumn({ key: 'name', sortable: false }),
|
|
||||||
new ObjectDataColumn({ key: 'other', sortable: false })
|
|
||||||
]
|
|
||||||
);
|
);
|
||||||
const rows = dataTable.data.getRows();
|
const rows = dataTable.data.getRows();
|
||||||
|
|
||||||
@ -1186,12 +1028,7 @@ describe('DataTable', () => {
|
|||||||
|
|
||||||
it('should enable sticky header if the stickyHeader is set to true and header is visible', () => {
|
it('should enable sticky header if the stickyHeader is set to true and header is visible', () => {
|
||||||
dataTable.data = new ObjectDataTableAdapter(
|
dataTable.data = new ObjectDataTableAdapter(
|
||||||
[
|
[{ name: '1' }, { name: '2' }, { name: '3' }, { name: '4' }],
|
||||||
{ name: '1' },
|
|
||||||
{ name: '2' },
|
|
||||||
{ name: '3' },
|
|
||||||
{ name: '4' }
|
|
||||||
],
|
|
||||||
[new ObjectDataColumn({ key: 'name', title: 'Name' })]
|
[new ObjectDataColumn({ key: 'name', title: 'Name' })]
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -1204,12 +1041,7 @@ describe('DataTable', () => {
|
|||||||
|
|
||||||
it('should disable sticky header if component is loading', () => {
|
it('should disable sticky header if component is loading', () => {
|
||||||
dataTable.data = new ObjectDataTableAdapter(
|
dataTable.data = new ObjectDataTableAdapter(
|
||||||
[
|
[{ name: '1' }, { name: '2' }, { name: '3' }, { name: '4' }],
|
||||||
{ name: '1' },
|
|
||||||
{ name: '2' },
|
|
||||||
{ name: '3' },
|
|
||||||
{ name: '4' }
|
|
||||||
],
|
|
||||||
[new ObjectDataColumn({ key: 'name', title: 'Name' })]
|
[new ObjectDataColumn({ key: 'name', title: 'Name' })]
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -1222,12 +1054,7 @@ describe('DataTable', () => {
|
|||||||
|
|
||||||
it('should disable sticky header if user has no permissions', () => {
|
it('should disable sticky header if user has no permissions', () => {
|
||||||
dataTable.data = new ObjectDataTableAdapter(
|
dataTable.data = new ObjectDataTableAdapter(
|
||||||
[
|
[{ name: '1' }, { name: '2' }, { name: '3' }, { name: '4' }],
|
||||||
{ name: '1' },
|
|
||||||
{ name: '2' },
|
|
||||||
{ name: '3' },
|
|
||||||
{ name: '4' }
|
|
||||||
],
|
|
||||||
[new ObjectDataColumn({ key: 'name', title: 'Name' })]
|
[new ObjectDataColumn({ key: 'name', title: 'Name' })]
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -1239,10 +1066,7 @@ describe('DataTable', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should disable sticky header if user has no content', () => {
|
it('should disable sticky header if user has no content', () => {
|
||||||
dataTable.data = new ObjectDataTableAdapter(
|
dataTable.data = new ObjectDataTableAdapter([], [new ObjectDataColumn({ key: 'name', title: 'Name' })]);
|
||||||
[],
|
|
||||||
[new ObjectDataColumn({ key: 'name', title: 'Name' })]
|
|
||||||
);
|
|
||||||
|
|
||||||
dataTable.stickyHeader = true;
|
dataTable.stickyHeader = true;
|
||||||
dataTable.loading = false;
|
dataTable.loading = false;
|
||||||
@ -1252,9 +1076,11 @@ describe('DataTable', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should be able to define values using the resolver function', () => {
|
it('should be able to define values using the resolver function', () => {
|
||||||
dataTable.data = new ObjectDataTableAdapter([
|
dataTable.data = new ObjectDataTableAdapter(
|
||||||
|
[
|
||||||
{ id: 1, firstName: 'foo', lastName: 'bar' },
|
{ id: 1, firstName: 'foo', lastName: 'bar' },
|
||||||
{ id: 2, firstName: 'bar', lastName: 'baz' }],
|
{ id: 2, firstName: 'bar', lastName: 'baz' }
|
||||||
|
],
|
||||||
[new ObjectDataColumn({ key: 'id' }), new ObjectDataColumn({ key: 'name' })]
|
[new ObjectDataColumn({ key: 'id' }), new ObjectDataColumn({ key: 'name' })]
|
||||||
);
|
);
|
||||||
spyOn(dataTable, 'resolverFn').and.callFake(resolverFn);
|
spyOn(dataTable, 'resolverFn').and.callFake(resolverFn);
|
||||||
@ -1276,10 +1102,7 @@ describe('DataTable', () => {
|
|||||||
it('should update data columns when columns input changes', () => {
|
it('should update data columns when columns input changes', () => {
|
||||||
const existingDataColumnsSchema = [new ObjectDataColumn({ key: 'id' })];
|
const existingDataColumnsSchema = [new ObjectDataColumn({ key: 'id' })];
|
||||||
const existingData = [{ id: 'fake-data' }];
|
const existingData = [{ id: 'fake-data' }];
|
||||||
dataTable.data = new ObjectDataTableAdapter(
|
dataTable.data = new ObjectDataTableAdapter(existingData, existingDataColumnsSchema);
|
||||||
existingData,
|
|
||||||
existingDataColumnsSchema
|
|
||||||
);
|
|
||||||
|
|
||||||
const newDataColumnsSchema = { key: 'new-column' };
|
const newDataColumnsSchema = { key: 'new-column' };
|
||||||
const columnsChange = new SimpleChange(null, [newDataColumnsSchema], false);
|
const columnsChange = new SimpleChange(null, [newDataColumnsSchema], false);
|
||||||
@ -1290,14 +1113,12 @@ describe('DataTable', () => {
|
|||||||
|
|
||||||
it('should render the custom column header', () => {
|
it('should render the custom column header', () => {
|
||||||
const customHeader = TestBed.createComponent(CustomColumnHeaderComponent).componentInstance.templateRef;
|
const customHeader = TestBed.createComponent(CustomColumnHeaderComponent).componentInstance.templateRef;
|
||||||
dataTable.data = new ObjectDataTableAdapter([
|
dataTable.data = new ObjectDataTableAdapter(
|
||||||
|
[
|
||||||
{ id: 1, name: 'foo' },
|
{ id: 1, name: 'foo' },
|
||||||
{ id: 2, name: 'bar' }
|
{ id: 2, name: 'bar' }
|
||||||
],
|
],
|
||||||
[
|
[new ObjectDataColumn({ key: 'id', title: 'ID' }), new ObjectDataColumn({ key: 'name', title: 'Name', header: customHeader })]
|
||||||
new ObjectDataColumn({ key: 'id', title: 'ID' }),
|
|
||||||
new ObjectDataColumn({ key: 'name', title: 'Name', header: customHeader })
|
|
||||||
]
|
|
||||||
);
|
);
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
@ -1309,25 +1130,28 @@ describe('DataTable', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should set isContextMenuSource to true for row whose id matches selectedRowId', () => {
|
it('should set isContextMenuSource to true for row whose id matches selectedRowId', () => {
|
||||||
const rows = [{
|
const rows = [
|
||||||
|
{
|
||||||
id: '1234',
|
id: '1234',
|
||||||
isContextMenuSource: false
|
isContextMenuSource: false
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
id: '2345',
|
id: '2345',
|
||||||
isContextMenuSource: false
|
isContextMenuSource: false
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
id: '3456',
|
id: '3456',
|
||||||
isContextMenuSource: false
|
isContextMenuSource: false
|
||||||
}] as DataRow[];
|
}
|
||||||
|
] as DataRow[];
|
||||||
const row = {
|
const row = {
|
||||||
id: '2345',
|
id: '2345',
|
||||||
isContextMenuSource: false
|
isContextMenuSource: false
|
||||||
} as DataRow;
|
} as DataRow;
|
||||||
dataTable.data = new ObjectDataTableAdapter(
|
dataTable.data = new ObjectDataTableAdapter(rows, [
|
||||||
rows,
|
new ObjectDataColumn({ key: 'id' }),
|
||||||
[new ObjectDataColumn({ key: 'id' }),
|
new ObjectDataColumn({ key: 'isContextMenuSource' })
|
||||||
new ObjectDataColumn({ key: 'isContextMenuSource' })]
|
]);
|
||||||
);
|
|
||||||
|
|
||||||
dataTable.markRowAsContextMenuSource(row);
|
dataTable.markRowAsContextMenuSource(row);
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
@ -1339,10 +1163,7 @@ describe('DataTable', () => {
|
|||||||
it('should select the row, regardless of where the user clicks in the row.', async () => {
|
it('should select the row, regardless of where the user clicks in the row.', async () => {
|
||||||
dataTable.selectionMode = 'single';
|
dataTable.selectionMode = 'single';
|
||||||
const dataRows = [{ id: 0 }, { id: 1 }];
|
const dataRows = [{ id: 0 }, { id: 1 }];
|
||||||
dataTable.data = new ObjectDataTableAdapter(
|
dataTable.data = new ObjectDataTableAdapter(dataRows, [new ObjectDataColumn({ key: 'id' })]);
|
||||||
dataRows,
|
|
||||||
[new ObjectDataColumn({ key: 'id' })]
|
|
||||||
);
|
|
||||||
dataTable.ngOnChanges({
|
dataTable.ngOnChanges({
|
||||||
rows: new SimpleChange(null, dataRows, false)
|
rows: new SimpleChange(null, dataRows, false)
|
||||||
});
|
});
|
||||||
@ -1377,7 +1198,6 @@ describe('DataTable', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('Accesibility', () => {
|
describe('Accesibility', () => {
|
||||||
|
|
||||||
let fixture: ComponentFixture<DataTableComponent>;
|
let fixture: ComponentFixture<DataTableComponent>;
|
||||||
let dataTable: DataTableComponent;
|
let dataTable: DataTableComponent;
|
||||||
let element: any;
|
let element: any;
|
||||||
@ -1385,10 +1205,7 @@ describe('Accesibility', () => {
|
|||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [
|
imports: [TranslateModule.forRoot(), CoreTestingModule],
|
||||||
TranslateModule.forRoot(),
|
|
||||||
CoreTestingModule
|
|
||||||
],
|
|
||||||
declarations: [CustomColumnTemplateComponent],
|
declarations: [CustomColumnTemplateComponent],
|
||||||
schemas: [NO_ERRORS_SCHEMA]
|
schemas: [NO_ERRORS_SCHEMA]
|
||||||
});
|
});
|
||||||
@ -1403,17 +1220,8 @@ describe('Accesibility', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should have accessibility tags', () => {
|
it('should have accessibility tags', () => {
|
||||||
|
const dataRows = [{ name: 'test1' }, { name: 'test2' }, { name: 'test3' }, { name: 'test4' }];
|
||||||
const dataRows =
|
dataTable.data = new ObjectDataTableAdapter([], [new ObjectDataColumn({ key: 'name' })]);
|
||||||
[
|
|
||||||
{ name: 'test1' },
|
|
||||||
{ name: 'test2' },
|
|
||||||
{ name: 'test3' },
|
|
||||||
{ name: 'test4' }
|
|
||||||
];
|
|
||||||
dataTable.data = new ObjectDataTableAdapter([],
|
|
||||||
[new ObjectDataColumn({ key: 'name' })]
|
|
||||||
);
|
|
||||||
|
|
||||||
dataTable.ngOnChanges({
|
dataTable.ngOnChanges({
|
||||||
rows: new SimpleChange(null, dataRows, false)
|
rows: new SimpleChange(null, dataRows, false)
|
||||||
@ -1475,9 +1283,7 @@ describe('Accesibility', () => {
|
|||||||
keyCode: 38
|
keyCode: 38
|
||||||
} as KeyboardEventInit);
|
} as KeyboardEventInit);
|
||||||
dataRows = [{ name: 'test1' }, { name: 'test2' }];
|
dataRows = [{ name: 'test1' }, { name: 'test2' }];
|
||||||
dataTable.data = new ObjectDataTableAdapter([],
|
dataTable.data = new ObjectDataTableAdapter([], [new ObjectDataColumn({ key: 'name' })]);
|
||||||
[new ObjectDataColumn({key: 'name'})]
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should focus next row on ArrowDown event', () => {
|
it('should focus next row on ArrowDown event', () => {
|
||||||
@ -1497,10 +1303,10 @@ describe('Accesibility', () => {
|
|||||||
const rowElement = document.querySelectorAll('.adf-datatable-body .adf-datatable-row')[0];
|
const rowElement = document.querySelectorAll('.adf-datatable-body .adf-datatable-row')[0];
|
||||||
const rowCellElement = rowElement.querySelector('.adf-datatable-cell');
|
const rowCellElement = rowElement.querySelector('.adf-datatable-cell');
|
||||||
|
|
||||||
rowCellElement.dispatchEvent(new MouseEvent('click', {bubbles: true}));
|
rowCellElement?.dispatchEvent(new MouseEvent('click', { bubbles: true }));
|
||||||
fixture.debugElement.nativeElement.dispatchEvent(event);
|
fixture.debugElement.nativeElement.dispatchEvent(event);
|
||||||
|
|
||||||
expect(document.activeElement.getAttribute('data-automation-id')).toBe('datatable-row-1');
|
expect(document.activeElement?.getAttribute('data-automation-id')).toBe('datatable-row-1');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should focus previous row on ArrowUp event', () => {
|
it('should focus previous row on ArrowUp event', () => {
|
||||||
@ -1514,10 +1320,10 @@ describe('Accesibility', () => {
|
|||||||
const rowElement = document.querySelectorAll('.adf-datatable-body .adf-datatable-row')[1];
|
const rowElement = document.querySelectorAll('.adf-datatable-body .adf-datatable-row')[1];
|
||||||
const rowCellElement = rowElement.querySelector('.adf-datatable-cell');
|
const rowCellElement = rowElement.querySelector('.adf-datatable-cell');
|
||||||
|
|
||||||
rowCellElement.dispatchEvent(new MouseEvent('click', {bubbles: true}));
|
rowCellElement?.dispatchEvent(new MouseEvent('click', { bubbles: true }));
|
||||||
fixture.debugElement.nativeElement.dispatchEvent(event);
|
fixture.debugElement.nativeElement.dispatchEvent(event);
|
||||||
|
|
||||||
expect(document.activeElement.getAttribute('data-automation-id')).toBe('datatable-row-0');
|
expect(document.activeElement?.getAttribute('data-automation-id')).toBe('datatable-row-0');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should select header row when `showHeader` is `Always`', () => {
|
it('should select header row when `showHeader` is `Always`', () => {
|
||||||
@ -1531,12 +1337,12 @@ describe('Accesibility', () => {
|
|||||||
dataTable.ngAfterViewInit();
|
dataTable.ngAfterViewInit();
|
||||||
|
|
||||||
const rowElement = document.querySelector('.adf-datatable-row[data-automation-id="datatable-row-0"]');
|
const rowElement = document.querySelector('.adf-datatable-row[data-automation-id="datatable-row-0"]');
|
||||||
const rowCellElement = rowElement.querySelector('.adf-datatable-cell');
|
const rowCellElement = rowElement?.querySelector('.adf-datatable-cell');
|
||||||
|
|
||||||
rowCellElement.dispatchEvent(new MouseEvent('click', {bubbles: true}));
|
rowCellElement?.dispatchEvent(new MouseEvent('click', { bubbles: true }));
|
||||||
fixture.debugElement.nativeElement.dispatchEvent(event);
|
fixture.debugElement.nativeElement.dispatchEvent(event);
|
||||||
|
|
||||||
expect(document.activeElement.getAttribute('data-automation-id')).toBe('datatable-row-header');
|
expect(document.activeElement?.getAttribute('data-automation-id')).toBe('datatable-row-header');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not select header row when `showHeader` is `Never`', () => {
|
it('should not select header row when `showHeader` is `Never`', () => {
|
||||||
@ -1550,12 +1356,12 @@ describe('Accesibility', () => {
|
|||||||
dataTable.ngAfterViewInit();
|
dataTable.ngAfterViewInit();
|
||||||
|
|
||||||
const rowElement = document.querySelector('.adf-datatable-row[data-automation-id="datatable-row-0"]');
|
const rowElement = document.querySelector('.adf-datatable-row[data-automation-id="datatable-row-0"]');
|
||||||
const rowCellElement = rowElement.querySelector('.adf-datatable-cell');
|
const rowCellElement = rowElement?.querySelector('.adf-datatable-cell');
|
||||||
|
|
||||||
rowCellElement.dispatchEvent(new MouseEvent('click'));
|
rowCellElement?.dispatchEvent(new MouseEvent('click'));
|
||||||
fixture.debugElement.nativeElement.dispatchEvent(event);
|
fixture.debugElement.nativeElement.dispatchEvent(event);
|
||||||
|
|
||||||
expect(document.activeElement.getAttribute('data-automation-id')).toBe('datatable-row-1');
|
expect(document.activeElement?.getAttribute('data-automation-id')).toBe('datatable-row-1');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1563,9 +1369,7 @@ describe('Accesibility', () => {
|
|||||||
dataTable.showHeader = ShowHeaderMode.Never;
|
dataTable.showHeader = ShowHeaderMode.Never;
|
||||||
const dataRows = [{ name: 'name1' }];
|
const dataRows = [{ name: 'name1' }];
|
||||||
|
|
||||||
dataTable.data = new ObjectDataTableAdapter([],
|
dataTable.data = new ObjectDataTableAdapter([], [new ObjectDataColumn({ key: 'name', template: columnCustomTemplate, focus: false })]);
|
||||||
[new ObjectDataColumn({ key: 'name', template: columnCustomTemplate, focus: false })]
|
|
||||||
);
|
|
||||||
|
|
||||||
dataTable.ngOnChanges({
|
dataTable.ngOnChanges({
|
||||||
rows: new SimpleChange(null, dataRows, false)
|
rows: new SimpleChange(null, dataRows, false)
|
||||||
@ -1575,16 +1379,14 @@ describe('Accesibility', () => {
|
|||||||
dataTable.ngAfterViewInit();
|
dataTable.ngAfterViewInit();
|
||||||
|
|
||||||
const cell = document.querySelector('.adf-datatable-row[data-automation-id="datatable-row-0"] .adf-cell-value');
|
const cell = document.querySelector('.adf-datatable-row[data-automation-id="datatable-row-0"] .adf-cell-value');
|
||||||
expect(cell.getAttribute('tabindex')).toBe(null);
|
expect(cell?.getAttribute('tabindex')).toBe(null);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should allow element focus when [focus] is set to true', () => {
|
it('should allow element focus when [focus] is set to true', () => {
|
||||||
dataTable.showHeader = ShowHeaderMode.Never;
|
dataTable.showHeader = ShowHeaderMode.Never;
|
||||||
const dataRows = [{ name: 'name1' }];
|
const dataRows = [{ name: 'name1' }];
|
||||||
|
|
||||||
dataTable.data = new ObjectDataTableAdapter([],
|
dataTable.data = new ObjectDataTableAdapter([], [new ObjectDataColumn({ key: 'name', template: columnCustomTemplate, focus: true })]);
|
||||||
[new ObjectDataColumn({ key: 'name', template: columnCustomTemplate, focus: true })]
|
|
||||||
);
|
|
||||||
|
|
||||||
dataTable.ngOnChanges({
|
dataTable.ngOnChanges({
|
||||||
rows: new SimpleChange(null, dataRows, false)
|
rows: new SimpleChange(null, dataRows, false)
|
||||||
@ -1594,7 +1396,7 @@ describe('Accesibility', () => {
|
|||||||
dataTable.ngAfterViewInit();
|
dataTable.ngAfterViewInit();
|
||||||
|
|
||||||
const cell = document.querySelector('.adf-datatable-row[data-automation-id="datatable-row-0"] .adf-cell-value');
|
const cell = document.querySelector('.adf-datatable-row[data-automation-id="datatable-row-0"] .adf-cell-value');
|
||||||
expect(cell.getAttribute('tabindex')).toBe('0');
|
expect(cell?.getAttribute('tabindex')).toBe('0');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1606,10 +1408,7 @@ describe('Drag&Drop column header', () => {
|
|||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [
|
imports: [TranslateModule.forRoot(), CoreTestingModule],
|
||||||
TranslateModule.forRoot(),
|
|
||||||
CoreTestingModule
|
|
||||||
],
|
|
||||||
declarations: [CustomColumnTemplateComponent],
|
declarations: [CustomColumnTemplateComponent],
|
||||||
schemas: [NO_ERRORS_SCHEMA]
|
schemas: [NO_ERRORS_SCHEMA]
|
||||||
});
|
});
|
||||||
@ -1625,29 +1424,30 @@ describe('Drag&Drop column header', () => {
|
|||||||
new ObjectDataColumn({ key: 'name', title: 'Name', draggable: true })
|
new ObjectDataColumn({ key: 'name', title: 'Name', draggable: true })
|
||||||
];
|
];
|
||||||
|
|
||||||
dataTable.data = new ObjectDataTableAdapter(
|
dataTable.data = new ObjectDataTableAdapter([...data], [...dataTableSchema]);
|
||||||
[...data],
|
|
||||||
[...dataTableSchema]
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should show/hide drag indicator icon', () => {
|
it('should show/hide drag indicator icon', () => {
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
const hedaderColumn = fixture.debugElement.nativeElement.querySelector('[data-automation-id="auto_id_name"]');
|
const headerColumn = fixture.debugElement.nativeElement.querySelector('[data-automation-id="auto_id_name"]');
|
||||||
hedaderColumn.dispatchEvent(new MouseEvent('mouseenter'));
|
headerColumn.dispatchEvent(new MouseEvent('mouseenter'));
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
let dragIcon = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-datatable-cell-header-drag-icon-name"]');
|
let dragIcon = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-datatable-cell-header-drag-icon-name"]');
|
||||||
let dragIconPlaceholder = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-datatable-cell-header-drag-icon-placeholder-name"]');
|
let dragIconPlaceholder = fixture.debugElement.nativeElement.querySelector(
|
||||||
|
'[data-automation-id="adf-datatable-cell-header-drag-icon-placeholder-name"]'
|
||||||
|
);
|
||||||
expect(dragIcon).toBeTruthy();
|
expect(dragIcon).toBeTruthy();
|
||||||
expect(dragIconPlaceholder).toBeTruthy();
|
expect(dragIconPlaceholder).toBeTruthy();
|
||||||
|
|
||||||
hedaderColumn.dispatchEvent(new MouseEvent('mouseleave'));
|
headerColumn.dispatchEvent(new MouseEvent('mouseleave'));
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
dragIcon = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-datatable-cell-header-drag-icon-name"]');
|
dragIcon = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-datatable-cell-header-drag-icon-name"]');
|
||||||
dragIconPlaceholder = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-datatable-cell-header-drag-icon-placeholder-name"]');
|
dragIconPlaceholder = fixture.debugElement.nativeElement.querySelector(
|
||||||
|
'[data-automation-id="adf-datatable-cell-header-drag-icon-placeholder-name"]'
|
||||||
|
);
|
||||||
expect(dragIcon).toBeFalsy();
|
expect(dragIcon).toBeFalsy();
|
||||||
expect(dragIconPlaceholder).toBeFalsy();
|
expect(dragIconPlaceholder).toBeFalsy();
|
||||||
});
|
});
|
||||||
@ -1655,12 +1455,14 @@ describe('Drag&Drop column header', () => {
|
|||||||
it('should not show drag indicator icon, when drag and drop is disabled', () => {
|
it('should not show drag indicator icon, when drag and drop is disabled', () => {
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
const hedaderColumn = fixture.debugElement.nativeElement.querySelector('[data-automation-id="auto_id_id"]');
|
const headerColumn = fixture.debugElement.nativeElement.querySelector('[data-automation-id="auto_id_id"]');
|
||||||
hedaderColumn.dispatchEvent(new MouseEvent('mouseenter'));
|
headerColumn.dispatchEvent(new MouseEvent('mouseenter'));
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
const dragIcon = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-datatable-cell-header-drag-icon-id"]');
|
const dragIcon = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-datatable-cell-header-drag-icon-id"]');
|
||||||
const dragIconPlaceholder = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-datatable-cell-header-drag-icon-placeholder-id"]');
|
const dragIconPlaceholder = fixture.debugElement.nativeElement.querySelector(
|
||||||
|
'[data-automation-id="adf-datatable-cell-header-drag-icon-placeholder-id"]'
|
||||||
|
);
|
||||||
|
|
||||||
expect(dragIcon).toBeFalsy();
|
expect(dragIcon).toBeFalsy();
|
||||||
expect(dragIconPlaceholder).toBeFalsy();
|
expect(dragIconPlaceholder).toBeFalsy();
|
||||||
@ -1717,10 +1519,7 @@ describe('Show/hide columns', () => {
|
|||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [
|
imports: [TranslateModule.forRoot(), CoreTestingModule],
|
||||||
TranslateModule.forRoot(),
|
|
||||||
CoreTestingModule
|
|
||||||
],
|
|
||||||
declarations: [CustomColumnTemplateComponent],
|
declarations: [CustomColumnTemplateComponent],
|
||||||
schemas: [NO_ERRORS_SCHEMA]
|
schemas: [NO_ERRORS_SCHEMA]
|
||||||
});
|
});
|
||||||
@ -1738,10 +1537,7 @@ describe('Show/hide columns', () => {
|
|||||||
new ObjectDataColumn({ key: 'status', title: 'status', isHidden: true })
|
new ObjectDataColumn({ key: 'status', title: 'status', isHidden: true })
|
||||||
];
|
];
|
||||||
|
|
||||||
dataTable.data = new ObjectDataTableAdapter(
|
dataTable.data = new ObjectDataTableAdapter([...data], [...dataTableSchema]);
|
||||||
[...data],
|
|
||||||
[...dataTableSchema]
|
|
||||||
);
|
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
});
|
});
|
||||||
@ -1776,11 +1572,14 @@ describe('Show/hide columns', () => {
|
|||||||
|
|
||||||
describe('markRowAsContextMenuSource', () => {
|
describe('markRowAsContextMenuSource', () => {
|
||||||
it('should set isContextMenuSource to false for all rows returned by getRows function', () => {
|
it('should set isContextMenuSource to false for all rows returned by getRows function', () => {
|
||||||
const rows = [{
|
const rows = [
|
||||||
|
{
|
||||||
isContextMenuSource: true
|
isContextMenuSource: true
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
isContextMenuSource: true
|
isContextMenuSource: true
|
||||||
}] as DataRow[];
|
}
|
||||||
|
] as DataRow[];
|
||||||
spyOn(dataTable.data, 'getRows').and.returnValue(rows);
|
spyOn(dataTable.data, 'getRows').and.returnValue(rows);
|
||||||
dataTable.markRowAsContextMenuSource({} as DataRow);
|
dataTable.markRowAsContextMenuSource({} as DataRow);
|
||||||
rows.forEach((row) => expect(row.isContextMenuSource).toBeFalse());
|
rows.forEach((row) => expect(row.isContextMenuSource).toBeFalse());
|
||||||
@ -1802,7 +1601,6 @@ describe('Column Resizing', () => {
|
|||||||
let data: { id: number; name: string }[] = [];
|
let data: { id: number; name: string }[] = [];
|
||||||
let dataTableSchema: DataColumn[] = [];
|
let dataTableSchema: DataColumn[] = [];
|
||||||
|
|
||||||
|
|
||||||
const testClassesAfterResizing = (headerColumnsSelector = '.adf-datatable-cell-header', excludedClass = 'adf-datatable__cursor--pointer') => {
|
const testClassesAfterResizing = (headerColumnsSelector = '.adf-datatable-cell-header', excludedClass = 'adf-datatable__cursor--pointer') => {
|
||||||
dataTable.isResizingEnabled = true;
|
dataTable.isResizingEnabled = true;
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
@ -1819,10 +1617,7 @@ describe('Column Resizing', () => {
|
|||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [
|
imports: [TranslateModule.forRoot(), CoreTestingModule],
|
||||||
TranslateModule.forRoot(),
|
|
||||||
CoreTestingModule
|
|
||||||
],
|
|
||||||
declarations: [CustomColumnTemplateComponent],
|
declarations: [CustomColumnTemplateComponent],
|
||||||
schemas: [NO_ERRORS_SCHEMA]
|
schemas: [NO_ERRORS_SCHEMA]
|
||||||
});
|
});
|
||||||
@ -1838,10 +1633,7 @@ describe('Column Resizing', () => {
|
|||||||
new ObjectDataColumn({ key: 'name', title: 'Name', draggable: true })
|
new ObjectDataColumn({ key: 'name', title: 'Name', draggable: true })
|
||||||
];
|
];
|
||||||
|
|
||||||
dataTable.data = new ObjectDataTableAdapter(
|
dataTable.data = new ObjectDataTableAdapter([...data], [...dataTableSchema]);
|
||||||
[...data],
|
|
||||||
[...dataTableSchema]
|
|
||||||
);
|
|
||||||
|
|
||||||
dataTable.isResizingEnabled = false;
|
dataTable.isResizingEnabled = false;
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
@ -1884,8 +1676,8 @@ describe('Column Resizing', () => {
|
|||||||
dataTable.isResizingEnabled = true;
|
dataTable.isResizingEnabled = true;
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
const hedaderColumn = fixture.debugElement.nativeElement.querySelector('[data-automation-id="auto_id_id"]');
|
const headerColumn = fixture.debugElement.nativeElement.querySelector('[data-automation-id="auto_id_id"]');
|
||||||
hedaderColumn.dispatchEvent(new MouseEvent('mouseenter'));
|
headerColumn.dispatchEvent(new MouseEvent('mouseenter'));
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
let dragIcon = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-datatable-cell-header-drag-icon-id"]');
|
let dragIcon = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-datatable-cell-header-drag-icon-id"]');
|
||||||
|
|
||||||
@ -2047,5 +1839,4 @@ describe('Column Resizing', () => {
|
|||||||
expect(dataTable.isResizing).toBeFalse();
|
expect(dataTable.isResizing).toBeFalse();
|
||||||
expect(dataTable.columnsWidthChanged.emit).toHaveBeenCalled();
|
expect(dataTable.columnsWidthChanged.emit).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -40,7 +40,7 @@ export class ObjectDataTableAdapter implements DataTableAdapter {
|
|||||||
|
|
||||||
if (typeof rowToExamine === 'object') {
|
if (typeof rowToExamine === 'object') {
|
||||||
for (const key in rowToExamine) {
|
for (const key in rowToExamine) {
|
||||||
if (rowToExamine.hasOwnProperty(key)) {
|
if (Object.prototype.hasOwnProperty.call(rowToExamine, key)) {
|
||||||
schema.push({
|
schema.push({
|
||||||
type: 'text',
|
type: 'text',
|
||||||
key,
|
key,
|
||||||
|
@ -51,26 +51,24 @@ export class ResizableDirective implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
mousemove = new Subject<IResizeMouseEvent>();
|
mousemove = new Subject<IResizeMouseEvent>();
|
||||||
|
|
||||||
private pointerDown: Observable<IResizeMouseEvent>;
|
private readonly pointerDown: Observable<IResizeMouseEvent>;
|
||||||
|
private readonly pointerMove: Observable<IResizeMouseEvent>;
|
||||||
private pointerMove: Observable<IResizeMouseEvent>;
|
private readonly pointerUp: Observable<IResizeMouseEvent>;
|
||||||
|
|
||||||
private pointerUp: Observable<IResizeMouseEvent>;
|
|
||||||
|
|
||||||
private startingRect: BoundingRectangle;
|
private startingRect: BoundingRectangle;
|
||||||
|
|
||||||
private currentRect: BoundingRectangle;
|
private currentRect: BoundingRectangle;
|
||||||
|
|
||||||
private unlistenMouseDown?: () => void;
|
private unsubscribeMouseDown?: () => void;
|
||||||
private unlistenMouseMove?: () => void;
|
private unsubscribeMouseMove?: () => void;
|
||||||
private unlistenMouseUp?: () => void;
|
private unsubscribeMouseUp?: () => void;
|
||||||
|
|
||||||
private destroy$ = new Subject<void>();
|
private destroy$ = new Subject<void>();
|
||||||
|
|
||||||
constructor(private readonly renderer: Renderer2, private readonly element: ElementRef<HTMLElement>, private readonly zone: NgZone) {
|
constructor(private readonly renderer: Renderer2, private readonly element: ElementRef<HTMLElement>, private readonly zone: NgZone) {
|
||||||
this.pointerDown = new Observable((observer: Observer<IResizeMouseEvent>) => {
|
this.pointerDown = new Observable((observer: Observer<IResizeMouseEvent>) => {
|
||||||
zone.runOutsideAngular(() => {
|
zone.runOutsideAngular(() => {
|
||||||
this.unlistenMouseDown = renderer.listen('document', 'mousedown', (event: MouseEvent) => {
|
this.unsubscribeMouseDown = renderer.listen('document', 'mousedown', (event: MouseEvent) => {
|
||||||
observer.next(event);
|
observer.next(event);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -78,7 +76,7 @@ export class ResizableDirective implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
this.pointerMove = new Observable((observer: Observer<IResizeMouseEvent>) => {
|
this.pointerMove = new Observable((observer: Observer<IResizeMouseEvent>) => {
|
||||||
zone.runOutsideAngular(() => {
|
zone.runOutsideAngular(() => {
|
||||||
this.unlistenMouseMove = renderer.listen('document', 'mousemove', (event: MouseEvent) => {
|
this.unsubscribeMouseMove = renderer.listen('document', 'mousemove', (event: MouseEvent) => {
|
||||||
observer.next(event);
|
observer.next(event);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -86,7 +84,7 @@ export class ResizableDirective implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
this.pointerUp = new Observable((observer: Observer<IResizeMouseEvent>) => {
|
this.pointerUp = new Observable((observer: Observer<IResizeMouseEvent>) => {
|
||||||
zone.runOutsideAngular(() => {
|
zone.runOutsideAngular(() => {
|
||||||
this.unlistenMouseUp = renderer.listen('document', 'mouseup', (event: MouseEvent) => {
|
this.unsubscribeMouseUp = renderer.listen('document', 'mouseup', (event: MouseEvent) => {
|
||||||
observer.next(event);
|
observer.next(event);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -101,7 +99,7 @@ export class ResizableDirective implements OnInit, OnDestroy {
|
|||||||
const mouseDrag: Observable<IResizeMouseEvent | ICoordinateX> = mousedown$
|
const mouseDrag: Observable<IResizeMouseEvent | ICoordinateX> = mousedown$
|
||||||
.pipe(
|
.pipe(
|
||||||
mergeMap(({ clientX = 0 }) =>
|
mergeMap(({ clientX = 0 }) =>
|
||||||
merge(mousemove$.pipe(take(1)).pipe(map((coords) => [, coords])), mousemove$.pipe(pairwise()))
|
merge(mousemove$.pipe(take(1)).pipe(map((coords) => [undefined, coords])), mousemove$.pipe(pairwise()))
|
||||||
.pipe(
|
.pipe(
|
||||||
map(([previousCoords = {}, newCoords = {}]) => [
|
map(([previousCoords = {}, newCoords = {}]) => [
|
||||||
{ clientX: previousCoords.clientX - clientX },
|
{ clientX: previousCoords.clientX - clientX },
|
||||||
@ -170,9 +168,9 @@ export class ResizableDirective implements OnInit, OnDestroy {
|
|||||||
this.mousedown.complete();
|
this.mousedown.complete();
|
||||||
this.mousemove.complete();
|
this.mousemove.complete();
|
||||||
this.mouseup.complete();
|
this.mouseup.complete();
|
||||||
this.unlistenMouseDown?.();
|
this.unsubscribeMouseDown?.();
|
||||||
this.unlistenMouseMove?.();
|
this.unsubscribeMouseMove?.();
|
||||||
this.unlistenMouseUp?.();
|
this.unsubscribeMouseUp?.();
|
||||||
this.destroy$.next();
|
this.destroy$.next();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ import {
|
|||||||
numberMinMaxForm,
|
numberMinMaxForm,
|
||||||
textWidgetVisibility,
|
textWidgetVisibility,
|
||||||
numberWidgetVisibilityForm,
|
numberWidgetVisibilityForm,
|
||||||
radioWidgetVisibiltyForm,
|
radioWidgetVisibilityForm,
|
||||||
customWidgetForm,
|
customWidgetForm,
|
||||||
formDateVisibility,
|
formDateVisibility,
|
||||||
customWidgetFormWithVisibility,
|
customWidgetFormWithVisibility,
|
||||||
@ -86,7 +86,6 @@ const expectElementToBeValid = (fieldId: string, fixture: ComponentFixture<FormR
|
|||||||
};
|
};
|
||||||
|
|
||||||
describe('Form Renderer Component', () => {
|
describe('Form Renderer Component', () => {
|
||||||
|
|
||||||
let formRendererComponent: FormRendererComponent<any>;
|
let formRendererComponent: FormRendererComponent<any>;
|
||||||
let fixture: ComponentFixture<FormRendererComponent<any>>;
|
let fixture: ComponentFixture<FormRendererComponent<any>>;
|
||||||
let formService: FormService;
|
let formService: FormService;
|
||||||
@ -95,11 +94,7 @@ describe('Form Renderer Component', () => {
|
|||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [
|
imports: [TranslateModule.forRoot(), CoreTestingModule, FormBaseModule]
|
||||||
TranslateModule.forRoot(),
|
|
||||||
CoreTestingModule,
|
|
||||||
FormBaseModule
|
|
||||||
]
|
|
||||||
});
|
});
|
||||||
fixture = TestBed.createComponent(FormRendererComponent);
|
fixture = TestBed.createComponent(FormRendererComponent);
|
||||||
formRendererComponent = fixture.componentInstance;
|
formRendererComponent = fixture.componentInstance;
|
||||||
@ -287,7 +282,6 @@ describe('Form Renderer Component', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('Number widget', () => {
|
describe('Number widget', () => {
|
||||||
|
|
||||||
it('[C315169] - Should be able to complete a task with a form with number widgets', async () => {
|
it('[C315169] - Should be able to complete a task with a form with number widgets', async () => {
|
||||||
formRendererComponent.formDefinition = formService.parseForm(formNumberWidgetVisibility.formRepresentation.formDefinition);
|
formRendererComponent.formDefinition = formService.parseForm(formNumberWidgetVisibility.formRepresentation.formDefinition);
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
@ -364,8 +358,8 @@ describe('Form Renderer Component', () => {
|
|||||||
await fixture.whenStable();
|
await fixture.whenStable();
|
||||||
numberContainerElement = fixture.nativeElement.querySelector('#field-Number2-container');
|
numberContainerElement = fixture.nativeElement.querySelector('#field-Number2-container');
|
||||||
expectElementToBeHidden(numberContainerElement);
|
expectElementToBeHidden(numberContainerElement);
|
||||||
const errorWidetText: HTMLDivElement = fixture.nativeElement.querySelector('#field-Number1-container error-widget .adf-error-text');
|
const errorWidgetText: HTMLDivElement = fixture.nativeElement.querySelector('#field-Number1-container error-widget .adf-error-text');
|
||||||
expect(errorWidetText.textContent).toBe(`FORM.FIELD.VALIDATOR.NOT_GREATER_THAN`);
|
expect(errorWidgetText.textContent).toBe(`FORM.FIELD.VALIDATOR.NOT_GREATER_THAN`);
|
||||||
expect(formRendererComponent.formDefinition.isValid).toBe(false, 'Form should not be valid without mandatory field');
|
expect(formRendererComponent.formDefinition.isValid).toBe(false, 'Form should not be valid without mandatory field');
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -397,12 +391,16 @@ describe('Form Renderer Component', () => {
|
|||||||
await fixture.whenStable();
|
await fixture.whenStable();
|
||||||
const formSizedElement = fixture.nativeElement.querySelector('#field-2bc275fb-e113-4d7d-885f-6e74a7332d40-container div.adf-grid-list');
|
const formSizedElement = fixture.nativeElement.querySelector('#field-2bc275fb-e113-4d7d-885f-6e74a7332d40-container div.adf-grid-list');
|
||||||
expectElementToBeVisible(formSizedElement);
|
expectElementToBeVisible(formSizedElement);
|
||||||
const sectionGridElement: HTMLElement[] = fixture.nativeElement.querySelectorAll('#field-2bc275fb-e113-4d7d-885f-6e74a7332d40-container div .adf-grid-list-item');
|
const sectionGridElement: HTMLElement[] = fixture.nativeElement.querySelectorAll(
|
||||||
|
'#field-2bc275fb-e113-4d7d-885f-6e74a7332d40-container div .adf-grid-list-item'
|
||||||
|
);
|
||||||
sectionGridElement.forEach((element) => {
|
sectionGridElement.forEach((element) => {
|
||||||
expect(element.style['grid-area']).toBe('auto / auto / span 1 / span 1', 'Elemens is wrong sized for this section');
|
expect(element.style['grid-area']).toBe('auto / auto / span 1 / span 1', 'Elemens is wrong sized for this section');
|
||||||
});
|
});
|
||||||
|
|
||||||
const fullWidthElement = fixture.nativeElement.querySelector('#field-d52ada4e-cbdc-4f0c-a480-5b85fa00e4f8-container div.adf-grid-list .adf-grid-list-item');
|
const fullWidthElement = fixture.nativeElement.querySelector(
|
||||||
|
'#field-d52ada4e-cbdc-4f0c-a480-5b85fa00e4f8-container div.adf-grid-list .adf-grid-list-item'
|
||||||
|
);
|
||||||
expect(fullWidthElement.style['grid-area']).toBe('auto / auto / span 1 / span 2');
|
expect(fullWidthElement.style['grid-area']).toBe('auto / auto / span 1 / span 2');
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -410,13 +408,19 @@ describe('Form Renderer Component', () => {
|
|||||||
formRendererComponent.formDefinition = formService.parseForm(colspanForm.formRepresentation.formDefinition, null, false, false);
|
formRendererComponent.formDefinition = formService.parseForm(colspanForm.formRepresentation.formDefinition, null, false, false);
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
await fixture.whenStable();
|
await fixture.whenStable();
|
||||||
const formSizedElement = fixture.nativeElement.querySelector('#field-2bc275fb-e113-4d7d-885f-6e74a7332d40-container section.adf-grid-list-column-view');
|
const formSizedElement = fixture.nativeElement.querySelector(
|
||||||
|
'#field-2bc275fb-e113-4d7d-885f-6e74a7332d40-container section.adf-grid-list-column-view'
|
||||||
|
);
|
||||||
expectElementToBeVisible(formSizedElement);
|
expectElementToBeVisible(formSizedElement);
|
||||||
const sectionGridElement: HTMLElement[] = fixture.nativeElement.querySelectorAll('#field-2bc275fb-e113-4d7d-885f-6e74a7332d40-container section .adf-grid-list-single-column');
|
const sectionGridElement: HTMLElement[] = fixture.nativeElement.querySelectorAll(
|
||||||
|
'#field-2bc275fb-e113-4d7d-885f-6e74a7332d40-container section .adf-grid-list-single-column'
|
||||||
|
);
|
||||||
sectionGridElement.forEach((element) => {
|
sectionGridElement.forEach((element) => {
|
||||||
expect(element.style['width']).toBe('50%', 'Elemens is wrong sized for this section');
|
expect(element.style['width']).toBe('50%', 'Elemens is wrong sized for this section');
|
||||||
});
|
});
|
||||||
const fullWidthElement = fixture.nativeElement.querySelector('#field-d52ada4e-cbdc-4f0c-a480-5b85fa00e4f8-container section.adf-grid-list-column-view .adf-grid-list-single-column');
|
const fullWidthElement = fixture.nativeElement.querySelector(
|
||||||
|
'#field-d52ada4e-cbdc-4f0c-a480-5b85fa00e4f8-container section.adf-grid-list-column-view .adf-grid-list-single-column'
|
||||||
|
);
|
||||||
expect(fullWidthElement.style['width']).toBe('100%');
|
expect(fullWidthElement.style['width']).toBe('100%');
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -587,11 +591,9 @@ describe('Form Renderer Component', () => {
|
|||||||
expectInputElementValueIs(testTwoInput, 'aaa');
|
expectInputElementValueIs(testTwoInput, 'aaa');
|
||||||
expectElementToBeHidden(numberFieldContainer);
|
expectElementToBeHidden(numberFieldContainer);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Text widget', () => {
|
describe('Text widget', () => {
|
||||||
|
|
||||||
it('[C309669] - Should be able to set visibility conditions for Text widget', async () => {
|
it('[C309669] - Should be able to set visibility conditions for Text widget', async () => {
|
||||||
formRendererComponent.formDefinition = formService.parseForm(textWidgetVisibility.formRepresentation.formDefinition);
|
formRendererComponent.formDefinition = formService.parseForm(textWidgetVisibility.formRepresentation.formDefinition);
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
@ -630,13 +632,11 @@ describe('Form Renderer Component', () => {
|
|||||||
expectElementToBeVisible(elementFourContainer);
|
expectElementToBeVisible(elementFourContainer);
|
||||||
expectElementToBeHidden(elementThreeContainer);
|
expectElementToBeHidden(elementThreeContainer);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Radio widget', () => {
|
describe('Radio widget', () => {
|
||||||
|
|
||||||
it('[C310352] - Should be able to set visibility conditions for Radio Button widget', async () => {
|
it('[C310352] - Should be able to set visibility conditions for Radio Button widget', async () => {
|
||||||
formRendererComponent.formDefinition = formService.parseForm(radioWidgetVisibiltyForm.formRepresentation.formDefinition);
|
formRendererComponent.formDefinition = formService.parseForm(radioWidgetVisibilityForm.formRepresentation.formDefinition);
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
await fixture.whenStable();
|
await fixture.whenStable();
|
||||||
const textInputElement = fixture.nativeElement.querySelector('#Text0cee7g');
|
const textInputElement = fixture.nativeElement.querySelector('#Text0cee7g');
|
||||||
@ -651,11 +651,9 @@ describe('Form Renderer Component', () => {
|
|||||||
radioButtonContainer = fixture.nativeElement.querySelector('#field-Radiobuttons03rkbo-container');
|
radioButtonContainer = fixture.nativeElement.querySelector('#field-Radiobuttons03rkbo-container');
|
||||||
expectElementToBeVisible(radioButtonContainer);
|
expectElementToBeVisible(radioButtonContainer);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Custom Widget', () => {
|
describe('Custom Widget', () => {
|
||||||
|
|
||||||
it('Should be able to correctly display a custom process cloud widget', async () => {
|
it('Should be able to correctly display a custom process cloud widget', async () => {
|
||||||
formRenderingService.register({ bananaforevah: () => TextWidgetComponent }, true);
|
formRenderingService.register({ bananaforevah: () => TextWidgetComponent }, true);
|
||||||
formRendererComponent.formDefinition = formService.parseForm(customWidgetForm.formRepresentation.formDefinition);
|
formRendererComponent.formDefinition = formService.parseForm(customWidgetForm.formRepresentation.formDefinition);
|
||||||
@ -681,7 +679,6 @@ describe('Form Renderer Component', () => {
|
|||||||
customWidgetElementContainer = fixture.nativeElement.querySelector('#field-bananaforevah0k8gui-container');
|
customWidgetElementContainer = fixture.nativeElement.querySelector('#field-bananaforevah0k8gui-container');
|
||||||
expectElementToBeVisible(customWidgetElementContainer);
|
expectElementToBeVisible(customWidgetElementContainer);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Form rules', () => {
|
describe('Form rules', () => {
|
||||||
|
@ -84,7 +84,7 @@ export class FormRendererComponent<T> implements OnChanges, OnDestroy {
|
|||||||
const maxColumnFieldsSize = this.getMaxColumnFieldSize(content);
|
const maxColumnFieldsSize = this.getMaxColumnFieldSize(content);
|
||||||
for (let rowIndex = 0; rowIndex < maxColumnFieldsSize; rowIndex++) {
|
for (let rowIndex = 0; rowIndex < maxColumnFieldsSize; rowIndex++) {
|
||||||
content?.columns.flatMap((currentColumn) => {
|
content?.columns.flatMap((currentColumn) => {
|
||||||
if (!!currentColumn?.fields[rowIndex]) {
|
if (currentColumn?.fields[rowIndex]) {
|
||||||
serialisedFormFields.push(currentColumn?.fields[rowIndex]);
|
serialisedFormFields.push(currentColumn?.fields[rowIndex]);
|
||||||
} else {
|
} else {
|
||||||
const firstRowElementColSpan = currentColumn?.fields[0]?.colspan;
|
const firstRowElementColSpan = currentColumn?.fields[0]?.colspan;
|
||||||
|
@ -154,8 +154,7 @@ export const formDisplayValueForm = {
|
|||||||
colspan: 1,
|
colspan: 1,
|
||||||
visibilityCondition: {
|
visibilityCondition: {
|
||||||
leftFormFieldId: '',
|
leftFormFieldId: '',
|
||||||
leftRestResponseId:
|
leftRestResponseId: 'bcdfe3af-d635-40ee-b9fd-4f9d3655d77b',
|
||||||
'bcdfe3af-d635-40ee-b9fd-4f9d3655d77b',
|
|
||||||
operator: '==',
|
operator: '==',
|
||||||
rightValue: '',
|
rightValue: '',
|
||||||
rightType: null,
|
rightType: null,
|
||||||
@ -187,8 +186,7 @@ export const formDisplayValueForm = {
|
|||||||
rightValue: '',
|
rightValue: '',
|
||||||
rightType: null,
|
rightType: null,
|
||||||
rightFormFieldId: '',
|
rightFormFieldId: '',
|
||||||
rightRestResponseId:
|
rightRestResponseId: 'bcdfe3af-d635-40ee-b9fd-4f9d3655d77b',
|
||||||
'bcdfe3af-d635-40ee-b9fd-4f9d3655d77b',
|
|
||||||
nextConditionOperator: '',
|
nextConditionOperator: '',
|
||||||
nextCondition: null
|
nextCondition: null
|
||||||
},
|
},
|
||||||
@ -300,8 +298,7 @@ export const formDisplayValueForm = {
|
|||||||
existingColspan: 1,
|
existingColspan: 1,
|
||||||
maxColspan: 2,
|
maxColspan: 2,
|
||||||
field: {
|
field: {
|
||||||
id:
|
id: 'bcdfe3af-d635-40ee-b9fd-4f9d3655d77b',
|
||||||
'bcdfe3af-d635-40ee-b9fd-4f9d3655d77b',
|
|
||||||
name: 'vstring',
|
name: 'vstring',
|
||||||
type: 'string'
|
type: 'string'
|
||||||
}
|
}
|
||||||
@ -651,8 +648,7 @@ export const formNumberTextJson = {
|
|||||||
required: false,
|
required: false,
|
||||||
visibilityCondition: {
|
visibilityCondition: {
|
||||||
leftFormFieldId: '',
|
leftFormFieldId: '',
|
||||||
leftRestResponseId:
|
leftRestResponseId: '3b316e21-3632-4dde-ba19-b27dca09a83b',
|
||||||
'3b316e21-3632-4dde-ba19-b27dca09a83b',
|
|
||||||
operator: '==',
|
operator: '==',
|
||||||
rightValue: 'aaa',
|
rightValue: 'aaa',
|
||||||
rightType: null,
|
rightType: null,
|
||||||
@ -682,8 +678,7 @@ export const formNumberTextJson = {
|
|||||||
rightValue: '',
|
rightValue: '',
|
||||||
rightType: null,
|
rightType: null,
|
||||||
rightFormFieldId: '',
|
rightFormFieldId: '',
|
||||||
rightRestResponseId:
|
rightRestResponseId: '3b316e21-3632-4dde-ba19-b27dca09a83b',
|
||||||
'3b316e21-3632-4dde-ba19-b27dca09a83b',
|
|
||||||
nextConditionOperator: '',
|
nextConditionOperator: '',
|
||||||
nextCondition: null
|
nextCondition: null
|
||||||
},
|
},
|
||||||
@ -743,7 +738,6 @@ export const formNumberTextJson = {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const formRequiredNumberWidget = {
|
export const formRequiredNumberWidget = {
|
||||||
@ -1264,7 +1258,7 @@ export const numberWidgetVisibilityForm = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const radioWidgetVisibiltyForm = {
|
export const radioWidgetVisibilityForm = {
|
||||||
formRepresentation: {
|
formRepresentation: {
|
||||||
id: 'form-e0d77062-9b04-40d6-beed-6b63045f63b4',
|
id: 'form-e0d77062-9b04-40d6-beed-6b63045f63b4',
|
||||||
name: 'RadioVisibility',
|
name: 'RadioVisibility',
|
||||||
|
@ -38,9 +38,7 @@ import { FormModel } from './form.model';
|
|||||||
declare let moment: any;
|
declare let moment: any;
|
||||||
|
|
||||||
describe('FormFieldValidator', () => {
|
describe('FormFieldValidator', () => {
|
||||||
|
|
||||||
describe('RequiredFieldValidator', () => {
|
describe('RequiredFieldValidator', () => {
|
||||||
|
|
||||||
let validator: RequiredFieldValidator;
|
let validator: RequiredFieldValidator;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
@ -71,9 +69,7 @@ describe('FormFieldValidator', () => {
|
|||||||
const field = new FormFieldModel(new FormModel(), {
|
const field = new FormFieldModel(new FormModel(), {
|
||||||
type: FormFieldTypes.DROPDOWN,
|
type: FormFieldTypes.DROPDOWN,
|
||||||
value: '<empty>',
|
value: '<empty>',
|
||||||
options: [
|
options: [{ id: 'empty', name: 'Choose option...' }],
|
||||||
{id: 'empty', name: 'Choose option...'}
|
|
||||||
],
|
|
||||||
hasEmptyValue: true,
|
hasEmptyValue: true,
|
||||||
required: true
|
required: true
|
||||||
});
|
});
|
||||||
@ -244,7 +240,6 @@ describe('FormFieldValidator', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('NumberFieldValidator', () => {
|
describe('NumberFieldValidator', () => {
|
||||||
|
|
||||||
let validator: NumberFieldValidator;
|
let validator: NumberFieldValidator;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
@ -308,7 +303,6 @@ describe('FormFieldValidator', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('MinLengthFieldValidator', () => {
|
describe('MinLengthFieldValidator', () => {
|
||||||
|
|
||||||
let validator: MinLengthFieldValidator;
|
let validator: MinLengthFieldValidator;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
@ -360,7 +354,6 @@ describe('FormFieldValidator', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('MaxLengthFieldValidator', () => {
|
describe('MaxLengthFieldValidator', () => {
|
||||||
|
|
||||||
let validator: MaxLengthFieldValidator;
|
let validator: MaxLengthFieldValidator;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
@ -412,7 +405,6 @@ describe('FormFieldValidator', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('MinValueFieldValidator', () => {
|
describe('MinValueFieldValidator', () => {
|
||||||
|
|
||||||
let validator: MinValueFieldValidator;
|
let validator: MinValueFieldValidator;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
@ -483,7 +475,6 @@ describe('FormFieldValidator', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('MaxValueFieldValidator', () => {
|
describe('MaxValueFieldValidator', () => {
|
||||||
|
|
||||||
let validator: MaxValueFieldValidator;
|
let validator: MaxValueFieldValidator;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
@ -554,7 +545,6 @@ describe('FormFieldValidator', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('RegExFieldValidator', () => {
|
describe('RegExFieldValidator', () => {
|
||||||
|
|
||||||
let validator: RegExFieldValidator;
|
let validator: RegExFieldValidator;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
@ -613,7 +603,6 @@ describe('FormFieldValidator', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('FixedValueFieldValidator', () => {
|
describe('FixedValueFieldValidator', () => {
|
||||||
|
|
||||||
let validator: FixedValueFieldValidator;
|
let validator: FixedValueFieldValidator;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
@ -647,7 +636,10 @@ describe('FormFieldValidator', () => {
|
|||||||
const field = new FormFieldModel(new FormModel(), {
|
const field = new FormFieldModel(new FormModel(), {
|
||||||
type: FormFieldTypes.TYPEAHEAD,
|
type: FormFieldTypes.TYPEAHEAD,
|
||||||
value: '1',
|
value: '1',
|
||||||
options: [{id: '1', name: 'Leanne Graham'}, {id: '2', name: 'Ervin Howell'}]
|
options: [
|
||||||
|
{ id: '1', name: 'Leanne Graham' },
|
||||||
|
{ id: '2', name: 'Ervin Howell' }
|
||||||
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(validator.validate(field)).toBeTruthy();
|
expect(validator.validate(field)).toBeTruthy();
|
||||||
@ -657,7 +649,10 @@ describe('FormFieldValidator', () => {
|
|||||||
const field = new FormFieldModel(new FormModel(), {
|
const field = new FormFieldModel(new FormModel(), {
|
||||||
type: FormFieldTypes.TYPEAHEAD,
|
type: FormFieldTypes.TYPEAHEAD,
|
||||||
value: 'Lean',
|
value: 'Lean',
|
||||||
options: [{id: '1', name: 'Leanne Graham'}, {id: '2', name: 'Ervin Howell'}]
|
options: [
|
||||||
|
{ id: '1', name: 'Leanne Graham' },
|
||||||
|
{ id: '2', name: 'Ervin Howell' }
|
||||||
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(validator.validate(field)).toBeFalsy();
|
expect(validator.validate(field)).toBeFalsy();
|
||||||
@ -665,7 +660,6 @@ describe('FormFieldValidator', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('MaxDateTimeFieldValidator', () => {
|
describe('MaxDateTimeFieldValidator', () => {
|
||||||
|
|
||||||
let validator: MaxDateTimeFieldValidator;
|
let validator: MaxDateTimeFieldValidator;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
@ -791,7 +785,6 @@ describe('FormFieldValidator', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('MinDateTimeFieldValidator', () => {
|
describe('MinDateTimeFieldValidator', () => {
|
||||||
|
|
||||||
let validator: MinDateTimeFieldValidator;
|
let validator: MinDateTimeFieldValidator;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
@ -917,7 +910,6 @@ describe('FormFieldValidator', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('MaxDateFieldValidator', () => {
|
describe('MaxDateFieldValidator', () => {
|
||||||
|
|
||||||
let validator: MaxDateFieldValidator;
|
let validator: MaxDateFieldValidator;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
@ -1010,7 +1002,6 @@ describe('FormFieldValidator', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('MinDateFieldValidator', () => {
|
describe('MinDateFieldValidator', () => {
|
||||||
|
|
||||||
let validator: MinDateFieldValidator;
|
let validator: MinDateFieldValidator;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
@ -1103,7 +1094,6 @@ describe('FormFieldValidator', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('DateTimeFieldValidator', () => {
|
describe('DateTimeFieldValidator', () => {
|
||||||
|
|
||||||
let validator: DateTimeFieldValidator;
|
let validator: DateTimeFieldValidator;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
@ -1114,7 +1104,7 @@ describe('FormFieldValidator', () => {
|
|||||||
const field = new FormFieldModel(new FormModel(), {
|
const field = new FormFieldModel(new FormModel(), {
|
||||||
type: FormFieldTypes.DATETIME,
|
type: FormFieldTypes.DATETIME,
|
||||||
value: '2021-06-09 14:10',
|
value: '2021-06-09 14:10',
|
||||||
dateDisplayFormay: 'YYYY-MM-DD HH:mm'
|
dateDisplayFormat: 'YYYY-MM-DD HH:mm'
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(validator.validate(field)).toBeTruthy();
|
expect(validator.validate(field)).toBeTruthy();
|
||||||
|
@ -272,11 +272,10 @@ export class FormFieldModel extends FormWidgetModel {
|
|||||||
|
|
||||||
if (json.fields) {
|
if (json.fields) {
|
||||||
for (const currentField in json.fields) {
|
for (const currentField in json.fields) {
|
||||||
if (json.fields.hasOwnProperty(currentField)) {
|
if (Object.prototype.hasOwnProperty.call(json.fields, currentField)) {
|
||||||
const col = new ContainerColumnModel();
|
const col = new ContainerColumnModel();
|
||||||
|
|
||||||
const fields: FormFieldModel[] = (json.fields[currentField] || []).map((field) => new FormFieldModel(form, field));
|
col.fields = (json.fields[currentField] || []).map((field) => new FormFieldModel(form, field));
|
||||||
col.fields = fields;
|
|
||||||
col.rowspan = json.fields[currentField].length;
|
col.rowspan = json.fields[currentField].length;
|
||||||
|
|
||||||
col.fields.forEach((colFields: any) => {
|
col.fields.forEach((colFields: any) => {
|
||||||
@ -291,7 +290,7 @@ export class FormFieldModel extends FormWidgetModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
parseValue(json: any): any {
|
parseValue(json: any): any {
|
||||||
let value = json.hasOwnProperty('value') && json.value !== undefined ? json.value : null;
|
let value = Object.prototype.hasOwnProperty.call(json, 'value') && json.value !== undefined ? json.value : null;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
This is needed due to Activiti issue related to reading dropdown values as value string
|
This is needed due to Activiti issue related to reading dropdown values as value string
|
||||||
@ -363,7 +362,7 @@ export class FormFieldModel extends FormWidgetModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch (this.type) {
|
switch (this.type) {
|
||||||
case FormFieldTypes.DROPDOWN:
|
case FormFieldTypes.DROPDOWN: {
|
||||||
if (!this.value) {
|
if (!this.value) {
|
||||||
this.form.values[this.id] = null;
|
this.form.values[this.id] = null;
|
||||||
break;
|
break;
|
||||||
@ -390,13 +389,15 @@ export class FormFieldModel extends FormWidgetModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case FormFieldTypes.RADIO_BUTTONS:
|
}
|
||||||
|
case FormFieldTypes.RADIO_BUTTONS: {
|
||||||
const radioButton: FormFieldOption[] = this.options.filter((opt) => opt.id === this.value);
|
const radioButton: FormFieldOption[] = this.options.filter((opt) => opt.id === this.value);
|
||||||
if (radioButton.length > 0) {
|
if (radioButton.length > 0) {
|
||||||
this.form.values[this.id] = radioButton[0];
|
this.form.values[this.id] = radioButton[0];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case FormFieldTypes.UPLOAD:
|
}
|
||||||
|
case FormFieldTypes.UPLOAD: {
|
||||||
this.form.hasUpload = true;
|
this.form.hasUpload = true;
|
||||||
if (this.value && this.value.length > 0) {
|
if (this.value && this.value.length > 0) {
|
||||||
this.form.values[this.id] = Array.isArray(this.value) ? this.value.map((elem) => elem.id).join(',') : [this.value];
|
this.form.values[this.id] = Array.isArray(this.value) ? this.value.map((elem) => elem.id).join(',') : [this.value];
|
||||||
@ -404,7 +405,8 @@ export class FormFieldModel extends FormWidgetModel {
|
|||||||
this.form.values[this.id] = null;
|
this.form.values[this.id] = null;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case FormFieldTypes.TYPEAHEAD:
|
}
|
||||||
|
case FormFieldTypes.TYPEAHEAD: {
|
||||||
const typeAheadEntry: FormFieldOption[] = this.options.filter((opt) => opt.id === this.value || opt.name === this.value);
|
const typeAheadEntry: FormFieldOption[] = this.options.filter((opt) => opt.id === this.value || opt.name === this.value);
|
||||||
if (typeAheadEntry.length > 0) {
|
if (typeAheadEntry.length > 0) {
|
||||||
this.form.values[this.id] = typeAheadEntry[0];
|
this.form.values[this.id] = typeAheadEntry[0];
|
||||||
@ -412,7 +414,8 @@ export class FormFieldModel extends FormWidgetModel {
|
|||||||
this.form.values[this.id] = null;
|
this.form.values[this.id] = null;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case FormFieldTypes.DATE:
|
}
|
||||||
|
case FormFieldTypes.DATE: {
|
||||||
if (typeof this.value === 'string' && this.value === 'today') {
|
if (typeof this.value === 'string' && this.value === 'today') {
|
||||||
this.value = moment(new Date()).format(this.dateDisplayFormat);
|
this.value = moment(new Date()).format(this.dateDisplayFormat);
|
||||||
}
|
}
|
||||||
@ -425,7 +428,8 @@ export class FormFieldModel extends FormWidgetModel {
|
|||||||
this._value = this.value;
|
this._value = this.value;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case FormFieldTypes.DATETIME:
|
}
|
||||||
|
case FormFieldTypes.DATETIME: {
|
||||||
if (typeof this.value === 'string' && this.value === 'now') {
|
if (typeof this.value === 'string' && this.value === 'now') {
|
||||||
this.value = moment(new Date()).utc().format(this.dateDisplayFormat);
|
this.value = moment(new Date()).utc().format(this.dateDisplayFormat);
|
||||||
}
|
}
|
||||||
@ -439,21 +443,27 @@ export class FormFieldModel extends FormWidgetModel {
|
|||||||
this._value = this.value;
|
this._value = this.value;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case FormFieldTypes.NUMBER:
|
}
|
||||||
|
case FormFieldTypes.NUMBER: {
|
||||||
this.form.values[this.id] = this.enableFractions ? parseFloat(this.value) : parseInt(this.value, 10);
|
this.form.values[this.id] = this.enableFractions ? parseFloat(this.value) : parseInt(this.value, 10);
|
||||||
break;
|
break;
|
||||||
case FormFieldTypes.AMOUNT:
|
}
|
||||||
|
case FormFieldTypes.AMOUNT: {
|
||||||
this.form.values[this.id] = this.enableFractions ? parseFloat(this.value) : parseInt(this.value, 10);
|
this.form.values[this.id] = this.enableFractions ? parseFloat(this.value) : parseInt(this.value, 10);
|
||||||
break;
|
break;
|
||||||
case FormFieldTypes.BOOLEAN:
|
}
|
||||||
|
case FormFieldTypes.BOOLEAN: {
|
||||||
this.form.values[this.id] = this.value !== null && this.value !== undefined ? this.value : false;
|
this.form.values[this.id] = this.value !== null && this.value !== undefined ? this.value : false;
|
||||||
break;
|
break;
|
||||||
case FormFieldTypes.PEOPLE:
|
}
|
||||||
|
case FormFieldTypes.PEOPLE: {
|
||||||
this.form.values[this.id] = this.value ? this.value : null;
|
this.form.values[this.id] = this.value ? this.value : null;
|
||||||
break;
|
break;
|
||||||
case FormFieldTypes.FUNCTIONAL_GROUP:
|
}
|
||||||
|
case FormFieldTypes.FUNCTIONAL_GROUP: {
|
||||||
this.form.values[this.id] = this.value ? this.value : null;
|
this.form.values[this.id] = this.value ? this.value : null;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
if (!FormFieldTypes.isReadOnlyType(this.type) && !this.isInvalidFieldType(this.type)) {
|
if (!FormFieldTypes.isReadOnlyType(this.type) && !this.isInvalidFieldType(this.type)) {
|
||||||
this.form.values[this.id] = this.value;
|
this.form.values[this.id] = this.value;
|
||||||
|
@ -265,7 +265,7 @@ export class FormModel implements ProcessFormModel {
|
|||||||
getDefaultFormVariableValue(identifier: string): any {
|
getDefaultFormVariableValue(identifier: string): any {
|
||||||
const variable = this.getFormVariable(identifier);
|
const variable = this.getFormVariable(identifier);
|
||||||
|
|
||||||
if (variable?.hasOwnProperty('value')) {
|
if (variable && Object.prototype.hasOwnProperty.call(variable, 'value')) {
|
||||||
return this.parseValue(variable.type, variable.value);
|
return this.parseValue(variable.type, variable.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -420,7 +420,7 @@ export class FormModel implements ProcessFormModel {
|
|||||||
const visibilityRule: WidgetVisibilityModel = new WidgetVisibilityModel();
|
const visibilityRule: WidgetVisibilityModel = new WidgetVisibilityModel();
|
||||||
|
|
||||||
const field = this.getFieldById(fieldId);
|
const field = this.getFieldById(fieldId);
|
||||||
if (!!field) {
|
if (field) {
|
||||||
visibilityRule.operator = visibility ? 'empty' : '!empty';
|
visibilityRule.operator = visibility ? 'empty' : '!empty';
|
||||||
visibilityRule.leftType = WidgetTypeEnum.field;
|
visibilityRule.leftType = WidgetTypeEnum.field;
|
||||||
field.visibilityCondition = visibilityRule;
|
field.visibilityCondition = visibilityRule;
|
||||||
@ -430,28 +430,28 @@ export class FormModel implements ProcessFormModel {
|
|||||||
|
|
||||||
changeFieldDisabled(fieldId: string, disabled: boolean): void {
|
changeFieldDisabled(fieldId: string, disabled: boolean): void {
|
||||||
const field = this.getFieldById(fieldId);
|
const field = this.getFieldById(fieldId);
|
||||||
if (!!field) {
|
if (field) {
|
||||||
field.readOnly = this.readOnly || disabled;
|
field.readOnly = this.readOnly || disabled;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
changeFieldRequired(fieldId: string, required: boolean): void {
|
changeFieldRequired(fieldId: string, required: boolean): void {
|
||||||
const field = this.getFieldById(fieldId);
|
const field = this.getFieldById(fieldId);
|
||||||
if (!!field) {
|
if (field) {
|
||||||
field.required = required;
|
field.required = required;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
changeFieldValue(fieldId: string, value: any): void {
|
changeFieldValue(fieldId: string, value: any): void {
|
||||||
const field = this.getFieldById(fieldId);
|
const field = this.getFieldById(fieldId);
|
||||||
if (!!field) {
|
if (field) {
|
||||||
field.value = value;
|
field.value = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
changeVariableValue(variableId: string, value: any): void {
|
changeVariableValue(variableId: string, value: any): void {
|
||||||
const variable = this.getFormVariable(variableId);
|
const variable = this.getFormVariable(variableId);
|
||||||
if (!!variable) {
|
if (variable) {
|
||||||
variable.value = value;
|
variable.value = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,12 +50,13 @@ export abstract class FormRulesManager<T> {
|
|||||||
if (!this.formModel.readOnly) {
|
if (!this.formModel.readOnly) {
|
||||||
const rules = this.getRules();
|
const rules = this.getRules();
|
||||||
|
|
||||||
if (!!rules) {
|
if (rules) {
|
||||||
this.formService.formRulesEvent
|
this.formService.formRulesEvent
|
||||||
.pipe(
|
.pipe(
|
||||||
filter(event => !!event?.form?.id && event.form.id === formModel?.id),
|
filter((event) => !!event?.form?.id && event.form.id === formModel?.id),
|
||||||
takeUntil(this.onDestroy$)
|
takeUntil(this.onDestroy$)
|
||||||
).subscribe(event => {
|
)
|
||||||
|
.subscribe((event) => {
|
||||||
this.handleRuleEvent(event, rules);
|
this.handleRuleEvent(event, rules);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -76,7 +77,6 @@ export abstract class FormRulesManager<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class ByPassFormRuleManager<T> extends FormRulesManager<T> {
|
export class ByPassFormRuleManager<T> extends FormRulesManager<T> {
|
||||||
|
|
||||||
protected getRules(): T {
|
protected getRules(): T {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ export class WidgetVisibilityModel {
|
|||||||
return WidgetTypeEnum.field;
|
return WidgetTypeEnum.field;
|
||||||
} else if (this.leftRestResponseId) {
|
} else if (this.leftRestResponseId) {
|
||||||
return WidgetTypeEnum.variable;
|
return WidgetTypeEnum.variable;
|
||||||
} else if (!!this.json.leftType) {
|
} else if (this.json.leftType) {
|
||||||
return this.json.leftType;
|
return this.json.leftType;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -68,7 +68,7 @@ export class WidgetVisibilityModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get rightType(): string {
|
get rightType(): string {
|
||||||
if (!!this.json.rightType) {
|
if (this.json.rightType) {
|
||||||
return this.json.rightType;
|
return this.json.rightType;
|
||||||
} else if (this.json.rightValue) {
|
} else if (this.json.rightValue) {
|
||||||
return WidgetTypeEnum.value;
|
return WidgetTypeEnum.value;
|
||||||
|
@ -68,7 +68,7 @@ export class WidgetVisibilityService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public isFieldVisible(form: FormModel, visibilityObj: WidgetVisibilityModel, accumulator: any[] = [], result: boolean = false): boolean {
|
public isFieldVisible(form: FormModel, visibilityObj: WidgetVisibilityModel, accumulator: any[] = [], result?: boolean): boolean {
|
||||||
const leftValue = this.getLeftValue(form, visibilityObj);
|
const leftValue = this.getLeftValue(form, visibilityObj);
|
||||||
const rightValue = this.getRightValue(form, visibilityObj);
|
const rightValue = this.getRightValue(form, visibilityObj);
|
||||||
const actualResult = this.evaluateCondition(leftValue, rightValue, visibilityObj.operator);
|
const actualResult = this.evaluateCondition(leftValue, rightValue, visibilityObj.operator);
|
||||||
@ -88,7 +88,7 @@ export class WidgetVisibilityService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private transformToLiteralExpression(currentExpression: any): string {
|
private transformToLiteralExpression(currentExpression: any): string {
|
||||||
const currentTransformedValue = !!currentExpression.value ? 'true' : 'false';
|
const currentTransformedValue = currentExpression.value ? 'true' : 'false';
|
||||||
return currentTransformedValue.concat(this.transformToLiteralOperator(currentExpression.operator));
|
return currentTransformedValue.concat(this.transformToLiteralOperator(currentExpression.operator));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,9 +206,9 @@ export class WidgetVisibilityService {
|
|||||||
const containers = this.getFormTabContainers(form);
|
const containers = this.getFormTabContainers(form);
|
||||||
let isVisible: boolean = true;
|
let isVisible: boolean = true;
|
||||||
containers.map((container: ContainerModel) => {
|
containers.map((container: ContainerModel) => {
|
||||||
if (!!this.getCurrentFieldFromTabById(container, currentFormField.id)) {
|
if (this.getCurrentFieldFromTabById(container, currentFormField.id)) {
|
||||||
const currentTab = form.tabs.find((tab: TabModel) => tab.id === container.tab);
|
const currentTab = form.tabs.find((tab: TabModel) => tab.id === container.tab);
|
||||||
if (!!currentTab) {
|
if (currentTab) {
|
||||||
isVisible = currentTab.isVisible;
|
isVisible = currentTab.isVisible;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -230,7 +230,7 @@ export class WidgetVisibilityService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private getFormTabContainers(form: FormModel): ContainerModel[] {
|
private getFormTabContainers(form: FormModel): ContainerModel[] {
|
||||||
if (!!form) {
|
if (form) {
|
||||||
return form.fields.filter((field) => field.type === 'container' && field.tab) as ContainerModel[];
|
return form.fields.filter((field) => field.type === 'container' && field.tab) as ContainerModel[];
|
||||||
}
|
}
|
||||||
return [];
|
return [];
|
||||||
|
@ -15,6 +15,8 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* eslint-disable @cspell/spellchecker */
|
||||||
|
|
||||||
export const mockTabText = `Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam urna odio, sagittis vel nulla vel, condimentum egestas dolor.
|
export const mockTabText = `Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam urna odio, sagittis vel nulla vel, condimentum egestas dolor.
|
||||||
Interdum et malesuada fames ac ante ipsum primis in faucibus. Mauris eu hendrerit lectus. Aliquam et ex imperdiet, sodales tellus finibus, malesuada eros.
|
Interdum et malesuada fames ac ante ipsum primis in faucibus. Mauris eu hendrerit lectus. Aliquam et ex imperdiet, sodales tellus finibus, malesuada eros.
|
||||||
Vestibulum aliquet eros sed diam euismod tincidunt.
|
Vestibulum aliquet eros sed diam euismod tincidunt.
|
||||||
|
@ -38,7 +38,7 @@ export class CookieServiceMock extends CookieService {
|
|||||||
/** @override */
|
/** @override */
|
||||||
clear() {
|
clear() {
|
||||||
Object.keys(this).forEach((key) => {
|
Object.keys(this).forEach((key) => {
|
||||||
if (this.hasOwnProperty(key) && typeof this[key] !== 'function') {
|
if (Object.prototype.hasOwnProperty.call(this, key) && typeof this[key] !== 'function') {
|
||||||
this[key] = undefined;
|
this[key] = undefined;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
export class DemoForm {
|
export class DemoForm {
|
||||||
|
|
||||||
easyForm: any = {
|
easyForm: any = {
|
||||||
formRepresentation: {
|
formRepresentation: {
|
||||||
id: 1001,
|
id: 1001,
|
||||||
@ -1859,10 +1858,10 @@ export class DemoForm {
|
|||||||
id: 'my1r7YmMOs',
|
id: 'my1r7YmMOs',
|
||||||
type: 'paragraph',
|
type: 'paragraph',
|
||||||
data: {
|
data: {
|
||||||
text: `<font color="#000000">Is simply a redonly</font><mark class="cdx-marker">
|
text: `<font color="#000000">Is simply a readonly</font><mark class="cdx-marker">
|
||||||
<font color="#000000">dummy </font><b>text</b></mark><b></b><font color="#000000">
|
<font color="#000000">dummy </font><b>text</b></mark><b></b><font color="#000000">
|
||||||
of the </font><i>printing and typesetting</i><font color="#000000"> industry.\n
|
of the </font><i>printing and typesetting</i><font color="#000000"> industry.\n
|
||||||
</font><b><i>Lorem</i></b><font color="#000000"> Ipsum has been the industry\'s standard du</font><b>
|
</font><b><i>Lorem</i></b><font color="#000000"> Ipsum has been the industry's standard du</font><b>
|
||||||
<i>mmy text ever since the 1500s,\n when an unknown printer took a galley of type
|
<i>mmy text ever since the 1500s,\n when an unknown printer took a galley of type
|
||||||
and scrambled it to make a type specime</i></b><font color="#000000">n book. </font><font color="#ff1300">
|
and scrambled it to make a type specime</i></b><font color="#000000">n book. </font><font color="#ff1300">
|
||||||
It has survived not only five centuries</font><font color="#000000">,\n
|
It has survived not only five centuries</font><font color="#000000">,\n
|
||||||
@ -1880,10 +1879,7 @@ export class DemoForm {
|
|||||||
type: 'list',
|
type: 'list',
|
||||||
data: {
|
data: {
|
||||||
style: 'unordered',
|
style: 'unordered',
|
||||||
items: [
|
items: ['Unordered list example', 'Unordered list example']
|
||||||
'Unordered list example',
|
|
||||||
'Unordered list example'
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -1954,5 +1950,4 @@ export class DemoForm {
|
|||||||
getFormCloudDefinition(): any {
|
getFormCloudDefinition(): any {
|
||||||
return this.cloudFormDefinition;
|
return this.cloudFormDefinition;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export const formDefVisibilitiFieldDependsOnNextOne: any = {
|
export const formDefVisibilityFieldDependsOnNextOne: any = {
|
||||||
id: 19,
|
id: 19,
|
||||||
processDefinitionId: 'visibility:1:148',
|
processDefinitionId: 'visibility:1:148',
|
||||||
processDefinitionName: 'visibility',
|
processDefinitionName: 'visibility',
|
||||||
|
@ -173,13 +173,12 @@ export class PdfViewerComponent implements OnChanges, OnDestroy {
|
|||||||
|
|
||||||
const urlFile = changes['urlFile'];
|
const urlFile = changes['urlFile'];
|
||||||
if (urlFile?.currentValue) {
|
if (urlFile?.currentValue) {
|
||||||
const pdfOptions = {
|
const pdfOptions: any = {
|
||||||
...this.pdfjsDefaultOptions,
|
...this.pdfjsDefaultOptions,
|
||||||
url: urlFile.currentValue,
|
url: urlFile.currentValue,
|
||||||
withCredentials: this.appConfigService.get<boolean>('auth.withCredentials', undefined)
|
withCredentials: this.appConfigService.get<boolean>('auth.withCredentials', undefined)
|
||||||
};
|
};
|
||||||
if (this.cacheType) {
|
if (this.cacheType) {
|
||||||
// @ts-ignore
|
|
||||||
pdfOptions.httpHeaders = {
|
pdfOptions.httpHeaders = {
|
||||||
'Cache-Control': this.cacheType
|
'Cache-Control': this.cacheType
|
||||||
};
|
};
|
||||||
|
@ -24,7 +24,6 @@ import { Injectable } from '@angular/core';
|
|||||||
*/
|
*/
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class RenderingQueueServices {
|
export class RenderingQueueServices {
|
||||||
|
|
||||||
renderingStates = {
|
renderingStates = {
|
||||||
INITIAL: 0,
|
INITIAL: 0,
|
||||||
RUNNING: 1,
|
RUNNING: 1,
|
||||||
@ -149,22 +148,27 @@ export class RenderingQueueServices {
|
|||||||
renderView(view: any) {
|
renderView(view: any) {
|
||||||
const state = view.renderingState;
|
const state = view.renderingState;
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case this.renderingStates.FINISHED:
|
case this.renderingStates.FINISHED: {
|
||||||
return false;
|
return false;
|
||||||
case this.renderingStates.PAUSED:
|
}
|
||||||
|
case this.renderingStates.PAUSED: {
|
||||||
this.highestPriorityPage = view.renderingId;
|
this.highestPriorityPage = view.renderingId;
|
||||||
view.resume();
|
view.resume();
|
||||||
break;
|
break;
|
||||||
case this.renderingStates.RUNNING:
|
}
|
||||||
|
case this.renderingStates.RUNNING: {
|
||||||
this.highestPriorityPage = view.renderingId;
|
this.highestPriorityPage = view.renderingId;
|
||||||
break;
|
break;
|
||||||
case this.renderingStates.INITIAL:
|
}
|
||||||
|
case this.renderingStates.INITIAL: {
|
||||||
this.highestPriorityPage = view.renderingId;
|
this.highestPriorityPage = view.renderingId;
|
||||||
|
// eslint-disable-next-line space-before-function-paren
|
||||||
const continueRendering = function () {
|
const continueRendering = function () {
|
||||||
this.renderHighestPriority();
|
this.renderHighestPriority();
|
||||||
}.bind(this);
|
}.bind(this);
|
||||||
view.draw().then(continueRendering, continueRendering);
|
view.draw().then(continueRendering, continueRendering);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,6 @@ import { AppExtensionService, ViewerExtensionRef } from '@alfresco/adf-extension
|
|||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
})
|
})
|
||||||
export class ViewUtilService {
|
export class ViewUtilService {
|
||||||
|
|
||||||
// Extensions that are supported by the Viewer without conversion
|
// Extensions that are supported by the Viewer without conversion
|
||||||
private extensions = {
|
private extensions = {
|
||||||
image: ['png', 'jpg', 'jpeg', 'gif', 'bpm', 'svg'],
|
image: ['png', 'jpg', 'jpeg', 'gif', 'bpm', 'svg'],
|
||||||
@ -50,11 +49,10 @@ export class ViewUtilService {
|
|||||||
* Provides a list of file extensions supported by external plugins.
|
* Provides a list of file extensions supported by external plugins.
|
||||||
*/
|
*/
|
||||||
get externalExtensions(): string[] {
|
get externalExtensions(): string[] {
|
||||||
return this.viewerExtensions.map(ext => ext.fileExtension);
|
return this.viewerExtensions.map((ext) => ext.fileExtension);
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(private extensionService: AppExtensionService) {
|
constructor(private extensionService: AppExtensionService) {}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get File name from url
|
* get File name from url
|
||||||
@ -64,9 +62,7 @@ export class ViewUtilService {
|
|||||||
getFilenameFromUrl(url: string): string {
|
getFilenameFromUrl(url: string): string {
|
||||||
const anchor = url.indexOf('#');
|
const anchor = url.indexOf('#');
|
||||||
const query = url.indexOf('?');
|
const query = url.indexOf('?');
|
||||||
const end = Math.min(
|
const end = Math.min(anchor > 0 ? anchor : url.length, query > 0 ? query : url.length);
|
||||||
anchor > 0 ? anchor : url.length,
|
|
||||||
query > 0 ? query : url.length);
|
|
||||||
return url.substring(url.lastIndexOf('/', end) + 1, end);
|
return url.substring(url.lastIndexOf('/', end) + 1, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,7 +76,7 @@ export class ViewUtilService {
|
|||||||
*/
|
*/
|
||||||
getFileExtension(fileName: string): string {
|
getFileExtension(fileName: string): string {
|
||||||
if (fileName) {
|
if (fileName) {
|
||||||
const match = fileName.match(/\.([^\./\?\#]+)($|\?|\#)/);
|
const match = fileName.match(/\.([^./?#]+)($|\?|#)/);
|
||||||
return match ? match[1] : null;
|
return match ? match[1] : null;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -143,7 +139,7 @@ export class ViewUtilService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private isExternalViewer(): boolean {
|
private isExternalViewer(): boolean {
|
||||||
return !!this.viewerExtensions.find(ext => ext.fileExtension === '*');
|
return !!this.viewerExtensions.find((ext) => ext.fileExtension === '*');
|
||||||
}
|
}
|
||||||
|
|
||||||
isCustomViewerExtension(extension: string): boolean {
|
isCustomViewerExtension(extension: string): boolean {
|
||||||
@ -156,5 +152,4 @@ export class ViewUtilService {
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -94,7 +94,7 @@ export class DynamicColumnComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private updateInstance() {
|
private updateInstance() {
|
||||||
if (this.componentRef && this.componentRef.instance) {
|
if (this.componentRef?.instance) {
|
||||||
this.componentRef.instance.context = this.context;
|
this.componentRef.instance.context = this.context;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -89,8 +89,9 @@ export class DynamicExtensionComponent implements OnChanges, OnDestroy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private proxy(lifecycleMethod, ...args) {
|
private proxy(lifecycleMethod: string, ...args: any[]) {
|
||||||
if (this.componentCreated() && this.lifecycleHookIsImplemented(lifecycleMethod)) {
|
if (this.componentCreated() && this.lifecycleHookIsImplemented(lifecycleMethod)) {
|
||||||
|
// eslint-disable-next-line prefer-spread
|
||||||
this.componentRef.instance[lifecycleMethod].apply(this.componentRef.instance, args);
|
this.componentRef.instance[lifecycleMethod].apply(this.componentRef.instance, args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,7 @@ export class DynamicTabComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private updateInstance() {
|
private updateInstance() {
|
||||||
if (this.componentRef && this.componentRef.instance) {
|
if (this.componentRef?.instance) {
|
||||||
this.componentRef.instance.node = this.node;
|
this.componentRef.instance.node = this.node;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,7 @@ export class PreviewExtensionComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private updateInstance() {
|
private updateInstance() {
|
||||||
if (this.componentRef && this.componentRef.instance) {
|
if (this.componentRef?.instance) {
|
||||||
const instance = this.componentRef.instance;
|
const instance = this.componentRef.instance;
|
||||||
|
|
||||||
instance.url = this.url;
|
instance.url = this.url;
|
||||||
|
@ -135,7 +135,7 @@ export const mergeArrays = (left: any[], right: any[]): any[] => {
|
|||||||
|
|
||||||
(left || []).forEach((entry) => {
|
(left || []).forEach((entry) => {
|
||||||
const element = entry;
|
const element = entry;
|
||||||
if (element && element.hasOwnProperty('id')) {
|
if (element && Object.prototype.hasOwnProperty.call(element, 'id')) {
|
||||||
map[element.id] = element;
|
map[element.id] = element;
|
||||||
} else {
|
} else {
|
||||||
result.push(element);
|
result.push(element);
|
||||||
@ -144,7 +144,7 @@ export const mergeArrays = (left: any[], right: any[]): any[] => {
|
|||||||
|
|
||||||
(right || []).forEach((entry) => {
|
(right || []).forEach((entry) => {
|
||||||
const element = entry;
|
const element = entry;
|
||||||
if (element && element.hasOwnProperty('id') && map[element.id]) {
|
if (element && Object.prototype.hasOwnProperty.call(element, 'id') && map[element.id]) {
|
||||||
const merged = mergeObjects(map[element.id], element);
|
const merged = mergeObjects(map[element.id], element);
|
||||||
map[element.id] = merged;
|
map[element.id] = merged;
|
||||||
} else {
|
} else {
|
||||||
|
@ -79,7 +79,7 @@ export class AppExtensionService {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (extension.rules && extension.rules.disabled) {
|
if (extension.rules?.disabled) {
|
||||||
return this.extensionService.evaluateRule(extension.rules.disabled);
|
return this.extensionService.evaluateRule(extension.rules.disabled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ export class ExtensionLoaderService {
|
|||||||
config = JSON.parse(override);
|
config = JSON.parse(override);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!config.$references || !config.$references.length) {
|
if (!config.$references?.length) {
|
||||||
config.$references = this.filterIgnoredExtensions(extensions || [], config.$ignoreReferenceList);
|
config.$references = this.filterIgnoredExtensions(extensions || [], config.$ignoreReferenceList);
|
||||||
} else {
|
} else {
|
||||||
config.$references = this.filterIgnoredExtensions(config.$references, config.$ignoreReferenceList);
|
config.$references = this.filterIgnoredExtensions(config.$references, config.$ignoreReferenceList);
|
||||||
@ -102,7 +102,7 @@ export class ExtensionLoaderService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getRules(config: ExtensionConfig): Array<RuleRef> {
|
getRules(config: ExtensionConfig): Array<RuleRef> {
|
||||||
if (config && config.rules) {
|
if (config?.rules) {
|
||||||
return config.rules;
|
return config.rules;
|
||||||
}
|
}
|
||||||
return [];
|
return [];
|
||||||
@ -170,10 +170,10 @@ export class ExtensionLoaderService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private filterIgnoredExtensions(extensions: Array<string | ExtensionRef>, ignoreReferenceList: string[]): Array<string | ExtensionRef> {
|
private filterIgnoredExtensions(extensions: Array<string | ExtensionRef>, ignoreReferenceList: string[]): Array<string | ExtensionRef> {
|
||||||
if (!ignoreReferenceList || !ignoreReferenceList.length) {
|
if (!ignoreReferenceList?.length) {
|
||||||
return extensions;
|
return extensions;
|
||||||
}
|
}
|
||||||
|
|
||||||
return extensions.map((file: string) => file.match('(?!.*\/).+')[0]).filter((fileName: string) => !ignoreReferenceList.includes(fileName));
|
return extensions.map((file: string) => file.match('(?!.*/).+')[0]).filter((fileName: string) => !ignoreReferenceList.includes(fileName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -68,8 +68,8 @@ describe('ExtensionService', () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const requestedFeatue = service.getFeature('searchedArrayFeature');
|
const requestedFeature = service.getFeature('searchedArrayFeature');
|
||||||
expect(requestedFeatue).toEqual(searchedArrayFeature);
|
expect(requestedFeature).toEqual(searchedArrayFeature);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return object if seached feature is an object', async () => {
|
it('should return object if seached feature is an object', async () => {
|
||||||
@ -81,16 +81,16 @@ describe('ExtensionService', () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const requestedFeatue = service.getFeature<{ test: string }>('searchedObjectFeature');
|
const requestedFeature = service.getFeature<{ test: string }>('searchedObjectFeature');
|
||||||
expect(requestedFeatue).toEqual(searchedObjectFeature);
|
expect(requestedFeature).toEqual(searchedObjectFeature);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return default value if feature is not found', async () => {
|
it('should return default value if feature is not found', async () => {
|
||||||
const defaultValue = {};
|
const defaultValue = {};
|
||||||
service.setup(blankConfig);
|
service.setup(blankConfig);
|
||||||
|
|
||||||
const requestedFeatue = service.getFeature<{ test: string }>('searchedFeature', defaultValue);
|
const requestedFeature = service.getFeature<{ test: string }>('searchedFeature', defaultValue);
|
||||||
expect(requestedFeatue).toEqual(defaultValue);
|
expect(requestedFeature).toEqual(defaultValue);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -123,7 +123,7 @@ export class ExtensionService {
|
|||||||
*/
|
*/
|
||||||
getFeature<T = any[]>(key: string | string[], defaultValue: any = []): T {
|
getFeature<T = any[]>(key: string | string[], defaultValue: any = []): T {
|
||||||
const properties: string[] = Array.isArray(key) ? key : key.split('.');
|
const properties: string[] = Array.isArray(key) ? key : key.split('.');
|
||||||
return properties.reduce((prev, curr) => prev && prev[curr], this.features) || defaultValue;
|
return properties.reduce((prev, curr) => prev?.[curr], this.features) || defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
getElements<T extends ExtensionElement>(key: string, fallback: Array<T> = []): Array<T> {
|
getElements<T extends ExtensionElement>(key: string, fallback: Array<T> = []): Array<T> {
|
||||||
|
@ -62,7 +62,7 @@ export class RuleService {
|
|||||||
* @returns RuleEvaluator or null if not found
|
* @returns RuleEvaluator or null if not found
|
||||||
*/
|
*/
|
||||||
getEvaluator(key: string): RuleEvaluator {
|
getEvaluator(key: string): RuleEvaluator {
|
||||||
if (key && key.startsWith('!')) {
|
if (key?.startsWith('!')) {
|
||||||
const fn = this.evaluators[key.substring(1)];
|
const fn = this.evaluators[key.substring(1)];
|
||||||
return (context: RuleContext, ...args: RuleParameter[]): boolean => !fn(context, ...args);
|
return (context: RuleContext, ...args: RuleParameter[]): boolean => !fn(context, ...args);
|
||||||
}
|
}
|
||||||
|
@ -175,7 +175,7 @@ export class AnalyticsReportParametersComponent implements OnInit, OnChanges, On
|
|||||||
|
|
||||||
onValueChanged(values: any) {
|
onValueChanged(values: any) {
|
||||||
this.formValueChanged.emit(values);
|
this.formValueChanged.emit(values);
|
||||||
if (this.reportForm && this.reportForm.valid) {
|
if (this.reportForm?.valid) {
|
||||||
this.submit(values);
|
this.submit(values);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -306,7 +306,7 @@ export class AnalyticsReportParametersComponent implements OnInit, OnChanges, On
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngAfterContentChecked() {
|
ngAfterContentChecked() {
|
||||||
if (this.reportForm && this.reportForm.valid) {
|
if (this.reportForm?.valid) {
|
||||||
this.reportForm.markAsDirty();
|
this.reportForm.markAsDirty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -320,7 +320,7 @@ export class AnalyticsReportParametersComponent implements OnInit, OnChanges, On
|
|||||||
}
|
}
|
||||||
|
|
||||||
isFormValid() {
|
isFormValid() {
|
||||||
return this.reportForm && this.reportForm.dirty && this.reportForm.valid;
|
return this.reportForm?.dirty && this.reportForm.valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
get taskGroup(): UntypedFormGroup {
|
get taskGroup(): UntypedFormGroup {
|
||||||
|
@ -117,7 +117,7 @@ export class DiagramComponent implements OnChanges {
|
|||||||
|
|
||||||
setMetricValueToDiagramElement(diagram: DiagramModel, metrics: any, metricType: string) {
|
setMetricValueToDiagramElement(diagram: DiagramModel, metrics: any, metricType: string) {
|
||||||
for (const key in metrics) {
|
for (const key in metrics) {
|
||||||
if (metrics.hasOwnProperty(key)) {
|
if (Object.prototype.hasOwnProperty.call(metrics, key)) {
|
||||||
const foundElement: DiagramElementModel = diagram.elements.find(
|
const foundElement: DiagramElementModel = diagram.elements.find(
|
||||||
(element: DiagramElementModel) => element.id === key);
|
(element: DiagramElementModel) => element.id === key);
|
||||||
if (foundElement) {
|
if (foundElement) {
|
||||||
|
@ -40,8 +40,8 @@ export class BarChart extends Chart {
|
|||||||
|
|
||||||
constructor(obj?: any) {
|
constructor(obj?: any) {
|
||||||
super(obj);
|
super(obj);
|
||||||
this.xAxisType = obj && obj.xAxisType || null;
|
this.xAxisType = obj?.xAxisType || null;
|
||||||
this.yAxisType = obj && obj.yAxisType || null;
|
this.yAxisType = obj?.yAxisType || null;
|
||||||
this.options.scales.xAxes[0].ticks.callback = this.xAxisTickFormatFunction(this.xAxisType);
|
this.options.scales.xAxes[0].ticks.callback = this.xAxisTickFormatFunction(this.xAxisType);
|
||||||
this.options.scales.yAxes[0].ticks.callback = this.yAxisTickFormatFunction(this.yAxisType);
|
this.options.scales.yAxes[0].ticks.callback = this.yAxisTickFormatFunction(this.yAxisType);
|
||||||
if (obj.values) {
|
if (obj.values) {
|
||||||
|
@ -34,7 +34,7 @@ export class DiagramColorService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getFillColour(key: string) {
|
getFillColour(key: string) {
|
||||||
if (this.totalColors?.hasOwnProperty(key)) {
|
if (this.totalColors && Object.prototype.hasOwnProperty.call(this.totalColors, key)) {
|
||||||
const colorPercentage = this.totalColors[key];
|
const colorPercentage = this.totalColors[key];
|
||||||
return this.convertColorToHsb(colorPercentage);
|
return this.convertColorToHsb(colorPercentage);
|
||||||
} else {
|
} else {
|
||||||
|
@ -578,7 +578,7 @@ describe('FormCloudComponent', () => {
|
|||||||
spyOn(formComponent, 'handleError').and.stub();
|
spyOn(formComponent, 'handleError').and.stub();
|
||||||
spyOn(formCloudService, 'getTaskForm').and.callFake(() => throwError(error));
|
spyOn(formCloudService, 'getTaskForm').and.callFake(() => throwError(error));
|
||||||
|
|
||||||
formComponent.getFormByTaskId('test-app', '123').then((_) => {
|
formComponent.getFormByTaskId('test-app', '123').then(() => {
|
||||||
expect(formComponent.handleError).toHaveBeenCalledWith(error);
|
expect(formComponent.handleError).toHaveBeenCalledWith(error);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
@ -1049,7 +1049,7 @@ describe('FormCloudComponent', () => {
|
|||||||
pfx_property_five: 'orange',
|
pfx_property_five: 'orange',
|
||||||
pfx_property_none: 'no_form_field'
|
pfx_property_none: 'no_form_field'
|
||||||
}, 'Complete', 123).subscribe({
|
}, 'Complete', 123).subscribe({
|
||||||
next: _ => done.fail('expected an error, not data'),
|
next: () => done.fail('expected an error, not data'),
|
||||||
error: error => {
|
error: error => {
|
||||||
expect(error).toBe(errorMessage);
|
expect(error).toBe(errorMessage);
|
||||||
expect(formComponent.disableSaveButton).toBeFalse();
|
expect(formComponent.disableSaveButton).toBeFalse();
|
||||||
|
@ -94,7 +94,7 @@ export class AttachFileCloudWidgetComponent extends UploadCloudWidgetComponent i
|
|||||||
this.contentModelFormFileHandler(files[0]);
|
this.contentModelFormFileHandler(files[0]);
|
||||||
}
|
}
|
||||||
this.field.params.displayableCMProperties = this.field.params.displayableCMProperties ?? [];
|
this.field.params.displayableCMProperties = this.field.params.displayableCMProperties ?? [];
|
||||||
this.displayedColumns.splice(2, 0, ...this.field.params.displayableCMProperties?.map(property => property?.name));
|
this.displayedColumns.splice(2, 0, ...(this.field.params.displayableCMProperties?.map(property => property?.name) || []));
|
||||||
}
|
}
|
||||||
|
|
||||||
isPathStaticType(): boolean {
|
isPathStaticType(): boolean {
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user