Added sample object creation UI
This commit is contained in:
parent
030c91e8a1
commit
17e0912c70
@ -92,5 +92,8 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"cli": {
|
||||||
|
"analytics": false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,6 @@
|
|||||||
<h1>Sample object control panel</h1>
|
<h1>Sample object control panel</h1>
|
||||||
<h3>Create object types</h3>
|
<h3>Create object types</h3>
|
||||||
<form>
|
<app-objecttype></app-objecttype>
|
||||||
<input type="text" pInputText />
|
|
||||||
<button pButton type="submit">Create</button>
|
|
||||||
</form>
|
|
||||||
<h3>Create object</h3>
|
<h3>Create object</h3>
|
||||||
<form>
|
<app-object></app-object>
|
||||||
<input type="text" pInputText />
|
|
||||||
<p-dropdown [options]="cities" [(ngModel)]="selectedCity1" placeholder="Select a City" optionLabel="name"></p-dropdown>
|
|
||||||
<button pButton type="submit">Create</button>
|
|
||||||
</form>
|
|
||||||
|
@ -2,28 +2,4 @@ import { TestBed } from '@angular/core/testing';
|
|||||||
import { AppComponent } from './app.component';
|
import { AppComponent } from './app.component';
|
||||||
|
|
||||||
describe('AppComponent', () => {
|
describe('AppComponent', () => {
|
||||||
beforeEach(async () => {
|
|
||||||
await TestBed.configureTestingModule({
|
|
||||||
imports: [AppComponent],
|
|
||||||
}).compileComponents();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should create the app', () => {
|
|
||||||
const fixture = TestBed.createComponent(AppComponent);
|
|
||||||
const app = fixture.componentInstance;
|
|
||||||
expect(app).toBeTruthy();
|
|
||||||
});
|
|
||||||
|
|
||||||
it(`should have the 'webui' title`, () => {
|
|
||||||
const fixture = TestBed.createComponent(AppComponent);
|
|
||||||
const app = fixture.componentInstance;
|
|
||||||
expect(app.title).toEqual('webui');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should render title', () => {
|
|
||||||
const fixture = TestBed.createComponent(AppComponent);
|
|
||||||
fixture.detectChanges();
|
|
||||||
const compiled = fixture.nativeElement as HTMLElement;
|
|
||||||
expect(compiled.querySelector('h1')?.textContent).toContain('Hello, webui');
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
@ -1,38 +1,17 @@
|
|||||||
import {Component} from '@angular/core';
|
import {Component} from '@angular/core';
|
||||||
import { RouterOutlet } from '@angular/router';
|
import { RouterOutlet } from '@angular/router';
|
||||||
import { ButtonModule } from 'primeng/button';
|
import {ObjecttypeComponent} from "./create/objecttype/objecttype.component";
|
||||||
import {PaginatorModule} from "primeng/paginator";
|
import {ObjectComponent} from "./create/object/object.component";
|
||||||
import { InputTextModule } from 'primeng/inputtext';
|
|
||||||
import { DropdownModule } from 'primeng/dropdown';
|
|
||||||
|
|
||||||
|
|
||||||
interface City {
|
|
||||||
name: string,
|
|
||||||
code: string
|
|
||||||
}
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-root',
|
selector: 'app-root',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [RouterOutlet, ButtonModule, PaginatorModule, InputTextModule, DropdownModule],
|
imports: [RouterOutlet, ObjecttypeComponent, ObjectComponent],
|
||||||
templateUrl: './app.component.html',
|
templateUrl: './app.component.html',
|
||||||
styleUrl: './app.component.css'
|
styleUrl: './app.component.css'
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
export class AppComponent {
|
export class AppComponent {
|
||||||
cities: City[];
|
|
||||||
|
|
||||||
selectedCity1: City;
|
|
||||||
|
|
||||||
constructor() {
|
|
||||||
this.cities = [
|
|
||||||
{name: 'New York', code: 'NY'},
|
|
||||||
{name: 'Rome', code: 'RM'},
|
|
||||||
{name: 'London', code: 'LDN'},
|
|
||||||
{name: 'Istanbul', code: 'IST'},
|
|
||||||
{name: 'Paris', code: 'PRS'}
|
|
||||||
];
|
|
||||||
this.selectedCity1 = this.cities[0]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
16
src/main/webui/src/app/create/object/object.component.html
Normal file
16
src/main/webui/src/app/create/object/object.component.html
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
|
||||||
|
<div>
|
||||||
|
<form>
|
||||||
|
<input type="text" pInputText />
|
||||||
|
<p-dropdown [options]="objectTypes" [(ngModel)]="selectedObjectType" placeholder="Select a object type" name="objectTypeSelect" [editable]="true"></p-dropdown>
|
||||||
|
</form>
|
||||||
|
<h4>Object attributes</h4>
|
||||||
|
<div *ngFor="let objectAttribute of objectAttributes">
|
||||||
|
<input type="text" pInputText [(ngModel)]="objectAttribute.name" name="attributename" placeholder="Object attribute name"/>
|
||||||
|
<p-dropdown [options]="valueTypes" [(ngModel)]="objectAttribute.type" placeholder="Select a object type" name="objectAttributeTyoeSelect" ></p-dropdown>
|
||||||
|
<input type="text" pInputText [(ngModel)]="objectAttribute.value" placeholder="Attribute type"/>
|
||||||
|
</div>
|
||||||
|
<button pButton (click)="createAttribute()">Add</button>
|
||||||
|
</div>
|
||||||
|
<br>
|
||||||
|
<button pButton type="submit" (click)="createNewObject()">Create Object</button>
|
@ -0,0 +1,23 @@
|
|||||||
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { ObjectComponent } from './object.component';
|
||||||
|
|
||||||
|
describe('ObjectComponent', () => {
|
||||||
|
let component: ObjectComponent;
|
||||||
|
let fixture: ComponentFixture<ObjectComponent>;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
await TestBed.configureTestingModule({
|
||||||
|
imports: [ObjectComponent]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
|
||||||
|
fixture = TestBed.createComponent(ObjectComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
52
src/main/webui/src/app/create/object/object.component.ts
Normal file
52
src/main/webui/src/app/create/object/object.component.ts
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
import { Component } from '@angular/core';
|
||||||
|
import {ButtonDirective} from "primeng/button";
|
||||||
|
import {DropdownModule} from "primeng/dropdown";
|
||||||
|
import {FormsModule} from "@angular/forms";
|
||||||
|
import {InputTextModule} from "primeng/inputtext";
|
||||||
|
import {PaginatorModule} from "primeng/paginator";
|
||||||
|
import {SelectItem} from "primeng/api";
|
||||||
|
import {NgForOf} from "@angular/common";
|
||||||
|
|
||||||
|
interface ObjectAttribute {
|
||||||
|
name: string;
|
||||||
|
type: string; // This should be an enum
|
||||||
|
value: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-object',
|
||||||
|
standalone: true,
|
||||||
|
imports: [
|
||||||
|
ButtonDirective,
|
||||||
|
DropdownModule,
|
||||||
|
FormsModule,
|
||||||
|
InputTextModule,
|
||||||
|
PaginatorModule,
|
||||||
|
NgForOf
|
||||||
|
],
|
||||||
|
templateUrl: './object.component.html',
|
||||||
|
styleUrl: './object.component.css'
|
||||||
|
})
|
||||||
|
export class ObjectComponent {
|
||||||
|
objectTypes!:SelectItem[];
|
||||||
|
selectedObjectType!:SelectItem;
|
||||||
|
objectAttributes!:ObjectAttribute[];
|
||||||
|
valueTypes!:SelectItem[];
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
this.objectTypes = [];
|
||||||
|
this.objectTypes.push({label: 'Example', value: 'Example'}); // Note that the objectTypes array must be initialized with at least one element for the dropdown to work
|
||||||
|
this.valueTypes = [{label: 'String', value: 'String'}, {label: 'Number', value: 'Number'}, {label: 'Boolean', value: 'Boolean'}];
|
||||||
|
}
|
||||||
|
|
||||||
|
createNewObject() {
|
||||||
|
console.log('selectedObjectType', this.selectedObjectType);
|
||||||
|
}
|
||||||
|
|
||||||
|
createAttribute() {
|
||||||
|
if(this.objectAttributes === undefined) {
|
||||||
|
this.objectAttributes = [];
|
||||||
|
}
|
||||||
|
this.objectAttributes.push({name: '', type: '', value: ''});
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,4 @@
|
|||||||
|
<form>
|
||||||
|
<input type="text" pInputText [(ngModel)]="newObjectType" name="newObjectType"/>
|
||||||
|
<button pButton (click)="createNewObjectType()">Create</button>
|
||||||
|
</form>
|
@ -0,0 +1,23 @@
|
|||||||
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { ObjecttypeComponent } from './objecttype.component';
|
||||||
|
|
||||||
|
describe('ObjecttypeComponent', () => {
|
||||||
|
let component: ObjecttypeComponent;
|
||||||
|
let fixture: ComponentFixture<ObjecttypeComponent>;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
await TestBed.configureTestingModule({
|
||||||
|
imports: [ObjecttypeComponent]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
|
||||||
|
fixture = TestBed.createComponent(ObjecttypeComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
@ -0,0 +1,34 @@
|
|||||||
|
import { Component } from '@angular/core';
|
||||||
|
import {ButtonDirective} from "primeng/button";
|
||||||
|
import {FormsModule} from "@angular/forms";
|
||||||
|
import {InputTextModule} from "primeng/inputtext";
|
||||||
|
import {PaginatorModule} from "primeng/paginator";
|
||||||
|
import {SelectItem} from "primeng/api";
|
||||||
|
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-objecttype',
|
||||||
|
standalone: true,
|
||||||
|
imports: [
|
||||||
|
ButtonDirective,
|
||||||
|
FormsModule,
|
||||||
|
InputTextModule,
|
||||||
|
PaginatorModule
|
||||||
|
],
|
||||||
|
templateUrl: './objecttype.component.html',
|
||||||
|
styleUrl: './objecttype.component.css'
|
||||||
|
})
|
||||||
|
export class ObjecttypeComponent {
|
||||||
|
objectTypes!:SelectItem[];
|
||||||
|
newObjectType:string = '';
|
||||||
|
|
||||||
|
|
||||||
|
createNewObjectType() {
|
||||||
|
if(this.objectTypes === undefined) {
|
||||||
|
this.objectTypes = [];
|
||||||
|
}
|
||||||
|
this.objectTypes.push({label: this.newObjectType, value: this.newObjectType});
|
||||||
|
console.log('objectTypes', this.objectTypes)
|
||||||
|
this.newObjectType = '';
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user