Skip to content

Commit

Permalink
feat: Change size component implementation (#464)
Browse files Browse the repository at this point in the history
* feat: Change size component implementation

* fix operators list.

* set size values in references.

* fix: Operator's comparison list.

* Set id with constants references.
  • Loading branch information
Edwin Betancourt authored Apr 29, 2020
1 parent 840692c commit 6e9c48a
Show file tree
Hide file tree
Showing 16 changed files with 584 additions and 477 deletions.
4 changes: 3 additions & 1 deletion src/components/ADempiere/Field/FieldDate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

<script>
import { fieldMixin } from '@/components/ADempiere/Field/FieldMixin'
import { DATE_PLUS_TIME } from '@/utils/ADempiere/references'
export default {
name: 'FieldDate',
Expand Down Expand Up @@ -103,7 +104,8 @@ export default {
picker += 's'
return picker
}
if (this.metadata.displayType === 16) {
// Date + Time reference (16)
if (this.metadata.displayType === DATE_PLUS_TIME.id) {
picker += 'time'
}
if (this.metadata.isRange && !this.metadata.inTable) {
Expand Down
4 changes: 3 additions & 1 deletion src/components/ADempiere/Field/FieldText.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

<script>
import { fieldMixin } from '@/components/ADempiere/Field/FieldMixin'
import { TEXT } from '@/utils/ADempiere/references'
export default {
name: 'FieldText',
Expand Down Expand Up @@ -49,7 +50,8 @@ export default {
typeTextBox() {
// String, Url, FileName...
let typeInput = 'text'
if (this.metadata.referenceType === 'Text') {
// Display Type 'Text' (14)
if (this.metadata.displayType === TEXT.id) {
typeInput = 'textarea'
}
if (this.metadata.isEncrypted) {
Expand Down
146 changes: 0 additions & 146 deletions src/components/ADempiere/Field/fieldSize.js

This file was deleted.

23 changes: 8 additions & 15 deletions src/components/ADempiere/Field/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
>
<template slot="label">
<operator-comparison
v-if="isAdvancedQuery"
v-if="field.isComparisonField"
key="is-field-operator-comparison"
:field-attributes="fieldAttributes"
:field-value="field.value"
Expand Down Expand Up @@ -75,7 +75,7 @@ import documentStatus from '@/components/ADempiere/Field/popover/documentStatus'
import operatorComparison from '@/components/ADempiere/Field/popover/operatorComparison'
import translated from '@/components/ADempiere/Field/popover/translated'
import calculator from '@/components/ADempiere/Field/popover/calculator'
import FIELDS_DISPLAY_SIZES, { DEFAULT_SIZE } from '@/components/ADempiere/Field/fieldSize'
import { DEFAULT_SIZE } from '@/utils/ADempiere/references'
import { evalutateTypeField, fieldIsDisplayed } from '@/utils/ADempiere/dictionaryUtils'
import { showMessage } from '@/utils/ADempiere/notification'
Expand Down Expand Up @@ -222,23 +222,17 @@ export default {
},
sizeFieldResponsive() {
if (!this.isDisplayed) {
return DEFAULT_SIZE.size
return DEFAULT_SIZE
}
let sizeField = {}
if (this.field.sizeFieldFromType && this.field.sizeFieldFromType.size) {
if (this.field.size) {
// set field size property
sizeField = this.field.sizeFieldFromType.size
}
if (this.isEmptyValue(sizeField)) {
// Sizes from panel and groups
sizeField = FIELDS_DISPLAY_SIZES.find(item => {
return item.type === this.field.componentPath
})
sizeField = this.field.size
}
if (this.isEmptyValue(sizeField)) {
// set default size
sizeField = DEFAULT_SIZE.size
sizeField = DEFAULT_SIZE
}
const newSizes = {}
Expand Down Expand Up @@ -325,8 +319,7 @@ export default {
let componentReference = evalutateTypeField(this.field.displayType)
if (this.isEmptyValue(componentReference)) {
componentReference = {
type: 'FieldText',
alias: ['Text']
componentPath: 'FieldText'
}
}
this.field = {
Expand All @@ -336,7 +329,7 @@ export default {
isDisplayedFromLogic: true,
isShowedFromUser: true,
//
componentPath: componentReference.type
componentPath: componentReference.componentPath
}
}
},
Expand Down
5 changes: 4 additions & 1 deletion src/components/ADempiere/Field/popover/calculator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@
</template>

<script>
import { ID, INTEGER } from '@/utils/ADempiere/references'
export default {
name: 'FieldCalc',
props: {
Expand Down Expand Up @@ -298,7 +300,8 @@ export default {
}
},
isDisabled(row, column) {
const isInteger = ['Integer', 'ID'].includes(this.fieldAttributes.referenceType)
// Integer or ID
const isInteger = [ID.id, INTEGER.id].includes(this.fieldAttributes.displayType)
const value = row[column.property].value
if (isInteger && value === ',') {
return true
Expand Down
20 changes: 5 additions & 15 deletions src/components/ADempiere/Field/popover/operatorComparison.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<template>
<span>
<span v-if="fieldAttributes.isComparisonField">
<el-popover
ref="operatorComarison"
placement="top"
width="200"
width="230"
trigger="click"
>
<span class="custom-tittle-popover">
Expand All @@ -14,7 +14,7 @@
@change="changeOperator"
>
<el-option
v-for="(item, key) in operatorsList"
v-for="(item, key) in fieldAttributes.operatorsList"
:key="key"
:value="item"
:label="$t('operators.' + item)"
Expand All @@ -28,8 +28,6 @@
</template>

<script>
import { FIELD_OPERATORS_LIST } from '@/utils/ADempiere/dataUtils'
export default {
name: 'FieldOperatorComparison',
props: {
Expand All @@ -43,14 +41,6 @@ export default {
value: this.fieldAttributes.operator
}
},
computed: {
operatorsList() {
const { conditionsList } = FIELD_OPERATORS_LIST.find(item => {
return item.type === this.fieldAttributes.componentPath
})
return conditionsList
}
},
watch: {
'fieldAttributes.operator'(newValue) {
this.value = newValue
Expand All @@ -61,13 +51,13 @@ export default {
}
},
methods: {
changeOperator(value) {
changeOperator(operatorValue) {
this.$store.dispatch('changeFieldAttribure', {
containerUuid: this.fieldAttributes.containerUuid,
columnName: this.fieldAttributes.columnName,
isAdvancedQuery: true,
attributeName: 'operator',
attributeValue: value
attributeValue: operatorValue
})
},
/**
Expand Down
6 changes: 3 additions & 3 deletions src/components/ADempiere/Panel/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -389,21 +389,21 @@ export default {
fieldItem.value = parsedValueComponent({
fieldType: fieldItem.componentPath,
value: route.query[fieldItem.columnName],
referenceType: fieldItem.referenceType,
displayType: fieldItem.displayType,
isIdentifier: fieldItem.columnName.includes('_ID')
})
if (String(route.query.isAdvancedQuery) === String(fieldItem.isAdvancedQuery)) {
fieldItem.value = parsedValueComponent({
fieldType: fieldItem.componentPath,
value: route.query[fieldItem.columnName],
referenceType: fieldItem.referenceType,
displayType: fieldItem.displayType,
isIdentifier: fieldItem.columnName.includes('_ID')
})
if (fieldItem.isRange && this.$route.query[`${fieldItem.columnName}_To`]) {
fieldItem.valueTo = parsedValueComponent({
fieldType: fieldItem.componentPath,
value: route.query[`${fieldItem.columnName}_To`],
referenceType: fieldItem.referenceType,
displayType: fieldItem.displayType,
isIdentifier: fieldItem.columnName.includes('_ID')
})
}
Expand Down
4 changes: 2 additions & 2 deletions src/lang/ADempiere/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,8 @@ export default {
BETWEEN: 'Between ">-<"',
NOT_NULL: 'Is not null',
NULL: 'Is null',
IN: 'Include',
NOT_IN: 'Not include'
IN: 'Include "()"',
NOT_IN: 'Not include "!()"'
},
quickAccess: {
newRecord: 'Quick Access to Create New Record',
Expand Down
4 changes: 2 additions & 2 deletions src/lang/ADempiere/es.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,8 @@ export default {
BETWEEN: 'Entre ">-<"',
NULL: 'No tiene valor',
NOT_NULL: 'Tiene un valor',
IN: 'Incluye',
NOT_IN: 'No incluye'
IN: 'Incluye "()"',
NOT_IN: 'No incluye "!()"'
},
quickAccess: {
newRecord: 'Acceso Rápido para Crear Registro Nuevo',
Expand Down
4 changes: 3 additions & 1 deletion src/store/modules/ADempiere/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { getPrivateAccessFromServer, lockPrivateAccessFromServer, unlockPrivateA
import { isEmptyValue } from '@/utils/ADempiere/valueUtils'
import { parseContext } from '@/utils/ADempiere/contextUtils'
import { showMessage } from '@/utils/ADempiere/notification'
import { TABLE, TABLE_DIRECT } from '@/utils/ADempiere/references'
import language from '@/lang'

const initStateBusinessData = {
Expand Down Expand Up @@ -224,7 +225,8 @@ const data = {
return
}
// always the values for these types of fields are integers
if (['TableDirect'].includes(itemField.referenceType)) {
// Table (18) or Table Direct (19)
if ([TABLE.id, TABLE_DIRECT.id].includes(itemField.diplayType)) {
valueGetDisplayColumn = parseInt(valueGetDisplayColumn, 10)
} else {
if (!isNaN(valueGetDisplayColumn)) {
Expand Down
Loading

0 comments on commit 6e9c48a

Please sign in to comment.