Skip to content

Commit

Permalink
storybook
Browse files Browse the repository at this point in the history
  • Loading branch information
bozana committed Jul 17, 2024
1 parent f101bbf commit 445fdc8
Show file tree
Hide file tree
Showing 5 changed files with 193 additions and 0 deletions.
91 changes: 91 additions & 0 deletions src/components/Form/mocks/form-counter-report.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import Form from './form';
import FieldTextTitle from './field-text-title';

export default {
...Form,
id: 'example',
action: 'https://example.org/example',
fields: [
{
...FieldTextTitle,
value: {
en: '',
fr_CA: '',
ar: '',
},
groupId: 'default',
},
{
name: 'descriptionShort',
component: 'field-rich-textarea',
label: 'Short Description',
isMultilingual: true,
plugins: 'paste,link,noneditable',
toolbar: 'bold italic superscript subscript | link',
value: {
en: '',
fr_CA: '',
ar: '',
},
groupId: 'default',
},
{
name: 'description',
component: 'field-rich-textarea',
label: 'Description',
isMultilingual: true,
size: 'large',
plugins: 'paste,link,noneditable',
toolbar: 'bold italic superscript subscript | link',
value: {
en: '',
fr_CA: '',
ar: '',
},
groupId: 'default',
},
{
name: 'dateExpire',
component: 'field-text',
inputType: 'text',
label: 'Expiry Date',
description:
'The announcement will be displayed to readers until this date. Leave blank if the announcement should be displayed indefinitely.',
value: '',
groupId: 'default',
},
{
name: 'sendEmail',
component: 'field-options',
label: 'Send Email',
description: '',
type: 'checkbox',
value: false,
options: [
{
value: true,
label:
'Yes, I would like an email about this announcement to be sent to all registered users.',
},
],
groupId: 'default',
},
],
groups: [
{
id: 'default',
pageId: 'default',
},
],
supportedFormLocales: [
...Form.supportedFormLocales,
{
key: 'fr_CA',
label: 'Français (Canada)',
},
{
key: 'ar',
label: 'عربى',
},
],
};
26 changes: 26 additions & 0 deletions src/components/ListPanel/counter/CounterReportsEditModal.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<template>
<SideModalBody>
<template #title>
{{ title }}
</template>
<SideModalLayoutBasic>
<PkpForm
v-bind="activeForm"
@set="(...args) => emit('updateForm', ...args)"
@success="(...args) => emit('formSuccess', ...args)"
/>
</SideModalLayoutBasic>
</SideModalBody>
</template>

<script setup>
import SideModalBody from '@/components/Modal/SideModalBody.vue';
import SideModalLayoutBasic from '@/components/Modal/SideModalLayoutBasic.vue';
import PkpForm from '@/components/Form/Form.vue';
defineProps({
title: {type: String, required: true},
activeForm: {type: Object, required: true},
});
const emit = defineEmits(['updateForm', 'formSuccess']);
</script>
14 changes: 14 additions & 0 deletions src/components/ListPanel/counter/CounterReportsListPanel.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import {Primary, Controls, Stories, Meta, ArgTypes} from '@storybook/blocks';

import * as CounterReportsListPanelStories from './CounterReportsListPanel.stories.js';

<Meta of={CounterReportsListPanelStories} />

# CounterReportsListPanel

## Usage

Use this component to get COUNTER R5 TSV reports.

<Primary />
<ArgTypes />
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import CounterReportsListPanel from './CounterReportsListPanel.vue';

import CounterReportMock from '@/mocks/counterReport';
import FormCounterReportMock from '@/components/Form/mocks/form-counter-report';

export default {
title: 'ListPanel/CounterReportsListPanel',
component: CounterReportsListPanel,
};

const counterReports = [
{
...CounterReportMock,
Report_ID: 'PR',
begin_date: '2022-02-03',
end_date: '2024-07-17',
customer_id: 0,
metric_type: {
0: 'Total_Item_Investigations',
1: 'Unique_Item_Investigations',
2: 'Total_Item_Requests',
3: 'Unique_Item_Requests',
},
},
];

export const Base = {
render: (args) => ({
components: {CounterReportsListPanel},
setup() {
return {args};
},
template: `
<CounterReportsListPanel
v-bind="args"
/>
`,
}),

args: {
form: {...FormCounterReportMock},
items: [...counterReports],
itemsMax: counterReports.length,
title: 'Counter R5 Reports',
id: 'previewCounterReportsListPanel',
apiUrl: '',
editCounterReportLabel: 'Edit',
usagePossible: true,
},
};
12 changes: 12 additions & 0 deletions src/mocks/counterReport.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export default {
Report_ID: 'PR',
begin_date: '2022-02-03',
end_date: '2024-07-17',
customer_id: 0,
metric_type: {
0: 'Total_Item_Investigations',
1: 'Unique_Item_Investigations',
2: 'Total_Item_Requests',
3: 'Unique_Item_Requests',
},
};

0 comments on commit 445fdc8

Please sign in to comment.