mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-11-22 20:19:21 +00:00
Display user ID and email in settings
This commit is contained in:
parent
643ebd235d
commit
ba87b35382
16
assets/css/pages/settings/sections/general.css
Normal file
16
assets/css/pages/settings/sections/general.css
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
/**
|
||||||
|
* General settings stylesheet
|
||||||
|
*
|
||||||
|
* @author Pierre HUBERT
|
||||||
|
*/
|
||||||
|
|
||||||
|
.box-general-settings .input-user-id {
|
||||||
|
width: 29%;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.box-general-settings .input-user-email {
|
||||||
|
width: 70%;
|
||||||
|
display: inline-block;
|
||||||
|
margin-left: 1%;
|
||||||
|
}
|
@ -39,6 +39,7 @@ function createElem(nodeType, appendTo){
|
|||||||
* @info {String} value The value of the new element
|
* @info {String} value The value of the new element
|
||||||
* @info {String} placeholder The placeholder of the new element
|
* @info {String} placeholder The placeholder of the new element
|
||||||
* @info {String} innerHTML Specify the html content of the newly created element
|
* @info {String} innerHTML Specify the html content of the newly created element
|
||||||
|
* @info {boolean} disabled Set whether the field should be disabled or not (input only)
|
||||||
* @return {HTMLElement} The newly created element
|
* @return {HTMLElement} The newly created element
|
||||||
*/
|
*/
|
||||||
function createElem2(infos){
|
function createElem2(infos){
|
||||||
@ -101,6 +102,10 @@ function createElem2(infos){
|
|||||||
if(infos.innerHTML)
|
if(infos.innerHTML)
|
||||||
newElem.innerHTML = infos.innerHTML;
|
newElem.innerHTML = infos.innerHTML;
|
||||||
|
|
||||||
|
//Set field state
|
||||||
|
if(infos.disabled)
|
||||||
|
infos.disabled = true;
|
||||||
|
|
||||||
//Return newly created element
|
//Return newly created element
|
||||||
return newElem;
|
return newElem;
|
||||||
}
|
}
|
||||||
@ -190,13 +195,28 @@ function checkMail(emailAddress){
|
|||||||
* * @info {Boolean} checked Defines if the fields has to be checked or not (checkbox only)
|
* * @info {Boolean} checked Defines if the fields has to be checked or not (checkbox only)
|
||||||
* * @info {Boolean} multiple Defines if the fields can accept more than one response
|
* * @info {Boolean} multiple Defines if the fields can accept more than one response
|
||||||
* * @info {String} type The type of the field
|
* * @info {String} type The type of the field
|
||||||
|
* * @info {string} value The default value of the input
|
||||||
|
* * @info {boolean} disabled Set whether the field should be disabled or not
|
||||||
|
* * @info {string} additionalGroupClasses Additionnal form group class names
|
||||||
* @return {HTMLElement} The input
|
* @return {HTMLElement} The input
|
||||||
*/
|
*/
|
||||||
function createFormGroup(infos){
|
function createFormGroup(infos){
|
||||||
|
|
||||||
|
//Check for default value
|
||||||
|
var value = infos.value ? infos.value : "";
|
||||||
|
|
||||||
|
//Check if the field has to be disabled
|
||||||
|
var disabled = infos.disabled;
|
||||||
|
|
||||||
//Create formgroup
|
//Create formgroup
|
||||||
var formGroup = createElem("div", infos.target);
|
var formGroup = createElem("div", infos.target);
|
||||||
formGroup.className = "form-group";
|
formGroup.className = "form-group";
|
||||||
|
|
||||||
|
//Add optionnal classes if required
|
||||||
|
if(infos.additionalGroupClasses){
|
||||||
|
formGroup.className += " " + infos.additionalGroupClasses;
|
||||||
|
}
|
||||||
|
|
||||||
//Add label
|
//Add label
|
||||||
var labelElem = createElem("label", formGroup);
|
var labelElem = createElem("label", formGroup);
|
||||||
|
|
||||||
@ -206,6 +226,7 @@ function createFormGroup(infos){
|
|||||||
//Create checkbox
|
//Create checkbox
|
||||||
var input = createElem("input", labelElem) ;
|
var input = createElem("input", labelElem) ;
|
||||||
input.type = "checkbox";
|
input.type = "checkbox";
|
||||||
|
input.disabled = disabled;
|
||||||
|
|
||||||
//Check if input has to be checked by default
|
//Check if input has to be checked by default
|
||||||
if(infos.checked){
|
if(infos.checked){
|
||||||
@ -236,6 +257,7 @@ function createFormGroup(infos){
|
|||||||
var input = createElem("select", formGroup);
|
var input = createElem("select", formGroup);
|
||||||
input.style.width = "100%";
|
input.style.width = "100%";
|
||||||
input.className = "form-control select2";
|
input.className = "form-control select2";
|
||||||
|
input.disabled = disabled;
|
||||||
if(infos.multiple) //For multiple changes
|
if(infos.multiple) //For multiple changes
|
||||||
input.setAttribute("multiple", "multiple");
|
input.setAttribute("multiple", "multiple");
|
||||||
if(infos.placeholder) //Placeholder if required
|
if(infos.placeholder) //Placeholder if required
|
||||||
@ -256,6 +278,8 @@ function createFormGroup(infos){
|
|||||||
type: "textarea",
|
type: "textarea",
|
||||||
class: "form-control",
|
class: "form-control",
|
||||||
placeholder: infos.placeholder,
|
placeholder: infos.placeholder,
|
||||||
|
value: value,
|
||||||
|
disabled: disabled
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -273,6 +297,8 @@ function createFormGroup(infos){
|
|||||||
input.className = "form-control";
|
input.className = "form-control";
|
||||||
input.type = infos.type;
|
input.type = infos.type;
|
||||||
input.placeholder = infos.placeholder;
|
input.placeholder = infos.placeholder;
|
||||||
|
input.value = value;
|
||||||
|
input.disabled = disabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Return input
|
//Return input
|
||||||
|
@ -18,7 +18,20 @@ ComunicWeb.pages.settings.sections.general = {
|
|||||||
var box = createElem2({
|
var box = createElem2({
|
||||||
appendTo: target,
|
appendTo: target,
|
||||||
type: "div",
|
type: "div",
|
||||||
class: "box box-primary"
|
class: "box box-primary box-general-settings"
|
||||||
|
});
|
||||||
|
|
||||||
|
//Add box header
|
||||||
|
var boxHead = createElem2({
|
||||||
|
appendTo: box,
|
||||||
|
type: "div",
|
||||||
|
class: "box-header",
|
||||||
|
});
|
||||||
|
var boxTitle = createElem2({
|
||||||
|
appendTo: boxHead,
|
||||||
|
type: "h3",
|
||||||
|
class: "box-title",
|
||||||
|
innerHTML: "General settings"
|
||||||
});
|
});
|
||||||
|
|
||||||
//Create box body
|
//Create box body
|
||||||
@ -44,8 +57,39 @@ ComunicWeb.pages.settings.sections.general = {
|
|||||||
boxBody.appendChild(errMsg);
|
boxBody.appendChild(errMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Display the settings form
|
||||||
|
ComunicWeb.pages.settings.sections.general._show_form(infos, boxBody);
|
||||||
});
|
});
|
||||||
}
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the settings form
|
||||||
|
*
|
||||||
|
* @param {object} infos Informations about the user (General settings)
|
||||||
|
* @param {HTMLElement} target The target for the page
|
||||||
|
*/
|
||||||
|
_show_form: function(infos, target){
|
||||||
|
|
||||||
|
//Display user ID
|
||||||
|
createFormGroup({
|
||||||
|
target: target,
|
||||||
|
label: "User ID",
|
||||||
|
type: "text",
|
||||||
|
value: infos.id,
|
||||||
|
disabled: true,
|
||||||
|
additionalGroupClasses: "input-user-id"
|
||||||
|
});
|
||||||
|
|
||||||
|
//Display user name
|
||||||
|
createFormGroup({
|
||||||
|
target: target,
|
||||||
|
label: "Email address",
|
||||||
|
type: "email",
|
||||||
|
value: infos.email,
|
||||||
|
disabled: true,
|
||||||
|
additionalGroupClasses: "input-user-email"
|
||||||
|
});
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
};
|
};
|
@ -164,6 +164,10 @@ class Dev {
|
|||||||
//Post page
|
//Post page
|
||||||
"css/pages/postPage/main.css",
|
"css/pages/postPage/main.css",
|
||||||
|
|
||||||
|
//Settings page
|
||||||
|
//Sections sections
|
||||||
|
"css/pages/settings/sections/general.css",
|
||||||
|
|
||||||
//Latest post page stylesheet
|
//Latest post page stylesheet
|
||||||
"css/pages/latestPosts/main.css",
|
"css/pages/latestPosts/main.css",
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user