mirror of https://github.com/Squidex/squidex.git
12 changed files with 302 additions and 99 deletions
@ -0,0 +1,52 @@ |
|||||
|
<div class="row transition no-gutters"> |
||||
|
<div class="col-auto"> |
||||
|
<i class="icon-arrow-right text-decent"></i> |
||||
|
</div> |
||||
|
<div class="col col-step"> |
||||
|
<div class="transition-to"> |
||||
|
<div class="color-circle" [style.background]="transition.step.color"></div> {{transition.to}} |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="col-auto col-label"> |
||||
|
<span class="text-decent">when</span> |
||||
|
</div> |
||||
|
<div class="col"> |
||||
|
<ng-container *ngIf="elementsActive['expression']; else noExpression"> |
||||
|
<input class="form-control" sqxFocusOnInit (focus)="focusElement('expression')" (blur)="blurElement('expression')" spellcheck="false" |
||||
|
[ngModelOptions]="onBlur" |
||||
|
[ngModel]="transition.expression" |
||||
|
(ngModelChange)="changeExpression($event)" /> |
||||
|
</ng-container> |
||||
|
|
||||
|
<ng-template #noExpression> |
||||
|
<button class="btn btn-block btn-outline-secondary dashed" (click)="showElement('expression')"> |
||||
|
Add Expression |
||||
|
</button> |
||||
|
</ng-template> |
||||
|
</div> |
||||
|
<div class="col-auto col-label"> |
||||
|
<span class="text-decent">for</span> |
||||
|
</div> |
||||
|
<div class="col"> |
||||
|
<ng-container *ngIf="elementsActive['role']; else noRole"> |
||||
|
<select class="form-control" sqxFocusOnInit (focus)="focusElement('role')" (blur)="blurElement('role')" |
||||
|
[ngModelOptions]="onBlur" |
||||
|
[ngModel]="transition.role" |
||||
|
(ngModelChange)="changeRole($event)"> |
||||
|
<option *ngFor="let role of roles; trackBy: trackByRole" [ngValue]="role.name">{{role.name}}</option> |
||||
|
<option [ngValue]="null">- All Roles -</option> |
||||
|
</select> |
||||
|
</ng-container> |
||||
|
|
||||
|
<ng-template #noRole> |
||||
|
<button class="btn btn-block btn-outline-secondary dashed" (click)="showElement('role')"> |
||||
|
Add Role |
||||
|
</button> |
||||
|
</ng-template> |
||||
|
</div> |
||||
|
<div class="col-auto pl-2"> |
||||
|
<button type="button" class="btn btn-text-danger" (click)="remove.emit()"> |
||||
|
<i class="icon-bin2"></i> |
||||
|
</button> |
||||
|
</div> |
||||
|
</div> |
||||
@ -0,0 +1,6 @@ |
|||||
|
@import '_vars'; |
||||
|
@import '_mixins'; |
||||
|
|
||||
|
.dashed { |
||||
|
border-style: dashed; |
||||
|
} |
||||
@ -0,0 +1,84 @@ |
|||||
|
/* |
||||
|
* Squidex Headless CMS |
||||
|
* |
||||
|
* @license |
||||
|
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. |
||||
|
*/ |
||||
|
|
||||
|
import { Component, EventEmitter, Input, OnChanges, Output, SimpleChanges } from '@angular/core'; |
||||
|
|
||||
|
import { |
||||
|
RoleDto, |
||||
|
WorkflowTransitionValues, |
||||
|
WorkflowTransitionView |
||||
|
} from '@app/shared'; |
||||
|
|
||||
|
@Component({ |
||||
|
selector: 'sqx-workflow-transition', |
||||
|
styleUrls: ['./workflow-transition.component.scss'], |
||||
|
templateUrl: './workflow-transition.component.html' |
||||
|
}) |
||||
|
export class WorkflowTransitionComponent implements OnChanges { |
||||
|
@Input() |
||||
|
public transition: WorkflowTransitionView; |
||||
|
|
||||
|
@Input() |
||||
|
public roles: RoleDto[]; |
||||
|
|
||||
|
@Output() |
||||
|
public update = new EventEmitter<WorkflowTransitionValues>(); |
||||
|
|
||||
|
@Output() |
||||
|
public remove = new EventEmitter(); |
||||
|
|
||||
|
public elementsActive: { [name: string]: boolean } = {}; |
||||
|
public elementsFocused: { [name: string]: boolean } = {}; |
||||
|
public elementsValid: { [name: string]: boolean } = {}; |
||||
|
|
||||
|
public onBlur = { updateOn: 'blur' }; |
||||
|
|
||||
|
public ngOnChanges(changes: SimpleChanges) { |
||||
|
if (changes['transition']) { |
||||
|
if (this.transition.expression) { |
||||
|
this.elementsValid['expression'] = true; |
||||
|
this.elementsActive['expression'] = true; |
||||
|
} |
||||
|
|
||||
|
if (this.transition.role) { |
||||
|
this.elementsValid['role'] = true; |
||||
|
this.elementsActive['role'] = true; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public changeExpression(expression: string) { |
||||
|
this.update.emit({ expression }); |
||||
|
} |
||||
|
|
||||
|
public changeRole(role: string) { |
||||
|
this.update.emit({ role }); |
||||
|
} |
||||
|
|
||||
|
public showElement(name: string) { |
||||
|
this.elementsActive[name] = true; |
||||
|
} |
||||
|
|
||||
|
public focusElement(name: string) { |
||||
|
this.elementsFocused[name] = true; |
||||
|
} |
||||
|
|
||||
|
public blurElement(name: string) { |
||||
|
this.elementsFocused[name] = false; |
||||
|
|
||||
|
setTimeout(() => { |
||||
|
if (!this.elementsFocused[name] && !this.elementsValid[name]) { |
||||
|
this.elementsActive[name] = false; |
||||
|
} |
||||
|
}, 2000); |
||||
|
} |
||||
|
|
||||
|
public trackByRole(index: number, role: RoleDto) { |
||||
|
return role.name; |
||||
|
} |
||||
|
} |
||||
|
|
||||
Loading…
Reference in new issue