cap-sflight
cap-sflight copied to clipboard
Fix deductDiscountEnabled
Fixes this UI glitch:
- Open any travel entry in Object Page
- Do Deduct Discount once
- → Deduct Discount button is erroneously disabled now
- Leave to list page and re-enter Object Page
- → Deduct Discount button is correctly enabled now
This fix is not a nice one though → we should calculate there properties in the client, not in server
I think we should go for calculated fields instead of the programmatically filled field controls: https://github.com/SAP-samples/cap-sflight/pull/50/commits/ebbfe15457ddf58db9be92738648601894bcf295
Fix https://github.com/SAP-samples/cap-sflight/pull/50/commits/75c0f721e0b50c27e4bf25c445d425921fff413c was in general wrong before, I think. With calculated fields it is necessary
Still: the real best practice would be to move all of this to the client. → just learned that Olingo is a blocker for that
todo: java code that sets acceptEnabled, rejectEnabled, deductDiscountEnabled needs to be removed
Hi Robin,
I can reprouce what Steffen reports here, I think it is a backend implementation issue:
The actions decribed trigger this $ batch request:
POST TravelService.deductDiscount {"percent":10}
GET select=deductDiscountEnabled
In all responses, deductDiscountEnabled is null, therefore rendered as inactive: The response must contain trie/falöse, not null.
{"@odata.context":"$metadata#Travel(TravelUUID,deductDiscountEnabled,IsActiveEntity)/$entity","@odata.metadataEtag":"W/"3c18da24a6589c44ae5da0e8317ac0ad35757b6a4b458b5c2b3c694badfa41bf"","@odata.id":"Travel(TravelUUID='75757221a8e4645c17002df03754ab66',IsActiveEntity=true)","TravelUUID":"75757221a8e4645c17002df03754ab66","deductDiscountEnabled":null,"IsActiveEntity":true}
"Travel(TravelUUID='75757221a8e4645c17002df03754ab66',IsActiveEntity=true)","TravelUUID":"75757221a8e4645c17002df03754ab66","deductDiscountEnabled":null,"IsActiveEntity":true}
The responses must contain true/false, not null.
In AcceptRejectHandler.java, the values are set using setUiEnabledFields(). But this is not happening in DeductDiscountHandler.java as far as I can see.
Could you have a look?
Best regards, Roland
So, as far as I understand this PR it would be sufficient to just remove the server side handling in AcceptRejectHandler.java. For the DeductDiscountHandler no code needs to be removed as there was no handler implemented so far.
Yes, that is how I understand it. So we could remove the respective code to get the tests of this PR green, then merge it, and then check whether the problem with the deployed Java app is gone (or there maybe is some other code that has similar issues ...??)
... to make the tests green, all custom code referring to the virtual elements acceptEnabled, rejectEnabled, deductDiscountEnabled has to be removed, as these virtual elements are removed (replaced by calculated fields in the db view)
Simply removing the java code that accesses the removed virtual fields dosn't help:
Caused by: org.h2.jdbc.JdbcSQLFeatureNotSupportedException: Dieses Feature wird nicht unterstⁿtzt: "VIEW"
Feature not supported: "VIEW"; SQL statement:
UPDATE TravelService_Travel SET LastChangedAt = ?, LastChangedBy = ?, TravelStatus_code = ? WHERE TravelUUID = ? [50100-200]
has become obsolete logic has been moved to client via OData annos with expressions