Ethetic modification of lists and foreign keys
This commit is contained in:
@@ -16,6 +16,7 @@ import { DateTypeComponent } from "./types/date.type";
|
||||
import { ApiService, CrudService } from "./crud.service";
|
||||
import { CrudFormlyJsonschemaService } from "./crud-formly-jsonschema.service";
|
||||
import { NgbModule} from "@ng-bootstrap/ng-bootstrap";
|
||||
import { allIcons, NgxBootstrapIconsModule } from "ngx-bootstrap-icons";
|
||||
import { JsonschemasService } from "./jsonschemas.service";
|
||||
import { MultiSchemaTypeComponent } from "./types/multischema.type";
|
||||
import { ForeignkeyTypeComponent } from "./types/foreignkey.type";
|
||||
@@ -49,6 +50,7 @@ import { DictionaryService } from "./types/dictionary.service";
|
||||
HttpClientModule,
|
||||
FormsModule,
|
||||
NgbModule,
|
||||
NgxBootstrapIconsModule.pick(allIcons),
|
||||
//BrowserAnimationsModule,
|
||||
ReactiveFormsModule,
|
||||
FormlyModule.forRoot({
|
||||
|
||||
@@ -38,7 +38,7 @@ export class JsonschemasService {
|
||||
delete resource.properties[prop_name]
|
||||
} else if (this.is_reference(prop)) {
|
||||
this.resolveReference(resource, prop);
|
||||
} else if (prop.hasOwnProperty('oneOf')) {
|
||||
} else if (this.is_union(prop)) {
|
||||
for (let i in prop.oneOf) {
|
||||
this.resolveReference(resource, prop.oneOf[i]);
|
||||
}
|
||||
|
||||
@@ -7,36 +7,38 @@ import { FieldArrayType } from '@ngx-formly/core';
|
||||
<div>
|
||||
<label *ngIf="props.label" class="form-label">{{ props.label }}</label>
|
||||
<p *ngIf="props.description">{{ props.description }}</p>
|
||||
|
||||
<div class="alert alert-danger" role="alert" *ngIf="showError && formControl.errors">
|
||||
<formly-validation-message [field]="field"></formly-validation-message>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div *ngFor="let entry of field.fieldGroup; let i = index" class="card {{this.colSm}}">
|
||||
<div class="card-header">
|
||||
<div *ngIf="props['numbered']" class="float-start">
|
||||
<strong>{{ i + 1 }}</strong>
|
||||
<div class="row row-cols-1 row-cols-md-{{this.itemsPerRow}} g-1">
|
||||
<div *ngFor="let entry of field.fieldGroup; let i = index" class="col">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<div *ngIf="props['numbered']" class="float-start">
|
||||
<strong>{{ i + 1 }}</strong>
|
||||
</div>
|
||||
<div class="float-end">
|
||||
<button class="btn btn-primary btn-sm" [attr.disabled]="i == 0 ? 'disabled' : null" type="button" (click)="move(i, i-1)"><i-bs name="caret-up-fill"></i-bs></button>
|
||||
<button class="btn btn-primary btn-sm" [attr.disabled]="i == this.field.fieldGroup!.length-1 ? 'disabled' : null" type="button" (click)="move(i, i+1)"><i-bs name="caret-down-fill"></i-bs></button>
|
||||
<button class="btn btn-danger btn-sm" [attr.disabled]="field.props!['removable'] === false ? 'disabled' : null" type="button" (click)="remove(i)"><i-bs name="x-octagon-fill"></i-bs></button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<formly-field class="col" [field]="entry"></formly-field>
|
||||
</div>
|
||||
</div>
|
||||
<div class="float-end">
|
||||
<button class="btn btn-primary btn-sm" [attr.disabled]="i == 0 ? 'disabled' : null" type="button" (click)="move(i, i-1)">UP</button>
|
||||
<button class="btn btn-primary btn-sm" [attr.disabled]="i == this.field.fieldGroup!.length-1 ? 'disabled' : null" type="button" (click)="move(i, i+1)">DOWN</button>
|
||||
<button class="btn btn-danger btn-sm" [attr.disabled]="field.props!['removable'] === false ? 'disabled' : null" type="button" (click)="remove(i)">-</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<formly-field class="col" [field]="entry"></formly-field>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<button class="btn btn-success col-sm-12" type="button" (click)="add()">+</button>
|
||||
<button class="btn btn-success col-sm-12" type="button" (click)="add()"><i-bs name="plus-square-fill"></i-bs></button>
|
||||
</div>
|
||||
`,
|
||||
})
|
||||
export class ArrayTypeComponent extends FieldArrayType implements OnInit {
|
||||
colSm: string = "col-sm-6"
|
||||
itemsPerRow = 2;
|
||||
ngOnInit() {
|
||||
if (this.field.props.hasOwnProperty('items-per-row')) {
|
||||
this.colSm = `col-sm-${12 / this.field.props['items-per-row']}`
|
||||
this.itemsPerRow = this.field.props['items-per-row']
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -43,10 +43,10 @@ import {DictionaryService} from "./dictionary.service";
|
||||
readonly="readonly"
|
||||
/>
|
||||
<div class="input-group-append">
|
||||
<button class="btn btn-info" type="button" (click)="see(foreignModal)"><span class="cil-zoom btn-icon"></span>See</button>
|
||||
<button class="btn btn-info" type="button" (click)="see(foreignModal)"><span class="cil-zoom btn-icon"></span><i-bs name="zoom-in"></i-bs></button>
|
||||
</div>
|
||||
<div class="input-group-append">
|
||||
<button class="btn btn-danger" type="button" (click)="remove()"><span class="cil-x btn-icon mr-2"></span>Remove</button>
|
||||
<button class="btn btn-danger" type="button" (click)="remove()"><span class="cil-x btn-icon mr-2"></span><i-bs name="eraser-fill"></i-bs></button>
|
||||
</div>
|
||||
</div>
|
||||
<formly-form *ngIf="this.hasValue() && this.displayedFields" [form]="this.foreignForm" [fields]="this.foreignFields" [model]="this.foreignModel"></formly-form>
|
||||
|
||||
Reference in New Issue
Block a user