Skip to content

Commit

Permalink
Item8223: fixes for IE and tidy ups
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/trunk/SkillsPlugin@4574 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
CrawfordCurrie authored and CrawfordCurrie committed Jul 28, 2009
1 parent d237459 commit e3d292d
Show file tree
Hide file tree
Showing 22 changed files with 378 additions and 510 deletions.
3 changes: 3 additions & 0 deletions data/System/SkillsAdminIntroduction.txt
Expand Up @@ -56,6 +56,9 @@ Existing Skills:
<td class="%IF{"$INCLUDINGTOPIC=SkillsEditMySkills" then="current" else="other"}%">
[[SkillsEditMySkills][Edit My Skills]]
</td>
<td class="%IF{"$INCLUDINGTOPIC=SkillsSelectMySkills" then="current" else="other"}%">
[[SkillsSelectMySkills][Select My Skills]]
</td>
<td class="%IF{"$INCLUDINGTOPIC=SkillsSearch" then="current" else="other"}%">
[[SkillsSearch][Search Skills]]
</td>
Expand Down
5 changes: 3 additions & 2 deletions data/System/SkillsCreateNewCategory.txt
Expand Up @@ -34,11 +34,11 @@ Create a new category.
<form name="createcategory" action="%SCRIPTURL{rest}%/SkillsPlugin/createNode" method="post">
<div class="foswikiFormSteps">
<div class="foswikiFormStep">
Name of new category: %BR% <input name="name" type="text" class="twikiInputField" size="20" value="%URLPARAM{"name"}%" />
Name of new category: %BR% <input name="path2" type="text" class="twikiInputField" size="20" value="%URLPARAM{"name"}%" />
</div>
<div class="foswikiFormStep">
In category: %BR%
<select name="path">
<select name="path1">
<option>%URLPARAM{path}%</option>
%SKILLS{action="showcategories" format="<option value='$category'>$category</option>" }%
</select>
Expand All @@ -51,6 +51,7 @@ In category: %BR%
<div class="foswikiFormStep foswikiLast">
<input name="createcategory" type="submit" class="foswikiSubmit" value="%MAKETEXT{"Create"}%" />
<input type="hidden" name="endPoint" value="%WEB%.%TOPIC%" />
<input type="hidden" name="name" value="Empty Skill" />
</div>
</div>
</form>
Expand Down
2 changes: 1 addition & 1 deletion data/System/SkillsDisplayOnHomePage.txt
Expand Up @@ -11,7 +11,7 @@ The topic you need to edit is [[%USERSWEB%.PatternSkinUserViewTemplate]].

Firstly, add the following line to %USERSWEB%.PatternSkinUserViewTemplate. This needs to be anywhere between =%TMPL:INCLUDE{"view"}%= and =%TMPL:DEF{"formattop"}%=:

<verbatim>%TMPL:DEF{"skills"}%<div class="skills_UserHomePage">%SKILLS{action="userskills" user="%TOPIC%"}%</div>%TMPL:END%</verbatim>
<verbatim>%TMPL:DEF{"skills"}%<div style="margin:0 5px">%SKILLS{action="userskills" user="%TOPIC%"}%</div>%TMPL:END%</verbatim>

---+++ Step 2.

Expand Down
1 change: 1 addition & 0 deletions data/System/SkillsPlugin.txt
Expand Up @@ -142,6 +142,7 @@ Next:
| Plugin Release: | %$RELEASE% |
| Plugin Version: | %$VERSION% |
| Change History: | <!-- versions below in reverse order -->&nbsp; |
| 28 Jul 2009 | Foswiki:Tasks.Item8223: bare metal rewrite to support deep taxonomies. -- Foswiki:Main.CrawfordCurrie |
| 17 Jul 2009 | Foswiki:Tasks.Item8217: add support for flat display of skills for bulk editing, added override for the hard-coded skill levels using a preference. *REMOVED* =ALLOWADDSKILLS=. Foswiki:Tasks.Item8219: add descriptions of the skills and categories to easy navigation - Foswiki:Main.CrawfordCurrie |
| 20 Mar 2009 | Foswiki:Tasks.Item1260 - Ported to Foswiki as version 1.0; Small code improvements; Update docs & screenshots |
| 05 Feb 2009 | Complete rewrite; more scaleable; better performace; can use special characters in skill names; can use templates to change output; tested on Foswiki |
Expand Down
14 changes: 2 additions & 12 deletions data/System/SkillsSelectMySkills.txt
Expand Up @@ -3,18 +3,8 @@
---+!! SkillsPlugin: Select My Skills

