From: <max...@us...> - 2009-07-24 13:54:18
|
Revision: 3865 http://uni-d.svn.sourceforge.net/uni-d/?rev=3865&view=rev Author: max_brod Date: 2009-07-24 13:54:08 +0000 (Fri, 24 Jul 2009) Log Message: ----------- [ICT-1485] Ask confirmation before removing a record. Make the "remove" work in selects with single result - it wasn't working. Some improvements in the Select page. Modified Paths: -------------- trunk/Uni-d/tapestry/src/main/java/be/unid/tapestry/components/navigation/entityUsageMenu/EntityUsageMenu.java trunk/Uni-d/tapestry/src/main/java/be/unid/tapestry/components/select/unidSelectResults/UnidSelectResults.java trunk/Uni-d/tapestry/src/main/java/be/unid/tapestry/pages/shared/AddViewEditManipulation.java trunk/Uni-d/tapestry/src/main/resources/be/unid/tapestry/components/navigation/entityUsageMenu/EntityUsageMenu.html trunk/Uni-d/tapestry/src/main/resources/be/unid/tapestry/components/select/unidSelectResults/UnidSelectResults.html trunk/Uni-d/template/src/main/webapp/translations-common.txt Modified: trunk/Uni-d/tapestry/src/main/java/be/unid/tapestry/components/navigation/entityUsageMenu/EntityUsageMenu.java =================================================================== --- trunk/Uni-d/tapestry/src/main/java/be/unid/tapestry/components/navigation/entityUsageMenu/EntityUsageMenu.java 2009-07-22 08:37:23 UTC (rev 3864) +++ trunk/Uni-d/tapestry/src/main/java/be/unid/tapestry/components/navigation/entityUsageMenu/EntityUsageMenu.java 2009-07-24 13:54:08 UTC (rev 3865) @@ -38,6 +38,8 @@ import java.util.ArrayList; import java.util.List; +import javolution.lang.TextBuilder; + /** * EntityUsageMenu java class. * @@ -318,4 +320,16 @@ { return getCurrentEvent().getType(); } + + public String getButtonOnClick() + { + TextBuilder text = TextBuilder.newInstance(); + if ( getCurrentEvent() == EntityUsageListener.EntityUsageEvent.EVENT_REMOVE ) + { + text.append( "if (!confirm('" ).append( getMessages().getMessage( "ConfirmationRemove" ) ) + .append( "')) {return;}" ); + } + text.append( "this.parentNode.getElementsByTagName('input')[0].click(); " ); + return text.toString(); + } } \ No newline at end of file Modified: trunk/Uni-d/tapestry/src/main/java/be/unid/tapestry/components/select/unidSelectResults/UnidSelectResults.java =================================================================== --- trunk/Uni-d/tapestry/src/main/java/be/unid/tapestry/components/select/unidSelectResults/UnidSelectResults.java 2009-07-22 08:37:23 UTC (rev 3864) +++ trunk/Uni-d/tapestry/src/main/java/be/unid/tapestry/components/select/unidSelectResults/UnidSelectResults.java 2009-07-24 13:54:08 UTC (rev 3865) @@ -69,6 +69,8 @@ import java.util.*; import java.util.List; +import javolution.lang.TextBuilder; + /** * Component to display the results of a select (using the selectObject parameter) or from a calculated list (via directValues). * @@ -358,19 +360,21 @@ { if ( isEditing() ) { - UnidProxy proxyToEdit=UnidProxyAccessor.findUoid( getTableName(), uoid ); - if (proxyToEdit==null) + UnidProxy proxyToEdit = UnidProxyAccessor.findUoid( getTableName(), uoid ); + if ( proxyToEdit == null ) { - log.error("Could not find record with uoid "+uoid); + log.error( "Could not find record with uoid " + uoid ); } else { // so far only needed for this case - if (getEditedFieldDescription().isMultiple() ) + if ( getEditedFieldDescription().isMultiple() ) { - Collection currentValues= (Collection)UnidProxyAccessor.getField( proxyToEdit, getEditedFieldDescription().getName()); - currentValues.remove( getEditedFieldValue()); - UnidProxyAccessor.setField( proxyToEdit,getEditedFieldDescription().getName(), Collection.class, currentValues); + Collection currentValues = (Collection) UnidProxyAccessor + .getField( proxyToEdit, getEditedFieldDescription().getName() ); + currentValues.remove( getEditedFieldValue() ); + UnidProxyAccessor.setField( proxyToEdit, getEditedFieldDescription().getName(), + Collection.class, currentValues ); proxyToEdit.unidUpdate(); } } @@ -765,7 +769,8 @@ } if ( accessR != null ) hasPrefsInDB = true; if ( getSessionUserAdmin().hasAccess( field.getId(), AccessRight.EDITABLE_ACCESS_VIEW ) && - ( accessR == AccessRight.TABLE_PREFERENCE_DISPLAY || ( accessR == null && field.isDisplayedInLists() ) ) ) + ( accessR == AccessRight.TABLE_PREFERENCE_DISPLAY || + ( accessR == null && field.isDisplayedInLists() ) ) ) { displayedFields.add( field ); } @@ -832,6 +837,30 @@ { return !isEditing(); } + + public String getRemoveButtonOnClick() + { + TextBuilder text = TextBuilder.newInstance(); + text.append("<script language='JavaScript'>\n<!--\n"); + text.append( "function removeButtonOnClick() { return confirm('" ).append( getMessages().getMessage( "ConfirmationRemove" ) ).append( "'); }" ); + text.append("\n-->\n</script>"); + return text.toString(); + } + + public boolean isHavingNoResults() + { + return getSize()==0; + } + + public boolean isHavingOneResult() + { + return getSize()==1; + } + + public String getRowId() + { + return getRowProxy().getUOID().getId(); + } } class FakeGmField Modified: trunk/Uni-d/tapestry/src/main/java/be/unid/tapestry/pages/shared/AddViewEditManipulation.java =================================================================== --- trunk/Uni-d/tapestry/src/main/java/be/unid/tapestry/pages/shared/AddViewEditManipulation.java 2009-07-22 08:37:23 UTC (rev 3864) +++ trunk/Uni-d/tapestry/src/main/java/be/unid/tapestry/pages/shared/AddViewEditManipulation.java 2009-07-24 13:54:08 UTC (rev 3865) @@ -31,6 +31,7 @@ import be.unid.tapestry.pages.view.ViewPage; import be.unid.tapestry.pages.tableManager.TableManagerPage; import be.unid.tapestry.pages.select.SelectPage; +import be.unid.tapestry.pages.select.SelectPageParams; import be.unid.tapestry.pages.add.AddPage; import be.unid.tapestry.util.UnidProxyAccessor; @@ -261,7 +262,12 @@ page.getPageParameters().setShowSelect( pageParams.isShowSelect() ); nm.forward( page ); } - + if ( navPage.getPageParameters() instanceof SelectPageParams ) + { + SelectPageParams pageParams = (SelectPageParams) navPage.getPageParameters(); + // remove proxy + pageParams.getProxy().removeEntityBean(); + } } public static synchronized void doClone( NavigationablePage navPage, UnidProxy proxy, String tablenName ) Modified: trunk/Uni-d/tapestry/src/main/resources/be/unid/tapestry/components/navigation/entityUsageMenu/EntityUsageMenu.html =================================================================== --- trunk/Uni-d/tapestry/src/main/resources/be/unid/tapestry/components/navigation/entityUsageMenu/EntityUsageMenu.html 2009-07-22 08:37:23 UTC (rev 3864) +++ trunk/Uni-d/tapestry/src/main/resources/be/unid/tapestry/components/navigation/entityUsageMenu/EntityUsageMenu.html 2009-07-24 13:54:08 UTC (rev 3865) @@ -44,11 +44,9 @@ </span> <span jwcid="@Else"> <span> - <span class="displayNone" jwcid="@NavigationLink" listener="listener:callLinkListener" - parameters="prop:currentEventType"> - <span jwcid="@Insert" value="prop:display"/> - </span> - <input type="button" jwcid="@Any" value="prop:display" onclick="window.location=this.parentNode.getElementsByTagName('A')[0].href; " id="prop:generatedId" accesskey="prop:accessKey" title="prop:title"/> + <span class="displayNone" jwcid="@Submit" listener="listener:callLinkListener" + parameters="prop:currentEventType"/> + <input type="button" jwcid="@Any" value="prop:display" onclick="prop:buttonOnClick" id="prop:generatedId" accesskey="prop:accessKey" title="prop:title"/> </span> </span> Modified: trunk/Uni-d/tapestry/src/main/resources/be/unid/tapestry/components/select/unidSelectResults/UnidSelectResults.html =================================================================== --- trunk/Uni-d/tapestry/src/main/resources/be/unid/tapestry/components/select/unidSelectResults/UnidSelectResults.html 2009-07-22 08:37:23 UTC (rev 3864) +++ trunk/Uni-d/tapestry/src/main/resources/be/unid/tapestry/components/select/unidSelectResults/UnidSelectResults.html 2009-07-24 13:54:08 UTC (rev 3865) @@ -32,22 +32,23 @@ @version $Revision$ </span> -<span class="displayError" jwcid="@Insert" value="ognl:error"/> +<span class="displayError" jwcid="@Insert" value="prop:error"/> <span jwcid="@If" condition="prop:autoRunSelect"> - <span jwcid="@If" condition="ognl:size == 0"> + <span jwcid="@If" condition="prop:havingNoResults"> <span key="NoResults"/> </span> <span jwcid="@Else"> - <span jwcid="@If" condition="ognl:size == 1"> + <span jwcid="@If" condition="prop:havingOneResult"> <span jwcid="unidView"/> </span> <span jwcid="@Else"> + <span jwcid="@Insert" value="prop:removeButtonOnClick" raw="true"/> <fieldset> <span jwcid="@If" condition="prop:previous"> <a href="#" jwcid="@NavigationLink" listener="listener:changePage" - parameters="ognl:{0}"><<</a> + parameters="literal:0"><<</a> </span> <span jwcid="@If" condition="prop:previous"> @@ -97,30 +98,30 @@ <span jwcid="@If" condition="prop:fakeColumn"> <span jwcid="@If" condition="prop:viewColumn"> <a jwcid="@NavigationLink" listener="listener:view" - parameters="ognl:{RowProxy.getUOID().getId()}"> + parameters="prop:rowId"> <img jwcid="@Any" src="asset:imageView" border="0"/> </a> </span> <span jwcid="@If" condition="prop:editColumn"> <a jwcid="@NavigationLink" listener="listener:edit" - parameters="ognl:{RowProxy.getUOID().getId()}"> + parameters="prop:rowId"> <img jwcid="@Any" src="asset:imageEdit" border="0"/> </a> </span> <span jwcid="@If" condition="prop:removeColumn"> <a jwcid="@NavigationLink" listener="listener:remove" - parameters="ognl:{RowProxy.getUOID().getId()}"> + parameters="prop:rowId" onclick="return removeButtonOnClick();"> <img jwcid="@Any" src="asset:imageRemove" border="0"/> </a> </span> <span jwcid="@If" condition="prop:selectColumn"> <a jwcid="@NavigationLink" listener="listener:select" - parameters="ognl:{RowProxy.getUOID().getId()}"> + parameters="prop:rowId"> <img jwcid="@Any" src="asset:imageSelect" border="0"/> </a> </span> <span jwcid="@If" condition="prop:uoidColumn"> - <span jwcid="@Insert" value="ognl:getRowProxy().getUOID().getId()"/> + <span jwcid="@Insert" value="prop:rowId"/> </span> </span> <span jwcid="@Else"> Modified: trunk/Uni-d/template/src/main/webapp/translations-common.txt =================================================================== --- trunk/Uni-d/template/src/main/webapp/translations-common.txt 2009-07-22 08:37:23 UTC (rev 3864) +++ trunk/Uni-d/template/src/main/webapp/translations-common.txt 2009-07-24 13:54:08 UTC (rev 3865) @@ -1084,5 +1084,10 @@ .label.nl Record is niet actief .label.ro Inregistrarea e inactiva .label.fr Cet record n'est pas actif +.key ConfirmationRemove/Uni-d-fixed +.label.en Are you sure? +.label.nl Ben je zeker? +.label.ro Sunteti sigur? +.label.fr Vous êtes sûr? This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |