Version 22.120.16:Sep 10, 2023 Code refactoring in project visibility.

This commit is contained in:
acanas 2023-09-10 16:55:23 +02:00
parent d9d7428c86
commit 8165d5ca08
5 changed files with 58 additions and 63 deletions

View File

@ -629,10 +629,11 @@ TODO: Emilce Barrera Mesa: Podr
TODO: Emilce Barrera Mesa: Mis estudiantes presentan muchas dificultades a la hora de poner la foto porque la plataforma es muy exigente respecto al fondo de la imagen. TODO: Emilce Barrera Mesa: Mis estudiantes presentan muchas dificultades a la hora de poner la foto porque la plataforma es muy exigente respecto al fondo de la imagen.
*/ */
#define Log_PLATFORM_VERSION "SWAD 22.120.15 (2023-09-10)" #define Log_PLATFORM_VERSION "SWAD 22.120.16 (2023-09-10)"
#define CSS_FILE "swad22.120.4.css" #define CSS_FILE "swad22.120.4.css"
#define JS_FILE "swad22.49.js" #define JS_FILE "swad22.49.js"
/* /*
Version 22.120.16:Sep 10, 2023 Code refactoring in project visibility. (337575 lines)
Version 22.120.15:Sep 10, 2023 Code refactoring related to hidden-visible in projects. (337580 lines) Version 22.120.15:Sep 10, 2023 Code refactoring related to hidden-visible in projects. (337580 lines)
Version 22.120.14:Sep 10, 2023 Code refactoring related to hidden-visible in program resources. (337590 lines) Version 22.120.14:Sep 10, 2023 Code refactoring related to hidden-visible in program resources. (337590 lines)
Version 22.120.13:Sep 10, 2023 Code refactoring related to hidden-visible in program items. (337587 lines) Version 22.120.13:Sep 10, 2023 Code refactoring related to hidden-visible in program items. (337587 lines)

View File

@ -198,7 +198,7 @@ static void Prj_PutParFaulti (unsigned Faulti);
static void Prj_PutParReview (unsigned Review); static void Prj_PutParReview (unsigned Review);
static void Prj_PutParFilterDptCod (long DptCod); static void Prj_PutParFilterDptCod (long DptCod);
static void Prj_GetParPreNon (struct Prj_Projects *Projects); static void Prj_GetParPreNon (struct Prj_Projects *Projects);
static Prj_HiddenVisibl_t Prj_GetParHidVis (void); static unsigned Prj_GetParHidVis (void);
static unsigned Prj_GetParFaulti (void); static unsigned Prj_GetParFaulti (void);
static unsigned Prj_GetParReview (void); static unsigned Prj_GetParReview (void);
static long Prj_GetParFilterDptCod (void); static long Prj_GetParFilterDptCod (void);
@ -700,22 +700,22 @@ static void Prj_ShowFormToFilterByAssign (const struct Prj_Projects *Projects)
static void Prj_ShowFormToFilterByHidden (const struct Prj_Projects *Projects) static void Prj_ShowFormToFilterByHidden (const struct Prj_Projects *Projects)
{ {
extern const char *Txt_PROJECT_HIDDEN_VISIBL_PROJECTS[Prj_NUM_HIDDEN_VISIBL]; extern const char *Txt_PROJECT_HIDDEN_VISIBL_PROJECTS[HidVis_NUM_HIDDEN_VISIBLE];
struct Prj_Filter Filter; struct Prj_Filter Filter;
Prj_HiddenVisibl_t HidVis; HidVis_HiddenOrVisible_t HidVis;
static const struct static const struct
{ {
const char *Icon; const char *Icon;
Ico_Color_t Color; Ico_Color_t Color;
} HiddenVisiblIcon[Prj_NUM_HIDDEN_VISIBL] = } HiddenVisiblIcon[HidVis_NUM_HIDDEN_VISIBLE] =
{ {
[Prj_HIDDEN] = {"eye-slash.svg",Ico_RED }, [HidVis_HIDDEN ] = {"eye-slash.svg",Ico_RED },
[Prj_VISIBL] = {"eye.svg" ,Ico_GREEN}, [HidVis_VISIBLE] = {"eye.svg" ,Ico_GREEN},
}; };
Set_BeginOneSettingSelector (); Set_BeginOneSettingSelector ();
for (HidVis = (Prj_HiddenVisibl_t) 0; for (HidVis = (HidVis_HiddenOrVisible_t) 0;
HidVis <= (Prj_HiddenVisibl_t) (Prj_NUM_HIDDEN_VISIBL - 1); HidVis <= (HidVis_HiddenOrVisible_t) (HidVis_NUM_HIDDEN_VISIBLE - 1);
HidVis++) HidVis++)
{ {
Set_BeginPref ((Projects->Filter.Hidden & (1 << HidVis))); Set_BeginPref ((Projects->Filter.Hidden & (1 << HidVis)));
@ -1031,20 +1031,20 @@ static void Prj_GetParPreNon (struct Prj_Projects *Projects)
(unsigned) Prj_FILTER_NONASSIG_DEFAULT); (unsigned) Prj_FILTER_NONASSIG_DEFAULT);
} }
static Prj_HiddenVisibl_t Prj_GetParHidVis (void) static unsigned Prj_GetParHidVis (void)
{ {
switch (Gbl.Usrs.Me.Role.Logged) switch (Gbl.Usrs.Me.Role.Logged)
{ {
case Rol_STD: // Students can view only visible projects case Rol_STD: // Students can view only visible projects
return (Prj_HiddenVisibl_t) (1 << Prj_VISIBL); // Only visible projects return (unsigned) (1 << HidVis_VISIBLE); // Only visible projects
case Rol_NET: case Rol_NET:
case Rol_TCH: case Rol_TCH:
case Rol_SYS_ADM: case Rol_SYS_ADM:
return (Prj_HiddenVisibl_t) return (unsigned)
Par_GetParUnsignedLong (Prj_PARAM_FILTER_HID_VIS_NAME, Par_GetParUnsignedLong (Prj_PARAM_FILTER_HID_VIS_NAME,
0, 0,
(1 << Prj_HIDDEN) | (1 << HidVis_HIDDEN) |
(1 << Prj_VISIBL), (1 << HidVis_VISIBLE),
(unsigned) Prj_FILTER_HIDDEN_DEFAULT | (unsigned) Prj_FILTER_HIDDEN_DEFAULT |
(unsigned) Prj_FILTER_VISIBL_DEFAULT); (unsigned) Prj_FILTER_VISIBL_DEFAULT);
default: default:
@ -1445,10 +1445,10 @@ static void Prj_ShowProjectRow (struct Prj_Projects *Projects)
struct Prj_Faults Faults; struct Prj_Faults Faults;
static unsigned UniqueId = 0; static unsigned UniqueId = 0;
char *Anchor = NULL; char *Anchor = NULL;
const char *ClassLabel = (Projects->Prj.Hidden == Prj_HIDDEN) ? "ASG_LABEL_LIGHT" : const char *ClassLabel = (Projects->Prj.Hidden == HidVis_HIDDEN) ? "ASG_LABEL_LIGHT" :
"ASG_LABEL"; "ASG_LABEL";
const char *ClassData = (Projects->Prj.Hidden == Prj_HIDDEN) ? "DAT_LIGHT" : const char *ClassData = (Projects->Prj.Hidden == HidVis_HIDDEN) ? "DAT_LIGHT" :
"DAT"; "DAT";
/***** Set anchor string *****/ /***** Set anchor string *****/
Frm_SetAnchorStr ((long) Projects->NumIndex,&Anchor); Frm_SetAnchorStr ((long) Projects->NumIndex,&Anchor);
@ -1503,8 +1503,8 @@ static void Prj_ShowFirstRow (struct Prj_Projects *Projects,
extern const char *Txt_Actions[ActLst_NUM_ACTIONS]; extern const char *Txt_Actions[ActLst_NUM_ACTIONS];
char *Id; char *Id;
Act_Action_t NextAction; Act_Action_t NextAction;
const char *ClassDate = (Projects->Prj.Hidden == Prj_HIDDEN) ? "DATE_BLUE_LIGHT" : const char *ClassDate = (Projects->Prj.Hidden == HidVis_HIDDEN) ? "DATE_BLUE_LIGHT" :
"DATE_BLUE"; "DATE_BLUE";
/***** Write first row of data of this project *****/ /***** Write first row of data of this project *****/
HTM_TR_Begin (NULL); HTM_TR_Begin (NULL);
@ -1607,8 +1607,8 @@ static void Prj_ShowFirstRow (struct Prj_Projects *Projects,
Prj_PutCurrentPars (Projects); Prj_PutCurrentPars (Projects);
HTM_BUTTON_Submit_Begin (Txt_Actions[NextAction], HTM_BUTTON_Submit_Begin (Txt_Actions[NextAction],
"class=\"LT BT_LINK %s_%s\"", "class=\"LT BT_LINK %s_%s\"",
Projects->Prj.Hidden == Prj_HIDDEN ? "ASG_TITLE_LIGHT" : Projects->Prj.Hidden == HidVis_HIDDEN ? "ASG_TITLE_LIGHT" :
"ASG_TITLE", "ASG_TITLE",
The_GetSuffix ()); The_GetSuffix ());
HTM_Txt (Projects->Prj.Title); HTM_Txt (Projects->Prj.Title);
HTM_BUTTON_End (); HTM_BUTTON_End ();
@ -2008,10 +2008,10 @@ static void Prj_ShowProjectMembersWithARole (struct Prj_Projects *Projects,
bool WriteRow; bool WriteRow;
unsigned NumUsr; unsigned NumUsr;
unsigned NumUsrs; unsigned NumUsrs;
const char *ClassLabel = (Projects->Prj.Hidden == Prj_HIDDEN) ? "ASG_LABEL_LIGHT" : const char *ClassLabel = (Projects->Prj.Hidden == HidVis_HIDDEN) ? "ASG_LABEL_LIGHT" :
"ASG_LABEL"; "ASG_LABEL";
const char *ClassData = (Projects->Prj.Hidden == Prj_HIDDEN) ? "DAT_LIGHT" : const char *ClassData = (Projects->Prj.Hidden == HidVis_HIDDEN) ? "DAT_LIGHT" :
"DAT"; "DAT";
/***** Get users in project from database *****/ /***** Get users in project from database *****/
NumUsrs = Prj_DB_GetUsrsInPrj (&mysql_res,Projects->Prj.PrjCod,RoleInPrj); NumUsrs = Prj_DB_GetUsrsInPrj (&mysql_res,Projects->Prj.PrjCod,RoleInPrj);
@ -2104,8 +2104,8 @@ static void Prj_ShowProjectMembersWithARole (struct Prj_Projects *Projects,
/* Write user's name */ /* Write user's name */
HTM_TD_Begin ("class=\"LM %s_%s\"", HTM_TD_Begin ("class=\"LM %s_%s\"",
Projects->Prj.Hidden == Prj_HIDDEN ? "MSG_AUT_LIGHT" : Projects->Prj.Hidden == HidVis_HIDDEN ? "MSG_AUT_LIGHT" :
"MSG_AUT", "MSG_AUT",
The_GetSuffix ()); The_GetSuffix ());
HTM_Txt (Gbl.Usrs.Other.UsrDat.FullName); HTM_Txt (Gbl.Usrs.Other.UsrDat.FullName);
HTM_TD_End (); HTM_TD_End ();
@ -2510,10 +2510,10 @@ static void Prj_ShowTableAllProjectsOneRow (struct Prj_Project *Prj)
Prj_GetProjectDataByCod (Prj); Prj_GetProjectDataByCod (Prj);
/***** Set CSS classes *****/ /***** Set CSS classes *****/
ClassDate = (Prj->Hidden == Prj_HIDDEN) ? "DATE_BLUE_LIGHT" : ClassDate = (Prj->Hidden == HidVis_HIDDEN) ? "DATE_BLUE_LIGHT" :
"DATE_BLUE"; "DATE_BLUE";
ClassData = (Prj->Hidden == Prj_HIDDEN) ? "DAT_LIGHT" : ClassData = (Prj->Hidden == HidVis_HIDDEN) ? "DAT_LIGHT" :
"DAT"; "DAT";
/***** Begin row *****/ /***** Begin row *****/
HTM_TR_Begin (NULL); HTM_TR_Begin (NULL);
@ -2603,8 +2603,8 @@ static void Prj_ShowTableAllProjectsDepartment (const struct Prj_Project *Prj)
const char *ClassData; const char *ClassData;
/***** Set CSS classes *****/ /***** Set CSS classes *****/
ClassData = (Prj->Hidden == Prj_HIDDEN) ? "DAT_LIGHT" : ClassData = (Prj->Hidden == HidVis_HIDDEN) ? "DAT_LIGHT" :
"DAT"; "DAT";
/***** Get data of department *****/ /***** Get data of department *****/
Dpt.DptCod = Prj->DptCod; Dpt.DptCod = Prj->DptCod;
@ -2627,8 +2627,8 @@ static void Prj_ShowTableAllProjectsTxtField (struct Prj_Project *Prj,
const char *ClassData; const char *ClassData;
/***** Set CSS classes *****/ /***** Set CSS classes *****/
ClassData = (Prj->Hidden == Prj_HIDDEN) ? "DAT_LIGHT" : ClassData = (Prj->Hidden == HidVis_HIDDEN) ? "DAT_LIGHT" :
"DAT"; "DAT";
/***** Change format *****/ /***** Change format *****/
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
@ -2650,8 +2650,8 @@ static void Prj_ShowTableAllProjectsURL (const struct Prj_Project *Prj)
const char *ClassData; const char *ClassData;
/***** Set CSS classes *****/ /***** Set CSS classes *****/
ClassData = (Prj->Hidden == Prj_HIDDEN) ? "DAT_LIGHT" : ClassData = (Prj->Hidden == HidVis_HIDDEN) ? "DAT_LIGHT" :
"DAT"; "DAT";
/***** Show URL *****/ /***** Show URL *****/
HTM_TD_Begin ("class=\"LT %s_%s %s\"", HTM_TD_Begin ("class=\"LT %s_%s %s\"",
@ -2674,8 +2674,8 @@ static void Prj_ShowTableAllProjectsMembersWithARole (const struct Prj_Project *
const char *ClassData; const char *ClassData;
/***** Set CSS classes *****/ /***** Set CSS classes *****/
ClassData = (Prj->Hidden == Prj_HIDDEN) ? "DAT_LIGHT" : ClassData = (Prj->Hidden == HidVis_HIDDEN) ? "DAT_LIGHT" :
"DAT"; "DAT";
/***** Get users in project from database *****/ /***** Get users in project from database *****/
NumUsrs = Prj_DB_GetUsrsInPrj (&mysql_res,Prj->PrjCod,RoleInPrj); NumUsrs = Prj_DB_GetUsrsInPrj (&mysql_res,Prj->PrjCod,RoleInPrj);
@ -3173,8 +3173,8 @@ static void Prj_PutIconsToRemEditOnePrj (struct Prj_Projects *Projects,
/***** Icon to hide/unhide project *****/ /***** Icon to hide/unhide project *****/
Ico_PutContextualIconToHideUnhide (ActionHideUnhide,Anchor, Ico_PutContextualIconToHideUnhide (ActionHideUnhide,Anchor,
Prj_PutCurrentPars,Projects, Prj_PutCurrentPars,Projects,
Projects->Prj.Hidden == Prj_HIDDEN ? HidVis_HIDDEN : Projects->Prj.Hidden == HidVis_HIDDEN ? HidVis_HIDDEN :
HidVis_VISIBLE); HidVis_VISIBLE);
/***** Icon to edit project *****/ /***** Icon to edit project *****/
Ico_PutContextualIconToEdit (ActEdiOnePrj,NULL, Ico_PutContextualIconToEdit (ActEdiOnePrj,NULL,
@ -3367,8 +3367,8 @@ void Prj_GetProjectDataByCod (struct Prj_Project *Prj)
and whether the project is assigned or not (row[5]) */ and whether the project is assigned or not (row[5]) */
Prj->Locked = (row[3][0] == 'Y') ? Prj_LOCKED : Prj->Locked = (row[3][0] == 'Y') ? Prj_LOCKED :
Prj_UNLOCKED; Prj_UNLOCKED;
Prj->Hidden = (row[4][0] == 'Y') ? Prj_HIDDEN : Prj->Hidden = (row[4][0] == 'Y') ? HidVis_HIDDEN :
Prj_VISIBL; HidVis_VISIBLE;
Prj->Assigned = (row[5][0] == 'Y') ? Prj_ASSIGNED : Prj->Assigned = (row[5][0] == 'Y') ? Prj_ASSIGNED :
Prj_NONASSIG; Prj_NONASSIG;

View File

@ -64,15 +64,9 @@ typedef enum
} Prj_Locked_t; } Prj_Locked_t;
/* Hidden/visible project */ /* Hidden/visible project */
#define Prj_NUM_HIDDEN_VISIBL 2 #define Prj_NEW_PRJ_HIDDEN_VISIBL_DEFAULT HidVis_VISIBLE
typedef enum #define Prj_FILTER_HIDDEN_DEFAULT (1 << HidVis_HIDDEN) // on
{ #define Prj_FILTER_VISIBL_DEFAULT (1 << HidVis_VISIBLE) // on
Prj_HIDDEN = 0,
Prj_VISIBL = 1,
} Prj_HiddenVisibl_t;
#define Prj_NEW_PRJ_HIDDEN_VISIBL_DEFAULT Prj_VISIBL
#define Prj_FILTER_HIDDEN_DEFAULT (1 << Prj_HIDDEN) // on
#define Prj_FILTER_VISIBL_DEFAULT (1 << Prj_VISIBL) // on
/* Faulty/faultless project */ /* Faulty/faultless project */
#define Prj_NUM_FAULTINESS 2 #define Prj_NUM_FAULTINESS 2
@ -162,7 +156,7 @@ struct Prj_Project
long PrjCod; long PrjCod;
long CrsCod; long CrsCod;
Prj_Locked_t Locked; Prj_Locked_t Locked;
Prj_HiddenVisibl_t Hidden; HidVis_HiddenOrVisible_t Hidden;
Prj_AssignedNonassig_t Assigned; Prj_AssignedNonassig_t Assigned;
unsigned NumStds; unsigned NumStds;
Prj_Proposal_t Proposal; Prj_Proposal_t Proposal;

View File

@ -118,8 +118,8 @@ long Prj_DB_CreateProject (const struct Prj_Project *Prj)
"'%s',FROM_UNIXTIME(%ld),'%s')", "'%s',FROM_UNIXTIME(%ld),'%s')",
Gbl.Hierarchy.Crs.CrsCod, Gbl.Hierarchy.Crs.CrsCod,
Prj->DptCod, Prj->DptCod,
Prj->Hidden == Prj_HIDDEN ? 'Y' : Prj->Hidden == HidVis_HIDDEN ? 'Y' :
'N', 'N',
Prj->Assigned == Prj_ASSIGNED ? 'Y' : Prj->Assigned == Prj_ASSIGNED ? 'Y' :
'N', 'N',
Prj->NumStds, Prj->NumStds,
@ -158,8 +158,8 @@ void Prj_DB_UpdateProject (const struct Prj_Project *Prj)
" WHERE PrjCod=%ld" " WHERE PrjCod=%ld"
" AND CrsCod=%ld", // Extra check " AND CrsCod=%ld", // Extra check
Prj->DptCod, Prj->DptCod,
Prj->Hidden == Prj_HIDDEN ? 'Y' : Prj->Hidden == HidVis_HIDDEN ? 'Y' :
'N', 'N',
Prj->Assigned == Prj_ASSIGNED ? 'Y' : Prj->Assigned == Prj_ASSIGNED ? 'Y' :
'N', 'N',
Prj->NumStds, Prj->NumStds,
@ -286,11 +286,11 @@ unsigned Prj_DB_GetListProjects (MYSQL_RES **mysql_res,
case Rol_SYS_ADM: case Rol_SYS_ADM:
switch (Projects->Filter.Hidden) switch (Projects->Filter.Hidden)
{ {
case (1 << Prj_HIDDEN): // Hidden projects case (1 << HidVis_HIDDEN): // Hidden projects
if (asprintf (&HidVisSubQuery," AND prj_projects.Hidden='Y'") < 0) if (asprintf (&HidVisSubQuery," AND prj_projects.Hidden='Y'") < 0)
Err_NotEnoughMemoryExit (); Err_NotEnoughMemoryExit ();
break; break;
case (1 << Prj_VISIBL): // Visible projects case (1 << HidVis_VISIBLE): // Visible projects
if (asprintf (&HidVisSubQuery," AND prj_projects.Hidden='N'") < 0) if (asprintf (&HidVisSubQuery," AND prj_projects.Hidden='N'") < 0)
Err_NotEnoughMemoryExit (); Err_NotEnoughMemoryExit ();
break; break;

View File

@ -32006,9 +32006,9 @@ const char *Txt_PROJECT_ASSIGNED_NONASSIGNED_SINGUL[Prj_NUM_ASSIGNED_NONASSIG] =
#endif #endif
}; };
const char *Txt_PROJECT_HIDDEN_VISIBL_PROJECTS[Prj_NUM_HIDDEN_VISIBL] = const char *Txt_PROJECT_HIDDEN_VISIBL_PROJECTS[HidVis_NUM_HIDDEN_VISIBLE] =
{ {
[Prj_HIDDEN] = [HidVis_HIDDEN] =
#if L==1 // ca #if L==1 // ca
"Projectes ocults" "Projectes ocults"
#elif L==2 // de #elif L==2 // de
@ -32031,7 +32031,7 @@ const char *Txt_PROJECT_HIDDEN_VISIBL_PROJECTS[Prj_NUM_HIDDEN_VISIBL] =
"Hidden projects" // Çeviri lazim! "Hidden projects" // Çeviri lazim!
#endif #endif
, ,
[Prj_VISIBL] = [HidVis_VISIBLE] =
#if L==1 // ca #if L==1 // ca
"Projectes visibles" "Projectes visibles"
#elif L==2 // de #elif L==2 // de