%STARTINCLUDE%
<table class="skillNavigation" border="0" cellpadding="3" cellspacing="0"><tr>
<td>&nbsp; &nbsp;</td>
<td bgcolor="#F6F4EB">&nbsp; [[SkillsBrowseAll][Browse Skills]] &nbsp;</td>
<td>&nbsp;</td>
<td bgcolor="#EAE9DE">&nbsp; *Edit My Skills* &nbsp;</td>
<td>&nbsp;</td>
<td bgcolor="#F6F4EB">&nbsp; [[SkillsSearch][Search Skills]] &nbsp;</td>
<td>&nbsp;</td>
</tr></table>
<table border="0" cellpadding="5" cellspacing="0" style="width:100%;">
<tr bgcolor="#EAE9DE"><td style="width:100%;"></td></tr>
</table>
%INCLUDE{"SkillsAdminIntroduction" section="tabs"}%

%STARTSECTION{"selectskills"}%
<div class="foswikiFormSteps">
<div class="foswikiFormStep">
Expand Down
49 changes: 32 additions & 17 deletions lib/Foswiki/Plugins/SkillsPlugin.pm
Expand Up @@ -26,7 +26,7 @@ use Foswiki::Plugins::SkillsPlugin::SkillNode ();

# Plugin Variables
our $VERSION = '$Rev$';
our $RELEASE = '16 Jul 2009';
our $RELEASE = '28 Jul 2009';
our $NO_PREFS_IN_TOPIC = 1;
our $SHORTDESCRIPTION =
'Allows users to list their skills, which can then be searched';
Expand All @@ -35,10 +35,11 @@ our $recursionBlock;
# ========================= INIT
sub initPlugin {

# Set a context that defined how many levels of
Foswiki::Func::getContext()->{skillsplugin_subcategories} = 1;
# Register tag %SKILLS%

Foswiki::Func::registerTagHandler( 'SKILLS', \&_handleTag );
# Register tag %SKILLRATINGS%

Foswiki::Func::registerTagHandler( 'SKILLRATINGS', \&_SKILLRATINGS );

# Register REST handlers
Expand Down Expand Up @@ -84,7 +85,10 @@ sub _genTooltips {
my ($node, $out) = @_;
my $id = $node->getID();
my $desc = Foswiki::Func::renderText($node->{text});
$$out .= "<div class='skillsTooltip' id='tip$id'>$desc</div>";
if ($desc && length($desc) > 0) {
$$out .= "<div class='skillsplugin_tooltip' id='tip$id'>"
. "$desc</div>";
}
},
\$out
);
Expand Down Expand Up @@ -294,15 +298,15 @@ sub _tagEditAllSkills {
}

