n8n/packages/editor-ui/src/components/VariableSelectorItem.vue

156 lines
4 KiB
Vue
Raw Normal View History

2019-06-23 03:35:23 -07:00
<template>
<div class="item">
<div v-if="item.options" class="options">
<div v-if="item.options.length" class="headline clickable" @click="extended=!extended">
<div class="options-toggle" v-if="extendAll !== true">
<font-awesome-icon v-if="extended" icon="angle-down" />
<font-awesome-icon v-else icon="angle-right" />
</div>
<div class="option-title" :title="item.key">
{{item.name}}
<el-dropdown trigger="click" @click.stop @command="optionSelected($event, item)" v-if="allowParentSelect === true">
<span class="el-dropdown-link clickable" @click.stop>
2021-12-07 06:58:26 -08:00
<font-awesome-icon icon="dot-circle" :title="$i18n2.baseText('variableSelectorItem.selectItem')" />
2019-06-23 03:35:23 -07:00
</span>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item :command="operation.command" v-for="operation in itemAddOperations" :key="operation.command">{{operation.displayName}}</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</div>
</div>
<div v-if="item.options && (extended === true || extendAll === true)">
<variable-selector-item v-for="option in item.options" :item="option" :key="option.key" :extendAll="extendAll" :allowParentSelect="option.allowParentSelect" class="sub-level" @itemSelected="forwardItemSelected"></variable-selector-item>
</div>
</div>
<div v-else class="value clickable" @click="selectItem(item)">
<div class="item-title" :title="item.key">
{{item.name}}:
<font-awesome-icon icon="dot-circle" title="Select Item" />
</div>
2021-12-07 06:58:26 -08:00
<div class="item-value">{{ item.value !== undefined?item.value: $i18n2.baseText('variableSelectorItem.empty') }}</div>
2019-06-23 03:35:23 -07:00
</div>
</div>
</template>
<script lang="ts">
import Vue from 'vue';
import {
IVariableSelectorOption,
IVariableItemSelected,
} from '@/Interface';
2021-11-10 10:41:40 -08:00
import { renderText } from './mixins/renderText';
import mixins from 'vue-typed-mixins';
2019-06-23 03:35:23 -07:00
2021-11-10 10:41:40 -08:00
export default mixins(renderText).extend({
2019-06-23 03:35:23 -07:00
name: 'VariableSelectorItem',
props: [
'allowParentSelect',
'extendAll',
'item',
],
computed: {
itemAddOperations () {
const returnOptions = [
{
command: 'raw',
displayName: 'Raw value',
},
];
if (this.item.dataType === 'array') {
returnOptions.push({
command: 'arrayLength',
displayName: 'Length',
});
returnOptions.push({
command: 'arrayValues',
displayName: 'Values',
});
} else if (this.item.dataType === 'object') {
returnOptions.push({
command: 'objectKeys',
displayName: 'Keys',
});
returnOptions.push({
command: 'objectValues',
displayName: 'Values',
});
}
return returnOptions;
},
},
data () {
return {
extended: false,
};
},
methods: {
optionSelected (command: string, item: IVariableSelectorOption) {
// By default it is raw
let variable = item.key;
if (command === 'arrayValues') {
variable = `${item.key}.join(', ')`;
} else if (command === 'arrayLength') {
variable = `${item.key}.length`;
} else if (command === 'objectKeys') {
variable = `Object.keys(${item.key}).join(', ')`;
} else if (command === 'objectValues') {
variable = `Object.values(${item.key}).join(', ')`;
}
this.$emit('itemSelected', { variable });
},
selectItem (item: IVariableSelectorOption) {
this.$emit('itemSelected', { variable: item.key });
},
forwardItemSelected (eventData: IVariableItemSelected) {
this.$emit('itemSelected', eventData);
},
},
});
</script>
<style scoped lang="scss">
.option-title {
position: relative;
display: inline-block;
font-size: 0.9em;
font-weight: 600;
padding: 0.2em 1em 0.2em 0.4em;
}
.item-title {
font-weight: 600;
font-size: 0.8em;
white-space: nowrap;
:sparkles: Implement design system (#2050) * split up main, sass imports, import new nds * migrate most buttons * update sizes based on feedback * update copy buttons * update executions list * fix issues * force message box buttons * update warning color * update more buttons * wrap message box buttons * update last component * lint fixes * add build report step * breakout imports * set package.json * fix notification bug * clean up imports * use build directories directly * update imports * remove xl size * update number inputs * fix input width * update line height, fix icon bug * fix up editor * fix spacing between buttons * Reset line height * revert changes to this * revert changes * clean up button sizes * change to outline * update select height * update tooltip * remove build report step * clean up impl * remove regenerator runtime * add design system repo * apply editorconfig * apply editor config prettier * lint issue * switch to tabs * switch to single space * update eslintrc * remove git modules * update sass package * support dart sass * add build * update dependency * update contributing.md * set repo * update versions * add tslint step * update spacing to spaces, add dev step * add test step * add test step * update browser lint rc * remove .github * delete .gitignore * set comment for icons * remove preview link * update button interface * update types * set types * clean up intro * update intro * remove assets * move into preview * remove headline comment * reduce theme build * loading executions * match deps versions * match deps versions * fix lint issues * fix lint issues * update callback * disable codacy for docs.css * fix storybook issues * add design system to docker image * update spacing around delete sort button * set line height to stop juggling headline * update sizes * clean up vars * fix scss issues * update button vars * add shade color * fix button without click * fix buttons bug * fix bug with executions list * clean up theme * update link styling * fix typo * run prettier * :art: code format * :art: code format * 🔥 remove empty files * :sparkles: N8n 2284 new inputs (#2075) * implement inputs * prettier fixes * revert unnessary change * move input components and tooltip * remove form elements * move select * update input placements * update sizes * update credentails * clean up select size * fix caret issue * update inputs * clean up select * fix tags dropdown border * clean up tags input * fix workflow name bug * clean up select here * add sizes template * fix option caret * fix input sizes * update date input size * remove tags input override * update prop * update input size * center run data inputs * update disabled colors * update execution header * update scrollbar * update text area spacing * fix items in header * update run data tooltip * remove popover * update prefix positions * add filterable demo * address design issues * fix input issues, flip boolean input to text * update input sufffix colors * remove override * speed up switch, fix toggle spacing issue * update icon * remove icon classes * clean up inputs * clean up inputs with icons * update input spacing again * update suffix position * build * Add support for xlarge inputs * fix input issues * fix input issue * update listeners * update number inputs for settings * update append/prepend spacing * clean up inputs, set expression input as text * fix type errors * fix workflow number input * fix tags dropdown bug * fix bugs * fix menu item bug * remove font weight from link element * remove default * fix select option * fix contrast issues * allow overflow x for multi selects * fix icon * update options select * fix issue that resolves expression to null * update how actions are centered * fix up selects * update selects to support limiting size * update option styles * :zap: Apply suggestions BHesseldieck Co-authored-by: Ben Hesseldieck <1849459+BHesseldieck@users.noreply.github.com> * :art: code format Co-authored-by: Jan <janober@users.noreply.github.com> Co-authored-by: Ben Hesseldieck <1849459+BHesseldieck@users.noreply.github.com> Co-authored-by: Ben Hesseldieck <b.hesseldieck@gmail.com> * ⏪ Revert "🔥 remove empty files" This reverts commit e91ace4e52403f4a6b00b7be68b86fc48b7d8fef. * :zap: Remove private from n8n-design-system package * :art: Change to spaces to stay consistent with editorconfig & others package files * :zap: Fix year in license Co-authored-by: Ben Hesseldieck <1849459+BHesseldieck@users.noreply.github.com> Co-authored-by: Ben Hesseldieck <b.hesseldieck@gmail.com> Co-authored-by: Jan <janober@users.noreply.github.com> Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
2021-08-29 04:36:17 -07:00
overflow: hidden;
2019-06-23 03:35:23 -07:00
text-overflow: ellipsis;
}
.headline {
position: relative;
margin: 2px;
margin-top: 10px;
color: $--color-primary;
}
.options-toggle {
position: relative;
top: 1px;
margin: 0 3px 0 8px;
display: inline;
}
.value {
margin: 0.2em;
padding: 0.1em 0.3em;
}
.item-value {
font-size: 0.6em;
overflow-x: auto;
}
.sub-level {
padding-left: 20px;
}
</style>