-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
198bc83
commit a073d81
Showing
10 changed files
with
233 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
databrowser/src/domain/cellComponents/components/cells/dictionaryCell/DictionaryCell.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<!-- | ||
SPDX-FileCopyrightText: NOI Techpark <digital@noi.bz.it> | ||
SPDX-License-Identifier: AGPL-3.0-or-later | ||
--> | ||
|
||
<template> | ||
<EditListCell :items="recordAsItems" @update="update"> | ||
<template #table="{ items }"> | ||
<DictionaryTable :dictitems="items" /> | ||
</template> | ||
</EditListCell> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { toRefs } from 'vue'; | ||
import EditListCell from '../../utils/editList/EditListCell.vue'; | ||
import { useRecordSupportForCell } from '../../utils/editList/support/useRecordSupport'; | ||
import DictionaryTable from './DictionaryTable.vue'; | ||
import { DictionaryEntry } from './types'; | ||
const emit = defineEmits(['update']); | ||
const props = defineProps<{ dictitems?: Record<string, string> | null }>(); | ||
const { dictitems } = toRefs(props); | ||
const { recordAsItems, update } = useRecordSupportForCell< | ||
string, | ||
DictionaryEntry | ||
>({ | ||
record: dictitems, | ||
prop: 'dictitems', | ||
mapRecordToItems: (record) => | ||
Object.entries(record).map(([key, value]) => ({ key, value })), | ||
mapUpdateToRecord: (items) => | ||
items.reduce((prev, curr) => ({ ...prev, [curr.key]: curr.value }), {}), | ||
emit, | ||
}); | ||
</script> |
69 changes: 69 additions & 0 deletions
69
databrowser/src/domain/cellComponents/components/cells/dictionaryCell/DictionaryTable.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<!-- | ||
SPDX-FileCopyrightText: NOI Techpark <digital@noi.bz.it> | ||
SPDX-License-Identifier: AGPL-3.0-or-later | ||
--> | ||
|
||
<template> | ||
<EditListTable :items="dictitems" :hide-tab-link="true" :hide-sortable="true"> | ||
<template #colGroup> | ||
<col class="w-32 md:w-40" /> | ||
<col class="w-32 md:w-60" /> | ||
</template> | ||
|
||
<template #tableHeader> | ||
<TableHeaderCell>Key</TableHeaderCell> | ||
<TableHeaderCell>Value</TableHeaderCell> | ||
</template> | ||
|
||
<template #tableCols="{ item, index }"> | ||
<TableCell> | ||
<StringCell | ||
:text="item.key" | ||
:editable="editable" | ||
@update="updateItem(index, { key: $event.value, value: item.value })" | ||
/> | ||
</TableCell> | ||
<TableCell> | ||
<StringCell | ||
:text="item.value" | ||
:editable="editable" | ||
@update="updateItem(index, { key: item.key, value: $event.value })" | ||
/> | ||
</TableCell> | ||
</template> | ||
<template #noItems>No items have been defined yet</template> | ||
<template #addItems> | ||
<EditListAddButton | ||
:text="'Add new item'" | ||
@click="addItems([{ key: '' }])" | ||
/> | ||
</template> | ||
</EditListTable> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { toRefs } from 'vue'; | ||
import TableHeaderCell from '../../../../../components/table/TableHeaderCell.vue'; | ||
import TableCell from '../../../../../components/table/TableCell.vue'; | ||
import EditListTable from '../../utils/editList/table/EditListTable.vue'; | ||
import EditListAddButton from '../../utils/editList/EditListAddButton.vue'; | ||
import { useInjectActionTriggers } from '../../utils/editList/actions/useActions'; | ||
import StringCell from '../stringCell/StringCell.vue'; | ||
import { DictionaryEntry } from './types'; | ||
import { useRecordSupportForTable } from '../../utils/editList/support/useRecordSupport'; | ||
import { useInjectEditMode } from '../../utils/editList/actions/useEditMode'; | ||
const props = defineProps<{ dictitems: DictionaryEntry[] }>(); | ||
const { dictitems } = toRefs(props); | ||
const { editable } = useInjectEditMode(); | ||
const { addItems, updateItem } = useInjectActionTriggers(); | ||
useRecordSupportForTable<DictionaryEntry>({ | ||
items: dictitems, | ||
duplication: (items, index) => ({ ...items[index], key: '' }), | ||
}); | ||
</script> |
8 changes: 8 additions & 0 deletions
8
databrowser/src/domain/cellComponents/components/cells/dictionaryCell/types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// SPDX-FileCopyrightText: NOI Techpark <digital@noi.bz.it> | ||
// | ||
// SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
export interface DictionaryEntry { | ||
key: string; | ||
value: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters