fixing more Matrix problems
This commit is contained in:
parent
e5daa223ed
commit
05bb43852d
5 changed files with 200 additions and 50 deletions
|
|
@ -719,6 +719,21 @@ sub www_click {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_deleteStickied ( )
|
||||
|
||||
Sets the sort scratch variable.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_deleteStickied {
|
||||
|
||||
my $self = shift;
|
||||
$self->getParent->www_deleteStickied();
|
||||
return undef;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_edit ( )
|
||||
|
||||
Web facing method which is the default edit page
|
||||
|
|
@ -757,9 +772,9 @@ sub www_getAttributes {
|
|||
my @results;
|
||||
my @categories = keys %{$self->getParent->getCategories};
|
||||
foreach my $category (@categories) {
|
||||
push(@results,{label=>$category,fieldType=>'category'});
|
||||
my $attributes;
|
||||
my @attribute_loop;
|
||||
#my $categoryLoopName = $self->session->url->urlize($category)."_loop";
|
||||
$attributes = $db->read("select * from Matrix_attribute as a
|
||||
left join MatrixListing_attribute as l on (a.attributeId = l.attributeId and l.matrixListingId = ?)
|
||||
where category =? and a.assetId = ?",
|
||||
|
|
@ -770,13 +785,14 @@ sub www_getAttributes {
|
|||
if ($attribute->{fieldType} eq 'MatrixCompare'){
|
||||
$attribute->{value} = WebGUI::Form::MatrixCompare->new($self->session,$attribute)->getValueAsHtml;
|
||||
}
|
||||
if($session->scratch->get('stickied_'.$attribute->{attributeId})){
|
||||
$attribute->{checked} = 'checked';
|
||||
}
|
||||
else{
|
||||
$attribute->{checked} = '';
|
||||
}
|
||||
push(@results,$attribute);
|
||||
}
|
||||
#$var->{$categoryLoopName} = \@attribute_loop;
|
||||
#push(@{$var->{category_loop}},{
|
||||
# categoryLabel => $category,
|
||||
# attribute_loop => \@attribute_loop,
|
||||
#});
|
||||
}
|
||||
my $jsonOutput;
|
||||
$jsonOutput->{ResultSet} = {Result=>\@results};
|
||||
|
|
@ -964,7 +980,20 @@ sub www_sendEmail {
|
|||
$self->prepareView;
|
||||
return $self->view(0,1);
|
||||
}
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_setStickied ( )
|
||||
|
||||
Sets the sort scratch variable.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_setStickied {
|
||||
|
||||
my $self = shift;
|
||||
$self->getParent->www_setStickied();
|
||||
return undef;
|
||||
}
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_view ( )
|
||||
|
|
|
|||
|
|
@ -669,7 +669,7 @@ sub www_compare {
|
|||
|
||||
$var->{javascript} = "<script type='text/javascript'>\n".
|
||||
'var listingIds = new Array('.join(", ",map {'"'.$_.'"'} @listingIds).");\n".
|
||||
'var responseFields = new Array("attributeId", "name", '.join(", ",map {'"'.$_.'"'} @responseFields).");\n".
|
||||
'var responseFields = new Array("attributeId", "name", "fieldType", "checked", '.join(", ",map {'"'.$_.'"'} @responseFields).");\n".
|
||||
"var maxComparisons = ".$maxComparisons.";\n".
|
||||
"</script>";
|
||||
|
||||
|
|
@ -696,6 +696,24 @@ sub www_deleteAttribute {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_deleteStickied ( )
|
||||
|
||||
Sets the sort scratch variable.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_deleteStickied {
|
||||
|
||||
my $self = shift;
|
||||
|
||||
if(my $attributeId = $self->session->form->process("attributeId")){
|
||||
$self->session->scratch->delete('stickied_'.$attributeId);
|
||||
}
|
||||
return undef;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_editAttribute ( )
|
||||
|
||||
Shows a form to edit or add an attribute.
|
||||
|
|
@ -878,8 +896,13 @@ sub www_getCompareFormData {
|
|||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
my $form = $session->form;
|
||||
my $sort = $session->scratch->get('sort') || $self->get('defaultSort');
|
||||
my $sortDirection = ' asc';
|
||||
|
||||
if ( WebGUI::Utility::isIn($sort),qw(revisionDate score)) {
|
||||
$sortDirection = " desc";
|
||||
}
|
||||
|
||||
my @results;
|
||||
my @listingIds = $self->session->form->checkList("listingId");
|
||||
|
||||
|
|
@ -914,7 +937,7 @@ assetData.revisionDate
|
|||
and status='approved'
|
||||
group by
|
||||
assetData.assetId
|
||||
order by ".$self->get('defaultSort').$sortDirection;
|
||||
order by ".$sort.$sortDirection;
|
||||
|
||||
@results = @{ $session->db->buildArrayRefOfHashRefs($sql,[$self->getId]) };
|
||||
foreach my $result (@results){
|
||||
|
|
@ -988,7 +1011,7 @@ sub www_getCompareListData {
|
|||
|
||||
my $session = $self->session;
|
||||
my (@results,$results,@columnDefs);
|
||||
my $sortDirection = ' asc';
|
||||
#my $sortDirection = ' asc';
|
||||
|
||||
foreach my $listingId (@listingIds){
|
||||
$listingId =~ s/_____/-/g;
|
||||
|
|
@ -1003,6 +1026,7 @@ sub www_getCompareListData {
|
|||
$jsonOutput->{ColumnDefs} = \@columnDefs;
|
||||
|
||||
foreach my $category (keys %{$self->getCategories}) {
|
||||
push(@results,{name=>$category,fieldType=>'category'});
|
||||
my $fields = " a.name, a.fieldType, a.attributeId ";
|
||||
my $from = "from Matrix_attribute a";
|
||||
my $tableCount = "b";
|
||||
|
|
@ -1020,8 +1044,9 @@ sub www_getCompareListData {
|
|||
) });
|
||||
}
|
||||
foreach my $result (@results){
|
||||
unless($result->{fieldType} eq 'category'){
|
||||
foreach my $listingId (@listingIds) {
|
||||
$result->{attributId} =~ s/-/_____/g;
|
||||
$result->{attributeId} =~ s/-/_____/g;
|
||||
my $listingId_safe = $listingId;
|
||||
$listingId_safe =~ s/-/_____/g;
|
||||
if ($result->{fieldType} eq 'MatrixCompare'){
|
||||
|
|
@ -1030,6 +1055,14 @@ sub www_getCompareListData {
|
|||
$result->{$listingId_safe} = WebGUI::Form::MatrixCompare->new( $self->session,
|
||||
{ value=>$result->{$listingId_safe} },defaultValue=>0)->getValueAsHtml;
|
||||
}
|
||||
if($session->scratch->get('stickied_'.$result->{attributeId})){
|
||||
$self->session->errorHandler->warn("found checked stickie: ".$result->{attributeId});
|
||||
$result->{checked} = 'checked';
|
||||
}
|
||||
else{
|
||||
$result->{checked} = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1135,6 +1168,40 @@ sub www_search {
|
|||
return $self->processStyle($self->processTemplate($var,$self->get("searchTemplateId")));
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_setSort ( )
|
||||
|
||||
Sets the sort scratch variable.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_setSort {
|
||||
|
||||
my $self = shift;
|
||||
|
||||
if(my $sort = $self->session->form->process("sort")){
|
||||
$self->session->scratch->set('sort',$sort);
|
||||
}
|
||||
return undef;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_setStickied ( )
|
||||
|
||||
Sets the sort scratch variable.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_setStickied {
|
||||
|
||||
my $self = shift;
|
||||
|
||||
if(my $attributeId = $self->session->form->process("attributeId")){
|
||||
$self->session->scratch->set('stickied_'.$attributeId,1);
|
||||
}
|
||||
return undef;
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -43,25 +43,29 @@ YAHOO.util.Event.addListener(window, "load", function() {
|
|||
this.myDataTable.hideColumn(this.myDataTable.getColumn(3));
|
||||
this.myDataTable.hideColumn(this.myDataTable.getColumn(4));
|
||||
this.myDataTable.hideColumn(this.myDataTable.getColumn(5));
|
||||
|
||||
|
||||
var btnSortByViews = new YAHOO.widget.Button("sortByViews");
|
||||
btnSortByViews.on("click", function(e) {
|
||||
this.myDataTable.sortColumn(this.myDataTable.getColumn(2));
|
||||
this.myDataTable.sortColumn(this.myDataTable.getColumn(2));
|
||||
var request = YAHOO.util.Connect.asyncRequest('POST', "?func=setSort;sort=views");
|
||||
},this,true);
|
||||
|
||||
var btnSortByClicks = new YAHOO.widget.Button("sortByClicks");
|
||||
btnSortByClicks.on("click", function(e) {
|
||||
this.myDataTable.sortColumn(this.myDataTable.getColumn(3));
|
||||
var request = YAHOO.util.Connect.asyncRequest('POST', "?func=setSort;sort=clicks");
|
||||
},this,true);
|
||||
|
||||
var btnSortByCompares = new YAHOO.widget.Button("sortByCompares");
|
||||
btnSortByCompares.on("click", function(e) {
|
||||
this.myDataTable.sortColumn(this.myDataTable.getColumn(4));
|
||||
var request = YAHOO.util.Connect.asyncRequest('POST', "?func=setSort;sort=compares");
|
||||
},this,true);
|
||||
|
||||
var btnSortByUpdated = new YAHOO.widget.Button("sortByUpdated");
|
||||
btnSortByUpdated.on("click", function(e) {
|
||||
this.myDataTable.sortColumn(this.myDataTable.getColumn(5));
|
||||
var request = YAHOO.util.Connect.asyncRequest('POST', "?func=setSort;sort=lastUpdated");
|
||||
},this,true);
|
||||
|
||||
var myCallback = function() {
|
||||
|
|
|
|||
|
|
@ -4,23 +4,39 @@ YAHOO.util.Event.addListener(window, "load", function() {
|
|||
var hideStickies = 0;
|
||||
|
||||
this.formatStickied = function(elCell, oRecord, oColumn, sData) {
|
||||
elCell.innerHTML = "<input type='checkBox' class='stickieCheckbox' id='" + oRecord.getData("attributeId") + "_stickied'>";
|
||||
if(oRecord.getData("fieldType") != 'category'){
|
||||
var innerHTML = "<input type='checkBox' class='stickieCheckbox' id='" + oRecord.getData("attributeId") + "_stickied' name='" + oRecord.getData("attributeId") + "' onChange='setStickied(this)'";
|
||||
if(typeof(oRecord.getData("checked")) != 'undefined' && oRecord.getData("checked") == 'checked'){
|
||||
innerHTML = innerHTML + " checked='checked'";
|
||||
}
|
||||
innerHTML = innerHTML + ">";
|
||||
elCell.innerHTML = innerHTML;
|
||||
}
|
||||
};
|
||||
|
||||
this.formatColors = function(elCell, oRecord, oColumn, sData) {
|
||||
var colorField = oColumn.key + "_compareColor";
|
||||
var color = oRecord.getData(colorField);
|
||||
if(color){
|
||||
Dom.setStyle(elCell.parentNode, "background-color", color);
|
||||
if(oRecord.getData("fieldType") != 'category'){
|
||||
var colorField = oColumn.key + "_compareColor";
|
||||
var color = oRecord.getData(colorField);
|
||||
if(color){
|
||||
Dom.setStyle(elCell.parentNode, "background-color", color);
|
||||
}
|
||||
elCell.innerHTML = sData;
|
||||
}
|
||||
};
|
||||
this.formatLabel = function(elCell, oRecord, oColumn, sData) {
|
||||
if(oRecord.getData("fieldType") == 'category'){
|
||||
elCell.innerHTML = "<b>" +sData + "</b>";
|
||||
}else{
|
||||
elCell.innerHTML = sData;
|
||||
}
|
||||
elCell.innerHTML = sData;
|
||||
};
|
||||
|
||||
YAHOO.widget.DataTable.Formatter.formatColors = this.formatColors;
|
||||
|
||||
var myColumnDefs = [
|
||||
{key:"stickied",formatter:this.formatStickied},
|
||||
{key:"name"}
|
||||
{key:"stickied",formatter:this.formatStickied,label:""},
|
||||
{key:"name",formatter:this.formatLabel,label:""}
|
||||
];
|
||||
|
||||
this.myDataSource = new YAHOO.util.DataSource("?");
|
||||
|
|
@ -106,22 +122,26 @@ YAHOO.util.Event.addListener(window, "load", function() {
|
|||
if(hideStickies == 0){
|
||||
// hide non-selected attributes
|
||||
for(i=0; i<elements.length; i++){
|
||||
var attributeId = elements[i].getData('attributeId');
|
||||
var checkBox = Dom.get(attributeId+"_stickied");
|
||||
if (checkBox.checked == false){
|
||||
elRow = myDataTable.getTrEl(elements[i]);
|
||||
Dom.setStyle(elRow, "display", "none");
|
||||
if(elements[i].getData('fieldType') != 'category'){
|
||||
var attributeId = elements[i].getData('attributeId');
|
||||
var checkBox = Dom.get(attributeId+"_stickied");
|
||||
if (checkBox.checked == false){
|
||||
elRow = myDataTable.getTrEl(elements[i]);
|
||||
Dom.setStyle(elRow, "display", "none");
|
||||
}
|
||||
}
|
||||
}
|
||||
hideStickies = 1;
|
||||
}else{
|
||||
// show all attributes
|
||||
for(i=0; i<elements.length; i++){
|
||||
var attributeId = elements[i].getData('attributeId');
|
||||
var checkBox = Dom.get(attributeId+"_stickied");
|
||||
if (checkBox.checked == false){
|
||||
elRow = myDataTable.getTrEl(elements[i]);
|
||||
Dom.setStyle(elRow, "display", "table-row");
|
||||
if(elements[i].getData('fieldType') != 'category'){
|
||||
var attributeId = elements[i].getData('attributeId');
|
||||
var checkBox = Dom.get(attributeId+"_stickied");
|
||||
if (checkBox.checked == false){
|
||||
elRow = myDataTable.getTrEl(elements[i]);
|
||||
Dom.setStyle(elRow, "display", "table-row");
|
||||
}
|
||||
}
|
||||
}
|
||||
hideStickies = 0;
|
||||
|
|
@ -131,5 +151,14 @@ YAHOO.util.Event.addListener(window, "load", function() {
|
|||
};
|
||||
});
|
||||
|
||||
function setStickied (checkbox) {
|
||||
if(checkbox.checked == true){
|
||||
var request = YAHOO.util.Connect.asyncRequest('POST', "?func=setStickied;attributeId="+checkbox.name);
|
||||
}else{
|
||||
var request = YAHOO.util.Connect.asyncRequest('POST', "?func=deleteStickied;attributeId="+checkbox.name);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -4,12 +4,26 @@ YAHOO.util.Event.addListener(window, "load", function() {
|
|||
var hideStickies = 0;
|
||||
|
||||
this.formatStickied = function(elCell, oRecord, oColumn, sData) {
|
||||
elCell.innerHTML = "<input type='checkBox' class='stickieCheckbox' id='" + oRecord.getData("attributeId") + "_stickied'>";
|
||||
if(oRecord.getData("fieldType") != 'category'){
|
||||
var innerHTML = "<input type='checkBox' class='stickieCheckbox' id='" + oRecord.getData("attributeId") + "_stickied' name='" + oRecord.getData("attributeId") + "' onChange='setStickied(this)'";
|
||||
if(typeof(oRecord.getData("checked")) != 'undefined' && oRecord.getData("checked") == 'checked'){
|
||||
innerHTML = innerHTML + " checked='checked'";
|
||||
}
|
||||
innerHTML = innerHTML + ">";
|
||||
elCell.innerHTML = innerHTML;
|
||||
}
|
||||
};
|
||||
this.formatLabel = function(elCell, oRecord, oColumn, sData) {
|
||||
if(oRecord.getData("fieldType") == 'category'){
|
||||
elCell.innerHTML = "<b>" +sData + "</b>";
|
||||
}else{
|
||||
elCell.innerHTML = sData;
|
||||
}
|
||||
};
|
||||
|
||||
var myColumnDefs = [
|
||||
{key:"stickied",formatter:this.formatStickied},
|
||||
{key:"label"},
|
||||
{key:"stickied",formatter:this.formatStickied,label:""},
|
||||
{key:"label",formatter:this.formatLabel},
|
||||
{key:"value"}
|
||||
];
|
||||
|
||||
|
|
@ -18,15 +32,11 @@ YAHOO.util.Event.addListener(window, "load", function() {
|
|||
this.myDataSource.connXhrMode = "queueRequests";
|
||||
this.myDataSource.responseSchema = {
|
||||
resultsList: "ResultSet.Result",
|
||||
fields: ["label","value","attributeId"]
|
||||
fields: ["label","value","attributeId","fieldType","checked"]
|
||||
};
|
||||
|
||||
var uri = "func=getAttributes";
|
||||
|
||||
// for (var i = 0; i < listingIds.length; i++) {
|
||||
// uri = uri+';listingId='+listingIds[i];
|
||||
// }
|
||||
|
||||
var myDataTable = new YAHOO.widget.DataTable("attributes", myColumnDefs,
|
||||
this.myDataSource, {initialRequest:uri});
|
||||
|
||||
|
|
@ -46,36 +56,38 @@ YAHOO.util.Event.addListener(window, "load", function() {
|
|||
this.onDataReturnAppendRows.apply(this,arguments);
|
||||
};
|
||||
|
||||
|
||||
var callback2 = {
|
||||
success : myCallback,
|
||||
failure : myCallback,
|
||||
scope : myDataTable
|
||||
};
|
||||
|
||||
|
||||
var btnStickied = new YAHOO.widget.Button("stickied");
|
||||
btnStickied.on("click", function(e) {
|
||||
var elements = myDataTable.getRecordSet().getRecords();
|
||||
if(hideStickies == 0){
|
||||
// hide non-selected attributes
|
||||
for(i=0; i<elements.length; i++){
|
||||
var attributeId = elements[i].getData('attributeId');
|
||||
var checkBox = Dom.get(attributeId+"_stickied");
|
||||
if (checkBox.checked == false){
|
||||
elRow = myDataTable.getTrEl(elements[i]);
|
||||
Dom.setStyle(elRow, "display", "none");
|
||||
if(elements[i].getData('fieldType') != 'category'){
|
||||
var attributeId = elements[i].getData('attributeId');
|
||||
var checkBox = Dom.get(attributeId+"_stickied");
|
||||
if (checkBox.checked == false){
|
||||
elRow = myDataTable.getTrEl(elements[i]);
|
||||
Dom.setStyle(elRow, "display", "none");
|
||||
}
|
||||
}
|
||||
}
|
||||
hideStickies = 1;
|
||||
}else{
|
||||
// show all attributes
|
||||
for(i=0; i<elements.length; i++){
|
||||
var attributeId = elements[i].getData('attributeId');
|
||||
var checkBox = Dom.get(attributeId+"_stickied");
|
||||
if (checkBox.checked == false){
|
||||
elRow = myDataTable.getTrEl(elements[i]);
|
||||
Dom.setStyle(elRow, "display", "table-row");
|
||||
if(elements[i].getData('fieldType') != 'category'){
|
||||
var attributeId = elements[i].getData('attributeId');
|
||||
var checkBox = Dom.get(attributeId+"_stickied");
|
||||
if (checkBox.checked == false){
|
||||
elRow = myDataTable.getTrEl(elements[i]);
|
||||
Dom.setStyle(elRow, "display", "table-row");
|
||||
}
|
||||
}
|
||||
}
|
||||
hideStickies = 0;
|
||||
|
|
@ -85,5 +97,14 @@ YAHOO.util.Event.addListener(window, "load", function() {
|
|||
};
|
||||
});
|
||||
|
||||
function setStickied (checkbox) {
|
||||
if(checkbox.checked == true){
|
||||
var request = YAHOO.util.Connect.asyncRequest('POST', "?func=setStickied;attributeId="+checkbox.name);
|
||||
}else{
|
||||
var request = YAHOO.util.Connect.asyncRequest('POST', "?func=deleteStickied;attributeId="+checkbox.name);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue