Added a live notice to check the availability of a virtual directory for a group.

This commit is contained in:
Pierre HUBERT 2018-07-14 11:48:59 +02:00
parent a8e686d59b
commit 5cfee77bb2
2 changed files with 48 additions and 0 deletions

View File

@ -109,6 +109,23 @@ ComunicWeb.components.groups.interface = {
ComunicWeb.common.api.makeAPIrequest(apiURI, settings, true, callback);
},
/**
* Check the availability of a virtual directory for a group
*
* @param {String} directory The directory to check
* @param {Number} groupID The ID of the group to check
* @param {Function} callback
*/
checkVirtualDirectory: function(directory, groupID, callback){
//Perform the request over the API
var apiURI = "groups/checkVirtualDirectory";
var params = {
groupID: groupID,
directory: directory
};
ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, callback);
},
/**
* Upload a new group logo
*

View File

@ -130,6 +130,37 @@ ComunicWeb.pages.groups.pages.settings = {
value: settings.virtual_directory == "null" ? "" : settings.virtual_directory,
});
//Check message target
var checkVirtualDirectoryTarget = createElem2({
appendTo: formContainer,
type: "small"
});
virtualDirectory.onkeyup = function(){
checkVirtualDirectoryTarget.innerHTML = "Checking availability...";
//Get the directory to check
var directory = virtualDirectory.value;
//Check if the directory is empty
if(directory == ""){
checkVirtualDirectoryTarget.innerHTML = "";
return;
}
//Perform a request on the API
ComunicWeb.components.groups.interface.checkVirtualDirectory(directory, settings.id, function(callback){
//Check if the directory is available or not
checkVirtualDirectoryTarget.innerHTML =
callback.error
? "<invalidDirectory>This directory is not available!</invalidDirectory>"
: "This directory seems to be available!";
})
}
//Group visibility
var visibilityForm = createElem2({