Lots more Dashboard features/changes.
Internationalization and Help to come. Default dashlet demos/walkthroughs to come.
This commit is contained in:
parent
440ca63333
commit
09bf2b263f
12 changed files with 369 additions and 281 deletions
|
|
@ -74,7 +74,7 @@ sub definition {
|
|||
# overrideForm=>{fieldType=>'yesNo',defaultValue=>0},
|
||||
# overrideValue=>{fieldType=>'yesNo',defaultValue=>0},
|
||||
possibleValues=>{fieldType=>'textarea',defaultValue=>'',label=>'Possible values for this Field. Only applies to selectList and checkList.'},
|
||||
defaultValue=>{fieldType=>'text',defaultValue=>'',label=>'Default Value for this field.'}
|
||||
defaultValue=>{fieldType=>'textarea',defaultValue=>'',label=>'Default Value for this field.'}
|
||||
);
|
||||
|
||||
push(@{$definition}, {
|
||||
|
|
@ -170,13 +170,19 @@ sub getUserPref {
|
|||
my $returnDataType = shift || 'string';
|
||||
my $returnDataFormat = shift || 'raw';
|
||||
my $sql = "select userValue from wgFieldUserData where assetId=".quote($fieldId)." and userId=".quote($userId);
|
||||
WebGUI::ErrorHandler::warn($sql);
|
||||
# WebGUI::ErrorHandler::warn($sql);
|
||||
my ($userValue) = WebGUI::SQL->quickArray($sql);
|
||||
unless ($userValue) {
|
||||
return '' if $fieldId eq 'skipThisRequest';
|
||||
$field = WebGUI::Asset->newByDynamicClass($fieldId) unless $field;
|
||||
return '' unless $field;
|
||||
$userValue = $field->get("defaultValue");
|
||||
if ($userId eq '1') {
|
||||
$userValue = $field->get("defaultValue");
|
||||
# fall back to wobject defaults if this is blank.
|
||||
$userValue = WebGUI::Asset->newByDynamicClass($field->getParent->get("shortcutToAssetId"))->get($field->get("fieldName")) if (ref $field->getParent eq 'WebGUI::Asset::Shortcut' && !($userValue) && !($field->get("isUserPref")));
|
||||
} else {
|
||||
$userValue = WebGUI::Asset::Field->getUserPref($fieldId,1);
|
||||
}
|
||||
}
|
||||
if ($returnDataType eq 'string' && $returnDataFormat eq 'raw') {
|
||||
return $userValue;
|
||||
|
|
|
|||
|
|
@ -375,8 +375,8 @@ sub getFieldsList {
|
|||
$output .= '<tr>';
|
||||
$output .= '<td class="tableData"><a href="'.$field->getUrl('func=edit').'">'.$field->get("fieldName").'</a></td>';
|
||||
$output .= '<td class="tableData">';
|
||||
$output .= WebGUI::Icon::editIcon($field->getUrl('func=edit'));
|
||||
$output .= WebGUI::Icon::deleteIcon($field->getUrl('func=delete'));
|
||||
$output .= editIcon('func=edit',$field->getUrl());
|
||||
$output .= deleteIcon('func=delete',$field->getUrl());
|
||||
$output .= '</td>';
|
||||
$output .= '</tr>';
|
||||
}
|
||||
|
|
@ -607,9 +607,9 @@ sub www_edit {
|
|||
sub www_getUserPrefsForm {
|
||||
#This is a form retrieved by "ajax".
|
||||
my $self = shift;
|
||||
return '' unless $self->getParent->canPersonalize;
|
||||
return 'nuhuh' unless $self->getParent->canPersonalize;
|
||||
my @fielden = $self->getUserPrefs;
|
||||
my $f = WebGUI::HTMLForm->new(extras=>' onSubmit="submitForm(this,\''.'form_'.$self->getId.'\');return false;"');
|
||||
my $f = WebGUI::HTMLForm->new(extras=>' onSubmit="submitForm(this,\''.$self->getId.'\',\''.$self->getUrl.'\');return false;"');
|
||||
$f->hidden(
|
||||
-name => 'func',
|
||||
-value => 'saveUserPrefs'
|
||||
|
|
@ -653,9 +653,18 @@ sub www_saveUserPrefs {
|
|||
foreach my $fieldId (keys %{$session{form}}) {
|
||||
my $field = WebGUI::Asset->newByDynamicClass($fieldId);
|
||||
next unless $field;
|
||||
return 0 unless $field->setUserPref($fieldId,$session{form}{$fieldId});
|
||||
$field->setUserPref($fieldId,$session{form}{$fieldId});
|
||||
}
|
||||
return 1;
|
||||
return $self->view;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_getNewTitle {
|
||||
my $self = shift;
|
||||
return '' unless $self->getParent->canPersonalize;
|
||||
my $foo = $self->getShortcut;
|
||||
my $title = $foo->{_properties}{title};
|
||||
return $title;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -179,18 +179,24 @@ sub view {
|
|||
my $t = [Time::HiRes::gettimeofday()] if ($showPerformance);
|
||||
my $view = $child->view;
|
||||
$view .= "Asset:".Time::HiRes::tv_interval($t) if ($showPerformance);
|
||||
$child->{_properties}{title} = $child->getShortcut->get("title") if ref $child eq 'WebGUI::Asset::Shortcut';
|
||||
$child->{_properties}{title} = $child->getShortcut->get("title") if (ref $child eq 'WebGUI::Asset::Shortcut');
|
||||
if ($i > $numPositions) {
|
||||
push(@{$vars{"position1_loop"}},{
|
||||
id=>$child->getId,
|
||||
content=>$view,
|
||||
dashletTitle=>$child->get("title")
|
||||
dashletTitle=>$child->get("title"),
|
||||
shortcutUrl=>$child->getUrl,
|
||||
canPersonalize=>$self->canPersonalize,
|
||||
canEditUserPrefs=>(($session{user}{userId} ne '1') && (ref $child eq 'WebGUI::Asset::Shortcut') && (scalar($child->getUserPrefs) > 0))
|
||||
});
|
||||
} else {
|
||||
push(@{$vars{"position".$i."_loop"}},{
|
||||
id=>$child->getId,
|
||||
content=>$view,
|
||||
dashletTitle=>$child->get("title")
|
||||
dashletTitle=>$child->get("title"),
|
||||
shortcutUrl=>$child->getUrl,
|
||||
canPersonalize=>$self->canPersonalize,
|
||||
canEditUserPrefs=>(($session{user}{userId} ne '1') && (ref $child eq 'WebGUI::Asset::Shortcut') && (scalar($child->getUserPrefs) > 0))
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -207,10 +213,14 @@ sub view {
|
|||
my $t = [Time::HiRes::gettimeofday()] if ($showPerformance);
|
||||
my $view = $child->view;
|
||||
$view .= "Asset:".Time::HiRes::tv_interval($t) if ($showPerformance);
|
||||
$child->{_properties}{title} = $child->getShortcut->get("title") if (ref $child eq 'WebGUI::Asset::Shortcut');
|
||||
push(@{$vars{"position1_loop"}},{
|
||||
id=>$child->getId,
|
||||
content=>$view,
|
||||
dashletTitle=>$child->get("title")
|
||||
dashletTitle=>$child->get("title"),
|
||||
shortcutUrl=>$child->getUrl,
|
||||
canPersonalize=>$self->canPersonalize,
|
||||
canEditUserPrefs=>(($session{user}{userId} ne '1') && (ref $child eq 'WebGUI::Asset::Shortcut') && (scalar($child->getUserPrefs) > 0))
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -230,9 +240,9 @@ sub view {
|
|||
#-------------------------------------------------------------------
|
||||
sub www_setContentPositions {
|
||||
my $self = shift;
|
||||
return 'Visitors cannot save settings' if $session{user}{userId} == 1;
|
||||
return 'Visitors cannot save settings' if($session{user}{userId} eq '1');
|
||||
return WebGUI::Privilege::insufficient() unless ($self->canPersonalize);
|
||||
return '' unless $self->get("mapFieldId");
|
||||
return 'empty' unless $self->get("mapFieldId");
|
||||
my $success = WebGUI::Asset::Field->setUserPref($self->get("mapFieldId"),$session{form}{map});
|
||||
return "Map set: ".$session{form}{map} if $success;
|
||||
return "Map failed to set.";
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ if (isIn($currCond,'Ice Pellets','Light Ice Pellets','Heavy Ice Pellets','Ice Pe
|
|||
if (isIn($currCond,'Freezing Rain Snow','Light Freezing Rain Snow','Heavy Freezing Rain Snow','Freezing Drizzle Snow','Light Freezing Drizzle Snow','Heavy Freezing Drizzle Snow','Snow Freezing Rain| Light Snow Freezing Rain','Heavy Snow Freezing Rain','Snow Freezing Drizzle','Light Snow Freezing Drizzle','Heavy Snow Freezing Drizzle')) {return 'mix';}
|
||||
if (isIn($currCond,'Rain Ice Pellets','Light Rain Ice Pellets','Heavy Rain Ice Pellets','Drizzle Ice Pellets','Light Drizzle Ice Pellets','Heavy Drizzle Ice Pellets','Ice Pellets Rain','Light Ice Pellets Rain','Heavy Ice Pellets Rain','Ice Pellets Drizzle','Light Ice Pellets Drizzle','Heavy Ice Pellets Drizzle')) {return 'raip';}
|
||||
if (isIn($currCond,'Rain Snow','Light Rain Snow','Heavy Rain Snow','Snow Rain','Light Snow Rain','Heavy Snow Rain','Drizzle Snow','Light Drizzle Snow','Heavy Drizzle Snow','Snow Drizzle','Light Snow Drizzle','Heavy Snow Drizzle')) {return 'rasn';}
|
||||
if (isIn($currCond,'Rain Showers','Light Rain Showers','Heavy Rain Showers','Rain Showers in Vicinity','Light Showers Rain','Heavy Showers Rain','Showers Rain','Showers Rain in Vicinity','Rain Showers Fog/Mist','Light Rain Showers Fog/Mist','Heavy Rain Showers Fog/Mist','Rain Showers in Vicinity Fog/Mist','Light Showers Rain Fog/Mist','Heavy Showers Rain Fog/Mist','Showers Rain Fog/Mist','Showers Rain in Vicinity Fog/Mist')) {return 'shra';}
|
||||
if (isIn($currCond,'Rain Showers','Light Rain Showers','Heavy Rain Showers','Rain Showers in Vicinity','Light Showers Rain','Heavy Showers Rain','Showers Rain','Showers Rain in Vicinity','Rain Showers Fog/Mist','Light Rain Showers Fog/Mist','Heavy Rain Showers Fog/Mist','Rain Showers in Vicinity Fog/Mist','Light Showers Rain Fog/Mist','Heavy Showers Rain Fog/Mist','Showers Rain Fog/Mist','Showers Rain in Vicinity Fog/Mist','Light Rain and Breezy')) {return 'shra';}
|
||||
if (isIn($currCond,'Thunderstorm','Light Thunderstorm Rain','Heavy Thunderstorm Rain','Thunderstorm Rain Fog/Mist','Light Thunderstorm Rain Fog/Mist','Heavy Thunderstorm Rain Fog/Mist','Thunderstorm Showers in Vicinity','| Light Thunderstorm Rain Haze','Heavy Thunderstorm Rain Haze','Thunderstorm Fog','Light Thunderstorm Rain Fog','Heavy Thunderstorm Rain Fog','Thunderstorm Light Rain','Thunderstorm Heavy Rain','Thunderstorm Rain Fog/Mist','Thunderstorm Light Rain Fog/Mist','Thunderstorm Heavy Rain Fog/Mist','Thunderstorm in Vicinity Fog/Mist','Thunderstorm Showers in Vicinity','Thunderstorm in Vicinity','Thunderstorm in Vicinity Haze','Thunderstorm Haze in Vicinity','Thunderstorm Light Rain Haze','Thunderstorm Heavy Rain Haze','Thunderstorm Fog','Thunderstorm Light Rain Fog','Thunderstorm Heavy Rain Fog','Thunderstorm Hail','Light Thunderstorm Rain Hail','Heavy Thunderstorm Rain Hail','Thunderstorm Rain Hail Fog/Mist','Light Thunderstorm Rain Hail Fog/Mist','Heavy Thunderstorm Rain Hail Fog/Mist','Thunderstorm Showers in Vicinity Hail','| Light Thunderstorm Rain Hail Haze','Heavy Thunderstorm Rain Hail Haze','Thunderstorm Hail Fog','Light Thunderstorm Rain Hail Fog','Heavy Thunderstorm Rain Hail Fog','Thunderstorm Light Rain Hail','Thunderstorm Heavy Rain Hail','Thunderstorm Rain Hail Fog/Mist','Thunderstorm Light Rain Hail Fog/Mist','Thunderstorm Heavy Rain Hail Fog/Mist','Thunderstorm in Vicinity Hail Fog/Mist','Thunderstorm Showers in Vicinity Hail','Thunderstorm in Vicinity Hail','Thunderstorm in Vicinity Hail Haze','Thunderstorm Haze in Vicinity Hail','Thunderstorm Light Rain Hail Haze','Thunderstorm Heavy Rain Hail Haze','Thunderstorm Hail Fog','Thunderstorm Light Rain Hail Fog','Thunderstorm Heavy Rain Hail Fog','Thunderstorm Small Hail/Snow Pellets','Thunderstorm Rain Small Hail/Snow Pellets','Light Thunderstorm Rain Small Hail/Snow Pellets','Heavy Thunderstorm Rain Small Hail/Snow Pellets')) {return 'tsra';}
|
||||
if (isIn($currCond,'Snow','Light Snow','Heavy Snow','Snow Showers','Light Snow Showers','Heavy Snow Showers','Showers Snow','Light Showers Snow','Heavy Showers Snow','Snow Fog/Mist','Light Snow Fog/Mist','Heavy Snow Fog/Mist','Snow Showers Fog/Mist','Light Snow Showers Fog/Mist','Heavy Snow Showers Fog/Mist','Showers Snow Fog/Mist','Light Showers Snow Fog/Mist','Heavy Showers Snow Fog/Mist','Snow Fog','Light Snow Fog','Heavy Snow Fog','Snow Showers Fog','Light Snow Showers Fog','Heavy Snow Showers Fog','Showers Snow Fog','Light Showers Snow Fog','Heavy Showers Snow Fog','Showers in Vicinity Snow','Snow Showers in Vicinity','Snow Showers in Vicinity Fog/Mist','Snow Showers in Vicinity Fog','Low Drifting Snow','Blowing Snow','Snow Low Drifting Snow','Snow Blowing Snow','Light Snow Low Drifting Snow','Light Snow Blowing Snow','Heavy Snow Low Drifting Snow','Heavy Snow Blowing Snow','Thunderstorm Snow','Light Thunderstorm Snow','Heavy Thunderstorm Snow','Snow Grains','Light Snow Grains','Heavy Snow Grains','Heavy Blowing Snow','Blowing Snow in Vicinity')) {return 'sn';}
|
||||
if (isIn($currCond,'Windy','Fair and Windy','A Few Clouds and Windy','Partly Cloudy and Windy','Mostly Cloudy and Windy','Overcast and Windy')) {return 'wind';}
|
||||
|
|
@ -198,21 +198,17 @@ sub view {
|
|||
#Set some template variables
|
||||
|
||||
#Build list of locations as an array
|
||||
my $defaults = $self->getValue("locations");
|
||||
my $defaults = $self->get("locations");
|
||||
#replace any windows newlines
|
||||
$defaults =~ s/\r//;
|
||||
$defaults =~ s/\r//gm;
|
||||
my @array = split("\n",$defaults);
|
||||
#trim locations of whitespace
|
||||
for (my $i = 0; $i < scalar(@array); $i++) {
|
||||
$array[$i] = $self->_trim($array[$i]);
|
||||
}
|
||||
my $data = $self->_getLocationData(\@array);
|
||||
|
||||
my @locs = ();
|
||||
foreach my $location (@array) {
|
||||
push (@locs, $self->_getLocationData($location));
|
||||
for (my $i = 0; $i < scalar(@array); $i++) {
|
||||
$array[$i] = $self->_trim($array[$i]);\
|
||||
push (@locs, $self->_getLocationData($array[$i]));
|
||||
}
|
||||
$var->{'locations.loop'} = \@locs;
|
||||
$var->{'ourLocations.loop'} = \@locs;
|
||||
return $self->processTemplate($var, $self->get("templateId"));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -315,7 +315,7 @@ Creates an HTML formatted string
|
|||
sub showDebug {
|
||||
my $text = $WebGUI::Session::session{debug}{'error'};
|
||||
$text =~ s/\n/\<br \/\>\n/g;
|
||||
my $output = '<div style="background-color: #800000;color: #ffffff;">'.$text."</div>\n";
|
||||
my $output = 'beginDebug<br /><div style="background-color: #800000;color: #ffffff;">'.$text."</div>\n";
|
||||
$text = $WebGUI::Session::session{debug}{'warn'};
|
||||
$text =~ s/\n/\<br \/\>\n/g;
|
||||
$output .= '<div style="background-color: #ffdddd;color: #000000;">'.$text."</div>\n";
|
||||
|
|
|
|||
|
|
@ -607,9 +607,10 @@ The database handler. Defaults to the WebGUI database handler.
|
|||
=cut
|
||||
|
||||
sub quote {
|
||||
my $value = shift;
|
||||
my $value = shift;
|
||||
return "''" unless $value;
|
||||
my $dbh = shift || _getDefaultDb();
|
||||
return $dbh->quote($value);
|
||||
return $dbh->quote($value);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue