Skip to content

Commit

Permalink
Improved iTop 3.0 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Hipska committed Jun 28, 2022
1 parent 10be266 commit 55172cf
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 13 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 1.7.0 - 2022-06-28
### Added
- Improved support for iTop 3.0

## 1.6.0 - 2022-06-22
### Added
- PHP methods to calculate RD (Rijksdriehoek) coordinates
Expand Down
2 changes: 1 addition & 1 deletion datamodel.sv-geolocation.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<itop_design xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.3">
<classes>
<class id="Location" _created_in="itop-config-mgmt">
<class id="Location" _created_in="itop-structure">
<fields>
<field id="geo" _delta="define" xsi:type="AttributeGeolocation">
<sql>geo</sql>
Expand Down
35 changes: 25 additions & 10 deletions geomap.class.inc.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
<?php
/**
* @copyright Copyright (C) 2019 Super-Visions
* @copyright Copyright (C) 2019-2022 Super-Visions
* @license http://opensource.org/licenses/AGPL-3.0
*/

use Combodo\iTop\Application\UI\Base\Component\Html\Html;
use Combodo\iTop\Application\UI\Base\Layout\UIContentBlockUIBlockFactory;

class GeoMap extends Dashlet
{
static protected $aAttributeList;
Expand All @@ -22,11 +25,7 @@ public function __construct(ModelReflection $oModelReflection, $sId)
}

/**
* @param WebPage $oPage
* @param bool $bEditMode
* @param array $aExtraParams
* @return mixed
* @throws CoreException
* @inheritDoc
*/
public function Render($oPage, $bEditMode = false, $aExtraParams = array())
{
Expand All @@ -43,6 +42,7 @@ public function Render($oPage, $bEditMode = false, $aExtraParams = array())
{
$sCreateUrl = sprintf(utils::GetAbsoluteUrlAppRoot().'pages/UI.php?operation=new&class=%s&default[%s]=', $oFilter->GetClass(), $this->aProperties['attribute']);
}
$oBlock = null;

// Prepare page
$oPage->add_dict_entry('UI:ClickToCreateNew');
Expand All @@ -63,15 +63,28 @@ public function Render($oPage, $bEditMode = false, $aExtraParams = array())
$sDisplaySearch = $this->aProperties['search'] ? 'block' : 'none';
$sSearch = Dict::S('UI:Button:Search');
$sBackgroundUrl = utils::GetAbsoluteUrlModulesRoot().'sv-geolocation/images/world-map.jpg';
$oPage->add(<<<HTML
<div id= class="dashlet-content">

if (version_compare(ITOP_DESIGN_LATEST_VERSION , 3.0) < 0)
{
$oPage->add(<<<HTML
<div class="dashlet-content">
<div id="{$sId}_panel" class="map_panel" style="display: {$sDisplaySearch};"><input id="{$sId}_address" type="text" /><button id="{$sId}_submit">{$sSearch}</button></div>
<div id="{$sId}" style="height: {$this->aProperties['height']}px; background: white url('{$sBackgroundUrl}') 50%/contain no-repeat;"></div>
</div>
HTML
);
);
}
else
{
$oBlock = UIContentBlockUIBlockFactory::MakeStandard(null, ["dashlet-content"]);
$oBlock->AddSubBlock(new Html(<<<HTML
<div id="{$sId}_panel" class="map_panel" style="display: {$sDisplaySearch};"><input id="{$sId}_address" type="text" /><button id="{$sId}_submit">{$sSearch}</button></div>
<div id="{$sId}" class="ibo-panel--body" style="height: {$this->aProperties['height']}px; background: #ffffff url('{$sBackgroundUrl}') 50%/contain no-repeat;"></div>
HTML
));
}

if ($bEditMode) return;
if ($bEditMode) return $oBlock;

$aDashletOptions = array(
'id' => $sId,
Expand Down Expand Up @@ -100,6 +113,8 @@ public function Render($oPage, $bEditMode = false, $aExtraParams = array())
$oPage->add_linked_script(sprintf('https://maps.googleapis.com/maps/api/js?key=%s', $sApiKey));
$oPage->add_linked_script(utils::GetAbsoluteUrlModulesRoot().'sv-geolocation/js/google-maps-utils.js');
$oPage->add_ready_script(sprintf('render_geomap(%s);', json_encode($aDashletOptions)));

return $oBlock;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions module.sv-geolocation.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

SetupWebPage::AddModule(
__FILE__, // Path to the current file, all other file names are relative to the directory containing this file
'sv-geolocation/1.6.0',
'sv-geolocation/1.7.0',
array(
// Identification
//
Expand All @@ -15,7 +15,7 @@
// Setup
//
'dependencies' => array(
'itop-config-mgmt/2.5.0',
'(itop-config-mgmt/2.5.0 & itop-config-mgmt/<3.0.0)||itop-structure/3.0.0',
),
'mandatory' => false,
'visible' => true,
Expand Down

0 comments on commit 55172cf

Please sign in to comment.