-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
JNG-4838 finish bulk remove and delete
- Loading branch information
Showing
7 changed files
with
133 additions
and
52 deletions.
There are no files selected for viewing
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
49 changes: 47 additions & 2 deletions
49
judo-ui-react/src/main/resources/actor/src/pages/v2/actions/BulkDeleteAction.fragment.hbs
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 |
---|---|---|
@@ -1,3 +1,48 @@ | ||
const {{ simpleActionDefinitionName action.actionDefinition }} = async () => { | ||
// alert('BulkDeleteAction'); | ||
const {{ simpleActionDefinitionName action.actionDefinition }} = async (selectedRows: {{ classDataName action.actionDefinition.bulkOf.targetType 'Stored' }}[]): Promise<DialogResult<Array<{{ classDataName action.actionDefinition.bulkOf.targetType 'Stored' }}>>> => { | ||
{{# with (getTableParentForActionDefinition action.actionDefinition) as |table| }} | ||
return new Promise((resolve) => { | ||
openCRUDDialog<{{ classDataName (getReferenceClassType table) 'Stored' }}>({ | ||
dialogTitle: t('TMP', { defaultValue: 'Delete' }), | ||
{{# with (getFirstTitleColumnForTable table) as |column| }} | ||
itemTitleFn: (item) => item.{{ column.attributeType.name }}!, | ||
{{ else }} | ||
itemTitleFn: (item) => t('judo.placeholder', { defaultValue: 'placeholder' }) as string, | ||
{{/ with }} | ||
selectedItems: selectedRows, | ||
action: async (item, successHandler: () => void, errorHandler: (error: any) => void) => { | ||
try { | ||
if (actions.{{ simpleActionDefinitionName actionDefinition.bulkOf }}) { | ||
await actions.{{ simpleActionDefinitionName actionDefinition.bulkOf }}!(item, true); | ||
} | ||
successHandler(); | ||
} catch (error) { | ||
errorHandler(error); | ||
} | ||
}, | ||
onClose: async (needsRefresh) => { | ||
if (needsRefresh) { | ||
{{# if page.container.table }} | ||
setRefreshCounter((prev) => prev + 1); | ||
{{/ if }} | ||
{{# if page.container.view }} | ||
{{# with (getRefreshActionDefinitionForContainer page.container) as |refreshActionDefinition| }} | ||
if (actions.{{ simpleActionDefinitionName refreshActionDefinition }}) { | ||
await actions.{{ simpleActionDefinitionName refreshActionDefinition }}!(processQueryCustomizer(pageQueryCustomizer)); | ||
} | ||
{{/ with }} | ||
{{/ if }} | ||
resolve({ | ||
result: 'submit', | ||
data: [], | ||
}); | ||
} else { | ||
resolve({ | ||
result: 'close', | ||
data: [], | ||
}); | ||
} | ||
}, | ||
}); | ||
}); | ||
{{/ with }} | ||
}; |
58 changes: 56 additions & 2 deletions
58
judo-ui-react/src/main/resources/actor/src/pages/v2/actions/BulkRemoveAction.fragment.hbs
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 |
---|---|---|
@@ -1,3 +1,57 @@ | ||
const {{ simpleActionDefinitionName action.actionDefinition }} = async () => { | ||
// alert('BulkRemoveAction'); | ||
const {{ simpleActionDefinitionName action.actionDefinition }} = async (selectedRows: {{ classDataName action.actionDefinition.bulkOf.targetType 'Stored' }}[]): Promise<DialogResult<Array<{{ classDataName action.actionDefinition.bulkOf.targetType 'Stored' }}>>> => { | ||
{{# with (getTableParentForActionDefinition action.actionDefinition) as |table| }} | ||
return new Promise((resolve) => { | ||
{{# if table.isEager }} | ||
const selectedIds = selectedRows.map(r => r.__identifier); | ||
const newList = (data?.{{ table.dataElement.name }} ?? []).filter(c => !selectedIds.includes(c.__identifier)); | ||
storeDiff('{{ table.dataElement.name }}', newList); | ||
resolve({ | ||
result: 'submit', | ||
data: [], | ||
}); | ||
{{ else }} | ||
openCRUDDialog<{{ classDataName (getReferenceClassType table) 'Stored' }}>({ | ||
dialogTitle: t('TMP', { defaultValue: 'Remove' }), | ||
{{# with (getFirstTitleColumnForTable table) as |column| }} | ||
itemTitleFn: (item) => item.{{ column.attributeType.name }}!, | ||
{{ else }} | ||
itemTitleFn: (item) => t('judo.placeholder', { defaultValue: 'placeholder' }) as string, | ||
{{/ with }} | ||
selectedItems: selectedRows, | ||
action: async (item, successHandler: () => void, errorHandler: (error: any) => void) => { | ||
try { | ||
if (actions.{{ simpleActionDefinitionName actionDefinition.bulkOf }}) { | ||
await actions.{{ simpleActionDefinitionName actionDefinition.bulkOf }}!(item, true); | ||
} | ||
successHandler(); | ||
} catch (error) { | ||
errorHandler(error); | ||
} | ||
}, | ||
onClose: async (needsRefresh) => { | ||
if (needsRefresh) { | ||
{{# if page.container.table }} | ||
setRefreshCounter((prev) => prev + 1); | ||
{{/ if }} | ||
{{# if page.container.view }} | ||
{{# with (getRefreshActionDefinitionForContainer page.container) as |refreshActionDefinition| }} | ||
if (actions.{{ simpleActionDefinitionName refreshActionDefinition }}) { | ||
await actions.{{ simpleActionDefinitionName refreshActionDefinition }}!(processQueryCustomizer(pageQueryCustomizer)); | ||
} | ||
{{/ with }} | ||
{{/ if }} | ||
resolve({ | ||
result: 'submit', | ||
data: [], | ||
}); | ||
} else { | ||
resolve({ | ||
result: 'close', | ||
}); | ||
} | ||
}, | ||
}); | ||
{{/ if }} | ||
}); | ||
{{/ with }} | ||
}; |
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