mirror of
https://github.com/portainer/portainer.git
synced 2025-08-02 12:25:22 +02:00
feat(app): sort environment variables (#4815)
* feat(app): sort environment variables * feat(k8s/application): improve the sorting for the env variables when creating/editing application * feat(k8s/application): update the removal of the env var * feat(docker/service): improve the sorting order for env var in service edition view
This commit is contained in:
parent
86335a4357
commit
387bbeceba
9 changed files with 24 additions and 15 deletions
|
@ -142,7 +142,7 @@
|
|||
</div>
|
||||
|
||||
<div class="col-sm-12 form-inline" style="margin-top: 10px;">
|
||||
<div ng-repeat="envVar in ctrl.formValues.EnvironmentVariables" style="margin-top: 2px;">
|
||||
<div ng-repeat="envVar in ctrl.formValues.EnvironmentVariables | orderBy: 'NameIndex'" style="margin-top: 2px;">
|
||||
<div class="col-sm-4 input-group input-group-sm" style="vertical-align: top;">
|
||||
<div class="input-group col-sm-12 input-group-sm" ng-class="{ striked: envVar.NeedsDeletion }">
|
||||
<span class="input-group-addon">name</span>
|
||||
|
@ -191,10 +191,10 @@
|
|||
</div>
|
||||
|
||||
<div class="input-group col-sm-2 input-group-sm" ng-if="ctrl.formValues.Containers.length <= 1">
|
||||
<button ng-if="!envVar.NeedsDeletion" class="btn btn-sm btn-danger" type="button" ng-click="ctrl.removeEnvironmentVariable($index)">
|
||||
<button ng-if="!envVar.NeedsDeletion" class="btn btn-sm btn-danger" type="button" ng-click="ctrl.removeEnvironmentVariable(envVar)">
|
||||
<i class="fa fa-trash-alt" aria-hidden="true"></i>
|
||||
</button>
|
||||
<button ng-if="envVar.NeedsDeletion" class="btn btn-sm btn-primary" type="button" ng-click="ctrl.restoreEnvironmentVariable($index)">
|
||||
<button ng-if="envVar.NeedsDeletion" class="btn btn-sm btn-primary" type="button" ng-click="ctrl.restoreEnvironmentVariable(envVar)">
|
||||
<i class="fa fa-trash-restore" aria-hidden="true"></i>
|
||||
</button>
|
||||
</div>
|
||||
|
|
|
@ -165,15 +165,19 @@ class KubernetesCreateApplicationController {
|
|||
this.formValues.EnvironmentVariables.push(new KubernetesApplicationEnvironmentVariableFormValue());
|
||||
}
|
||||
|
||||
restoreEnvironmentVariable(index) {
|
||||
this.formValues.EnvironmentVariables[index].NeedsDeletion = false;
|
||||
restoreEnvironmentVariable(item) {
|
||||
item.NeedsDeletion = false;
|
||||
}
|
||||
|
||||
removeEnvironmentVariable(index) {
|
||||
if (this.state.isEdit && !this.formValues.EnvironmentVariables[index].IsNew) {
|
||||
this.formValues.EnvironmentVariables[index].NeedsDeletion = true;
|
||||
} else {
|
||||
this.formValues.EnvironmentVariables.splice(index, 1);
|
||||
removeEnvironmentVariable(item) {
|
||||
const index = this.formValues.EnvironmentVariables.indexOf(item);
|
||||
if (index !== -1) {
|
||||
const envVar = this.formValues.EnvironmentVariables[index];
|
||||
if (!envVar.IsNew) {
|
||||
envVar.NeedsDeletion = true;
|
||||
} else {
|
||||
this.formValues.EnvironmentVariables.splice(index, 1);
|
||||
}
|
||||
}
|
||||
this.onChangeEnvironmentName();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue