Commit e7c513f5 authored by Benjamin Fischer's avatar Benjamin Fischer
Browse files

extension/file2: added suggestions for current directory items in navbar

parent 5f5d1f8e
......@@ -7,6 +7,8 @@
:path="path"
:loading="loading"
:workspace-id="workspaceId"
:view-id="view.id"
:dir-names="dirNames"
:path-edit.sync="pathEdit"
></navbar>
<component
......
......@@ -24,11 +24,15 @@
@keyup.enter="pathNav"
@keyup.esc="pathEdit = false"
@blur="pathEdit = false"
:list="suggestionsId"
>
<button
class="btn-nostyle"
@click="pathNav"
><i class="fa fa-arrow-right"></i></button>
<datalist :id="suggestionsId"
><option v-for="sugg in suggestions" :value="sugg"
/></datalist>
</div>
</div>
<div class="navi-button">
......
......@@ -65,6 +65,13 @@ define([
}
return items;
},
dirNames: function() {
return this.filteredItems.filter(function(item) {
return item.type === "d";
}).map(function(item) {
return item.name;
});
},
sortedItems: function() {
var order = (this.pref("dirFirst") ? ["type"] : []).concat(this.pref("sortOrder"));
return this.filteredItems.slice().sort(function(a, b) {
......
......@@ -23,6 +23,8 @@ define([
path: String,
loading: Boolean,
workspaceId: Number,
viewId: String,
dirNames: Array,
pathEdit: {
type: Boolean,
default: false,
......@@ -66,6 +68,19 @@ define([
},
};
},
suggestions: function() {
var prefix = this.path + "/";
if (!this.pathText.startsWith(prefix)) return [];
var base = this.pathText.replace(prefix, "");
return this.dirNames
.filter(function(name) {return name.startsWith(base);})
.map(function(name) {return prefix + name;})
.sort()
.slice(0, 10);
},
suggestionsId: function() {
return "file2_navbar_suggestions_" + this.viewId;
},
},
methods: {
pathNav: function() {
......
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