* Remove the bracket types specified in the `settings` object, from the given string `value`. * * @param {string} value * @param {object} settings * @param {boolean} rearrangeSignsAndValueOrder If set to `true`, then only the brackets are remove and a negative sign is added, with
(value, settings, rearrangeSignsAndValueOrder = true)
| 5075 | * @private |
| 5076 | */ |
| 5077 | static _removeBrackets(value, settings, rearrangeSignsAndValueOrder = true) { |
| 5078 | let result; |
| 5079 | if (!AutoNumericHelper.isNull(settings.negativeBracketsTypeOnBlur) && value.charAt(0) === settings.firstBracket) { |
| 5080 | // Remove the brackets if they are present |
| 5081 | result = value.replace(settings.firstBracket, ''); |
| 5082 | result = result.replace(settings.lastBracket, ''); |
| 5083 | |
| 5084 | // Add back the negative sign at the right place |
| 5085 | if (rearrangeSignsAndValueOrder) { |
| 5086 | // First we need to remove the currency symbol from the value, since we want to be able to add back the negative sign at the right place (including between the value and the currency sign) |
| 5087 | result = result.replace(settings.currencySymbol, ''); |
| 5088 | result = this._mergeCurrencySignNegativePositiveSignAndValue(result, settings, true, false); //TODO This assume the value is negative and non-empty. Is this always the case? |
| 5089 | } else { |
| 5090 | // Here we only want to add the negative sign since we removed the brackets, without reordering |
| 5091 | result = `${settings.negativeSignCharacter}${result}`; |
| 5092 | } |
| 5093 | } else { |
| 5094 | result = value; |
| 5095 | } |
| 5096 | |
| 5097 | return result; |
| 5098 | } |
| 5099 | |
| 5100 | /** |
| 5101 | * Analyze the `negativeBracketsTypeOnBlur` options and keep track of the first and last bracket characters to use. |
no test coverage detected