Added member and contact changing to groups
This commit is contained in:
@@ -258,4 +258,33 @@ function add_verified_groups()
|
||||
delete_from_table("groups_requests",["user_id" => user_id])
|
||||
end
|
||||
|
||||
function changeMemberCount()
|
||||
user_id = get_authentication()
|
||||
groups_ids = select_from_table("users_groups" => ["group_id"], where_data = ["user_id" => user_id])[:,1]
|
||||
group_id = isempty(groups_ids) ? nothing : groups_ids[1]
|
||||
data = copy(jsonpayload())
|
||||
update_table("groups",data, where_data=["id" => group_id])
|
||||
end
|
||||
|
||||
function change_group()
|
||||
user_id = get_authentication()
|
||||
groups_ids = select_from_table("users_groups" => ["group_id"], where_data = ["user_id" => user_id])[:,1]
|
||||
group_id = isempty(groups_ids) ? nothing : groups_ids[1]
|
||||
if !isnothing(group_id)
|
||||
data = copy(jsonpayload())
|
||||
data_new = Dict()
|
||||
ks = keys(data)
|
||||
for x in ["members","contact"]
|
||||
if x in ks
|
||||
data_new[x] = data[x]
|
||||
end
|
||||
end
|
||||
if !isempty(data_new)
|
||||
update_table("groups",data_new, where_data=["id" => group_id])
|
||||
end
|
||||
end
|
||||
return nothing
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
@@ -34,6 +34,11 @@
|
||||
|
||||
let locale = "en"
|
||||
|
||||
let oldValues = {
|
||||
"contact": null,
|
||||
"members": null,
|
||||
}
|
||||
|
||||
let inputLocation
|
||||
let inputContact
|
||||
let inputMembers
|
||||
@@ -85,14 +90,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
function launchChangeLocation() {
|
||||
showLocationOverlay()
|
||||
}
|
||||
|
||||
function launchChangeMembers() {
|
||||
|
||||
}
|
||||
|
||||
function showSaveButton(button,input) {
|
||||
if (!input.readOnly) {
|
||||
button.style.display = "initial"
|
||||
@@ -101,23 +98,33 @@
|
||||
|
||||
function resetMembersField() {
|
||||
saveMembersButton.style.display = "none"
|
||||
inputMembers = oldValues["members"]
|
||||
}
|
||||
|
||||
function resetContactField() {
|
||||
saveContactButton.style.display = "none"
|
||||
inputContact = oldValues["contact"]
|
||||
}
|
||||
|
||||
function saveMembers() {
|
||||
let email = emailInput.value
|
||||
if (AuthTools.checkEmail(email,emailMsg)) {
|
||||
if (email!=user.email) {
|
||||
AuthTools.changeUser("email",email,user)
|
||||
}
|
||||
resetMembersField()
|
||||
let val = parseInt(membersInput.value)
|
||||
let data = {
|
||||
"members": val
|
||||
}
|
||||
sendData("/xx/group-change",data)
|
||||
oldValues["members"] = val
|
||||
saveMembersButton.style.display = "none"
|
||||
}
|
||||
|
||||
function saveContact() {}
|
||||
function saveContact() {
|
||||
let val = contactInput.value
|
||||
let data = {
|
||||
"contact": val
|
||||
}
|
||||
sendData("/xx/group-change",data)
|
||||
oldValues["contact"] = val
|
||||
saveContactButton.style.display = "none"
|
||||
}
|
||||
|
||||
function updateUserGroup(newInfo) {
|
||||
if (newInfo!=undefined) {
|
||||
@@ -159,7 +166,9 @@
|
||||
let group = userGroups[0]
|
||||
|
||||
inputContact = getContact(group.contact)
|
||||
oldValues["contact"] = inputContact
|
||||
inputMembers = group.members
|
||||
oldValues["members"] = inputMembers
|
||||
let status = group.status
|
||||
if (status!=undefined) {
|
||||
if (status==0) {
|
||||
|
Reference in New Issue
Block a user