Commit 554e7644 authored by Jean Rabreau's avatar Jean Rabreau
Browse files

🚸 item copy: warning messages for partial copy

parent d074ae98
Pipeline #62343 failed with stages
in 3 minutes and 47 seconds
......@@ -240,8 +240,15 @@ export const en_US = {
duplicate: "Create a copy",
title: "Copy @:item.designate",
here: "Copy here",
ignored: {
field : "This field will be ignored. | Those fields will be ignored.",
value: `This item value will be ignored, field is missing in this set.
| Those item values will be ignored, fields are missing in this set.`,
},
impossible: "Copy impossible, ",
required: "this field is required. | those fields are required.",
required: `@:item.copy.impossible this field is required.
| @:item.copy.impossible those fields are required.`,
partial: "Warning: Only partial copy available.",
inProject: "Choose set",
projectsLoad: "Load other projets",
prefix: "Copy of ",
......
......@@ -247,15 +247,22 @@ export const fr_FR = {
duplicate: "Créer une copie",
title: "Copier @:item.designate",
here: "Copier ici",
ignored: {
field : "Ce champ sera ignoré. | Ces champs seront ignorés.",
value: `Cette donnée de l'élément sera ignorée, le champ est manquant dans cet ensemble.
| Ces données de l'élément seront ignorées, les champs sont manquant dans cet ensemble.`,
},
impossible: "La copie est impossible, ",
required: "ce champ est requis. | ces champs sont requis.",
required: `@:item.copy.impossible ce champ est requis.
| @:item.copy.impossible ces champs sont requis.`,
partial: "Attention : Seule une copie partielle est possible.",
inProject: "Choisir l'ensemble",
projectsLoad: "Charger les autres projets",
prefix: "Copie de ",
reason: {
unknownOption: `Cette option est inconnue @:item.copy.inTarget
| Ces options sont inconnues @:item.copy.inTarget`,
typeMismatch: "Le type de champ ciblé ne correspond pas avec la donnée de l'élément",
typeMismatch: "Le type du champ cible ne correspond pas avec la donnée de l'élément",
tooManyValues: "Ce champ reçoit trop de données, maximum : {limit}",
missingValue: "Donnée(s) manquante(s)"
}
......
......@@ -51,7 +51,7 @@
</v-card-title>
<v-card-text>
<div v-if="hasError">
<h3>{{ $t('item.copy.impossible') }} {{ $tc('item.copy.required', analysis.result.required.length) }}</h3>
<h2 class="error">{{ $tc('item.copy.required', analysis.result.required.length) }}</h2>
<ul>
<li
v-for="detail in analysis.result.required"
......@@ -61,6 +61,33 @@
</li>
</ul>
</div>
<div v-else-if="hasIgnoredValue || hasMissingField">
<h2 class="warning">{{ $t('item.copy.partial') }}</h2>
<div v-if="hasIgnoredValue">
<h3>{{ $tc('item.copy.ignored.field', analysis.result.ignored.length) }}</h3>
<ul>
<li
v-for="detail in analysis.result.ignored"
:key="detail.field.id"
>
{{ detail.field.name }} - {{ detail.reason }}
</li>
</ul>
</div>
<div v-if="hasMissingField">
<h3>
{{ $tc('item.copy.ignored.value', analysis.result.missing.length) }}
</h3>
<ul>
<li
v-for="itemValue in analysis.result.missing"
:key="itemValue.id"
>
{{ itemValue.name }} - {{ itemValue.value }}
</li>
</ul>
</div>
</div>
</v-card-text>
<v-card-actions>
......@@ -167,11 +194,13 @@ export default {
const results = this.analysis.result
return results && !!results.required.length
},
hasWarning() {
hasIgnoredValue() {
const results = this.analysis.result
return results && !!results.ignored.length
},
hasMissingField() {
const results = this.analysis.result
return results
&& !!results.ignored
&& !!results.missing
return results && !!results.missing.length
},
},
created() {
......@@ -198,13 +227,15 @@ export default {
}
}
else {
let error = false
const pushList = field.required ? result.required : result.ignored
const itemData = itemFields[itemDataIndex]
if (itemData.repeatable === !!field.repeatable
&& itemData.multiple === !!field.multiple
&& itemData.isOption === !!field.options
) {
let error = false
const itemValue = Array.isArray(itemData.value) ? itemData.value : [itemData.value]
if (itemData.isOption) {
......@@ -240,16 +271,18 @@ export default {
)
})
}
result.missing.splice(itemDataIndex, 1)
if (!error) {
result.metadata.push(itemData)
}
} else {
error = true
pushList.push({
field,
reason: this.$t('item.copy.reason.typeMismatch')
})
}
result.missing.splice(itemDataIndex, 1)
if (!error) {
result.metadata.push(itemData)
}
}
return result
}, {
......@@ -354,5 +387,8 @@ export default {
cursor: pointer;
}
}
h2 {
margin-bottom: 1rem;
}
</style>
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