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

F t34968 add dp bulk edit header to storybook #615

Merged
merged 29 commits into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
0a8ddfe
chore (refs T34968): WIP: Add DpBulkEditHeader to Storybook.
ahmad-demos Oct 25, 2023
0414355
chore (refs T34968): Add Tran-Key.
ahmad-demos Oct 25, 2023
3743631
chore (refs T34968): Add resetSelection.
ahmad-demos Oct 27, 2023
ccf9eae
chore (refs T34968): Add template to docu.
ahmad-demos Oct 27, 2023
bbb51c9
ore (refs T34968): WIP: Add deleteSelection.
ahmad-demos Oct 27, 2023
49a5b0a
chore (refs T34968): WIP: Add selectedItemsCount computed.
ahmad-demos Oct 30, 2023
2236931
Merge branch 'main' into f_T34968_add_DpBulkEditHeader_to_storybook
ahmad-demos Oct 30, 2023
ae2d09a
chore (refs T34968): WIP: Add toggleSelectAll.
ahmad-demos Oct 31, 2023
c75a186
Merge branch 'main' into f_T34968_add_DpBulkEditHeader_to_storybook
ahmad-demos Oct 31, 2023
1205093
Merge branch 'main' into f_T34968_add_DpBulkEditHeader_to_storybook
ahmad-demos Nov 1, 2023
5ac79e9
chore (refs T34968): Add CHANGELOG.
ahmad-demos Nov 1, 2023
698b1b5
chore (refs T34968): adjust template code.
ahmad-demos Nov 1, 2023
8a67367
chore (refs T34968): adjust template.
ahmad-demos Nov 1, 2023
fb8c369
Update src/components/core/DpBulkEditHeader.stories.mdx
ahmad-demos Nov 1, 2023
bc5118d
Update src/components/core/DpBulkEditHeader.stories.tsx
ahmad-demos Nov 1, 2023
627fc1d
chore (refs T34968): Use label for input.
ahmad-demos Nov 1, 2023
e2d7e2e
chore (refs T34968): call resetSelection instead of deleting the elem…
ahmad-demos Nov 1, 2023
9a6ce28
chore (refs T34968): rename computed.
ahmad-demos Nov 1, 2023
eab8db3
chore (refs T34968): use DpButton instead of deleting the icon class.
ahmad-demos Nov 2, 2023
e768e6f
chore (refs T34968): adjust Trans-Key.
ahmad-demos Nov 2, 2023
e241f51
chore (refs T34968): adjust toggleSelectAll.
ahmad-demos Nov 2, 2023
cb41626
chore (refs T34968): minor improvements in Props & slot.
ahmad-demos Nov 2, 2023
aff06c0
chore (refs T34968): adjust template code & edit Trans-Key.
ahmad-demos Nov 2, 2023
1aa6373
chore (refs T34968): adjust icon.
ahmad-demos Nov 2, 2023
5232061
Update src/components/core/DpBulkEditHeader.stories.mdx
ahmad-demos Nov 2, 2023
df65adb
chore: minor code style fixes
spiess-demos Nov 2, 2023
cb8d317
feat: rename selectAll to toggleAll
spiess-demos Nov 2, 2023
dd48a66
chore: adapt example
spiess-demos Nov 2, 2023
4624c5b
chore (refs T34968): change computed to data.
ahmad-demos Nov 2, 2023
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Since v0.0.10, this Changelog is formatted according to the [Common Changelog][c
- ([#621](https://github.com/demos-europe/demosplan-ui/pull/621)) Bump Vue Peer dependency to 2.5.17 ([@spiess-demos](https://github.com/spiess-demos))

### Added
- ([#615](https://github.com/demos-europe/demosplan-ui/pull/615)) Add DpBulkEditHeader documentation to Storybook ([@ahmad-demos](https://github.com/@ahmad-demos))
- ([#605](https://github.com/demos-europe/demosplan-ui/pull/605)) Add DpEditableList documentation to Storybook ([@ahmad-demos](https://github.com/@ahmad-demos))
- ([#591](https://github.com/demos-europe/demosplan-ui/pull/591)) Add label tests for form components ([@hwiem](https://github.com/hwiem))

Expand Down
50 changes: 50 additions & 0 deletions src/components/core/DpBulkEditHeader.stories.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { Meta } from '@storybook/addon-docs'
import DpBulkEditHeader from './DpBulkEditHeader'

<Meta
title="Components/BulkEditHeader"
component={DpBulkEditHeader}
/>

# BulkEditHeader

The BulkEditHeader component allows users to perform bulk editing operations on a set of data or records.

In a data management system, users often need to edit multiple records simultaneously.
Instead of editing each record individually, a bulk edit functionality allows users to select multiple records
and apply changes to specific fields in one go.
ahmad-demos marked this conversation as resolved.
Show resolved Hide resolved

## Custom usage

```html
<div>
<dp-bulk-edit-header
v-if="selectedItemsCount.length > 0"
:selected-items-count="selectedItemsCount.length"
selection-text="Elements"
@reset-selection="resetSelection"
v-bind="args">
<button
class="btn-icns u-m-0"
type="button"
@click.prevent="deleteSelection">
<i class="fa fa-times u-mr-0_125" />
Delete
</button>
spiess-demos marked this conversation as resolved.
Show resolved Hide resolved
</dp-bulk-edit-header>
<input
type="checkbox"
@click="toggleSelectAll"> Select all
spiess-demos marked this conversation as resolved.
Show resolved Hide resolved
<div
class="u-mt-0_5"
v-for="item in args.options"
:key="item.id">
<input
:id="item.id"
v-model="item.checked"
:checked="!item.checked === false"
type="checkbox"/>
{{ item.label }}
spiess-demos marked this conversation as resolved.
Show resolved Hide resolved
</div>
</div>
```
96 changes: 96 additions & 0 deletions src/components/core/DpBulkEditHeader.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
import type { Meta, StoryObj } from '@storybook/vue'
import DpBulkEditHeader from './DpBulkEditHeader.vue'

const meta: Meta<typeof DpBulkEditHeader> = {
component: DpBulkEditHeader,
title: 'Components/BulkEditHeader',
render: (args) => ({
components: {
DpBulkEditHeader
},
computed: {
selectedItemsCount () {
return args.options.filter(checked => checked.checked == true)
}
},
setup() {
const toggleSelectAll = () => {
for (let element of args.options) {
if(element.checked === false) {
element.checked = true
} else {
element.checked = false
}
spiess-demos marked this conversation as resolved.
Show resolved Hide resolved
}
}

const resetSelection = () => {
for (const element of args.options) {
element.checked = false
}
}

const deleteSelection = () => {
for (let element of args.options) {
if(element.checked === true) {
args.options = args.options.filter(checked => checked.checked != true)
}
}
spiess-demos marked this conversation as resolved.
Show resolved Hide resolved
}

return { args, deleteSelection, resetSelection, toggleSelectAll }
},
template: `
<div>
<dp-bulk-edit-header
v-if="selectedItemsCount.length > 0"
:selected-items-count="selectedItemsCount.length"
selection-text="Elements"
spiess-demos marked this conversation as resolved.
Show resolved Hide resolved
@reset-selection="resetSelection"
v-bind="args">
<button
class="btn-icns u-m-0"
type="button"
@click.prevent="deleteSelection">
<i class="fa fa-times u-mr-0_125" />
Delete
</button>
</dp-bulk-edit-header>
<input
type="checkbox"
@click="toggleSelectAll"> Select all
<div
class="u-mt-0_5"
v-for="item in args.options"
:key="item.id">
<input
:id="item.id"
v-model="item.checked"
:checked="!item.checked === false"
type="checkbox"/>
{{ item.label }}
</div>
</div>
`,
})
}

interface IDpBulkEditHeader {
options: object[]
}

type Story = StoryObj<IDpBulkEditHeader>

export default meta

export const Default: Story = {
args: {
options: [
{ label: 'Option 1', id: '1', checked: false },
{ label: 'Option 2', id: '2', checked: false },
{ label: 'Option 3', id: '3', checked: false }
ahmad-demos marked this conversation as resolved.
Show resolved Hide resolved

]
},
argTypes: {}
}
8 changes: 7 additions & 1 deletion src/components/core/DpBulkEditHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@
type="button"
class="btn btn--secondary float-right"
@click="$emit('reset-selection')">
{{ Translator.trans('unselect') }}
{{ unselect }}
</button>
</div>
</template>

<script>
import { de } from '~/components/shared/translations'

export default {
name: 'DpBulkEditHeader',

Expand All @@ -38,6 +40,10 @@ export default {
computed: {
selectedItemsText () {
return this.selectedItemsCount + ' ' + this.selectionText
},

unselect () {
return de.operations.deselect.element
spiess-demos marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/components/shared/translations.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ const de = {
add: 'Hinzufügen',
delete: 'Löschen',
deselect: {
all: 'Alle abwählen'
all: 'Alle abwählen',
element: 'Auswahl aufheben'
spiess-demos marked this conversation as resolved.
Show resolved Hide resolved
},
new: 'Neu',
none: 'Keine',
Expand Down