@@ -5,6 +5,65 @@ import handleDownVote from '@salesforce/apex/IdeaListViewComponentController.han
55import { ShowToastEvent } from 'lightning/platformShowToastEvent' ;
66import { refreshApex } from '@salesforce/apex' ;
77
8+ const columns = [
9+ {
10+ label : 'Subject' ,
11+ fieldName : 'ideaUrl' ,
12+ type : 'url' ,
13+ typeAttributes : {
14+ label : { fieldName : 'subject' } ,
15+ } ,
16+ initialWidth : 380 , // Adjust the width as needed
17+ } ,
18+ {
19+ label : 'Product' ,
20+ fieldName : 'productTagUrl' ,
21+ type : 'url' ,
22+ typeAttributes : {
23+ label : { fieldName : 'productTagName' } ,
24+ } ,
25+ } ,
26+ { label : 'Status' , fieldName : 'status' , type : 'text' } ,
27+ {
28+ label : '' ,
29+ fieldName : 'upVoteCount' ,
30+ type : 'number' ,
31+ initialWidth : 10 , // Adjust the width as needed
32+ cellAttributes : { alignment : 'center' }
33+ } ,
34+ {
35+ label : 'Up' ,
36+ type : 'button-icon' ,
37+ initialWidth : 60 , // Adjust the width as needed
38+ typeAttributes : {
39+ iconName : 'utility:like' ,
40+ variant : { fieldName : 'upVoteVariant' } ,
41+ name : 'upvote' ,
42+ alternativeText : 'Up Vote' ,
43+ title : 'Up Vote' ,
44+ } ,
45+ } ,
46+ {
47+ label : '' ,
48+ fieldName : 'downVoteCount' ,
49+ type : 'number' ,
50+ initialWidth : 10 , // Adjust the width as needed
51+ cellAttributes : { alignment : 'center' }
52+ } ,
53+ {
54+ label : 'Down' ,
55+ type : 'button-icon' ,
56+ initialWidth : 60 , // Adjust the width as needed
57+ typeAttributes : {
58+ iconName : 'utility:dislike' ,
59+ variant : { fieldName : 'downVoteVariant' } ,
60+ name : 'downvote' ,
61+ alternativeText : 'Down Vote' ,
62+ title : 'Down Vote' ,
63+ } ,
64+ } ,
65+ ] ;
66+
867export default class IdeaListViewComponent extends LightningElement {
968 @api title = 'Most Popular Ideas' ; // Title set from the property in the .js-meta.xml
1069 @api sourceType = 'All' ; // Default to showing all ideas
@@ -13,6 +72,7 @@ export default class IdeaListViewComponent extends LightningElement {
1372 @api statusFilter = '' ; // New status filter property
1473
1574 ideas = [ ] ;
75+ columns = columns ;
1676 error ;
1777 wiredIdeasResult ;
1878
@@ -37,17 +97,17 @@ export default class IdeaListViewComponent extends LightningElement {
3797 }
3898 }
3999
40- const ideaId = ideaWrapper . idea . Id ;
41- const productTagId = ideaWrapper . idea . Product_Tag__c ;
42- const submittedById = ideaWrapper . idea . Submitted_By__c ;
43-
44100 return {
45- ...ideaWrapper ,
101+ ideaId : ideaWrapper . idea . Id ,
102+ ideaUrl : `/ideaexchange/s/idea/${ ideaWrapper . idea . Id } ` ,
103+ productTagName : ideaWrapper . idea . Product_Tag__r . Name ,
104+ productTagUrl : `/ideaexchange/s/adm-product-tag/${ ideaWrapper . idea . Product_Tag__c } ` ,
105+ status : ideaWrapper . idea . Status__c ,
106+ subject : ideaWrapper . idea . Subject__c , // Use subject as label for the URL
107+ upVoteCount : ideaWrapper . idea . Up__c , // Add upvote count
108+ downVoteCount : ideaWrapper . idea . Down__c , // Add downvote count
46109 upVoteVariant,
47110 downVoteVariant,
48- ideaUrl : `/ideaexchange/s/idea/${ ideaId } ` ,
49- productTagUrl : `/ideaexchange/s/adm-product-tag/${ productTagId } ` ,
50- submittedByUrl : `/ideaexchange/s/profile/${ submittedById } `
51111 } ;
52112 } ) ;
53113
@@ -60,10 +120,20 @@ export default class IdeaListViewComponent extends LightningElement {
60120 }
61121 }
62122
63- handleUpVote ( event ) {
64- const ideaId = event . currentTarget . dataset . id ;
123+ handleRowAction ( event ) {
124+ const actionName = event . detail . action . name ;
125+ const ideaId = event . detail . row . ideaId ;
126+
127+ if ( actionName === 'upvote' ) {
128+ this . handleUpVote ( ideaId ) ;
129+ } else if ( actionName === 'downvote' ) {
130+ this . handleDownVote ( ideaId ) ;
131+ }
132+ }
133+
134+ handleUpVote ( ideaId ) {
65135 console . log ( 'Upvote button clicked for Idea ID:' , ideaId ) ;
66- const ideaWrapper = this . ideas . find ( idea => idea . idea . Id === ideaId ) ;
136+ const ideaWrapper = this . ideas . find ( idea => idea . ideaId === ideaId ) ;
67137 const initialVoteType = ideaWrapper && ideaWrapper . userVote ? ideaWrapper . userVote . Type__c : null ;
68138
69139 handleUpVote ( { ideaId } )
@@ -88,10 +158,9 @@ export default class IdeaListViewComponent extends LightningElement {
88158 } ) ;
89159 }
90160
91- handleDownVote ( event ) {
92- const ideaId = event . currentTarget . dataset . id ;
161+ handleDownVote ( ideaId ) {
93162 console . log ( 'Downvote button clicked for Idea ID:' , ideaId ) ;
94- const ideaWrapper = this . ideas . find ( idea => idea . idea . Id === ideaId ) ;
163+ const ideaWrapper = this . ideas . find ( idea => idea . ideaId === ideaId ) ;
95164 const initialVoteType = ideaWrapper && ideaWrapper . userVote ? ideaWrapper . userVote . Type__c : null ;
96165
97166 handleDownVote ( { ideaId } )
@@ -119,9 +188,9 @@ export default class IdeaListViewComponent extends LightningElement {
119188 showToast ( title , message , variant ) {
120189 console . log ( 'Show toast:' , title , message , variant ) ;
121190 const event = new ShowToastEvent ( {
122- title : title ,
123- message : message ,
124- variant : variant ,
191+ title,
192+ message,
193+ variant,
125194 } ) ;
126195 this . dispatchEvent ( event ) ;
127196 }
0 commit comments