diff --git a/backend/src/main/resources/metadata-sources-ui-schema.json b/backend/src/main/resources/metadata-sources-ui-schema.json index 9d64e75b4..1bf90c362 100644 --- a/backend/src/main/resources/metadata-sources-ui-schema.json +++ b/backend/src/main/resources/metadata-sources-ui-schema.json @@ -31,17 +31,23 @@ "name": { "title": "label.organization-name", "description": "tooltip.organization-name", - "type": "string" + "type": "string", + "minLength": 1, + "maxLength": 255 }, "displayName": { "title": "label.organization-display-name", "description": "tooltip.organization-display-name", - "type": "string" + "type": "string", + "minLength": 1, + "maxLength": 255 }, "url": { "title": "label.organization-url", "description": "tooltip.organization-url", - "type": "string" + "type": "string", + "minLength": 1, + "maxLength": 255 } }, "dependencies": { @@ -101,17 +107,23 @@ "displayName": { "title": "label.display-name", "description": "tooltip.mdui-display-name", - "type": "string" + "type": "string", + "minLength": 1, + "maxLength": 255 }, "informationUrl": { "title": "label.information-url", "description": "tooltip.mdui-information-url", - "type": "string" + "type": "string", + "minLength": 1, + "maxLength": 255 }, "privacyStatementUrl": { "title": "label.privacy-statement-url", "description": "tooltip.mdui-privacy-statement-url", - "type": "string" + "type": "string", + "minLength": 1, + "maxLength": 255 }, "description": { "title": "label.description", @@ -119,26 +131,28 @@ "type": "string", "widget": { "id": "textarea" - } + }, + "minLength": 1, + "maxLength": 255 }, "logoUrl": { "title": "label.logo-url", "description": "tooltip.mdui-logo-url", - "type": "string" + "type": "string", + "minLength": 1, + "maxLength": 255 }, "logoHeight": { "title": "label.logo-height", "description": "tooltip.mdui-logo-height", "min": 0, - "type": "integer", - "default": 0 + "type": "integer" }, "logoWidth": { "title": "label.logo-width", "description": "tooltip.mdui-logo-width", "min": 0, - "type": "integer", - "default": 0 + "type": "integer" } } }, diff --git a/ui/src/app/shared/constant.ts b/ui/src/app/shared/constant.ts index a6e3fde7d..a0eaf09b8 100644 --- a/ui/src/app/shared/constant.ts +++ b/ui/src/app/shared/constant.ts @@ -1 +1 @@ -export const DEFAULT_FIELD_MAX_LENGTH = 255; \ No newline at end of file +export const DEFAULT_FIELD_MAX_LENGTH = 255; diff --git a/ui/src/app/shared/directive/input-defaults.directive.spec.ts b/ui/src/app/shared/directive/input-defaults.directive.spec.ts deleted file mode 100644 index 172c41a3f..000000000 --- a/ui/src/app/shared/directive/input-defaults.directive.spec.ts +++ /dev/null @@ -1,60 +0,0 @@ -import { Component, DebugElement } from '@angular/core'; -import { By } from '@angular/platform-browser'; -import { TestBed, ComponentFixture } from '@angular/core/testing'; -import { ReactiveFormsModule, FormsModule, NgControl } from '@angular/forms'; -import { Router } from '@angular/router'; -import { NoopAnimationsModule } from '@angular/platform-browser/animations'; -import { RouterStub } from '../../../testing/router.stub'; -import { NgbModalStub } from '../../../testing/modal.stub'; -import { InputDefaultsDirective } from './input-defaults.directive'; - -import * as constants from '../../shared/constant'; - -@Component({ - template: `` -}) -class TestComponent { - isDisabled = false; - set disableDefaults(isDisabled: boolean) { - this.isDisabled = isDisabled; - } - get disableDefaults(): boolean { - return this.isDisabled; - } -} - -describe('Input Defaults Directive', () => { - let component: TestComponent; - let fixture: ComponentFixture; - let inputEl: DebugElement; - - beforeEach(() => { - TestBed.configureTestingModule({ - providers: [], - imports: [ - FormsModule, - ReactiveFormsModule - ], - declarations: [ - InputDefaultsDirective, - TestComponent - ], - }); - - fixture = TestBed.createComponent(TestComponent); - inputEl = fixture.debugElement.query(By.css('input')); - }); - - describe('attributes', () => { - it('should add a maxlength attribute based on the constants file', () => { - fixture.detectChanges(); - expect(parseInt(inputEl.attributes.maxlength, 10)).toEqual(constants.DEFAULT_FIELD_MAX_LENGTH); - }); - - it('should be null if disableDefaults is set', () => { - fixture.componentInstance.disableDefaults = true; - fixture.detectChanges(); - expect(inputEl.attributes.maxlength).toBeNull(); - }); - }); -}); diff --git a/ui/src/app/shared/directive/input-defaults.directive.ts b/ui/src/app/shared/directive/input-defaults.directive.ts deleted file mode 100644 index 409d02ea8..000000000 --- a/ui/src/app/shared/directive/input-defaults.directive.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { Directive, Self, HostBinding, Input } from '@angular/core'; -import * as constants from '../../shared/constant'; - -@Directive({ - selector: 'input[type="text"].form-control,textarea.form-control' -}) -export class InputDefaultsDirective { - public constructor() { } - - @Input() disableDefaults = false; - - @HostBinding('attr.maxlength') - get maxlength() { - return this.disableDefaults ? null : constants.DEFAULT_FIELD_MAX_LENGTH; - } -} diff --git a/ui/src/app/shared/shared.module.ts b/ui/src/app/shared/shared.module.ts index 75dd7911c..720f2a407 100644 --- a/ui/src/app/shared/shared.module.ts +++ b/ui/src/app/shared/shared.module.ts @@ -4,7 +4,6 @@ import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { HighlightPipe } from './pipe/highlight.pipe'; import { AutoCompleteComponent } from './autocomplete/autocomplete.component'; import { ValidationClassDirective } from './validation/validation-class.directive'; -import { InputDefaultsDirective } from './directive/input-defaults.directive'; import { ValidFormIconComponent } from './component/valid-form-icon.component'; import { PrettyXml } from './pipe/pretty-xml.pipe'; import { ToggleSwitchComponent } from './switch/switch.component'; @@ -27,7 +26,6 @@ import { NgbPopoverModule } from '@ng-bootstrap/ng-bootstrap'; AutoCompleteComponent, ToggleSwitchComponent, ValidationClassDirective, - InputDefaultsDirective, ValidFormIconComponent, PrettyXml, CustomDatePipe, @@ -41,7 +39,6 @@ import { NgbPopoverModule } from '@ng-bootstrap/ng-bootstrap'; CommonModule, ReactiveFormsModule, FormsModule, - InputDefaultsDirective, ValidFormIconComponent, ValidationClassDirective, ContenteditableDirective,