forked from AutomaApp/automa
-
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.
- Loading branch information
Showing
6 changed files
with
169 additions
and
117 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,3 +27,5 @@ get-pass-key.js | |
getPassKey.js | ||
|
||
.idea | ||
|
||
business/prod |
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
152 changes: 152 additions & 0 deletions
152
src/components/newtab/workflow/edit/EditWorkflowParameters.vue
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 |
---|---|---|
@@ -0,0 +1,152 @@ | ||
<template> | ||
<div | ||
class="overflow-auto scroll" | ||
style="max-height: calc(100vh - 15rem); min-height: 200px" | ||
> | ||
<p | ||
v-if="state.parameters.length === 0" | ||
class="my-4 text-center text-gray-600 dark:text-gray-200" | ||
> | ||
No parameters | ||
</p> | ||
<table v-else class="w-full"> | ||
<thead> | ||
<tr class="text-sm text-left"> | ||
<th>Name</th> | ||
<th>Type</th> | ||
<th>Placeholder</th> | ||
<th>Default Value</th> | ||
<th></th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<template v-for="(param, index) in state.parameters" :key="index"> | ||
<tr> | ||
<td> | ||
<ui-input | ||
:model-value="param.name" | ||
placeholder="Parameter name" | ||
@change="updateParam(index, $event)" | ||
/> | ||
</td> | ||
<td> | ||
<ui-select v-model="param.type"> | ||
<option | ||
v-for="type in paramTypes" | ||
:key="type.id" | ||
:value="type.id" | ||
> | ||
{{ type.name }} | ||
</option> | ||
</ui-select> | ||
</td> | ||
<td> | ||
<ui-input v-model="param.placeholder" placeholder="A parameter" /> | ||
</td> | ||
<td> | ||
<component | ||
:is="paramTypes[param.type].valueComp" | ||
v-if="paramTypes[param.type].valueComp" | ||
v-model="param.defaultValue" | ||
:param-data="param" | ||
/> | ||
<ui-input | ||
v-else | ||
v-model="param.defaultValue" | ||
:type="param.type === 'number' ? 'number' : 'text'" | ||
placeholder="NULL" | ||
/> | ||
</td> | ||
<td> | ||
<ui-button icon @click="state.parameters.splice(index, 1)"> | ||
<v-remixicon name="riDeleteBin7Line" /> | ||
</ui-button> | ||
</td> | ||
</tr> | ||
<tr v-if="paramTypes[param.type].options"> | ||
<td colspan="999" style="padding-top: 0"> | ||
<ui-expand | ||
hide-header-icon | ||
header-class="flex items-center focus:ring-0 w-full" | ||
> | ||
<template #header="{ show }"> | ||
<v-remixicon | ||
:rotate="show ? 270 : 180" | ||
name="riArrowLeftSLine" | ||
class="mr-2 transition-transform -ml-1" | ||
/> | ||
<span>Options</span> | ||
</template> | ||
<div class="pl-[28px] mt-2 mb-4"> | ||
<component | ||
:is="paramTypes[param.type].options" | ||
v-model="param.data" | ||
/> | ||
</div> | ||
</ui-expand> | ||
</td> | ||
</tr> | ||
</template> | ||
</tbody> | ||
</table> | ||
</div> | ||
<ui-button variant="accent" class="mt-4" @click="addParameter"> | ||
Add parameter | ||
</ui-button> | ||
</template> | ||
<script setup> | ||
import { reactive, watch } from 'vue'; | ||
import cloneDeep from 'lodash.clonedeep'; | ||
import { workflowParameters } from '@business'; | ||
const props = defineProps({ | ||
data: { | ||
type: Array, | ||
default: () => [], | ||
}, | ||
}); | ||
const emit = defineEmits(['update']); | ||
const paramTypes = { | ||
string: { | ||
id: 'string', | ||
name: 'Input (string)', | ||
}, | ||
number: { | ||
id: 'number', | ||
name: 'Input (number)', | ||
}, | ||
...workflowParameters, | ||
}; | ||
const state = reactive({ | ||
parameters: cloneDeep(props.data || []), | ||
}); | ||
function addParameter() { | ||
state.parameters.push({ | ||
data: {}, | ||
name: 'param', | ||
type: 'string', | ||
defaultValue: '', | ||
placeholder: 'Text', | ||
}); | ||
} | ||
function updateParam(index, value) { | ||
state.parameters[index].name = value.replace(/\s/g, '_'); | ||
} | ||
watch( | ||
() => state.parameters, | ||
(parameters) => { | ||
emit('update', parameters); | ||
}, | ||
{ deep: true } | ||
); | ||
</script> | ||
<style scoped> | ||
table th, | ||
table td { | ||
@apply p-1 font-normal; | ||
} | ||
</style> |
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