Skip to content

Commit

Permalink
fix: Smart Browser with reorder records. (PanJiaChen#2386)
Browse files Browse the repository at this point in the history
  • Loading branch information
EdwinBetanc0urt authored Jun 24, 2024
1 parent 13171af commit f2f94de
Show file tree
Hide file tree
Showing 28 changed files with 196 additions and 94 deletions.
12 changes: 8 additions & 4 deletions src/components/ADempiere/DataTable/Browser/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ import LoadingView from '@/components/ADempiere/LoadingView/index.vue'
// Utils and Helper Methods
import { isEmptyValue } from '@/utils/ADempiere/valueUtils'

/**
* TODO: Reindex with `rowIndex` property when sorting by Column without refreshing records
*/
export default defineComponent({
name: 'BrowserTable',

Expand Down Expand Up @@ -207,10 +210,11 @@ export default defineComponent({
})

const keyColumn = computed(() => {
if (props.panelMetadata) {
return props.panelMetadata.keyColumn
}
return undefined
// if (props.panelMetadata) {
// return props.panelMetadata.keyColumn
// }
// return undefined
return 'rowUid'
})

const headerList = computed(() => {
Expand Down
20 changes: 11 additions & 9 deletions src/components/ADempiere/DataTable/Components/CellEditInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,22 @@
:metadata-field="{
...fieldAttributes,
rowIndex: scope.$index,
rowUid: dataRow.rowUid,
recordUuid: dataRow.UUID
}"
size="mini"
@shortkey="keyboardShortcuts"
/>
</span>

<cell-display-info
v-else
key="info-value"
:class="cellCssClass"
:field-attributes="fieldAttributes"
:data-row="dataRow"
/>
<span v-else key="cell-info">
<cell-display-info
key="info-value"
:class="cellCssClass"
:field-attributes="fieldAttributes"
:data-row="dataRow"
/>
</span>
</template>

<script>
Expand All @@ -56,7 +58,7 @@ import CellDisplayInfo from '@/components/ADempiere/DataTable/Components/CellDis
import FieldDefinition from '@/components/ADempiere/FieldDefinition/index.vue'

// Constants
import { BINARY_DATA, IMAGE } from '@/utils/ADempiere/references'
import { BINARY_DATA, BUTTON, IMAGE } from '@/utils/ADempiere/references'

// Utils and Helpers Methods
import { isEmptyValue } from '@/utils/ADempiere/valueUtils.js'
Expand Down Expand Up @@ -116,7 +118,7 @@ export default defineComponent({
})

const isRowChangeEdited = computed(() => {
if ([BINARY_DATA.id, IMAGE.id].includes(props.fieldAttributes.display_type)) {
if ([BINARY_DATA.id, BUTTON.id, IMAGE.id].includes(props.fieldAttributes.display_type)) {
return false
}
if (props.dataRow.isEditRow && !isReadOnly.value) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!--
ADempiere-Vue (Frontend) for ADempiere ERP & CRM Smart Business Solution
Copyright (C) 2018-Present E.R.P. Consultores y Asociados, C.A.
Contributor(s): Edwin Betancourt EdwinBetanc0urt@outlook.com www.erpya.com
Copyright (C) 2018-Present E.R.P. Consultores y Asociados, C.A. www.erpya.com
Contributor(s): Edwin Betancourt EdwinBetanc0urt@outlook.com https://github.com/EdwinBetanc0urt
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
Expand Down Expand Up @@ -90,6 +90,10 @@ export default defineComponent({
type: [Number, String],
default: -1
},
rowUid: {
type: String,
default: null
},
totalRecords: {
type: [Number, String],
default: 0
Expand Down Expand Up @@ -184,9 +188,10 @@ export default defineComponent({
})

const currentIndex = computed(() => {
if (!isEmptyValue(props.rowIndex)) {
if (!isEmptyValue(props.rowIndex) || !isEmptyValue(props.rowUid)) {
return indexRowByPage({
indexRow: props.rowIndex,
rowUid: props.rowUid,
pageNumber: currentPageNumber.value,
pageSize: currentPageSize.value
})
Expand Down
39 changes: 21 additions & 18 deletions src/components/ADempiere/FieldDefinition/FieldDate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -151,18 +151,17 @@ export default {
// table records values
if (inTable) {
// implement container manager row
if (this.containerManager && this.containerManager.getCell) {
const value = this.containerManager.getCell({
containerUuid,
rowIndex: this.metadata.rowIndex,
columnName
})
// types `decimal` and `date` is a object struct
if ((getTypeOfValue(value) === 'OBJECT') && !isEmptyValue(value.type)) {
return value.value
}
return value
const value = this.containerManager.getCell({
containerUuid,
rowIndex: this.metadata.rowIndex,
rowUid: this.metadata.rowUid,
columnName
})
// types `decimal` and `date` is a object struct
if ((getTypeOfValue(value) === 'OBJECT') && !isEmptyValue(value.type)) {
return value.value
}
return value
}

// main panel values
Expand Down Expand Up @@ -201,14 +200,18 @@ export default {
// table records values
if (inTable) {
// implement container manager row
if (this.containerManager && this.containerManager.setCell) {
this.containerManager.setCell({
containerUuid,
rowIndex: this.metadata.rowIndex,
columnName,
value
})
const value = this.containerManager.setCell({
containerUuid,
rowIndex: this.metadata.rowIndex,
rowUid: this.metadata.rowUid,
columnName,
value
})
// types `decimal` and `date` is a object struct
if ((getTypeOfValue(value) === 'OBJECT') && !isEmptyValue(value.type)) {
return value.value
}
return value
}

let startValue, endValue
Expand Down
30 changes: 18 additions & 12 deletions src/components/ADempiere/FieldDefinition/FieldNumber.vue
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ import { DISPLAY_COLUMN_PREFIX } from '@/utils/ADempiere/dictionaryUtils'
import {
NUMBER
} from '@/utils/ADempiere/references.js'

import { CURRENCY } from '@/utils/ADempiere/constants/systemColumns'
import { NUMBER_PRECISION } from '@/utils/ADempiere/formatValue/numberFormat.js'

// Utils and Helper Methods
Expand Down Expand Up @@ -156,27 +156,33 @@ export default {
}
},
currencyDocument() {
const columnName = DISPLAY_COLUMN_PREFIX + 'C_Currency_ID'
const columnName = DISPLAY_COLUMN_PREFIX + CURRENCY
// table records values
if (this.metadata.inTable) {
// implement container manager row
if (this.metadata.containerManager && this.metadata.containerManager.getCell) {
const currentValue = this.metadata.containerManager.getCell({
containerUuid: this.metadata.containerUuid,
rowIndex: this.metadata.rowIndex,
columnName
})
if (!isEmptyValue(currentValue)) {
return currentValue
}
const value = this.containerManager.getCell({
containerUuid: this.metadata.containerUuid,
rowIndex: this.metadata.rowIndex,
rowUid: this.metadata.rowUid,
columnName
})
// types `decimal` and `date` is a object struct
if ((getTypeOfValue(value) === 'OBJECT') && !isEmptyValue(value.type)) {
return value.value
}
return value
}

return store.getters.getValueOfField({
const value = this.$store.getters.getValueOfField({
parentUuid: this.metadata.parentUuid,
containerUuid: this.metadata.containerUuid,
columnName
})
// types `decimal` and `date` is a object struct
if ((getTypeOfValue(value) === 'OBJECT') && !isEmptyValue(value.type)) {
return value.value
}
return value
},
currencyCode() {
if (!isEmptyValue(this.metadata.labelCurrency)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!--
ADempiere-Vue (Frontend) for ADempiere ERP & CRM Smart Business Solution
Copyright (C) 2017-Present E.R.P. Consultores y Asociados, C.A.www.erpya.com
Copyright (C) 2018-Present E.R.P. Consultores y Asociados, C.A.www.erpya.com
Contributor(s): Edwin Betancourt EdwinBetanc0urt@outlook.com https://github.com/EdwinBetanc0urt
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -170,6 +170,7 @@ export default {
return this.containerManager.getCell({
containerUuid: this.metadata.containerUuid,
rowIndex: this.metadata.rowIndex,
rowUid: this.metadata.rowUid,
columnName
})
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<!--
ADempiere-Vue (Frontend) for ADempiere ERP & CRM Smart Business Solution
Copyright (C) 2017-Present E.R.P. Consultores y Asociados, C.A.
Contributor(s): Elsio Sanchez esanchez@erpya.com www.erpya.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <https:www.gnu.org/licenses/>.
ADempiere-Vue (Frontend) for ADempiere ERP & CRM Smart Business Solution
Copyright (C) 2018-Present E.R.P. Consultores y Asociados, C.A. www.erpya.com
Contributor(s): Elsio Sanchez esanchez@erpya.com https://github.com/elsiosanchez
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <https:www.gnu.org/licenses/>.
-->

<template>
Expand Down Expand Up @@ -177,6 +177,7 @@ export default {
return this.containerManager.getCell({
containerUuid,
rowIndex: this.fieldAttributes.rowIndex,
rowUid: this.metadata.rowUid,
columnName
})
}
Expand All @@ -195,6 +196,7 @@ export default {
return this.containerManager.getCell({
containerUuid,
rowIndex: this.fieldAttributes.rowIndex,
rowUid: this.metadata.rowUid,
columnName
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,14 @@ export default ({
containerManager.setCell({
containerUuid,
rowIndex: fieldAttributes.rowIndex,
rowUid: fieldAttributes.rowUid,
columnName: column_name,
value: id
})
containerManager.setCell({
containerUuid,
rowIndex: fieldAttributes.rowIndex,
rowUid: fieldAttributes.rowUid,
columnName: DISPLAY_COLUMN_PREFIX + column_name,
value: description
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,14 @@ export default ({
containerManager.setCell({
containerUuid,
rowIndex: fieldAttributes.rowIndex,
rowUid: fieldAttributes.rowUid,
columnName,
value: id
})
containerManager.setCell({
containerUuid,
rowIndex: fieldAttributes.rowIndex,
rowUid: fieldAttributes.rowUid,
columnName: DISPLAY_COLUMN_PREFIX + columnName,
value: displayValue
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,14 @@ export default ({
containerManager.setCell({
containerUuid,
rowIndex: fieldAttributes.rowIndex,
rowUid: fieldAttributes.rowUid,
columnName,
value: id
})
containerManager.setCell({
containerUuid,
rowIndex: fieldAttributes.rowIndex,
rowUid: fieldAttributes.rowUid,
columnName: DISPLAY_COLUMN_PREFIX + columnName,
value: displayValue
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,12 +215,14 @@ export default {
this.containerManager.setCell({
containerUuid,
rowIndex: this.metadata.rowIndex,
rowUid: this.metadata.rowUid,
columnName,
value: id
})
this.containerManager.setCell({
containerUuid,
rowIndex: this.metadata.rowIndex,
rowUid: this.metadata.rowUid,
columnName: DISPLAY_COLUMN_PREFIX + columnName,
value: displayValue
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,14 @@ export default ({
containerManager.setCell({
containerUuid,
rowIndex: fieldAttributes.rowIndex,
rowUid: fieldAttributes.rowUid,
columnName,
value: id
})
containerManager.setCell({
containerUuid,
rowIndex: fieldAttributes.rowIndex,
rowUid: fieldAttributes.rowUid,
columnName: DISPLAY_COLUMN_PREFIX + columnName,
value: displayValue
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,12 +215,14 @@ export default {
this.containerManager.setCell({
containerUuid,
rowIndex: this.metadata.rowIndex,
rowUid: this.metadata.rowUid,
columnName,
value: id
})
this.containerManager.setCell({
containerUuid,
rowIndex: this.metadata.rowIndex,
rowUid: this.metadata.rowUid,
columnName: DISPLAY_COLUMN_PREFIX + columnName,
value: displayValue
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,14 @@ export default ({
containerManager.setCell({
containerUuid,
rowIndex: fieldAttributes.rowIndex,
rowUid: fieldAttributes.rowUid,
columnName,
value: id
})
containerManager.setCell({
containerUuid,
rowIndex: fieldAttributes.rowIndex,
rowUid: fieldAttributes.rowUid,
columnName: DISPLAY_COLUMN_PREFIX + columnName,
value: displayValue
})
Expand Down
Loading

0 comments on commit f2f94de

Please sign in to comment.