Commit 79e9b890 authored by Filipa Lacerda's avatar Filipa Lacerda

Sort environments by name

parent 3ea611e7
...@@ -60,14 +60,14 @@ ...@@ -60,14 +60,14 @@
if (environment.environment_type !== null) { if (environment.environment_type !== null) {
const occurs = acc.find((element, index, array) => { const occurs = acc.find((element, index, array) => {
return element.name === environment.environment_type; return element.environment_type === environment.environment_type;
}); });
data["vue-isChildren"] = true; data["vue-isChildren"] = true;
if (occurs !== undefined) { if (occurs !== undefined) {
acc[acc.indexOf(occurs)].children.push(data); acc[acc.indexOf(occurs)].children.push(data);
acc[acc.indexOf(occurs)].children.sort(); acc[acc.indexOf(occurs)].children.push(data).sort(this.sortByName)
} else { } else {
acc.push({ acc.push({
name: environment.environment_type, name: environment.environment_type,
...@@ -81,11 +81,26 @@ ...@@ -81,11 +81,26 @@
} }
return acc; return acc;
}, []).sort(); }, []).sort(this.sortByName);
this.state.environments = environmentsTree; this.state.environments = environmentsTree;
return environmentsTree; return environmentsTree;
},
sortByName (a,b) {
const nameA = a.name.toUpperCase();
const nameB = b.name.toUpperCase();
if (nameA < nameB) {
return -1;
}
if (nameA > nameB) {
return 1;
}
return 0;
} }
} }
})(); })();
...@@ -52,6 +52,7 @@ ...@@ -52,6 +52,7 @@
%td.hidden-xs %td.hidden-xs
.pull-right{ "v-if" => "!isFolder"} .pull-right{ "v-if" => "!isFolder"}
=render "projects/environments/components/external_url" =render "projects/environments/components/external_url"
=render "projects/environments/components/actions"
%tr{"v-if" => "open && isFolder", %tr{"v-if" => "open && isFolder",
"is" => "environment-item", "is" => "environment-item",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment