BigW Consortium Gitlab

Commit 727c8a26 by Jacob Schatz

Alphabetizes the list of files.

parent 2bdf1d9f
......@@ -73,17 +73,15 @@ const RepoHelper = {
},
getNewMergedList(inDirectory, currentList, newList) {
if (!inDirectory) return newList;
const newListSorted = newList.sort(this.compareFilesCaseInsensitive);
if (!inDirectory) return newListSorted;
const indexOfFile = currentList.findIndex(file => file.url === inDirectory.url);
if (!indexOfFile) return newList;
return RepoHelper.mergeNewListToOldList(newList, currentList, inDirectory, indexOfFile);
if (!indexOfFile) return newListSorted;
return RepoHelper.mergeNewListToOldList(newListSorted, currentList, inDirectory, indexOfFile);
},
mergeNewListToOldList(newList, oldList, inDirectory, indexOfFile) {
newList.forEach((newFile) => {
newList.reverse().forEach((newFile) => {
const fileIndex = indexOfFile + 1;
const file = newFile;
file.level = inDirectory.level + 1;
......@@ -93,6 +91,17 @@ const RepoHelper = {
return oldList;
},
compareFilesCaseInsensitive(a,b) {
const aName = a.name.toLowerCase();
const bName = b.name.toLowerCase();
if(a.level > 0) return 0;
if (aName < bName)
return -1;
if (aName > bName)
return 1;
return 0;
},
getContent(treeOrFile, cb) {
let file = treeOrFile;
// const loadingData = RepoHelper.setLoading(true);
......
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