N°2847 Add a user placeholder image selector in user preferences (poc, need to cleanup)

This commit is contained in:
Stephen Abello
2020-08-07 15:42:10 +02:00
parent 93871308d1
commit ea7924663a
55 changed files with 75 additions and 1 deletions

View File

@@ -1088,7 +1088,7 @@ class UserRights
public static function GetContactPicture($sName = '') public static function GetContactPicture($sName = '')
{ {
// TODO: replace with console one // TODO: replace with console one
$sPictureUrl = utils::GetAbsoluteUrlAppRoot().'datamodels/2.x/itop-portal-base/portal/public/img/user-profile-default-256px.png'; $sPictureUrl = utils::GetAbsoluteUrlAppRoot().'images/user-pictures/' . appUserPreferences::GetPref('user_picture_placeholder', 'default-placeholder.png');
if (empty($sName)) if (empty($sName))
{ {

View File

@@ -119,6 +119,7 @@ $ibo-navigation-menu--notifications-toggler--font-size: 28px !default;
$ibo-navigation-menu--user--text-color: $ibo-color-white-100 !default; $ibo-navigation-menu--user--text-color: $ibo-color-white-100 !default;
$ibo-navigation-menu--user-welcome-message--toggler--padding-left : 6px !default; $ibo-navigation-menu--user-welcome-message--toggler--padding-left : 6px !default;
$ibo-navigation-menu--user-picture--image--border-radius: $ibo-border-radius-full !default; $ibo-navigation-menu--user-picture--image--border-radius: $ibo-border-radius-full !default;
$ibo-navigation-menu--user-picture--image--background-color: $ibo-color-grey-300;
$ibo-navigation-menu--user-notifications--toggler--padding-left: 5px !default; $ibo-navigation-menu--user-notifications--toggler--padding-left: 5px !default;
$ibo-navigation-menu--user-picture--image-collapsed--size: 36px !default; $ibo-navigation-menu--user-picture--image-collapsed--size: 36px !default;
@@ -507,6 +508,7 @@ $ibo-navigation-menu--user-picture--image-expanded--size: 72px !default;
.ibo-navigation-menu--user-picture--image{ .ibo-navigation-menu--user-picture--image{
width: $ibo-navigation-menu--user-picture--image-collapsed--size; width: $ibo-navigation-menu--user-picture--image-collapsed--size;
border-radius: $ibo-navigation-menu--user-picture--image--border-radius; border-radius: $ibo-navigation-menu--user-picture--image--border-radius;
background-color: $ibo-navigation-menu--user-picture--image--background-color;
} }
} }
.ibo-navigation-menu--user-welcome-message, .ibo-navigation-menu--user-organization, .ibo-navigation-menu--user-notifications{ .ibo-navigation-menu--user-welcome-message, .ibo-navigation-menu--user-organization, .ibo-navigation-menu--user-notifications{

View File

@@ -4365,4 +4365,27 @@
border: 2px solid black; border: 2px solid black;
} }
} }
}
.ibo-preferences--user-preferences--picture-placeholder{
display: flex;
flex-direction: row;
flex-wrap: wrap;
}
.ibo-preferences--user-preferences--picture-placeholder--image{
height: 54px;
width: 54px;
border-radius: 100%;
margin: 12px;
}
.ibo-preferences--user-preferences--picture-placeholder--image > img{
border-radius: 100%;
background-color: lightgray;
}
.ibo-preferences--user-preferences--picture-placeholder--image.ibo-is-active{
border: solid 3px hsla(213, 49.4%, 34.1%, 1);
}
.ibo-preferences--user-preferences--picture-placeholder--image:hover{
border: solid 3px hsla(209, 61.6%, 50%, 1);
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

@@ -17,6 +17,8 @@
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
*/ */
use Combodo\iTop\Application\UI\Layout\PageContent\PageContentFactory;
require_once('../approot.inc.php'); require_once('../approot.inc.php');
require_once(APPROOT.'/application/application.inc.php'); require_once(APPROOT.'/application/application.inc.php');
require_once(APPROOT.'/application/itopwebpage.class.inc.php'); require_once(APPROOT.'/application/itopwebpage.class.inc.php');
@@ -28,6 +30,8 @@ require_once(APPROOT.'/application/startup.inc.php');
*/ */
function DisplayPreferences($oP) function DisplayPreferences($oP)
{ {
$oP->SetContentLayout(PageContentFactory::MakeStandardEmpty());
// $oP->AddUiBlock(new \Combodo\iTop\Application\UI\Component\Breadcrumbs\Breadcrumbs());
$oAppContext = new ApplicationContext(); $oAppContext = new ApplicationContext();
$sURL = utils::GetAbsoluteUrlAppRoot().'pages/UI.php?'.$oAppContext->GetForLink(); $sURL = utils::GetAbsoluteUrlAppRoot().'pages/UI.php?'.$oAppContext->GetForLink();
@@ -362,6 +366,50 @@ EOF
$oP->add('</form>'); $oP->add('</form>');
$oP->add('</fieldset>'); $oP->add('</fieldset>');
} }
//Todo: factorize as UiBlock
if (true)
{
$sUserPicturesFolder = '../images/user-pictures/';
$sUserDefaultPicture = appUserPreferences::GetPref('user_picture_placeholder', 'default-placeholder.png');
$oP->add(
<<<HTML
<fieldset><legend>UI:Preferences:ChooseAPlaceholder'</legend>
<p>UI:Preferences:ChooseAPlaceholder+</p>
<div class="ibo-preferences--user-preferences--picture-placeholder">
HTML
);
foreach (scandir($sUserPicturesFolder) as $sUserPicture)
{
if ($sUserPicture === '.' || $sUserPicture === '..')
{
continue;
}
$sAdditionalClass = '';
if ($sUserDefaultPicture === $sUserPicture)
{
$sAdditionalClass = ' ibo-is-active';
}
$oP->add('<a class="ibo-preferences--user-preferences--picture-placeholder--image'.$sAdditionalClass.'" data-image-name="'.$sUserPicture.'" data-role="ibo-preferences--user-preferences--picture-placeholder--image" href="#"> <img src="'.$sUserPicturesFolder.$sUserPicture.'"/> </a>');
}
$oP->add_ready_script(
<<<JS
$('[data-role="ibo-preferences--user-preferences--picture-placeholder--image"]').on('click',function(){
SetUserPreference('user_picture_placeholder', $(this).attr('data-image-name'), true);
$('[data-role="ibo-preferences--user-preferences--picture-placeholder--image"]').removeClass('ibo-is-active');
$(this).addClass('ibo-is-active');
});
JS
);
$oP->add(
<<<HTML
</div>
</fieldset>
HTML
);
}
/** @var iPreferencesExtension $oLoginExtensionInstance */ /** @var iPreferencesExtension $oLoginExtensionInstance */
foreach (MetaModel::EnumPlugins('iPreferencesExtension') as $oPreferencesExtensionInstance) foreach (MetaModel::EnumPlugins('iPreferencesExtension') as $oPreferencesExtensionInstance)
@@ -511,6 +559,7 @@ try
DisplayPreferences($oPage); DisplayPreferences($oPage);
} }
} }
$oPage->output(); $oPage->output();
} }
catch(CoreException $e) catch(CoreException $e)