From 427a88a6326582374a0b15e54fe85967ccaff98b Mon Sep 17 00:00:00 2001 From: Coenen Benjamin Date: Thu, 27 Dec 2018 17:47:25 +0100 Subject: [PATCH] fix(ui): no more christmas tree in run conditions (#3781) Signed-off-by: Benjamin Coenen --- .../condition-form/condition.component.ts | 22 +++++++++++-------- .../condition-form/condition.form.html | 2 +- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/ui/src/app/shared/workflow/modal/conditions/condition-form/condition.component.ts b/ui/src/app/shared/workflow/modal/conditions/condition-form/condition.component.ts index cd5ddf44bb..12d4dca086 100644 --- a/ui/src/app/shared/workflow/modal/conditions/condition-form/condition.component.ts +++ b/ui/src/app/shared/workflow/modal/conditions/condition-form/condition.component.ts @@ -1,8 +1,8 @@ -import {Component, EventEmitter, Input, Output, ViewChild} from '@angular/core'; -import {cloneDeep} from 'lodash'; -import {CodemirrorComponent} from 'ng2-codemirror-typescript/Codemirror'; -import {PipelineStatus} from '../../../../../model/pipeline.model'; -import {Workflow, WorkflowNodeCondition, WorkflowNodeConditions} from '../../../../../model/workflow.model'; +import { Component, EventEmitter, Input, Output, ViewChild } from '@angular/core'; +import { cloneDeep } from 'lodash'; +import { CodemirrorComponent } from 'ng2-codemirror-typescript/Codemirror'; +import { PipelineStatus } from '../../../../../model/pipeline.model'; +import { Workflow, WorkflowNodeCondition, WorkflowNodeConditions } from '../../../../../model/workflow.model'; declare var CodeMirror: any; @Component({ @@ -35,6 +35,7 @@ export class WorkflowNodeConditionFormComponent { _names: Array = []; suggest: Array = []; condition = new WorkflowNodeCondition(); + oldVariableCondition: string; codeMirrorConfig: {}; statuses = [PipelineStatus.SUCCESS, PipelineStatus.FAIL, PipelineStatus.SKIPPED]; @@ -87,10 +88,13 @@ export class WorkflowNodeConditionFormComponent { this.condition.value = event.target.checked ? 'true' : 'false'; } - variableChanged(event: any) { - this.condition.value = null; - this.condition.operator = 'eq'; - if (event.target.value === 'cds.manual') { + variableChanged(variable: any) { + if (!variable || variable !== this.oldVariableCondition) { + this.condition.value = null; + this.condition.operator = 'eq'; + } + this.oldVariableCondition = variable; + if (variable === 'cds.manual') { this.condition.value = 'false'; } } diff --git a/ui/src/app/shared/workflow/modal/conditions/condition-form/condition.form.html b/ui/src/app/shared/workflow/modal/conditions/condition-form/condition.form.html index 16fd46c219..af9f0a437c 100644 --- a/ui/src/app/shared/workflow/modal/conditions/condition-form/condition.form.html +++ b/ui/src/app/shared/workflow/modal/conditions/condition-form/condition.form.html @@ -20,7 +20,7 @@

{{ 'workflow_node_condition_form' | translate}}

*ngIf="names" class="search" [(model)]="condition.variable" - (change)="variableChanged($event)" + (click)="variableChanged(condition.variable)" [options]="{'fullTextSearch': true, 'allowAdditions': true}">