mirror of
https://github.com/PanJiaChen/vue-element-admin.git
synced 2025-08-16 17:05:41 +08:00
This is the first commit for changes and integration with ADempiere UI, the pull request have very to long commits, here is a squash and merge, for detail refere to https://github.com/erpcya/adempiere-vue with committers: - [Yamel Senih](https://github.com/yamelsenih) - [Raúl Muñoz](https://github.com/Raul-mz) - [Edwin Betancourt](https://github.com/EdwinBetanc0urt) - [Leonel Matos](https://github.com/leonel1524) - [Elsio Sanchez](https://github.com/elsiosanchez) * add server error message (#571) * Feature/collapse avanced search (#572) * add server error message * add collasep to advanced search * bugfix load data ordered (#573) * Fix share values from panel. (#574) * Fix share values from panel. * Parsed values. * support refresh and field updata (#575) * refresh * bugfix load data ordered * minimal changes * Fix parameters to share data type date and boolean. (#576) * Change search browser. (#577) * read url parameters and load data (#578) * Fix error when search browser list. (#579) * Fix error when search browser list. * Minimal changes. * Update Dictionary and business data client version * bugfix share link with props (#580) * bugfix copy link with uuid * bugfix share link with props * Add support conditions to object list from criteria. (#581) * bugfix record navigation in left table (#582) * add export-browser (#583) * add export browser * minimal changes * wait for service * add window report * bugfix load report with link shared (#584) * bugfix copy link with uuid * bugfix share link with props * bugfix load report with link shared * Rollback support to window. (#585) * Rollback support to window. * Minimal changes. * support Mandatory Field (#586) * support Mandatory Field * delete comment * bugfix share link from avanced query (#588) * bugfix copy link with uuid * bugfix share link with props * bugfix load report with link shared * bugfix share link from avanced query * Fix optional fields showed from user. (#589) * Fix optional fields showed from user. * Remove destructuring assignment. * message error serve (#587) * message error serve * remove console * remove error code * minimal changes * bugfix change records in record navigation (#590) * bugfix record navigation in left table * bugfix change records in record navigation * support process Activity (#592) * support processActivity * minimal changes * Load one group field to advanced query. (#593) * Load one group field to advanced query. * Minimal changes. * bugfix load record with criteria method (#594) * support refrest menu contexto (#595) * Add new version from business data * Fix read only fields. (#591) * Fix read only fields. * Minimal changes. * Add all field list in panel advanced query. (#596) * fix set date with context (#597) * support logs Process Activity (#598) * support for the logs of Process Activity * support logs Process Activity * remove console.log * Update data in main panel when update list from server. (#599) * Update data in main panel when update list from server. * Update comments. * Update conditional to update main panel. * First commit to data load children. (#600) * bugfix change tag view title and rename variables (#601) * Fix add optional fields to advanced query. (#602) * Fix add optional fields to advanced query. * Add attribute to advanced query. * Fix variable name. * Fix change roles in navigation bar and view profile. (#603) * Fix send all parameters by advanced query. (#604) * bugfix close tag after process execute (#605) * bugfix load windows process without fields (#606) * clear fields when the window is closed (#607) * clear field of process * minimal changes * add report type to share link of reports (#608) * Fix context menu. (#609) * bugfix reload parameters after close SB (#610) * bugfix reload parameters after close SB * change condition * add ZoomIn ProcessActivity (#611) * add ZoomIn ProcessActivity * add parameters * Update es.js Fix Variable Name * Update index.vue Fix Variable Name * Update en.js * bugfix close window after process (#613) * bugfix close window after process * bugfix close views after execute SB process * support refresh the SmartBrowser (#614) * Remove data after close view. (#612) * Remove data after close view. * Clear data in tabs children when change uuid in main panel. * Fix load data in tabs children. (#615) * Fix load data in tabs children. * Send where clause. * bugfix load data whith criteria conditions (#616) * bugfix load data whith criteria conditions * remove unnecessary functions * change import function and change component name (#617) * add reference mobile (#618) * fix function calling (#619) * support mobile (#620) * remove advanced query option from child tabs * support mobile * Fix load data tab children and not send row tab (edit mode). (#621) * bugfix execute report formats (#622) * support datatable y and contextmenu (#623) * Fix load display column, record navigation. (#624) * some bugfix in advanced query panel (#625) * support for the range date and the title of the processes and reports (#626) * add option select last week range date * adjust the height of the title of the processes and reports * fix create new action error (#627) * Remove duplicate request to server by Tabs and Fields children. (#628) * Fix display value NULL in TextField component. (#630) * Smart browser support when opening the process Activity (#631) * support to record load in the table * add dispatch isClearSelection * adding conditional * minimal changes * Update contextMenuMixin.js * bugfix in share link report and process properties (#632) * fix open report viewer on process return error (#633) * feat: Add create entity in tab children. (#634) * feat: Add create entity in tab children. * Fix route query action when create entity in tab children. * feat: Add notification after delete selection records in table. (#636) * feat: Add notification after delete selection records in table. * Add destructuring of object. * Fix fields list mandatory empty when create/update in table. (#635) * feat: Add create entity in tab children. * Fix route query action when create entity in tab children. * Fix fields list mandatory empty when create/update in table. * fix: Create entity from main panel. (#637) * add condition (#638) * fix values of date parameters in share link (#639) * Support DateRange week (#640) * Add Summary to logs (#641) * support daterange week (#642) * Support DateRange week * minimal changes * Auto stash before merge of "bugfix/support-date-range-week" and "develop-i18n" * fix: Search browser when change show/hidden field not isQueryCriteria. (#643) * change displayed fields on advanced query (#644) * add summary to logs (#645) * fix create new action query (#646) * fix: Not load tabs not supported (isSortTab and isTranslationTab) (#647) * Change version * remove refresh the tabs children (#648) * remove refresh the tabs children * column top of the table of the select * minimal changes * fix: Create entity in table send server after change field. (#649) * add loading (#650) * add loading * rename isLoaded * add translations * add translations * add message * report control error (#651) * Add mark (*) mandatory fields in table. (#652) * fix: Exception not handled, add message when capturing error in promise. (#653) * fix: Correct loading into table when it has 0 records. (#654) * fix: Correct loading into table when it has 0 records. If the search returns 0 records the DataTable remains loading even when that was its response, giving the confucion that it is still waiting for the response from the server. * Minimal changes. * fix: Hide search notification for language and role. (#655) * add hidden main panel (#656) * fix: Show fields with default values. (#658) * fix load records in left table (#657) * support the hide panel button (#660) * add icon create new (#659) * add icon create new * setting the add button * fix: Delete record and selection in browser after run process. (#661) * fix load parameters of share link (#662) * open report from the window (#663) * open report from the window * resolve Conflicts * fix references disabled * Remove console.log (#664) * fix: Load data tab children after set context main panel. (#665) * add lastrun to the process Activity (#667) * fix: Lookups context. (#668) * fix: Set is load context not report and process. (#669) * fix: Set is load context not report and process. * Minimal changes. * Change evaluate multiple conditions. * feat: Add display column in add new row with value or default values. (#670) * feat: Add display column in add new row with value or default values. * Add comments. * Fixing navigation height between records (#671) * Fixing navigation height between records * minimal changes * support recent intems * fix: Context for window request. TODO: Add AD_User_ID in user info gRPC. (#672) * feat: Add last run to process activity. (#673) * feat: Add last run to process activity. * Change convert parameters to object in vuex store. * fix: Run process error. * Update source packages version * Update access version * fix: Do not show loading when the data request returns error. (#675) * feat: Add support to fields isEncrypted (type password). (#677) * fixing translation (#678) * fix display panel and fields in advanced query (#676) * fix display panel and fields in advanced query * bugfix filter fields in advanced query * fix load values in lookup component (#679) * filter fields exclude buttons on adavanced query (#680) * fix: Add display column to field link in tab. (#681) * feat: Add support to default context. (#682) TODO: Add default context in session info. * feat: Add field length to field text as max length attribute. (#683) * Add support to latest version from access * button setting to close table panel or expand (#684) * fix activities order by date (#685) * add date translations in process activity * fix activities order by date * fix: Handle data request error to leave loading the table. (#686) * fix: Smart Browser, research data when records length > 100. (#687) * fix: Smart Browser, research data when records length > 100. * Correct variable evaluation. * fix close report (#688) * Evaluate server response error by dictionary (#689) * Evaluate server response error by dictionary * Support Smart Browser and Process * minimal changes * fixed color and size of icon datatable (#690) * fixed color and size of icon datatable * minimal changes * add clearable * fix: Create request field mandatory number 0. (#691) * validate edit mode until ready to save (#692) * validate edit mode until ready to save * correcting condition * add child tab to url and share link (#693) * feat: Add support to new session request. (#694) * multiple record support (#695) * fix delete data after close window (#696) * fix load view on reapeted route * fix delete data after close window * feat: Add read only row from table. (#697) * feat: Add read only row from table. * Add read only if client context is different to client record. * add call off record (#698) * date error when executing (#699) * feat: Add validation read only with parent record is read only. (#700) * feat: Add validation read only with parent record is read only. * Minimal changes. * fix: Run process associate with Smart Browser or Window. (#702) * restore create new record of datatable child (#701) * restore create new record of datatable child * restore change * minimal changes * restoring values in the table * fix: Create new main panel, clear records to tabs children. (#703) * validate multiple record (#704) * validate multiple record * validate isEdit datatable children * Add new version for data * Add new version for data * add show to password type field (#705) * validate multiple record * add show to password type field * fix: Change evaluation of conditionals to add new row. (#706) * feat: Keep rows in edit mode after listing by creating record. (#707) * fix: Fix get lookup to window navigation. (#708) * fix: Parse default values to create or update record. (#709) * bugfix set tab child in URL (#710) * support height datable (#711) * fix: Read Only from processed and processing record. (#712) * Support badge and column fixed (#713) * support height datable * support badge * raname badge (#714) * no recharge view on changes (#715) * bugfix style of badge (#717) * change tabNumber query prop for tabParent (#718) * bugfix set tab child in URL * change tabNumber query prop for tabParent * fix: Pagination and total records. (#719) * Support duplicate lookup (#721) * set advanced search (#716) * field auto focus (#720) * field auto focus * bugfix * some changes * change method * remove unused attributes * fix: Add display column from server to add new row. (#723) * set values in main panel to share link (#725) * fix: Add new record data tables. (#726) * support LookupList (#724) * support LookupList * fix: Add display column from server to add new row. * delete isDisabledAddNewIcono * remove highlight current row of data table (#722) * fix: Tag view undefined. (#727) * fix: Get display column from server to add new row. (#729) * remove unused conditions (#730) * support style collapse item (#731) * clear panel values when view is closed (#732) * fix: Get multiple request data. (#733) * bugfix open process activity view (#736) * Evaluate values of the displayColumn with empty string or number at 0 (#737) * Evaluate values of the displayColumn with empty string or number at 0 * documenting evaluation * fix route from process activity to process view (#735) * bugfix conditions of tags views (#738) * bugfix infinity loading in datatable on new record (#734) * bugfix maxlength in process (#739) * feat: Add support to callout. (#741) * feat: Add callout support. * feat: Add support to callout. * Evaluate Column display values with empty string or number in 0u8 evaluation (#740) * bugfix close window after delete record (#742) * bugfix change panel records (#743) * fix: Error input text when show/hidden column DataTables. (#744) * fix: Remove duplicate code to focus field. (#745) * add change value of image (#746) * fix: Disable roles that do not have uuid in the registry (#747) * Add new version for gRPC data client * fix: Remove multiple request data from server. (#748) * Support duplicate or null data lookup (#749) * bugfix (#750) * Bugfix/parsed boolean context (#751) * bugfix * fix: Parsed context convert Boolean values to string values in query. * feat: Add support to callout response. (#752) * bugfix * feat: Add support to callout response to change panel values. * remove concole.log. * fix: Not send callout if is panel change. (#753) * fix: Not request callout when navigation records. (#755) * Update business data client from latest * Reduce time transition menu (#754) * fix: Set null values before reset panel to new. (#756) * fix: Set null values before reset panel to new. * Add oldValue. * add windowNo to callout store (#757) * bugfix record void in tabs (#758) * Update data version * feat: Add callout request to tab children. (#759) * feat: Add callout request to tab children. * Minimal changes. * bugfix context default values (#762) * bugfix void values from gRPC (#763) * feat: Add support for empty gRPC values. (#764) * feat: Add support for empty gRPC values. * Update comments. * tab record load and reduce requests to the server (#765) * tab record load and reduce requests to the server * duplicate keys Lookups * add forget password (#761) * add forget password * remove console * rename translation * minimal changes * Minimal Changes * duplicate data and string type (#766) * Support duplicate data and string type * minimal changes * update grpc-access-client version (#768) * bugfix load values after callout response (#769) * feat: Add support enrollment. (#767) * feat: Add support enrollment. * Update enrollment package version. * Fix language. * feat: Add reset password with token. (#771) * bugfix send panel values to create record (#772) * bugfix convert dates to UTC (#774) * feat: Add persistent vuex state in local storage. (#773) * feat: Add persistent vuex state in local storage. * fix: Error when LogOut session. * validate options list lookup (#776) * feat: Add enrollment user. (#778) * feat: Add create password and join with reset password form view. (#779) * fix: Zoom item process activity, parameters undefined. (#780) * Validate ColumnName in DataTable (#783) * bugfix load list items and callout send (#777) * fix: Search records with uuid url. (#781) * convert ternary operator into computed property (#782) * fix: Remove unused methods and remove watching. (#784) * fix: Remove unused methods and remove watching. * remove watch window view. * fix: Validation in google chrome enroll user. (#785) * fix: Validation in google chrome enroll user. * Update grpc-enrollment-user-client version. * fix: Convert context map to array pairs. (#786) * fix: Delete persistent date. (#788) * fix: Yes -No component value in table when edit mode. (#789) * multiple requests LookupList (#791) * fix: Read only panel parent when set context tab children. (#792) * Change value to displayColumn (#793) * add display column in tables childs (#787) * bugfix load list items and callout send * add display column in tables childs * add dynamic table name * add get default value from server * change comparation * remove request LookupItem (#794) * Change value to displayColumn * minimal changes * bugfix send criteria for get default value (#795) * bugfix load list items and callout send * add display column in tables childs * add dynamic table name * add get default value from server * change comparation * add criteria for get default value * remove parse int * feat: Add undo to create new record. (#796) * bugfix display values in tabs child (#797) * fix: Browser Generate Invoice From Outbound Order not search result. (#798) * add icons to recent items (#799) * bugfix display values in tabs child * add icons to recent items * correct translation and add client when changing rolecorrect translation and add client when changing role (#800) * feat: Add show mandatory columns and show all available columns. (#801) * bugfix recent items and change styles (#802) * change getDefaultValue service implementation (#803) * bugfix display values with sql * change getDefaultValue service implementation * fix: Set empty values to component's base. (#804) * add context info in field (#805) * bugfix context info fields (#806) * feat: Update access client and data client grpc version. (#807) * Add displayColumn to getterValueSelect (#808) * Add displayColumn to getterValueSelect * Update panel.js * fix: Duplicate change panel with record. (#809) * Change license and readme waiting for merge with ADempiere trunk * Add Changes for license and readme * Add commiter
895 lines
31 KiB
JavaScript
895 lines
31 KiB
JavaScript
import Vue from 'vue'
|
|
import {
|
|
getObject,
|
|
getObjectListFromCriteria,
|
|
getRecentItems,
|
|
getDefaultValueFromServer,
|
|
convertValueFromGRPC,
|
|
getContextInfoValueFromServer
|
|
} from '@/api/ADempiere'
|
|
import { convertValuesMapToObject, isEmptyValue, showMessage, convertAction } from '@/utils/ADempiere'
|
|
import language from '@/lang'
|
|
|
|
const data = {
|
|
state: {
|
|
recordSelection: [], // record data and selection
|
|
recordDetail: [],
|
|
recentItems: [],
|
|
inGetting: [],
|
|
contextInfoField: []
|
|
},
|
|
mutations: {
|
|
addInGetting(state, payload) {
|
|
state.inGetting.push(payload)
|
|
},
|
|
deleteInGetting(state, payload) {
|
|
state.inGetting = state.inGetting.filter(item => item.containerUuid !== payload.containerUuid)
|
|
},
|
|
setRecordSelection(state, payload) {
|
|
if (payload.index > -1 && payload.index !== undefined) {
|
|
state.recordSelection.splice(payload.index, 1, payload)
|
|
} else {
|
|
state.recordSelection.push(payload)
|
|
}
|
|
},
|
|
setSelection(state, payload) {
|
|
payload.data.selection = payload.newSelection
|
|
},
|
|
deleteRecordContainer(state, payload) {
|
|
state.recordSelection = payload
|
|
},
|
|
notifyCellTableChange: (state, payload) => {
|
|
payload.row[payload.columnName] = payload.value
|
|
if (payload.displayColumn !== undefined) {
|
|
const key = 'DisplayColumn_' + payload.columnName
|
|
payload.row[key] = payload.displayColumn
|
|
}
|
|
},
|
|
notifyCellSelectionChange: (state, payload) => {
|
|
if (payload.row !== undefined) {
|
|
payload.row[payload.columnName] = payload.value
|
|
if (payload.displayColumn !== undefined) {
|
|
const key = 'DisplayColumn_' + payload.columnName
|
|
payload.row[key] = payload.displayColumn
|
|
}
|
|
}
|
|
},
|
|
notifyRowTableChange: (state, payload) => {
|
|
Object.assign(payload.row, payload.newRow)
|
|
},
|
|
setRecentItems(state, payload) {
|
|
state.recentItems = payload
|
|
},
|
|
setPageNumber(state, payload) {
|
|
payload.data.pageNumber = payload.pageNumber
|
|
},
|
|
setIsloadContext(state, payload) {
|
|
payload.data.isLoadedContext = payload.isLoadedContext
|
|
},
|
|
setRecordDetail(state, payload) {
|
|
var isFinded = false
|
|
state.recordDetail = state.recordDetail.map(itemData => {
|
|
if (itemData.uuid === payload.uuid) {
|
|
isFinded = true
|
|
var newValues = Object.assign(itemData.data, payload.data)
|
|
payload.data = newValues
|
|
return payload
|
|
}
|
|
return itemData
|
|
})
|
|
if (!isFinded) {
|
|
state.recordDetail.push(payload)
|
|
}
|
|
},
|
|
addNewRow(state, payload) {
|
|
payload.data = payload.data.unshift(payload.values)
|
|
},
|
|
addDisplayColumn(state, payload) {
|
|
Vue.set(payload.row, payload.columnName, payload.displayColumn)
|
|
},
|
|
setContextInfoField(state, payload) {
|
|
state.contextInfoField.push(payload)
|
|
}
|
|
},
|
|
actions: {
|
|
/**
|
|
* Set page number of pagination list
|
|
* @param {string} parameters.parentUuid
|
|
* @param {string} parameters.containerUuid
|
|
* @param {integer} parameters.panelType
|
|
* @param {string} parameters.pageNumber
|
|
*/
|
|
setPageNumber({ commit, state, dispatch, rootGetters }, parameters) {
|
|
const data = state.recordSelection.find(recordItem => {
|
|
return recordItem.containerUuid === parameters.containerUuid
|
|
})
|
|
commit('setPageNumber', {
|
|
data: data,
|
|
pageNumber: parameters.pageNumber
|
|
})
|
|
|
|
// refresh list table with data from server
|
|
if (parameters.panelType === 'window') {
|
|
dispatch('getDataListTab', {
|
|
parentUuid: parameters.parentUuid,
|
|
containerUuid: parameters.containerUuid
|
|
})
|
|
} else if (parameters.panelType === 'browser') {
|
|
if (!rootGetters.isNotReadyForSubmit(parameters.containerUuid)) {
|
|
dispatch('getBrowserSearch', {
|
|
containerUuid: parameters.containerUuid,
|
|
isClearSelection: true
|
|
})
|
|
}
|
|
}
|
|
},
|
|
/**
|
|
* Insert new row bottom list table, used only from window
|
|
* @param {string} parentUuid
|
|
* @param {string} containerUuid
|
|
* @param {boolean} isPanelValues, define if used values form panel
|
|
* @param {boolean} isEdit, define if used values form panel
|
|
*/
|
|
addNewRow({ commit, getters, rootGetters, dispatch }, parameters) {
|
|
const { parentUuid, containerUuid, isPanelValues = false, isEdit = true, isNew = true } = parameters
|
|
var { fieldList = [] } = parameters
|
|
|
|
const tabPanel = rootGetters.getPanel(containerUuid)
|
|
|
|
if (!fieldList.length) {
|
|
fieldList = tabPanel.fieldList
|
|
}
|
|
|
|
var values = {}
|
|
// add row with default values to create new record
|
|
if (isPanelValues) {
|
|
// add row with values used from record in panel
|
|
values = rootGetters.getColumnNamesAndValues({
|
|
containerUuid: containerUuid,
|
|
propertyName: 'value',
|
|
isObjectReturn: true,
|
|
isAddDisplayColumn: true,
|
|
fieldList: fieldList
|
|
})
|
|
} else {
|
|
values = rootGetters.getParsedDefaultValues({
|
|
parentUuid: parentUuid,
|
|
containerUuid: containerUuid,
|
|
fieldList: fieldList
|
|
})
|
|
}
|
|
values.isNew = isNew
|
|
values.isEdit = isEdit
|
|
values.isSendServer = false
|
|
|
|
// get the link column name from the tab
|
|
var linkColumnName = tabPanel.linkColumnName
|
|
if (isEmptyValue(linkColumnName)) {
|
|
// get the link column name from field list
|
|
linkColumnName = tabPanel.fieldLinkColumnName
|
|
}
|
|
|
|
var valueLink
|
|
// get context value if link column exists and does not exist in row
|
|
if (!isEmptyValue(linkColumnName)) {
|
|
valueLink = rootGetters.getContext({
|
|
parentUuid: parentUuid,
|
|
containerUuid: containerUuid,
|
|
columnName: linkColumnName
|
|
})
|
|
}
|
|
if (!isEmptyValue(valueLink)) {
|
|
valueLink = parseInt(valueLink, 10)
|
|
}
|
|
|
|
// get display column
|
|
if (fieldList.length) {
|
|
fieldList
|
|
// TODO: Evaluate if is field is read only and FieldSelect
|
|
.filter(itemField => itemField.componentPath === 'FieldSelect' || String(values[itemField.columnName]) === '[object Object]')
|
|
.forEach(itemField => {
|
|
var valueGetDisplayColumn = values[itemField.columnName]
|
|
if (String(values[itemField.columnName]) === '[object Object]' && itemField.componentPath === 'FieldSelect') {
|
|
values[itemField.columnName] = ' '
|
|
values['DisplayColumn_' + itemField.columnName] = ' '
|
|
} else if (String(values[itemField.columnName]) === '[object Object]' && itemField.componentPath === 'FieldNumber') {
|
|
values[itemField.columnName] = 0
|
|
}
|
|
// overwrite value with column link
|
|
if (!isEmptyValue(linkColumnName) && linkColumnName === itemField.columnName) {
|
|
valueGetDisplayColumn = valueLink
|
|
}
|
|
|
|
// break this itineration if is empty
|
|
if (isEmptyValue(valueGetDisplayColumn)) {
|
|
return
|
|
}
|
|
// always the values for these types of fields are integers
|
|
if (['TableDirect'].includes(itemField.referenceType)) {
|
|
valueGetDisplayColumn = parseInt(valueGetDisplayColumn, 10)
|
|
} else {
|
|
if (!isNaN(valueGetDisplayColumn)) {
|
|
valueGetDisplayColumn = parseInt(valueGetDisplayColumn, 10)
|
|
}
|
|
}
|
|
if (!isEmptyValue(valueGetDisplayColumn) && String(valueGetDisplayColumn) === '[object Object]') {
|
|
// get value from direct Query
|
|
dispatch('getRecordBySQL', { query: valueGetDisplayColumn.query, field: itemField })
|
|
.then(defaultValue => {
|
|
if (itemField.componentPath === 'FieldSelect') {
|
|
values[itemField.columnName] = defaultValue.key
|
|
values['DisplayColumn_' + itemField.columnName] = defaultValue.label
|
|
} else {
|
|
values[itemField.columnName] = defaultValue.key
|
|
dispatch('notifyRowTableChange', {
|
|
parentUuid: parentUuid,
|
|
containerUuid: containerUuid,
|
|
isNew: isNew,
|
|
isEdit: isEdit,
|
|
values: values
|
|
})
|
|
}
|
|
})
|
|
return
|
|
}
|
|
// get label (DisplayColumn) from vuex store
|
|
const options = rootGetters.getLookupAll({
|
|
parentUuid: parentUuid,
|
|
containerUuid: containerUuid,
|
|
tableName: itemField.reference.tableName,
|
|
query: itemField.reference.query,
|
|
directQuery: itemField.reference.directQuery,
|
|
value: valueGetDisplayColumn
|
|
})
|
|
|
|
const option = options.find(itemOption => itemOption.key === valueGetDisplayColumn)
|
|
// if there is a lookup option, assign the display column with the label
|
|
if (option) {
|
|
values['DisplayColumn_' + itemField.columnName] = option.label
|
|
return
|
|
}
|
|
if (linkColumnName === itemField.columnName) {
|
|
// get context value if link column exists and does not exist in row
|
|
const nameParent = rootGetters.getContext({
|
|
parentUuid: parentUuid,
|
|
containerUuid: containerUuid,
|
|
columnName: 'Name'
|
|
})
|
|
if (nameParent) {
|
|
values['DisplayColumn_' + itemField.columnName] = nameParent
|
|
return
|
|
}
|
|
}
|
|
// get from server
|
|
dispatch('getLookupItemFromServer', {
|
|
parentUuid: parentUuid,
|
|
containerUuid: containerUuid,
|
|
tableName: itemField.reference.tableName,
|
|
directQuery: itemField.reference.directQuery,
|
|
value: valueGetDisplayColumn
|
|
})
|
|
.then(responseLookup => {
|
|
dispatch('addDisplayColumn', {
|
|
containerUuid: containerUuid,
|
|
columnName: itemField.columnName,
|
|
displayColumn: responseLookup.label
|
|
})
|
|
})
|
|
})
|
|
}
|
|
|
|
// overwrite value with column link
|
|
if (isEmptyValue(values[linkColumnName])) {
|
|
values[linkColumnName] = valueLink
|
|
}
|
|
|
|
const dataStore = getters.getDataRecordsList(containerUuid)
|
|
commit('addNewRow', {
|
|
values: values,
|
|
data: dataStore
|
|
})
|
|
},
|
|
addDisplayColumn({ commit, getters }, parameters) {
|
|
const { containerUuid, columnName, displayColumn } = parameters
|
|
const dataStore = getters.getDataRecordsList(containerUuid)
|
|
const rowRecord = dataStore.find(itemData => itemData.isNew)
|
|
|
|
commit('addDisplayColumn', {
|
|
row: rowRecord,
|
|
displayColumn: displayColumn,
|
|
columnName: 'DisplayColumn_' + columnName
|
|
})
|
|
},
|
|
/**
|
|
* Is load context in true when panel is set context
|
|
* @param {string} parameters.containerUuid
|
|
*/
|
|
setIsloadContext({ commit, state }, parameters) {
|
|
const { containerUuid } = parameters
|
|
const data = state.recordSelection.find(recordItem => {
|
|
return recordItem.containerUuid === containerUuid
|
|
})
|
|
if (data) {
|
|
commit('setIsloadContext', {
|
|
data: data,
|
|
isLoadedContext: true
|
|
})
|
|
}
|
|
},
|
|
/**
|
|
* Set record, selection, page number, token, and record count, with container uuid
|
|
* TODO: Refactor and optimize the mutation of state
|
|
* @param {string} parameters.containerUuid
|
|
* @param {array} parameters.record
|
|
* @param {array} parameters.selection
|
|
* @param {integer} parameters.pageNumber
|
|
* @param {integer} parameters.recordCount
|
|
* @param {string} parameters.nextPageToken
|
|
* @param {string} parameters.panelType
|
|
*/
|
|
setRecordSelection({ commit, state }, parameters) {
|
|
const { parentUuid, containerUuid, record = [], selection = [], pageNumber = 1, recordCount = 0, nextPageToken, panelType = 'window' } = parameters
|
|
var index = state.recordSelection.findIndex(recordItem => {
|
|
return recordItem.containerUuid === containerUuid
|
|
})
|
|
commit('setRecordSelection', {
|
|
parentUuid: parentUuid,
|
|
containerUuid: containerUuid,
|
|
record: record,
|
|
selection: selection,
|
|
pageNumber: pageNumber,
|
|
recordCount: recordCount,
|
|
nextPageToken: nextPageToken,
|
|
panelType: panelType,
|
|
isLoaded: true,
|
|
isLoadedContext: false,
|
|
index: index
|
|
})
|
|
},
|
|
/**
|
|
* Set selection in data list associated in container
|
|
* @param {string} parameters.containerUuid
|
|
* @param {string} parameters.selection
|
|
*/
|
|
setSelection({ commit, getters }, parameters) {
|
|
const recordSelection = getters.getDataRecordAndSelection(parameters.containerUuid)
|
|
commit('setSelection', {
|
|
newSelection: parameters.selection,
|
|
data: recordSelection
|
|
})
|
|
},
|
|
/**
|
|
* Delete record result in container
|
|
* @param {string} viewUuid // As parentUuid in window
|
|
* @param {array} withOut
|
|
*/
|
|
deleteRecordContainer({ commit, state, dispatch }, parameters) {
|
|
const { viewUuid, withOut = [], isNew = false } = parameters
|
|
var setNews = []
|
|
const record = state.recordSelection.filter(itemRecord => {
|
|
// ignore this uuid
|
|
if (withOut.includes(itemRecord.containerUuid)) {
|
|
return true
|
|
}
|
|
// remove window and tabs data
|
|
if (itemRecord.parentUuid) {
|
|
if (isNew) {
|
|
setNews.push(itemRecord.containerUuid)
|
|
}
|
|
return itemRecord.parentUuid !== viewUuid
|
|
}
|
|
// remove browser data
|
|
return itemRecord.containerUuid !== viewUuid
|
|
})
|
|
commit('deleteRecordContainer', record)
|
|
|
|
if (setNews.length) {
|
|
setNews.forEach(uuid => {
|
|
dispatch('setRecordSelection', {
|
|
parentUuid: viewUuid,
|
|
containerUuid: uuid
|
|
})
|
|
})
|
|
}
|
|
},
|
|
/**
|
|
* @param {string} tableName
|
|
* @param {string} recordUuid
|
|
*/
|
|
getEntity({ commit }, parameters) {
|
|
return new Promise((resolve, reject) => {
|
|
getObject(parameters.tableName, parameters.recordUuid)
|
|
.then(response => {
|
|
var map = response.getValuesMap()
|
|
var newValues = convertValuesMapToObject(map)
|
|
const responseConvert = {
|
|
data: newValues,
|
|
id: response.getId(),
|
|
uuid: response.getUuid(),
|
|
tableName: parameters.tableName
|
|
}
|
|
|
|
commit('setRecordDetail', responseConvert)
|
|
resolve(newValues)
|
|
})
|
|
.catch(error => {
|
|
reject(error)
|
|
})
|
|
})
|
|
},
|
|
/**
|
|
* Request list to view in table
|
|
* TODO: Join with getDataListTab action
|
|
* @param {string} parentUuid, uuid from window
|
|
* @param {string} containerUuid, uuid from tab
|
|
* @param {string} tableName, table name to search record data
|
|
* @param {string} query, criteria to search record data
|
|
* @param {string} whereClause, criteria to search record data
|
|
* @param {string} orderByClause, criteria to search record data
|
|
* @param {array} conditions, conditions to criteria
|
|
*/
|
|
getObjectListFromCriteria({ commit, dispatch, getters, rootGetters }, parameters) {
|
|
const { parentUuid, containerUuid, tableName, query, whereClause, orderByClause, conditions = [], isShowNotification = true, isParentTab = true } = parameters
|
|
if (isShowNotification) {
|
|
showMessage({
|
|
title: language.t('notifications.loading'),
|
|
message: language.t('notifications.searching'),
|
|
type: 'info'
|
|
})
|
|
}
|
|
const dataStore = getters.getDataRecordAndSelection(containerUuid)
|
|
|
|
var nextPageToken
|
|
if (!isEmptyValue(dataStore.nextPageToken)) {
|
|
nextPageToken = dataStore.nextPageToken + '-' + dataStore.pageNumber
|
|
}
|
|
|
|
var inEdited = []
|
|
if (!isParentTab) {
|
|
// TODO: Evaluate peformance to evaluate records to edit
|
|
inEdited = dataStore.record.filter(itemRecord => {
|
|
return itemRecord.isEdit && !itemRecord.isNew
|
|
})
|
|
}
|
|
|
|
commit('addInGetting', {
|
|
containerUuid: containerUuid,
|
|
tableName: tableName,
|
|
conditions: conditions
|
|
})
|
|
|
|
// gets the default value of the fields (including whether it is empty or undefined)
|
|
const defaultValues = rootGetters.getParsedDefaultValues({
|
|
parentUuid: parentUuid,
|
|
containerUuid: containerUuid,
|
|
isGetServer: false
|
|
})
|
|
return getObjectListFromCriteria({
|
|
tableName: tableName,
|
|
query: query,
|
|
whereClause: whereClause,
|
|
conditions: conditions,
|
|
orderByClause: orderByClause,
|
|
nextPageToken: nextPageToken
|
|
})
|
|
.then(response => {
|
|
const recordList = response.getRecordsList()
|
|
const record = recordList.map(itemRecord => {
|
|
var values = convertValuesMapToObject(
|
|
itemRecord.getValuesMap()
|
|
)
|
|
|
|
// datatables attribute
|
|
values.isNew = false
|
|
values.isEdit = false
|
|
values.isSelected = false
|
|
values.isReadOnlyFromRow = false
|
|
|
|
if (inEdited.find(itemEdit => itemEdit.UUID === values.UUID)) {
|
|
values.isEdit = true
|
|
}
|
|
|
|
// overwrite default values and sets the values obtained from the
|
|
// server (empty fields are not brought from the server)
|
|
return {
|
|
...defaultValues,
|
|
...values
|
|
}
|
|
})
|
|
|
|
var token = response.getNextPageToken()
|
|
if (!isEmptyValue(token)) {
|
|
token = token.slice(0, -2)
|
|
if (token.substr(-1, 1) === '-') {
|
|
token = token.slice(0, -1)
|
|
}
|
|
} else {
|
|
token = dataStore.nextPageToken
|
|
}
|
|
if (isShowNotification) {
|
|
let searchMessage = 'searchWithOutRecords'
|
|
if (record.length) {
|
|
searchMessage = 'succcessSearch'
|
|
}
|
|
showMessage({
|
|
title: language.t('notifications.succesful'),
|
|
message: language.t(`notifications.${searchMessage}`),
|
|
type: 'success'
|
|
})
|
|
}
|
|
dispatch('setRecordSelection', {
|
|
parentUuid: parentUuid,
|
|
containerUuid: containerUuid,
|
|
record: record,
|
|
selection: dataStore.selection,
|
|
recordCount: response.getRecordcount(),
|
|
nextPageToken: token,
|
|
pageNumber: dataStore.pageNumber
|
|
})
|
|
return record
|
|
})
|
|
.catch(error => {
|
|
// Set default registry values so that the table does not say loading,
|
|
// there was already a response from the server
|
|
dispatch('setRecordSelection', {
|
|
parentUuid: parentUuid,
|
|
containerUuid: containerUuid
|
|
})
|
|
|
|
if (isShowNotification) {
|
|
showMessage({
|
|
title: language.t('notifications.error'),
|
|
message: error.message,
|
|
type: 'error'
|
|
})
|
|
}
|
|
console.warn('Error Get Object List ' + error.message + '. Code: ' + error.code)
|
|
})
|
|
.finally(() => {
|
|
commit('deleteInGetting', {
|
|
containerUuid: containerUuid,
|
|
tableName: tableName
|
|
})
|
|
})
|
|
},
|
|
getRecordBySQL({ dispatch }, parameters) {
|
|
const { query, field } = parameters
|
|
return new Promise((resolve, reject) => {
|
|
getDefaultValueFromServer(query)
|
|
.then(response => {
|
|
var valueToReturn = {}
|
|
valueToReturn['key'] = convertValueFromGRPC(response)
|
|
// add display Column for table
|
|
if (field.componentPath === 'FieldSelect') {
|
|
dispatch('getLookupItemFromServer', {
|
|
parentUuid: field.parentUuid,
|
|
containerUuid: field.containerUuid,
|
|
tableName: field.reference.tableName,
|
|
directQuery: field.reference.directQuery,
|
|
value: valueToReturn.key
|
|
})
|
|
.then(responseLookup => {
|
|
valueToReturn['label'] = responseLookup.label
|
|
dispatch('addDisplayColumn', {
|
|
containerUuid: field.containerUuid,
|
|
columnName: field.columnName,
|
|
displayColumn: responseLookup.label
|
|
})
|
|
})
|
|
}
|
|
resolve(valueToReturn)
|
|
})
|
|
.catch(error => {
|
|
reject(error)
|
|
})
|
|
})
|
|
},
|
|
getRecentItemsFromServer({ commit }) {
|
|
return new Promise((resolve, reject) => {
|
|
getRecentItems()
|
|
.then(response => {
|
|
const recentItems = response.getRecentitemsList().map(item => {
|
|
return {
|
|
action: convertAction(item.getAction()).name,
|
|
icon: convertAction(item.getAction()).icon,
|
|
displayName: item.getDisplayname(),
|
|
menuUuid: item.getMenuuuid(),
|
|
menuName: item.getMenuname(),
|
|
windowUuid: item.getWindowuuid(),
|
|
tableId: item.getTableid(),
|
|
recordId: item.getRecordid(),
|
|
uuidRecord: item.getRecorduuid(),
|
|
tabUuid: item.getTabuuid(),
|
|
updated: new Date(item.getUpdated()),
|
|
description: item.getMenudescription()
|
|
}
|
|
})
|
|
commit('setRecentItems', recentItems)
|
|
resolve(recentItems)
|
|
})
|
|
.catch(error => {
|
|
reject(error)
|
|
})
|
|
})
|
|
},
|
|
/**
|
|
* TODO: Add support to tab children
|
|
* @param {object} objectParams
|
|
* @param {string} objectParams.containerUuid
|
|
* @param {objec} objectParams.row, new data to change
|
|
* @param {objec} objectParams.isEdit, if the row displayed to edit mode
|
|
* @param {objec} objectParams.isNew, if insert data to new row
|
|
*/
|
|
notifyRowTableChange({ commit, state, getters, rootGetters }, objectParams) {
|
|
const { parentUuid, containerUuid, isEdit = true } = objectParams
|
|
var currentValues = {}
|
|
if (objectParams.hasOwnProperty('values')) {
|
|
currentValues = objectParams.values
|
|
} else {
|
|
currentValues = rootGetters.getColumnNamesAndValues({
|
|
parentUuid: parentUuid,
|
|
containerUuid: containerUuid,
|
|
propertyName: 'value',
|
|
isObjectReturn: true,
|
|
isAddDisplayColumn: true
|
|
})
|
|
}
|
|
|
|
var row = getters.getRowData(objectParams.containerUuid, currentValues.UUID)
|
|
|
|
var newRow = {
|
|
...currentValues,
|
|
// ...objectParams.row,
|
|
isEdit: isEdit
|
|
}
|
|
|
|
commit('notifyRowTableChange', {
|
|
isNew: objectParams.isNew,
|
|
newRow: newRow,
|
|
row: row
|
|
})
|
|
},
|
|
notifyCellTableChange({ commit, state, dispatch, rootGetters }, parameters) {
|
|
const {
|
|
parentUuid, containerUuid, field, panelType = 'window',
|
|
isSendToServer = true, columnName, rowKey, keyColumn, newValue,
|
|
displayColumn, withOutColumnNames = [], isSendCallout = true
|
|
} = parameters
|
|
|
|
const recordSelection = state.recordSelection.find(recordItem => {
|
|
return recordItem.containerUuid === containerUuid
|
|
})
|
|
const row = recordSelection.record.find(itemRecord => {
|
|
return itemRecord[keyColumn] === rowKey
|
|
})
|
|
|
|
// the field has not changed, then the action is broken
|
|
if (row[columnName] === newValue) {
|
|
return
|
|
}
|
|
|
|
const rowSelection = recordSelection.selection.find(itemRecord => {
|
|
return itemRecord[keyColumn] === rowKey
|
|
})
|
|
commit('notifyCellTableChange', {
|
|
row: row,
|
|
value: newValue,
|
|
columnName: columnName,
|
|
displayColumn: displayColumn
|
|
})
|
|
|
|
if (panelType === 'browser') {
|
|
commit('notifyCellSelectionChange', {
|
|
row: rowSelection,
|
|
value: newValue,
|
|
columnName: columnName,
|
|
displayColumn: displayColumn
|
|
})
|
|
} else if (panelType === 'window') {
|
|
// request callouts
|
|
if (isSendCallout && !withOutColumnNames.includes(field.columnName) &&
|
|
!isEmptyValue(newValue) && !isEmptyValue(field.callout)) {
|
|
withOutColumnNames.push(field.columnName)
|
|
dispatch('getCallout', {
|
|
parentUuid: parentUuid,
|
|
containerUuid: containerUuid,
|
|
tableName: field.tableName,
|
|
columnName: field.columnName,
|
|
callout: field.callout,
|
|
value: newValue,
|
|
withOutColumnNames: withOutColumnNames,
|
|
row: row,
|
|
inTable: true
|
|
})
|
|
}
|
|
|
|
if (isSendToServer) {
|
|
const fieldNotReady = rootGetters.isNotReadyForSubmit(containerUuid, row)
|
|
if (!fieldNotReady) {
|
|
if (!isEmptyValue(row.UUID)) {
|
|
dispatch('updateCurrentEntityFromTable', {
|
|
parentUuid: parentUuid,
|
|
containerUuid: containerUuid,
|
|
row: row
|
|
})
|
|
} else {
|
|
dispatch('createEntityFromTable', {
|
|
parentUuid: parentUuid,
|
|
containerUuid: containerUuid,
|
|
row: row
|
|
})
|
|
.then(() => {
|
|
// refresh record list
|
|
dispatch('getDataListTab', {
|
|
parentUuid: parentUuid,
|
|
containerUuid: containerUuid
|
|
})
|
|
})
|
|
}
|
|
} else {
|
|
const fieldsEmpty = rootGetters.getFieldListEmptyMandatory({
|
|
containerUuid: containerUuid,
|
|
row: row
|
|
})
|
|
showMessage({
|
|
message: language.t('notifications.mandatoryFieldMissing') + fieldsEmpty,
|
|
type: 'info'
|
|
})
|
|
}
|
|
}
|
|
}
|
|
},
|
|
getContextInfoValueFromServer({ commit, getters }, parameters) {
|
|
var { sqlStatement, contextInfoUuid } = parameters
|
|
var contextInforField = getters.getContextInfoField(contextInfoUuid, sqlStatement)
|
|
if (contextInforField) {
|
|
return contextInforField
|
|
}
|
|
return getContextInfoValueFromServer({ uuid: contextInfoUuid, query: sqlStatement })
|
|
.then(response => {
|
|
const contextInfo = {
|
|
messageText: response.getMessagetext(),
|
|
messageTip: response.getMessagetip()
|
|
}
|
|
commit('setContextInfoField', {
|
|
contextInfoUuid: contextInfoUuid,
|
|
sqlStatement: sqlStatement,
|
|
messageText: contextInfo.messageText,
|
|
messageTip: contextInfo.messageTip
|
|
})
|
|
return contextInfo
|
|
})
|
|
.catch(error => {
|
|
console.warn(`Error ${error.code} getting context info value for field ${error.message}`)
|
|
})
|
|
}
|
|
},
|
|
getters: {
|
|
getInGetting: (state) => (containerUuid) => {
|
|
return state.inGetting.find(item => item.containerUuid === containerUuid)
|
|
},
|
|
/**
|
|
* Used by datatables in tab children, record navigation in window, result in browser
|
|
* @param {string} containerUuid
|
|
*/
|
|
getDataRecordAndSelection: (state, getters) => (containerUuid) => {
|
|
return state.recordSelection.find(itemRecord => {
|
|
return itemRecord.containerUuid === containerUuid
|
|
}) || {
|
|
containerUuid: containerUuid,
|
|
record: [],
|
|
recordCount: 0,
|
|
selection: [],
|
|
pageNumber: 1,
|
|
nextPageToken: undefined,
|
|
isLoadedContext: false,
|
|
isLoaded: false // Boolean(false || getters.getInGetting(containerUuid))
|
|
}
|
|
},
|
|
getDataRecordsList: (state, getters) => (containerUuid) => {
|
|
return getters.getDataRecordAndSelection(containerUuid).record
|
|
},
|
|
getDataRecordCount: (state, getters) => (containerUuid) => {
|
|
return getters.getDataRecordAndSelection(containerUuid).recordCount
|
|
},
|
|
getPageNextToken: (state, getters) => (containerUuid) => {
|
|
return getters.getDataRecordAndSelection(containerUuid).nextPageToken
|
|
},
|
|
getDataRecordSelection: (state, getters) => (containerUuid) => {
|
|
return getters.getDataRecordAndSelection(containerUuid).selection
|
|
},
|
|
getPageNumber: (state, getters) => (containerUuid) => {
|
|
return getters.getDataRecordAndSelection(containerUuid).pageNumber
|
|
},
|
|
getRowData: (state, getters) => (containerUuid, recordUuid) => {
|
|
return getters.getDataRecordsList(containerUuid).find(itemData => {
|
|
if (itemData.UUID === recordUuid) {
|
|
return true
|
|
}
|
|
})
|
|
},
|
|
/**
|
|
* @returns {object}
|
|
*/
|
|
getRecordDetail: (state) => (parameters) => {
|
|
return state.recordDetail.find(itemData => {
|
|
if (itemData.uuid === parameters.recordUuid) {
|
|
return true
|
|
}
|
|
}) || {}
|
|
},
|
|
/**
|
|
* Getter converter selection data record in format
|
|
* @param {string} containerUuid
|
|
* [
|
|
* {
|
|
* selectionId: keyColumn Value,
|
|
* selectionValues: [
|
|
* { columname, value },
|
|
* { columname, value },
|
|
* { columname, value }
|
|
* ]
|
|
* },
|
|
* {
|
|
* selectionId: keyColumn Value,
|
|
* selectionValues: [
|
|
* { columname, value },
|
|
* { columname, value }
|
|
* ]
|
|
* }
|
|
* ]
|
|
*/
|
|
getSelectionToServer: (state, getters, rootState, rootGetters) => (parameters) => {
|
|
var { containerUuid, selection = [] } = parameters
|
|
var selectionToServer = []
|
|
const withOut = ['isEdit', 'isSelected', 'isSendToServer']
|
|
|
|
if (selection.length <= 0) {
|
|
selection = getters.getDataRecordSelection(containerUuid)
|
|
}
|
|
if (selection.length) {
|
|
const panel = rootGetters.getPanel(containerUuid)
|
|
|
|
selection.forEach(itemRow => {
|
|
var records = []
|
|
|
|
Object.keys(itemRow).forEach(key => {
|
|
if (!key.includes('DisplayColumn') && !withOut.includes(key)) {
|
|
// evaluate metadata attributes before to convert
|
|
const field = panel.fieldList.find(itemField => itemField.columnName === key)
|
|
if (field && (field.isIdentifier || field.isUpdateable)) {
|
|
records.push({
|
|
columnName: key,
|
|
value: itemRow[key]
|
|
})
|
|
}
|
|
}
|
|
})
|
|
|
|
selectionToServer.push({
|
|
selectionId: itemRow[panel.keyColumn],
|
|
selectionValues: records
|
|
})
|
|
})
|
|
}
|
|
return selectionToServer
|
|
},
|
|
getRecentItems: (state) => {
|
|
return state.recentItems
|
|
},
|
|
getLanguageList: (state) => (roleUuid) => {
|
|
return state.recordSelection.find(
|
|
record => record.containerUuid === roleUuid
|
|
) || []
|
|
},
|
|
getContextInfoField: (state) => (contextInfoUuid, sqlStatement) => {
|
|
return state.contextInfoField.find(info =>
|
|
info.contextInfoUuid === contextInfoUuid &&
|
|
info.sqlStatement === sqlStatement
|
|
)
|
|
}
|
|
}
|
|
}
|
|
|
|
export default data
|