sub _addCommentTip {
my $userSkill = shift;
if ( !$userSkill->{comment} ) {
my ($user, $skill) = @_;
if ( !$skill->{text} ) {
return ( '', '');
}
my $id = $userSkill->getID();
my $tipDiv = "<div style='display:none' id='${id}_comment'>"
.$userSkill->{comment}."</div>";
my $id = 'comment:'.$user->{name}.':'.$skill->getID();
my $tipDiv = "<div style='display:none' id='tip$id'>"
.$skill->{text}."</div>";
my $tipIcon =
"<span id='$id' title='${id}_comment' class='skillsTipped'>%ICON{note}%</span>";
"<span id='$id' class='skillsTipped'>%ICON{note}%</span>";
return ( $tipIcon, $tipDiv );
}

Expand Down Expand Up @@ -522,7 +526,7 @@ sub _compileAllUserSkills {
next unless $user;
my $skill = $user->getByPath(@$path);
next unless $skill; # User does not have this skill

next unless $skill->{rating} > 0;
$out .= _compileUserSkill(
$user, $skill, $templates, $commentTips, $matches);
}
Expand Down Expand Up @@ -558,7 +562,7 @@ sub _compileUserSkill {
$out .= Foswiki::Func::expandTemplate($templates.':repeated:userend');

# comment
my ($tipIcon, $tipDiv) = _addCommentTip($user);
my ($tipIcon, $tipDiv) = _addCommentTip($user, $skill);
$$commentTips .= $tipDiv;
$out =~ s/%COMMENTTIP%/$tipIcon/g;
$out =~ s/%USER%/$user->{name}/g;
Expand All @@ -580,7 +584,7 @@ sub _getPathFromCGI {
} else {
for (my $i = 1; $i < 10; $i++) {
if (defined($request->param("path$i"))) {
push(@path, $request->param("path$i"));
push(@path, split('/', $request->param("path$i")));
}
}
}
Expand Down Expand Up @@ -711,12 +715,15 @@ sub _rest_getChildNodes {

my $request = Foswiki::Func::getCgiQuery();
my @path = _getPathFromCGI();
my $leafonly = $request->param('leafonly');

my $skills = new Foswiki::Plugins::SkillsPlugin::Skills();
my $node = $skills->getByPath(@path);
return returnRESTResult($response, 500,
join('/', @path)." is not in the skills database") unless $node;
my @kids = map { $_->{name} } @{$node->{childNodes}};
my @kids = map { $_->{name} }
grep { !($leafonly && $_->hasChildren) }
@{$node->{childNodes}};
return JSON::to_json(\@kids);
}

Expand Down Expand Up @@ -822,7 +829,7 @@ sub _rest_saveUserChanges {
sub {
my $node = shift;
return if $node->hasChildren();
my $key = "editall:2f".$node->getID();
my $key = $node->getID();
my $rating = $request->param("$key-rating");
my $comment = $request->param("$key-comment");
if (defined $rating || defined $comment) {
Expand All @@ -835,19 +842,27 @@ sub _rest_saveUserChanges {
$known->{rating} = $rating;
$known->{text} = $comment;
$added++;
print STDERR "Add ".$known->getPath()."\n";
print STDERR $known->getPath()." added\n";
} else {
my $changes = 0;
if (defined $rating &&
(!defined $known->{rating} ||
$rating ne $known->{rating})) {
($rating||0) != ($known->{rating}||0))) {
print STDERR "Rating ".
(defined $known->{rating}?
$known->{rating}:'undef')." -> ".
"$rating\n";
$known->{rating} = $rating;
$changes++;
}
if (defined $comment &&
(!defined $known->{text} ||
$comment ne $known->{text})) {
$known->{text} = $comment;
print STDERR "Comment ".
(defined $known->{text}?
$known->{text}:'undef')." -> ".
"$comment\n";
$changes++;
}
if ( $changes ) {
Expand Down
1 change: 1 addition & 0 deletions lib/Foswiki/Plugins/SkillsPlugin/MANIFEST
Expand Up @@ -28,6 +28,7 @@ pub/System/SkillsPlugin/searchSkills.js 0644
pub/System/SkillsPlugin/skills_screenshot_full.png 0644
pub/System/SkillsPlugin/skills_screenshot_search.png 0644
pub/System/SkillsPlugin/skills_screenshot_thumb.png 0644
pub/System/SkillsPlugin/star.gif 0644
pub/System/SkillsPlugin/style.css 0644
pub/System/SkillsPlugin/viewUserSkills.js 0644
templates/skills.tmpl 0644
Expand Down
11 changes: 9 additions & 2 deletions lib/Foswiki/Plugins/SkillsPlugin/NamedNode.pm
Expand Up @@ -13,6 +13,13 @@ sub new {
return $this;
}

# By default children are the same type as the parent
sub newChild {
my $this = shift;
my $class = ref($this);
return $class->new(@_);
}

sub serializable {
my ($this, $field) = @_;
return $field eq 'name';
Expand Down Expand Up @@ -123,7 +130,7 @@ sub addByPath {
return $kid->addByPath($node, @_);
}
}
my $intermediate = ref($this)->new($child);
my $intermediate = $this->newChild($child);
$this->appendChild($intermediate);
$intermediate->addByPath($node, @_);
}
Expand Down Expand Up @@ -187,7 +194,7 @@ sub hasChildren {

sub stringify {
my $this = shift;
my $out = $this->{name}.'('.ref($this).')';
my $out = ($this->{name}||'unnamed').'('.ref($this).')';
if ($this->hasChildren()) {
my @kids;
foreach my $kid (@{$this->{childNodes}}) {
Expand Down
6 changes: 6 additions & 0 deletions lib/Foswiki/Plugins/SkillsPlugin/Skills.pm
Expand Up @@ -29,6 +29,12 @@ sub new {
return $this;
}

# Children are of a different type
sub newChild {
my $this = shift;
return new Foswiki::Plugins::SkillsPlugin::SkillNode(@_);
}

# Deprecated: read skills from file in work area
sub _getSkillsFromWorking {
my $this = shift;
Expand Down
49 changes: 13 additions & 36 deletions pub/System/SkillsPlugin/addEditSkills.js
Expand Up @@ -14,31 +14,24 @@ SkillsPlugin.addEditSkills = function () {
el.style.display = '';
}

// resets the entire form to its initial state
var _resetForm = function(){
SkillsPlugin.main.populateCategorySelect('addedit');
}

return {
// clears the rating and the comment
resetSkillDetails: function(){
// reset details
var yuiEl = new YAHOO.util.Element();
var els = yuiEl.getElementsByClassName('skillsRating');
var els = yuiEl.getElementsByClassName('skillsFormRatingControl');
for( var i in els) {
if (els[i].checked )
els[i].checked = false;
}
var els = yuiEl.getElementsByClassName('skillsComment');
var els = yuiEl.getElementsByClassName('skillsFormCommentControl');
for( var i in els)
els[i].value = '';
_hideClearComment();
},

// populates the rating and the comment for a skill
populateSkillDetails: function() {
this.resetSkillDetails();

// get selected category and skill
var elSelect = document.getElementById(
"addedit-category-select");
Expand All @@ -56,7 +49,7 @@ SkillsPlugin.addEditSkills = function () {
if (!skid.rating == null)
skid.rating = 0;
var yuiEl = new YAHOO.util.Element();
var els = yuiEl.getElementsByClassName('skillsRating');
var els = yuiEl.getElementsByClassName('skillsFormRatingControl');

// select the rating radio button
for( var i in els) {
Expand All @@ -79,18 +72,19 @@ SkillsPlugin.addEditSkills = function () {

SkillsPlugin.main.lockForm();
SkillsPlugin.main.get(
"getSkillDetails?path1=" + encodeURIComponent(cat)
+ ((subcat < 0) ? '' : ";path2=" + encodeURIComponent(subcat))
+ ";path3=" + encodeURIComponent(skill),
"getSkillDetails?path="
+ encodeURIComponent(cat + "/" + skill),
cbSkillDetails, cat, skill);
},

// submits the form
submit: function() {
SkillsPlugin.main.submit(
'addEditSkill', 'addedit-skill-form',
"addedit-skills-message",
_resetForm);
function (o) {
SkillsPlugin.main.displayMessage(
o.responseText, "addedit-skills-message");
});
},

// clears the comment text field
Expand All @@ -114,26 +108,8 @@ SkillsPlugin.addEditSkills = function () {
}();

// register events
YAHOO.util.Event.onAvailable(
"addedit-category-select",
function () {
SkillsPlugin.main.populateCategorySelect('addedit');
},
SkillsPlugin.addEditSkills, true);

YAHOO.util.Event.addListener(
"addedit-category-select", "change",
function() {
var elSelect = document.getElementById("addedit-subcategory-select");
this.resetSkillDetails();
if (elSelect)
SkillsPlugin.main.populateSubCategorySelect('addedit');
else
SkillsPlugin.main.populateSkillSelect('addedit');
}, SkillsPlugin.addEditSkills, true);

YAHOO.util.Event.addListener(
"addedit-subcategory-select", "change",
function() {
this.resetSkillDetails();
SkillsPlugin.main.populateSkillSelect('addedit');
Expand All @@ -142,21 +118,22 @@ YAHOO.util.Event.addListener(
YAHOO.util.Event.addListener(
"addedit-skill-select", "change",
function () {
this.resetSkillDetails();
this.populateSkillDetails();
},
SkillsPlugin.addEditSkills, true);

YAHOO.util.Event.addListener(
"addedit-skill-comment", "keyup",
this.commentKeyPress,
SkillsPlugin.addEditSkills.commentKeyPress,
SkillsPlugin.addEditSkills, true);

YAHOO.util.Event.addListener(
"addedit-skill-comment-clear", "click",
this.clearComment,
SkillsPlugin.addEditSkills.clearComment,
SkillsPlugin.addEditSkills, true);

YAHOO.util.Event.addListener(
"addedit-skill-submit", "click",
function () { this.submit() },
SkillsPlugin.addEditSkills.submit,
SkillsPlugin.addEditSkills, true);

0 comments on commit e3d292d

Please sign in to comment.