Version 20.40.1: Mar 03, 2021 Code refactoring in fav/share timeline.

This commit is contained in:
acanas 2021-03-03 09:40:01 +01:00
parent e3865dc32c
commit c4adac88ed
5 changed files with 47 additions and 51 deletions

View File

@ -598,10 +598,11 @@ TODO: DNI de un estudiante sale err
TODO: BUG: Cuando un tipo de grupo sólo tiene un grupo, inscribirse es voluntario, el estudiante sólo puede pertenecer a un grupo, y se inscribe en él, debería poder desapuntarse. Ahora no puede.
TODO: Salvador Romero Cortés: @acanas opción para editar posts
*/
#define Log_PLATFORM_VERSION "SWAD 20.40 (2021-03-03)"
#define Log_PLATFORM_VERSION "SWAD 20.40.1 (2021-03-03)"
#define CSS_FILE "swad20.33.9.css"
#define JS_FILE "swad20.6.2.js"
/*
Version 20.40.1: Mar 03, 2021 Code refactoring in fav/share timeline. (305532 lines)
Version 20.40: Mar 03, 2021 Code refactoring in fav/share timeline. (305532 lines)
Version 20.39.11: Mar 02, 2021 Code refactoring in fav/share timeline. (305525 lines)
Version 20.39.10: Mar 02, 2021 Code refactoring in timeline. (305576 lines)

View File

@ -62,8 +62,6 @@ static void TL_Fav_UnfNote (struct TL_Not_Note *Not);
static void TL_Fav_FavComm (struct TL_Com_Comment *Com);
static void TL_Fav_UnfComm (struct TL_Com_Comment *Com);
static void TL_Fav_PutDisabledIconFav (unsigned NumUsrs);
/*****************************************************************************/
/********************** Mark/unmark a note as favourite **********************/
/*****************************************************************************/
@ -362,7 +360,7 @@ void TL_Fav_PutIconToFavUnf (TL_Usr_FavSha_t FavSha,
/* Icon to fav/unfav */
if (Usr_ItsMe (UsrCod)) // I am the author ==> I can not fav/unfav
TL_Fav_PutDisabledIconFav (NumUsrs);
TL_Usr_PutDisabledIconFavSha (FavSha,NumUsrs);
else // I am not the author
TL_Frm_PutFormToFavUnfShaUns (FavSha,Cod);
@ -372,25 +370,3 @@ void TL_Fav_PutIconToFavUnf (TL_Usr_FavSha_t FavSha,
/***** Show who have faved this note/comment *****/
TL_Usr_GetAndShowSharersOrFavers (FavSha,Cod,UsrCod,NumUsrs,HowManyUsrs);
}
/*****************************************************************************/
/****************** Put disabled icon to mark as favourite *******************/
/*****************************************************************************/
static void TL_Fav_PutDisabledIconFav (unsigned NumUsrs)
{
extern const char *Txt_TIMELINE_Favourited_by_X_USERS;
extern const char *Txt_TIMELINE_Not_favourited_by_anyone;
/***** Disabled icon to mark as favourite *****/
if (NumUsrs)
{
Ico_PutDivIcon ("TL_ICO_DISABLED",TL_Fav_ICON_FAV,
Str_BuildStringLong (Txt_TIMELINE_Favourited_by_X_USERS,
(long) NumUsrs));
Str_FreeString ();
}
else
Ico_PutDivIcon ("TL_ICO_DISABLED",TL_Fav_ICON_FAV,
Txt_TIMELINE_Not_favourited_by_anyone);
}

View File

@ -59,8 +59,6 @@ extern struct Globals Gbl;
static void TL_Sha_ShaNote (struct TL_Not_Note *Not);
static void TL_Sha_UnsNote (struct TL_Not_Note *Not);
static void TL_Sha_PutDisabledIconShare (unsigned NumShared);
/*****************************************************************************/
/******************************** Share a note *******************************/
/*****************************************************************************/
@ -200,7 +198,7 @@ void TL_Sha_PutIconToShaUnsNote (const struct TL_Not_Note *Not,
if (Not->Unavailable || // Unavailable notes can not be shared
Usr_ItsMe (Not->UsrCod)) // I am the author
/* Put disabled icon */
TL_Sha_PutDisabledIconShare (Not->NumShared);
TL_Usr_PutDisabledIconFavSha (TL_Usr_SHA_UNS_NOTE,Not->NumShared);
else // Available and I am not the author
/* Put icon to share/unshare */
TL_Frm_PutFormToFavUnfShaUns (TL_Usr_SHA_UNS_NOTE,Not->NotCod);
@ -213,25 +211,3 @@ void TL_Sha_PutIconToShaUnsNote (const struct TL_Not_Note *Not,
TL_Usr_GetAndShowSharersOrFavers (TL_Usr_SHA_UNS_NOTE,
Not->NotCod,Not->UsrCod,Not->NumShared,HowManyUsrs);
}
/*****************************************************************************/
/*********************** Put disabled icon to share **************************/
/*****************************************************************************/
static void TL_Sha_PutDisabledIconShare (unsigned NumShared)
{
extern const char *Txt_TIMELINE_Shared_by_X_USERS;
extern const char *Txt_TIMELINE_Not_shared_by_anyone;
/***** Disabled icon to share *****/
if (NumShared)
{
Ico_PutDivIcon ("TL_ICO_DISABLED",TL_Sha_ICON_SHARE,
Str_BuildStringLong (Txt_TIMELINE_Shared_by_X_USERS,
(long) NumShared));
Str_FreeString ();
}
else
Ico_PutDivIcon ("TL_ICO_DISABLED",TL_Sha_ICON_SHARE,
Txt_TIMELINE_Not_shared_by_anyone);
}

View File

@ -36,6 +36,7 @@
#include "swad_timeline_database.h"
#include "swad_timeline_favourite.h"
#include "swad_timeline_form.h"
#include "swad_timeline_share.h"
#include "swad_timeline_user.h"
/*****************************************************************************/
@ -285,3 +286,43 @@ unsigned TL_Usr_GetListFaversOrSharers (TL_Usr_FavSha_t FavSha,
return 0; // Not reached
}
/*****************************************************************************/
/****************** Put disabled icon to mark as favourite *******************/
/*****************************************************************************/
void TL_Usr_PutDisabledIconFavSha (TL_Usr_FavSha_t FavSha,unsigned NumUsrs)
{
extern const char *Txt_TIMELINE_Favourited_by_X_USERS;
extern const char *Txt_TIMELINE_Not_favourited_by_anyone;
extern const char *Txt_TIMELINE_Shared_by_X_USERS;
extern const char *Txt_TIMELINE_Not_shared_by_anyone;
static const char *Icon[TL_Usr_NUM_FAV_SHA] =
{
[TL_Usr_FAV_UNF_NOTE] = TL_Fav_ICON_FAV,
[TL_Usr_FAV_UNF_COMM] = TL_Fav_ICON_FAV,
[TL_Usr_SHA_UNS_NOTE] = TL_Sha_ICON_SHARE,
};
const char *TitleWithUsrs[TL_Usr_NUM_FAV_SHA] =
{
[TL_Usr_FAV_UNF_NOTE] = Txt_TIMELINE_Favourited_by_X_USERS,
[TL_Usr_FAV_UNF_COMM] = Txt_TIMELINE_Favourited_by_X_USERS,
[TL_Usr_SHA_UNS_NOTE] = Txt_TIMELINE_Shared_by_X_USERS,
};
const char *TitleWithoutUsrs[TL_Usr_NUM_FAV_SHA] =
{
[TL_Usr_FAV_UNF_NOTE] = Txt_TIMELINE_Not_favourited_by_anyone,
[TL_Usr_FAV_UNF_COMM] = Txt_TIMELINE_Not_favourited_by_anyone,
[TL_Usr_SHA_UNS_NOTE] = Txt_TIMELINE_Not_shared_by_anyone,
};
/***** Disabled icon to fav/share *****/
if (NumUsrs)
{
Ico_PutDivIcon ("TL_ICO_DISABLED",Icon[FavSha],
Str_BuildStringLong (TitleWithUsrs[FavSha],(long) NumUsrs));
Str_FreeString ();
}
else
Ico_PutDivIcon ("TL_ICO_DISABLED",Icon[FavSha],TitleWithoutUsrs[FavSha]);
}

View File

@ -81,4 +81,6 @@ unsigned TL_Usr_GetListFaversOrSharers (TL_Usr_FavSha_t FavSha,
long Cod,long UsrCod,unsigned MaxUsrs,
MYSQL_RES **mysql_res);
void TL_Usr_PutDisabledIconFavSha (TL_Usr_FavSha_t FavSha,unsigned NumUsrs);
#endif