Skip to content

Commit

Permalink
Zoom in to Records from Links Report (PanJiaChen#2635)
Browse files Browse the repository at this point in the history
  • Loading branch information
elsiosanchez authored Sep 13, 2024
1 parent c2685d9 commit 29d3387
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 3 deletions.
97 changes: 95 additions & 2 deletions src/components/ADempiere/Report/Data/DataCells.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,39 @@ along with this program. If not, see <https:www.gnu.org/licenses/>.
:style="cellStyle(attributes.code, rowData)"
>
<!-- Show cell label -->
{{ displayLabel(attributes, rowData) }}
<el-dropdown
v-if="!isEmptyValue(attributes.column_name)"
trigger="click"
@visible-change="loadZoom"
@command="zoomInWindow"
>
<span class="el-dropdown-link">
{{ displayLabel(attributes, rowData) }}
</span>
<el-dropdown-menu
v-if="isLoaded"
slot="dropdown"
>
<el-dropdown-item>
<i class="el-icon-loading" />
</el-dropdown-item>
</el-dropdown-menu>
<el-dropdown-menu v-else slot="dropdown">
<el-dropdown-item
v-for="(zoom, key) in rowData.zoom_windows"
:key="key"
:command="zoom"
>
<i class="el-icon-zoom-in" style="font-weight: bolder;" />
<b>
{{ $t('page.processActivity.zoomIn') }} {{ ' - ' + zoom.name + ' ( ' + displayLabel(attributes, rowData) + ' )' }}
</b>
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
<span v-else>
{{ displayLabel(attributes, rowData) }}
</span>
<!-- Show popover only if the row is selected and is parent -->
<el-popover
v-if="currentSelectedColumn === attributes.code && rowData.is_parent"
Expand All @@ -41,13 +73,17 @@ along with this program. If not, see <https:www.gnu.org/licenses/>.
<script>
import {
defineComponent,
computed
computed,
ref
} from '@vue/composition-api'
// Components
import InfoReport from '@/views/ADempiere/ReportViewerEngine/infoReport.vue'
// Utility functions
import { isEmptyValue } from '@/utils/ADempiere/valueUtils.js'
import { isLookup } from '@/utils/ADempiere/references'
import { zoomIn } from '@/utils/ADempiere/coreUtils.js'
// Api
import { listZoomWindowsRequest } from '@//api/ADempiere/fields/zoom.js'
export default defineComponent({
name: 'DataCells',
Expand Down Expand Up @@ -82,9 +118,15 @@ export default defineComponent({
showDetails: {
type: Boolean,
default: false
},
tableName: {
type: String,
default: ''
}
},
setup(props) {
// Ref
const isLoaded = ref(false)
// Computed
const show = computed({
Expand Down Expand Up @@ -155,12 +197,63 @@ export default defineComponent({
}
}
function loadZoom(show) {
if (
!show ||
isEmptyValue(props.tableName) ||
isEmptyValue(props.attributes.column_name)
) {
isLoaded.value = false
return
}
// props.rowData.isLoadingZoom = true
isLoaded.value = true
listZoomWindowsRequest({
column_name: props.attributes.column_name,
table_name: props.tableName
})
.then(response => {
props.rowData.zoom_windows = response.zoom_windows.map(listZoom => {
return {
...listZoom,
columnName: props.attributes.column_name,
currentValue: props.rowData.cells[props.attributes.code]
}
})
isLoaded.value = false
})
.catch(() => {
isLoaded.value = false
})
.finally(() => {
isLoaded.value = false
})
}
function zoomInWindow(report) {
const { columnName, id, currentValue } = report
zoomIn({
attributeValue: `window_${id}`,
attributeName: 'containerKey',
query: {
[columnName]: currentValue.value
},
params: {
[columnName]: currentValue.value
}
})
}
return {
// Ref
isLoaded,
// Computed
show,
// Métodos
loadZoom,
cellStyle,
displayLabel,
zoomInWindow,
shouldHideName
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/components/ADempiere/Report/Data/DataReport.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ along with this program. If not, see <https:www.gnu.org/licenses/>.
:attributes="fieldAttributes"
:current-selected-row="selectedRow"
:current-selected-column="selectedColumn"
:table-name="reportOutput.table_name"
/>
</template>
</el-table-column>
Expand Down Expand Up @@ -225,7 +226,9 @@ export default defineComponent({
return {
...child,
children: hasChildren(child.children, index.toString()),
level: index
level: index,
zoom_windows: [],
isLoadingZoom: false
}
})
}
Expand Down

0 comments on commit 29d3387

Please sign in to comment.