Skip to content

Commit

Permalink
Merge pull request #344 from webitel/fix/props-in-wt-action-bar
Browse files Browse the repository at this point in the history
fix: props mode and add new props include/exclude[WTEL-5282] (https://webitel.atlassian.net/browse/WTEL-5282)
  • Loading branch information
dlohvinov authored Nov 7, 2024
2 parents f7b988e + a89616f commit 689b7e9
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@webitel/ui-sdk",
"version": "24.10.62",
"version": "24.10.63",
"private": false,
"scripts": {
"dev": "vite",
Expand Down
5 changes: 1 addition & 4 deletions src/components/wt-action-bar/WtActionBarActionsOrder.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,4 @@ export const tableActionsOrder = [
];

// TODO
export const cardActionsOrder = [
...tableActionsOrder,
IconAction.EDIT,
]
export const sectionActionsOrder = tableActionsOrder;
30 changes: 26 additions & 4 deletions src/components/wt-action-bar/wt-action-bar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@
import { computed } from 'vue';
import IconAction from '../../enums/IconAction/IconAction.enum.js';
import WtIconAction from '../wt-icon-action/wt-icon-action.vue';
import { tableActionsOrder, cardActionsOrder } from './WtActionBarActionsOrder.js';
import { tableActionsOrder, sectionActionsOrder } from './WtActionBarActionsOrder.js';
const props = defineProps({
/**
* [`'table'`, `'card'`]
* [`'table'`, `'section'`]
* */
mode: {
type: String,
default: 'table',
validator: (v) => ['table', 'card'].includes(v),
validator: (v) => ['table', 'section'].includes(v),
},
/**
* see `IconAction` enum
Expand All @@ -63,6 +63,24 @@ const props = defineProps({
// default: 'md',
// validator: (v) => ['sm', 'md', 'lg'].includes(v),
},
/**
* Leave the default value for the mode only listed in includes prop
*/
include: {
type: Array,
default: () => [],
},
/**
* Leave the default values for the mode, except for those in exclude prop
*/
exclude: {
type: Array,
default: () => [],
},
});
const emit = defineEmits([
/**
Expand All @@ -72,7 +90,11 @@ const emit = defineEmits([
]);
const shownActions = computed(() => {
const actionsOrder = props.mode === 'card' ? cardActionsOrder : tableActionsOrder;
const actionsOrder = props.mode === 'section' ? sectionActionsOrder : tableActionsOrder;
if(props.include.length) return actionsOrder.filter((action) => props.include.includes(action));
if(props.exclude.length) return actionsOrder.filter((action) => !props.exclude.includes(action));
return actionsOrder.filter((action) => props.actions.includes(action));
});
Expand Down

0 comments on commit 689b7e9

Please sign in to comment.