3 * ============LICENSE_START=======================================================
4 * Copyright (C) 2022 Nordix Foundation.
5 * ================================================================================
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 * SPDX-License-Identifier: Apache-2.0
19 * ============LICENSE_END=========================================================
22 import {Component, Input, OnInit} from '@angular/core';
23 import {FormControl, FormGroup, Validators} from "@angular/forms";
24 import {DataTypeModel} from "../../../../models/data-types";
25 import { DEFAULT_MODEL_NAME } from "app/utils/constants";
28 selector: 'app-type-workspace-general',
29 templateUrl: './type-workspace-general.component.html',
30 styleUrls: ['./type-workspace-general.component.less']
32 export class TypeWorkspaceGeneralComponent implements OnInit {
33 @Input() isViewOnly = true;
34 @Input() dataType: DataTypeModel = new DataTypeModel();
36 DEFAULT_MODEL_NAME = DEFAULT_MODEL_NAME;
38 type: FormControl = new FormControl(undefined, [Validators.required, Validators.minLength(1), Validators.maxLength(300)]);
39 derivedFrom: FormControl = new FormControl(undefined, [Validators.required, Validators.minLength(1)]);
40 description: FormControl = new FormControl(undefined, [Validators.required, Validators.minLength(1)]);
41 model: FormControl = new FormControl(undefined, [Validators.required]);
42 formGroup: FormGroup = new FormGroup({
44 'description': this.description,
46 'derivedFrom': this.derivedFrom
53 private initForm(): void {
57 this.type.setValue(this.dataType.name);
58 this.description.setValue(this.dataType.description);
59 this.model.setValue(this.dataType.model);
60 this.derivedFrom.setValue(this.dataType.derivedFrom);