mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-13 16:14:07 -08:00
5fec563c5c
* ⚡ Create endpoint for node credential translation * ⚡ Add API helper method in FE * 🔨 Add creds JSON files to tsconfig * ⚡ Refactor credentials loading * ⚡ Refactor calls in CredentialConfig * ✏️ Add dummy translations * ⚡ Split translations per node * 🔥 Remove deprecated method * ⚡ Refactor nesting in collections * 🚚 Rename topParameter methods for accuracy * ✏️ Fill out GitHub dummy cred * 🚚 Clarify naming for collection utils * ✏️ Fill out dummy translation * 🔥 Remove surplus colons * 🔥 Remove logging * ⚡ Restore missing space * 🔥 Remove lingering colon * ⚡ Add path to InputLabel calls * ✏️ Fill out dummy translations * 🐛 Fix multipleValuesButtonText logic * ⚡ Add sample properties to be deleted * ⚡ Render deeply nested params * 📦 Update package-lock.json * 🔥 remove logging * ✏️ Add dummy value to Slack translation * ✏️ Add placeholder to dummy translation * ⚡ Fix placeholder rendering for button text * 👕 Fix lint * 🔥 Remove outdated comment * 🐛 Pass in missing arg for placeholder * ✏️ Fill out Slack translation * ⚡ Add explanatory comment * ✏️ Fill out dummy translation * ✏️ Update documentation * 🔥 Remove broken link * ✏️ Add pending functionality * ✏️ Fix indentation * 🐛 Fix method call in CredentialEdit * ⚡ Implement eventTriggerDescription * 🐛 Fix table-json-binary radio buttons * ✏️ Clarify usage of eventTriggerDescription * 🔥 Remove unneeded arg * 🐛 Fix display in CodeEdit and TextEdit * 🔥 Remove logging * ✏️ Add translation for test cred options * ✏️ Add test for separate file in same dir * ✏️ Add test for versioned node * ✏️ Add test for node in grouped dir * ✏️ Add minor clarifications * ✏️ Add nested collection test * ✏️ Add pending functionality * ⚡ Generalize collections handling * 🚚 Rename helper to remove redundancy * 🚚 Improve naming in helpers * ✏️ Improve helpers documentation * ✏️ Improve i18n methods documentation * 🚚 Make endpoint naming consistent * ✏️ Add final newlines * ✏️ Clean up JSON examples * ⚡ Reuse i18n method * ⚡ Improve utils readability * ⚡ Return early if cred translation exists * 🔥 Remove dummy translations
193 lines
5.1 KiB
Vue
193 lines
5.1 KiB
Vue
<template>
|
|
<div @keydown.stop class="duplicate-parameter">
|
|
<n8n-input-label
|
|
:label="$locale.nodeText().inputLabelDisplayName(parameter, path)"
|
|
:tooltipText="$locale.nodeText().inputLabelDescription(parameter, path)"
|
|
:underline="true"
|
|
:labelHoverableOnly="true"
|
|
size="small"
|
|
>
|
|
|
|
<div v-for="(value, index) in values" :key="index" class="duplicate-parameter-item" :class="parameter.type">
|
|
<div class="delete-item clickable" v-if="!isReadOnly">
|
|
<font-awesome-icon icon="trash" :title="$locale.baseText('multipleParameter.deleteItem')" @click="deleteItem(index)" />
|
|
<div v-if="sortable">
|
|
<font-awesome-icon v-if="index !== 0" icon="angle-up" class="clickable" :title="$locale.baseText('multipleParameter.moveUp')" @click="moveOptionUp(index)" />
|
|
<font-awesome-icon v-if="index !== (values.length -1)" icon="angle-down" class="clickable" :title="$locale.baseText('multipleParameter.moveDown')" @click="moveOptionDown(index)" />
|
|
</div>
|
|
</div>
|
|
<div v-if="parameter.type === 'collection'">
|
|
<collection-parameter :parameter="parameter" :values="value" :nodeValues="nodeValues" :path="getPath(index)" :hideDelete="hideDelete" @valueChanged="valueChanged" />
|
|
</div>
|
|
<div v-else>
|
|
<parameter-input class="duplicate-parameter-input-item" :parameter="parameter" :value="value" :displayOptions="true" :path="getPath(index)" @valueChanged="valueChanged" inputSize="small" :isReadOnly="isReadOnly" />
|
|
</div>
|
|
</div>
|
|
|
|
<div class="add-item-wrapper">
|
|
<div v-if="values && Object.keys(values).length === 0 || isReadOnly" class="no-items-exist">
|
|
<n8n-text size="small">{{ $locale.baseText('multipleParameter.currentlyNoItemsExist') }}</n8n-text>
|
|
</div>
|
|
<n8n-button v-if="!isReadOnly" fullWidth @click="addItem()" :label="addButtonText" />
|
|
</div>
|
|
|
|
</n8n-input-label>
|
|
</div>
|
|
</template>
|
|
|
|
<script lang="ts">
|
|
import {
|
|
IUpdateInformation,
|
|
} from '@/Interface';
|
|
|
|
import CollectionParameter from '@/components/CollectionParameter.vue';
|
|
import ParameterInput from '@/components/ParameterInput.vue';
|
|
|
|
import { get } from 'lodash';
|
|
|
|
import { genericHelpers } from '@/components/mixins/genericHelpers';
|
|
|
|
import mixins from 'vue-typed-mixins';
|
|
|
|
export default mixins(genericHelpers)
|
|
.extend({
|
|
name: 'MultipleParameter',
|
|
components: {
|
|
CollectionParameter,
|
|
ParameterInput,
|
|
},
|
|
props: [
|
|
'nodeValues', // NodeParameters
|
|
'parameter', // NodeProperties
|
|
'path', // string
|
|
'values', // NodeParameters[]
|
|
],
|
|
computed: {
|
|
addButtonText (): string {
|
|
if (
|
|
!this.parameter.typeOptions ||
|
|
(this.parameter.typeOptions && !this.parameter.typeOptions.multipleValueButtonText)
|
|
) {
|
|
return this.$locale.baseText('multipleParameter.addItem');
|
|
}
|
|
|
|
return this.$locale.nodeText().multipleValueButtonText(this.parameter);
|
|
},
|
|
hideDelete (): boolean {
|
|
return this.parameter.options.length === 1;
|
|
},
|
|
sortable (): string {
|
|
return this.parameter.typeOptions && this.parameter.typeOptions.sortable;
|
|
},
|
|
},
|
|
methods: {
|
|
addItem () {
|
|
const name = this.getPath();
|
|
let currentValue = get(this.nodeValues, name);
|
|
|
|
if (currentValue === undefined) {
|
|
currentValue = [];
|
|
}
|
|
|
|
currentValue.push(JSON.parse(JSON.stringify(this.parameter.default)));
|
|
|
|
const parameterData = {
|
|
name,
|
|
value: currentValue,
|
|
};
|
|
|
|
this.$emit('valueChanged', parameterData);
|
|
},
|
|
deleteItem (index: number) {
|
|
const parameterData = {
|
|
name: this.getPath(index),
|
|
value: undefined,
|
|
};
|
|
|
|
this.$emit('valueChanged', parameterData);
|
|
},
|
|
getPath (index?: number): string {
|
|
return this.path + (index !== undefined ? `[${index}]` : '');
|
|
},
|
|
moveOptionDown (index: number) {
|
|
this.values.splice(index + 1, 0, this.values.splice(index, 1)[0]);
|
|
|
|
const parameterData = {
|
|
name: this.path,
|
|
value: this.values,
|
|
};
|
|
|
|
this.$emit('valueChanged', parameterData);
|
|
},
|
|
moveOptionUp (index: number) {
|
|
this.values.splice(index - 1, 0, this.values.splice(index, 1)[0]);
|
|
|
|
const parameterData = {
|
|
name: this.path,
|
|
value: this.values,
|
|
};
|
|
|
|
this.$emit('valueChanged', parameterData);
|
|
},
|
|
valueChanged (parameterData: IUpdateInformation) {
|
|
this.$emit('valueChanged', parameterData);
|
|
},
|
|
},
|
|
});
|
|
</script>
|
|
|
|
<style scoped lang="scss">
|
|
|
|
.duplicate-parameter-item ~.add-item-wrapper {
|
|
margin-top: var(--spacing-xs);
|
|
}
|
|
|
|
.delete-item {
|
|
display: none;
|
|
position: absolute;
|
|
left: 0.1em;
|
|
top: .3em;
|
|
z-index: 999;
|
|
color: #f56c6c;
|
|
width: 15px;
|
|
font-size: var(--font-size-2xs);
|
|
|
|
:hover {
|
|
color: #ff0000;
|
|
}
|
|
}
|
|
|
|
::v-deep .duplicate-parameter-item {
|
|
position: relative;
|
|
|
|
.multi > .delete-item{
|
|
top: 0.1em;
|
|
}
|
|
}
|
|
|
|
::v-deep .duplicate-parameter-input-item {
|
|
margin: 0.5em 0 0.25em 2em;
|
|
}
|
|
|
|
::v-deep .duplicate-parameter-item + .duplicate-parameter-item {
|
|
.collection-parameter-wrapper {
|
|
border-top: 1px dashed #999;
|
|
margin-top: var(--spacing-xs);
|
|
}
|
|
}
|
|
|
|
.no-items-exist {
|
|
margin: var(--spacing-xs) 0;
|
|
}
|
|
</style>
|
|
|
|
<style>
|
|
.duplicate-parameter-item:hover > .delete-item {
|
|
display: inline;
|
|
}
|
|
|
|
.duplicate-parameter-item .multi > .delete-item{
|
|
top: 0.1em;
|
|
}
|
|
</style>
|