Add virtual directory support for sidebar

This commit is contained in:
Pierre HUBERT 2020-04-09 09:25:58 +02:00
parent 01d244386f
commit 1596fda533
3 changed files with 32 additions and 5 deletions

View File

@ -17,6 +17,10 @@ class Group {
this.virtual_directory = info.virtual_directory; this.virtual_directory = info.virtual_directory;
this.visibility = info.visibility; this.visibility = info.visibility;
} }
get hasVirtualDirectory() {
return this.virtual_directory;
}
} }
class GroupsList { class GroupsList {

View File

@ -368,7 +368,7 @@ const SidebarMain = {
* *
* @param {HTMLElement} target * @param {HTMLElement} target
* @param {*} friend * @param {*} friend
* @param {*} user * @param {User} user
*/ */
applyFriend: function(target, friend, user) { applyFriend: function(target, friend, user) {
@ -378,6 +378,9 @@ const SidebarMain = {
}); });
li.setAttribute("data-membership-user-id", user.id) li.setAttribute("data-membership-user-id", user.id)
if(user.hasVirtualDirectory)
li.setAttribute("data-membership-dir", user.virtualDirectory)
let a = createElem2({ let a = createElem2({
appendTo: li, appendTo: li,
@ -467,7 +470,7 @@ const SidebarMain = {
* Apply group information * Apply group information
* *
* @param {HTMLElement} target * @param {HTMLElement} target
* @param {*} group * @param {Group} group
* @param {*} lastactive * @param {*} lastactive
*/ */
applyGroup: function(target, group, lastactive) { applyGroup: function(target, group, lastactive) {
@ -478,6 +481,9 @@ const SidebarMain = {
}); });
li.setAttribute("data-membership-group-id", group.id) li.setAttribute("data-membership-group-id", group.id)
if(group.hasVirtualDirectory)
li.setAttribute("data-membership-dir", group.virtual_directory)
let a = createElem2({ let a = createElem2({
appendTo: li, appendTo: li,
type: "a", type: "a",
@ -591,14 +597,17 @@ const SidebarMain = {
query = "[data-membership-user-id=\""+currPage.split("/")[1].split("#")[0]+"\"]" query = "[data-membership-user-id=\""+currPage.split("/")[1].split("#")[0]+"\"]"
// Groups // Groups
if(currPage.startsWith("groups/")) else if(currPage.startsWith("groups/"))
query = "[data-membership-group-id=\""+currPage.split("/")[1].split("#")[0]+"\"]" query = "[data-membership-group-id=\""+currPage.split("/")[1].split("#")[0]+"\"]"
// Conversations // Conversations
if(currPage.startsWith("conversations/")) else if(currPage.startsWith("conversations/"))
query = "[data-membership-conv-id=\""+currPage.split("/")[1].split("#")[0]+"\"]" query = "[data-membership-conv-id=\""+currPage.split("/")[1].split("#")[0]+"\"]"
// Search by virtual directory
else {
query = "[data-membership-dir=\""+currPage.split("/")[0].split("?")[0].split("#")[0]+"\"]";
}
// Query element // Query element

View File

@ -20,12 +20,26 @@ class User {
this.id = info.userID; this.id = info.userID;
} }
/**
* Backward compatibility
*/
get userID() {
return this.id
}
/** /**
* Get the full name of the user * Get the full name of the user
*/ */
get fullName() { get fullName() {
return this.firstName + " " + this.lastName; return this.firstName + " " + this.lastName;
} }
/**
* Check out whether a given user has a virtual directory or not
*/
get hasVirtualDirectory() {
return this.virtualDirectory;
}
} }
class UsersList { class UsersList {