Skip to content

Commit

Permalink
fix(ui): fix edit action page (#2414)
Browse files Browse the repository at this point in the history
Signed-off-by: Benjamin Coenen <[email protected]>
  • Loading branch information
bnjjj authored and fsamin committed Mar 19, 2018
1 parent 143133f commit b64105e
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 13 deletions.
17 changes: 10 additions & 7 deletions ui/src/app/shared/action/action.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Component, Input, Output, EventEmitter, OnDestroy} from '@angular/core';
import {Component, Input, Output, EventEmitter, OnDestroy, OnInit} from '@angular/core';
import {Action} from '../../model/action.model';
import {SharedService} from '../shared.service';
import {RequirementEvent} from '../requirements/requirement.event.model';
Expand All @@ -18,7 +18,7 @@ import {cloneDeep} from 'lodash';
templateUrl: './action.html',
styleUrls: ['./action.scss']
})
export class ActionComponent implements OnDestroy {
export class ActionComponent implements OnDestroy, OnInit {
editableAction: Action;
steps: Array<Action> = new Array<Action>();
publicActions: Array<Action>;
Expand Down Expand Up @@ -48,10 +48,6 @@ export class ActionComponent implements OnDestroy {
collapsed = true;
configRequirements: {disableModel?: boolean, disableHostname?: boolean} = {};
constructor(private sharedService: SharedService, private _actionStore: ActionStore, private dragulaService: DragulaService) {
this._actionStore.getActions().subscribe(mapActions => {
this.publicActions = mapActions.toArray();
});

dragulaService.setOptions('bag-nonfinal', {
moves: function (el, source, handle) {
return handle.classList.contains('move');
Expand All @@ -68,6 +64,12 @@ export class ActionComponent implements OnDestroy {
});
}

ngOnInit() {
this._actionStore.getActions().subscribe(mapActions => {
this.publicActions = mapActions.toArray().filter((action) => action.name !== this.editableAction.name);
});
}

ngOnDestroy() {
this.dragulaService.destroy('bag-nonfinal');
this.dragulaService.destroy('bag-final');
Expand Down Expand Up @@ -167,13 +169,14 @@ export class ActionComponent implements OnDestroy {
}
let indexAdd = this.editableAction.parameters.findIndex(param => p.parameter.name === param.name);
if (indexAdd === -1) {
this.editableAction.parameters.push(p.parameter);
this.editableAction.parameters = this.editableAction.parameters.concat([p.parameter]);
}
break;
case 'delete':
let indexDelete = this.editableAction.parameters.indexOf(p.parameter);
if (indexDelete >= 0) {
this.editableAction.parameters.splice(indexDelete, 1);
this.editableAction.parameters = this.editableAction.parameters.concat([]);
}
break;
}
Expand Down
12 changes: 8 additions & 4 deletions ui/src/app/shared/action/action.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,13 @@ <h3>{{ 'requirement_add' | translate }}</h3>
<div class="field">
<label>{{ 'common_parameters' | translate }}</label>
<div>
<app-parameter-list [project]="project" [parameters]="editableAction.parameters" [mode]="edit? 'edit': 'ro'"
(event)="parameterEvent($event)"></app-parameter-list>
<app-parameter-list
[project]="project"
[parameters]="editableAction.parameters"
[mode]="edit? 'edit': 'ro'"
[hideSave]="true"
(event)="parameterEvent($event)">
</app-parameter-list>
</div>
<div>
<app-parameter-form *ngIf="edit" [project]="project" (createParameterEvent)="parameterEvent($event)"></app-parameter-form>
Expand All @@ -73,7 +78,7 @@ <h3>{{ 'requirement_add' | translate }}</h3>

<div class="subtitle normalStep">
<h3 class="inline">{{ 'action_step_title' | translate }}</h3>
<div class="right floated">
<div class="right floated" *ngIf="steps && steps.length > 0">
<button class="ui blue button" (click)="collapsed = !collapsed">
<ng-container *ngIf="collapsed">
<i class="hide icon"></i>
Expand All @@ -83,7 +88,6 @@ <h3 class="inline">{{ 'action_step_title' | translate }}</h3>
<i class="eye icon"></i>
{{'common_show_all' | translate}}
</ng-container>

</button>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/shared/parameter/form/parameter.form.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<textarea [(ngModel)]="newParameter.description" name="description" rows="{{ _sharedService.getTextAreaheight(newParameter.description)}}"></textarea>
</div>
<div class="two wide center field">
<button class="ui blue button"><i class="plus icon"></i>{{ 'btn_add' | translate}}</button>
<button class="ui blue button" [disabled]="!newParameter.name"><i class="plus icon"></i>{{ 'btn_add' | translate}}</button>
</div>
</div>
</form>
1 change: 1 addition & 0 deletions ui/src/app/shared/parameter/list/parameter.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export class ParameterListComponent extends Table {
@Input() suggest: Array<string>;
@Input() keys: AllKeys;
@Input() canDelete: boolean;
@Input() hideSave = false;

// edit/launcher/ro/job
@Input() mode = 'edit';
Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/shared/parameter/list/parameter.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
</td>
<td class="center" *ngIf="mode !== 'launcher' && mode !== 'job'">
<ng-container *ngIf="mode === 'edit'">
<div *ngIf="p.hasChanged;then save;else remove"></div>
<div *ngIf="p.hasChanged && !hideSave;then save;else remove"></div>
<ng-template #save>
<button class="ui green button" [class.loading]="p.updating" [class.disabled]="p.updating" name="btnupdatevparam" (click)="sendEvent('update', p)">
<i class="save icon"></i>
Expand Down

0 comments on commit b64105e

Please sign in to comment.