Compare form on Matrix default view screen is now generated from markup
This commit is contained in:
parent
79db642219
commit
909c8f62ae
3 changed files with 59 additions and 36 deletions
BIN
docs/upgrades/packages-7.7.6/matrix-default-view-template.wgpkg
Normal file
BIN
docs/upgrades/packages-7.7.6/matrix-default-view-template.wgpkg
Normal file
Binary file not shown.
|
|
@ -458,6 +458,54 @@ sub getCompareForm {
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
|
=head2 getListings ( )
|
||||||
|
|
||||||
|
Returns the listings as an arrayRef of hashRefs.
|
||||||
|
|
||||||
|
=head3 sort
|
||||||
|
|
||||||
|
The criterium by which the listings should be sorted.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub getListings {
|
||||||
|
|
||||||
|
my $self = shift;
|
||||||
|
my $session = $self->session;
|
||||||
|
my $sort = shift || $session->scratch->get('matrixSort') || $self->get('defaultSort');
|
||||||
|
|
||||||
|
my $sortDirection = ' desc';
|
||||||
|
if ($sort eq 'title'){
|
||||||
|
$sortDirection = ' asc';
|
||||||
|
}
|
||||||
|
|
||||||
|
my $sql = "
|
||||||
|
select
|
||||||
|
assetData.title,
|
||||||
|
assetData.url,
|
||||||
|
listing.assetId,
|
||||||
|
listing.views,
|
||||||
|
listing.compares,
|
||||||
|
listing.clicks,
|
||||||
|
listing.lastUpdated
|
||||||
|
from asset
|
||||||
|
left join assetData using(assetId)
|
||||||
|
left join MatrixListing as listing on listing.assetId = assetData.assetId and listing.revisionDate =
|
||||||
|
assetData.revisionDate
|
||||||
|
where
|
||||||
|
asset.parentId=?
|
||||||
|
and asset.state='published'
|
||||||
|
and asset.className='WebGUI::Asset::MatrixListing'
|
||||||
|
and assetData.revisionDate = (SELECT max(revisionDate) from assetData where assetId=asset.assetId and status='approved')
|
||||||
|
and status='approved'
|
||||||
|
order by ".$sort.$sortDirection;
|
||||||
|
|
||||||
|
return $session->db->buildArrayRefOfHashRefs($sql,[$self->getId]);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 getEditForm ( )
|
=head2 getEditForm ( )
|
||||||
|
|
||||||
returns the tabform object that will be used in generating the edit page for Matrix.
|
returns the tabform object that will be used in generating the edit page for Matrix.
|
||||||
|
|
@ -544,12 +592,13 @@ sub view {
|
||||||
|
|
||||||
my ($varStatistics,$varStatisticsEncoded);
|
my ($varStatistics,$varStatisticsEncoded);
|
||||||
my $var = $self->get;
|
my $var = $self->get;
|
||||||
|
$var->{listing_loop} = $self->getListings;
|
||||||
$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->{exportAttributes_url} = $self->getUrl('func=exportAttributes');
|
$var->{exportAttributes_url} = $self->getUrl('func=exportAttributes');
|
||||||
$var->{listAttributes_url} = $self->getUrl('func=listAttributes');
|
$var->{listAttributes_url} = $self->getUrl('func=listAttributes');
|
||||||
$var->{search_url} = $self->getUrl('func=search');
|
$var->{search_url} = $self->getUrl('func=search');
|
||||||
|
$var->{compareForm_url} = $self->getUrl();
|
||||||
|
|
||||||
if ($self->canEdit){
|
if ($self->canEdit){
|
||||||
# Get all the MatrixListings that are still pending.
|
# Get all the MatrixListings that are still pending.
|
||||||
|
|
@ -1053,32 +1102,9 @@ sub www_getCompareFormData {
|
||||||
@searchParams_sorted = sort { $b->{value} <=> $a->{value} } @searchParams;
|
@searchParams_sorted = sort { $b->{value} <=> $a->{value} } @searchParams;
|
||||||
}
|
}
|
||||||
|
|
||||||
my $sql = "
|
|
||||||
select
|
|
||||||
assetData.title,
|
|
||||||
assetData.url,
|
|
||||||
listing.assetId,
|
|
||||||
listing.views,
|
|
||||||
listing.compares,
|
|
||||||
listing.clicks,
|
|
||||||
listing.lastUpdated
|
|
||||||
from asset
|
|
||||||
left join assetData using(assetId)
|
|
||||||
left join MatrixListing as listing on listing.assetId = assetData.assetId and listing.revisionDate =
|
|
||||||
assetData.revisionDate
|
|
||||||
where
|
|
||||||
asset.parentId=?
|
|
||||||
and asset.state='published'
|
|
||||||
and asset.className='WebGUI::Asset::MatrixListing'
|
|
||||||
and assetData.revisionDate = (SELECT max(revisionDate) from assetData where assetId=asset.assetId and status='approved')
|
|
||||||
and status='approved'
|
|
||||||
order by ".$sort.$sortDirection;
|
|
||||||
|
|
||||||
my $sth = $session->db->read($sql,[$self->getId]);
|
|
||||||
my @results;
|
my @results;
|
||||||
|
|
||||||
if($form->process("search")){
|
if($form->process("search")){
|
||||||
while (my $result = $sth->hashRef) {
|
while (my $result = $self->getListings) {
|
||||||
my $matrixListing_attributes = $session->db->buildHashRefOfHashRefs("
|
my $matrixListing_attributes = $session->db->buildHashRefOfHashRefs("
|
||||||
select value, fieldType, attributeId from Matrix_attribute
|
select value, fieldType, attributeId from Matrix_attribute
|
||||||
left join MatrixListing_attribute as listing using(attributeId)
|
left join MatrixListing_attribute as listing using(attributeId)
|
||||||
|
|
@ -1105,7 +1131,7 @@ assetData.revisionDate
|
||||||
push @results, $result;
|
push @results, $result;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
while (my $result = $sth->hashRef) {
|
foreach my $result (@{$self->getListings}) {
|
||||||
$result->{assetId} =~ s/-/_____/g;
|
$result->{assetId} =~ s/-/_____/g;
|
||||||
if(WebGUI::Utility::isIn($result->{assetId},@listingIds)){
|
if(WebGUI::Utility::isIn($result->{assetId},@listingIds)){
|
||||||
$result->{checked} = 'checked';
|
$result->{checked} = 'checked';
|
||||||
|
|
@ -1114,7 +1140,6 @@ assetData.revisionDate
|
||||||
push @results, $result;
|
push @results, $result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$sth->finish;
|
|
||||||
|
|
||||||
my $jsonOutput;
|
my $jsonOutput;
|
||||||
$jsonOutput->{ResultSet} = {Result=>\@results};
|
$jsonOutput->{ResultSet} = {Result=>\@results};
|
||||||
|
|
|
||||||
|
|
@ -29,16 +29,14 @@ YAHOO.util.Event.addListener(window, "load", function() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.myDataSource = new YAHOO.util.DataSource(matrixUrl + "?");
|
this.myDataSource = new YAHOO.util.DataSource(YAHOO.util.Dom.get("compareFormTable"));
|
||||||
this.myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON;
|
this.myDataSource.responseType = YAHOO.util.DataSource.TYPE_HTMLTABLE;
|
||||||
this.myDataSource.connXhrMode = "queueRequests";
|
this.myDataSource.responseSchema = {
|
||||||
this.myDataSource.responseSchema = {
|
fields: [{key: "checked"},"assetId","title",{key: "views", parser: "number"},{key: "clicks", parser: "number"},{key: "compares", parser: "number"},{key: "lastUpdated", parser: "number"},"url"]
|
||||||
resultsList: "ResultSet.Result",
|
};
|
||||||
fields: ["title",{key: "views", parser: "number"},{key: "clicks", parser: "number"},{key: "compares", parser: "number"},{key: "checked"},{key: "lastUpdated", parser: "number"},"url","assetId"]
|
|
||||||
};
|
|
||||||
|
|
||||||
this.myDataTable = new YAHOO.widget.DataTable("compareForm", myColumnDefs,
|
this.myDataTable = new YAHOO.widget.DataTable("compareForm", myColumnDefs,
|
||||||
this.myDataSource, {initialRequest:uri});
|
this.myDataSource);
|
||||||
|
|
||||||
this.myDataTable.hideColumn(this.myDataTable.getColumn(2));
|
this.myDataTable.hideColumn(this.myDataTable.getColumn(2));
|
||||||
this.myDataTable.hideColumn(this.myDataTable.getColumn(3));
|
this.myDataTable.hideColumn(this.myDataTable.getColumn(3));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue