#assign manageCommentsUrl='jsp/admin/plugins/extend/modules/comment/ManageComments.jsp' />
<#macro operationButton idComment operation title icon color='primary' size=''>
<@aButton color=color size=size href='${manageCommentsUrl}?view=confirmUpdateComment&idComment=${idComment}&operation=${operation}&viewAllResources=${allResources?c}${fromUrlParam}' title=title hideTitle=['all'] buttonIcon=icon />
#macro>
<#assign fromUrlParam><#if from_url?? && from_url?has_content && from_url != "null">&from_url=${from_url}#if>#assign>
<#assign addCommentHref>${manageCommentsUrl}?view=createComment&idExtendableResource=${idExtendableResource}&extendableResourceType=${extendableResourceType}${fromUrlParam}#assign>
<@div class='d-flex justify-content-end gap-2 mb-3'>
<@button type='button' title='#i18n{module.extend.comment.comment_info.labelSearch}' buttonIcon='filter' color='light' params='data-bs-toggle="modal" data-bs-target="#comment-filter-modal"' />
<@aButton href=addCommentHref title='#i18n{module.extend.comment.comment.labelAddComment}' buttonIcon='plus' />
@div>
<@modal id='comment-filter-modal'>
<@modalHeader modalTitle='#i18n{module.extend.comment.comment_info.labelSearch}' />
<@modalBody>
<@tform action='jsp/admin/plugins/extend/ViewExtenderInfo.jsp'>
<@input type='hidden' name='idExtendableResource' value='${idExtendableResource}' />
<@input type='hidden' name='extendableResourceType' value='${extendableResourceType}' />
<@input type='hidden' name='extenderType' value='comment' />
<#if from_url?? && from_url?has_content && from_url != "null"><@input type='hidden' name='from_url' value='${from_url}' />#if>
<@formGroup labelKey='#i18n{module.extend.comment.comment_info.pinned}' labelFor='filterPinned' rows=2>
<@select name='filterPinned' default_value="${filterPinned!''}" items=listPinnedFilter />
@formGroup>
<@formGroup labelKey='#i18n{module.extend.comment.comment_info.important}' labelFor='filterMarkAsImportant' rows=2>
<@select name='filterMarkAsImportant' default_value="${filterMarkAsImportant!''}" items=listMarkAsImportantFilter />
@formGroup>
<@formGroup labelKey='#i18n{module.extend.comment.comment_info.labelPublished}' labelFor='filterState' rows=2>
<@select name='filterState' default_value="${filterState!''}" items=listCommentStates />
@formGroup>
<@formGroup labelKey='#i18n{module.extend.comment.comment_info.labelSort}' labelFor='sorted_attribute_name' rows=2>
<@select name='sorted_attribute_name'>
<@option label='#i18n{module.extend.comment.comment_info.sortByDateModification}' value='date_last_modif' selected=(sorted_attribute_name?? && sorted_attribute_name == "date_last_modif") />
<@option label='#i18n{module.extend.comment.comment_info.sortByDateCreation}' value='date_comment' selected=(sorted_attribute_name?? && sorted_attribute_name == "date_comment") />
@select>
@formGroup>
<@formGroup labelKey='#i18n{module.extend.comment.comment_info.labelSortOrder}' labelFor='asc_sort' rows=2>
<@select name='asc_sort'>
<@option label='#i18n{portal.util.sort.asc}' value='true' selected=(asc_sort?? && asc_sort) />
<@option label='#i18n{portal.util.sort.desc}' value='false' selected=(asc_sort?? && !asc_sort) />
@select>
@formGroup>
<@formGroup rows=2>
<@button type='submit' color='primary' title='#i18n{module.extend.comment.comment_info.labelSearch}' buttonIcon='filter' />
@formGroup>
@tform>
@modalBody>
@modal>
<#if listComments?? && listComments?has_content>
<@manageFeature listClass='d-flex flex-column gap-3'>
<#list listComments as comment>
<#assign itemClass = comment.pinned?then('order-first', '')>
<#assign commentIcon><#if comment.pinned>pin<#elseif comment.isImportant>exclamation-mark<#else>message#if>#assign>
<#assign commentIconBg><#if !comment.published> bg-danger<#elseif comment.isImportant> bg-warning<#elseif comment.pinned>bg-info<#else> bg-primary#if>#assign>
<#assign commentLabel>
<#assign adminClass><#if !comment.isAdminComment> comment#if>#assign>
<@div class="d-flex justify-content-between align-items-center ${adminClass}">
<@div class='fw-bold'>
<@span class='badge ${commentIconBg} text-white me-2'><@icon style=commentIcon />@span><@icon style='user' /> ${comment.name!}
@div>
<@div>
<#if 0 < comment.firstUnpublishedSubComment>
<@tag color='warning' title='#i18n{module.extend.comment.comment_info.unpublishedSubComments}' tagIcon='alert-triangle'>#i18n{module.extend.comment.comment_info.unpublishedSubComments}@tag>
#if>
<#if comment.published><@tag color='success' tagIcon='eye' title='#i18n{module.extend.comment.comment_info.labelPublished}' /><#else><@tag color='danger' tagIcon='eye-off' title='#i18n{module.extend.comment.comment_info.labelUnpublished}' />#if>
<@span class='dt-comment'>${comment.dateComment!?string["dd/MM/yyyy HH:mm"]}@span>
${comment.email!}
@div>
@div>
#assign>
<#assign actions>
<@div class='d-flex flex-wrap gap-1'>
<#assign deleteHref>${manageCommentsUrl}?view=confirmRemoveComment&idComment=${comment.idComment!}&viewAllResources=${allResources?c}${fromUrlParam}#assign>
<@aButton color='danger' href=deleteHref title='#i18n{portal.util.labelDelete}' hideTitle=['all'] buttonIcon='trash' />
<#if comment.published>
<@operationButton idComment=comment.idComment operation='unpublish' color='danger' title='#i18n{module.extend.comment.comment_info.buttonUnpublish}' icon='toggle-right' />
<#else>
<@operationButton idComment=comment.idComment operation='publish' title='#i18n{module.extend.comment.comment_info.buttonPublish}' icon='toggle-left' />
#if>
<#if allowSubComments>
<#assign answerHref>${manageCommentsUrl}?view=createComment&idExtendableResource=${idExtendableResource}&extendableResourceType=${extendableResourceType}&idComment=${comment.idComment}&viewAllResources=${allResources?c}${fromUrlParam}#assign>
<@aButton href=answerHref title='#i18n{module.extend.comment.comment_info.labelAnswer}' hideTitle=['all'] buttonIcon='message-reply' />
#if>
<#if comment.isImportant>
<@operationButton idComment=comment.idComment operation='cancelFlagImportant' color='danger' title='#i18n{module.extend.comment.comment_info.labelCancelFlagImportant}' icon='thumb-down' />
<#else>
<@operationButton idComment=comment.idComment operation='flagImportant' title='#i18n{module.extend.comment.comment_info.labelDoFlagImportant}' icon='thumb-up' />
#if>
<#if comment.pinned>
<@operationButton idComment=comment.idComment operation='cancelPin' color='danger' title='#i18n{module.extend.comment.comment_info.labelCancelPinned}' icon='pinned-off' />
<#else>
<@operationButton idComment=comment.idComment operation='pin' title='#i18n{module.extend.comment.comment_info.labelDoPinned}' icon='pin' />
#if>
@Extender[${comment.idComment},Comment,rating,{show:"button"}]@
<#if comment.listWorkflowActions?? && comment.listWorkflowActions?size gt 0>
<#list comment.listWorkflowActions as action>
<#assign iconStyle><#if action.icon.width!=-1> width="${action.icon.width}" #if><#if action.icon.height!=-1> height="${action.icon.height}"#if>#assign>
<@aButton color='link' href='${manageCommentsUrl}?view=confirmUpdateComment&idComment=${comment.idComment}&id_action=${action.id}&viewAllResources=${allResources?c}${fromUrlParam}' title='${action.name}' hideTitle=['all']>
<@img url='image?resource_type=workflow_icon_img&id=${action.icon.id}' title='${action.name}' alt='${action.name}' params=iconStyle /> <@span class='ms-2'>${action.name}@span>
@aButton>
#list>
#if>
@div>
#assign>
<@manageFeatureItem liClass=itemClass>
<@manageFeatureItemColumn flex=false>
${commentLabel}
<@row class='mb-3'>
@row>
<@row class='mb-3 py-2 border-bottom'>
${actions}
@row>
<#if comment.listSubComments?? && 0 < comment.listSubComments?size>
<#list comment.listSubComments as subComment>
<@div class='border-start border-3 ps-3 mt-3'>
<#assign subCommentIcon><#if subComment.pinned>pin<#elseif subComment.isImportant>exclamation-mark<#else>message#if>#assign>
<#assign subCommentIconBg><#if !subComment.published> bg-danger<#elseif subComment.isImportant> bg-warning<#else> bg-primary#if>#assign>
<#assign subCommentLabel>
<#assign adminClass><#if !subComment.isAdminComment> comment#if>#assign>
<@div class="d-flex justify-content-start align-items-center ${adminClass}">
<@div>
<@span class='badge ${subCommentIconBg} text-white me-2'><@icon style=subCommentIcon />@span><@icon style='user' /> ${subComment.name!}
<@span class='dt-comment'>${subComment.dateComment!?string["dd/MM/yyyy HH:mm"]}@span>
${subComment.email!}
@div>
@div>
#assign>
<#assign subCommentActions>
<@div class='d-flex flex-wrap gap-1'>
<#if subComment.published>
<@operationButton idComment=subComment.idComment operation='unpublish' color='danger' size='sm' title='#i18n{module.extend.comment.comment_info.buttonUnpublish}' icon='toggle-right' />
<#else>
<@operationButton idComment=subComment.idComment operation='publish' size='sm' title='#i18n{module.extend.comment.comment_info.buttonPublish}' icon='toggle-left' />
#if>
<#assign subDeleteHref>${manageCommentsUrl}?view=confirmRemoveComment&idComment=${subComment.idComment!}&viewAllResources=${allResources?c}${fromUrlParam}#assign>
<@aButton color='danger' size='sm' href=subDeleteHref title='#i18n{portal.util.labelDelete}' hideTitle=['all'] buttonIcon='trash' />
<#if 0 < subComment.firstUnpublishedSubComment>
<#assign unpublishedHref>${postBackUrl!}<#if (postBackUrl!)?contains('?')>&<#else>?#if>extenderType=comment&idExtendableResource=${idExtendableResource}&extendableResourceType=${extendableResourceType}&idComment=${subComment.idComment}${fromUrlParam}#comment_${subComment.firstUnpublishedSubComment}#assign>
<@aButton color='warning' size='sm' href=unpublishedHref title='#i18n{module.extend.comment.comment_info.unpublishedSubComments}' />
#if>
@div>
#assign>
${subCommentLabel}
<@row>
@row>
<@row>
${subCommentActions}
@row>
@div>
#list>
#if>
@manageFeatureItemColumn>
@manageFeatureItem>
#list>
@manageFeature>
<@paginationAdmin paginator=paginator combo=1 showcount=0 />
<#else>
<@row>
<@columns>
<@empty title='#i18n{module.extend.comment.comment_info.labelNoComment}' iconName='message-circle-off' subtitle=' ' />
@columns>
@row>
#if>