Version 22.41: Oct 06, 2022 Changes in the behavior of the expansion/contraction of program items.

This commit is contained in:
acanas 2022-10-06 18:24:29 +02:00
parent 8c29494413
commit a8211a1eb4
2 changed files with 62 additions and 65 deletions

View File

@ -606,10 +606,11 @@ TODO: Fix bug: error al enviar un mensaje a dos recipientes, error on duplicate
TODO: Attach pdf files in multimedia. TODO: Attach pdf files in multimedia.
*/ */
#define Log_PLATFORM_VERSION "SWAD 22.40 (2022-10-04)" #define Log_PLATFORM_VERSION "SWAD 22.41 (2022-10-06)"
#define CSS_FILE "swad22.40.css" #define CSS_FILE "swad22.40.css"
#define JS_FILE "swad21.100.js" #define JS_FILE "swad21.100.js"
/* /*
Version 22.41: Oct 06, 2022 Changes in the behavior of the expansion/contraction of program items. (332511 lines)
Version 22.40: Oct 04, 2022 Link in main title. (332514 lines) Version 22.40: Oct 04, 2022 Link in main title. (332514 lines)
Version 22.39.5: Oct 03, 2022 Fixed bug in edition of course program. (332513 lines) Version 22.39.5: Oct 03, 2022 Fixed bug in edition of course program. (332513 lines)
Version 22.39.4: Oct 03, 2022 Fixed layout issues in projects. (332515 lines) Version 22.39.4: Oct 03, 2022 Fixed layout issues in projects. (332515 lines)

View File

@ -118,7 +118,6 @@ static void Prg_PutButtonToCreateNewItem (void);
static void Prg_WriteRowItem (Prg_ListingType_t ListingType, static void Prg_WriteRowItem (Prg_ListingType_t ListingType,
unsigned NumItem,struct Prg_Item *Item, unsigned NumItem,struct Prg_Item *Item,
bool HasChildren,
bool Expanded, bool Expanded,
long SelectedItmCod, long SelectedItmCod,
long SelectedRscCod); long SelectedRscCod);
@ -227,7 +226,6 @@ void Prg_ShowAllItems (Prg_ListingType_t ListingType,
unsigned FormLevel = 0; // Initialized to avoid warning unsigned FormLevel = 0; // Initialized to avoid warning
struct Prg_Item Item; struct Prg_Item Item;
struct Prg_ItemRange ToHighlight; struct Prg_ItemRange ToHighlight;
bool HasChildren;
bool Expanded; bool Expanded;
char *Title; char *Title;
static bool FirstTBodyOpen = false; static bool FirstTBodyOpen = false;
@ -307,14 +305,6 @@ void Prg_ShowAllItems (Prg_ListingType_t ListingType,
/* Get data of this program item */ /* Get data of this program item */
Item.Hierarchy.ItmCod = Prg_GetItmCodFromNumItem (NumItem); Item.Hierarchy.ItmCod = Prg_GetItmCodFromNumItem (NumItem);
Prg_GetDataOfItemByCod (&Item); Prg_GetDataOfItemByCod (&Item);
if (NumItem == Prg_Gbl.List.NumItems - 1)
// The last item
HasChildren = false; // Last item has no children
else
// Not the last item
// This item has children if its level is lower than the level of the following item
HasChildren = (Prg_GetLevelFromNumItem (NumItem) <
Prg_GetLevelFromNumItem (NumItem + 1));
/* Begin range to highlight? */ /* Begin range to highlight? */
if (Item.Hierarchy.ItmInd == ToHighlight.Begin) // Begin of the highlighted range if (Item.Hierarchy.ItmInd == ToHighlight.Begin) // Begin of the highlighted range
@ -336,7 +326,7 @@ void Prg_ShowAllItems (Prg_ListingType_t ListingType,
if (Prg_CheckIfAllHigherLevelsAreExpanded (Item.Hierarchy.Level)) if (Prg_CheckIfAllHigherLevelsAreExpanded (Item.Hierarchy.Level))
{ {
/* Write row with this item */ /* Write row with this item */
Prg_WriteRowItem (ListingType,NumItem,&Item,HasChildren,Expanded, Prg_WriteRowItem (ListingType,NumItem,&Item,Expanded,
SelectedItmCod,SelectedRscCod); SelectedItmCod,SelectedRscCod);
The_ChangeRowColor (); The_ChangeRowColor ();
@ -479,13 +469,12 @@ static void Prg_PutButtonToCreateNewItem (void)
static void Prg_WriteRowItem (Prg_ListingType_t ListingType, static void Prg_WriteRowItem (Prg_ListingType_t ListingType,
unsigned NumItem,struct Prg_Item *Item, unsigned NumItem,struct Prg_Item *Item,
bool HasChildren,
bool Expanded, bool Expanded,
long SelectedItmCod, long SelectedItmCod,
long SelectedRscCod) long SelectedRscCod)
{ {
static unsigned UniqueId = 0; static unsigned UniqueId = 0;
static bool Editing[Prg_NUM_LISTING_TYPES] = static bool EditingProgram[Prg_NUM_LISTING_TYPES] =
{ {
[Prg_PRINT ] = false, [Prg_PRINT ] = false,
[Prg_VIEW ] = false, [Prg_VIEW ] = false,
@ -500,6 +489,11 @@ static void Prg_WriteRowItem (Prg_ListingType_t ListingType,
[Prg_CHANGE_RESOURCE_LINK] = true, [Prg_CHANGE_RESOURCE_LINK] = true,
[Prg_END_EDIT_RES ] = true, [Prg_END_EDIT_RES ] = true,
}; };
static const char *RowSpan[2] =
{
[false] = "", // Not expanded
[true ] = " rowspan=\"2\"", // Expanded
};
bool IsHidden; bool IsHidden;
char *Id; char *Id;
unsigned ColSpan; unsigned ColSpan;
@ -515,11 +509,8 @@ static void Prg_WriteRowItem (Prg_ListingType_t ListingType,
else // this item is not marked as hidden else // this item is not marked as hidden
IsHidden = Prg_CheckIfAnyHigherLevelIsHidden (Item->Hierarchy.Level); IsHidden = Prg_CheckIfAnyHigherLevelIsHidden (Item->Hierarchy.Level);
if (Editing[ListingType] || !IsHidden) if (EditingProgram[ListingType] || !IsHidden)
{ {
/***** Title CSS class *****/
Prg_SetTitleClass (&TitleClass,Item->Hierarchy.Level);
/***** Increase number in level *****/ /***** Increase number in level *****/
Prg_IncreaseNumberInLevel (Item->Hierarchy.Level); Prg_IncreaseNumberInLevel (Item->Hierarchy.Level);
@ -528,36 +519,40 @@ static void Prg_WriteRowItem (Prg_ListingType_t ListingType,
(ListingType == Prg_FORM_EDIT_ITEM || (ListingType == Prg_FORM_EDIT_ITEM ||
ListingType == Prg_END_EDIT_ITEM); ListingType == Prg_END_EDIT_ITEM);
/***** Begin row *****/ /***** First row (title and dates) *****/
HTM_TR_Begin (NULL); HTM_TR_Begin (NULL);
/***** Indent depending on the level *****/ /* Title CSS class */
Prg_SetTitleClass (&TitleClass,Item->Hierarchy.Level);
/* Indent depending on the level */
for (NumCol = 1; for (NumCol = 1;
NumCol < Item->Hierarchy.Level; NumCol < Item->Hierarchy.Level;
NumCol++) NumCol++)
{ {
HTM_TD_Begin ("rowspan=\"2\" class=\"%s\"",The_GetColorRows ()); HTM_TD_Begin ("class=\"%s\"%s",
The_GetColorRows (),RowSpan[Expanded]);
HTM_TD_End (); HTM_TD_End ();
} }
/***** Expand/contract this program item *****/ /* Expand/contract this program item */
HTM_TD_Begin ("rowspan=\"2\" class=\"LT %s\"",The_GetColorRows ()); HTM_TD_Begin ("class=\"LT %s\"%s",
/* Only if this item has children ==> show icon to contract/expand */ The_GetColorRows (),RowSpan[Expanded]);
if (HasChildren) Prg_PutIconToContractExpandItem (Item,Expanded,EditingProgram[ListingType]);
Prg_PutIconToContractExpandItem (Item,Expanded,Editing[ListingType]);
HTM_TD_End (); HTM_TD_End ();
/***** Forms to remove/edit this program item *****/ /* Forms to remove/edit this program item */
if (Editing[ListingType]) if (EditingProgram[ListingType])
{ {
HTM_TD_Begin ("rowspan=\"2\" class=\"PRG_COL1 LT %s\"", HTM_TD_Begin ("class=\"PRG_COL1 LT %s\"%s",
The_GetColorRows ()); The_GetColorRows (),RowSpan[Expanded]);
Prg_PutFormsToRemEditOneItem (ListingType,NumItem,Item,HighlightItem); Prg_PutFormsToRemEditOneItem (ListingType,NumItem,Item,HighlightItem);
HTM_TD_End (); HTM_TD_End ();
} }
/***** Item number *****/ /* Item number */
HTM_TD_Begin ("rowspan=\"2\" class=\"PRG_NUM %s\"",The_GetColorRows ()); HTM_TD_Begin ("class=\"PRG_NUM %s\"%s",
The_GetColorRows (),RowSpan[Expanded]);
HTM_DIV_Begin ("class=\"RT %s%s\"", HTM_DIV_Begin ("class=\"RT %s%s\"",
TitleClass, TitleClass,
IsHidden ? " PRG_HIDDEN" : IsHidden ? " PRG_HIDDEN" :
@ -566,7 +561,7 @@ static void Prg_WriteRowItem (Prg_ListingType_t ListingType,
HTM_DIV_End (); HTM_DIV_End ();
HTM_TD_End (); HTM_TD_End ();
/***** Title *****/ /* Title */
ColSpan = (Prg_GetMaxItemLevel () + 2) - Item->Hierarchy.Level; ColSpan = (Prg_GetMaxItemLevel () + 2) - Item->Hierarchy.Level;
switch (ListingType) switch (ListingType)
{ {
@ -592,7 +587,7 @@ static void Prg_WriteRowItem (Prg_ListingType_t ListingType,
HTM_ARTICLE_End (); HTM_ARTICLE_End ();
HTM_TD_End (); HTM_TD_End ();
/***** Start/end date/time *****/ /* Start/end date/time */
switch (ListingType) switch (ListingType)
{ {
case Prg_PRINT: case Prg_PRINT:
@ -624,44 +619,45 @@ static void Prg_WriteRowItem (Prg_ListingType_t ListingType,
} }
HTM_TD_End (); HTM_TD_End ();
/***** End row *****/ /* Free title CSS class */
Prg_FreeTitleClass (TitleClass);
HTM_TR_End (); HTM_TR_End ();
/***** Begin row *****/ /***** Second row (text and resources) *****/
HTM_TR_Begin (NULL); if (Expanded)
{
HTM_TR_Begin (NULL);
/* Begin text and resources */ /* Begin text and resources */
ColSpan++; ColSpan++;
switch (ListingType) switch (ListingType)
{ {
case Prg_PRINT: case Prg_PRINT:
HTM_TD_Begin ("colspan=\"%u\" class=\"PRG_MAIN\"",ColSpan); HTM_TD_Begin ("colspan=\"%u\" class=\"PRG_MAIN\"",ColSpan);
break; break;
default: default:
HTM_TD_Begin ("colspan=\"%u\" class=\"PRG_MAIN %s\"", HTM_TD_Begin ("colspan=\"%u\" class=\"PRG_MAIN %s\"",
ColSpan,The_GetColorRows ()); ColSpan,The_GetColorRows ());
break; break;
} }
/* Item text / form */ /* Item text / form */
if (ListingType == Prg_FORM_EDIT_ITEM && HighlightItem) if (ListingType == Prg_FORM_EDIT_ITEM && HighlightItem)
/* Form to change item title, dates and text */ /* Form to change item title, dates and text */
Prg_ShowFormToChangeItem (Item->Hierarchy.ItmCod); Prg_ShowFormToChangeItem (Item->Hierarchy.ItmCod);
else else
/* Text */ /* Text */
Prg_WriteItemText (Item->Hierarchy.ItmCod,IsHidden); Prg_WriteItemText (Item->Hierarchy.ItmCod,IsHidden);
/* List of resources */ /* List of resources */
PrgRsc_ListItemResources (ListingType,Item,SelectedItmCod,SelectedRscCod); PrgRsc_ListItemResources (ListingType,Item,SelectedItmCod,SelectedRscCod);
/* End text and resources */ /* End text and resources */
HTM_TD_End (); HTM_TD_End ();
/***** End row *****/ HTM_TR_End ();
HTM_TR_End (); }
/***** Free title CSS class *****/
Prg_FreeTitleClass (TitleClass);
} }
} }