Skip to content

Commit

Permalink
new 'inputs' object param to OCA.Assistant.openAssistantForm to provi…
Browse files Browse the repository at this point in the history
…de all initial inputs

Signed-off-by: Julien Veyssier <[email protected]>
  • Loading branch information
julien-nc committed Apr 17, 2024
1 parent 7cf3cc9 commit 27f7375
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
5 changes: 3 additions & 2 deletions docs/developer/web-integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ It accepts one parameter which is an object that can contain those keys:
* appId: [string, mandatory] app id of the app currently displayed
* identifier: [string, optional, default: ''] the task identifier (if the task is scheduled, this helps to identify the task when receiving the "task finished" event in the backend)
* taskType: [string, optional, default: last used task type] initially selected task type. It can be a text processing task type class or `speech-to-text` or `OCP\TextToImage\Task`
* input: [string, optional, default: ''] initial input prompt
* input: [string, optional, default: '', DEPRECATED] initial input prompt (for task types that only require a prompt)
* inputs: [object, optional, default: {}] initial inputs (specific to each task type)
* isInsideViewer: [boolean, optional, default: false] should be true if this function is called while the Viewer is displayed
* closeOnResult: [boolean, optional, default: false] If true, the modal will be closed after running a synchronous task and getting its result
* actionButtons: [array, optional, default: empty list] List of extra buttons to show in the assistant result form (only used if closeOnResult is false)
Expand Down Expand Up @@ -65,7 +66,7 @@ OCA.Assistant.openAssistantForm({
appId: 'my_app_id',
identifier: 'my custom identifier',
taskType: 'OCP\\TextProcessing\\FreePromptTaskType',
input: 'count to 3',
inputs: { prompt: 'count to 3' },
actionButtons: [
{
label: 'Label 1',
Expand Down
7 changes: 4 additions & 3 deletions src/assistant.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,16 @@ export async function openAssistantTextProcessingForm(params) {
* @param {string} params.appId the scheduling app id
* @param {string} params.identifier the task identifier
* @param {string} params.taskType the text processing task type class
* @param {string} params.input optional initial input text
* @param {string} params.input DEPRECATED optional initial input text
* @param {object} params.inputs optional initial named inputs
* @param {boolean} params.isInsideViewer Should be true if this function is called while the Viewer is displayed
* @param {boolean} params.closeOnResult If true, the modal will be closed when getting a sync result
* @param {Array} params.actionButtons List of extra buttons to show in the assistant result form (only if closeOnResult is false)
* @param {boolean} params.useMetaTasks If true, the promise will resolve with the meta task object instead of the ocp task
* @return {Promise<unknown>}
*/
export async function openAssistantForm({
appId, identifier = '', taskType = null, input = '',
appId, identifier = '', taskType = null, input = '', inputs = {},
isInsideViewer = undefined, closeOnResult = false, actionButtons = undefined, useMetaTasks = true,
}) {
const { default: Vue } = await import(/* webpackChunkName: "vue-lazy" */'vue')
Expand All @@ -73,7 +74,7 @@ export async function openAssistantForm({
const view = new View({
propsData: {
isInsideViewer,
inputs: { prompt: input },
inputs: input ? { prompt: input } : inputs,
selectedTaskTypeId,
showScheduleConfirmation: false,
showSyncTaskRunning: false,
Expand Down

0 comments on commit 27f7375

Please sign in to comment.