diff --git a/core-web/apps/dotcms-ui/src/app/modules.ts b/core-web/apps/dotcms-ui/src/app/modules.ts index 399530e6a3ba..0bae1b7a5f47 100644 --- a/core-web/apps/dotcms-ui/src/app/modules.ts +++ b/core-web/apps/dotcms-ui/src/app/modules.ts @@ -28,10 +28,9 @@ import { DotContentCompareModule } from '@components/dot-content-compare/dot-con import { DotDialogModule } from '@components/dot-dialog/dot-dialog.module'; import { DotMessageDisplayModule } from '@components/dot-message-display/dot-message-display.module'; import { DotToolbarModule } from '@components/dot-toolbar/dot-toolbar.module'; -import { DotIconModule } from '@dotcms/ui'; +import { DotFieldValidationMessageComponent, DotIconModule } from '@dotcms/ui'; import { DotActionButtonModule } from './view/components/_common/dot-action-button/dot-action-button.module'; -import { DotFieldValidationMessageModule } from './view/components/_common/dot-field-validation-message/dot-file-validation-message.module'; import { DotGenerateSecurePasswordModule } from './view/components/_common/dot-generate-secure-password/dot-generate-secure-password.module'; import { DotSiteSelectorModule } from './view/components/_common/dot-site-selector/dot-site-selector.module'; import { DotTextareaContentModule } from './view/components/_common/dot-textarea-content/dot-textarea-content.module'; @@ -51,7 +50,7 @@ export const CUSTOM_MODULES = [ DotTextareaContentModule, DotWorkflowTaskDetailModule, DotMessageDisplayModule, - DotFieldValidationMessageModule, + DotFieldValidationMessageComponent, IFrameModule, DotListingDataTableModule, SearchableDropDownModule, diff --git a/core-web/apps/dotcms-ui/src/app/portlets/dot-edit-page/components/dot-favorite-page/dot-favorite-page.component.spec.ts b/core-web/apps/dotcms-ui/src/app/portlets/dot-edit-page/components/dot-favorite-page/dot-favorite-page.component.spec.ts index 7a5331f7a251..95c5f4bc6b04 100644 --- a/core-web/apps/dotcms-ui/src/app/portlets/dot-edit-page/components/dot-favorite-page/dot-favorite-page.component.spec.ts +++ b/core-web/apps/dotcms-ui/src/app/portlets/dot-edit-page/components/dot-favorite-page/dot-favorite-page.component.spec.ts @@ -10,13 +10,16 @@ import { MultiSelectModule } from 'primeng/multiselect'; import { of } from 'rxjs/internal/observable/of'; -import { DotFieldValidationMessageModule } from '@components/_common/dot-field-validation-message/dot-file-validation-message.module'; import { DotRouterService } from '@dotcms/app/api/services/dot-router/dot-router.service'; import { DotPagesFavoritePageEmptySkeletonComponent } from '@dotcms/app/portlets/dot-pages/dot-pages-favorite-page-empty-skeleton/dot-pages-favorite-page-empty-skeleton.component'; import { DotMessageService, DotSessionStorageService } from '@dotcms/data-access'; import { CoreWebService, CoreWebServiceMock, LoginService } from '@dotcms/dotcms-js'; import { DotPageRender, DotPageRenderState } from '@dotcms/dotcms-models'; -import { DotFieldRequiredDirective, DotMessagePipe } from '@dotcms/ui'; +import { + DotFieldRequiredDirective, + DotFieldValidationMessageComponent, + DotMessagePipe +} from '@dotcms/ui'; import { LoginServiceMock, MockDotMessageService, @@ -134,7 +137,7 @@ describe('DotFavoritePageComponent', () => { FormsModule, MultiSelectModule, ReactiveFormsModule, - DotFieldValidationMessageModule, + DotFieldValidationMessageComponent, DotFieldRequiredDirective, DotPagesFavoritePageEmptySkeletonComponent, HttpClientTestingModule diff --git a/core-web/apps/dotcms-ui/src/app/portlets/dot-edit-page/components/dot-favorite-page/dot-favorite-page.module.ts b/core-web/apps/dotcms-ui/src/app/portlets/dot-edit-page/components/dot-favorite-page/dot-favorite-page.module.ts index ee7a781e6aa6..74efb03f161b 100644 --- a/core-web/apps/dotcms-ui/src/app/portlets/dot-edit-page/components/dot-favorite-page/dot-favorite-page.module.ts +++ b/core-web/apps/dotcms-ui/src/app/portlets/dot-edit-page/components/dot-favorite-page/dot-favorite-page.module.ts @@ -5,12 +5,16 @@ import { ReactiveFormsModule } from '@angular/forms'; import { ButtonModule } from 'primeng/button'; import { InputTextModule } from 'primeng/inputtext'; -import { DotFieldValidationMessageModule } from '@components/_common/dot-field-validation-message/dot-file-validation-message.module'; import { DotFormDialogModule } from '@components/dot-form-dialog/dot-form-dialog.module'; import { DotTempFileUploadService } from '@dotcms/app/api/services/dot-temp-file-upload/dot-temp-file-upload.service'; import { DotPagesFavoritePageEmptySkeletonComponent } from '@dotcms/app/portlets/dot-pages/dot-pages-favorite-page-empty-skeleton/dot-pages-favorite-page-empty-skeleton.component'; import { DotWorkflowActionsFireService } from '@dotcms/data-access'; -import { DotAutofocusDirective, DotFieldRequiredDirective, DotMessagePipe } from '@dotcms/ui'; +import { + DotAutofocusDirective, + DotFieldRequiredDirective, + DotFieldValidationMessageComponent, + DotMessagePipe +} from '@dotcms/ui'; import { DotPipesModule } from '@pipes/dot-pipes.module'; import { DotFavoritePageComponent } from './dot-favorite-page.component'; @@ -23,7 +27,7 @@ import { DotFavoritePageComponent } from './dot-favorite-page.component'; ButtonModule, DotAutofocusDirective, DotFormDialogModule, - DotFieldValidationMessageModule, + DotFieldValidationMessageComponent, DotPagesFavoritePageEmptySkeletonComponent, DotPipesModule, InputTextModule, diff --git a/core-web/apps/dotcms-ui/src/app/portlets/dot-templates/dot-template-create-edit/dot-template-props/dot-template-props.component.spec.ts b/core-web/apps/dotcms-ui/src/app/portlets/dot-templates/dot-template-create-edit/dot-template-props/dot-template-props.component.spec.ts index 54fdf8a71a2e..4c2343f2e361 100644 --- a/core-web/apps/dotcms-ui/src/app/portlets/dot-templates/dot-template-create-edit/dot-template-props/dot-template-props.component.spec.ts +++ b/core-web/apps/dotcms-ui/src/app/portlets/dot-templates/dot-template-create-edit/dot-template-props/dot-template-props.component.spec.ts @@ -12,9 +12,12 @@ import { By } from '@angular/platform-browser'; import { DynamicDialogConfig, DynamicDialogRef } from 'primeng/dynamicdialog'; -import { DotFieldValidationMessageModule } from '@components/_common/dot-field-validation-message/dot-file-validation-message.module'; import { DotMessageService } from '@dotcms/data-access'; -import { DotFieldRequiredDirective, DotMessagePipe } from '@dotcms/ui'; +import { + DotFieldRequiredDirective, + DotFieldValidationMessageComponent, + DotMessagePipe +} from '@dotcms/ui'; import { MockDotMessageService } from '@dotcms/utils-testing'; import { DotTemplatePropsComponent } from './dot-template-props.component'; @@ -117,7 +120,7 @@ describe('DotTemplatePropsComponent', () => { DotMessagePipe, FormsModule, ReactiveFormsModule, - DotFieldValidationMessageModule, + DotFieldValidationMessageComponent, DotFieldRequiredDirective ], providers: [ diff --git a/core-web/apps/dotcms-ui/src/app/portlets/dot-templates/dot-template-create-edit/dot-template-props/dot-template-props.module.ts b/core-web/apps/dotcms-ui/src/app/portlets/dot-templates/dot-template-create-edit/dot-template-props/dot-template-props.module.ts index 7c419f399369..92b3dfbd0a66 100644 --- a/core-web/apps/dotcms-ui/src/app/portlets/dot-templates/dot-template-create-edit/dot-template-props/dot-template-props.module.ts +++ b/core-web/apps/dotcms-ui/src/app/portlets/dot-templates/dot-template-create-edit/dot-template-props/dot-template-props.module.ts @@ -5,10 +5,13 @@ import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { InputTextModule } from 'primeng/inputtext'; import { InputTextareaModule } from 'primeng/inputtextarea'; -import { DotFieldValidationMessageModule } from '@components/_common/dot-field-validation-message/dot-file-validation-message.module'; import { DotFormDialogModule } from '@components/dot-form-dialog/dot-form-dialog.module'; import { DotThemeSelectorDropdownModule } from '@components/dot-theme-selector-dropdown/dot-theme-selector-dropdown.module'; -import { DotFieldRequiredDirective, DotMessagePipe } from '@dotcms/ui'; +import { + DotFieldRequiredDirective, + DotFieldValidationMessageComponent, + DotMessagePipe +} from '@dotcms/ui'; import { DotTemplatePropsComponent } from './dot-template-props.component'; import { DotTemplateThumbnailFieldModule } from './dot-template-thumbnail-field/dot-template-thumbnail-field.module'; @@ -17,7 +20,7 @@ import { DotTemplateThumbnailFieldModule } from './dot-template-thumbnail-field/ declarations: [DotTemplatePropsComponent], imports: [ CommonModule, - DotFieldValidationMessageModule, + DotFieldValidationMessageComponent, DotFormDialogModule, FormsModule, InputTextModule, diff --git a/core-web/apps/dotcms-ui/src/app/portlets/shared/dot-content-types-edit/components/fields/content-type-fields-drop-zone/content-type-fields-drop-zone.component.spec.ts b/core-web/apps/dotcms-ui/src/app/portlets/shared/dot-content-types-edit/components/fields/content-type-fields-drop-zone/content-type-fields-drop-zone.component.spec.ts index ae43ac6cf2c8..581fc6206955 100644 --- a/core-web/apps/dotcms-ui/src/app/portlets/shared/dot-content-types-edit/components/fields/content-type-fields-drop-zone/content-type-fields-drop-zone.component.spec.ts +++ b/core-web/apps/dotcms-ui/src/app/portlets/shared/dot-content-types-edit/components/fields/content-type-fields-drop-zone/content-type-fields-drop-zone.component.spec.ts @@ -27,7 +27,6 @@ import { TableModule } from 'primeng/table'; import { TabViewModule } from 'primeng/tabview'; import { DotActionButtonModule } from '@components/_common/dot-action-button/dot-action-button.module'; -import { DotFieldValidationMessageModule } from '@components/_common/dot-field-validation-message/dot-file-validation-message.module'; import { DotDialogActions, DotDialogComponent } from '@components/dot-dialog/dot-dialog.component'; import { DotDialogModule } from '@components/dot-dialog/dot-dialog.module'; import { DotMessageDisplayService } from '@components/dot-message-display/services'; @@ -41,7 +40,7 @@ import { DotCMSContentTypeLayoutRow, DotFieldVariable } from '@dotcms/dotcms-models'; -import { DotIconModule, DotMessagePipe } from '@dotcms/ui'; +import { DotFieldValidationMessageComponent, DotIconModule, DotMessagePipe } from '@dotcms/ui'; import { DotLoadingIndicatorService } from '@dotcms/utils'; import { cleanUpDialog, @@ -212,7 +211,7 @@ describe('ContentTypeFieldsDropZoneComponent', () => { DotIconModule, DragulaModule, TableModule, - DotFieldValidationMessageModule, + DotFieldValidationMessageComponent, ReactiveFormsModule, HttpClientTestingModule, DotMessagePipe, @@ -484,7 +483,6 @@ describe('Load fields and drag and drop', () => { } ]), DragulaModule, - DotFieldValidationMessageModule, DotContentTypeFieldsVariablesModule, FormsModule, CheckboxModule, diff --git a/core-web/apps/dotcms-ui/src/app/portlets/shared/dot-content-types-edit/components/fields/content-type-fields-properties-form/field-properties/default-value-property/default-value-property.component.spec.ts b/core-web/apps/dotcms-ui/src/app/portlets/shared/dot-content-types-edit/components/fields/content-type-fields-properties-form/field-properties/default-value-property/default-value-property.component.spec.ts index 334de3be8cb4..1bf549dac765 100644 --- a/core-web/apps/dotcms-ui/src/app/portlets/shared/dot-content-types-edit/components/fields/content-type-fields-properties-form/field-properties/default-value-property/default-value-property.component.spec.ts +++ b/core-web/apps/dotcms-ui/src/app/portlets/shared/dot-content-types-edit/components/fields/content-type-fields-properties-form/field-properties/default-value-property/default-value-property.component.spec.ts @@ -8,9 +8,8 @@ import { } from '@angular/forms'; import { By } from '@angular/platform-browser'; -import { DotFieldValidationMessageComponent } from '@components/_common/dot-field-validation-message/dot-field-validation-message'; import { DotMessageService } from '@dotcms/data-access'; -import { DotMessagePipe } from '@dotcms/ui'; +import { DotFieldValidationMessageComponent, DotMessagePipe } from '@dotcms/ui'; import { dotcmsContentTypeFieldBasicMock, MockDotMessageService } from '@dotcms/utils-testing'; import { DotPipesModule } from '@pipes/dot-pipes.module'; @@ -30,8 +29,13 @@ describe('DefaultValuePropertyComponent', () => { beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ - declarations: [DefaultValuePropertyComponent, DotFieldValidationMessageComponent], - imports: [ReactiveFormsModule, DotPipesModule, DotMessagePipe], + declarations: [DefaultValuePropertyComponent], + imports: [ + ReactiveFormsModule, + DotPipesModule, + DotMessagePipe, + DotFieldValidationMessageComponent + ], providers: [{ provide: DotMessageService, useValue: messageServiceMock }] }).compileComponents(); diff --git a/core-web/apps/dotcms-ui/src/app/portlets/shared/dot-content-types-edit/components/fields/content-type-fields-properties-form/field-properties/dot-relationships-property/dot-relationships.module.ts b/core-web/apps/dotcms-ui/src/app/portlets/shared/dot-content-types-edit/components/fields/content-type-fields-properties-form/field-properties/dot-relationships-property/dot-relationships.module.ts index 1e5a18ba568d..5238311e6d86 100644 --- a/core-web/apps/dotcms-ui/src/app/portlets/shared/dot-content-types-edit/components/fields/content-type-fields-properties-form/field-properties/dot-relationships-property/dot-relationships.module.ts +++ b/core-web/apps/dotcms-ui/src/app/portlets/shared/dot-content-types-edit/components/fields/content-type-fields-properties-form/field-properties/dot-relationships-property/dot-relationships.module.ts @@ -5,9 +5,12 @@ import { FormsModule } from '@angular/forms'; import { DropdownModule } from 'primeng/dropdown'; import { RadioButtonModule } from 'primeng/radiobutton'; -import { DotFieldValidationMessageModule } from '@components/_common/dot-field-validation-message/dot-file-validation-message.module'; import { SearchableDropDownModule } from '@components/_common/searchable-dropdown'; -import { DotFieldRequiredDirective, DotMessagePipe } from '@dotcms/ui'; +import { + DotFieldRequiredDirective, + DotFieldValidationMessageComponent, + DotMessagePipe +} from '@dotcms/ui'; import { DotPipesModule } from '@pipes/dot-pipes.module'; import { DotCardinalitySelectorComponent } from './dot-cardinality-selector/dot-cardinality-selector.component'; @@ -28,7 +31,7 @@ import { DotRelationshipService } from './services/dot-relationship.service'; imports: [ CommonModule, DropdownModule, - DotFieldValidationMessageModule, + DotFieldValidationMessageComponent, FormsModule, RadioButtonModule, SearchableDropDownModule, diff --git a/core-web/apps/dotcms-ui/src/app/portlets/shared/dot-content-types-edit/components/form/content-types-form.component.spec.ts b/core-web/apps/dotcms-ui/src/app/portlets/shared/dot-content-types-edit/components/form/content-types-form.component.spec.ts index 671abad2ae4a..adb79399cef5 100644 --- a/core-web/apps/dotcms-ui/src/app/portlets/shared/dot-content-types-edit/components/form/content-types-form.component.spec.ts +++ b/core-web/apps/dotcms-ui/src/app/portlets/shared/dot-content-types-edit/components/form/content-types-form.component.spec.ts @@ -21,7 +21,6 @@ import { InputTextModule } from 'primeng/inputtext'; import { OverlayPanelModule } from 'primeng/overlaypanel'; import { TabViewModule } from 'primeng/tabview'; -import { DotFieldValidationMessageModule } from '@components/_common/dot-field-validation-message/dot-file-validation-message.module'; import { DotPageSelectorModule } from '@components/_common/dot-page-selector/dot-page-selector.module'; import { DotWorkflowsActionsSelectorFieldModule } from '@components/_common/dot-workflows-actions-selector-field/dot-workflows-actions-selector-field.module'; import { DotWorkflowsSelectorFieldModule } from '@components/_common/dot-workflows-selector-field/dot-workflows-selector-field.module'; @@ -38,7 +37,7 @@ import { } from '@dotcms/data-access'; import { DotcmsConfigService, LoginService, SiteService } from '@dotcms/dotcms-js'; import { DotCMSContentTypeLayoutRow, DotCMSSystemActionType } from '@dotcms/dotcms-models'; -import { DotIconModule, DotMessagePipe } from '@dotcms/ui'; +import { DotFieldValidationMessageComponent, DotIconModule, DotMessagePipe } from '@dotcms/ui'; import { dotcmsContentTypeBasicMock, dotcmsContentTypeFieldBasicMock, @@ -165,7 +164,7 @@ describe('ContentTypesFormComponent', () => { ButtonModule, DotDirectivesModule, DotFieldHelperModule, - DotFieldValidationMessageModule, + DotFieldValidationMessageComponent, DotIconModule, DotPageSelectorModule, DotWorkflowsActionsSelectorFieldModule, diff --git a/core-web/apps/dotcms-ui/src/app/portlets/shared/dot-content-types-edit/dot-content-types-edit.module.ts b/core-web/apps/dotcms-ui/src/app/portlets/shared/dot-content-types-edit/dot-content-types-edit.module.ts index 82173910f944..edc9457ea177 100644 --- a/core-web/apps/dotcms-ui/src/app/portlets/shared/dot-content-types-edit/dot-content-types-edit.module.ts +++ b/core-web/apps/dotcms-ui/src/app/portlets/shared/dot-content-types-edit/dot-content-types-edit.module.ts @@ -18,7 +18,6 @@ import { TabViewModule } from 'primeng/tabview'; import { TooltipModule } from 'primeng/tooltip'; import { DotAddToBundleModule } from '@components/_common/dot-add-to-bundle'; -import { DotFieldValidationMessageModule } from '@components/_common/dot-field-validation-message/dot-file-validation-message.module'; import { DotInlineEditModule } from '@components/_common/dot-inline-edit/dot-inline-edit.module'; import { DotMenuModule } from '@components/_common/dot-menu/dot-menu.module'; import { DotPageSelectorModule } from '@components/_common/dot-page-selector/dot-page-selector.module'; @@ -43,6 +42,7 @@ import { DotContentTypesInfoService, DotWorkflowService } from '@dotcms/data-acc import { DotAutofocusDirective, DotFieldRequiredDirective, + DotFieldValidationMessageComponent, DotIconModule, DotMessagePipe } from '@dotcms/ui'; @@ -130,7 +130,7 @@ import { DotAddToMenuModule } from '../dot-content-types-listing/components/dot- DotPipesModule, DotSecondaryToolbarModule, DotFieldHelperModule, - DotFieldValidationMessageModule, + DotFieldValidationMessageComponent, TooltipModule, DotIconModule, DotMaxlengthModule, diff --git a/core-web/apps/dotcms-ui/src/app/portlets/shared/dot-content-types-listing/components/dot-add-to-menu/dot-add-to-menu.component.spec.ts b/core-web/apps/dotcms-ui/src/app/portlets/shared/dot-content-types-listing/components/dot-add-to-menu/dot-add-to-menu.component.spec.ts index 8521153aafc8..2cb693f02948 100644 --- a/core-web/apps/dotcms-ui/src/app/portlets/shared/dot-content-types-listing/components/dot-add-to-menu/dot-add-to-menu.component.spec.ts +++ b/core-web/apps/dotcms-ui/src/app/portlets/shared/dot-content-types-listing/components/dot-add-to-menu/dot-add-to-menu.component.spec.ts @@ -12,7 +12,6 @@ import { DropdownModule } from 'primeng/dropdown'; import { InputTextModule } from 'primeng/inputtext'; import { RadioButtonModule } from 'primeng/radiobutton'; -import { DotFieldValidationMessageModule } from '@components/_common/dot-field-validation-message/dot-file-validation-message.module'; import { DotDialogModule } from '@components/dot-dialog/dot-dialog.module'; import { DotMenuServiceMock } from '@components/dot-navigation/services/dot-navigation.service.spec'; import { @@ -22,7 +21,7 @@ import { import { DotMenuService } from '@dotcms/app/api/services/dot-menu.service'; import { DotMessageService } from '@dotcms/data-access'; import { CoreWebService } from '@dotcms/dotcms-js'; -import { DotMessagePipe } from '@dotcms/ui'; +import { DotFieldValidationMessageComponent, DotMessagePipe } from '@dotcms/ui'; import { CoreWebServiceMock, dotcmsContentTypeBasicMock, @@ -103,7 +102,7 @@ describe('DotAddToMenuComponent', () => { DotPipesModule, DotMessagePipe, HttpClientTestingModule, - DotFieldValidationMessageModule + DotFieldValidationMessageComponent ], providers: [ { provide: CoreWebService, useClass: CoreWebServiceMock }, diff --git a/core-web/apps/dotcms-ui/src/app/portlets/shared/dot-content-types-listing/components/dot-add-to-menu/dot-add-to-menu.module.ts b/core-web/apps/dotcms-ui/src/app/portlets/shared/dot-content-types-listing/components/dot-add-to-menu/dot-add-to-menu.module.ts index 4ce00f7a5cea..f1a413da7923 100644 --- a/core-web/apps/dotcms-ui/src/app/portlets/shared/dot-content-types-listing/components/dot-add-to-menu/dot-add-to-menu.module.ts +++ b/core-web/apps/dotcms-ui/src/app/portlets/shared/dot-content-types-listing/components/dot-add-to-menu/dot-add-to-menu.module.ts @@ -6,12 +6,16 @@ import { DropdownModule } from 'primeng/dropdown'; import { InputTextModule } from 'primeng/inputtext'; import { RadioButtonModule } from 'primeng/radiobutton'; -import { DotFieldValidationMessageModule } from '@components/_common/dot-field-validation-message/dot-file-validation-message.module'; import { DotDialogModule } from '@components/dot-dialog/dot-dialog.module'; import { DotNavigationService } from '@components/dot-navigation/services/dot-navigation.service'; import { DotAddToMenuService } from '@dotcms/app/api/services/add-to-menu/add-to-menu.service'; import { DotMenuService } from '@dotcms/app/api/services/dot-menu.service'; -import { DotAutofocusDirective, DotFieldRequiredDirective, DotMessagePipe } from '@dotcms/ui'; +import { + DotAutofocusDirective, + DotFieldRequiredDirective, + DotFieldValidationMessageComponent, + DotMessagePipe +} from '@dotcms/ui'; import { DotPipesModule } from '@pipes/dot-pipes.module'; import { DotAddToMenuComponent } from './dot-add-to-menu.component'; @@ -23,7 +27,7 @@ import { DotAddToMenuComponent } from './dot-add-to-menu.component'; CommonModule, DotAutofocusDirective, DotDialogModule, - DotFieldValidationMessageModule, + DotFieldValidationMessageComponent, DotPipesModule, DropdownModule, InputTextModule, diff --git a/core-web/apps/dotcms-ui/src/app/portlets/shared/dot-content-types-listing/components/dot-content-type-copy-dialog/dot-content-type-copy-dialog.component.spec.ts b/core-web/apps/dotcms-ui/src/app/portlets/shared/dot-content-types-listing/components/dot-content-type-copy-dialog/dot-content-type-copy-dialog.component.spec.ts index 66b10e96db7f..e15ff69a67a1 100644 --- a/core-web/apps/dotcms-ui/src/app/portlets/shared/dot-content-types-listing/components/dot-content-type-copy-dialog/dot-content-type-copy-dialog.component.spec.ts +++ b/core-web/apps/dotcms-ui/src/app/portlets/shared/dot-content-types-listing/components/dot-content-type-copy-dialog/dot-content-type-copy-dialog.component.spec.ts @@ -7,13 +7,12 @@ import { ReactiveFormsModule } from '@angular/forms'; import { By } from '@angular/platform-browser'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; -import { DotFieldValidationMessageModule } from '@components/_common/dot-field-validation-message/dot-file-validation-message.module'; import { DotMdIconSelectorModule } from '@components/_common/dot-md-icon-selector/dot-md-icon-selector.module'; import { SiteSelectorFieldModule } from '@components/_common/dot-site-selector-field/dot-site-selector-field.module'; import { DotDialogModule } from '@components/dot-dialog/dot-dialog.module'; import { DotEventsService, DotMessageService } from '@dotcms/data-access'; import { CoreWebService, SiteService } from '@dotcms/dotcms-js'; -import { DotMessagePipe } from '@dotcms/ui'; +import { DotFieldValidationMessageComponent, DotMessagePipe } from '@dotcms/ui'; import { CoreWebServiceMock, MockDotMessageService, SiteServiceMock } from '@dotcms/utils-testing'; import { DotPipesModule } from '@pipes/dot-pipes.module'; import { DotFormSelectorModule } from '@portlets/dot-edit-page/content/components/dot-form-selector/dot-form-selector.module'; @@ -55,7 +54,7 @@ describe('DotContentTypeCloneDialogComponent', () => { imports: [ DotFormSelectorModule, BrowserAnimationsModule, - DotFieldValidationMessageModule, + DotFieldValidationMessageComponent, DotMdIconSelectorModule, SiteSelectorFieldModule, DotDialogModule, diff --git a/core-web/apps/dotcms-ui/src/app/portlets/shared/dot-content-types-listing/components/dot-content-type-copy-dialog/dot-content-type-copy-dialog.module.ts b/core-web/apps/dotcms-ui/src/app/portlets/shared/dot-content-types-listing/components/dot-content-type-copy-dialog/dot-content-type-copy-dialog.module.ts index ad10b961d9ba..958480fc6440 100644 --- a/core-web/apps/dotcms-ui/src/app/portlets/shared/dot-content-types-listing/components/dot-content-type-copy-dialog/dot-content-type-copy-dialog.module.ts +++ b/core-web/apps/dotcms-ui/src/app/portlets/shared/dot-content-types-listing/components/dot-content-type-copy-dialog/dot-content-type-copy-dialog.module.ts @@ -4,13 +4,17 @@ import { ReactiveFormsModule } from '@angular/forms'; import { InputTextModule } from 'primeng/inputtext'; -import { DotFieldValidationMessageModule } from '@components/_common/dot-field-validation-message/dot-file-validation-message.module'; import { DotMdIconSelectorModule } from '@components/_common/dot-md-icon-selector/dot-md-icon-selector.module'; import { SiteSelectorFieldModule } from '@components/_common/dot-site-selector-field/dot-site-selector-field.module'; import { DotBaseTypeSelectorModule } from '@components/dot-base-type-selector'; import { DotDialogModule } from '@components/dot-dialog/dot-dialog.module'; import { DotListingDataTableModule } from '@components/dot-listing-data-table'; -import { DotAutofocusDirective, DotFieldRequiredDirective, DotMessagePipe } from '@dotcms/ui'; +import { + DotAutofocusDirective, + DotFieldRequiredDirective, + DotFieldValidationMessageComponent, + DotMessagePipe +} from '@dotcms/ui'; import { DotPipesModule } from '@pipes/dot-pipes.module'; import { DotContentTypeCopyDialogComponent } from './dot-content-type-copy-dialog.component'; @@ -23,7 +27,7 @@ import { DotContentTypeCopyDialogComponent } from './dot-content-type-copy-dialo DotListingDataTableModule, DotBaseTypeSelectorModule, DotPipesModule, - DotFieldValidationMessageModule, + DotFieldValidationMessageComponent, DotDialogModule, DotMdIconSelectorModule, SiteSelectorFieldModule, diff --git a/core-web/apps/dotcms-ui/src/app/view/components/_common/dot-add-to-bundle/dot-add-to-bundle.component.spec.ts b/core-web/apps/dotcms-ui/src/app/view/components/_common/dot-add-to-bundle/dot-add-to-bundle.component.spec.ts index 9d2089be2e4b..fab27fd83b8d 100644 --- a/core-web/apps/dotcms-ui/src/app/view/components/_common/dot-add-to-bundle/dot-add-to-bundle.component.spec.ts +++ b/core-web/apps/dotcms-ui/src/app/view/components/_common/dot-add-to-bundle/dot-add-to-bundle.component.spec.ts @@ -9,12 +9,11 @@ import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { DOTTestBed } from '@dotcms/app/test/dot-test-bed'; import { AddToBundleService, DotMessageService } from '@dotcms/data-access'; +import { DotFieldValidationMessageComponent } from '@dotcms/ui'; import { MockDotMessageService } from '@dotcms/utils-testing'; import { DotAddToBundleComponent } from './dot-add-to-bundle.component'; -import { DotFieldValidationMessageModule } from '../dot-field-validation-message/dot-file-validation-message.module'; - class AddToBundleServiceMock { getBundles(): Observable { return observableOf([]); @@ -54,7 +53,7 @@ xdescribe('DotAddToBundleComponent', () => { DOTTestBed.configureTestingModule({ declarations: [DotAddToBundleComponent, TestHostComponent], - imports: [BrowserAnimationsModule, DotFieldValidationMessageModule], + imports: [BrowserAnimationsModule, DotFieldValidationMessageComponent], providers: [ { provide: AddToBundleService, useValue: addToBundleServiceMock }, { provide: DotMessageService, useValue: messageServiceMock } diff --git a/core-web/apps/dotcms-ui/src/app/view/components/_common/dot-add-to-bundle/dot-add-to-bundle.module.ts b/core-web/apps/dotcms-ui/src/app/view/components/_common/dot-add-to-bundle/dot-add-to-bundle.module.ts index ae798c2634f7..d2fb9d7232a9 100644 --- a/core-web/apps/dotcms-ui/src/app/view/components/_common/dot-add-to-bundle/dot-add-to-bundle.module.ts +++ b/core-web/apps/dotcms-ui/src/app/view/components/_common/dot-add-to-bundle/dot-add-to-bundle.module.ts @@ -7,13 +7,11 @@ import { DropdownModule } from 'primeng/dropdown'; import { DotDialogModule } from '@components/dot-dialog/dot-dialog.module'; import { AddToBundleService, DotCurrentUserService } from '@dotcms/data-access'; -import { DotMessagePipe } from '@dotcms/ui'; +import { DotFieldValidationMessageComponent, DotMessagePipe } from '@dotcms/ui'; import { DotPipesModule } from '@pipes/dot-pipes.module'; import { DotAddToBundleComponent } from './dot-add-to-bundle.component'; -import { DotFieldValidationMessageModule } from '../dot-field-validation-message/dot-file-validation-message.module'; - @NgModule({ declarations: [DotAddToBundleComponent], exports: [DotAddToBundleComponent], @@ -24,7 +22,7 @@ import { DotFieldValidationMessageModule } from '../dot-field-validation-message DotDialogModule, ReactiveFormsModule, DropdownModule, - DotFieldValidationMessageModule, + DotFieldValidationMessageComponent, DotPipesModule, DotMessagePipe ], diff --git a/core-web/apps/dotcms-ui/src/app/view/components/_common/dot-field-validation-message/dot-field-validation-message.html b/core-web/apps/dotcms-ui/src/app/view/components/_common/dot-field-validation-message/dot-field-validation-message.html deleted file mode 100644 index 44665d527103..000000000000 --- a/core-web/apps/dotcms-ui/src/app/view/components/_common/dot-field-validation-message/dot-field-validation-message.html +++ /dev/null @@ -1,7 +0,0 @@ - - {{ errorMsg | dm }} - diff --git a/core-web/apps/dotcms-ui/src/app/view/components/_common/dot-field-validation-message/dot-field-validation-message.spec.ts b/core-web/apps/dotcms-ui/src/app/view/components/_common/dot-field-validation-message/dot-field-validation-message.spec.ts deleted file mode 100644 index 7c4d7f533855..000000000000 --- a/core-web/apps/dotcms-ui/src/app/view/components/_common/dot-field-validation-message/dot-field-validation-message.spec.ts +++ /dev/null @@ -1,101 +0,0 @@ -/* eslint-disable @typescript-eslint/no-explicit-any */ - -import { DebugElement, Pipe, PipeTransform } from '@angular/core'; -import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; -import { UntypedFormControl, Validators } from '@angular/forms'; -import { By } from '@angular/platform-browser'; - -import { DotMessageService } from '@dotcms/data-access'; -import { MockDotMessageService } from '@dotcms/utils-testing'; - -import { DotFieldValidationMessageComponent } from './dot-field-validation-message'; - -@Pipe({ - name: 'dm' -}) -class DotMessageMockPipe implements PipeTransform { - transform(): string { - return 'Required'; - } -} - -const messageServiceMock = new MockDotMessageService({ - 'contentType.errors.input.maxlength': 'Value must be no more than {0} characters', - 'contentType.form.variable.placeholder': 'Will be auto-generated if left empty' -}); - -describe('FieldValidationComponent', () => { - let de: DebugElement; - let el: HTMLElement; - let fixture: ComponentFixture; - let component: DotFieldValidationMessageComponent; - - beforeEach(waitForAsync(() => { - TestBed.configureTestingModule({ - declarations: [DotFieldValidationMessageComponent, DotMessageMockPipe], - providers: [ - { - provide: DotMessageService, - useValue: messageServiceMock - } - ] - }).compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(DotFieldValidationMessageComponent); - component = fixture.debugElement.componentInstance; - }); - - it('should hide the message by default', () => { - const control = new UntypedFormControl('', Validators.required); - component.field = control; - fixture.detectChanges(); - de = fixture.debugElement.query(By.css('[data-testId="dotErrorMsg"]')); - expect(de).toBeNull(); - }); - - it('should hide the message when field it is valid', () => { - const control = new UntypedFormControl('valid-content', Validators.required); - control.markAsDirty(); - control.markAsTouched(); - - component.field = control; - - fixture.detectChanges(); - de = fixture.debugElement.query(By.css('[data-testId="dotErrorMsg"]')); - - expect(de).toBeNull(); - }); - - it('should show the default message when field it is dirty and invalid', () => { - const control = new UntypedFormControl('', Validators.required); - control.markAsDirty(); - control.markAsTouched(); - component.field = control; - - fixture.detectChanges(); - - de = fixture.debugElement.query(By.css('[data-testId="dotErrorMsg"]')); - el = de.nativeElement; - expect(el).toBeDefined(); - expect(el.textContent).toContain('Required'); - }); - - it('should show the message when field it is dirty and invalid', () => { - const control = new UntypedFormControl('', Validators.required); - component.defaultMessage = 'Required'; - - control.markAsDirty(); - control.markAsTouched(); - - component.field = control; - fixture.detectChanges(); - - de = fixture.debugElement.query(By.css('[data-testId="dotErrorMsg"]')); - - el = de.nativeElement; - expect(el).toBeDefined(); - expect(el.textContent).toContain('Required'); - }); -}); diff --git a/core-web/apps/dotcms-ui/src/app/view/components/_common/dot-field-validation-message/dot-file-validation-message.module.ts b/core-web/apps/dotcms-ui/src/app/view/components/_common/dot-field-validation-message/dot-file-validation-message.module.ts deleted file mode 100644 index 0bc85645921c..000000000000 --- a/core-web/apps/dotcms-ui/src/app/view/components/_common/dot-field-validation-message/dot-file-validation-message.module.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { CommonModule } from '@angular/common'; -import { NgModule } from '@angular/core'; - -import { DotMessagePipe } from '@dotcms/ui'; - -import { DotFieldValidationMessageComponent } from './dot-field-validation-message'; - -@NgModule({ - bootstrap: [], - declarations: [DotFieldValidationMessageComponent], - exports: [DotFieldValidationMessageComponent], - imports: [CommonModule, DotMessagePipe], - providers: [] -}) -export class DotFieldValidationMessageModule {} diff --git a/core-web/apps/dotcms-ui/src/app/view/components/_common/dot-push-publish-dialog/dot-push-publish-dialog.module.ts b/core-web/apps/dotcms-ui/src/app/view/components/_common/dot-push-publish-dialog/dot-push-publish-dialog.module.ts index 8787c961ab50..43d19beb7bc9 100644 --- a/core-web/apps/dotcms-ui/src/app/view/components/_common/dot-push-publish-dialog/dot-push-publish-dialog.module.ts +++ b/core-web/apps/dotcms-ui/src/app/view/components/_common/dot-push-publish-dialog/dot-push-publish-dialog.module.ts @@ -10,9 +10,9 @@ import { DotPushPublishDialogComponent } from '@components/_common/dot-push-publ import { DotPushPublishFormModule } from '@components/_common/forms/dot-push-publish-form/dot-push-publish-form.module'; import { DotDialogModule } from '@components/dot-dialog/dot-dialog.module'; import { DotPushPublishFiltersService } from '@dotcms/data-access'; +import { DotFieldValidationMessageComponent } from '@dotcms/ui'; import { DotPipesModule } from '@pipes/dot-pipes.module'; -import { DotFieldValidationMessageModule } from '../dot-field-validation-message/dot-file-validation-message.module'; import { PushPublishEnvSelectorModule } from '../dot-push-publish-env-selector/dot-push-publish-env-selector.module'; @NgModule({ @@ -27,7 +27,7 @@ import { PushPublishEnvSelectorModule } from '../dot-push-publish-env-selector/d PushPublishEnvSelectorModule, ReactiveFormsModule, DropdownModule, - DotFieldValidationMessageModule, + DotFieldValidationMessageComponent, SelectButtonModule, DotPipesModule, DotPushPublishFormModule diff --git a/core-web/apps/dotcms-ui/src/app/view/components/_common/forms/dot-push-publish-form/dot-push-publish-form.component.spec.ts b/core-web/apps/dotcms-ui/src/app/view/components/_common/forms/dot-push-publish-form/dot-push-publish-form.component.spec.ts index 2c7ca0b18acf..3dc75a509278 100644 --- a/core-web/apps/dotcms-ui/src/app/view/components/_common/forms/dot-push-publish-form/dot-push-publish-form.component.spec.ts +++ b/core-web/apps/dotcms-ui/src/app/view/components/_common/forms/dot-push-publish-form/dot-push-publish-form.component.spec.ts @@ -14,7 +14,6 @@ import { CalendarModule } from 'primeng/calendar'; import { Dropdown, DropdownModule } from 'primeng/dropdown'; import { SelectButton, SelectButtonModule } from 'primeng/selectbutton'; -import { DotFieldValidationMessageModule } from '@components/_common/dot-field-validation-message/dot-file-validation-message.module'; import { PushPublishEnvSelectorComponent } from '@components/_common/dot-push-publish-env-selector/dot-push-publish-env-selector.component'; import { PushPublishServiceMock } from '@components/_common/dot-push-publish-env-selector/dot-push-publish-env-selector.component.spec'; import { PushPublishEnvSelectorModule } from '@components/_common/dot-push-publish-env-selector/dot-push-publish-env-selector.module'; @@ -31,7 +30,7 @@ import { } from '@dotcms/data-access'; import { CoreWebService, DotcmsConfigService, LoginService } from '@dotcms/dotcms-js'; import { DotPushPublishDialogData } from '@dotcms/dotcms-models'; -import { DotMessagePipe } from '@dotcms/ui'; +import { DotFieldValidationMessageComponent, DotMessagePipe } from '@dotcms/ui'; import { CoreWebServiceMock, DotcmsConfigServiceMock, @@ -143,7 +142,7 @@ xdescribe('DotPushPublishFormComponent', () => { PushPublishEnvSelectorModule, ReactiveFormsModule, DropdownModule, - DotFieldValidationMessageModule, + DotFieldValidationMessageComponent, SelectButtonModule, DotPipesModule, DotMessagePipe, diff --git a/core-web/apps/dotcms-ui/src/app/view/components/_common/forms/dot-push-publish-form/dot-push-publish-form.module.ts b/core-web/apps/dotcms-ui/src/app/view/components/_common/forms/dot-push-publish-form/dot-push-publish-form.module.ts index 9a45f835a969..757ca53c36e1 100644 --- a/core-web/apps/dotcms-ui/src/app/view/components/_common/forms/dot-push-publish-form/dot-push-publish-form.module.ts +++ b/core-web/apps/dotcms-ui/src/app/view/components/_common/forms/dot-push-publish-form/dot-push-publish-form.module.ts @@ -7,14 +7,17 @@ import { CalendarModule } from 'primeng/calendar'; import { DropdownModule } from 'primeng/dropdown'; import { SelectButtonModule } from 'primeng/selectbutton'; -import { DotFieldValidationMessageModule } from '@components/_common/dot-field-validation-message/dot-file-validation-message.module'; import { PushPublishEnvSelectorModule } from '@components/_common/dot-push-publish-env-selector/dot-push-publish-env-selector.module'; import { DotPushPublishFormComponent } from '@components/_common/forms/dot-push-publish-form/dot-push-publish-form.component'; import { DotDialogModule } from '@components/dot-dialog/dot-dialog.module'; import { DotParseHtmlService } from '@dotcms/app/api/services/dot-parse-html/dot-parse-html.service'; import { PushPublishService } from '@dotcms/app/api/services/push-publish/push-publish.service'; import { DotcmsConfigService } from '@dotcms/dotcms-js'; -import { DotFieldRequiredDirective, DotMessagePipe } from '@dotcms/ui'; +import { + DotFieldRequiredDirective, + DotFieldValidationMessageComponent, + DotMessagePipe +} from '@dotcms/ui'; import { DotPipesModule } from '@pipes/dot-pipes.module'; @NgModule({ @@ -29,7 +32,7 @@ import { DotPipesModule } from '@pipes/dot-pipes.module'; PushPublishEnvSelectorModule, ReactiveFormsModule, DropdownModule, - DotFieldValidationMessageModule, + DotFieldValidationMessageComponent, SelectButtonModule, DotPipesModule, DotFieldRequiredDirective, diff --git a/core-web/apps/dotcms-ui/src/app/view/components/dot-add-persona-dialog/dot-create-persona-form/dot-create-persona-form.component.spec.ts b/core-web/apps/dotcms-ui/src/app/view/components/dot-add-persona-dialog/dot-create-persona-form/dot-create-persona-form.component.spec.ts index 091af0c9ace3..cd6d60727e67 100644 --- a/core-web/apps/dotcms-ui/src/app/view/components/dot-add-persona-dialog/dot-create-persona-form/dot-create-persona-form.component.spec.ts +++ b/core-web/apps/dotcms-ui/src/app/view/components/dot-add-persona-dialog/dot-create-persona-form/dot-create-persona-form.component.spec.ts @@ -9,12 +9,15 @@ import { FileUploadModule } from 'primeng/fileupload'; import { DotAutocompleteTagsComponent } from '@components/_common/dot-autocomplete-tags/dot-autocomplete-tags.component'; import { DotAutocompleteTagsModule } from '@components/_common/dot-autocomplete-tags/dot-autocomplete-tags.module'; -import { DotFieldValidationMessageModule } from '@components/_common/dot-field-validation-message/dot-file-validation-message.module'; import { SiteSelectorFieldModule } from '@components/_common/dot-site-selector-field/dot-site-selector-field.module'; import { DOTTestBed } from '@dotcms/app/test/dot-test-bed'; import { DotMessageService } from '@dotcms/data-access'; import { SiteService } from '@dotcms/dotcms-js'; -import { DotAutofocusDirective, DotMessagePipe } from '@dotcms/ui'; +import { + DotAutofocusDirective, + DotFieldValidationMessageComponent, + DotMessagePipe +} from '@dotcms/ui'; import { MockDotMessageService, mockSites, SiteServiceMock } from '@dotcms/utils-testing'; import { DotCreatePersonaFormComponent } from './dot-create-persona-form.component'; @@ -66,7 +69,7 @@ describe('DotCreatePersonaFormComponent', () => { BrowserAnimationsModule, FileUploadModule, SiteSelectorFieldModule, - DotFieldValidationMessageModule, + DotFieldValidationMessageComponent, DotAutofocusDirective, DotAutocompleteTagsModule, HttpClientTestingModule, diff --git a/core-web/apps/dotcms-ui/src/app/view/components/dot-add-persona-dialog/dot-create-persona-form/dot-create-persona-form.module.ts b/core-web/apps/dotcms-ui/src/app/view/components/dot-add-persona-dialog/dot-create-persona-form/dot-create-persona-form.module.ts index dee61a7c3cb3..ee39cdf8f2eb 100644 --- a/core-web/apps/dotcms-ui/src/app/view/components/dot-add-persona-dialog/dot-create-persona-form/dot-create-persona-form.module.ts +++ b/core-web/apps/dotcms-ui/src/app/view/components/dot-add-persona-dialog/dot-create-persona-form/dot-create-persona-form.module.ts @@ -8,10 +8,14 @@ import { FileUploadModule } from 'primeng/fileupload'; import { InputTextModule } from 'primeng/inputtext'; import { DotAutocompleteTagsModule } from '@components/_common/dot-autocomplete-tags/dot-autocomplete-tags.module'; -import { DotFieldValidationMessageModule } from '@components/_common/dot-field-validation-message/dot-file-validation-message.module'; import { SiteSelectorFieldModule } from '@components/_common/dot-site-selector-field/dot-site-selector-field.module'; import { DotCreatePersonaFormComponent } from '@components/dot-add-persona-dialog/dot-create-persona-form/dot-create-persona-form.component'; -import { DotAutofocusDirective, DotFieldRequiredDirective, DotMessagePipe } from '@dotcms/ui'; +import { + DotAutofocusDirective, + DotFieldRequiredDirective, + DotFieldValidationMessageComponent, + DotMessagePipe +} from '@dotcms/ui'; import { DotPipesModule } from '@pipes/dot-pipes.module'; @NgModule({ @@ -21,7 +25,7 @@ import { DotPipesModule } from '@pipes/dot-pipes.module'; InputTextModule, ReactiveFormsModule, SiteSelectorFieldModule, - DotFieldValidationMessageModule, + DotFieldValidationMessageComponent, DotAutofocusDirective, ButtonModule, AutoCompleteModule, diff --git a/core-web/apps/dotcms-ui/src/app/view/components/dot-copy-button/dot-copy-button.component.ts b/core-web/apps/dotcms-ui/src/app/view/components/dot-copy-button/dot-copy-button.component.ts index 820e53c076eb..581c4eaf92ff 100644 --- a/core-web/apps/dotcms-ui/src/app/view/components/dot-copy-button/dot-copy-button.component.ts +++ b/core-web/apps/dotcms-ui/src/app/view/components/dot-copy-button/dot-copy-button.component.ts @@ -5,7 +5,7 @@ import { DotMessageService } from '@dotcms/data-access'; /** * Icon button to copy to clipboard the string you pass to it, - * it use tooltip to indicate the user the action and the result. + * it uses tooltip to indicate the user the action and the result. * * @export * @class DotCopyButtonComponent diff --git a/core-web/apps/dotcms-ui/src/app/view/components/dot-edit-layout-designer/dot-edit-layout-designer.component.spec.ts b/core-web/apps/dotcms-ui/src/app/view/components/dot-edit-layout-designer/dot-edit-layout-designer.component.spec.ts index 2f9c94fe5117..971697007dcd 100644 --- a/core-web/apps/dotcms-ui/src/app/view/components/dot-edit-layout-designer/dot-edit-layout-designer.component.spec.ts +++ b/core-web/apps/dotcms-ui/src/app/view/components/dot-edit-layout-designer/dot-edit-layout-designer.component.spec.ts @@ -16,7 +16,6 @@ import { ButtonModule } from 'primeng/button'; import { TooltipModule } from 'primeng/tooltip'; import { DotActionButtonModule } from '@components/_common/dot-action-button/dot-action-button.module'; -import { DotFieldValidationMessageModule } from '@components/_common/dot-field-validation-message/dot-file-validation-message.module'; import { DotGlobalMessageModule } from '@components/_common/dot-global-message/dot-global-message.module'; import { DotGlobalMessageService } from '@components/_common/dot-global-message/dot-global-message.service'; import { DotSecondaryToolbarModule } from '@components/dot-secondary-toolbar'; @@ -26,7 +25,7 @@ import { DotRouterService } from '@dotcms/app/api/services/dot-router/dot-router import { DotTemplateContainersCacheService } from '@dotcms/app/api/services/dot-template-containers-cache/dot-template-containers-cache.service'; import { DotEventsService, DotMessageService, DotThemesService } from '@dotcms/data-access'; import { DotTemplateDesigner, DotTheme } from '@dotcms/dotcms-models'; -import { DotMessagePipe } from '@dotcms/ui'; +import { DotFieldValidationMessageComponent, DotMessagePipe } from '@dotcms/ui'; import { cleanUpDialog, DotThemesServiceMock, @@ -105,7 +104,7 @@ describe('DotEditLayoutDesignerComponent', () => { DotEditPageInfoModule, DotSecondaryToolbarModule, DotGlobalMessageModule, - DotFieldValidationMessageModule, + DotFieldValidationMessageComponent, FormsModule, ReactiveFormsModule, RouterTestingModule, diff --git a/core-web/apps/dotcms-ui/src/app/view/components/login/dot-login-component/dot-login.component.spec.ts b/core-web/apps/dotcms-ui/src/app/view/components/login/dot-login-component/dot-login.component.spec.ts index 43a1d856637f..77d69b9582e1 100644 --- a/core-web/apps/dotcms-ui/src/app/view/components/login/dot-login-component/dot-login.component.spec.ts +++ b/core-web/apps/dotcms-ui/src/app/view/components/login/dot-login-component/dot-login.component.spec.ts @@ -15,7 +15,6 @@ import { ButtonModule } from 'primeng/button'; import { Checkbox, CheckboxModule } from 'primeng/checkbox'; import { Dropdown, DropdownModule } from 'primeng/dropdown'; -import { DotFieldValidationMessageModule } from '@components/_common/dot-field-validation-message/dot-file-validation-message.module'; import { DotLoadingIndicatorModule } from '@components/_common/iframe/dot-loading-indicator/dot-loading-indicator.module'; import { DotLoginComponent } from '@components/login/dot-login-component/dot-login.component'; import { DotLoginPageStateService } from '@components/login/shared/services/dot-login-page-state.service'; @@ -24,6 +23,7 @@ import { DotRouterService } from '@dotcms/app/api/services/dot-router/dot-router import { DotMessageService } from '@dotcms/data-access'; import { CoreWebService, LoggerService, LoginService, StringUtils } from '@dotcms/dotcms-js'; import { DotLoginInformation } from '@dotcms/dotcms-models'; +import { DotFieldValidationMessageComponent } from '@dotcms/ui'; import { DotLoadingIndicatorService } from '@dotcms/utils'; import { CoreWebServiceMock, @@ -82,7 +82,7 @@ describe('DotLoginComponent', () => { CheckboxModule, DropdownModule, DotLoadingIndicatorModule, - DotFieldValidationMessageModule, + DotFieldValidationMessageComponent, RouterTestingModule, FormsModule, ReactiveFormsModule, diff --git a/core-web/apps/dotcms-ui/src/app/view/components/login/dot-login-component/dot-login.module.ts b/core-web/apps/dotcms-ui/src/app/view/components/login/dot-login-component/dot-login.module.ts index 64e13a54f37d..4b83a096f694 100644 --- a/core-web/apps/dotcms-ui/src/app/view/components/login/dot-login-component/dot-login.module.ts +++ b/core-web/apps/dotcms-ui/src/app/view/components/login/dot-login-component/dot-login.module.ts @@ -8,9 +8,12 @@ import { CheckboxModule } from 'primeng/checkbox'; import { DropdownModule } from 'primeng/dropdown'; import { InputTextModule } from 'primeng/inputtext'; -import { DotFieldValidationMessageModule } from '@components/_common/dot-field-validation-message/dot-file-validation-message.module'; import { DotLoginComponent } from '@components/login/dot-login-component/dot-login.component'; -import { DotAutofocusDirective, DotFieldRequiredDirective } from '@dotcms/ui'; +import { + DotAutofocusDirective, + DotFieldRequiredDirective, + DotFieldValidationMessageComponent +} from '@dotcms/ui'; import { DotDirectivesModule } from '@shared/dot-directives.module'; import { SharedModule } from '@shared/shared.module'; @@ -36,7 +39,7 @@ const routes: Routes = [ DotLoadingIndicatorModule, DotDirectivesModule, ReactiveFormsModule, - DotFieldValidationMessageModule, + DotFieldValidationMessageComponent, DotAutofocusDirective, DotFieldRequiredDirective ], diff --git a/core-web/apps/dotcms-ui/src/app/view/components/login/forgot-password-component/forgot-password.component.spec.ts b/core-web/apps/dotcms-ui/src/app/view/components/login/forgot-password-component/forgot-password.component.spec.ts index 9b99f8272c61..42bc1fcb70ca 100644 --- a/core-web/apps/dotcms-ui/src/app/view/components/login/forgot-password-component/forgot-password.component.spec.ts +++ b/core-web/apps/dotcms-ui/src/app/view/components/login/forgot-password-component/forgot-password.component.spec.ts @@ -10,13 +10,13 @@ import { RouterTestingModule } from '@angular/router/testing'; import { ButtonModule } from 'primeng/button'; import { InputTextModule } from 'primeng/inputtext'; -import { DotFieldValidationMessageModule } from '@components/_common/dot-field-validation-message/dot-file-validation-message.module'; import { MockDotLoginPageStateService } from '@components/login/dot-login-page-resolver.service.spec'; import { ForgotPasswordComponent } from '@components/login/forgot-password-component/forgot-password.component'; import { DotLoginPageStateService } from '@components/login/shared/services/dot-login-page-state.service'; import { DotRouterService } from '@dotcms/app/api/services/dot-router/dot-router.service'; import { DotMessageService } from '@dotcms/data-access'; import { LoginService } from '@dotcms/dotcms-js'; +import { DotFieldValidationMessageComponent } from '@dotcms/ui'; import { LoginServiceMock, MockDotMessageService, @@ -43,7 +43,7 @@ describe('ForgotPasswordComponent', () => { ReactiveFormsModule, ButtonModule, InputTextModule, - DotFieldValidationMessageModule, + DotFieldValidationMessageComponent, RouterTestingModule ], providers: [ diff --git a/core-web/apps/dotcms-ui/src/app/view/components/login/forgot-password-component/forgot-password.module.ts b/core-web/apps/dotcms-ui/src/app/view/components/login/forgot-password-component/forgot-password.module.ts index 3fb09d01e1b5..44f5f769c1e7 100644 --- a/core-web/apps/dotcms-ui/src/app/view/components/login/forgot-password-component/forgot-password.module.ts +++ b/core-web/apps/dotcms-ui/src/app/view/components/login/forgot-password-component/forgot-password.module.ts @@ -6,8 +6,11 @@ import { RouterModule, Routes } from '@angular/router'; import { ButtonModule } from 'primeng/button'; import { InputTextModule } from 'primeng/inputtext'; -import { DotFieldValidationMessageModule } from '@components/_common/dot-field-validation-message/dot-file-validation-message.module'; -import { DotAutofocusDirective, DotFieldRequiredDirective } from '@dotcms/ui'; +import { + DotAutofocusDirective, + DotFieldRequiredDirective, + DotFieldValidationMessageComponent +} from '@dotcms/ui'; import { ForgotPasswordComponent } from './forgot-password.component'; @@ -25,7 +28,7 @@ const routes: Routes = [ ButtonModule, InputTextModule, ReactiveFormsModule, - DotFieldValidationMessageModule, + DotFieldValidationMessageComponent, DotAutofocusDirective, RouterModule.forChild(routes), DotFieldRequiredDirective diff --git a/core-web/apps/dotcms-ui/src/app/view/components/login/main/dot-login-page.component.spec.ts b/core-web/apps/dotcms-ui/src/app/view/components/login/main/dot-login-page.component.spec.ts index b361036850d4..cdb6df104981 100644 --- a/core-web/apps/dotcms-ui/src/app/view/components/login/main/dot-login-page.component.spec.ts +++ b/core-web/apps/dotcms-ui/src/app/view/components/login/main/dot-login-page.component.spec.ts @@ -9,9 +9,9 @@ import { RouterTestingModule } from '@angular/router/testing'; import { ButtonModule } from 'primeng/button'; import { InputTextModule } from 'primeng/inputtext'; -import { DotFieldValidationMessageModule } from '@components/_common/dot-field-validation-message/dot-file-validation-message.module'; import { DotLoginPageComponent } from '@components/login/main/dot-login-page.component'; import { DotLoginPageStateService } from '@components/login/shared/services/dot-login-page-state.service'; +import { DotFieldValidationMessageComponent } from '@dotcms/ui'; import { mockLoginFormResponse } from '@dotcms/utils-testing'; @Injectable() @@ -30,7 +30,7 @@ describe('DotLoginPageComponent', () => { FormsModule, ButtonModule, InputTextModule, - DotFieldValidationMessageModule, + DotFieldValidationMessageComponent, RouterTestingModule ], providers: [ diff --git a/core-web/apps/dotcms-ui/src/app/view/components/login/reset-password-component/reset-password.component.spec.ts b/core-web/apps/dotcms-ui/src/app/view/components/login/reset-password-component/reset-password.component.spec.ts index 2077a8c98d2d..0daecaea2feb 100644 --- a/core-web/apps/dotcms-ui/src/app/view/components/login/reset-password-component/reset-password.component.spec.ts +++ b/core-web/apps/dotcms-ui/src/app/view/components/login/reset-password-component/reset-password.component.spec.ts @@ -11,13 +11,13 @@ import { RouterTestingModule } from '@angular/router/testing'; import { ButtonModule } from 'primeng/button'; import { InputTextModule } from 'primeng/inputtext'; -import { DotFieldValidationMessageModule } from '@components/_common/dot-field-validation-message/dot-file-validation-message.module'; import { MockDotLoginPageStateService } from '@components/login/dot-login-page-resolver.service.spec'; import { ResetPasswordComponent } from '@components/login/reset-password-component/reset-password.component'; import { DotLoginPageStateService } from '@components/login/shared/services/dot-login-page-state.service'; import { DotRouterService } from '@dotcms/app/api/services/dot-router/dot-router.service'; import { DotMessageService } from '@dotcms/data-access'; import { LoginService } from '@dotcms/dotcms-js'; +import { DotFieldValidationMessageComponent } from '@dotcms/ui'; import { LoginServiceMock, MockDotMessageService, @@ -45,7 +45,7 @@ describe('ResetPasswordComponent', () => { ReactiveFormsModule, ButtonModule, InputTextModule, - DotFieldValidationMessageModule, + DotFieldValidationMessageComponent, RouterTestingModule ], providers: [ diff --git a/core-web/apps/dotcms-ui/src/app/view/components/login/reset-password-component/reset-password.module.ts b/core-web/apps/dotcms-ui/src/app/view/components/login/reset-password-component/reset-password.module.ts index 97528a6df000..6181930fdf1c 100644 --- a/core-web/apps/dotcms-ui/src/app/view/components/login/reset-password-component/reset-password.module.ts +++ b/core-web/apps/dotcms-ui/src/app/view/components/login/reset-password-component/reset-password.module.ts @@ -6,8 +6,11 @@ import { RouterModule, Routes } from '@angular/router'; import { ButtonModule } from 'primeng/button'; import { InputTextModule } from 'primeng/inputtext'; -import { DotFieldValidationMessageModule } from '@components/_common/dot-field-validation-message/dot-file-validation-message.module'; -import { DotAutofocusDirective, DotFieldRequiredDirective } from '@dotcms/ui'; +import { + DotAutofocusDirective, + DotFieldRequiredDirective, + DotFieldValidationMessageComponent +} from '@dotcms/ui'; import { ResetPasswordComponent } from './reset-password.component'; @@ -25,7 +28,7 @@ const routes: Routes = [ InputTextModule, ButtonModule, ReactiveFormsModule, - DotFieldValidationMessageModule, + DotFieldValidationMessageComponent, DotAutofocusDirective, RouterModule.forChild(routes), DotFieldRequiredDirective diff --git a/core-web/libs/portlets/dot-experiments/portlet/src/lib/dot-experiments-configuration/components/dot-experiments-configuration-goal-select/dot-experiments-configuration-goal-select.component.ts b/core-web/libs/portlets/dot-experiments/portlet/src/lib/dot-experiments-configuration/components/dot-experiments-configuration-goal-select/dot-experiments-configuration-goal-select.component.ts index 2d61c745e64b..5eb8f8f33296 100644 --- a/core-web/libs/portlets/dot-experiments/portlet/src/lib/dot-experiments-configuration/components/dot-experiments-configuration-goal-select/dot-experiments-configuration-goal-select.component.ts +++ b/core-web/libs/portlets/dot-experiments/portlet/src/lib/dot-experiments-configuration/components/dot-experiments-configuration-goal-select/dot-experiments-configuration-goal-select.component.ts @@ -13,7 +13,6 @@ import { SidebarModule } from 'primeng/sidebar'; import { takeUntil } from 'rxjs/operators'; -import { DotFieldValidationMessageModule } from '@components/_common/dot-field-validation-message/dot-file-validation-message.module'; import { DotMessageService } from '@dotcms/data-access'; import { ComponentStatus, @@ -23,7 +22,12 @@ import { MAX_INPUT_DESCRIPTIVE_LENGTH, StepStatus } from '@dotcms/dotcms-models'; -import { DotAutofocusDirective, DotMessagePipe, DotTrimInputDirective } from '@dotcms/ui'; +import { + DotAutofocusDirective, + DotFieldValidationMessageComponent, + DotMessagePipe, + DotTrimInputDirective +} from '@dotcms/ui'; import { DotDropdownDirective } from '@portlets/shared/directives/dot-dropdown.directive'; import { DotSidebarDirective, @@ -45,7 +49,6 @@ import { DotExperimentsConfigurationStore } from '../../store/dot-experiments-co CommonModule, ReactiveFormsModule, DotMessagePipe, - DotFieldValidationMessageModule, DotSidebarHeaderComponent, DotSidebarDirective, DotExperimentsOptionsModule, @@ -60,7 +63,8 @@ import { DotExperimentsConfigurationStore } from '../../store/dot-experiments-co DotExperimentsGoalConfigurationReachPageComponent, DotExperimentsGoalConfigurationUrlParameterComponentComponent, DotExperimentsGoalsComingSoonComponent, - DotTrimInputDirective + DotTrimInputDirective, + DotFieldValidationMessageComponent ], templateUrl: './dot-experiments-configuration-goal-select.component.html', styleUrls: ['./dot-experiments-configuration-goal-select.component.scss'], diff --git a/core-web/libs/portlets/dot-experiments/portlet/src/lib/dot-experiments-configuration/components/dot-experiments-configuration-scheduling-add/dot-experiments-configuration-scheduling-add.component.ts b/core-web/libs/portlets/dot-experiments/portlet/src/lib/dot-experiments-configuration/components/dot-experiments-configuration-scheduling-add/dot-experiments-configuration-scheduling-add.component.ts index 895f83cf3830..58de5c808aa4 100644 --- a/core-web/libs/portlets/dot-experiments/portlet/src/lib/dot-experiments-configuration/components/dot-experiments-configuration-scheduling-add/dot-experiments-configuration-scheduling-add.component.ts +++ b/core-web/libs/portlets/dot-experiments/portlet/src/lib/dot-experiments-configuration/components/dot-experiments-configuration-scheduling-add/dot-experiments-configuration-scheduling-add.component.ts @@ -12,7 +12,6 @@ import { SidebarModule } from 'primeng/sidebar'; import { take } from 'rxjs/operators'; -import { DotFieldValidationMessageModule } from '@components/_common/dot-field-validation-message/dot-file-validation-message.module'; import { ComponentStatus, RangeOfDateAndTime, StepStatus } from '@dotcms/dotcms-models'; import { DotMessagePipe } from '@dotcms/ui'; import { DotSidebarDirective } from '@portlets/shared/directives/dot-sidebar.directive'; @@ -27,7 +26,6 @@ import { DotExperimentsConfigurationStore } from '../../store/dot-experiments-co CommonModule, ReactiveFormsModule, - DotFieldValidationMessageModule, DotMessagePipe, DotSidebarHeaderComponent, DotSidebarDirective, diff --git a/core-web/libs/portlets/dot-experiments/portlet/src/lib/dot-experiments-configuration/components/dot-experiments-configuration-traffic-allocation-add/dot-experiments-configuration-traffic-allocation-add.component.ts b/core-web/libs/portlets/dot-experiments/portlet/src/lib/dot-experiments-configuration/components/dot-experiments-configuration-traffic-allocation-add/dot-experiments-configuration-traffic-allocation-add.component.ts index 0dda7f9c4749..579497807d15 100644 --- a/core-web/libs/portlets/dot-experiments/portlet/src/lib/dot-experiments-configuration/components/dot-experiments-configuration-traffic-allocation-add/dot-experiments-configuration-traffic-allocation-add.component.ts +++ b/core-web/libs/portlets/dot-experiments/portlet/src/lib/dot-experiments-configuration/components/dot-experiments-configuration-traffic-allocation-add/dot-experiments-configuration-traffic-allocation-add.component.ts @@ -17,7 +17,6 @@ import { SliderModule } from 'primeng/slider'; import { take } from 'rxjs/operators'; -import { DotFieldValidationMessageModule } from '@components/_common/dot-field-validation-message/dot-file-validation-message.module'; import { ComponentStatus } from '@dotcms/dotcms-models'; import { DotMessagePipe } from '@dotcms/ui'; import { DotSidebarDirective } from '@portlets/shared/directives/dot-sidebar.directive'; @@ -35,7 +34,6 @@ import { CommonModule, ReactiveFormsModule, - DotFieldValidationMessageModule, DotMessagePipe, DotSidebarHeaderComponent, DotSidebarDirective, diff --git a/core-web/libs/portlets/dot-experiments/portlet/src/lib/dot-experiments-configuration/components/dot-experiments-configuration-traffic-split-add/dot-experiments-configuration-traffic-split-add.component.ts b/core-web/libs/portlets/dot-experiments/portlet/src/lib/dot-experiments-configuration/components/dot-experiments-configuration-traffic-split-add/dot-experiments-configuration-traffic-split-add.component.ts index e97d67650456..514fef4199d0 100644 --- a/core-web/libs/portlets/dot-experiments/portlet/src/lib/dot-experiments-configuration/components/dot-experiments-configuration-traffic-split-add/dot-experiments-configuration-traffic-split-add.component.ts +++ b/core-web/libs/portlets/dot-experiments/portlet/src/lib/dot-experiments-configuration/components/dot-experiments-configuration-traffic-split-add/dot-experiments-configuration-traffic-split-add.component.ts @@ -22,7 +22,6 @@ import { SidebarModule } from 'primeng/sidebar'; import { take } from 'rxjs/operators'; -import { DotFieldValidationMessageModule } from '@components/_common/dot-field-validation-message/dot-file-validation-message.module'; import { ComponentStatus, TrafficProportionTypes, Variant } from '@dotcms/dotcms-models'; import { DotMessagePipe } from '@dotcms/ui'; import { DotSidebarDirective } from '@portlets/shared/directives/dot-sidebar.directive'; @@ -39,8 +38,6 @@ import { imports: [ CommonModule, ReactiveFormsModule, - - DotFieldValidationMessageModule, DotMessagePipe, DotSidebarHeaderComponent, DotSidebarDirective, diff --git a/core-web/libs/portlets/dot-experiments/portlet/src/lib/dot-experiments-configuration/components/dot-experiments-configuration-variants-add/dot-experiments-configuration-variants-add.component.spec.ts b/core-web/libs/portlets/dot-experiments/portlet/src/lib/dot-experiments-configuration/components/dot-experiments-configuration-variants-add/dot-experiments-configuration-variants-add.component.spec.ts index 41839d313bc6..e201674c0afa 100644 --- a/core-web/libs/portlets/dot-experiments/portlet/src/lib/dot-experiments-configuration/components/dot-experiments-configuration-variants-add/dot-experiments-configuration-variants-add.component.spec.ts +++ b/core-web/libs/portlets/dot-experiments/portlet/src/lib/dot-experiments-configuration/components/dot-experiments-configuration-variants-add/dot-experiments-configuration-variants-add.component.spec.ts @@ -8,65 +8,37 @@ import { import { MockComponent } from 'ng-mocks'; import { of } from 'rxjs'; -import { CommonModule } from '@angular/common'; -import { ReactiveFormsModule } from '@angular/forms'; import { ActivatedRoute } from '@angular/router'; import { ConfirmationService, MessageService } from 'primeng/api'; -import { ButtonModule } from 'primeng/button'; -import { InputTextModule } from 'primeng/inputtext'; -import { InputTextareaModule } from 'primeng/inputtextarea'; -import { SidebarModule } from 'primeng/sidebar'; -import { DotFieldValidationMessageModule } from '@components/_common/dot-field-validation-message/dot-file-validation-message.module'; import { DotMessageService } from '@dotcms/data-access'; import { ComponentStatus, ExperimentSteps } from '@dotcms/dotcms-models'; import { DotExperimentsService } from '@dotcms/portlets/dot-experiments/data-access'; -import { ACTIVE_ROUTE_MOCK_CONFIG, MockDotMessageService } from '@dotcms/utils-testing'; -import { DotSidebarDirective } from '@portlets/shared/directives/dot-sidebar.directive'; +import { ACTIVE_ROUTE_MOCK_CONFIG } from '@dotcms/utils-testing'; import { DotHttpErrorManagerService } from '@services/dot-http-error-manager/dot-http-error-manager.service'; -import { DotSidebarHeaderComponent } from '@shared/dot-sidebar-header/dot-sidebar-header.component'; import { DotExperimentsConfigurationVariantsAddComponent } from './dot-experiments-configuration-variants-add.component'; import { DotExperimentsReportsChartComponent } from '../../../dot-experiments-reports/components/dot-experiments-reports-chart/dot-experiments-reports-chart.component'; import { DotExperimentsConfigurationStore } from '../../store/dot-experiments-configuration-store'; -const messageServiceMock = new MockDotMessageService({ - 'experiments.create.form.sidebar.header': 'Add a new experiment', - 'experiments.action.add': 'Add' -}); - describe('DotExperimentsConfigurationVariantsAddComponent', () => { let spectator: Spectator; let store: DotExperimentsConfigurationStore; let dotExperimentsService: SpyObject; const createComponent = createComponentFactory({ - imports: [ - CommonModule, - ReactiveFormsModule, - - SidebarModule, - DotSidebarDirective, - DotSidebarHeaderComponent, - ButtonModule, - InputTextModule, - InputTextareaModule, - DotFieldValidationMessageModule, - MockComponent(DotExperimentsReportsChartComponent) - ], + imports: [MockComponent(DotExperimentsReportsChartComponent)], component: DotExperimentsConfigurationVariantsAddComponent, providers: [ DotExperimentsConfigurationStore, mockProvider(DotExperimentsService), mockProvider(DotHttpErrorManagerService), mockProvider(ActivatedRoute, ACTIVE_ROUTE_MOCK_CONFIG), - { - provide: DotMessageService, - useValue: messageServiceMock - }, + mockProvider(MessageService), + mockProvider(DotMessageService), mockProvider(ConfirmationService) ] }); @@ -101,7 +73,7 @@ describe('DotExperimentsConfigurationVariantsAddComponent', () => { expect(spectator.query(byTestId('new-variant-form'))).toExist(); }); - it('should saveForm when form is valid', () => { + it('should saveForm when form is valid', async () => { jest.spyOn(store, 'addVariant'); const formValues = { @@ -109,12 +81,14 @@ describe('DotExperimentsConfigurationVariantsAddComponent', () => { }; spectator.component.form.setValue(formValues); + spectator.component.form.updateValueAndValidity(); spectator.detectComponentChanges(); + await spectator.fixture.whenStable(); + const submitButton = spectator.query(byTestId('add-variant-button')) as HTMLButtonElement; - expect(submitButton.disabled).toEqual(false); - expect(submitButton).toContainText('Add'); + expect(submitButton.disabled).toEqual(false); expect(spectator.component.form.valid).toEqual(true); spectator.click(submitButton); @@ -122,7 +96,7 @@ describe('DotExperimentsConfigurationVariantsAddComponent', () => { expect(store.addVariant).toHaveBeenCalledWith({ name: 'name', experimentId: '1' }); }); - it('should disable submit button if the form is invalid', () => { + it('should disable submit button if the form is invalid', async () => { const invalidFormValues = { name: 'this is more than 50 characters test - this is more than 50 characters test' }; @@ -131,9 +105,9 @@ describe('DotExperimentsConfigurationVariantsAddComponent', () => { spectator.component.form.updateValueAndValidity(); spectator.detectComponentChanges(); - const submitButton = spectator.query(byTestId('add-variant-button')) as HTMLButtonElement; + await spectator.fixture.whenStable(); + const submitButton = spectator.query(byTestId('add-variant-button')) as HTMLButtonElement; expect(submitButton.disabled).toEqual(true); - expect(submitButton).toContainText('Add'); }); }); diff --git a/core-web/libs/portlets/dot-experiments/portlet/src/lib/dot-experiments-configuration/components/dot-experiments-configuration-variants-add/dot-experiments-configuration-variants-add.component.ts b/core-web/libs/portlets/dot-experiments/portlet/src/lib/dot-experiments-configuration/components/dot-experiments-configuration-variants-add/dot-experiments-configuration-variants-add.component.ts index a3f242d6d591..1e1276eae85b 100644 --- a/core-web/libs/portlets/dot-experiments/portlet/src/lib/dot-experiments-configuration/components/dot-experiments-configuration-variants-add/dot-experiments-configuration-variants-add.component.ts +++ b/core-web/libs/portlets/dot-experiments/portlet/src/lib/dot-experiments-configuration/components/dot-experiments-configuration-variants-add/dot-experiments-configuration-variants-add.component.ts @@ -9,9 +9,13 @@ import { ButtonModule } from 'primeng/button'; import { InputTextModule } from 'primeng/inputtext'; import { SidebarModule } from 'primeng/sidebar'; -import { DotFieldValidationMessageModule } from '@components/_common/dot-field-validation-message/dot-file-validation-message.module'; import { ComponentStatus, MAX_INPUT_TITLE_LENGTH } from '@dotcms/dotcms-models'; -import { DotAutofocusDirective, DotMessagePipe } from '@dotcms/ui'; +import { + DotAutofocusDirective, + DotFieldValidationMessageComponent, + DotMessagePipe, + DotTrimInputDirective +} from '@dotcms/ui'; import { DotSidebarDirective } from '@portlets/shared/directives/dot-sidebar.directive'; import { DotSidebarHeaderComponent } from '@shared/dot-sidebar-header/dot-sidebar-header.component'; import { DotValidators } from '@shared/validators/dotValidators'; @@ -30,7 +34,7 @@ import { DotSidebarHeaderComponent, DotMessagePipe, - DotFieldValidationMessageModule, + DotFieldValidationMessageComponent, DotSidebarDirective, //PrimeNg @@ -38,7 +42,8 @@ import { ButtonModule, InputTextModule, AutoFocusModule, - DotAutofocusDirective + DotAutofocusDirective, + DotTrimInputDirective ], templateUrl: './dot-experiments-configuration-variants-add.component.html', styleUrls: ['./dot-experiments-configuration-variants-add.component.scss'], diff --git a/core-web/libs/portlets/dot-experiments/portlet/src/lib/dot-experiments-list/components/dot-experiments-create/dot-experiments-create.component.spec.ts b/core-web/libs/portlets/dot-experiments/portlet/src/lib/dot-experiments-list/components/dot-experiments-create/dot-experiments-create.component.spec.ts index a39c9e28081a..e068cf299b67 100644 --- a/core-web/libs/portlets/dot-experiments/portlet/src/lib/dot-experiments-list/components/dot-experiments-create/dot-experiments-create.component.spec.ts +++ b/core-web/libs/portlets/dot-experiments/portlet/src/lib/dot-experiments-list/components/dot-experiments-create/dot-experiments-create.component.spec.ts @@ -7,9 +7,9 @@ import { InputTextModule } from 'primeng/inputtext'; import { InputTextareaModule } from 'primeng/inputtextarea'; import { Sidebar, SidebarModule } from 'primeng/sidebar'; -import { DotFieldValidationMessageModule } from '@components/_common/dot-field-validation-message/dot-file-validation-message.module'; import { DotMessageService } from '@dotcms/data-access'; import { DotExperimentsService } from '@dotcms/portlets/dot-experiments/data-access'; +import { DotFieldValidationMessageComponent } from '@dotcms/ui'; import { DotExperimentsListStoreMock, MockDotMessageService } from '@dotcms/utils-testing'; import { DotSidebarDirective, @@ -52,7 +52,7 @@ describe('DotExperimentsCreateComponent', () => { ButtonModule, InputTextModule, InputTextareaModule, - DotFieldValidationMessageModule + DotFieldValidationMessageComponent ], component: DotExperimentsCreateComponent, providers: [ diff --git a/core-web/libs/portlets/dot-experiments/portlet/src/lib/dot-experiments-list/components/dot-experiments-create/dot-experiments-create.component.ts b/core-web/libs/portlets/dot-experiments/portlet/src/lib/dot-experiments-list/components/dot-experiments-create/dot-experiments-create.component.ts index a9e99cf07f54..a61415b1c9f6 100644 --- a/core-web/libs/portlets/dot-experiments/portlet/src/lib/dot-experiments-list/components/dot-experiments-create/dot-experiments-create.component.ts +++ b/core-web/libs/portlets/dot-experiments/portlet/src/lib/dot-experiments-list/components/dot-experiments-create/dot-experiments-create.component.ts @@ -9,11 +9,11 @@ import { InputTextModule } from 'primeng/inputtext'; import { InputTextareaModule } from 'primeng/inputtextarea'; import { SidebarModule } from 'primeng/sidebar'; -import { DotFieldValidationMessageModule } from '@components/_common/dot-field-validation-message/dot-file-validation-message.module'; import { DotExperiment, MAX_INPUT_TITLE_LENGTH } from '@dotcms/dotcms-models'; import { DotAutofocusDirective, DotFieldRequiredDirective, + DotFieldValidationMessageComponent, DotMessagePipe, DotTrimInputDirective } from '@dotcms/ui'; @@ -42,7 +42,7 @@ interface CreateForm { DotSidebarDirective, DotSidebarHeaderComponent, DotMessagePipe, - DotFieldValidationMessageModule, + DotFieldValidationMessageComponent, DotAutofocusDirective, // PrimeNg InputTextareaModule, diff --git a/core-web/libs/portlets/dot-experiments/portlet/src/lib/shared/ui/dot-experiments-goal-configuration-reach-page/dot-experiments-goal-configuration-reach-page.component.spec.ts b/core-web/libs/portlets/dot-experiments/portlet/src/lib/shared/ui/dot-experiments-goal-configuration-reach-page/dot-experiments-goal-configuration-reach-page.component.spec.ts index 85689d035d38..ef649aa4066d 100644 --- a/core-web/libs/portlets/dot-experiments/portlet/src/lib/shared/ui/dot-experiments-goal-configuration-reach-page/dot-experiments-goal-configuration-reach-page.component.spec.ts +++ b/core-web/libs/portlets/dot-experiments/portlet/src/lib/shared/ui/dot-experiments-goal-configuration-reach-page/dot-experiments-goal-configuration-reach-page.component.spec.ts @@ -2,7 +2,6 @@ import { byTestId, createComponentFactory, Spectator } from '@ngneat/spectator/j import { FormArray, FormControl, FormGroup, FormGroupDirective, Validators } from '@angular/forms'; -import { DotFieldValidationMessageComponent } from '@components/_common/dot-field-validation-message/dot-field-validation-message'; import { DotMessageService } from '@dotcms/data-access'; import { DefaultGoalConfiguration, @@ -11,6 +10,7 @@ import { GOAL_TYPES, Goals } from '@dotcms/dotcms-models'; +import { DotFieldValidationMessageComponent } from '@dotcms/ui'; import { MockDotMessageService } from '@dotcms/utils-testing'; import { DotExperimentsGoalConfigurationReachPageComponent } from './dot-experiments-goal-configuration-reach-page.component'; diff --git a/core-web/libs/portlets/dot-experiments/portlet/src/lib/shared/ui/dot-experiments-goal-configuration-reach-page/dot-experiments-goal-configuration-reach-page.component.ts b/core-web/libs/portlets/dot-experiments/portlet/src/lib/shared/ui/dot-experiments-goal-configuration-reach-page/dot-experiments-goal-configuration-reach-page.component.ts index 3070b65b116d..ae0f0e7be0a7 100644 --- a/core-web/libs/portlets/dot-experiments/portlet/src/lib/shared/ui/dot-experiments-goal-configuration-reach-page/dot-experiments-goal-configuration-reach-page.component.ts +++ b/core-web/libs/portlets/dot-experiments/portlet/src/lib/shared/ui/dot-experiments-goal-configuration-reach-page/dot-experiments-goal-configuration-reach-page.component.ts @@ -6,12 +6,16 @@ import { DropdownModule } from 'primeng/dropdown'; import { InputTextModule } from 'primeng/inputtext'; import { PaginatorModule } from 'primeng/paginator'; -import { DotFieldValidationMessageModule } from '@components/_common/dot-field-validation-message/dot-file-validation-message.module'; import { GoalsConditionsOperatorsListByType, GoalsConditionsParametersListByType } from '@dotcms/dotcms-models'; -import { DotAutofocusDirective, DotFieldRequiredDirective, DotMessagePipe } from '@dotcms/ui'; +import { + DotAutofocusDirective, + DotFieldRequiredDirective, + DotFieldValidationMessageComponent, + DotMessagePipe +} from '@dotcms/ui'; import { DotPipesModule } from '@pipes/dot-pipes.module'; import { DotDropdownDirective } from '@portlets/shared/directives/dot-dropdown.directive'; @@ -28,7 +32,7 @@ import { DotExperimentsOptionContentBaseComponent } from '../dot-experiment-opti DotAutofocusDirective, DotDropdownDirective, DotFieldRequiredDirective, - DotFieldValidationMessageModule, + DotFieldValidationMessageComponent, DotPipesModule, DropdownModule, DotMessagePipe, diff --git a/core-web/libs/portlets/dot-experiments/portlet/src/lib/shared/ui/dot-experiments-goal-configuration-url-parameter-component/dot-experiments-goal-configuration-url-parameter-component.component.spec.ts b/core-web/libs/portlets/dot-experiments/portlet/src/lib/shared/ui/dot-experiments-goal-configuration-url-parameter-component/dot-experiments-goal-configuration-url-parameter-component.component.spec.ts index 6eb3345ecd21..d8fee285abd8 100644 --- a/core-web/libs/portlets/dot-experiments/portlet/src/lib/shared/ui/dot-experiments-goal-configuration-url-parameter-component/dot-experiments-goal-configuration-url-parameter-component.component.spec.ts +++ b/core-web/libs/portlets/dot-experiments/portlet/src/lib/shared/ui/dot-experiments-goal-configuration-url-parameter-component/dot-experiments-goal-configuration-url-parameter-component.component.spec.ts @@ -2,7 +2,6 @@ import { byTestId, createComponentFactory, Spectator } from '@ngneat/spectator/j import { FormArray, FormControl, FormGroup, FormGroupDirective, Validators } from '@angular/forms'; -import { DotFieldValidationMessageComponent } from '@components/_common/dot-field-validation-message/dot-field-validation-message'; import { DotMessageService } from '@dotcms/data-access'; import { DefaultGoalConfiguration, @@ -11,6 +10,7 @@ import { GOAL_TYPES, Goals } from '@dotcms/dotcms-models'; +import { DotFieldValidationMessageComponent } from '@dotcms/ui'; import { MockDotMessageService } from '@dotcms/utils-testing'; import { DotExperimentsGoalConfigurationUrlParameterComponentComponent } from './dot-experiments-goal-configuration-url-parameter-component.component'; diff --git a/core-web/libs/portlets/dot-experiments/portlet/src/lib/shared/ui/dot-experiments-goal-configuration-url-parameter-component/dot-experiments-goal-configuration-url-parameter-component.component.ts b/core-web/libs/portlets/dot-experiments/portlet/src/lib/shared/ui/dot-experiments-goal-configuration-url-parameter-component/dot-experiments-goal-configuration-url-parameter-component.component.ts index f4e5887583f6..340386fd794c 100644 --- a/core-web/libs/portlets/dot-experiments/portlet/src/lib/shared/ui/dot-experiments-goal-configuration-url-parameter-component/dot-experiments-goal-configuration-url-parameter-component.component.ts +++ b/core-web/libs/portlets/dot-experiments/portlet/src/lib/shared/ui/dot-experiments-goal-configuration-url-parameter-component/dot-experiments-goal-configuration-url-parameter-component.component.ts @@ -13,9 +13,13 @@ import { InputTextModule } from 'primeng/inputtext'; import { takeUntil } from 'rxjs/operators'; -import { DotFieldValidationMessageModule } from '@components/_common/dot-field-validation-message/dot-file-validation-message.module'; import { GOAL_OPERATORS, GoalsConditionsOperatorsListByType } from '@dotcms/dotcms-models'; -import { DotAutofocusDirective, DotFieldRequiredDirective, DotMessagePipe } from '@dotcms/ui'; +import { + DotAutofocusDirective, + DotFieldRequiredDirective, + DotFieldValidationMessageComponent, + DotMessagePipe +} from '@dotcms/ui'; import { DotDropdownDirective } from '@portlets/shared/directives/dot-dropdown.directive'; import { DotExperimentsOptionContentBaseComponent } from '../dot-experiment-options/components/dot-experiments-option-content-base-component/dot-experiments-option-content-base.component'; @@ -31,7 +35,7 @@ const PARAMETER_QUERY_PARAMETER = 'queryParameter'; ReactiveFormsModule, NgForOf, DotDropdownDirective, - DotFieldValidationMessageModule, + DotFieldValidationMessageComponent, DotMessagePipe, DropdownModule, DotFieldRequiredDirective, diff --git a/core-web/libs/portlets/dot-experiments/portlet/src/lib/shared/ui/dot-experiments-inline-edit-text/dot-experiments-inline-edit-text.component.spec.ts b/core-web/libs/portlets/dot-experiments/portlet/src/lib/shared/ui/dot-experiments-inline-edit-text/dot-experiments-inline-edit-text.component.spec.ts index 80d1c36c45ff..639f427daa80 100644 --- a/core-web/libs/portlets/dot-experiments/portlet/src/lib/shared/ui/dot-experiments-inline-edit-text/dot-experiments-inline-edit-text.component.spec.ts +++ b/core-web/libs/portlets/dot-experiments/portlet/src/lib/shared/ui/dot-experiments-inline-edit-text/dot-experiments-inline-edit-text.component.spec.ts @@ -3,8 +3,8 @@ import { byTestId, createComponentFactory, Spectator } from '@ngneat/spectator/j import { ButtonDirective } from 'primeng/button'; import { Inplace } from 'primeng/inplace'; -import { DotFieldValidationMessageComponent } from '@components/_common/dot-field-validation-message/dot-field-validation-message'; import { DotMessageService } from '@dotcms/data-access'; +import { DotFieldValidationMessageComponent } from '@dotcms/ui'; import { MockDotMessageService } from '@dotcms/utils-testing'; import { DotExperimentsInlineEditTextComponent } from './dot-experiments-inline-edit-text.component'; diff --git a/core-web/libs/portlets/dot-experiments/portlet/src/lib/shared/ui/dot-experiments-inline-edit-text/dot-experiments-inline-edit-text.component.ts b/core-web/libs/portlets/dot-experiments/portlet/src/lib/shared/ui/dot-experiments-inline-edit-text/dot-experiments-inline-edit-text.component.ts index a55eac57f558..4989c919f62e 100644 --- a/core-web/libs/portlets/dot-experiments/portlet/src/lib/shared/ui/dot-experiments-inline-edit-text/dot-experiments-inline-edit-text.component.ts +++ b/core-web/libs/portlets/dot-experiments/portlet/src/lib/shared/ui/dot-experiments-inline-edit-text/dot-experiments-inline-edit-text.component.ts @@ -21,9 +21,13 @@ import { SharedModule } from 'primeng/api'; import { Inplace, InplaceModule } from 'primeng/inplace'; import { InputTextModule } from 'primeng/inputtext'; -import { DotFieldValidationMessageModule } from '@components/_common/dot-field-validation-message/dot-file-validation-message.module'; import { MAX_INPUT_DESCRIPTIVE_LENGTH } from '@dotcms/dotcms-models'; -import { DotAutofocusDirective, DotMessagePipe, DotTrimInputDirective } from '@dotcms/ui'; +import { + DotAutofocusDirective, + DotFieldValidationMessageComponent, + DotMessagePipe, + DotTrimInputDirective +} from '@dotcms/ui'; import { DotValidators } from '@shared/validators/dotValidators'; type InplaceInputSize = 'small' | 'large'; @@ -47,7 +51,7 @@ const InplaceInputSizeMapPrimeNg: Record + {{ errorMsg | dm }} + diff --git a/core-web/libs/ui/src/lib/components/dot-field-validation-message/dot-field-validation-message.component.spec.ts b/core-web/libs/ui/src/lib/components/dot-field-validation-message/dot-field-validation-message.component.spec.ts new file mode 100644 index 000000000000..9f41ca6376fe --- /dev/null +++ b/core-web/libs/ui/src/lib/components/dot-field-validation-message/dot-field-validation-message.component.spec.ts @@ -0,0 +1,102 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ + +import { createHostFactory, SpectatorHost } from '@ngneat/spectator'; +import { byTestId } from '@ngneat/spectator/jest'; + +import { Component } from '@angular/core'; +import { ReactiveFormsModule, UntypedFormControl, Validators } from '@angular/forms'; + +import { DotMessageService } from '@dotcms/data-access'; +import { DotFieldValidationMessageComponent, DotMessagePipe } from '@dotcms/ui'; +import { MockDotMessageService } from '@dotcms/utils-testing'; + +const messageServiceMock = new MockDotMessageService({ + 'contentType.errors.input.maxlength': 'Value must be no more than {0} characters', + 'error.form.validator.maxlength': 'Max length error', + 'error.form.validator.required': 'Required error', + 'contentType.form.variable.placeholder': 'Will be auto-generated if left empty' +}); + +@Component({ selector: 'dot-custom-host', template: '' }) +class CustomHostComponent { + defaultMessage = 'Required'; + control = new UntypedFormControl('', Validators.required); +} + +describe('FieldValidationComponent', () => { + let spectator: SpectatorHost; + const createHost = createHostFactory({ + component: DotFieldValidationMessageComponent, + host: CustomHostComponent, + imports: [ReactiveFormsModule, DotMessagePipe], + providers: [ + { + provide: DotMessageService, + useValue: messageServiceMock + } + ] + }); + + describe('Using default message', () => { + beforeEach(() => { + spectator = createHost( + ` + + ` + ); + }); + + it('should hide the message by default', () => { + expect(spectator.queryHost(byTestId('error-msg'))).not.toExist(); + }); + + it('should hide the message when field it is valid', () => { + expect(spectator.hostComponent.control.valid).toBe(false); + spectator.hostComponent.control.setValue('valid-content'); + + expect(spectator.hostComponent.control.valid).toBe(true); + expect(spectator.queryHost(byTestId('error-msg'))).not.toExist(); + }); + + it('should show the default message when field it is dirty and invalid', () => { + expect(spectator.hostComponent.control.valid).toBe(false); + expect(spectator.hostComponent.control.dirty).toBe(false); + + spectator.hostComponent.control.setValue(''); + spectator.hostComponent.control.markAsDirty(); + + spectator.detectComponentChanges(); + + expect(spectator.hostComponent.control.valid).toBe(false); + expect(spectator.hostComponent.control.dirty).toBe(true); + + expect(spectator.queryHost(byTestId('error-msg'))).toExist(); + }); + }); + + describe('Using validators messages', () => { + beforeEach(() => { + spectator = createHost( + ` + + ` + ); + }); + + it('should show the message Input() when field it is dirty and invalid', () => { + expect(spectator.hostComponent.control.valid).toBe(false); + expect(spectator.hostComponent.control.dirty).toBe(false); + + spectator.hostComponent.control.setValue(''); + spectator.hostComponent.control.markAsDirty(); + + spectator.detectComponentChanges(); + + expect(spectator.hostComponent.control.valid).toBe(false); + expect(spectator.hostComponent.control.dirty).toBe(true); + + expect(spectator.queryHost(byTestId('error-msg'))).toExist(); + expect(spectator.queryHost(byTestId('error-msg'))).toContainText('Required'); + }); + }); +}); diff --git a/core-web/apps/dotcms-ui/src/app/view/components/_common/dot-field-validation-message/dot-field-validation-message.ts b/core-web/libs/ui/src/lib/components/dot-field-validation-message/dot-field-validation-message.component.ts similarity index 93% rename from core-web/apps/dotcms-ui/src/app/view/components/_common/dot-field-validation-message/dot-field-validation-message.ts rename to core-web/libs/ui/src/lib/components/dot-field-validation-message/dot-field-validation-message.component.ts index b0b987779811..de2ece159cc9 100644 --- a/core-web/apps/dotcms-ui/src/app/view/components/_common/dot-field-validation-message/dot-field-validation-message.ts +++ b/core-web/libs/ui/src/lib/components/dot-field-validation-message/dot-field-validation-message.component.ts @@ -4,6 +4,7 @@ import { Subject } from 'rxjs'; +import { NgIf } from '@angular/common'; import { ChangeDetectionStrategy, ChangeDetectorRef, @@ -17,6 +18,8 @@ import { takeUntil } from 'rxjs/operators'; import { DotMessageService } from '@dotcms/data-access'; +import { DotMessagePipe } from '../../dot-message/dot-message.pipe'; + type DefaultsNGValidatorsTypes = 'maxlength' | 'required'; const NG_DEFAULT_VALIDATORS_ERRORS_MSG: Record = { @@ -26,7 +29,9 @@ const NG_DEFAULT_VALIDATORS_ERRORS_MSG: Record