Version 23.79.1: Apr 24, 2024 Code refactoring in HTML related to required field in form.

This commit is contained in:
acanas 2024-04-24 14:38:10 +02:00
parent 98a7747d18
commit a58aa9cd19
6 changed files with 29 additions and 17 deletions

View File

@ -1333,7 +1333,7 @@ void HTM_INPUT_IMAGE (const char *URL,const char *Icon,const char *Title,
}
void HTM_INPUT_PASSWORD (const char *Name,const char *PlaceHolder,
const char *AutoComplete,bool Required,
const char *AutoComplete,HTM_Required_t Required,
const char *fmt,...)
{
va_list ap;
@ -1348,7 +1348,7 @@ void HTM_INPUT_PASSWORD (const char *Name,const char *PlaceHolder,
if (AutoComplete)
if (AutoComplete[0])
HTM_TxtF (" autocomplete=\"%s\"",AutoComplete);
if (Required)
if (Required == HTM_REQUIRED)
HTM_Txt (" required=\"required\"");
if (fmt)

View File

@ -52,6 +52,13 @@ typedef enum
HTM_SUBMIT_ON_CLICK,
} HTM_SubmitOnClick_t;
#define HTM_NUM_REQUIRED 2
typedef enum
{
HTM_NOT_REQUIRED,
HTM_REQUIRED,
} HTM_Required_t;
typedef enum
{
HTM_OPTION_UNSELECTED,
@ -175,7 +182,7 @@ void HTM_INPUT_BUTTON (const char *Name,const char *Value,const char *Attr);
void HTM_INPUT_IMAGE (const char *URL,const char *Icon,const char *Title,
const char *fmt,...);
void HTM_INPUT_PASSWORD (const char *Name,const char *PlaceHolder,
const char *AutoComplete,bool Required,
const char *AutoComplete,HTM_Required_t Required,
const char *fmt,...);
void HTM_INPUT_LONG (const char *Name,long Min,long Max,long Value,
HTM_SubmitOnChange_t SubmitOnChange,bool Disabled,

View File

@ -637,6 +637,7 @@ Me sale este error, no s
#define CSS_FILE "swad23.67.2.css"
#define JS_FILE "swad23.79.js"
/*
Version 23.79.1: Apr 24, 2024 Code refactoring in HTML related to required field in form. (335751 lines)
Version 23.79: Apr 24, 2024 Code refactoring writing dates. (335741 lines)
Version 23.78: Apr 23, 2024 Code refactoring in list of actions. (335577 lines)
Version 23.77: Apr 19, 2024 Code refactoring in list of actions. (335567 lines)

View File

@ -620,7 +620,7 @@ void Pwd_ShowFormChgMyPwd (void)
/* Data */
HTM_TD_Begin ("class=\"Frm_C2 LM\"");
HTM_INPUT_PASSWORD ("UsrPwd",NULL,"off",
true, // Required
HTM_REQUIRED,
"id=\"UsrPwd\""
" class=\"Frm_C2_INPUT INPUT_%s\"",
The_GetSuffix ());
@ -670,7 +670,7 @@ void Pwd_PutFormToGetNewPasswordOnce (void)
/* Data */
HTM_TD_Begin ("class=\"Frm_C2 LM\"");
HTM_INPUT_PASSWORD ("Paswd",Txt_HELP_password,NULL,
true, // Required
HTM_REQUIRED,
"id=\"Paswd\" class=\"REC_C2_BOT_INPUT INPUT_%s\"",
The_GetSuffix ());
@ -698,7 +698,7 @@ void Pwd_PutFormToGetNewPasswordTwice (void)
/* Data */
HTM_TD_Begin ("class=\"Frm_C2 LM\"");
HTM_INPUT_PASSWORD ("Paswd1",Txt_HELP_password,NULL,
true, // Required
HTM_REQUIRED,
"id=\"Paswd1\" class=\"Frm_C2_INPUT INPUT_%s\"",
The_GetSuffix ());
HTM_TD_End ();
@ -714,7 +714,7 @@ void Pwd_PutFormToGetNewPasswordTwice (void)
/* Data */
HTM_TD_Begin ("class=\"Frm_C2 LM\"");
HTM_INPUT_PASSWORD ("Paswd2",Txt_HELP_password,NULL,
true, // Required
HTM_REQUIRED,
"id=\"Paswd2\" class=\"Frm_C2_INPUT INPUT_%s\"",
The_GetSuffix ());
HTM_TD_End ();
@ -799,7 +799,7 @@ void Pwd_AskForConfirmationOnDangerousAction (void)
HTM_LABEL_Begin ("class=\"FORM_IN_%s\"",The_GetSuffix ());
HTM_TxtColonNBSP (Txt_For_security_enter_your_password);
HTM_INPUT_PASSWORD ("OthUsrPwd",NULL,"off",
true, // Required
HTM_REQUIRED,
"class=\"INPUT_%s\"",
The_GetSuffix ());
HTM_LABEL_End ();

View File

@ -300,7 +300,7 @@ static void Prj_ReqCreatOrEditPrj (struct Prj_Projects *Projects);
static void Prj_PutFormProject (struct Prj_Projects *Projects,bool ItsANewProject);
static void Prj_EditOneProjectTxtArea (const char *Id,
const char *Label,char *TxtField,
unsigned NumRows,bool Required);
unsigned NumRows,HTM_Required_t Required);
static void Prj_CreateProject (struct Prj_Project *Prj);
static void Prj_UpdateProject (struct Prj_Project *Prj);
@ -3901,17 +3901,17 @@ static void Prj_PutFormProject (struct Prj_Projects *Projects,
/* Description of the project */
Prj_EditOneProjectTxtArea ("Description",Txt_Description,
Projects->Prj.Description,12,
true); // Required
HTM_REQUIRED);
/* Required knowledge to carry out the project */
Prj_EditOneProjectTxtArea ("Knowledge",Txt_Required_knowledge,
Projects->Prj.Knowledge,4,
false); // Not required
HTM_NOT_REQUIRED);
/* Required materials to carry out the project */
Prj_EditOneProjectTxtArea ("Materials",Txt_Required_materials,
Projects->Prj.Materials,4,
false); // Not required
HTM_NOT_REQUIRED);
/* URL for additional info */
HTM_TR_Begin (NULL);
@ -3952,8 +3952,14 @@ static void Prj_PutFormProject (struct Prj_Projects *Projects,
static void Prj_EditOneProjectTxtArea (const char *Id,
const char *Label,char *TxtField,
unsigned NumRows,bool Required)
unsigned NumRows,HTM_Required_t Required)
{
static const char *RequiredTxt[HTM_NUM_REQUIRED] =
{
[HTM_NOT_REQUIRED] = "",
[HTM_REQUIRED ] = " required=\"required\"",
};
/***** Description *****/
HTM_TR_Begin (NULL);
@ -3965,9 +3971,7 @@ static void Prj_EditOneProjectTxtArea (const char *Id,
HTM_TEXTAREA_Begin ("id=\"%s\" name=\"%s\" rows=\"%u\""
" class=\"Frm_C2_INPUT INPUT_%s\"%s",
Id,Id,NumRows,
The_GetSuffix (),
Required ? " required=\"required\"" :
"");
The_GetSuffix (),RequiredTxt[Required]);
HTM_Txt (TxtField);
HTM_TEXTAREA_End ();
HTM_TD_End ();

View File

@ -1180,7 +1180,7 @@ void Usr_WriteFormLogin (Act_Action_t NextAction,void (*FuncPars) (void))
Txt_Password,"CONTEXT_ICO16x16");
HTM_LABEL_End ();
HTM_INPUT_PASSWORD ("UsrPwd",Txt_password,NULL,
false, // Not required
HTM_NOT_REQUIRED,
"id=\"UsrPwd\" class=\"INPUT_%s\"",
The_GetSuffix ());
HTM_DIV_End ();