2019-06-23 03:35:23 -07:00
|
|
|
<template>
|
|
|
|
<div @keydown.stop class="duplicate-parameter">
|
|
|
|
|
|
|
|
<div class="parameter-name">
|
|
|
|
{{parameter.displayName}}:
|
2021-08-29 04:36:17 -07:00
|
|
|
<n8n-tooltip v-if="parameter.description" class="parameter-info" placement="top" >
|
|
|
|
<div slot="content" v-html="parameter.description"></div>
|
2019-07-07 07:32:28 -07:00
|
|
|
<font-awesome-icon icon="question-circle" />
|
2021-08-29 04:36:17 -07:00
|
|
|
</n8n-tooltip>
|
2019-06-23 03:35:23 -07:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div v-for="(value, index) in values" :key="index" class="duplicate-parameter-item" :class="parameter.type">
|
2020-12-26 15:15:33 -08:00
|
|
|
<div class="delete-item clickable" v-if="!isReadOnly">
|
|
|
|
<font-awesome-icon icon="trash" title="Delete Item" @click="deleteItem(index)" />
|
|
|
|
<div v-if="sortable">
|
|
|
|
<font-awesome-icon v-if="index !== 0" icon="angle-up" class="clickable" title="Move up" @click="moveOptionUp(index)" />
|
|
|
|
<font-awesome-icon v-if="index !== (values.length -1)" icon="angle-down" class="clickable" title="Move down" @click="moveOptionDown(index)" />
|
|
|
|
</div>
|
2019-06-23 03:35:23 -07:00
|
|
|
</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>
|
2021-08-29 04:36:17 -07:00
|
|
|
<parameter-input class="duplicate-parameter-input-item" :parameter="parameter" :value="value" :displayOptions="true" :path="getPath(index)" @valueChanged="valueChanged" inputSize="small" />
|
2019-06-23 03:35:23 -07:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="add-item-wrapper">
|
|
|
|
<div v-if="values && Object.keys(values).length === 0 || isReadOnly" class="no-items-exist">
|
|
|
|
Currently no items exist
|
|
|
|
</div>
|
2021-08-29 04:36:17 -07:00
|
|
|
<n8n-button v-if="!isReadOnly" fullWidth @click="addItem()" :label="addButtonText" />
|
2019-06-23 03:35:23 -07:00
|
|
|
</div>
|
|
|
|
|
|
|
|
</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';
|
2021-08-26 10:42:38 -07:00
|
|
|
import { addTargetBlank } from './helpers';
|
2019-06-23 03:35:23 -07:00
|
|
|
|
|
|
|
export default mixins(genericHelpers)
|
|
|
|
.extend({
|
|
|
|
name: 'MultipleParameter',
|
|
|
|
components: {
|
|
|
|
CollectionParameter,
|
|
|
|
ParameterInput,
|
|
|
|
},
|
|
|
|
props: [
|
|
|
|
'nodeValues', // NodeParameters
|
|
|
|
'parameter', // NodeProperties
|
|
|
|
'path', // string
|
|
|
|
'values', // NodeParameters[]
|
|
|
|
],
|
|
|
|
computed: {
|
|
|
|
addButtonText (): string {
|
|
|
|
return (this.parameter.typeOptions && this.parameter.typeOptions.multipleValueButtonText) ? this.parameter.typeOptions.multipleValueButtonText : 'Add item';
|
|
|
|
},
|
|
|
|
hideDelete (): boolean {
|
|
|
|
return this.parameter.options.length === 1;
|
|
|
|
},
|
2020-12-26 15:15:33 -08:00
|
|
|
sortable (): string {
|
|
|
|
return this.parameter.typeOptions && this.parameter.typeOptions.sortable;
|
|
|
|
},
|
2019-06-23 03:35:23 -07:00
|
|
|
},
|
|
|
|
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);
|
|
|
|
},
|
2021-08-26 10:42:38 -07:00
|
|
|
addTargetBlank,
|
2019-06-23 03:35:23 -07:00
|
|
|
deleteItem (index: number) {
|
|
|
|
const parameterData = {
|
|
|
|
name: this.getPath(index),
|
2019-07-14 05:10:16 -07:00
|
|
|
value: undefined,
|
2019-06-23 03:35:23 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
this.$emit('valueChanged', parameterData);
|
|
|
|
},
|
|
|
|
getPath (index?: number): string {
|
|
|
|
return this.path + (index !== undefined ? `[${index}]` : '');
|
|
|
|
},
|
2020-12-26 15:28:51 -08:00
|
|
|
moveOptionDown (index: number) {
|
2020-12-26 15:15:33 -08:00
|
|
|
this.values.splice(index + 1, 0, this.values.splice(index, 1)[0]);
|
|
|
|
|
|
|
|
const parameterData = {
|
|
|
|
name: this.path,
|
|
|
|
value: this.values,
|
|
|
|
};
|
|
|
|
|
|
|
|
this.$emit('valueChanged', parameterData);
|
|
|
|
},
|
2020-12-26 15:28:51 -08:00
|
|
|
moveOptionUp (index: number) {
|
2020-12-26 15:15:33 -08:00
|
|
|
this.values.splice(index - 1, 0, this.values.splice(index, 1)[0]);
|
|
|
|
|
|
|
|
const parameterData = {
|
|
|
|
name: this.path,
|
|
|
|
value: this.values,
|
|
|
|
};
|
|
|
|
|
|
|
|
this.$emit('valueChanged', parameterData);
|
|
|
|
},
|
2019-06-23 03:35:23 -07:00
|
|
|
valueChanged (parameterData: IUpdateInformation) {
|
|
|
|
this.$emit('valueChanged', parameterData);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
|
|
|
|
|
.duplicate-parameter-item ~.add-item-wrapper {
|
|
|
|
margin: 1.5em 0 0em 0em;
|
|
|
|
}
|
|
|
|
|
|
|
|
.add-item-wrapper {
|
|
|
|
margin: 0.5em 0 0em 2em;
|
|
|
|
}
|
|
|
|
|
|
|
|
.delete-item {
|
|
|
|
display: none;
|
|
|
|
position: absolute;
|
|
|
|
left: 0.1em;
|
|
|
|
top: .3em;
|
|
|
|
z-index: 999;
|
|
|
|
color: #f56c6c;
|
2020-12-26 15:15:33 -08:00
|
|
|
width: 15px;
|
2019-06-23 03:35:23 -07:00
|
|
|
|
|
|
|
:hover {
|
|
|
|
color: #ff0000;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.duplicate-parameter {
|
|
|
|
margin-top: 0.5em;
|
|
|
|
.parameter-name {
|
|
|
|
border-bottom: 1px solid #999;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-07 08:36:23 -08:00
|
|
|
::v-deep .duplicate-parameter-item {
|
2019-06-23 03:35:23 -07:00
|
|
|
position: relative;
|
|
|
|
margin-top: 0.5em;
|
|
|
|
padding-top: 0.5em;
|
|
|
|
|
|
|
|
.multi > .delete-item{
|
|
|
|
top: 0.1em;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-07 08:36:23 -08:00
|
|
|
::v-deep .duplicate-parameter-input-item {
|
2019-07-07 07:32:28 -07:00
|
|
|
margin: 0.5em 0 0.25em 2em;
|
2019-06-23 03:35:23 -07:00
|
|
|
}
|
|
|
|
|
2020-02-07 08:36:23 -08:00
|
|
|
::v-deep .duplicate-parameter-item + .duplicate-parameter-item {
|
2019-06-23 03:35:23 -07:00
|
|
|
.collection-parameter-wrapper {
|
|
|
|
border-top: 1px dashed #999;
|
|
|
|
padding-top: 0.5em;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.no-items-exist {
|
|
|
|
margin: 0 0 1em 0;
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
.duplicate-parameter-item:hover > .delete-item {
|
|
|
|
display: inline;
|
|
|
|
}
|
|
|
|
|
|
|
|
.duplicate-parameter-item .multi > .delete-item{
|
|
|
|
top: 0.1em;
|
|
|
|
}
|
|
|
|
</style>
|