Skip to content
This repository has been archived by the owner on Nov 25, 2024. It is now read-only.

Commit

Permalink
Fix: Dialog functionality (#2480)
Browse files Browse the repository at this point in the history
* Fix: Dialog Functionality

* Fix: Dialog Functionality
  • Loading branch information
Ricargame authored Jul 24, 2024
1 parent 136bda1 commit 470f07e
Show file tree
Hide file tree
Showing 9 changed files with 412 additions and 108 deletions.
36 changes: 36 additions & 0 deletions src/api/ADempiere/reportManagement/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,3 +180,39 @@ export function runExport({
method: 'post'
})
}

export function ListNotificationsTypes() {
return request({
url: '/send_notifications/notifications_types',
method: 'get'
})
}

export function ListUsers() {
return request({
url: '/send_notifications/user',
method: 'get'
})
}

export function SendNotification({
user_id,
title,
recipients,
subject,
notification_type,
attachments
}) {
return request({
url: '/send_notifications/notification',
method: 'post',
params: {
user_id,
title,
recipients,
subject,
notification_type,
attachments
}
})
}
5 changes: 4 additions & 1 deletion src/lang/ADempiere/en/report.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,10 @@ const report = {
viewReport: 'Report View',
Detail: 'View Detailed',
summary: 'View Summary',
exportFormat: 'Export Format'
exportFormat: 'Export Format',
download: 'Generated Download Link',
sharedReport: 'Shared Report',
mesajeDownload: 'Click on the Following lLnk to go to Download '
}
}

Expand Down
5 changes: 4 additions & 1 deletion src/lang/ADempiere/es/report.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,10 @@ const report = {
viewReport: 'Vista del Informe',
Detail: 'Ver Detallado',
summary: 'Ver Resumido',
exportFormat: 'Formato de Exportación'
exportFormat: 'Formato de Exportación',
download: 'Link de Descarga Generado',
sharedReport: 'Reporte Compartido',
mesajeDownload: 'Haga clic en el Siguiente Enlace para ir a la Descarga '
}
}

