Skip to content

Commit 1002014

Browse files
committed
feat(openAssistantForm): add param to restrict which task types are displayed
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
1 parent 7957474 commit 1002014

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

src/assistant.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ window.assistantPollTimerId = null
3939
* @param {string} params.appId the scheduling app id
4040
* @param {string} params.customId the task custom identifier
4141
* @param {string} params.identifier DEPRECATED the task custom identifier
42-
* @param {string} params.taskType the text processing task type class
42+
* @param {string} params.taskType the selected task type ID
43+
* @param {Array} params.taskTypeIdList the task types to display (all if not specified)
4344
* @param {string} params.input DEPRECATED optional initial input text
4445
* @param {object} params.inputs optional initial named inputs
4546
* @param {boolean} params.isInsideViewer Should be true if this function is called while the Viewer is displayed
@@ -49,7 +50,7 @@ window.assistantPollTimerId = null
4950
* @return {Promise<unknown>}
5051
*/
5152
export async function openAssistantForm({
52-
appId, taskType = null, input = '', inputs = {},
53+
appId, taskType = null, taskTypeIdList = null, input = '', inputs = {},
5354
isInsideViewer = undefined, closeOnResult = false, actionButtons = undefined,
5455
customId = '', identifier = '', mountPoint = null,
5556
}) {
@@ -92,6 +93,7 @@ export async function openAssistantForm({
9293
initSelectedTaskTypeId: selectedTaskTypeId,
9394
showSyncTaskRunning: false,
9495
actionButtons,
96+
taskTypeIdList,
9597
/*
9698
// events emitted by the root component can be listened to this way
9799
// this is a handler for the 'load-task' event

src/components/AssistantTextProcessingForm.vue

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,10 @@ export default {
234234
type: Array,
235235
default: () => [],
236236
},
237+
taskTypeIdList: {
238+
type: [Array, null],
239+
default: null,
240+
},
237241
},
238242
emits: [
239243
'sync-submit',
@@ -267,7 +271,11 @@ export default {
267271
return null
268272
},
269273
sortedTaskTypes() {
270-
return this.taskTypes.slice().sort((a, b) => {
274+
const filteredTaskTypes = this.taskTypeIdList !== null
275+
? this.taskTypes.slice().filter(t => this.taskTypeIdList.find(tt => tt === t.id))
276+
: this.taskTypes.slice()
277+
278+
return filteredTaskTypes.sort((a, b) => {
271279
const prioA = a.priority
272280
const prioB = b.priority
273281
return prioA > prioB

src/components/AssistantTextProcessingModal.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
:progress="progress"
3737
:expected-runtime="expectedRuntime"
3838
:is-notify-enabled="isNotifyEnabled"
39+
:task-type-id-list="taskTypeIdList"
3940
@sync-submit="onSyncSubmit"
4041
@action-button-clicked="onActionButtonClicked"
4142
@try-again="onTryAgain"
@@ -94,6 +95,10 @@ export default {
9495
type: Array,
9596
default: () => [],
9697
},
98+
taskTypeIdList: {
99+
type: [Array, null],
100+
default: null,
101+
},
97102
},
98103
emits: [
99104
'cancel',

0 commit comments

Comments
 (0)