Skip to content

Commit

Permalink
Merge pull request #80 from Robert-2/feature/material-view
Browse files Browse the repository at this point in the history
Ajoute la vue d'un matériel
  • Loading branch information
polosson authored Jan 4, 2021
2 parents d318c40 + 0b8c817 commit 27e467d
Show file tree
Hide file tree
Showing 16 changed files with 343 additions and 23 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Ce projet adhère au principe du [Semantic Versioning](https://semver.org/spec/v
(Un lien symbolique est utilisé côté serveur pour relier les deux côtés de l'application)
- Corrige l'hôte de développement et permet sa customisation via une variable d'environnement.
- Améliorations internes de la validation des données.
- Ajoute une page de vue du matériel en détail.

## 0.10.2 (2020-11-16)

Expand Down
File renamed without changes.
15 changes: 15 additions & 0 deletions client/src/components/MaterialTags/MaterialTags.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.MaterialTags {
display: flex;
flex-wrap: wrap;
align-items: center;
padding: 0;
margin: 0;

&__item {
list-style: none;
padding: .3rem .5rem;
margin: 0 .35rem .35rem 0;
background: $bg-color-emphasis;
border-radius: 10px;
}
}
26 changes: 26 additions & 0 deletions client/src/components/MaterialTags/MaterialTags.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<template>
<ul class="MaterialTags">
<li
v-for="tag in tags"
:key="tag.id"
class="MaterialTags__item"
>
<i class="fas fa-tag" />
{{ tag.name }}
</li>
</ul>
</template>

<style lang="scss">
@import '../../themes/default/index';
@import './MaterialTags';
</style>

<script>
export default {
name: 'MaterialTags',
props: {
tags: Array,
},
};
</script>
8 changes: 8 additions & 0 deletions client/src/locale/en/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export default {

'action-add': "Add",
'action-edit': "Edit",
'action-view': "Display details",
'action-trash': "Trash bin",
'action-restore': "Restore",
'action-delete': "Delete",
Expand Down Expand Up @@ -78,21 +79,28 @@ export default {
'ref': "Ref.",
'reference': "Reference",
'park': "Park",
'prices': "Prices",
'rental-price': "Rental price",
'replacement-price': "Replacement price",
'rent-price': "Rent. price",
'repl-price': "Repl. price",
'value-per-day': '{value}\u00a0/\u00a0day',
'serial-number': "Serial n°",
'quantity': "Stock qty",
'quantities': "Quantities",
'quantity-out-of-order': "Out of order qty",
'discountable': "Discountable?",
'material-is-discountable': "The material is «\u0a00discountable\u00a0»: a discount amount can be applied to this material.",
'hidden-on-bill': "Hidden on bill?",
'material-not-displayed-on-bill': "The material is not displayed on bills.",
'price-must-be-zero': "the rental price must be 0",
'all-parks': "All parks combined",
'all-categories': "All categories",
'all-sub-categories': "All sub-categories",
'open-trash-bin': "Display trash bin",
'display-not-deleted-items': "Display not deleted items",
'created-at': "Created at:",
'updated-at': "Updated at:",

'event-details': "Event's details",
'title': "Title",
Expand Down
1 change: 1 addition & 0 deletions client/src/locale/en/pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ export default {
'add': "New material",
'edit': "Modify material «\u00a0{pageSubTitle}\u00a0»",
'help-edit': "Give a short name, and use the description field to detail the material if needed.",
'view': "Details of material «\u00a0{pageSubTitle}\u00a0»",
'confirm-delete': "Move this material in trash bin?",
'confirm-permanently-delete': "Do you really want to permanently delete this material?",
'confirm-restore': "Do you really want to restore this material?",
Expand Down
8 changes: 8 additions & 0 deletions client/src/locale/fr/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export default {

'action-add': "Ajouter",
'action-edit': "Modifier",
'action-view': "Afficher en détail",
'action-trash': "Corbeille",
'action-restore': "Restaurer",
'action-delete': "Supprimer",
Expand Down Expand Up @@ -78,21 +79,28 @@ export default {
'ref': "Réf.",
'reference': "Référence",
'park': "Parc",
'prices': "Tarifs",
'rental-price': "Tarif location",
'replacement-price': "Prix de remplacement",
'rent-price': "Tarif loc.",
'repl-price': "Val. rempl.",
'value-per-day': '{value}\u00a0/\u00a0jour',
'serial-number': "N° de série",
'quantity': "Qté stock",
'quantities': "Quantités",
'quantity-out-of-order': "Qté en panne",
'discountable': "Remisable\u00a0?",
'material-is-discountable': "Le matériel est «\u00a0remisable\u00a0»\u00a0: une remise peut être appliquée sur ce matériel.",
'hidden-on-bill': "Caché sur la facture\u00a0?",
'material-not-displayed-on-bill': "Le matériel n'est pas affiché sur les factures.",
'price-must-be-zero': "le tarif de location doit être égal à 0",
'all-parks': "Tous parcs confondus",
'all-categories': "Toutes catégories",
'all-sub-categories': "Toutes sous-catégories",
'open-trash-bin': "Afficher la corbeille",
'display-not-deleted-items': "Afficher les enregistrements non supprimés",
'created-at': "Créé le\u00a0:",
'updated-at': "Modifié le\u00a0:",

'event-details': "Détails de l'événement",
'title': "Titre",
Expand Down
1 change: 1 addition & 0 deletions client/src/locale/fr/pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ export default {
'add': "Nouveau matériel",
'edit': "Modifier le matériel «\u00a0{pageSubTitle}\u00a0»",
'help-edit': "Trouvez un nom assez court, et utilisez plutôt la description pour détailler le matériel si besoin.",
'view': "Détails du matériel «\u00a0{pageSubTitle}\u00a0»",
'confirm-delete': "Mettre ce matériel à la corbeille\u00a0?",
'confirm-permanently-delete': "Voulez-vous vraiment supprimer définitivement ce matériel\u00a0?",
'confirm-restore': "Voulez-vous vraiment restaurer ce matériel\u00a0?",
Expand Down
2 changes: 1 addition & 1 deletion client/src/pages/Material/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export default {
this.setMaterialData(data);

setTimeout(() => {
this.$router.push('/materials');
this.$router.push(`/materials/${data.id}/view`);
}, 300);
})
.catch(this.displayError);
Expand Down
32 changes: 32 additions & 0 deletions client/src/pages/MaterialView/MaterialView.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
.MaterialView {
display: flex;
flex-wrap: wrap;
color: $text-base-color;
padding-bottom: 6rem;

&__infos {
flex: 2;
min-width: 250px;
margin-right: 3rem;
}

&__no-attribute-help {
color: $text-light-color;
font-style: italic;
}

&__extras {
flex: 1;
min-width: 250px;
padding: 1rem 0 0;
}

&__categories {
margin: 1.5rem 0;
}

&__dates {
color: $text-light-color;
margin-top: 1.5rem;
}
}
120 changes: 120 additions & 0 deletions client/src/pages/MaterialView/MaterialView.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
<template>
<div class="content">
<div class="content__main-view">
<Help
:message="help"
:error="error"
:isLoading="isLoading"
/>
<div class="MaterialView" v-if="!isLoading">
<section class="MaterialView__infos">
<h2>
{{ material.reference }}
</h2>
<h3>
<router-link :to="`/materials?${queryStringCategory}`">
{{ categoryName }}
</router-link>
<span v-if="subCategoryName">/</span>
<router-link
:to="`/materials?${queryStringSubCategory}`"
v-if="subCategoryName"
>
{{ subCategoryName }}
</router-link>
/
{{ material.name }}
</h3>
<p>{{ material.description }}</p>
<h3>{{ $t('quantities') }}</h3>
<ul>
<li>
<strong>{{ material.stock_quantity }} en stock</strong>
</li>
<li v-if="material.out_of_order_quantity > 0">
{{ material.out_of_order_quantity || 0 }} en panne
</li>
</ul>
<div class="MaterialView__billing" v-if="showBilling">
<h3>{{ $t('prices') }}</h3>
<ul>
<li>
<strong>{{ $t('value-per-day', { value: rentalPrice }) }}</strong>
</li>
<li v-if="replacementPrice">
{{ $t('replacement-price') }} {{ replacementPrice }}
</li>
</ul>
<h3>{{ $t('billing') }}</h3>
<p v-if="material.is_hidden_on_bill">
{{ $t('material-not-displayed-on-bill') }}
</p>
<p v-if="material.is_discountable">
{{ $t('material-is-discountable') }}
</p>
</div>
<div
class="MaterialView__attributes"
v-if="material.attributes.length > 0"
>
<h3>{{ $t('special-attributes') }}</h3>
<ul
class="MaterialView__attributes__list"
v-if="material.attributes.length > 0"
>
<li
class="MaterialView__attributes__list__item"
v-for="attribute in material.attributes"
:key="attribute.id"
>
{{ attribute.name }}:
<span v-if="attribute.type !== 'boolean'">
{{ attribute.value }}
{{ attribute.unit }}
</span>
<span v-if="attribute.type === 'boolean'">
{{ attribute.value ? $t('yes') : $t('no') }}
</span>
</li>
</ul>
</div>
<div class="MaterialView__notes" v-if="material.note">
<h3>{{ $t('notes') }}</h3>
<p>{{ material.note }}</p>
</div>
</section>
<section class="MaterialView__extras">
<div class="MaterialView__actions">
<router-link
v-tooltip="$t('action-edit')"
:to="`/materials/${material.id}`"
tag="button"
class="info"
>
<i class="fas fa-edit" />
{{ $t('action-edit') }}
</router-link>
</div>
<div class="MaterialView__categories">
<p>{{ $t('category') }}: <strong>{{ categoryName }}</strong></p>
<p v-if="subCategoryName">
{{ $t('sub-category') }}: <strong>{{ subCategoryName }}</strong>
</p>
</div>
<MaterialTags :tags="material.tags" />
<div class="MaterialView__dates">
<p>{{ $t('created-at') }} {{ createDate }}</p>
<p>{{ $t('updated-at') }} {{ updateDate }}</p>
</div>
</section>
</div>
</div>
</div>
</template>

<style lang="scss">
@import '../../themes/default/index';
@import './MaterialView';
</style>

<script src="./index.js"></script>
Loading

0 comments on commit 27e467d

Please sign in to comment.