Skip to content

Commit

Permalink
fix: Number field range To. (PanJiaChen#2442)
Browse files Browse the repository at this point in the history
* fix: Number field range To.

* add `To` translation.
  • Loading branch information
EdwinBetanc0urt authored Jul 13, 2024
1 parent 59b7cec commit fd2cafc
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 39 deletions.
3 changes: 2 additions & 1 deletion src/lang/ADempiere/en/field/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,6 @@ export default {
locationsAddress,
invoice,
payment,
order
order,
to: 'To'
}
3 changes: 2 additions & 1 deletion src/lang/ADempiere/es/field/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,6 @@ export default {
locationsAddress,
invoice,
payment,
order
order,
to: 'Hasta'
}
16 changes: 8 additions & 8 deletions src/store/modules/ADempiere/calloutManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,24 +140,24 @@ const calloutManager = {

const recordUuid = rootGetters.getUuidOfContainer(containerUuid)
attributesList.forEach(attribute => {
const { value, columnName } = attribute
const { value: attributeValue, columnName: attributeColumnName } = attribute

const oldValue = rootGetters.getValueOfFieldOnContainer({
const attributeOldValue = rootGetters.getValueOfFieldOnContainer({
parentUuid,
containerUuid,
columnName
columnName: attributeColumnName
})

// add changes to send
if (!isSameValues(value, oldValue)) {
const field = fieldsList.find(fieldItem => fieldItem.columnName === columnName)
if (!isSameValues(attributeValue, attributeOldValue)) {
const field = fieldsList.find(fieldItem => fieldItem.column_name === attributeColumnName)
if (!isEmptyValue(field)) {
commit('addChangeToPersistenceQueue', {
containerUuid,
recordUuid,
columnName,
oldValue,
value
columnName: attributeColumnName,
oldValue: attributeOldValue,
value: attributeValue
})
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/store/modules/ADempiere/dictionary/browser/getters.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,9 @@ export default {

fieldsList.forEach(fieldItem => {
// default operator
const { is_info_only, column_name, columnNameTo, operator, display_type } = fieldItem
const {
is_info_only, column_name, columnNameTo, operator, display_type
} = fieldItem
if (is_info_only) {
return false
}
Expand Down
21 changes: 9 additions & 12 deletions src/store/modules/ADempiere/dictionary/process/getters.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import { FIELDS_DATE, FIELDS_DECIMALS } from '@/utils/ADempiere/references.js'
// Utils and Helper Methods
import { isEmptyValue } from '@/utils/ADempiere/valueUtils'
import { isDisplayedField, isMandatoryField } from '@/utils/ADempiere/dictionary/process.js'
import { isNumberField } from '@/utils/ADempiere/references'

/**
* Dictionary Process Getters
Expand Down Expand Up @@ -106,10 +105,12 @@ export default {
const processParameters = {}

fieldsList.forEach(fieldItem => {
if (fieldItem.is_info_only) {
const {
is_info_only, columnName, display_type, is_range, columnNameTo, isGeneratedRange
} = fieldItem
if (is_info_only) {
return false
}
const { columnName, display_type } = fieldItem
const isMandatory = isMandatoryField(fieldItem)
if (!isMandatory) {
// evaluate displayed fields
Expand All @@ -126,24 +127,20 @@ export default {
const isDateField = FIELDS_DATE.includes(display_type)
const isDecimalField = FIELDS_DECIMALS.includes(display_type)

if (fieldItem.is_range && !isNumberField(fieldItem.display_type)) {
if (is_range && isGeneratedRange) {
const valueTo = rootGetters.getValueOfField({
containerUuid,
columnName: fieldItem.columnNameTo
columnName: columnNameTo
})
if (!isEmptyValue(valueTo)) {
// processParameters.push({
// columnName: fieldItem.columnNameTo,
// value: valueTo
// })
processParameters[fieldItem.columnNameTo] = valueTo
processParameters[columnNameTo] = valueTo
if (isDateField) {
processParameters[columnName] = {
processParameters[columnNameTo] = {
type: 'date',
value: valueTo
}
} else if (isDecimalField) {
processParameters[columnName] = {
processParameters[columnNameTo] = {
type: 'decimal',
value: valueTo
}
Expand Down
21 changes: 9 additions & 12 deletions src/store/modules/ADempiere/dictionary/report/getters.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import { FIELDS_DATE, FIELDS_DECIMALS } from '@/utils/ADempiere/references.js'
// Utils and Helper Methods
import { isEmptyValue } from '@/utils/ADempiere/valueUtils.js'
import { isDisplayedField, isMandatoryField } from '@/utils/ADempiere/dictionary/process.js'
import { isNumberField } from '@/utils/ADempiere/references.js'

/**
* Dictionary Report Getters
Expand Down Expand Up @@ -117,10 +116,12 @@ export default {
const reportParameters = {}

fieldsList.forEach(fieldItem => {
if (fieldItem.is_info_only) {
const {
is_info_only, columnName, display_type, is_range, columnNameTo, isGeneratedRange
} = fieldItem
if (is_info_only) {
return false
}
const { columnName, display_type } = fieldItem
const isMandatory = isMandatoryField(fieldItem)
if (!isMandatory) {
// evaluate displayed fields
Expand All @@ -137,24 +138,20 @@ export default {
const isDateField = FIELDS_DATE.includes(display_type)
const isDecimalField = FIELDS_DECIMALS.includes(display_type)

if (fieldItem.is_range && !isNumberField(display_type)) {
if (is_range && !isGeneratedRange) {
const valueTo = rootGetters.getValueOfField({
containerUuid: uuid,
columnName: fieldItem.columnNameTo
columnName: columnNameTo
})
if (!isEmptyValue(valueTo)) {
// reportParameters.push({
// columnName: fieldItem.columnNameTo,
// value: valueTo
// })
reportParameters[fieldItem.columnNameTo] = valueTo
reportParameters[columnNameTo] = valueTo
if (isDateField) {
reportParameters[columnName] = {
reportParameters[columnNameTo] = {
type: 'date',
value: valueTo
}
} else if (isDecimalField) {
reportParameters[columnName] = {
reportParameters[columnNameTo] = {
type: 'decimal',
value: valueTo
}
Expand Down
4 changes: 3 additions & 1 deletion src/utils/ADempiere/dictionaryUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

import lang from '@/lang'

// Constants
import REFERENCES, { YES_NO, DEFAULT_SIZE } from '@/utils/ADempiere/references'
import {
Expand Down Expand Up @@ -297,7 +299,7 @@ export function generateField({
field.column_name = field.columnNameTo
field.elementName = field.elementNameTo
field.element_name = field.elementNameTo
field.name = `${field.name} To`
field.name = `${field.name} ${lang.t('field.to')}`
field.value = parsedDefaultValueTo
field.default_value = field.default_value_to
field.parsedDefaultValue = field.parsedDefaultValueTo
Expand Down
6 changes: 3 additions & 3 deletions src/utils/ADempiere/references.js
Original file line number Diff line number Diff line change
Expand Up @@ -496,15 +496,15 @@ export function isRangeField(displayType) {
/**
* Is manage range to in other field
* @param {boolean} is_range
* @param {number} displayType
* @param {number} display_type
* @returns {boolean}
*/
export function isAddRangeField({ is_range, displayType }) {
export function isAddRangeField({ is_range, display_type }) {
if (!is_range) {
return false
}

return isNumberField(displayType)
return isNumberField(display_type)
}

/**
Expand Down

0 comments on commit fd2cafc

Please sign in to comment.