From d47cd4532bb9b7b2c7573d6c0ebe252343f8d0c0 Mon Sep 17 00:00:00 2001 From: Yvonnick Esnault Date: Tue, 20 Jun 2017 13:49:42 +0200 Subject: [PATCH] fix (ui): update checkbox (#741) close #724 close #723 --- .../app/shared/action/step/step.component.ts | 1 + ui/src/app/shared/action/step/step.html | 2 +- .../app/shared/parameter/list/parameter.html | 3 +- .../value/parameter.value.component.ts | 26 ++++++++++------- .../parameter/value/parameter.value.html | 28 +++++++++---------- .../views/pipeline/show/pipeline.show.scss | 2 +- .../stage/pipeline.stage.component.ts | 1 + .../show/workflow/stage/pipeline.stage.html | 3 +- .../show/workflow/stage/pipeline.stage.scss | 6 +++- .../action/edit/action.edit.component.ts | 22 +++++++++++++++ 10 files changed, 63 insertions(+), 31 deletions(-) diff --git a/ui/src/app/shared/action/step/step.component.ts b/ui/src/app/shared/action/step/step.component.ts index 4e12365d4e..77e60d7a6e 100644 --- a/ui/src/app/shared/action/step/step.component.ts +++ b/ui/src/app/shared/action/step/step.component.ts @@ -1,5 +1,6 @@ import {Component, Input, EventEmitter, Output} from '@angular/core'; import {Action} from '../../../model/action.model'; +import {Parameter} from '../../../model/parameter.model'; import {StepEvent} from './step.event'; @Component({ diff --git a/ui/src/app/shared/action/step/step.html b/ui/src/app/shared/action/step/step.html index 5a71b0431e..e49129a864 100644 --- a/ui/src/app/shared/action/step/step.html +++ b/ui/src/app/shared/action/step/step.html @@ -33,4 +33,4 @@ (valueUpdating)="action.hasChanged = true"> - \ No newline at end of file + diff --git a/ui/src/app/shared/parameter/list/parameter.html b/ui/src/app/shared/parameter/list/parameter.html index a0f9c1b3d6..bae21acbf6 100644 --- a/ui/src/app/shared/parameter/list/parameter.html +++ b/ui/src/app/shared/parameter/list/parameter.html @@ -13,7 +13,7 @@
- +
@@ -63,7 +63,6 @@ - diff --git a/ui/src/app/shared/parameter/value/parameter.value.component.ts b/ui/src/app/shared/parameter/value/parameter.value.component.ts index c8c995b7c1..fee140e611 100644 --- a/ui/src/app/shared/parameter/value/parameter.value.component.ts +++ b/ui/src/app/shared/parameter/value/parameter.value.component.ts @@ -13,10 +13,15 @@ declare var CodeMirror: any; templateUrl: './parameter.value.html', styleUrls: ['./parameter.value.scss'] }) -export class ParameterValueComponent implements OnInit { +export class ParameterValueComponent { + editableValue: string|number|boolean; @Input() type: string; - @Input() value: string|number|boolean; + @Input('value') + set value (data: string|number|boolean) { + this.editableValue = this.castValue(data); + }; + @Input() editList = true; @Input() edit = true; @Input() suggest: Array = new Array(); @@ -65,18 +70,19 @@ export class ParameterValueComponent implements OnInit { }; } - ngOnInit(): void { + castValue(data: string|number|boolean): string|number|boolean { if (this.type === 'boolean') { - this.value = (this.value === 'true'); + return (data === 'true' || data === true); } if (this.type === 'list' && !this.editList) { - this.list = (this.value).split(';'); - this.value = this.list[0]; + this.list = (data).split(';'); + return this.list[0]; } + return data; } valueChanged(): void { - this.valueChange.emit(this.value); + this.valueChange.emit(this.editableValue); } sendValueChanged(): void { @@ -85,7 +91,7 @@ export class ParameterValueComponent implements OnInit { changeCodeMirror(): void { this.valueChanged(); - let firstLine = String(this.value).split('\n')[0]; + let firstLine = String(this.editableValue).split('\n')[0]; if (firstLine.indexOf('FROM') !== -1) { this.codeMirrorConfig.mode = 'dockerfile'; @@ -93,7 +99,7 @@ export class ParameterValueComponent implements OnInit { this.codeMirrorConfig.mode = 'perl'; } else if (firstLine.indexOf('#!/usr/bin/python') !== -1) { this.codeMirrorConfig.mode = 'python'; - } else if (String(this.value).indexOf('c:\\') !== -1) { + } else if (String(this.editableValue).indexOf('c:\\') !== -1) { this.codeMirrorConfig.mode = 'powershell'; } else if (firstLine.indexOf('#!/bin/bash') !== -1) { this.codeMirrorConfig.mode = 'bash'; @@ -123,7 +129,7 @@ export class ParameterValueComponent implements OnInit { } valueRepoChanged(name): void { - this.value = this.selectedRepoManager.name + '##' + name; + this.editableValue = this.selectedRepoManager.name + '##' + name; this.valueChanged(); } diff --git a/ui/src/app/shared/parameter/value/parameter.value.html b/ui/src/app/shared/parameter/value/parameter.value.html index 641599c719..c1181d74e0 100644 --- a/ui/src/app/shared/parameter/value/parameter.value.html +++ b/ui/src/app/shared/parameter/value/parameter.value.html @@ -1,21 +1,21 @@
- +
- +
- +
- +
@@ -36,7 +36,7 @@
@@ -58,23 +58,23 @@ [disabled]="loadingRepos"> - +
-
- +
- - + +
- {{value}} + {{editableValue}}
-
\ No newline at end of file + diff --git a/ui/src/app/views/pipeline/show/pipeline.show.scss b/ui/src/app/views/pipeline/show/pipeline.show.scss index 11e52f7d61..696e647a05 100644 --- a/ui/src/app/views/pipeline/show/pipeline.show.scss +++ b/ui/src/app/views/pipeline/show/pipeline.show.scss @@ -3,4 +3,4 @@ flex-direction: column; align-content: stretch; height: 100%; -} \ No newline at end of file +} diff --git a/ui/src/app/views/pipeline/show/workflow/stage/pipeline.stage.component.ts b/ui/src/app/views/pipeline/show/workflow/stage/pipeline.stage.component.ts index 0aaf6e0c89..e02aea0415 100644 --- a/ui/src/app/views/pipeline/show/workflow/stage/pipeline.stage.component.ts +++ b/ui/src/app/views/pipeline/show/workflow/stage/pipeline.stage.component.ts @@ -102,6 +102,7 @@ export class PipelineStageComponent implements OnInit, DoCheck { this._toast.success('', this._translate.instant('stage_job_updated')); job.action.loading = false; job.action.hasChanged = false; + }, () => { job.action.loading = false; }); diff --git a/ui/src/app/views/pipeline/show/workflow/stage/pipeline.stage.html b/ui/src/app/views/pipeline/show/workflow/stage/pipeline.stage.html index 430763b1ca..c9040cbc51 100644 --- a/ui/src/app/views/pipeline/show/workflow/stage/pipeline.stage.html +++ b/ui/src/app/views/pipeline/show/workflow/stage/pipeline.stage.html @@ -1,5 +1,5 @@

{{ 'stage_jobs_title' | translate}}

-
+
{{ 'stage_jobs_title' | translate}} (actionEvent)="jobEvent($event)">
- diff --git a/ui/src/app/views/pipeline/show/workflow/stage/pipeline.stage.scss b/ui/src/app/views/pipeline/show/workflow/stage/pipeline.stage.scss index 87f84b8bfd..f527f91026 100644 --- a/ui/src/app/views/pipeline/show/workflow/stage/pipeline.stage.scss +++ b/ui/src/app/views/pipeline/show/workflow/stage/pipeline.stage.scss @@ -47,6 +47,10 @@ margin-top: 10px; } +.spacebottom { + padding-bottom: 50px !important; +} + pre { word-break: break-word; -} \ No newline at end of file +} diff --git a/ui/src/app/views/settings/action/edit/action.edit.component.ts b/ui/src/app/views/settings/action/edit/action.edit.component.ts index 8c10d070e7..8c555c7523 100644 --- a/ui/src/app/views/settings/action/edit/action.edit.component.ts +++ b/ui/src/app/views/settings/action/edit/action.edit.component.ts @@ -38,6 +38,28 @@ export class ActionEditComponent implements OnInit { actionEvent(event: ActionEvent): void { event.action.loading = true; + + if (event.action.actions) { + event.action.actions.forEach(a => { + if (a.parameters) { + a.parameters.forEach(p => { + if (p.type === 'boolean' && !p.value) { + p.value = 'false'; + } + p.value = p.value.toString(); + }); + } + }); + } + if (event.action.parameters) { + event.action.parameters.forEach(p => { + if (p.type === 'boolean' && !p.value) { + p.value = 'false'; + } + p.value = p.value.toString(); + }); + } + switch (event.type) { case 'update': this._actionService.updateAction(this.action.name, event.action).subscribe( action => {