mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-13 07:24:13 +01:00
Merge remote-tracking branch 'origin/support/3.0' into develop
This commit is contained in:
@@ -217,11 +217,12 @@ abstract class User extends cmdbAbstractObject
|
||||
"category" => "core,grant_by_profile,silo",
|
||||
"key_type" => "autoincrement",
|
||||
"name_attcode" => "login",
|
||||
"state_attcode" => "",
|
||||
"state_attcode" => "status",
|
||||
"reconc_keys" => array(),
|
||||
"db_table" => "priv_user",
|
||||
"db_key_field" => "id",
|
||||
"db_finalclass_field" => "",
|
||||
"style" => new ormStyle("ibo-dm-class--User", "ibo-dm-class-alt--User", "var(--ibo-dm-class--User--main-color)", "var(--ibo-dm-class--User--complementary-color)", null, "itop-structure/../../images/icons/icons8-security-pass.svg"),
|
||||
);
|
||||
MetaModel::Init_Params($aParams);
|
||||
//MetaModel::Init_InheritAttributes();
|
||||
@@ -235,7 +236,7 @@ abstract class User extends cmdbAbstractObject
|
||||
MetaModel::Init_AddAttribute(new AttributeString("login", array("allowed_values"=>null, "sql"=>"login", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
|
||||
|
||||
MetaModel::Init_AddAttribute(new AttributeApplicationLanguage("language", array("sql"=>"language", "default_value"=>"EN US", "is_null_allowed"=>false, "depends_on"=>array())));
|
||||
MetaModel::Init_AddAttribute(new AttributeEnum("status", array("allowed_values" => new ValueSetEnum('enabled,disabled'), "sql"=>"status", "default_value"=>"enabled", "is_null_allowed"=>false, "depends_on"=>array())));
|
||||
MetaModel::Init_AddAttribute(new AttributeEnum("status", array("allowed_values" => new ValueSetEnum('enabled,disabled'), "styled_values"=>['enabled' => new ormStyle('ibo-dm-enum--User-status-enabled', 'ibo-dm-enum-alt--User-status-enabled', 'var(--ibo-dm-enum--User-status-enabled--main-color)', 'var(--ibo-dm-enum--User-status-enabled--complementary-color)', null, null),'disabled' => new ormStyle('ibo-dm-enum--User-status-disabled', 'ibo-dm-enum-alt--User-status-disabled', 'var(--ibo-dm-enum--User-status-disabled--main-color)', 'var(--ibo-dm-enum--User-status-disabled--complementary-color)', null, null)], "sql"=>"status", "default_value"=>"enabled", "is_null_allowed"=>false, "depends_on"=>array())));
|
||||
|
||||
MetaModel::Init_AddAttribute(new AttributeLinkedSetIndirect("profile_list", array("linked_class"=>"URP_UserProfile", "ext_key_to_me"=>"userid", "ext_key_to_remote"=>"profileid", "allowed_values"=>null, "count_min"=>1, "count_max"=>0, "depends_on"=>array())));
|
||||
MetaModel::Init_AddAttribute(new AttributeLinkedSetIndirect("allowed_org_list", array("linked_class"=>"URP_UserOrg", "ext_key_to_me"=>"userid", "ext_key_to_remote"=>"allowed_org_id", "allowed_values"=>null, "count_min"=>1, "count_max"=>0, "depends_on"=>array())));
|
||||
|
||||
@@ -49,6 +49,10 @@ css/backoffice/
|
||||
| |- tabular-fields
|
||||
| ...
|
||||
|
|
||||
|- *datamodel/ # SCSS / CSS3 variables and CSS classes for PHP classes of the DM that are part of the core (not in a module) and cannot be styled otherwise
|
||||
| |- _user.scss
|
||||
| ...
|
||||
|
|
||||
|– pages/
|
||||
| |– _home.scss # Home specific styles
|
||||
| |– _contact.scss # Contact specific styles
|
||||
|
||||
12
css/backoffice/datamodel/_all.scss
Normal file
12
css/backoffice/datamodel/_all.scss
Normal file
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2021 Combodo SARL
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
*/
|
||||
|
||||
/**************************************************************************************************************************/
|
||||
/* SCSS / CSS3 variables and CSS classes are based on what the compiler generates and will be used across the application */
|
||||
/* In case you doubt what to put here, check the "env-xxx/branding/themes/datamodel-compiled-scss-rules.scss" file to */
|
||||
/* to see what the compiler generates for XML DM classes. */
|
||||
/**************************************************************************************************************************/
|
||||
|
||||
@import "user";
|
||||
64
css/backoffice/datamodel/_user.scss
Normal file
64
css/backoffice/datamodel/_user.scss
Normal file
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2021 Combodo SARL
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
*/
|
||||
|
||||
// Class itself
|
||||
$ibo-dm-class--User--main-color: $ibo-color-blue-grey-600 !default;
|
||||
$ibo-dm-class--User--complementary-color: $ibo-color-white-100 !default;
|
||||
|
||||
:root {
|
||||
--ibo-dm-class--User--main-color: #{$ibo-dm-class--User--main-color};
|
||||
--ibo-dm-class--User--complementary-color: #{$ibo-dm-class--User--complementary-color};
|
||||
}
|
||||
|
||||
.ibo-dm-class--User {
|
||||
--ibo-main-color: #{$ibo-dm-class--User--main-color};
|
||||
--ibo-main-color--100: #{ibo-adjust-alpha(ibo-adjust-lightness($ibo-dm-class--User--main-color, $ibo-color-base-lightness-100), $ibo-color-base-opacity-for-lightness-100)};
|
||||
--ibo-main-color--900: #{ibo-adjust-alpha(ibo-adjust-lightness($ibo-dm-class--User--main-color, $ibo-color-base-lightness-900), $ibo-color-base-opacity-for-lightness-900)};
|
||||
--ibo-complementary-color: #{$ibo-dm-class--User--complementary-color};
|
||||
}
|
||||
.ibo-dm-class-alt--User {
|
||||
--ibo-main-color: #{$ibo-dm-class--User--complementary-color};
|
||||
--ibo-complementary-color: #{$ibo-dm-class--User--main-color};
|
||||
}
|
||||
|
||||
// State attribute, "enabled" value
|
||||
$ibo-dm-enum--User-status-enabled--main-color: $ibo-lifecycle-active-state-primary-color !default;
|
||||
$ibo-dm-enum--User-status-enabled--complementary-color: $ibo-lifecycle-active-state-secondary-color !default;
|
||||
|
||||
:root {
|
||||
--ibo-dm-enum--User-status-enabled--main-color: #{$ibo-dm-enum--User-status-enabled--main-color};
|
||||
--ibo-dm-enum--User-status-enabled--complementary-color: #{$ibo-dm-enum--User-status-enabled--complementary-color};
|
||||
}
|
||||
|
||||
.ibo-dm-enum--User-status-enabled {
|
||||
--ibo-main-color: #{$ibo-dm-enum--User-status-enabled--main-color};
|
||||
--ibo-main-color--100: #{ibo-adjust-alpha(ibo-adjust-lightness($ibo-dm-enum--User-status-enabled--main-color, $ibo-color-base-lightness-100), $ibo-color-base-opacity-for-lightness-100)};
|
||||
--ibo-main-color--900: #{ibo-adjust-alpha(ibo-adjust-lightness($ibo-dm-enum--User-status-enabled--main-color, $ibo-color-base-lightness-900), $ibo-color-base-opacity-for-lightness-900)};
|
||||
--ibo-complementary-color: #{$ibo-dm-enum--User-status-enabled--complementary-color};
|
||||
}
|
||||
.ibo-dm-enum-alt--User-status-enabled {
|
||||
--ibo-main-color: #{$ibo-dm-enum--User-status-enabled--complementary-color};
|
||||
--ibo-complementary-color: #{$ibo-dm-enum--User-status-enabled--main-color};
|
||||
}
|
||||
|
||||
// State attribute, "disabled" value
|
||||
$ibo-dm-enum--User-status-disabled--main-color: $ibo-lifecycle-inactive-state-primary-color !default;
|
||||
$ibo-dm-enum--User-status-disabled--complementary-color: $ibo-lifecycle-inactive-state-secondary-color !default;
|
||||
|
||||
:root {
|
||||
--ibo-dm-enum--User-status-disabled--main-color: #{$ibo-dm-enum--User-status-disabled--main-color};
|
||||
--ibo-dm-enum--User-status-disabled--complementary-color: #{$ibo-dm-enum--User-status-disabled--complementary-color};
|
||||
}
|
||||
|
||||
.ibo-dm-enum--User-status-disabled {
|
||||
--ibo-main-color: #{$ibo-dm-enum--User-status-disabled--main-color};
|
||||
--ibo-main-color--100: #{ibo-adjust-alpha(ibo-adjust-lightness($ibo-dm-enum--User-status-disabled--main-color, $ibo-color-base-lightness-100), $ibo-color-base-opacity-for-lightness-100)};
|
||||
--ibo-main-color--900: #{ibo-adjust-alpha(ibo-adjust-lightness($ibo-dm-enum--User-status-disabled--main-color, $ibo-color-base-lightness-900), $ibo-color-base-opacity-for-lightness-900)};
|
||||
--ibo-complementary-color: #{$ibo-dm-enum--User-status-disabled--complementary-color};
|
||||
}
|
||||
.ibo-dm-enum-alt--User-status-disabled {
|
||||
--ibo-main-color: #{$ibo-dm-enum--User-status-disabled--complementary-color};
|
||||
--ibo-complementary-color: #{$ibo-dm-enum--User-status-disabled--main-color};
|
||||
}
|
||||
@@ -9,6 +9,7 @@
|
||||
@import "components/all";
|
||||
@import "layout/all";
|
||||
@import "application/all";
|
||||
@import "datamodel/all";
|
||||
@import "pages/all";
|
||||
@import "blocks-integrations/all";
|
||||
@import "themes/all";
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
images/icons/icons8-security-pass.svg
Normal file
1
images/icons/icons8-security-pass.svg
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 5.3 KiB |
@@ -92,14 +92,17 @@ $(function()
|
||||
{
|
||||
return this.options.field_set.triggerHandler('get_current_values');
|
||||
},
|
||||
//since 3.0.2 3.1.0
|
||||
/**
|
||||
* @private
|
||||
* @since 3.0.2 3.1.0
|
||||
*/
|
||||
_updatePreviousValues: function()
|
||||
{
|
||||
let me = this;
|
||||
if(this.element.find('[data-attribute-previous-value]').length>0) {
|
||||
if(this.element.find('[data-attribute-previous-value]').length > 0) {
|
||||
let aPreviousValues = {};
|
||||
$(this.element.find('[data-attribute-previous-value]')).each(function (idx, elt) {
|
||||
aPreviousValues[$(elt).data('field-id')] = $(elt).data('attribute-previous-value');
|
||||
$(this.element.find('[data-attribute-previous-value]')).each(function (iIdx, oElem) {
|
||||
aPreviousValues[$(oElem).data('field-id')] = $(oElem).data('attribute-previous-value');
|
||||
});
|
||||
me.element.find('[data-field-id="previous_values"]').find('input[type="hidden"]').val(JSON.stringify(aPreviousValues));
|
||||
}
|
||||
|
||||
@@ -53,180 +53,6 @@ class ThemeHandlerTest extends ItopTestCase
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test used to be notified by CI when precompiled styles are not up to date anymore in code repository.
|
||||
*
|
||||
* @param $xmlDataCusto
|
||||
* @param $sPrecompiledStylesheet
|
||||
* @param $oTheme
|
||||
*
|
||||
* @group beforeSetup
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function testValidatePrecompiledStyles()
|
||||
{
|
||||
$aErrors = [];
|
||||
$aDataModelFiles=glob(APPROOT . utils::GetConfig()->Get('source_dir'). "/**/datamodel*.xml");
|
||||
$aImportsPaths = [
|
||||
APPROOT.'datamodels', // Simulate env-xxx when looking for files outside env-xxx
|
||||
APPROOT.'datamodels/2.x', // Simulate env-xxx when looking for files within env-xxx
|
||||
$this->sTmpDir, // For DM rules
|
||||
];
|
||||
|
||||
// First we have to compile the styles defined in the DM in order to feed it to the themes
|
||||
$oMFCompiler = new SubMFCompiler($this->createMock(\ModelFactory::class), '');
|
||||
$sDmCssContent = "";
|
||||
foreach ($aDataModelFiles as $sXmlDataCustoFilePath) {
|
||||
if (is_file($sXmlDataCustoFilePath)) {
|
||||
$oDom = new MFDocument();
|
||||
$oDom->load($sXmlDataCustoFilePath);
|
||||
|
||||
$oClassNodes = $oDom->GetNodes("/itop_design//class");
|
||||
foreach ($oClassNodes as $oClassNode) {
|
||||
$sClass = $oClassNode->getAttribute("id");
|
||||
$oFieldNodes = $oClassNode->GetNodes("fields/field[@xsi:type='AttributeEnum' or @xsi:type='AttributeMetaEnum']");
|
||||
foreach ($oFieldNodes as $oFieldNode) {
|
||||
$sAttCode = $oFieldNode->getAttribute("id");
|
||||
|
||||
// Values styles
|
||||
$oValueNodes = $oFieldNode->GetNodes("value");
|
||||
foreach ($oValueNodes as $oValueNode) {
|
||||
$sValueCode = $oValueNode->getAttribute("id");
|
||||
$sDmCssContent .= $oMFCompiler->GenerateStyleDataFromNode($oValueNode, $oMFCompiler::ENUM_STYLE_HOST_ELEMENT_TYPE_ENUM, $sClass, $sAttCode, $sValueCode)['scss'];
|
||||
}
|
||||
|
||||
// Default style
|
||||
$oDefaultStyleNode = $oFieldNode->GetOptionalElement('default_style');
|
||||
if ($oDefaultStyleNode) {
|
||||
$sDmCssContent .= $oMFCompiler->GenerateStyleDataFromNode($oDefaultStyleNode, $oMFCompiler::ENUM_STYLE_HOST_ELEMENT_TYPE_ENUM, $sClass, $sAttCode)['scss'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// - Write file
|
||||
$sDmStylesheetId = 'datamodel-compiled-scss-rules';
|
||||
file_put_contents($this->sDmCssAbsPath, $sDmCssContent);
|
||||
|
||||
foreach ($aDataModelFiles as $sXmlDataCustoFilePath)
|
||||
{
|
||||
if (is_file($sXmlDataCustoFilePath))
|
||||
{
|
||||
$sXmlDataCustoFilePath = realpath($sXmlDataCustoFilePath);
|
||||
$sContent = file_get_contents($sXmlDataCustoFilePath);
|
||||
if (strpos($sContent, "precompiled_stylesheet") !== false)
|
||||
{
|
||||
$oDom = new MFDocument();
|
||||
$oDom->load($sXmlDataCustoFilePath);
|
||||
$oThemeNodes = $oDom->GetNodes("/itop_design/branding/themes/theme");
|
||||
|
||||
// Parsing themes from DM
|
||||
foreach ($oThemeNodes as $oTheme)
|
||||
{
|
||||
/** @var \MFElement $oTheme */
|
||||
$sPrecompiledStylesheetUri = $oTheme->GetChildText('precompiled_stylesheet', '');
|
||||
if (empty($sPrecompiledStylesheetUri))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$sThemeId = $oTheme->getAttribute('id');
|
||||
|
||||
//echo "=== theme: $sThemeId ===\n";
|
||||
$sPrecompiledFilePath = $sSourceDir = APPROOT . utils::GetConfig()->Get('source_dir') . $sPrecompiledStylesheetUri;
|
||||
$sPreCompiledSig = ThemeHandler::GetSignature($sPrecompiledFilePath);
|
||||
if (empty(trim($sPreCompiledSig))){
|
||||
var_dump("$sThemeId: $sPrecompiledFilePath => " . realpath($sPrecompiledFilePath));
|
||||
}
|
||||
//echo " precompiled signature: $sPreCompiledSig\n";
|
||||
|
||||
if (empty($sPreCompiledSig))
|
||||
{
|
||||
$aErrors[] = "Signature in precompiled theme '".$sThemeId."' is not retrievable (cf precompiledsheet $sPrecompiledStylesheetUri / datamodel $sXmlDataCustoFilePath)";
|
||||
continue;
|
||||
}
|
||||
|
||||
$aThemeParameters = array(
|
||||
'variables' => array(),
|
||||
'variable_imports' => array(),
|
||||
'utility_imports' => array(),
|
||||
'stylesheets' => array(),
|
||||
);
|
||||
|
||||
/** @var \DOMNodeList $oVariables */
|
||||
$oVariables = $oTheme->GetNodes('variables/variable');
|
||||
foreach ($oVariables as $oVariable)
|
||||
{
|
||||
$sVariableId = $oVariable->getAttribute('id');
|
||||
$aThemeParameters['variables'][$sVariableId] = $oVariable->GetText();
|
||||
}
|
||||
|
||||
/** @var \DOMNodeList $oImports */
|
||||
$oImports = $oTheme->GetNodes('imports/import');
|
||||
$oFindStylesheetObject = new FindStylesheetObject();
|
||||
|
||||
foreach ($oImports as $oImport)
|
||||
{
|
||||
$sImportId = $oImport->getAttribute('id');
|
||||
|
||||
if($oImport->getAttribute('xsi:type') === 'variables'){
|
||||
$aThemeParameters['variable_imports'][$sImportId] = $oImport->GetText();
|
||||
} else {
|
||||
$aThemeParameters['utility_imports'][$sImportId] = $oImport->GetText();
|
||||
ThemeHandler::FindStylesheetFile($oImport->GetText(), $aImportsPaths, $oFindStylesheetObject);
|
||||
}
|
||||
}
|
||||
|
||||
/** @var \DOMNodeList $oStylesheets */
|
||||
$oStylesheets = $oTheme->GetNodes('stylesheets/stylesheet');
|
||||
foreach ($oStylesheets as $oStylesheet)
|
||||
{
|
||||
$sStylesheetId = $oStylesheet->getAttribute('id');
|
||||
$aThemeParameters['stylesheets'][$sStylesheetId] = $oStylesheet->GetText();
|
||||
ThemeHandler::FindStylesheetFile($oStylesheet->GetText(), $aImportsPaths, $oFindStylesheetObject);
|
||||
}
|
||||
|
||||
$sDmCssRelPath = str_ireplace($this->sTmpDir, '', $this->sDmCssAbsPath);
|
||||
$aThemeParameters['stylesheets'][$sDmStylesheetId] = $sDmCssRelPath;
|
||||
ThemeHandler::FindStylesheetFile($sDmCssRelPath, $aImportsPaths, $oFindStylesheetObject);
|
||||
|
||||
$aIncludedImages = ThemeHandler::GetIncludedImages($aThemeParameters['variables'], $oFindStylesheetObject->GetAllStylesheetPaths(), $sThemeId);
|
||||
$compiled_json_sig = ThemeHandler::ComputeSignature($aThemeParameters, $aImportsPaths, $aIncludedImages);
|
||||
//echo " current signature: $compiled_json_sig\n";
|
||||
|
||||
if ($sPreCompiledSig !== $compiled_json_sig)
|
||||
{
|
||||
$sSignatureDiffToPrint = $this->KeepSignatureDiff($sPreCompiledSig, $compiled_json_sig);
|
||||
|
||||
// Temporary bypass of the test if it concerns only the DM CSS rules
|
||||
$aSignatureDiff = json_decode($sSignatureDiffToPrint, true);
|
||||
if (isset($aSignatureDiff['stylesheets']['datamodel-compiled-scss-rules']) && (count($aSignatureDiff['stylesheets']) === 1) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var_dump($sSignatureDiffToPrint);
|
||||
$iLine = $oTheme->GetLineNo();
|
||||
$aErrors[] = " $sPrecompiledStylesheetUri declared in $sXmlDataCustoFilePath:$iLine.\n$sSignatureDiffToPrint";
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (count($aErrors)!=0)
|
||||
{
|
||||
$sMsg = "Below precompiled files are not up to date. Please run a new setup and save your precompiled files again:\n";
|
||||
$sMsg .= implode("\n", $aErrors);
|
||||
$this->fail($sMsg);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
}
|
||||
|
||||
function KeepSignatureDiff($sSignature1, $sSignature2) : string {
|
||||
$aSignature1 = json_decode($sSignature1, true);
|
||||
$aSignature2 = json_decode($sSignature2, true);
|
||||
|
||||
Reference in New Issue
Block a user