Mglaser has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/363603 )

Change subject: BlueSpiceExtensions/Dashboards: nothing shown in dashboards
......................................................................

BlueSpiceExtensions/Dashboards: nothing shown in dashboards

The dashboard config was still encoded in database.

Maintenance script clearConfigs was not called in update.php

Dashboard config was not saved on remove portlet.

Codestyling and refactoring

Fixed some issues ERM#6744

Change-Id: Id31001a6c3e1e3f43d60bcb5d9bf5469d6d13a4a
---
M Dashboards/Dashboards.class.php
M Dashboards/extension.json
M Dashboards/maintenance/clearConfigs.php
M Dashboards/resources/BS.Dashboards/DashboardPanel.js
4 files changed, 27 insertions(+), 17 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/BlueSpiceExtensions 
refs/changes/03/363603/1

diff --git a/Dashboards/Dashboards.class.php b/Dashboards/Dashboards.class.php
index 34dfbe0..accfed4 100644
--- a/Dashboards/Dashboards.class.php
+++ b/Dashboards/Dashboards.class.php
@@ -89,6 +89,8 @@
                        'bs_dashboards_configs',
                        __DIR__ .'/db/mysql/bs_dashboards_configs.sql'
                );
+
+               $updater->addPostDatabaseUpdateMaintenance( 
BSDashBoardsClearConfigMaintenance::class );
                return true;
        }
 
diff --git a/Dashboards/extension.json b/Dashboards/extension.json
index 1952271..756edb9 100644
--- a/Dashboards/extension.json
+++ b/Dashboards/extension.json
@@ -38,7 +38,8 @@
                "SpecialUserDashboard": 
"includes/specials/SpecialUserDashboard.php",
                "BSApiDashboardTasks": "includes/api/BSApiDashboardTasks.php",
                "BSApiDashboardStore": "includes/api/BSApiDashboardStore.php",
-               "BSApiDashboardWidgetsTasks": 
"includes/api/BSApiDashboardWidgetsTasks.php"
+               "BSApiDashboardWidgetsTasks": 
"includes/api/BSApiDashboardWidgetsTasks.php",
+               "BSDashBoardsClearConfigMaintenance": 
"maintenance/clearConfigs.php"
        },
        "ResourceModules": {
                "ext.bluespice.dashboards": {
diff --git a/Dashboards/maintenance/clearConfigs.php 
b/Dashboards/maintenance/clearConfigs.php
index d53e8c3..625b697 100644
--- a/Dashboards/maintenance/clearConfigs.php
+++ b/Dashboards/maintenance/clearConfigs.php
@@ -2,15 +2,15 @@
 
 require_once( dirname(dirname(dirname(dirname(__DIR__)))) . 
'/maintenance/Maintenance.php' );
 
-class clearConfigs extends Maintenance{
-       public function execute() {
+class BSDashBoardsClearConfigMaintenance extends LoggedUpdateMaintenance {
+       public function doDBUpdates() {
                $aFinalPortletList = array();
                $aPortlets = array();
 
                Hooks::run( 'BSDashboardsUserDashboardPortalPortlets', array( 
&$aPortlets ) );
                Hooks::run( 'BSDashboardsAdminDashboardPortalPortlets', array( 
&$aPortlets ) );
                Hooks::run( 'BSDashboardsGetPortlets', array( &$aPortlets ) );
-
+               $this->output( 'Clearing dashboards... ');
                for ( $i = 0; $i < count( $aPortlets ); $i++ ) {
                        $aFinalPortletList[] = $aPortlets[$i]["type"];
                }
@@ -28,7 +28,7 @@
                                $aPortalConfig = unserialize( $row->dc_config 
); //backward compatible handling
                                MediaWiki\restoreWarnings();
                        }catch(Exception $e){
-                               $this->output( "Object in json only string" );
+                               $this->output( "Object in json only string\n" );
                        }
                        if ( $aPortalConfig === FALSE ) { //this should be the 
normal case
                                $aPortalConfig = FormatJson::decode( 
$row->dc_config );
@@ -49,23 +49,30 @@
                        }
                        $aPortalConfig = FormatJson::encode( $aPortalConfig );
                        if ( $bHasChange ) {
+                               $this->output( "Save changes to database\n" );
                                $oDbw = $this->getDB( DB_MASTER );
                                $oDbw->update(
-                                               'bs_dashboards_configs',
-                                               array(
-                                                       'dc_config' => 
$aPortalConfig //save json string into db
-                                               ),
-                                               array(
-                                                       'dc_type' => $sType,
-                                                       'dc_identifier' => 
$iUser
-                                               )
-                                       );
+                                       'bs_dashboards_configs',
+                                       array(
+                                               'dc_config' => $aPortalConfig 
//save json string into db
+                                       ),
+                                       array(
+                                               'dc_type' => $sType,
+                                               'dc_identifier' => $iUser
+                                       )
+                               );
                        }
                }
+
+               return true;
+       }
+
+       protected function getUpdateKey() {
+               return 'bs_dashboards-clear-configs';
        }
 }
 
-$maintClass = 'clearConfigs';
+$maintClass = 'BSDashBoardsClearConfigMaintenance';
 if (defined('RUN_MAINTENANCE_IF_MAIN')) {
        require_once( RUN_MAINTENANCE_IF_MAIN );
 } else {
diff --git a/Dashboards/resources/BS.Dashboards/DashboardPanel.js 
b/Dashboards/resources/BS.Dashboards/DashboardPanel.js
index 2487685..6059896 100644
--- a/Dashboards/resources/BS.Dashboards/DashboardPanel.js
+++ b/Dashboards/resources/BS.Dashboards/DashboardPanel.js
@@ -62,8 +62,8 @@
        onPortletConfigChange: function( portlet, cfg ) {
                this.savePortalConfig();
        },
-       onPortletDestroy: function() {
-               this.items.remove(portlet);
+       onPortletDestroy: function( portlet ) {
+               this.items.remove( portlet );
                this.savePortalConfig();
        },
        onDrop: function() {

-- 
To view, visit https://gerrit.wikimedia.org/r/363603
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id31001a6c3e1e3f43d60bcb5d9bf5469d6d13a4a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/BlueSpiceExtensions
Gerrit-Branch: REL1_27
Gerrit-Owner: Mglaser <[email protected]>
Gerrit-Reviewer: Nasty <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to