Expand Down
95 changes: 90 additions & 5 deletions src/store/modules/ADempiere/reportManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ import {
runExport,
generateReport,
generateReportRequest,
getReportOutputRequest
getReportOutputRequest,
ListNotificationsTypes,
ListUsers,
SendNotification
} from '@/api/ADempiere/reportManagement/index.ts'
import { listPrintFormatsRequest } from '@/api/ADempiere/reportManagement/printFormat.ts'
import { listReportViewsRequest } from '@/api/ADempiere/reportManagement/reportView.ts'
Expand Down Expand Up @@ -63,12 +66,24 @@ const initState = {
pageSize: 15,
isLoading: false,
showDialog: false,
expandedAll: true
expandedAll: true,
exportReport: {},
contactSend: '',
typeNotify: ''
}
const reportManager = {
state: initState,

mutations: {
setContactSend(state, contactSend) {
state.contactSend = contactSend
},
setTypeNotify(state, typeNotify) {
state.typeNotify = typeNotify
},
setExportReport(state, exportReport) {
state.exportReport = exportReport
},
setShowDialog(state, showDialog) {
state.showDialog = showDialog
},
Expand Down Expand Up @@ -676,7 +691,7 @@ const reportManager = {
* @returns {files}
*/
exportReport({
getters
commit
}, {
reportId,
reportName
Expand All @@ -689,8 +704,69 @@ const reportManager = {
const { file_name } = response
const file = document.createElement('a')
file.href = `${config.adempiere.resource.url}${file_name}`
file.download = `${reportName}` // name of the file to be downloaded
file.click()
file.download = `${reportName}`
commit('setExportReport', response)
resolve(response)
})
.catch(error => {
showNotification({
title: language.t('notifications.error'),
message: error.message,
type: 'error'
})
console.warn(`Error exporting report: ${error.message}. Code: ${error.code}.`)
})
})
},
ListNotifications() {
return new Promise(resolve => {
ListNotificationsTypes()
.then(response => {
resolve(response)
})
.catch(error => {
showNotification({
title: language.t('notifications.error'),
message: error.message,
type: 'error'
})
console.warn(`Error exporting report: ${error.message}. Code: ${error.code}.`)
})
})
},
ListUser() {
return new Promise(resolve => {
ListUsers()
.then(response => {
resolve(response)
})
.catch(error => {
showNotification({
title: language.t('notifications.error'),
message: error.message,
type: 'error'
})
console.warn(`Error exporting report: ${error.message}. Code: ${error.code}.`)
})
})
},
getSendNotification({ commit }, {
user_id,
title,
recipients,
notification_type,
attachments
}) {
return new Promise(resolve => {
SendNotification({
user_id,
title,
recipients,
notification_type,
attachments
})
.then(response => {
commit('setSendNotification', response)
resolve(response)
})
.catch(error => {
Expand All @@ -706,6 +782,15 @@ const reportManager = {
},

getters: {
getContactSend: (state) => {
return state.contactSend
},
getTypeNotify: (state) => {
return state.typeNotify
},
getExportReport: (state) => {
return state.exportReport
},
getExpandedAll: (state) => {
return state.expandedAll
},
Expand Down
14 changes: 7 additions & 7 deletions src/utils/ADempiere/notification.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,22 +81,22 @@ export function showNotification({ type = 'success', title, message = '', summar
})
}
export function showNotificationReport({ type = 'success', title, message, link }) {
title = hasTranslation(title)
if (message) {
message = hasTranslation(message)
}
return Notification({
title,
message: `
<div style="max-height: 100px;max-width: 250px; overflow-y: auto;">
${message}
<br><br>
<a href="${link}" target="_blank" style="text-decoration: underline;">Link</a>
</div>
`,
type,
position: 'bottom-right',
dangerouslyUseHTMLString: true,
onClick() {
router.push({
name: title,
path: link
}, () => {})
}
dangerouslyUseHTMLString: true
})
}
/**
Expand Down
56 changes: 56 additions & 0 deletions src/views/ADempiere/ReportViewerEngine/dialog/contactSend.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<template>
<el-form-item>
<template slot="label">
{{ $t('report.reportEnginer.optionsImport.contactsSend') }}
</template>
<el-select
v-model="contantSend"
filterable
allow-create
@change="setUser"
@visible-change="searchUser"
>
<el-option
v-for="(item, key) in listUserSend"
:key="key"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
</template>
<script>
import store from '@/store'
import { defineComponent, ref } from '@vue/composition-api'
import { isEmptyValue } from '@/utils/ADempiere/valueUtils'
export default defineComponent({
name: 'contactSend',
setup() {
const contantSend = ref('')
const listUserSend = ref([])
function searchUser() {
store.dispatch('ListUser')
.then(response => {
if (!isEmptyValue(response)) {
const { records } = response
listUserSend.value = records.map(item => {
return {
label: item.values.DisplayColumn,
value: item.id
}
})
}
})
}
function setUser(data) {
store.commit('setContactSend', data)
}
return {
contantSend,
listUserSend,
setUser,
searchUser
}
}
})
</script>
93 changes: 93 additions & 0 deletions src/views/ADempiere/ReportViewerEngine/dialog/copyLink.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<template>
<div>
<p style="width: 630px; margin: 0 auto; font-size: 14px; text-align: center;">
{{ $t('component.attachment.share.description') }}
</p>
<p style="text-align: center;">
<b>
{{ $t('component.attachment.share.timeText') }}
</b>
</p>
<el-radio-group
v-model="validTime"
style="display: flex; justify-content: center;"
@change="loadData"
>
<el-radio :label="3600">1 {{ ' ' + $t('component.attachment.share.time.hour') }}</el-radio>
<el-radio :label="21600">6 {{ ' ' + $t('component.attachment.share.time.hours') }}</el-radio>
<el-radio :label="86400">1 {{ ' ' + $t('component.attachment.share.time.day') }}</el-radio>
<el-radio :label="259200">3 {{ ' ' + $t('component.attachment.share.time.days') }}</el-radio>
<el-radio :label="604800">7 {{ ' ' + $t('component.attachment.share.time.days') }}</el-radio>
</el-radio-group>
<el-input
v-model="linkShare"
disabled
style="margin-top: 10px"
>
<i
v-if="isLoading"
slot="prefix"
class="el-icon-loading"
/>
<i
v-else
slot="prefix"
class="el-input__icon el-icon-document-copy"
@click="copyValue"
/>
</el-input>
</div>
</template>
<script>
import { defineComponent, ref } from '@vue/composition-api'
import {
requestShareResources
} from '@/api/ADempiere/file-management/resource-reference.ts'
import { copyToClipboard } from '@/utils/ADempiere/coreUtils.js'
import { isEmptyValue } from '@/utils/ADempiere/valueUtils'
export default defineComponent({
name: 'copyLink',
props: {
reportOutput: {
type: Object,
required: false
}
},
setup(props) {
const isLoading = ref(false)
const linkShare = ref('')
const validTime = ref(3600)
function loadData() {
isLoading.value = true
requestShareResources({
fileName: props.reportOutput.name,
seconds: validTime.value
})
.then(response => {
linkShare.value = response
})
.finally(() => {
isLoading.value = false
})
}
function copyValue() {
let textToCopy = linkShare.value
if (isEmptyValue(textToCopy)) {
textToCopy = ''
}
copyToClipboard({
text: textToCopy,
isShowMessage: true
})
}
loadData()
return {
isLoading,
linkShare,
validTime,
copyValue,
loadData
}
}
})
</script>
Loading

0 comments on commit 470f07e

Please sign in to comment.