Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'inputs' object param to OCA.Assistant.openAssistantForm #73

Merged
merged 1 commit into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading