forked from PanJiaChen/vue-element-admin
-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add show/hide optional fields. (#1290)
- Loading branch information
1 parent
63b1c8e
commit f9e03e8
Showing
12 changed files
with
272 additions
and
13 deletions.
There are no files selected for viewing
122 changes: 122 additions & 0 deletions
122
src/components/ADempiere/FilterFields/fieldsDisplayOptions.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
<!-- | ||
ADempiere-Vue (Frontend) for ADempiere ERP & CRM Smart Business Solution | ||
Copyright (C) 2017-Present E.R.P. Consultores y Asociados, C.A. | ||
Contributor(s): Edwin Betancourt [email protected] 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/>. | ||
--> | ||
|
||
<template> | ||
<el-dropdown trigger="click" class="fields-display-options" @command="handleCommand"> | ||
<span class="el-dropdown-link"> | ||
<svg-icon icon-class="list" /> | ||
</span> | ||
|
||
<el-dropdown-menu slot="dropdown" style="max-width: 300px;"> | ||
<el-dropdown-item | ||
:disabled="!isHiddenFields" | ||
command="hiddenOptionals" | ||
> | ||
<svg-icon icon-class="eye" /> | ||
{{ $t('fieldDisplayOptions.hideOptionalFields') }} | ||
</el-dropdown-item> | ||
|
||
<el-dropdown-item | ||
:disabled="!isShowFields" | ||
command="showOptionals" | ||
> | ||
<svg-icon icon-class="eye-open" /> | ||
{{ $t('fieldDisplayOptions.showOptionalFields') }} | ||
</el-dropdown-item> | ||
</el-dropdown-menu> | ||
</el-dropdown> | ||
</template> | ||
|
||
<script> | ||
import { computed, defineComponent } from '@vue/composition-api' | ||
export default defineComponent({ | ||
name: 'FieldsDisplayOption', | ||
props: { | ||
parentUuid: { | ||
type: String, | ||
default: undefined | ||
}, | ||
containerUuid: { | ||
type: String, | ||
required: true | ||
}, | ||
availableFields: { | ||
type: Array, | ||
required: true | ||
}, | ||
showedFields: { | ||
type: Array, | ||
required: true | ||
}, | ||
filterManager: { | ||
type: Function, | ||
default: ({ filterList }) => {} | ||
} | ||
}, | ||
setup(props) { | ||
// enabled showed optionals and mandatory fields | ||
const isShowFields = computed(() => { | ||
return props.availableFields.length > 0 && | ||
props.availableFields.length > props.showedFields.length | ||
}) | ||
// enabled hidden optionals fields (only mandatory)) | ||
const isHiddenFields = computed(() => { | ||
return props.showedFields.length > 0 && | ||
props.availableFields.length > 0 | ||
}) | ||
const fieldsList = computed(() => { | ||
return props.availableFields.map(field => { | ||
return field.columnName | ||
}) | ||
}) | ||
const handleCommand = (command) => { | ||
let fieldsShowed = [] | ||
if (command === 'showOptionals') { | ||
fieldsShowed = fieldsList.value | ||
} | ||
props.filterManager({ | ||
parentUuid: props.parentUuid, | ||
containerUuid: props.containerUuid, | ||
fieldsShowed, | ||
fieldsList: props.availableFields | ||
}) | ||
} | ||
return { | ||
// computeds | ||
isShowFields, | ||
isHiddenFields, | ||
// methods | ||
handleCommand | ||
} | ||
} | ||
}) | ||
</script> | ||
|
||
<style scoped lang="scss"> | ||
.fields-display-options { | ||
padding-left: 5px; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// ADempiere-Vue (Frontend) for ADempiere ERP & CRM Smart Business Solution | ||
// Copyright (C) 2017-Present E.R.P. Consultores y Asociados, C.A. | ||
// Contributor(s): Edwin Betancourt [email protected] 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/>. | ||
|
||
const fieldsDisplayOptions = { | ||
// fields showed options | ||
hideOptionalFields: 'Hide Optional Fields', | ||
showOptionalFields: 'Show Opcional Fields' | ||
} | ||
|
||
export default fieldsDisplayOptions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// ADempiere-Vue (Frontend) for ADempiere ERP & CRM Smart Business Solution | ||
// Copyright (C) 2017-Present E.R.P. Consultores y Asociados, C.A. | ||
// Contributor(s): Edwin Betancourt [email protected] 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/>. | ||
|
||
const fieldsDisplayOptions = { | ||
// fields showed options | ||
hideOptionalFields: 'Ocultar Campos Opcionales', | ||
showOptionalFields: 'Mostrar Campos Opcionales' | ||
} | ||
|
||
export default fieldsDisplayOptions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.