-
Notifications
You must be signed in to change notification settings - Fork 52
Credit Roles #644
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
Open
jyhein
wants to merge
1
commit into
pkp:main
Choose a base branch
from
jyhein:f857_credit
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Credit Roles #644
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,19 @@ | ||
import {Primary, Controls, Stories, Meta, ArgTypes} from '@storybook/blocks'; | ||
|
||
import * as FieldCreditRolesStories from './FieldCreditRoles.stories.js'; | ||
|
||
<Meta of={FieldCreditRolesStories} /> | ||
|
||
# FieldCreditRole | ||
|
||
## Usage | ||
|
||
A special component to maintain Credit roles and degrees of authors (contributors). | ||
|
||
The CreditRoles currently saved are shown in a tabular way as roles and degrees. | ||
|
||
The `value` is an array of objects `{ role, degree }`. | ||
|
||
<Primary /> | ||
<Controls /> | ||
<Stories /> |
This file contains hidden or 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,29 @@ | ||
import FieldCreditRoles from './FieldCreditRoles.vue'; | ||
import FieldCreditRolesMock from '@/components/Form/mocks/field-credit-roles'; | ||
|
||
export default { | ||
title: 'Forms/FieldCreditRoles', | ||
component: FieldCreditRoles, | ||
render: (args) => ({ | ||
components: {FieldCreditRoles}, | ||
setup() { | ||
function change(name, prop, newValue, localeKey) { | ||
args[prop] = newValue; | ||
} | ||
|
||
return {args, change}; | ||
}, | ||
template: '<FieldCreditRoles v-bind="args" @change="change"/>', | ||
}), | ||
parameters: { | ||
docs: { | ||
story: { | ||
height: '500px', | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
export const Base = { | ||
args: {...FieldCreditRolesMock}, | ||
}; |
This file contains hidden or 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,139 @@ | ||
<template> | ||
<!-- To be able to scroll to this field on error--> | ||
<div | ||
:id="`${props.formId}-${props.name}`" | ||
class="pkpFormField pkpFormField--creditRoles" | ||
> | ||
<div class="pkpFormField__heading"> | ||
<label :id="labelId" class="pkpFormFieldLabel"> | ||
{{ t('submission.submit.creditRoles.title', {}) }} | ||
</label> | ||
</div> | ||
<div :id="descriptionId" class="pkpFormField__description"> | ||
{{ t('submission.submit.creditRoles.description', {}) }} | ||
</div> | ||
<div class="pkpFormField__control pkpFormField--creditRoles__control"> | ||
<PkpTable :labelled-by="labelId" :described-by="descriptionId"> | ||
<TableHeader> | ||
<TableColumn id="" class="w-[45%]"> | ||
{{ t('submission.submit.creditRoles.role', {}) }} | ||
</TableColumn> | ||
<TableColumn id=""> | ||
{{ t('submission.submit.creditRoles.degree', {}) }} | ||
</TableColumn> | ||
<TableColumn id="" class="w-[100px]"> </TableColumn> | ||
</TableHeader> | ||
<TableBody> | ||
<TableRow | ||
v-for="({role, degree}, creditRoleIndex) in currentValue" | ||
:key="creditRoleIndex" | ||
> | ||
<TableCell> | ||
<FieldSelect | ||
name="role" | ||
:label="t('submission.submit.creditRoles.selectRole')" | ||
:is-required="true" | ||
:value="role" | ||
:options="props.options.roles" | ||
class="creditRole__roleSelect" | ||
@change=" | ||
(fieldName, propName, newValue, localeKey) => | ||
updateCreditRole(creditRoleIndex, fieldName, newValue) | ||
" | ||
/> | ||
</TableCell> | ||
<TableCell> | ||
<FieldSelect | ||
name="degree" | ||
:label="t('submission.submit.creditRoles.selectDegree')" | ||
:value="degree" | ||
:options="props.options.degrees" | ||
class="creditRole__roleSelect" | ||
@change=" | ||
(fieldName, propName, newValue, localeKey) => | ||
updateCreditRole(creditRoleIndex, fieldName, newValue) | ||
" | ||
/> | ||
</TableCell> | ||
<TableCell> | ||
<PkpButton | ||
:is-warnable="true" | ||
@click="removeCreditRole(creditRoleIndex)" | ||
> | ||
{{ t('submission.submit.creditRoles.button.remove') }} | ||
</PkpButton> | ||
</TableCell> | ||
</TableRow> | ||
</TableBody> | ||
<template #bottom-controls> | ||
<PkpButton @click="addCreditRole()"> | ||
{{ t('submission.submit.creditRoles.button.add') }} | ||
</PkpButton> | ||
</template> | ||
</PkpTable> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script setup> | ||
import {computed, useId} from 'vue'; | ||
import {t} from '@/utils/i18n'; | ||
import PkpButton from '@/components/Button/Button.vue'; | ||
import PkpTable from '@/components/Table/Table.vue'; | ||
import TableHeader from '@/components/Table/TableHeader.vue'; | ||
import TableBody from '@/components/Table/TableBody.vue'; | ||
import TableRow from '@/components/Table/TableRow.vue'; | ||
import TableColumn from '@/components/Table/TableColumn.vue'; | ||
import TableCell from '@/components/Table/TableCell.vue'; | ||
import FieldSelect from './FieldSelect.vue'; | ||
|
||
const props = defineProps({ | ||
/** Field key used for form submission */ | ||
name: { | ||
type: String, | ||
default: null, | ||
}, | ||
/** The ID of the form this field should appear in. This is passed down from the `Form`. */ | ||
formId: { | ||
type: String, | ||
default: null, | ||
}, | ||
/** Current value of the field */ | ||
value: { | ||
type: Array, | ||
default: () => [], | ||
}, | ||
options: { | ||
type: Object, | ||
required: true, | ||
}, | ||
}); | ||
|
||
/** | ||
* Accessibility | ||
*/ | ||
const labelId = useId(); | ||
const descriptionId = useId(); | ||
|
||
const emit = defineEmits(['change']); | ||
|
||
const currentValue = computed({ | ||
get: () => props.value, | ||
set: (newVal) => emit('change', props.name, 'value', newVal), | ||
}); | ||
|
||
function addCreditRole() { | ||
currentValue.value.push({ | ||
role: props.options.roles[0].value, | ||
degree: props.options.degrees[0].value, | ||
}); | ||
} | ||
|
||
function removeCreditRole(index) { | ||
currentValue.value.splice(index, 1); | ||
} | ||
|
||
function updateCreditRole(index, fieldName, newValue) { | ||
currentValue.value[index][fieldName] = newValue; | ||
} | ||
</script> |
This file contains hidden or 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,36 @@ | ||
export default { | ||
name: 'contributor-credit-roles', | ||
component: 'contributor-credit-roles', | ||
value: [ | ||
{ | ||
role: 'https://credit.niso.org/contributor-roles/data-curation/', | ||
degree: null, | ||
}, | ||
], | ||
options: { | ||
roles: [ | ||
{ | ||
label: 'Conceptualization', | ||
value: 'https://credit.niso.org/contributor-roles/conceptualization/', | ||
}, | ||
{ | ||
label: 'Data Curation', | ||
value: 'https://credit.niso.org/contributor-roles/data-curation/', | ||
}, | ||
{ | ||
label: 'Formal Analysis', | ||
value: 'https://credit.niso.org/contributor-roles/formal-analysis/', | ||
}, | ||
], | ||
degrees: [ | ||
{ | ||
label: '', | ||
value: null, | ||
}, | ||
{ | ||
label: 'LEAD', | ||
value: 'LEAD', | ||
}, | ||
], | ||
}, | ||
}; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please add it also to the storybook?
Have we had designs for it? Just wondering if there is reference for me to look at.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @jardakotesovec, I think those are here:
https://www.figma.com/design/Wf7sDlUg2372jaKKTJ0Mgz/OJS-3.4-3.5?node-id=13083-13980&t=s4aR9MZYwUh64cba-0
https://www.figma.com/board/FuyJHvTPTCUuk5gr5pHuEP/Design-Explanation?node-id=0-1&p=f&t=Y90cFJ4esWCv252E-0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is it added to the storybook?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checkout FieldAffiliations.stories.js for example
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. How do I test stories? I haven't done this before
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jardakotesovec , I added the storybook