mirror of https://github.com/Squidex/squidex.git
44 changed files with 395 additions and 317 deletions
@ -1,9 +1,9 @@ |
|||
<span class="form-check" *ngFor="let value of values"> |
|||
<input type="checkbox" class="form-check-input" id="{{control}}{{value}}" |
|||
<input type="checkbox" class="form-check-input" id="{{snapshot.controlId}}{{value}}" |
|||
(blur)="blur()" |
|||
(change)="check($event.target.checked, value)" |
|||
[checked]="isChecked(value)" |
|||
[disabled]="isDisabled"> |
|||
[disabled]="snapshot.isDisabled"> |
|||
|
|||
<label class="form-check-label" for="{{control}}{{value}}">{{value}}</label> |
|||
<label class="form-check-label" for="{{snapshot.controlId}}{{value}}">{{value}}</label> |
|||
</span> |
|||
@ -1,6 +1,6 @@ |
|||
<div class="errors-container" *ngIf="errorMessages.length > 0" @fade> |
|||
<div class="errors-container" *ngIf="snapshot.errorMessages.length > 0" @fade> |
|||
<div class="errors"> |
|||
<span *ngFor="let message of errorMessages"> |
|||
<span *ngFor="let message of snapshot.errorMessages"> |
|||
{{message}} |
|||
</span> |
|||
</div> |
|||
|
|||
@ -1,6 +1,6 @@ |
|||
<div class="toggle-container" (click)="changeState($event)" |
|||
[class.disabled]="isDisabled" |
|||
[class.checked]="isChecked === true" |
|||
[class.unchecked]="isChecked === false"> |
|||
[class.disabled]="snapshot.isDisabled" |
|||
[class.checked]="snapshot.isChecked === true" |
|||
[class.unchecked]="snapshot.isChecked === false"> |
|||
<div class="toggle-button"></div> |
|||
</div> |
|||
@ -0,0 +1,58 @@ |
|||
/* |
|||
* Squidex Headless CMS |
|||
* |
|||
* @license |
|||
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. |
|||
*/ |
|||
|
|||
import { ChangeDetectorRef, OnDestroy, OnInit } from '@angular/core'; |
|||
import { Subscription } from 'rxjs'; |
|||
|
|||
import { Types } from './../utils/types'; |
|||
|
|||
import { State } from '../state'; |
|||
|
|||
declare type UnsubscribeFunction = () => void; |
|||
|
|||
export abstract class StatefulComponent<T> extends State<T> implements OnDestroy, OnInit { |
|||
private subscriptions: (Subscription | UnsubscribeFunction)[] = []; |
|||
|
|||
constructor( |
|||
private readonly changeDetector: ChangeDetectorRef, |
|||
state: T |
|||
) { |
|||
super(state); |
|||
} |
|||
|
|||
protected observe(subscription: Subscription | UnsubscribeFunction) { |
|||
if (subscription) { |
|||
this.subscriptions.push(subscription); |
|||
} |
|||
} |
|||
|
|||
public ngOnInit() { |
|||
this.changes.subscribe(() => { |
|||
this.changeDetector.detectChanges(); |
|||
}); |
|||
} |
|||
|
|||
public ngOnDestroy() { |
|||
try { |
|||
for (let subscription of this.subscriptions) { |
|||
if (Types.isFunction(subscription)) { |
|||
subscription(); |
|||
} else { |
|||
subscription.unsubscribe(); |
|||
} |
|||
} |
|||
} finally { |
|||
this.subscriptions = []; |
|||
} |
|||
} |
|||
} |
|||
|
|||
export abstract class PureComponent extends StatefulComponent<any> { |
|||
constructor(changeDetector: ChangeDetectorRef) { |
|||
super(changeDetector, {}); |
|||
} |
|||
} |
|||
Loading…
Reference in new issue