Fix Actions dropdown options do not work

This commit is contained in:
p.kumar 2021-02-22 23:23:05 +05:30 committed by Dillon-Brown
parent d4844c8987
commit c642a86e04
4 changed files with 19 additions and 8 deletions

View file

@ -130,11 +130,19 @@ export class RecordStore {
*
* @returns {object} Record
*/
getRecord(): Record {
getBaseRecord(): Record {
if (!this.internalState) {
return null;
}
return deepClone(this.internalState);
const baseRecord = {
id: this.internalState.id,
type: this.internalState.type,
module: this.internalState.module,
attributes: this.internalState.attributes
} as Record;
return deepClone(baseRecord);
}
/**

View file

@ -17,6 +17,7 @@ export class RecordCreateAction extends RecordActionHandler {
run(data: RecordActionData): void {
const store = data.store;
const baseRecord = store.getBaseRecord();
const route = '/' + store.vm.appData.module.name + '/edit';
const module = this.moduleNameMapper.toLegacy(store.vm.appData.module.name);
@ -28,7 +29,7 @@ export class RecordCreateAction extends RecordActionHandler {
// eslint-disable-next-line camelcase,@typescript-eslint/camelcase
return_action: 'DetailView',
// eslint-disable-next-line camelcase,@typescript-eslint/camelcase
return_record: (store.getRecord() && store.getRecord().id) || ''
return_record: (baseRecord && baseRecord.id) || ''
}
}).then();
}

View file

@ -70,7 +70,8 @@ export class RecordActionsAdapter implements ActionDataSource {
meta,
mode,
record,
languages
languages,
widget
]
) => {
if (!mode || !meta) {
@ -135,13 +136,14 @@ export class RecordActionsAdapter implements ActionDataSource {
protected runAsyncAction(action: Action): void {
const actionName = `record-${action.key}`;
const baseRecord = this.store.getBaseRecord();
this.message.removeMessages();
const asyncData = {
action: actionName,
module: this.store.getRecord().module,
id: this.store.getRecord().id,
module: baseRecord.module,
id: baseRecord.id,
} as AsyncActionInput;
this.asyncActionService.run(actionName, asyncData).pipe(take(1)).subscribe((process: Process) => {

View file

@ -223,11 +223,11 @@ export class RecordViewStore extends ViewStore implements StateStore {
*
* @returns {string} ViewMode
*/
getRecord(): Record {
getBaseRecord(): Record {
if (!this.internalState) {
return null;
}
return this.recordStore.getRecord();
return this.recordStore.getBaseRecord();
}
/**