From 58449bb158908e33a8665fd8bf993c8146eee31c Mon Sep 17 00:00:00 2001 From: Drake Date: Fri, 1 Sep 2006 02:49:13 +0000 Subject: [PATCH] Multiple fixes: - Caching of overrides was using inconsistent tag in Shortcut assets. - Fix JavaScript race condition in dashlet prefs form code. --- docs/changelog/7.x.x.txt | 2 ++ lib/WebGUI/Asset/Shortcut.pm | 14 ++++++++++---- www/extras/wobject/Dashboard/draggable.js | 6 +++--- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index e6fca56b4..f6f8ed873 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -33,6 +33,8 @@ - API change: in ProfileField, the get*Fields family of methods are now class methods - API change: 'func' and 'op' are now reserved and not usable as profile fields - fix: project editing in project management systems not reading fields correctly + - fix: JavaScript race condition in dashlet prefs form + - fix: caching problem with overrides in dashlets 7.0.6 - fix: Error in DateTime.pm diff --git a/lib/WebGUI/Asset/Shortcut.pm b/lib/WebGUI/Asset/Shortcut.pm index 90fdd71b3..2e65ce117 100644 --- a/lib/WebGUI/Asset/Shortcut.pm +++ b/lib/WebGUI/Asset/Shortcut.pm @@ -374,13 +374,18 @@ sub getOverridesList { return $output; } +#------------------------------------------------------------------- +sub _overridesCacheTag { + my $self = shift; + #cache by userId, assetId of this shortcut, and whether adminMode is on or not. + return ["shortcutOverrides", $self->getId, $self->session->user->userId, $self->session->var->get("adminOn")]; +} #------------------------------------------------------------------- sub getOverrides { my $self = shift; my $i = 0; - #cache by userId, assetId of this shortcut, and whether adminMode is on or not. - my $cache = WebGUI::Cache->new($self->session,["shortcutOverrides",$self->getId,$self->session->user->userId,$self->session->var->get("adminOn")]); + my $cache = WebGUI::Cache->new($self->session,$self->_overridesCacheTag); my $overridesRef = $cache->get; unless ($overridesRef->{cacheNotExpired}) { my %overrides; @@ -412,7 +417,7 @@ sub getOverrides { my $fieldName = $field->getId; my $fieldValue = $u->profileField($field->getId); $overrides{userPrefs}{$fieldName}{value} = $fieldValue; - $overrides{overrides}{$fieldName}{parsedValue} = $fieldValue; + $overrides{userPrefs}{$fieldName}{parsedValue} = $fieldValue; # 'myTemplateId is ##userPref:myTemplateId##', for example. foreach my $overr (keys %{$overrides{overrides}}) { $overrides{overrides}{$overr}{parsedValue} =~ s/\#\#userPref\:${fieldName}\#\#/$fieldValue/gm; @@ -626,13 +631,14 @@ sub processPropertiesFromFormPost { $self->SUPER::processPropertiesFromFormPost; my $scratchId = "Shortcut_" . $self->getId; $self->session->scratch->delete($scratchId); + $self->uncacheOverrides; } #------------------------------------------------------------------- sub uncacheOverrides { my $self = shift; - WebGUI::Cache->new($self->session,["shortcutOverrides",$self->getId])->delete; + WebGUI::Cache->new($self->session,$self->_overridesCacheTag)->delete; } #------------------------------------------------------------------- diff --git a/www/extras/wobject/Dashboard/draggable.js b/www/extras/wobject/Dashboard/draggable.js index b429a7e1b..54cdeef33 100644 --- a/www/extras/wobject/Dashboard/draggable.js +++ b/www/extras/wobject/Dashboard/draggable.js @@ -516,11 +516,11 @@ function dashboard_toggleEditForm(event,shortcutId,shortcutUrl) { return; } // Create the new form element. - formDiv = document.createElement("div"); + var formDiv = document.createElement("div"); formDiv.id = "form" + shortcutId + "_div"; formDiv.className = "userPrefsForm"; - parentDiv = document.getElementById("td" + shortcutId + "_div"); - contentDiv = document.getElementById("ct" + shortcutId + "_div"); + var parentDiv = document.getElementById("td" + shortcutId + "_div"); + var contentDiv = document.getElementById("ct" + shortcutId + "_div"); parentDiv.insertBefore(formDiv,contentDiv); var hooha = AjaxRequest.get( {