Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Request fields preference value. #1271

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 22 additions & 9 deletions src/components/ADempiere/Field/FieldOptions/LabelField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,19 @@
<span>
{{ label }}
</span>

<span v-if="isMandatory" :style="'color: #f34b4b'">*</span>

<i class="el-icon-info" :style="iconStyle" />
</div>
</template>

<script>
export default {
import { defineComponent, computed } from '@vue/composition-api'

export default defineComponent({
name: 'LabelField',

props: {
isMandatory: {
type: Boolean,
Expand All @@ -24,25 +30,32 @@ export default {
default: false
}
},
computed: {
labelStyle() {

setup(props) {
const labelStyle = computed(() => {
let displayStyle
this.isMobile ? displayStyle = 'display: flex;width: auto;' : 'display: block;'
props.isMobile ? displayStyle = 'display: flex; width: auto;' : 'display: block;'
return displayStyle + ' margin-left: 3px;'
},
iconStyle() {
if (this.isMobile) {
})

const iconStyle = computed(() => {
if (props.isMobile) {
return 'margin-left: 5px; margin-top: 7px;'
}
return 'margin-left: -5px; padding-bottom: 6px;'
})

return {
iconStyle,
labelStyle
}
}
}
})
</script>

<style scoped>
.el-icon-info {
font-size: 11px;
color: #008fd3;
}
</style>

Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
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>
<el-card
v-if="!isEmptyValue(metadataList)"
Expand All @@ -31,11 +32,10 @@
</span>
</div>
<div class="text item">
{{
getDescriptionOfPreference
}}
{{ getDescriptionOfPreference }}
</div>
<br>

<div class="text item">
<el-form
:inline="true"
Expand Down Expand Up @@ -66,6 +66,7 @@
</el-form>
</div>
<br>

<el-row>
<el-col :span="24">
<samp style="float: left; padding-right: 10px;">
Expand All @@ -76,13 +77,15 @@
@click="remove()"
/>
</samp>

<samp style="float: right; padding-right: 10px;">
<el-button
type="danger"
class="custom-button-address-location"
icon="el-icon-close"
@click="close()"
/>

<el-button
type="primary"
class="custom-button-address-location"
Expand All @@ -93,6 +96,7 @@
</el-col>
</el-row>
</el-card>

<div
v-else
v-loading="isEmptyValue(metadataList)"
Expand All @@ -104,16 +108,15 @@

<script>
import formMixin from '@/components/ADempiere/Form/formMixin'
import preferenceFields from './preferenceFields.js'
import { createFieldFromDictionary } from '@/utils/ADempiere/lookupFactory'
import preferenceFields from './preferenceValueFieldsList.js'
import { CLIENT, ORGANIZATION } from '@/utils/ADempiere/constants/systemColumns'
import { setPreference, deletePreference } from '@/api/ADempiere/field/preference.js'
import { showMessage } from '@/utils/ADempiere/notification.js'
import language from '@/lang'

export default {
name: 'Preference',
mixins: [formMixin],
name: 'PreferenceValue',
mixins: [
formMixin
],
props: {
fieldAttributes: {
type: [Object],
Expand Down Expand Up @@ -146,41 +149,61 @@ export default {
}
})
},

clientField() {
return this.metadataList.find(field => {
return field.columnName === CLIENT
})
},
organizationField() {
return this.metadataList.find(field => {
return field.columnName === ORGANIZATION
})
},
userField() {
return this.metadataList.find(field => {
return field.columnName === 'AD_User_ID'
})
},
containerField() {
return this.metadataList.find(field => {
return field.columnName === 'AD_Window_ID'
})
},

getDescriptionOfPreference() {
if (this.isEmptyValue(this.metadataList)) {
return ''
}
const forCurrentClient = this.metadataList.find(field => field.columnName === CLIENT)
if (!forCurrentClient) {
if (!this.clientField) {
return ''
}
const forCurrentUser = this.metadataList.find(field => field.columnName === 'AD_User_ID')
const forCurrentOrganization = this.metadataList.find(field => field.columnName === ORGANIZATION)
const forCurrentContainer = this.metadataList.find(field => field.columnName === 'AD_Window_ID')
// Create Message
var expl = language.t('components.preference.for')// components.preference.for
if (forCurrentOrganization && forCurrentClient) {
if (forCurrentClient.value && forCurrentOrganization.value) {
expl = expl.concat(language.t('components.preference.clientAndOrganization'))// components.preference.clientAndOrganization
} else if (forCurrentClient.value && !forCurrentOrganization.value) {
expl = expl.concat(language.t('components.preference.allOrganizationOfClient'))// components.preference.allOrganizationOfClient
} else if (!forCurrentClient.value && forCurrentOrganization.value) {
forCurrentOrganization.value = false
expl = expl.concat(language.t('components.preference.entireSystem'))// components.preference.entireSystem

// Create Message
let expl = this.$t('components.preference.for')
if (this.clientField && this.organizationField) {
if (this.clientField.value && this.organizationField.value) {
expl = expl.concat(this.$t('components.preference.clientAndOrganization'))
} else if (this.clientField.value && !this.organizationField.value) {
expl = expl.concat(this.$t('components.preference.allOrganizationOfClient'))
} else if (!this.clientField.value && this.organizationField.value) {
expl = expl.concat(this.$t('components.preference.entireSystem'))
} else {
expl = expl.concat(language.t('components.preference.entireSystem'))// components.preference.entireSystem
expl = expl.concat(this.$t('components.preference.entireSystem'))
}
}
if (forCurrentUser && forCurrentContainer) {
if (forCurrentUser.value) {
expl = expl.concat(language.t('components.preference.thisUser'))// components.preference.thisUser

if (this.userField && this.containerField) {
if (this.userField.value) {
expl = expl.concat(this.$t('components.preference.thisUser'))
} else {
expl = expl.concat(language.t('components.preference.allUsers'))// components.preference.allUsers
expl = expl.concat(this.$t('components.preference.allUsers'))
}
if (forCurrentContainer.value) {
expl = expl.concat(language.t('components.preference.thisWindow'))// components.preference.thisWindow

if (this.containerField.value) {
expl = expl.concat(this.$t('components.preference.thisWindow'))
} else {
expl = expl.concat(language.t('components.preference.allWindows'))// components.preference.allWindows
expl = expl.concat(this.$t('components.preference.allWindows'))
}
}
return expl
Expand All @@ -207,7 +230,6 @@ export default {
}
},
methods: {
createFieldFromDictionary,
close() {
if (!this.isEmptyValue(this.$route.query.fieldColumnName)) {
this.$router.push({
Expand All @@ -224,36 +246,29 @@ export default {
}
},
remove() {
const isForCurrentUser = this.metadataList.find(field => field.columnName === 'AD_User_ID').value
const isForCurrentClient = this.metadataList.find(field => field.columnName === CLIENT).value
const isForCurrentOrganization = this.metadataList.find(field => field.columnName === ORGANIZATION).value
const isForCurrentContainer = this.metadataList.find(field => field.columnName === 'AD_Window_ID').value
deletePreference({
parentUuid: this.fieldAttributes.parentUuid,
attribute: this.fieldAttributes.columnName,
isForCurrentUser,
isForCurrentClient,
isForCurrentOrganization,
isForCurrentContainer
isForCurrentClient: this.clientField.value,
isForCurrentOrganization: this.organizationField.value,
isForCurrentUser: this.userField.value,
isForCurrentContainer: this.containerField.value
})
.then(preference => {
showMessage({
message: language.t('components.preference.preferenceRemoved')
.then(() => {
this.$message({
message: this.$t('components.preference.preferenceRemoved')
})
this.close()
})
.catch(error => {
showMessage({
this.$message({
message: error.message,
type: 'error'
})
console.warn(`setPreference error: ${error.message}.`)
})
},
notSubmitForm(event) {
event.preventDefault()
return false
},

setFieldsList() {
const fieldsList = []
// Product Code
Expand All @@ -272,31 +287,27 @@ export default {
console.warn(`LookupFactory: Get Field From Server (State) - Error ${error.code}: ${error.message}.`)
})
})

this.metadataList = fieldsList
},
sendValue(list) {
const isForCurrentUser = this.metadataList.find(field => field.columnName === 'AD_User_ID').value
const isForCurrentClient = this.metadataList.find(field => field.columnName === CLIENT).value
const isForCurrentOrganization = this.metadataList.find(field => field.columnName === ORGANIZATION).value
const isForCurrentContainer = this.metadataList.find(field => field.columnName === 'AD_Window_ID').value
//
sendValue() {
setPreference({
parentUuid: this.fieldAttributes.parentUuid,
attribute: this.fieldAttributes.columnName,
value: this.fieldValue,
isForCurrentUser,
isForCurrentClient,
isForCurrentOrganization,
isForCurrentContainer
isForCurrentClient: this.clientField.value,
isForCurrentOrganization: this.organizationField.value,
isForCurrentUser: this.userField.value,
isForCurrentContainer: this.containerField.value
})
.then(preference => {
showMessage({
message: language.t('components.preference.preferenceIsOk')
.then(() => {
this.$message({
message: this.$t('components.preference.preferenceIsOk')
})
this.close()
})
.catch(error => {
showMessage({
this.$message({
message: error.message,
type: 'error'
})
Expand All @@ -307,20 +318,3 @@ export default {
}
}
</script>

<style>
.title {
color: #000000;
text-size-adjust: 20px;
font-size: 120%;
/* font-weight: 605!important;
left: 50%; */
}
.value {
color: #606266;
text-size-adjust: 20px;
font-size: 120%;
/* font-weight: 605!important;
left: 50%; */
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ export const calculatorOptionItem = {
componentRender: () => import('@/components/ADempiere/Field/FieldOptions/calculator')
}

export const preferenceOptionItem = {
export const preferenceValueOptionItem = {
name: language.t('field.preference'),
enabled: true,
svg: false,
icon: 'el-icon-notebook-2',
componentRender: () => import('@/components/ADempiere/Field/FieldOptions/preference')
componentRender: () => import('@/components/ADempiere/Field/FieldOptions/PreferenceValue')
}

export const logsOptionItem = {
Expand All @@ -97,7 +97,7 @@ export const documentStatusOptionItem = {

export const optionsListStandad = [
infoOptionItem,
preferenceOptionItem,
preferenceValueOptionItem,
logsOptionItem
]

Expand Down
Loading