mirror of https://github.com/Squidex/squidex.git
10 changed files with 129 additions and 46 deletions
@ -0,0 +1,6 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<configuration> |
|||
<packageSources> |
|||
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" /> |
|||
</packageSources> |
|||
</configuration> |
|||
@ -0,0 +1,15 @@ |
|||
<div class="item" [class.invalid]="isInvalid | async"> |
|||
<button type="button" class="btn btn-link btn-danger item-remove" (click)="removing.emit(); $event.preventDefault()"> |
|||
<i class="icon-bin2"></i> |
|||
</button> |
|||
|
|||
<div class="form-group" *ngFor="let fieldControl of fieldControls"> |
|||
<sqx-field-editor |
|||
[form]="form" |
|||
[field]="fieldControl.field" |
|||
[language]="language" |
|||
[languages]="languages" |
|||
[control]="fieldControl.control"> |
|||
</sqx-field-editor> |
|||
</div> |
|||
</div> |
|||
@ -0,0 +1,21 @@ |
|||
@import '_vars'; |
|||
@import '_mixins'; |
|||
|
|||
|
|||
.item { |
|||
& { |
|||
background: $panel-light-background; |
|||
border: 1px solid darken($color-border, 5%); |
|||
border-left-width: 4px; |
|||
padding: 1rem; |
|||
position: relative; |
|||
} |
|||
|
|||
&-remove { |
|||
@include absolute(.5rem, .5rem, auto, auto); |
|||
} |
|||
} |
|||
|
|||
.invalid { |
|||
border-left-color: $color-theme-error; |
|||
} |
|||
@ -0,0 +1,59 @@ |
|||
/* |
|||
* Squidex Headless CMS |
|||
* |
|||
* @license |
|||
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. |
|||
*/ |
|||
|
|||
import { ChangeDetectionStrategy, Component, EventEmitter, Input, OnChanges, Output, SimpleChanges } from '@angular/core'; |
|||
import { AbstractControl, FormGroup } from '@angular/forms'; |
|||
import { Observable } from 'rxjs'; |
|||
import { map, startWith } from 'rxjs/operators'; |
|||
|
|||
import { |
|||
AppLanguageDto, |
|||
EditContentForm, |
|||
FieldDto, |
|||
ImmutableArray, |
|||
RootFieldDto |
|||
} from '@app/shared'; |
|||
|
|||
@Component({ |
|||
selector: 'sqx-array-item', |
|||
styleUrls: ['./array-item.component.scss'], |
|||
templateUrl: './array-item.component.html', |
|||
changeDetection: ChangeDetectionStrategy.OnPush |
|||
}) |
|||
export class ArrayItemComponent implements OnChanges { |
|||
@Output() |
|||
public removing = new EventEmitter(); |
|||
|
|||
@Input() |
|||
public form: EditContentForm; |
|||
|
|||
@Input() |
|||
public field: RootFieldDto; |
|||
|
|||
@Input() |
|||
public itemForm: FormGroup; |
|||
|
|||
@Input() |
|||
public language: AppLanguageDto; |
|||
|
|||
@Input() |
|||
public languages: ImmutableArray<AppLanguageDto>; |
|||
|
|||
public isInvalid: Observable<boolean>; |
|||
|
|||
public fieldControls: { field: FieldDto, control: AbstractControl }[]; |
|||
|
|||
public ngOnChanges(changes: SimpleChanges) { |
|||
if (changes['itemForm']) { |
|||
this.isInvalid = this.itemForm.statusChanges.pipe(startWith(this.itemForm.invalid), map(x => this.itemForm.invalid)); |
|||
} |
|||
|
|||
if (changes['itemForm'] || changes['field']) { |
|||
this.fieldControls = this.field.nested.map(field => ({ field, control: this.itemForm.get(field.name)! })).filter(x => !!x.control); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue