Commit 12d326ef authored by Jean Rabreau's avatar Jean Rabreau
Browse files

🚧 item copy page created

parent ca984f67
......@@ -233,6 +233,11 @@ export const en_US = {
},
item: {
backToSet: "Back to set",
copy: {
title: "Copy @:item.designate",
here: "Copy here",
inProject: "Choose set",
},
copyOf: "Copy of",
count: "No item | 1 item | {count} items",
create: "Add item",
......@@ -245,15 +250,12 @@ export const en_US = {
edit: "Item edition",
export: "Datacite export",
file: "File",
files: "Files",
label: "Item",
metadata: "Metadata",
none: "No item.",
plural: "Items",
shareLink: "Visualize the @.lower:item.label in Pount",
update: "Update item",
updated: "The item has been updated",
viewer: "Viewer",
fields: {
title: {
label: "Title",
......@@ -306,6 +308,13 @@ export const en_US = {
empty: "None",
},
},
tabs: {
Copy: 'Copy',
Detail: "@:detail",
Files: "Files",
Metadata: "Metadata",
Viewer: "Viewer",
},
},
legal: {
headline: "Legal Informations",
......
......@@ -240,6 +240,11 @@ export const fr_FR = {
},
item: {
backToSet: "Revenir à l'ensemble",
copy: {
title: "Copier @:item.designate",
here: "Copier ici",
inProject: "Choisir l'ensemble"
},
copyOf: "Copie de",
count: "Aucun élément | 1 élément | {count} éléments",
create: "Nouvel élément",
......@@ -252,15 +257,12 @@ export const fr_FR = {
edit: "Editer l'élément",
export: "Export Datacite",
file: "Fichier",
files: "Fichiers",
label: "Élément",
metadata: "Métadonnées",
none: "Aucun élément.",
plural: "Éléments",
shareLink: "Visualiser l'@.lower:item.label dans Pount",
update: "Modifier l'élément",
updated: "L'élément a bien été mis à jour",
viewer: "Visionneuse",
fields: {
title: {
label: "Titre",
......@@ -313,6 +315,13 @@ export const fr_FR = {
empty: "Non versionné",
},
},
tabs: {
Copy: 'Copie',
Detail: "@:detail",
Files: "Fichiers",
Metadata: "Métadonnées",
Viewer: "Visionneuse",
}
},
legal: {
headline: "Mentions légales",
......
......@@ -317,6 +317,11 @@ export const routes = [
name: 'itemFiles',
component: () => import(/* webpackChunkName: "item" */ '@/views/items/ItemFiles'),
},
{
path: 'copy',
name: 'itemCopy',
component: () => import(/* webpackChunkName: "item" */ '@/views/items/ItemCopy'),
},
],
},
{
......
......@@ -144,6 +144,7 @@ const Item = {
current: state => state.current,
itemId: state => state.current.id,
templateId: state => state.current.set.templateId,
projectId: state => state.current.set.projectId,
canEdit: (state) => state.current.canEdit,
files: state => state.current.mediaFiles,
fileView: state => state.current.viewer.fileId
......@@ -168,6 +169,8 @@ const Item = {
},
SET_CURRENT(state, item) {
state.current = { ...item}
// TODO test purpose
state.current.set.projectId = '76e6c198-89fc-4fc0-86e0-6c5e2900a30c'
},
SET_ITEMS(state, items) {
state.setItems = items
......
......@@ -109,32 +109,17 @@ export default {
},
tabs() {
const tabs = [
{
id: 'detail',
label: this.$t('detail'),
to: `/items/${this.item.id}/detail`,
isDisplayed: true,
},
{
id: 'viewer',
label: this.$t('item.viewer'),
to: `/items/${this.item.id}/viewer`,
isDisplayed: true,
},
{
id: 'metadata',
label: this.$t('item.metadata'),
to: `/items/${this.item.id}/metadata`,
isDisplayed: this.item.canEdit,
},
{
id: 'files',
label: this.$t('item.files'),
to: `/items/${this.item.id}/files`,
isDisplayed: this.item.canEdit,
},
];
return tabs.filter((tab) => tab.isDisplayed);
'Detail',
'Viewer',
]
if (this.item.canEdit) {
tabs.push('Metadata', 'Files', 'Copy')
}
return tabs.map(id => ({
id,
label: this.$t(`item.tabs.${id}`),
to: {name: `item${id}`, params: {itemId: this.itemId}}
}))
},
},
methods: {
......
<template>
<v-sheet class="mt-2 pa-2">
<v-card>
<v-card-title>
{{ $t('item.copy.title') }}
</v-card-title>
<v-card-text>
<crud-list
v-if="setLoaded"
class="mt-2"
:title="$t('set.plural')"
:button="{isDisplayed: false}"
:items="crudListItems"
:items-length="setsLength"
@paginate="onPagination"
/>
</v-card-text>
<v-card-actions>
<v-btn
tile
elevation="0"
@click="duplicate"
>
{{ $t('item.copy.here' )}}
<v-icon color="secondary" right>mdi-content-copy</v-icon>
</v-btn>
<v-btn
tile
elevation="0"
@click="displayProjectSets"
>
{{ $t('item.copy.inProject')}}
</v-btn>
<v-spacer />
<v-btn
color="secondary"
tile
elevation="0"
@click="$emit('close')"
>
{{ $t('btn.cancel') }}
</v-btn>
</v-card-actions>
</v-card>
</v-sheet>
</template>
<script>
import TextHelpersMixin from '@/mixins/TextHelpersMixin'
import CrudList from '@/components/crud/CrudList'
import {mapActions, mapGetters, mapState} from 'vuex'
export default {
name: "ItemCopy",
mixins: [
TextHelpersMixin,
],
components: {
CrudList,
},
props: {
itemId: {
type: String,
required: true
}
},
data() {
return {
setLoaded: false
}
},
computed: {
...mapGetters('item', ['projectId', 'templateId']),
...mapState('set', {
sets: 'projectSets',
setsLength: 'projectSetsCount',
pages: 'pageCount',
}),
...mapGetters('template', ['current']),
...mapGetters('project', { storedProject: 'projectId'}),
crudListItems() {
return this.sets.map((set) => ({
id: set.id,
name: this.textTruncate(set.title, 50),
thumbnail: set.thumbnails.s,
subtitles: [
this.textTruncate(this.stripHtml(set.description), 75),
],
isSelectable: !set.numItems,
updatedAt: set.updatedAt,
}));
},
},
methods: {
...mapActions('item', ['itemDuplicate']),
...mapActions('project', ['loadProject']),
...mapActions('set', ['loadProjectSets']),
...mapActions('template', ['loadProjectTemplates']),
async duplicate() {
await this.itemDuplicate()
this.$emit('close')
this.$router.push({
name: 'itemMetadata',
params: {itemId: this.item.id}
})
},
async displayProjectSets() {
if (this.projectId !== this.storedProject) {
await this.loadProject(this.projectId)
}
await this.loadProjectSets({size: 10})
this.setLoaded = true
},
onPagination(pagination){
this.loadProjectSets({ page: pagination.page, size: pagination.itemsPerPage});
},
},
}
</script>
<style scoped>
</style>
......@@ -2,7 +2,7 @@
<div class="mt-2">
<v-toolbar flat>
<v-toolbar-title>
{{ $t('item.files') }}
{{ $t('item.tabs.Files') }}
</v-toolbar-title>
</v-toolbar>
<v-data-table
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment