Fixed some yui features in Matrix v2
This commit is contained in:
parent
5169cb5e11
commit
01d2322af6
5 changed files with 140 additions and 40 deletions
|
|
@ -975,23 +975,23 @@ sub install {
|
||||||
my $session = WebGUI::Session->open($home, $config);
|
my $session = WebGUI::Session->open($home, $config);
|
||||||
$session->config->addToArray("assets","WebGUI::Asset::MatrixListing");
|
$session->config->addToArray("assets","WebGUI::Asset::MatrixListing");
|
||||||
$session->db->write("create table MatrixListing (
|
$session->db->write("create table MatrixListing (
|
||||||
assetId varchar(22) binary not null,
|
assetId char(22) binary not null,
|
||||||
revisionDate bigint not null,
|
revisionDate bigint not null,
|
||||||
title varchar(255),
|
screenshots char(22),
|
||||||
screenshots varchar(22),
|
|
||||||
description text,
|
description text,
|
||||||
version varchar(255),
|
version char(255),
|
||||||
views int(11),
|
views int(11),
|
||||||
compares int(11),
|
compares int(11),
|
||||||
clicks int(11),
|
clicks int(11),
|
||||||
viewsLastIp varchar(255),
|
viewsLastIp char(255),
|
||||||
comparesLastIp varchar(255),
|
comparesLastIp char(255),
|
||||||
clicksLastIp varchar(255),
|
clicksLastIp char(255),
|
||||||
lastUpdated int(11),
|
lastUpdated int(11),
|
||||||
maintainer varchar(22),
|
maintainer char(22),
|
||||||
manufacturerName varchar(255),
|
manufacturerName char(255),
|
||||||
manufacturerURL varchar(255),
|
manufacturerURL char(255),
|
||||||
productURL varchar(255),
|
productURL char(255),
|
||||||
|
score int(11),
|
||||||
primary key (assetId, revisionDate)
|
primary key (assetId, revisionDate)
|
||||||
)");
|
)");
|
||||||
$session->db->write("create table MatrixListing_attribute (
|
$session->db->write("create table MatrixListing_attribute (
|
||||||
|
|
|
||||||
|
|
@ -360,6 +360,8 @@ An array of listingIds that should be selected in the compare form.
|
||||||
|
|
||||||
sub getCompareForm {
|
sub getCompareForm {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
|
||||||
|
=cut
|
||||||
my @selectedListingIds = @_;
|
my @selectedListingIds = @_;
|
||||||
|
|
||||||
my (%options, @listings);
|
my (%options, @listings);
|
||||||
|
|
@ -380,12 +382,19 @@ sub getCompareForm {
|
||||||
$options{$listing->getId} = '<a href="'.$listing->getUrl.'">'.$listing->get('title').'</a>';
|
$options{$listing->getId} = '<a href="'.$listing->getUrl.'">'.$listing->get('title').'</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
my $maxComparisons;
|
||||||
my $form = WebGUI::Form::formHeader($self->session,{action=>$self->getUrl})
|
if($self->session->user->isVisitor){
|
||||||
.WebGUI::Form::submit($self->session, {
|
$maxComparisons = $self->get('maxComparisons');
|
||||||
value=>"compare"
|
}
|
||||||
})
|
else{
|
||||||
."<br />"
|
$maxComparisons = $self->get('maxComparisonsPrivileged');
|
||||||
|
}
|
||||||
|
=cut
|
||||||
|
my $form = WebGUI::Form::formHeader($self->session,{action=>$self->getUrl,extras=>'name="doCompare"'})
|
||||||
|
# .WebGUI::Form::submit($self->session, {
|
||||||
|
# value=>"compare"
|
||||||
|
# })
|
||||||
|
# ."<br />"
|
||||||
."<br />"
|
."<br />"
|
||||||
.WebGUI::Form::hidden($self->session, {
|
.WebGUI::Form::hidden($self->session, {
|
||||||
name=>"func",
|
name=>"func",
|
||||||
|
|
@ -399,11 +408,21 @@ sub getCompareForm {
|
||||||
# options=>\%options,
|
# options=>\%options,
|
||||||
# })
|
# })
|
||||||
."<br />"
|
."<br />"
|
||||||
.WebGUI::Form::submit($self->session,{
|
# .WebGUI::Form::submit($self->session,{
|
||||||
value=>"compare"
|
# value=>"compare"
|
||||||
})
|
# })
|
||||||
.WebGUI::Form::formFooter($self->session);
|
.WebGUI::Form::formFooter($self->session);
|
||||||
#.'<div id="compareForm"></div> ';
|
|
||||||
|
my $maxComparisons;
|
||||||
|
if($self->session->user->isVisitor){
|
||||||
|
$maxComparisons = $self->get('maxComparisons');
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$maxComparisons = $self->get('maxComparisonsPrivileged');
|
||||||
|
}
|
||||||
|
$form .= "\n<script type='text/javascript'>\n".
|
||||||
|
'var maxComparisons = '.$maxComparisons.';'.
|
||||||
|
"\n</script>\n";
|
||||||
return $form;
|
return $form;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -501,6 +520,8 @@ sub view {
|
||||||
$var->{isLoggedIn} = ($self->session->user->userId ne "1");
|
$var->{isLoggedIn} = ($self->session->user->userId ne "1");
|
||||||
$var->{addMatrixListing_url} = $self->getUrl('func=add;class=WebGUI::Asset::MatrixListing');
|
$var->{addMatrixListing_url} = $self->getUrl('func=add;class=WebGUI::Asset::MatrixListing');
|
||||||
$var->{compareForm} = $self->getCompareForm;
|
$var->{compareForm} = $self->getCompareForm;
|
||||||
|
$var->{exportAttributes_url} = $self->getUrl('func=exportAttributes');
|
||||||
|
$var->{listAttributes_url} = $self->getUrl('func=listAttributes');
|
||||||
|
|
||||||
# Get the MatrixListing with the most views as an object using getLineage.
|
# Get the MatrixListing with the most views as an object using getLineage.
|
||||||
my ($bestViews_listing) = @{ $self->getLineage(['descendants'], {
|
my ($bestViews_listing) = @{ $self->getLineage(['descendants'], {
|
||||||
|
|
@ -709,16 +730,25 @@ sub www_compare {
|
||||||
$self->session->style->setLink($self->session->url->extras('yui/build/datatable/assets/skins/sam/datatable.css'),
|
$self->session->style->setLink($self->session->url->extras('yui/build/datatable/assets/skins/sam/datatable.css'),
|
||||||
{type =>'text/css', rel=>'stylesheet'});
|
{type =>'text/css', rel=>'stylesheet'});
|
||||||
|
|
||||||
|
my $maxComparisons;
|
||||||
|
if($self->session->user->isVisitor){
|
||||||
|
$maxComparisons = $self->get('maxComparisons');
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$maxComparisons = $self->get('maxComparisonsPrivileged');
|
||||||
|
}
|
||||||
|
|
||||||
foreach my $listingId (@listingIds){
|
foreach my $listingId (@listingIds){
|
||||||
my $listingId_safe = $listingId;
|
my $listingId_safe = $listingId;
|
||||||
$listingId_safe =~ s/-/_____/g;
|
$listingId_safe =~ s/-/_____/g;
|
||||||
push(@columnKeys, $listingId_safe);
|
push(@columnKeys, $listingId_safe);
|
||||||
push(@columnKeys, $listingId_safe."_compareColor");
|
push(@columnKeys, $listingId_safe."_compareColor");
|
||||||
}
|
}
|
||||||
|
|
||||||
$var->{javascript} = "<script type='text/javascript'>\n".
|
$var->{javascript} = "<script type='text/javascript'>\n".
|
||||||
'var listingIds = new Array('.join(", ",map {'"'.$_.'"'} @listingIds).');'.
|
'var listingIds = new Array('.join(", ",map {'"'.$_.'"'} @listingIds).");\n".
|
||||||
'var columnKeys = new Array("attributeId", "name", '.join(", ",map {'"'.$_.'"'} @columnKeys).');'.
|
'var columnKeys = new Array("attributeId", "name", '.join(", ",map {'"'.$_.'"'} @columnKeys).");\n".
|
||||||
|
"var maxComparisons = ".$maxComparisons.";\n".
|
||||||
"</script>";
|
"</script>";
|
||||||
|
|
||||||
return $self->processStyle($self->processTemplate($var,$self->get("compareTemplateId")));
|
return $self->processStyle($self->processTemplate($var,$self->get("compareTemplateId")));
|
||||||
|
|
@ -921,6 +951,31 @@ sub www_editAttributeSave {
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
|
=head2 www_exportAttributes ( )
|
||||||
|
|
||||||
|
Exports search attributes as csv.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub www_exportAttributes {
|
||||||
|
my $self = shift;
|
||||||
|
my $session = $self->session;
|
||||||
|
my $output = WebGUI::Text::joinCSV("name","description","category");
|
||||||
|
|
||||||
|
my $attributes = $session->db->read("select name, description, category
|
||||||
|
from Matrix_attribute where assetId = ? order by category, name",[$self->getId]);
|
||||||
|
|
||||||
|
while (my $attribute = $attributes->hashRef) {
|
||||||
|
$output .= "\n".WebGUI::Text::joinCSV($attribute->{name},$attribute->{description},$attribute->{category});
|
||||||
|
}
|
||||||
|
my $fileName = "export_matrix_attributes.csv";
|
||||||
|
$self->session->http->setFilename($fileName,"application/octet-stream");
|
||||||
|
$self->session->http->sendHeader;
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 www_getCompareFormData ( )
|
=head2 www_getCompareFormData ( )
|
||||||
|
|
||||||
Returns the compare form data as JSON.
|
Returns the compare form data as JSON.
|
||||||
|
|
@ -1255,14 +1310,14 @@ sub install {
|
||||||
primary key (assetId, revisionDate)
|
primary key (assetId, revisionDate)
|
||||||
)");
|
)");
|
||||||
$session->db->write("create table Matrix_attribute (
|
$session->db->write("create table Matrix_attribute (
|
||||||
assetId varchar(22) binary not null,
|
assetId char(22) binary not null,
|
||||||
attributeId varchar(22) binary not null,
|
attributeId char(22) binary not null,
|
||||||
name varchar(255) not null,
|
name char(255) not null,
|
||||||
description text,
|
description text,
|
||||||
fieldType varchar(255) not null default 'MatrixField',
|
fieldType char(255) not null default 'MatrixCompare',
|
||||||
category varchar(22) not null,
|
category char(22) not null,
|
||||||
options text,
|
options text,
|
||||||
defaultValue varchar(255),
|
defaultValue char(255),
|
||||||
primary key (attributeId)
|
primary key (attributeId)
|
||||||
)");
|
)");
|
||||||
$session->var->end;
|
$session->var->end;
|
||||||
|
|
|
||||||
|
|
@ -82,19 +82,40 @@ YAHOO.util.Event.addListener(window, "load", function() {
|
||||||
// compareCheckBoxes[i].onchange = compareFormButton;
|
// compareCheckBoxes[i].onchange = compareFormButton;
|
||||||
//}
|
//}
|
||||||
|
|
||||||
};
|
var btnCompare = new YAHOO.widget.Button("compare",{disabled:true,id:"compareButton"});
|
||||||
});
|
btnCompare.on("click", function(e) {
|
||||||
function compareFormButton () {
|
alert('bla');
|
||||||
|
window.document.forms['doCompare'].submit();
|
||||||
|
},this,true);
|
||||||
|
|
||||||
|
window.compareFormButton = function() {
|
||||||
var compareCheckBoxes = YAHOO.util.Dom.getElementsByClassName('compareCheckBox','input');
|
var compareCheckBoxes = YAHOO.util.Dom.getElementsByClassName('compareCheckBox','input');
|
||||||
//alert(compareCheckBoxes.length);
|
|
||||||
var checked = 0;
|
var checked = 0;
|
||||||
for (var i = compareCheckBoxes.length; i--; ) {
|
for (var i = compareCheckBoxes.length; i--; ) {
|
||||||
if(compareCheckBoxes[i].checked){
|
if(compareCheckBoxes[i].checked){
|
||||||
checked++;
|
checked++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//alert(checked);
|
if (checked > 1 && checked < maxComparisons){
|
||||||
|
btnCompare.set("disabled",false);
|
||||||
|
}else{
|
||||||
|
btnCompare.set("disabled",true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
// function compareFormButton () {
|
||||||
|
// var compareCheckBoxes = YAHOO.util.Dom.getElementsByClassName('compareCheckBox','input');
|
||||||
|
//alert(compareCheckBoxes.length);
|
||||||
|
// var checked = 0;
|
||||||
|
// for (var i = compareCheckBoxes.length; i--; ) {
|
||||||
|
// if(compareCheckBoxes[i].checked){
|
||||||
|
// checked++;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//alert(checked);
|
||||||
|
// }
|
||||||
|
|
||||||
//function sort() {
|
//function sort() {
|
||||||
// myCompareTable.sortColumn()
|
// myCompareTable.sortColumn()
|
||||||
|
|
|
||||||
|
|
@ -108,9 +108,7 @@ YAHOO.util.Event.addListener(window, "load", function() {
|
||||||
},this,true);
|
},this,true);
|
||||||
|
|
||||||
//btnCompare.set("disabled",true);
|
//btnCompare.set("disabled",true);
|
||||||
alert(btnCompare.get("disabled"));
|
//alert(btnCompare.get("disabled"));
|
||||||
|
|
||||||
|
|
||||||
window.compareFormButton = function() {
|
window.compareFormButton = function() {
|
||||||
var compareCheckBoxes = YAHOO.util.Dom.getElementsByClassName('compareCheckBox','input');
|
var compareCheckBoxes = YAHOO.util.Dom.getElementsByClassName('compareCheckBox','input');
|
||||||
var checked = 0;
|
var checked = 0;
|
||||||
|
|
@ -119,7 +117,8 @@ YAHOO.util.Event.addListener(window, "load", function() {
|
||||||
checked++;
|
checked++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (checked > 1){
|
//alert(maxComparisons);
|
||||||
|
if (checked > 1 && checked < maxComparisons){
|
||||||
btnCompare.set("disabled",false);
|
btnCompare.set("disabled",false);
|
||||||
}else{
|
}else{
|
||||||
btnCompare.set("disabled",true);
|
btnCompare.set("disabled",true);
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,7 @@ YAHOO.util.Event.addListener(window, "load", function() {
|
||||||
myDataTable.getRecordSet().reset();
|
myDataTable.getRecordSet().reset();
|
||||||
this.set("sortedBy", null);
|
this.set("sortedBy", null);
|
||||||
this.onDataReturnAppendRows.apply(this,arguments);
|
this.onDataReturnAppendRows.apply(this,arguments);
|
||||||
|
compareFormButton();
|
||||||
};
|
};
|
||||||
|
|
||||||
var callback2 = {
|
var callback2 = {
|
||||||
|
|
@ -77,19 +78,43 @@ YAHOO.util.Event.addListener(window, "load", function() {
|
||||||
newUri = newUri + ';search_' + attributeSelects[i].id + '=' + attributeSelects[i].value;
|
newUri = newUri + ';search_' + attributeSelects[i].id + '=' + attributeSelects[i].value;
|
||||||
}
|
}
|
||||||
var elements = myDataTable.getRecordSet().getRecords();
|
var elements = myDataTable.getRecordSet().getRecords();
|
||||||
alert(elements.length);
|
|
||||||
for(i=0; i<elements.length; i++){
|
for(i=0; i<elements.length; i++){
|
||||||
elRow = myDataTable.getTrEl(elements[i]);
|
elRow = myDataTable.getTrEl(elements[i]);
|
||||||
Dom.setStyle(elRow, "display", "none");
|
Dom.setStyle(elRow, "display", "none");
|
||||||
}
|
}
|
||||||
|
var compareCheckBoxes = YAHOO.util.Dom.getElementsByClassName('compareCheckBox','input');
|
||||||
|
for (var i = compareCheckBoxes.length; i--; ) {
|
||||||
|
compareCheckBoxes[i].checked = false;
|
||||||
|
}
|
||||||
myDataTable.getRecordSet().deleteRecord(0,elements.length);
|
myDataTable.getRecordSet().deleteRecord(0,elements.length);
|
||||||
myDataSource.sendRequest(newUri,callback2);
|
myDataSource.sendRequest(newUri,callback2);
|
||||||
|
|
||||||
}
|
}
|
||||||
var attributeSelects = YAHOO.util.Dom.getElementsByClassName('attributeSelect','select');
|
var attributeSelects = YAHOO.util.Dom.getElementsByClassName('attributeSelect','select');
|
||||||
for (var i = attributeSelects.length; i--; ) {
|
for (var i = attributeSelects.length; i--; ) {
|
||||||
attributeSelects[i].onchange = reloadCompareForm;
|
attributeSelects[i].onchange = reloadCompareForm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var btnCompare = new YAHOO.widget.Button("compare",{disabled:true,id:"compareButton"});
|
||||||
|
btnCompare.on("click", function(e) {
|
||||||
|
window.document.forms['doCompare'].submit();
|
||||||
|
},this,true);
|
||||||
|
|
||||||
|
window.compareFormButton = function() {
|
||||||
|
var compareCheckBoxes = YAHOO.util.Dom.getElementsByClassName('compareCheckBox','input');
|
||||||
|
var checked = 0;
|
||||||
|
for (var i = compareCheckBoxes.length; i--; ) {
|
||||||
|
if(compareCheckBoxes[i].checked){
|
||||||
|
checked++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
alert(checked);
|
||||||
|
if (checked > 1 && checked < maxComparisons){
|
||||||
|
btnCompare.set("disabled",false);
|
||||||
|
}else{
|
||||||
|
btnCompare.set("disabled",true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue