mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
⚡ Fix that fixedCollection leaves empty arrays (#2792)
When deleting the single option inside of an option type, an empty array was left behind and will be: - shown as empty heading in UI - leave an empty array in JSON
This commit is contained in:
parent
7fc430c70a
commit
78babf9b9a
|
@ -4,7 +4,11 @@
|
||||||
<n8n-text size="small">{{ $locale.baseText('fixedCollectionParameter.currentlyNoItemsExist') }}</n8n-text>
|
<n8n-text size="small">{{ $locale.baseText('fixedCollectionParameter.currentlyNoItemsExist') }}</n8n-text>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-for="property in getProperties" :key="property.name" class="fixed-collection-parameter-property">
|
<div
|
||||||
|
v-for="property in getProperties"
|
||||||
|
:key="property.name"
|
||||||
|
class="fixed-collection-parameter-property"
|
||||||
|
>
|
||||||
<n8n-input-label
|
<n8n-input-label
|
||||||
:label="property.displayName === '' || parameter.options.length === 1 ? '' : $locale.nodeText().inputLabelDisplayName(property, path)"
|
:label="property.displayName === '' || parameter.options.length === 1 ? '' : $locale.nodeText().inputLabelDisplayName(property, path)"
|
||||||
:underline="true"
|
:underline="true"
|
||||||
|
@ -12,44 +16,93 @@
|
||||||
size="small"
|
size="small"
|
||||||
>
|
>
|
||||||
<div v-if="multipleValues === true">
|
<div v-if="multipleValues === true">
|
||||||
<div v-for="(value, index) in values[property.name]" :key="property.name + index" class="parameter-item">
|
<div
|
||||||
|
v-for="(value, index) in values[property.name]"
|
||||||
|
:key="property.name + index"
|
||||||
|
class="parameter-item"
|
||||||
|
>
|
||||||
<div class="parameter-item-wrapper">
|
<div class="parameter-item-wrapper">
|
||||||
<div class="delete-option" v-if="!isReadOnly">
|
<div class="delete-option" v-if="!isReadOnly">
|
||||||
<font-awesome-icon icon="trash" class="reset-icon clickable" :title="$locale.baseText('fixedCollectionParameter.deleteItem')" @click="deleteOption(property.name, index)" />
|
<font-awesome-icon
|
||||||
|
icon="trash"
|
||||||
|
class="reset-icon clickable"
|
||||||
|
:title="$locale.baseText('fixedCollectionParameter.deleteItem')"
|
||||||
|
@click="deleteOption(property.name, index)"
|
||||||
|
/>
|
||||||
<div v-if="sortable" class="sort-icon">
|
<div v-if="sortable" class="sort-icon">
|
||||||
<font-awesome-icon v-if="index !== 0" icon="angle-up" class="clickable" :title="$locale.baseText('fixedCollectionParameter.moveUp')" @click="moveOptionUp(property.name, index)" />
|
<font-awesome-icon
|
||||||
<font-awesome-icon v-if="index !== (values[property.name].length -1)" icon="angle-down" class="clickable" :title="$locale.baseText('fixedCollectionParameter.moveDown')" @click="moveOptionDown(property.name, index)" />
|
v-if="index !== 0"
|
||||||
|
icon="angle-up"
|
||||||
|
class="clickable"
|
||||||
|
:title="$locale.baseText('fixedCollectionParameter.moveUp')"
|
||||||
|
@click="moveOptionUp(property.name, index)"
|
||||||
|
/>
|
||||||
|
<font-awesome-icon
|
||||||
|
v-if="index !== (values[property.name].length - 1)"
|
||||||
|
icon="angle-down"
|
||||||
|
class="clickable"
|
||||||
|
:title="$locale.baseText('fixedCollectionParameter.moveDown')"
|
||||||
|
@click="moveOptionDown(property.name, index)"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<parameter-input-list :parameters="property.values" :nodeValues="nodeValues" :path="getPropertyPath(property.name, index)" :hideDelete="true" @valueChanged="valueChanged" />
|
<parameter-input-list
|
||||||
|
:parameters="property.values"
|
||||||
|
:nodeValues="nodeValues"
|
||||||
|
:path="getPropertyPath(property.name, index)"
|
||||||
|
:hideDelete="true"
|
||||||
|
@valueChanged="valueChanged"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-else class="parameter-item">
|
<div v-else class="parameter-item">
|
||||||
<div class="parameter-item-wrapper">
|
<div class="parameter-item-wrapper">
|
||||||
<div class="delete-option" v-if="!isReadOnly">
|
<div class="delete-option" v-if="!isReadOnly">
|
||||||
<font-awesome-icon icon="trash" class="reset-icon clickable" :title="$locale.baseText('fixedCollectionParameter.deleteItem')" @click="deleteOption(property.name)" />
|
<font-awesome-icon
|
||||||
|
icon="trash"
|
||||||
|
class="reset-icon clickable"
|
||||||
|
:title="$locale.baseText('fixedCollectionParameter.deleteItem')"
|
||||||
|
@click="deleteOption(property.name)"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<parameter-input-list :parameters="property.values" :nodeValues="nodeValues" :path="getPropertyPath(property.name)" class="parameter-item" @valueChanged="valueChanged" :hideDelete="true" />
|
<parameter-input-list
|
||||||
|
:parameters="property.values"
|
||||||
|
:nodeValues="nodeValues"
|
||||||
|
:path="getPropertyPath(property.name)"
|
||||||
|
class="parameter-item"
|
||||||
|
@valueChanged="valueChanged"
|
||||||
|
:hideDelete="true"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</n8n-input-label>
|
</n8n-input-label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-if="parameterOptions.length > 0 && !isReadOnly">
|
<div v-if="parameterOptions.length > 0 && !isReadOnly">
|
||||||
<n8n-button v-if="parameter.options.length === 1" fullWidth @click="optionSelected(parameter.options[0].name)" :label="getPlaceholderText" />
|
<n8n-button
|
||||||
|
v-if="parameter.options.length === 1"
|
||||||
|
fullWidth
|
||||||
|
@click="optionSelected(parameter.options[0].name)"
|
||||||
|
:label="getPlaceholderText"
|
||||||
|
/>
|
||||||
<div v-else class="add-option">
|
<div v-else class="add-option">
|
||||||
<n8n-select v-model="selectedOption" :placeholder="getPlaceholderText" size="small" @change="optionSelected" filterable>
|
<n8n-select
|
||||||
|
v-model="selectedOption"
|
||||||
|
:placeholder="getPlaceholderText"
|
||||||
|
size="small"
|
||||||
|
@change="optionSelected"
|
||||||
|
filterable
|
||||||
|
>
|
||||||
<n8n-option
|
<n8n-option
|
||||||
v-for="item in parameterOptions"
|
v-for="item in parameterOptions"
|
||||||
:key="item.name"
|
:key="item.name"
|
||||||
:label="$locale.nodeText().collectionOptionDisplayName(parameter, item, path)"
|
:label="$locale.nodeText().collectionOptionDisplayName(parameter, item, path)"
|
||||||
:value="item.name">
|
:value="item.name"
|
||||||
</n8n-option>
|
></n8n-option>
|
||||||
</n8n-select>
|
</n8n-select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -128,12 +181,20 @@ export default mixins(genericHelpers)
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
deleteOption(optionName: string, index?: number) {
|
deleteOption(optionName: string, index?: number) {
|
||||||
const parameterData = {
|
const currentOptionsOfSameType = this.values[optionName];
|
||||||
|
if (!currentOptionsOfSameType || currentOptionsOfSameType.length > 1) {
|
||||||
|
// it's not the only option of this type, so just remove it.
|
||||||
|
this.$emit('valueChanged', {
|
||||||
name: this.getPropertyPath(optionName, index),
|
name: this.getPropertyPath(optionName, index),
|
||||||
value: undefined,
|
value: undefined,
|
||||||
};
|
});
|
||||||
|
} else {
|
||||||
this.$emit('valueChanged', parameterData);
|
// it's the only option, so remove the whole type
|
||||||
|
this.$emit('valueChanged', {
|
||||||
|
name: this.getPropertyPath(optionName),
|
||||||
|
value: undefined,
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
getPropertyPath(name: string, index?: number) {
|
getPropertyPath(name: string, index?: number) {
|
||||||
return `${this.path}.${name}` + (index !== undefined ? `[${index}]` : '');
|
return `${this.path}.${name}` + (index !== undefined ? `[${index}]` : '');
|
||||||
|
@ -225,7 +286,6 @@ export default mixins(genericHelpers)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
|
|
||||||
.fixed-collection-parameter {
|
.fixed-collection-parameter {
|
||||||
padding-left: var(--spacing-s);
|
padding-left: var(--spacing-s);
|
||||||
}
|
}
|
||||||
|
@ -240,7 +300,7 @@ export default mixins(genericHelpers)
|
||||||
z-index: 999;
|
z-index: 999;
|
||||||
color: #f56c6c;
|
color: #f56c6c;
|
||||||
left: 0;
|
left: 0;
|
||||||
top: .5em;
|
top: 0.5em;
|
||||||
width: 15px;
|
width: 15px;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
|
@ -272,6 +332,6 @@ export default mixins(genericHelpers)
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
margin-left: 1px;
|
margin-left: 1px;
|
||||||
margin-top: .5em;
|
margin-top: 0.5em;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
Loading…
Reference in a new issue