Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/ lookups - app components [WTEL-4740] #136

Open
wants to merge 1 commit into
base: feat/lookups-pr
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions src/app/components/actions/delete-all-action.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<template>
<div class="delete-all-action">
<wt-tooltip>
<template #activator>
<wt-icon-btn
class="icon-action"
icon="bucket"
v-bind="$attrs"
@click="$emit('click')"
/>
</template>
{{ actionPanelDeleteTooltip }}
</wt-tooltip>
</div>
</template>

<script>
export default {
name: 'DeleteAllAction',
props: {
selectedCount: {
type: Number,
},
},
computed: {
actionPanelDeleteTooltip() {
return this.selectedCount
? this.$t('iconHints.deleteSelected', {
count: this.selectedCount,
})
: this.$t('iconHints.deleteAll');
},
},
};
</script>

<style lang="scss" scoped>
.delete-all-action {
line-height: 0;
}
</style>
5 changes: 5 additions & 0 deletions src/app/components/actions/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import DeleteAllAction from './delete-all-action.vue';

const actions = [DeleteAllAction];

export default actions;
61 changes: 61 additions & 0 deletions src/app/components/utils/object-list-popup/object-list-popup.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<template>
<wt-popup
v-bind="$attrs"
size="sm"
min-width="480"
@close="close"
>
<template #title>
{{ title }}
</template>
<template #main>
<section>
<wt-table
:data="dataList"
:grid-actions="false"
:headers="tableHeaders"
:selectable="false"
/>
</section>
</template>
</wt-popup>
</template>

<script>
export default {
name: 'ObjectListPopup',
props: {
title: {
type: String,
default: '',
},
dataList: {
type: Array,
default: () => [],
},
headers: {
type: Array,
description: 'Or default "name" header',
},
},
computed: {
tableHeaders() {
const defaultHeaders = [
{
value: 'name',
text: this.$t('reusable.name'),
},
];
return this.headers || defaultHeaders;
},
},
methods: {
close() {
this.$emit('close');
},
},
};
</script>

<style lang="scss" scoped>
</style>
154 changes: 154 additions & 0 deletions src/app/components/utils/selection-popup/selection-popup.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
<template>
<wt-popup
v-bind="$attrs"
:min-width="minWidth"
size="sm"
class="selection-popup"
overflow
@close="close"
>
<template #title>
{{ title }}
</template>
<template #main>
<ul class="popup-options">
<li
v-for="(option, key) of options"
:key="key"
:class="{'active': option.value === selected.value }"
class="popup-options__item-wrap"
@click="selectOption(option)"
>
<slot
name="option"
:option="option"
>
<wt-icon
v-if="option.icon"
:icon="option.icon"
size="sm"
/>
<h4 class="popup-options__item-header">
{{ option.title }}
</h4>
<wt-tooltip
popper-class="selection-popup__tooltip-popper"
>
<template #activator>
<wt-icon-btn
v-if="option.description"
color="info"
icon="rounded-info"
/>
</template>
{{ option.description }}
</wt-tooltip>
</slot>
</li>
</ul>
<!--Slot for displaying specific template styling-->
<slot name="after-section" />
</template>

<template #actions>
<wt-button
:disabled="!selected"
@click="add"
>
{{ $t('objects.create') }}
</wt-button>
<wt-button
color="secondary"
@click="close"
>
{{ $t('objects.close') }}
</wt-button>
</template>
</wt-popup>
</template>

<script>
export default {
name: 'SelectionPopup',
model: {
prop: 'selected',
event: 'change',
},
props: {
title: {
type: String,
},
selected: {
type: Object,
description: "Should have following schema: { value: '', title: '', description: ''}",
},
options: {
type: Array,
default: () => [],
},
minWidth: {
type: [String, Number],
default: 480,
},
},
methods: {
add() {
this.$emit('select', this.selected);
},
close() {
this.$emit('close');
},
selectOption(option) {
this.$emit('change', option);
},
isSelected(option) {
return option === this.selected;
},
},
};
</script>

<style lang="scss" scoped>
.selection-popup {
.popup-options {
margin-top: 20px;
padding-right: 10px;

.popup-options__item-wrap {
position: relative;
display: flex;
align-items: center;
margin-bottom: 10px;
padding: 7px 10px;
cursor: pointer;
transition: var(--transition);
border: 1px solid var(--form-border-color);
border-radius: var(--border-radius);

.wt-icon {
margin-right: var(--spacing-xs);
}

&:last-child {
margin-bottom: 0;
}

&:hover, &.active {
border-color: var(--primary-color);
}

.wt-tooltip {
margin-left: auto;
}
}

.popup-options__item-header {
@extend %typo-subtitle-2;
}
}
}

.selection-popup__tooltip-popper {
max-width: 480px;
}
</style>
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<template>
<div>
<a
v-if="collection.length"
class="nameLink"
tabIndex="0"
@click.prevent="inputHandler"
@keydown.enter.prevent="inputHandler"
>{{ collection[0].name }}</a>
<wt-chip v-if="collection.length > 1">
+{{ collection.length - 1 }}
</wt-chip>
</div>
</template>

<script>
export default {
name: 'OnePlusManyTableCell',
props: {
collection: {
required: true,
},
},
methods: {
inputHandler() {
this.$emit('input');
},
},
};
</script>

<style lang="scss" scoped>
.nameLink {
color: var(--text-main-color);
cursor: pointer;
}

.wt-chip {
margin-left: var(--spacing-sm);
}
</style>