Skip to content

Commit ea9cc67

Browse files
committed
Show a meaningful flash warning if trying to add/withdraw an amount of 0 instead of throwing an exception
Fixes issue Part-DB#448
1 parent b5721dc commit ea9cc67

File tree

2 files changed

+51
-39
lines changed

2 files changed

+51
-39
lines changed

src/Controller/PartController.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,12 @@ public function withdrawAddHandler(Part $part, Request $request, EntityManagerIn
414414
throw new \LogicException("The timestamp must not be in the future!");
415415
}
416416

417+
//Ensure that the amount is not null or negative
418+
if ($amount <= 0) {
419+
$this->addFlash('warning', 'part.withdraw.zero_amount');
420+
goto err;
421+
}
422+
417423
try {
418424
switch ($action) {
419425
case "withdraw":

translations/messages.en.xlf

Lines changed: 45 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -11958,115 +11958,115 @@ Please note, that you can not impersonate a disabled user. If you try you will g
1195811958
</segment>
1195911959
</unit>
1196011960
<unit id="2NZFail" name="collection_type.new_element.tooltip">
11961-
<segment state="translated">
11961+
<segment>
1196211962
<source>collection_type.new_element.tooltip</source>
1196311963
<target>This element was newly created and was not persisted to the database yet.</target>
1196411964
</segment>
1196511965
</unit>
1196611966
<unit id="USUaBZ0" name="part.merge.title">
11967-
<segment state="translated">
11967+
<segment>
1196811968
<source>part.merge.title</source>
1196911969
<target>Merge part</target>
1197011970
</segment>
1197111971
</unit>
1197211972
<unit id="sCLZTwA" name="part.merge.title.into">
11973-
<segment state="translated">
11973+
<segment>
1197411974
<source>part.merge.title.into</source>
1197511975
<target>into</target>
1197611976
</segment>
1197711977
</unit>
1197811978
<unit id="nISUoQl" name="part.merge.confirm.title">
11979-
<segment state="translated">
11979+
<segment>
1198011980
<source>part.merge.confirm.title</source>
11981-
<target>Do you really want to merge &lt;b&gt;%other%&lt;/b&gt; into &lt;b&gt;%target%&lt;/b&gt;?</target>
11981+
<target><![CDATA[Do you really want to merge <b>%other%</b> into <b>%target%</b>?]]></target>
1198211982
</segment>
1198311983
</unit>
1198411984
<unit id="qxHNYfX" name="part.merge.confirm.message">
11985-
<segment state="translated">
11985+
<segment>
1198611986
<source>part.merge.confirm.message</source>
11987-
<target>&lt;b&gt;%other%&lt;/b&gt; will be deleted, and the part will be saved with the shown information.</target>
11987+
<target><![CDATA[<b>%other%</b> will be deleted, and the part will be saved with the shown information.]]></target>
1198811988
</segment>
1198911989
</unit>
1199011990
<unit id="BY9.T4F" name="part.info.merge_modal.title">
11991-
<segment state="translated">
11991+
<segment>
1199211992
<source>part.info.merge_modal.title</source>
1199311993
<target>Merge parts</target>
1199411994
</segment>
1199511995
</unit>
1199611996
<unit id="CasQeyD" name="part.info.merge_modal.other_part">
11997-
<segment state="translated">
11997+
<segment>
1199811998
<source>part.info.merge_modal.other_part</source>
1199911999
<target>Other part</target>
1200012000
</segment>
1200112001
</unit>
1200212002
<unit id="96Qzc6H" name="part.info.merge_modal.other_into_this">
12003-
<segment state="translated">
12003+
<segment>
1200412004
<source>part.info.merge_modal.other_into_this</source>
1200512005
<target>Merge other part into this one (delete other part, keep this one)</target>
1200612006
</segment>
1200712007
</unit>
1200812008
<unit id="Oe4cpRH" name="part.info.merge_modal.this_into_other">
12009-
<segment state="translated">
12009+
<segment>
1201012010
<source>part.info.merge_modal.this_into_other</source>
1201112011
<target>Merge this part into other one (delete this part, keep other one)</target>
1201212012
</segment>
1201312013
</unit>
1201412014
<unit id="pO3q5CN" name="part.info.merge_btn">
12015-
<segment state="translated">
12015+
<segment>
1201612016
<source>part.info.merge_btn</source>
1201712017
<target>Merge part</target>
1201812018
</segment>
1201912019
</unit>
1202012020
<unit id="efgWRwB" name="part.update_part_from_info_provider.btn">
12021-
<segment state="translated">
12021+
<segment>
1202212022
<source>part.update_part_from_info_provider.btn</source>
1202312023
<target>Update part from info providers</target>
1202412024
</segment>
1202512025
</unit>
1202612026
<unit id="n6_Ec0h" name="info_providers.update_part.title">
12027-
<segment state="translated">
12027+
<segment>
1202812028
<source>info_providers.update_part.title</source>
1202912029
<target>Update existing part from info provider</target>
1203012030
</segment>
1203112031
</unit>
1203212032
<unit id="lkIVIWr" name="part.merge.flash.please_review">
12033-
<segment state="translated">
12033+
<segment>
1203412034
<source>part.merge.flash.please_review</source>
1203512035
<target>Data not saved yet. Review the changes and click save to persist the new data.</target>
1203612036
</segment>
1203712037
</unit>
1203812038
<unit id="0nL5IhK" name="user.edit.flash.permissions_fixed">
12039-
<segment state="translated">
12039+
<segment>
1204012040
<source>user.edit.flash.permissions_fixed</source>
1204112041
<target>Permissions required by other permissions were missing. This was corrected. Please check if the permissions are as you intended.</target>
1204212042
</segment>
1204312043
</unit>
1204412044
<unit id="gjo2ZK7" name="permission.legend.dependency_note">
12045-
<segment state="translated">
12045+
<segment>
1204612046
<source>permission.legend.dependency_note</source>
1204712047
<target>Please note that some permission operations depend on each other. If you encounter a warning that missing permissions were corrected and a permission was set to allow again, you have to set the dependent operation to forbid too. The dependents can normally found right of an operation.</target>
1204812048
</segment>
1204912049
</unit>
1205012050
<unit id="VFdWqOX" name="log.part_stock_changed.timestamp">
12051-
<segment state="translated">
12051+
<segment>
1205212052
<source>log.part_stock_changed.timestamp</source>
1205312053
<target>Timestamp</target>
1205412054
</segment>
1205512055
</unit>
1205612056
<unit id="Hj7NX8C" name="part.info.withdraw_modal.timestamp">
12057-
<segment state="translated">
12057+
<segment>
1205812058
<source>part.info.withdraw_modal.timestamp</source>
1205912059
<target>Action timestamp</target>
1206012060
</segment>
1206112061
</unit>
1206212062
<unit id="USYGK0J" name="part.info.withdraw_modal.timestamp.hint">
12063-
<segment state="translated">
12063+
<segment>
1206412064
<source>part.info.withdraw_modal.timestamp.hint</source>
1206512065
<target>This field allows you to specify the real date, when the stock operation actually was performed, and not just when it was logged. This value is saved in the extra field of the log entry.</target>
1206612066
</segment>
1206712067
</unit>
1206812068
<unit id="GIR36qJ" name="part.info.withdraw_modal.delete_lot_if_empty">
12069-
<segment state="translated">
12069+
<segment>
1207012070
<source>part.info.withdraw_modal.delete_lot_if_empty</source>
1207112071
<target>Delete this lot, if it becomes empty</target>
1207212072
</segment>
@@ -12078,112 +12078,118 @@ Please note, that you can not impersonate a disabled user. If you try you will g
1207812078
</segment>
1207912079
</unit>
1208012080
<unit id="9O_yLQy" name="eda_info.reference_prefix.placeholder">
12081-
<segment state="translated">
12081+
<segment>
1208212082
<source>eda_info.reference_prefix.placeholder</source>
1208312083
<target>e.g. R</target>
1208412084
</segment>
1208512085
</unit>
1208612086
<unit id="3nLUWrL" name="eda_info.reference_prefix">
12087-
<segment state="translated">
12087+
<segment>
1208812088
<source>eda_info.reference_prefix</source>
1208912089
<target>Reference prefix</target>
1209012090
</segment>
1209112091
</unit>
1209212092
<unit id="OTQU79e" name="eda_info.kicad_section.title">
12093-
<segment state="translated">
12093+
<segment>
1209412094
<source>eda_info.kicad_section.title</source>
1209512095
<target>KiCad specific settings</target>
1209612096
</segment>
1209712097
</unit>
1209812098
<unit id="_Z4ARu6" name="eda_info.value">
12099-
<segment state="translated">
12099+
<segment>
1210012100
<source>eda_info.value</source>
1210112101
<target>Value</target>
1210212102
</segment>
1210312103
</unit>
1210412104
<unit id="k5gOKhU" name="eda_info.value.placeholder">
12105-
<segment state="translated">
12105+
<segment>
1210612106
<source>eda_info.value.placeholder</source>
1210712107
<target>e.g. 100n</target>
1210812108
</segment>
1210912109
</unit>
1211012110
<unit id="VphdbQ9" name="eda_info.exclude_from_bom">
12111-
<segment state="translated">
12111+
<segment>
1211212112
<source>eda_info.exclude_from_bom</source>
1211312113
<target>Exclude part from BOM</target>
1211412114
</segment>
1211512115
</unit>
1211612116
<unit id="jDHzKDL" name="eda_info.exclude_from_board">
12117-
<segment state="translated">
12117+
<segment>
1211812118
<source>eda_info.exclude_from_board</source>
1211912119
<target>Exclude part from PCB/Board</target>
1212012120
</segment>
1212112121
</unit>
1212212122
<unit id="t3P3j0i" name="eda_info.exclude_from_sim">
12123-
<segment state="translated">
12123+
<segment>
1212412124
<source>eda_info.exclude_from_sim</source>
1212512125
<target>Exclude part from simulation</target>
1212612126
</segment>
1212712127
</unit>
1212812128
<unit id="P6keLR_" name="eda_info.kicad_symbol">
12129-
<segment state="translated">
12129+
<segment>
1213012130
<source>eda_info.kicad_symbol</source>
1213112131
<target>KiCad schematic symbol</target>
1213212132
</segment>
1213312133
</unit>
1213412134
<unit id="k_xjHgN" name="eda_info.kicad_symbol.placeholder">
12135-
<segment state="translated">
12135+
<segment>
1213612136
<source>eda_info.kicad_symbol.placeholder</source>
1213712137
<target>e.g. Transistor_BJT:BC547</target>
1213812138
</segment>
1213912139
</unit>
1214012140
<unit id="TAm88A8" name="eda_info.kicad_footprint">
12141-
<segment state="translated">
12141+
<segment>
1214212142
<source>eda_info.kicad_footprint</source>
1214312143
<target>KiCad footprint</target>
1214412144
</segment>
1214512145
</unit>
1214612146
<unit id="y2hGwZr" name="eda_info.kicad_footprint.placeholder">
12147-
<segment state="translated">
12147+
<segment>
1214812148
<source>eda_info.kicad_footprint.placeholder</source>
1214912149
<target>e.g. Package_TO_SOT_THT:TO-92</target>
1215012150
</segment>
1215112151
</unit>
1215212152
<unit id="2kt7qP7" name="part.edit.tab.eda">
12153-
<segment state="translated">
12153+
<segment>
1215412154
<source>part.edit.tab.eda</source>
1215512155
<target>EDA information</target>
1215612156
</segment>
1215712157
</unit>
1215812158
<unit id="G0dSeRY" name="api.api_endpoints.title">
12159-
<segment state="translated">
12159+
<segment>
1216012160
<source>api.api_endpoints.title</source>
1216112161
<target>API endpoints</target>
1216212162
</segment>
1216312163
</unit>
1216412164
<unit id="yFYyK5u" name="api.api_endpoints.partdb">
12165-
<segment state="translated">
12165+
<segment>
1216612166
<source>api.api_endpoints.partdb</source>
1216712167
<target>Part-DB API</target>
1216812168
</segment>
1216912169
</unit>
1217012170
<unit id="sb8URUl" name="api.api_endpoints.kicad_root_url">
12171-
<segment state="translated">
12171+
<segment>
1217212172
<source>api.api_endpoints.kicad_root_url</source>
1217312173
<target>KiCad API root URL</target>
1217412174
</segment>
1217512175
</unit>
1217612176
<unit id="UXT_MIM" name="eda_info.visibility">
12177-
<segment state="translated">
12177+
<segment>
1217812178
<source>eda_info.visibility</source>
1217912179
<target>Force visibility</target>
1218012180
</segment>
1218112181
</unit>
1218212182
<unit id="NN5DZ4F" name="eda_info.visibility.help">
12183-
<segment state="translated">
12183+
<segment>
1218412184
<source>eda_info.visibility.help</source>
1218512185
<target>By default, the visibility to the EDA software is automatically determined. With this checkbox, you can force the part to be visible or invisible.</target>
1218612186
</segment>
1218712187
</unit>
12188+
<unit id="rBWy8Ol" name="part.withdraw.zero_amount">
12189+
<segment>
12190+
<source>part.withdraw.zero_amount</source>
12191+
<target>You tried to withdraw/add an amount of zero! No action was performed.</target>
12192+
</segment>
12193+
</unit>
1218812194
</file>
1218912195
</xliff>

0 commit comments

Comments
 (0)