Add a find/approve/reject function for product reviews

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1359479 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Hans Bakker
2012-07-10 04:53:20 +00:00
parent 17db70f01a
commit 117d3f409f
10 changed files with 170 additions and 140 deletions
@@ -188,6 +188,12 @@
<value xml:lang="zh">已请求退货。</value>
<value xml:lang="zh_TW">已請求退貨。</value>
</property>
<property key="ProductReviewErrorCouldNotChangeOrderStatusFromTo">
<value xml:lang="de">Status ist keine gültige Änderung: von ${productReview.statusId} nach ${parameters.statusId}</value>
<value xml:lang="en">Status is not a valid change: from ${productReview.statusId} to ${parameters.statusId}</value>
<value xml:lang="fr">Le changement de statut de ${productReview.statusId} à ${parameters.statusId} n'est pas autorisé</value>
<value xml:lang="it">Cambio di stato non è valido: da ${productReview.statusId} a ${parameters.statusId}</value>
</property>
<property key="productSearchEvents.added_param_features">
<value xml:lang="de">${numAdded} Merkmale hinzugefügt mit ID ${productFeatureId}</value>
<value xml:lang="en">Added ${numAdded} features with ID ${productFeatureId}</value>
@@ -22652,6 +22652,17 @@
<value xml:lang="zh">重新索引关键字</value>
<value xml:lang="zh_TW">重新索引關鍵字</value>
</property>
<property key="ProductReviewBy">
<value xml:lang="de">Bewertung durch</value>
<value xml:lang="en">Review By</value>
<value xml:lang="es">Revisión por</value>
<value xml:lang="fr">A approuver par</value>
<value xml:lang="it">Recensito da</value>
<value xml:lang="th">การตรวจสอบโดย</value>
<value xml:lang="vi">Xem xét bởi</value>
<value xml:lang="zh">检查员</value>
<value xml:lang="zh_TW">檢查員</value>
</property>
<property key="ProductReWeighPackage">
<value xml:lang="de">Paket neu wägeny</value>
<value xml:lang="en">Re-Weigh Package</value>
@@ -1236,4 +1236,33 @@ under the License.
</if>
</iterate>
</simple-method>
<simple-method method-name="setProductReviewStatus" short-description="change the product review Status">
<set value="setProductReviewStatus" field="callingMethodName"/>
<set value="UPDATE" field="checkAction"/>
<call-simple-method method-name="checkProductRelatedPermission"/>
<check-errors/>
<entity-one value-field="productReview" entity-name="ProductReview"/>
<if-not-empty field="productReview">
<if-compare-field field="productReview.statusId" to-field="parameters.statusId" operator="not-equals">
<entity-one entity-name="StatusValidChange" value-field="statusChange">
<field-map field-name="statusId" from-field="productReview.statusId"/>
<field-map field-name="statusIdTo" from-field="parameters.statusId"/>
</entity-one>
<if-empty field="statusChange">
<set field="msg" value="Status is not a valid change: from ${productReview.statusId} to ${parameters.statusId}"/>
<log level="error" message="${msg}"/>
<add-error>
<fail-property resource="ProductErrorUiLabels" property="ProductReviewErrorCouldNotChangeOrderStatusFromTo"/>
</add-error>
</if-empty>
</if-compare-field>
</if-not-empty>
<check-errors/>
<set field="productReview.statusId" from-field="parameters.statusId"/>
<store-value value-field="productReview"/>
<field-to-result field="productReview.productReviewId" result-name="productReviewId"/>
</simple-method>
</simple-methods>
@@ -204,6 +204,16 @@ under the License.
<auto-attributes mode="IN" include="pk" optional="false"/>
<auto-attributes mode="IN" include="nonpk" optional="true"/>
</service>
<service name="setProductReviewStatus" engine="simple"
location="component://product/script/org/ofbiz/product/product/ProductServices.xml" invoke="setProductReviewStatus" auth="true">
<description>Updates a product review record</description>
<required-permissions join-type="OR">
<check-permission permission="CATALOG_UPDATE"/>
<check-permission permission="CATALOG_ADMIN"/>
</required-permissions>
<attribute name="productReviewId" type="String" mode="INOUT" optional="false"/>
<attribute name="statusId" type="String" mode="IN" optional="false"/>
</service>
<service name="findProductById" engine="java" auth="true" export="true"
location="org.ofbiz.product.product.ProductServices" invoke="findProductById">
@@ -2377,15 +2377,21 @@ under the License.
</request-map>
<!-- ================ Product Review Requests ================= -->
<request-map uri="pendingReviews">
<security https="true" auth="true"/>
<response name="success" type="view" value="pendingReviews"/>
</request-map>
<request-map uri="updateProductReview">
<security https="true" auth="true"/>
<event type="service-multi" path="" invoke="updateProductReview"/>
<response name="success" type="view" value="pendingReviews"/>
<response name="error" type="view" value="pendingReviews"/>
<event type="service" path="" invoke="updateProductReview"/>
<response name="success" type="request-redirect-noparam" value="FindReviews"/>
<response name="error" type="view" value="FindReviews"/>
</request-map>
<request-map uri="FindReviews">
<security https="true" auth="true"/>
<response name="success" type="view" value="FindReviews"/>
</request-map>
<request-map uri="updateProductReviewStatus">
<security https="true" auth="true"/>
<event type="service" path="" invoke="setProductReviewStatus"/>
<response name="success" type="view" value="FindReviews"/>
<response name="error" type="view" value="FindReviews"/>
</request-map>
<!-- ================ Supplier Product Requests ================= -->
@@ -3175,6 +3181,7 @@ under the License.
<view-map name="EditKeywordThesaurus" type="screen" page="component://product/widget/catalog/ThesaurusScreens.xml#EditKeywordThesaurus"/>
<view-map name="pendingReviews" type="screen" page="component://product/widget/catalog/ReviewScreens.xml#pendingReviews"/>
<view-map name="FindReviews" type="screen" page="component://product/widget/catalog/ReviewScreens.xml#FindReviews"/>
<view-map name="ViewProductOrder" type="screen" page="component://product/widget/catalog/ProductScreens.xml#ViewProductOrder"/>
<view-map name="EditProductCommunicationEvents" type="screen" page="component://product/widget/catalog/ProductScreens.xml#EditProductCommunicationEvents"/>
@@ -1,122 +0,0 @@
<#--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<script language="JavaScript" type="text/javascript">
function changeReviewStatus(statusId) {
document.selectAllForm.statusId.value = statusId;
document.selectAllForm.submit();
}
</script>
<div class="screenlet">
<div class="screenlet-title-bar">
<h3>${uiLabelMap.ProductReviewsPendingApproval}</h3>
</div>
<div class="screenlet-body">
<#if !pendingReviews?has_content>
<h3>${uiLabelMap.ProductReviewsNoPendingApproval}</h3>
<#else>
<form method='post' action='<@ofbizUrl>updateProductReview</@ofbizUrl>' name="selectAllForm">
<input type="hidden" name="_useRowSubmit" value="Y" />
<input type="hidden" name="_checkGlobalScope" value="Y" />
<input type="hidden" name="statusId" value="" />
<div align="right">
<input type="button" value="${uiLabelMap.CommonUpdate}" onclick="javascript:changeReviewStatus('PRR_PENDING')" />
<input type="button" value="${uiLabelMap.ProductPendingReviewUpdateAndApprove}" onclick="javascript:changeReviewStatus('PRR_APPROVED')" />
<input type="button" value="${uiLabelMap.CommonDelete}" onclick="javascript:changeReviewStatus('PRR_DELETED')" />
</div>
<table cellspacing="0" class="basic-table">
<tr class="header-row">
<td><b>${uiLabelMap.ProductPendingReviewDate}</b></td>
<td><b>${uiLabelMap.ProductPendingReviewBy}</b></td>
<td><b>${uiLabelMap.CommonIsAnonymous}</b></td>
<td><b>${uiLabelMap.ProductProductId}</b></td>
<td><b>${uiLabelMap.ProductRating}</b></td>
<td><b>${uiLabelMap.CommonStatus}</b></td>
<td><b>${uiLabelMap.ProductReviews}</b></td>
<td align="right">
<span class="label">${uiLabelMap.CommonAll}</span>
<input type="checkbox" name="selectAll" value="${uiLabelMap.CommonY}" onclick="javascript:toggleAll(this, 'selectAllForm');highlightAllRows(this, 'review_tableRow_', 'selectAllForm');" />
</td>
</tr>
<#assign rowCount = 0>
<#assign rowClass = "2">
<#list pendingReviews as review>
<#if review.userLoginId?has_content>
<#assign postedUserLogin = review.getRelatedOne("UserLogin", false)>
<#if postedUserLogin.partyId?has_content>
<#assign party = postedUserLogin.getRelatedOne("Party", false)>
<#assign partyTypeId = party.get("partyTypeId")>
<#if partyTypeId == "PERSON">
<#assign postedPerson = postedUserLogin.getRelatedOne("Person", false)>
<#else>
<#assign postedPerson = postedUserLogin.getRelatedOne("PartyGroup", false)>
</#if>
</#if>
</#if>
<tr id="review_tableRow_${rowCount}" valign="middle"<#if rowClass == "1"> class="alternate-row"</#if>>
<td>
<input type="hidden" name="productReviewId_o_${rowCount}" value="${review.productReviewId}" />
${review.postedDateTime?if_exists}
</td>
<td>
<#if review.userLoginId?has_content && postedPerson?has_content>
<td>
<#if postedPerson.firstName?has_content && postedPerson.lastName?has_content>
${postedPerson.firstName} ${postedPerson.lastName}
<#else>
${postedPerson.groupName}
</#if>
</td>
<#else>
<td></td>
</#if>
</td>
<td>
<select name='postedAnonymous_o_${rowCount}'>
<option value="${review.postedAnonymous?default("N")}">${review.postedAnonymous?default("N")}</option>
<option value="${review.postedAnonymous?default("N")}">----</option>
<option value="N">${uiLabelMap.CommonN}</option>
<option value="Y">${uiLabelMap.CommonY}</option>
</select>
</td>
<td>${review.getRelatedOne("Product", false).internalName?if_exists}<br /><a class="buttontext" href="<@ofbizUrl>EditProduct?productId=${review.productId}</@ofbizUrl>">${review.productId}</a></td>
<td>
<input type="text" size='3' name="productRating_o_${rowCount}" value="${review.productRating?if_exists?string}" />
</td>
<td>${review.getRelatedOne("StatusItem", false).get("description", locale)}</td>
<td>
<textarea name="productReview_o_${rowCount}" rows="5" cols="30" wrap="hard">${review.productReview?if_exists}</textarea>
</td>
<td align="right">
<input type="checkbox" name="_rowSubmit_o_${rowCount}" value="Y" onclick="javascript:checkToggle(this, 'selectAllForm');highlightRow(this,'review_tableRow_${rowCount}');" />
</td>
</tr>
<#assign rowCount = rowCount + 1>
<#-- toggle the row color -->
<#if rowClass == "2">
<#assign rowClass = "1">
<#else>
<#assign rowClass = "2">
</#if>
</#list>
<input type="hidden" name="_rowCount" value="${rowCount}" />
</table>
</form>
</#if>
</div>
</div>
@@ -27,7 +27,7 @@ under the License.
<menu-item name="pricerules" title="${uiLabelMap.ProductPriceRules}"><link target="FindProductPriceRules"/></menu-item>
<menu-item name="store" title="${uiLabelMap.ProductStores}"><link target="FindProductStore"/></menu-item>
<menu-item name="thesaurus" title="${uiLabelMap.ProductThesaurus}"><link target="editKeywordThesaurus"/></menu-item>
<menu-item name="reviews" title="${uiLabelMap.ProductReviews}"><link target="pendingReviews"/></menu-item>
<menu-item name="reviews" title="${uiLabelMap.ProductReviews}"><link target="FindReviews"/></menu-item>
<menu-item name="configs" title="${uiLabelMap.ProductConfigItems}"><link target="FindProductConfigItems"/></menu-item>
<menu-item name="Subscription" title="${uiLabelMap.ProductSubscriptions}"><link target="FindSubscription"/></menu-item>
<menu-item name="shipping" title="${uiLabelMap.ProductShipping}"><link target="ListShipmentMethodTypes"/></menu-item>
@@ -0,0 +1,84 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<forms xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/widget-form.xsd">
<form name="FindReviews" type="single" target="FindReviews" title="" header-row-style="header-row" default-table-style="basic-table" default-map-name="productReview">
<field name="noConditionFind"><hidden value="Y"/><!-- if this isn't there then with all fields empty no query will be done --></field>
<field name="productId" title="${uiLabelMap.ProductId}"><text-find/></field>
<field name="statusId" title="${uiLabelMap.CommonStatus}">
<drop-down allow-empty="true">
<entity-options entity-name="StatusItem" description="${description}">
<entity-constraint name="statusTypeId" operator="equals" value="PRODUCT_REVIEW_STTS"/>
</entity-options>
</drop-down>
</field>
<field name="productReview" title="${uiLabelMap.ProductReviews}"><text-find/></field>
<field name="submitButton" title="${uiLabelMap.CommonFind}" widget-style="smallSubmit">
<submit button-type="button"/>
</field>
</form>
<form name="ListReviews" type="list" list-name="listIt" target="updateProductReview" title="" paginate-target="FindReviews"
odd-row-style="alternate-row" default-table-style="basic-table hover-bar" header-row-style="header-row-2">
<actions>
<set field="entityName" value="ProductReview"/>
<service service-name="performFind" result-map="result" result-map-list="listIt">
<field-map field-name="inputFields" from-field="requestParameters"/>
<field-map field-name="entityName" from-field="entityName"/>
<field-map field-name="orderBy" value="postedDateTime"/>
<field-map field-name="viewIndex" from-field="viewIndex"/>
<field-map field-name="viewSize" from-field="viewSize"/>
</service>
</actions>
<row-actions>
<entity-and entity-name="UserLoginAndPartyDetails" list="userLoginAndPartyDetails">
<field-map field-name="userLoginId" from-field="userLoginId"/>
</entity-and>
<set field="reviewBy" value="${userLoginAndPartyDetails[0].firstName} ${userLoginAndPartyDetails[0].middleName} ${userLoginAndPartyDetails[0].lastName}"/>
</row-actions>
<field name="productReviewId"><hidden/></field>
<field name="productId">
<hyperlink also-hidden="false" description="${productId}" target="EditProduct">
<parameter param-name="productId"/>
</hyperlink>
</field>
<field name="statusId" title="${uiLabelMap.CommonStatus}"><display-entity entity-name="StatusItem"/></field>
<field name="userLoginId" title="${uiLabelMap.ProductReviewBy}" ><display/></field>
<field name="productRating" use-when="${statusId != 'PRR_DELETED'}"><text/></field>
<field name="productRating" use-when="${statusId == 'PRR_DELETED'}"><text disabled="true"/></field>
<field name="productReview" use-when="${statusId != 'PRR_DELETED'}"><textarea/></field>
<field name="productReview" use-when="${statusId == 'PRR_DELETED'}"><textarea read-only="true"/></field>
<field name="submitButton" title="${uiLabelMap.CommonUpdate}" use-when="${statusId != 'PRR_DELETED'}"><submit button-type="button"/></field>
<field name="approve" widget-style="buttontext" use-when="${statusId == 'PRR_PENDING'}">
<hyperlink target="updateProductReviewStatus" description="${uiLabelMap.FormFieldTitle_approve}" also-hidden="false">
<parameter param-name="statusId" value="PRR_APPROVED"/>
<parameter param-name="productReviewId" from-field="productReviewId"/>
</hyperlink>
</field>
<field name="rejectButton" widget-style="buttontext" use-when="${statusId != 'PRR_DELETED'}">
<hyperlink target="updateProductReviewStatus" description="${uiLabelMap.FormFieldTitle_rejectButton}" also-hidden="false" confirmation-message="Do you want to reject this review?">
<parameter param-name="statusId" value="PRR_DELETED"/>
<parameter param-name="productReviewId" from-field="productReviewId"/>
</hyperlink>
</field>
</form>
</forms>
@@ -45,23 +45,24 @@ under the License.
</widgets>
</section>
</screen>
<screen name="pendingReviews">
<screen name="FindReviews">
<section>
<actions>
<set field="titleProperty" value="ProductReviewsPendingApproval"/>
<set field="titleProperty" value="ProductReviews"/>
<set field="headerItem" value="reviews"/>
<entity-condition entity-name="ProductReview" list="pendingReviews">
<condition-expr field-name="statusId" value="PRR_PENDING"/>
<order-by field-name="+postedDateTime"/>
</entity-condition>
</actions>
<widgets>
<decorator-screen name="CommonReviewDecorator">
<decorator-section name="body">
<platform-specific>
<html><html-template location="component://product/webapp/catalog/reviews/pendingReviews.ftl"/></html>
</platform-specific>
<decorator-screen name="FindScreenDecorator" location="component://common/widget/CommonScreens.xml">
<decorator-section name="search-options">
<include-form name="FindReviews" location="component://product/widget/catalog/ReviewForms.xml"/>
</decorator-section>
<decorator-section name="search-results">
<include-form name="ListReviews" location="component://product/widget/catalog/ReviewForms.xml"/>
</decorator-section>
</decorator-screen>
</decorator-section>
</decorator-screen>
</widgets>
@@ -1688,4 +1688,8 @@ under the License.
<ProductKeyword productId="WG-1111" keyword="chrome" keywordTypeId="KWT_TAG" statusId="KW_APPROVED"/>
<ProductKeyword productId="GZ-1006" keyword="standard" keywordTypeId="KWT_TAG" statusId="KW_APPROVED"/>
<!-- Product review demo -->
<ProductReview productId="GZ-1000" productRating="4.000000" productReview="Good" productReviewId="9000" productStoreId="9000" statusId="PRR_PENDING" userLoginId="DemoCustomer"/>
<ProductReview productId="GZ-2644" productRating="5.000000" productReview="It's useful." productReviewId="9000" productStoreId="9000" statusId="PRR_APPROVED" userLoginId="DemoCustomer"/>
</entity-engine-xml>