diff --git a/framework/webtools/config/WebtoolsErrorUiLabels.xml b/framework/webtools/config/WebtoolsErrorUiLabels.xml index 665a0caebc..4ffb96fb84 100644 --- a/framework/webtools/config/WebtoolsErrorUiLabels.xml +++ b/framework/webtools/config/WebtoolsErrorUiLabels.xml @@ -100,6 +100,10 @@ 无法删除(写错误) 無法刪除(寫錯誤) + + Delete succeeded + La suppression a été effectuée: + The entityName was not specified, but is required El nombre de la entidad no fue especificado, pero es requerido diff --git a/framework/webtools/groovyScripts/entity/FindGeneric.groovy b/framework/webtools/groovyScripts/entity/FindGeneric.groovy index 11bbacba75..29d3eb1e66 100644 --- a/framework/webtools/groovyScripts/entity/FindGeneric.groovy +++ b/framework/webtools/groovyScripts/entity/FindGeneric.groovy @@ -41,8 +41,9 @@ if (modelEntity) { ModelReader entityModelReader = delegator.getModelReader() //create the search form with auto-fields-entity String dynamicAutoEntityFieldSearchForm = """ -
+ + """ @@ -81,9 +82,16 @@ if (modelEntity) { dynamicAutoEntitySearchFormRenderer.render(writer, context) context.dynamicAutoEntitySearchForm = writer + // In case of composite pk + String pk = modelEntity.pkNameString() + String res = "" + for (w in pk.split(", ")) { + res = "${res}/\${${w}}" + } + //prepare the result list from performFind String dynamicAutoEntityFieldListForm = """ - @@ -100,10 +108,7 @@ if (modelEntity) { "" } dynamicAutoEntityFieldListForm += """ - - - - + """ diff --git a/framework/webtools/groovyScripts/entity/ViewGeneric.groovy b/framework/webtools/groovyScripts/entity/ViewGeneric.groovy index ea9c05bc3b..36c963d3c5 100644 --- a/framework/webtools/groovyScripts/entity/ViewGeneric.groovy +++ b/framework/webtools/groovyScripts/entity/ViewGeneric.groovy @@ -28,7 +28,6 @@ import org.apache.ofbiz.entity.model.ModelRelation import org.apache.ofbiz.entity.model.ModelKeyMap import org.apache.ofbiz.base.util.UtilFormatOut import org.apache.ofbiz.base.util.UtilMisc -import org.apache.ofbiz.base.util.UtilValidate import java.sql.Timestamp import java.sql.Date import java.sql.Time @@ -58,25 +57,31 @@ context.put("hasAllDelete", hasAllDelete) context.put("hasViewPermission", hasViewPermission) context.put("hasCreatePermission", hasCreatePermission) context.put("hasUpdatePermission", hasUpdatePermission) -context.put("hasDeletePermission" , hasDeletePermission) +context.hasDeletePermission = hasDeletePermission boolean useValue = true -String curFindString = "entityName=" + entityName +String currentFindString = entityName GenericPK findByPK = delegator.makePK(entityName) Iterator pkIterator = entity.getPksIterator() -while (pkIterator.hasNext()) { - ModelField field = pkIterator.next() - ModelFieldType type = delegator.getEntityFieldType(entity, field.getType()) - String fval = parameters.get(field.getName()) - if (fval) { - curFindString = curFindString + "&" + field.getName() + "=" + fval - findByPK.setString(field.getName(), fval) +String fieldValues = parameters.get("pkValues") +HashMap pkNamesValuesMap = new HashMap<>() +if (fieldValues != null) { + Iterator pkParamIterator = Arrays.asList(fieldValues.split("/")).iterator() + while (pkIterator.hasNext() && pkParamIterator.hasNext()) { + ModelField field = pkIterator.next() + String fieldValue = pkParamIterator.next() + if (fieldValue) { + currentFindString += "/" + fieldValue + pkNamesValuesMap[field.getName()] = fieldValue + findByPK.setString(field.getName(), fieldValue) + } } } +parameters << pkNamesValuesMap +context.pkNamesValuesMap = pkNamesValuesMap context.put("findByPk", findByPK.toString()) -curFindString = UtilFormatOut.encodeQuery(curFindString) -context.put("curFindString", curFindString) +context.currentFindString = UtilFormatOut.encodeQuery(currentFindString) GenericValue value = null //only try to find it if this is a valid primary key... @@ -136,7 +141,7 @@ if (value == null && (findByPK.getAllFields().size() > 0)) { } context.put("pkNotFound", pkNotFound) -String lastUpdateMode = parameters.get("UPDATE_MODE") +String lastUpdateMode = parameters.get("restMethod") if ((session.getAttribute("_ERROR_MESSAGE_") != null || request.getAttribute("_ERROR_MESSAGE_") != null) && lastUpdateMode != null && !"DELETE".equals(lastUpdateMode)) { //if we are updating and there is an error, do not use the entity data for the fields, use parameters to get the old value diff --git a/framework/webtools/src/main/java/org/apache/ofbiz/webtools/GenericWebEvent.java b/framework/webtools/src/main/java/org/apache/ofbiz/webtools/GenericWebEvent.java index 635c782885..11e77365f8 100644 --- a/framework/webtools/src/main/java/org/apache/ofbiz/webtools/GenericWebEvent.java +++ b/framework/webtools/src/main/java/org/apache/ofbiz/webtools/GenericWebEvent.java @@ -61,7 +61,9 @@ public class GenericWebEvent { public static String updateGeneric(HttpServletRequest request, HttpServletResponse response) { String entityName = request.getParameter("entityName"); Locale locale = UtilHttp.getLocale(request); - + if (UtilValidate.isEmpty(entityName)) { + entityName = (String) request.getAttribute("entityName"); + } if (UtilValidate.isEmpty(entityName)) { String errMsg = UtilProperties.getMessage(GenericWebEvent.err_resource, "genericWebEvent.entity_name_not_specified", locale) + "."; request.setAttribute("_ERROR_MESSAGE_", errMsg); @@ -95,6 +97,16 @@ public class GenericWebEvent { } String updateMode = request.getParameter("UPDATE_MODE"); + if (updateMode == null && request.getParameter("restMethod") == null) { + updateMode = "CREATE"; + } + if (updateMode == null) { + switch (request.getParameter("restMethod")) { + case "PUT": updateMode = "UPDATE"; break; + case "DELETE": updateMode = "DELETE"; break; + default: updateMode = "CREATE"; break; + } + } if (UtilValidate.isEmpty(updateMode)) { String errMsg = UtilProperties.getMessage(GenericWebEvent.err_resource, "genericWebEvent.update_mode_not_specified", locale) + "."; @@ -156,6 +168,8 @@ public class GenericWebEvent { // Delete actual main entity last, just in case database is set up to do a cascading delete, caches won't get cleared try { delegator.removeByPrimaryKey(findByEntity.getPrimaryKey()); + String confirmMsg = UtilProperties.getMessage(GenericWebEvent.err_resource, "genericWebEvent.delete_succeeded", locale) ; + request.setAttribute("_EVENT_MESSAGE_", confirmMsg); } catch (GenericEntityException e) { String errMsg = UtilProperties.getMessage(GenericWebEvent.err_resource, "genericWebEvent.delete_failed", locale) + ": " + e.toString(); Debug.logWarning(e, errMsg, module); diff --git a/framework/webtools/template/artifactinfo/ArtifactInfo.ftl b/framework/webtools/template/artifactinfo/ArtifactInfo.ftl index 0a900b0f9d..7c4496fd5c 100644 --- a/framework/webtools/template/artifactinfo/ArtifactInfo.ftl +++ b/framework/webtools/template/artifactinfo/ArtifactInfo.ftl @@ -127,7 +127,7 @@ under the License. <#if "entity" == artifactInfo.getType()> - +

Entity Fields

<#list artifactInfo.modelEntity.getFieldsUnmodifiable() as modelField> diff --git a/framework/webtools/template/entity/EntityMaint.ftl b/framework/webtools/template/entity/EntityMaint.ftl index 3da728ed98..c12f42b68d 100644 --- a/framework/webtools/template/entity/EntityMaint.ftl +++ b/framework/webtools/template/entity/EntityMaint.ftl @@ -79,21 +79,13 @@ under the License. ${anchor}>${entity.entityName}<#if entity.viewEntity == 'Y'> (${uiLabelMap.WebtoolsEntityView}) <#assign anchor=""> <#if right_col> diff --git a/framework/webtools/template/entity/EntityRefMain.ftl b/framework/webtools/template/entity/EntityRefMain.ftl index dbebc7da93..7267c1380e 100644 --- a/framework/webtools/template/entity/EntityRefMain.ftl +++ b/framework/webtools/template/entity/EntityRefMain.ftl @@ -63,7 +63,7 @@ under the License.
${entity.title}  <#if !forstatic> - [${uiLabelMap.WebtoolsViewData}] + [${uiLabelMap.WebtoolsViewData}] <#if !forstatic> [${uiLabelMap.WebtoolsArtifactInfo}] diff --git a/framework/webtools/template/entity/ViewGeneric.ftl b/framework/webtools/template/entity/ViewGeneric.ftl index 6ee882f9f9..216eb63aaa 100644 --- a/framework/webtools/template/entity/ViewGeneric.ftl +++ b/framework/webtools/template/entity/ViewGeneric.ftl @@ -50,15 +50,22 @@ function ShowTab(lname) {

${uiLabelMap.WebtoolsWithPk}: ${findByPk}


- ${uiLabelMap.WebtoolsBackToFindScreen} + ${uiLabelMap.WebtoolsBackToFindScreen} <#if enableEdit = "false"> <#if hasCreatePermission> - ${uiLabelMap.CommonCreate} - ${uiLabelMap.CommonEdit} +
+ + <#if value?has_content> <#if hasDeletePermission> - ${uiLabelMap.WebtoolsDeleteThisValue} +
+ + <#list pkNamesValuesMap.keySet() as pkName> + + + + @@ -104,14 +111,13 @@ function ShowTab(lname) { <#if pkNotFound>

${uiLabelMap.WebtoolsEntityName} ${entityName} ${uiLabelMap.WebtoolsWithPk} ${findByPk} ${uiLabelMap.WebtoolsSpecifiedEntity2}.

-
+ <#assign showFields = true> <#assign alt_row = false>
- <#if entity.viewEntity == 'Y'> - <#if entity.entityPermissionView == 'Y'> - ${uiLabelMap.WebtoolsReln} - ${uiLabelMap.WebtoolsFind} - ${uiLabelMap.WebtoolsAll} - - <#else> - <#if entity.entityPermissionCreate == 'Y'> - ${uiLabelMap.WebtoolsCreate} - - <#if entity.entityPermissionView == 'Y'> - ${uiLabelMap.WebtoolsReln} - ${uiLabelMap.WebtoolsFind} - ${uiLabelMap.WebtoolsAll} - + <#if entity.viewEntity != 'Y' && entity.entityPermissionCreate == 'Y'> + ${uiLabelMap.WebtoolsCreate} + + <#if entity.entityPermissionView == 'Y'> + ${uiLabelMap.WebtoolsReln} + ${uiLabelMap.WebtoolsFind} + ${uiLabelMap.WebtoolsAll}
<#if value?has_content> <#if hasUpdatePermission> <#if newFieldPkList?has_content> - <#list newFieldPkList as field> class="alternate-row"> @@ -131,7 +137,6 @@ function ShowTab(lname) { <#if hasCreatePermission> <#if newFieldPkList?has_content>

${uiLabelMap.WebtoolsYouMayCreateAnEntity}

- <#list newFieldPkList as field> class="alternate-row"> @@ -204,6 +209,7 @@ function ShowTab(lname) { <#assign alt_row = !alt_row> <#if value?has_content> + <#assign button = "${uiLabelMap.CommonUpdate}"> <#else> <#assign button = "${uiLabelMap.CommonCreate}"> @@ -212,7 +218,7 @@ function ShowTab(lname) { diff --git a/framework/webtools/template/entity/ViewRelations.ftl b/framework/webtools/template/entity/ViewRelations.ftl index 55819838a1..00dfd03ba5 100644 --- a/framework/webtools/template/entity/ViewRelations.ftl +++ b/framework/webtools/template/entity/ViewRelations.ftl @@ -29,7 +29,7 @@ under the License.

${uiLabelMap.WebtoolsForEntity}: ${entityName}



${field.name}${field.name}  - ${uiLabelMap.CommonCancel} + ${uiLabelMap.CommonCancel}
@@ -44,7 +44,7 @@ under the License. <#list relations as relation> class="alternate-row"> - +
${relation.title}${relation.relEntityName}${relation.relEntityName} ${relation.type} ${relation.fkName} diff --git a/framework/webtools/webapp/webtools/WEB-INF/controller.xml b/framework/webtools/webapp/webtools/WEB-INF/controller.xml index eaec92b69f..6e4976cdca 100644 --- a/framework/webtools/webapp/webtools/WEB-INF/controller.xml +++ b/framework/webtools/webapp/webtools/WEB-INF/controller.xml @@ -42,6 +42,49 @@ under the License. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -586,6 +629,7 @@ under the License. + diff --git a/framework/webtools/widget/EntityForms.xml b/framework/webtools/widget/EntityForms.xml index 1587fea055..9c37ee3b3e 100644 --- a/framework/webtools/widget/EntityForms.xml +++ b/framework/webtools/widget/EntityForms.xml @@ -59,9 +59,7 @@ under the License. - - - + diff --git a/framework/webtools/widget/EntityScreens.xml b/framework/webtools/widget/EntityScreens.xml index d85270483c..0994a436b5 100644 --- a/framework/webtools/widget/EntityScreens.xml +++ b/framework/webtools/widget/EntityScreens.xml @@ -212,14 +212,9 @@ under the License. - - - - - - - - + + + @@ -266,6 +261,16 @@ under the License. + +
+ + + + + + +
+
diff --git a/framework/webtools/widget/Menus.xml b/framework/webtools/widget/Menus.xml index 0dab5874c0..2cf57d838b 100644 --- a/framework/webtools/widget/Menus.xml +++ b/framework/webtools/widget/Menus.xml @@ -212,19 +212,13 @@ under the License. - - - - + - - - + - - +