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

FileManager: improved display of DisplayMode and SortOrder (fast)menu entries

parent 0d9e3650
define([
"vispa/utils",
], function(
Utils
) {
var menu = {
home: {
......@@ -46,65 +48,78 @@ define([
},
// FIXME: implement proper auto-menu-entries for level-0-preferences
displayType: {
label: "Display type",
label: function () {
return (this.value ? Utils.capitalize(this.value) : "Display") + " Mode";
},
iconClass: "fa fa-image",
buttonClass: "btn-default",
position: 4,
unique: true,
multiple: false,
fastmenu: "dropdown",
items: {
symbol: {
label: "Icon",
iconClass: "fa fa-image",
buttonClass: "btn-default",
value: "icon",
callback: function() {
this.$root.instance.prefs.set("displayType", "icon");
this.$root.instance.prefs.set("displayType", this.value);
}
},
table: {
label: "Detail",
iconClass: "fa fa-list",
buttonClass: "btn-default",
value: "detail",
callback: function() {
this.$root.instance.prefs.set("displayType", "detail");
this.$root.instance.prefs.set("displayType", this.value);
}
}
}
},
sortType: {
label: "Sort",
iconClass: "fa fa-sort",
buttonClass: "btn-default",
position: 5,
fastmenu: "dropdown",
items: {
name: {
label: "Name",
iconClass: "fa-sort-alpha-asc",
buttonClass: "btn-default",
callback: function () {
this.$root.instance.vue.content.sortMod("name");
},
},
size: {
label: "Size",
iconClass: "fa-sort-amount-asc",
buttonClass: "btn-default",
callback: function () {
this.$root.instance.vue.content.sortMod("size");
},
},
modified: {
label: "Modified date",
iconClass: "fa-sort-numeric-asc",
buttonClass: "btn-default",
callback: function () {
this.$root.instance.vue.content.sortMod("modified");
},
},
},
};
// sorting menu (may become deprecated with auto pref menus)
var sortIcon = {
name: "fa-sort-alpha-asc",
size: "fa-sort-amount-asc",
mtime: "fa-sort-numeric-asc",
};
var sortLabel = {
name: "Name",
size: "Size",
mtime: "Date",
};
var sortMenu = {
label: function () {
var x = this.$root.instance.prefs.get("sortOrder");
x = sortLabel[x && x[0]];
return x ? ("Sort by " + x) : "Sort order";
},
iconClass: function () {
var x = this.$root.instance.prefs.get("sortOrder");
return sortIcon[x && x[0]] || "fa-sort";
},
buttonClass: "btn-default",
position: 5,
// unique: true,
fastmenu: "dropdown",
items: {},
};
for (var i in sortIcon) {
sortMenu.items[i] = {
label: sortLabel[i],
buttonClass: "btn-default",
value: i,
callback: function () {
this.$root.instance.vue.content.sortMod(this.value);
},
};
sortIcon["-" + i] = sortIcon[i].replace("-asc", "-desc");
sortLabel["-" + i] = sortLabel[i].replace("-asc", "-desc");
}
menu.sortOrder = sortMenu;
return menu;
});
define([
"vue/vue",
], function(
Vue
) {
var BaseMixin = {
init: function(args) {
......@@ -23,6 +25,16 @@ define([
if (this.autoPathLabel)
this.setLabel(this.state.get("path"), true);
Vue.set(this.menu.items.displayType, "value", this.prefs.get("displayType"));
var so = this.prefs.get("sortOrder");
if (so && so.length) {
so = so[0]
if (so.slice(0, 1) == "-")
so = so.slice(1);
Vue.set(this.menu.items.sortOrder, "value", so);
}
this.prefs.forceWorkspace("bookmarks");
},
......
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