Skip to content

Commit a249b3f

Browse files
authored
Accordion Demo (#29562) (#29585)
1 parent b97ced1 commit a249b3f

File tree

4 files changed

+23
-12
lines changed

4 files changed

+23
-12
lines changed

apps/demos/Demos/Accordion/Overview/Vue/App.vue

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
:collapsible="collapsible"
66
:multiple="multiple"
77
:animation-duration="animationDuration"
8-
v-model:selected-items="selectedItems"
8+
v-model:selected-items="selectedCompanies"
99
id="accordion-container"
1010
item-title-template="itemTitle"
1111
>
@@ -49,30 +49,46 @@
4949
<span class="caption">Selected Items</span>
5050
<DxTagBox
5151
:data-source="companies"
52-
v-model:value="selectedItems"
52+
v-model:value="selectedCompaniesIds"
5353
:input-attr="{ 'aria-label': 'Company' }"
5454
:disabled="!multiple"
5555
display-expr="CompanyName"
56+
value-expr="ID"
5657
/>
5758
</div>
5859
</div>
5960
</div>
6061
</template>
62+
6163
<script setup lang="ts">
62-
import { ref } from 'vue';
64+
import { ref, computed } from 'vue';
6365
import DxAccordion from 'devextreme-vue/accordion';
6466
import DxTagBox from 'devextreme-vue/tag-box';
6567
import DxCheckBox from 'devextreme-vue/check-box';
6668
import DxSlider, { DxTooltip, DxLabel } from 'devextreme-vue/slider';
6769
import CustomTitle from './CustomTitle.vue';
6870
import CustomItem from './CustomItem.vue';
71+
import { type CompanyData } from './data.ts';
6972
import service from './data.ts';
7073
71-
const companies = service.getCompanies();
72-
const selectedItems = ref([companies[0]]);
7374
const multiple = ref(false);
7475
const collapsible = ref(false);
7576
const animationDuration = ref(300);
77+
const companies = service.getCompanies();
78+
const selectedCompaniesIds = ref([companies[0].ID]);
79+
80+
const getCompaniesBySelectedIds = () => {
81+
const selectedIds = new Set(selectedCompaniesIds.value);
82+
return companies.filter((company: CompanyData) => selectedIds.has(company.ID));
83+
};
84+
const setSelectedCompanies = (companies: CompanyData[]) => {
85+
selectedCompaniesIds.value = companies.map((item) => item.ID);
86+
};
87+
const selectedCompanies = computed({
88+
get: getCompaniesBySelectedIds,
89+
set: setSelectedCompanies,
90+
});
91+
7692
</script>
7793
<style scoped>
7894
#accordion {

apps/demos/Demos/Accordion/Overview/Vue/data.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export type CompanyData = {
2+
ID: number,
23
CompanyName: string,
34
Address: string,
45
City: string,
@@ -9,7 +10,7 @@ export type CompanyData = {
910
Website: string,
1011
}
1112

12-
const companies = [{
13+
const companies: CompanyData[] = [{
1314
ID: 1,
1415
CompanyName: 'Super Mart of the West',
1516
Address: '702 SW 8th Street',

apps/demos/testing/common.test.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,6 @@ const SKIPPED_TESTS = {
240240
],
241241
},
242242
Vue: {
243-
Accordion: [
244-
{ demo: 'Overview', themes: [THEME.generic, THEME.material, THEME.fluent] },
245-
],
246243
Chat: [
247244
// TODO Chrome133: skipped during chrome update
248245
// error "ReferenceError: AzureOpenAI is not defined"

apps/demos/utils/visual-tests/matrix-test-helper.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,9 +268,6 @@ const SKIPPED_TESTS = {
268268
Common: [
269269
{ demo: 'DialogsAndNotificationsOverview', themes: [THEME.generic, THEME.material, THEME.fluent] },
270270
],
271-
Accordion: [
272-
{ demo: 'Overview', themes: [THEME.generic, THEME.material, THEME.fluent] },
273-
],
274271
Charts: [
275272
{ demo: 'Overview', themes: [THEME.material] },
276273
{ demo: 'ZoomingAndScrollingAPI', themes: [THEME.material] },

0 commit comments

Comments
 (0)