Badge-thirdparty

This commit is contained in:
2021-12-12 14:51:42 +00:00
committed by Julien Fastré
parent 10aa897899
commit c049a0b78b
28 changed files with 383 additions and 202 deletions

View File

@@ -128,6 +128,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
/**
* @ORM\Column(name="comment", type="text", nullable=true)
* @Groups({"read"})
*/
private ?string $comment = null;

View File

@@ -1,16 +1,23 @@
@import 'ChillMainAssets/module/bootstrap/shared';
.badge {
&.bg-thirdparty-company {
//@extend .bg-info;
background-color: $yellow;
}
&.bg-thirdparty-child {
//@extend .bg-chill-blue;
background-color: $chill-blue;
}
&.bg-thirdparty-contact {
//@extedn .bg-secondary;
background-color: $secondary;
/// Specific badge rounded-pill
.badge.rounded-pill {
&.bg-thirdparty {
//@extend .$chill-ll-gray;
background-color: $chill-ll-gray;
color: $chill-pink;
}
}
/// force first column width in list
div.thirdparty-list {
div.flex-table {
div.item-bloc {
div.item-row {
div.item-col:first-child {
flex-basis: 25%;
}
}
}
}
}

View File

@@ -7,30 +7,19 @@
<div class="entity-label">
<div :class="'denomination h' + options.hLevel">
<a v-if="this.options.addLink === true" href="#">
<a v-if="this.options.addLink === true" href="#">
<span class="name">{{ thirdparty.text }}</span>
</a>
<span class="name">{{ thirdparty.text }}</span>
<span class="name" v-else>{{ thirdparty.text }}</span>
<span class="badge bg-thirdparty-child" v-if="thirdparty.kind == 'child'">
{{ $t('thirdparty.child')}}
</span>
<span class="badge bg-thirdparty-company" v-else-if="thirdparty.kind == 'company'">
{{ $t('thirdparty.company')}}
</span>
<span class="badge bg-thirdparty-contact" v-else>
{{ $t('thirdparty.contact')}}
<span v-if="options.addId === true" class="id-number" :title="'n° ' + thirdparty.id">
{{ thirdparty.id }}
</span>
<span v-if="options.addId == true" class="id-number" :title="'n° ' + thirdparty.id">{{ thirdparty.id }}</span>
<span v-if="options.addEntity == true && thirdparty.type === 'thirdparty'" class="badge rounded-pill bg-secondary">{{ $t('renderbox.type.thirdparty') }}</span>
</div>
<div v-if="hasParent">
<span class="name tparty-parent">
> {{ thirdparty.parent.text }}
</span>
<badge-entity v-if="options.addEntity === true"
:entity="thirdparty"
:options="{ displayLong: options.entityDisplayLong }">
</badge-entity>
</div>
<p v-if="this.options.addInfo === true" class="moreinfo">
@@ -38,13 +27,38 @@
</div>
</div>
<div class="item-col">
<div class="float-button bottom">
<div class="box">
<div class="action">
<slot name="record-actions"></slot>
</div>
<ul class="list-content fa-ul">
<li v-if="hasParent">
<i class="fa fa-li fa-hand-o-right"></i>
<b class="me-2">{{ $t('child_of') }}</b>
<span class="chill-entity badge-thirdparty">{{ thirdparty.parent.text }}</span>
<!-- console: [Vue warn]: Failed to resolve component: on-the-fly ...
<on-the-fly type="thirdparty" action="show" :id="thirdparty.parent.id"
:buttonText="thirdparty.parent.text" :displayBadge="'true' === 'true'"
></on-the-fly>
-->
</li>
<!-- TODO hasChildren
<li v-if="hasChildren">
<i class="fa fa-li fa-hand-o-right"></i>
<b class="me-2">{{ $t('children') }}</b>
<span v-for="child in thirdparty.activeChildren">
<on-the-fly type="thirdparty"
action="show"
:id="child.id"
:buttonText="child.text"
displayBadge="'true' === 'true'">
</on-the-fly>
</span>
</li>
-->
</ul>
<confidential v-if="thirdparty.contactDataAnonymous">
<template v-slot:confidential-content>
<ul class="list-content fa-ul">
@@ -62,21 +76,24 @@
</li>
</ul>
</template>
</confidential>
<ul v-else class="list-content fa-ul">
<li v-if="thirdparty.address">
<i class="fa fa-li fa-map-marker"></i>
<address-render-box :address="thirdparty.address" :isMultiline="isMultiline"></address-render-box>
</li>
<li v-if="thirdparty.phonenumber">
<i class="fa fa-li fa-mobile"></i>
<a :href="'tel: ' + thirdparty.phonenumber">{{ thirdparty.phonenumber }}</a>
</li>
<li v-if="thirdparty.email">
<i class="fa fa-li fa-envelope-o"></i>
<a :href="'mailto: ' + thirdparty.email">{{ thirdparty.email }}</a>
</li>
</ul>
</confidential>
<ul v-else class="list-content fa-ul">
<li v-if="thirdparty.address">
<i class="fa fa-li fa-map-marker"></i>
<address-render-box :address="thirdparty.address" :isMultiline="isMultiline"></address-render-box>
</li>
<li v-if="thirdparty.phonenumber">
<i class="fa fa-li fa-mobile"></i>
<a :href="'tel: ' + thirdparty.phonenumber">{{ thirdparty.phonenumber }}</a>
</li>
<li v-if="thirdparty.email">
<i class="fa fa-li fa-envelope-o"></i>
<a :href="'mailto: ' + thirdparty.email">{{ thirdparty.email }}</a>
</li>
</ul>
<div v-if="options.addComment && !thirdparty.contactDataAnonymous && thirdparty.comment">
<blockquote class="chill-user-quote">{{ thirdparty.comment }}</blockquote>
</div>
</div>
</div>
</div>
@@ -91,25 +108,24 @@
import AddressRenderBox from 'ChillMainAssets/vuejs/_components/Entity/AddressRenderBox.vue';
import {dateToISO} from 'ChillMainAssets/chill/js/date.js';
import Confidential from 'ChillMainAssets/vuejs/_components/Confidential.vue';
const i18n = {
messages: {
fr: {
tparty: {
contact: "Personne physique",
company: "Personne morale"
}
}
}
};
import BadgeEntity from 'ChillMainAssets/vuejs/_components/BadgeEntity.vue';
//import OnTheFly from 'ChillMainAssets/vuejs/OnTheFly/components/OnTheFly.vue';
export default {
name: "ThirdPartyRenderBox",
components: {
AddressRenderBox,
Confidential
Confidential,
BadgeEntity,
//OnTheFly
},
i18n: {
messages: {
fr: {
children: "Personnes de contact: ",
child_of: "Contact de: ",
}}
},
i18n,
props: ['thirdparty', 'options'],
computed: {
isMultiline: function() {
@@ -120,8 +136,13 @@ export default {
}
},
hasParent() {
return !(this.$props.thirdparty.parent === null || this.$props.thirdparty.parent === undefined);
}
return !(this.thirdparty.parent === null || this.thirdparty.parent === undefined);
},
/* TODO need backend normalizer to serve children without circular reference
hasChildren() {
//console.log(this.thirdparty.activeChildren.length > 0)
return false
} */
}
}
</script>

View File

@@ -5,7 +5,8 @@
:thirdparty="thirdparty"
:options="{
addInfo: true,
addEntity: false,
addEntity: true,
entityDisplayLong: true,
addAltNames: true,
addId: true,
addLink: false,
@@ -13,6 +14,7 @@
hLevel: 3,
addCenter: true,
addNoData: true,
addComment: true,
isMultiline: true
}"
></third-party-render-box>
@@ -24,7 +26,7 @@
<div class="form-check">
<input class="form-check-input mt-0" type="radio" v-model="kind" value="company" id="tpartyKindInstitution">
<label for="tpartyKindInstitution" class="required">
<span class="badge bg-thirdparty-company" style="padding-top: 0;">
<span class="badge rounded-pill bg-thirdparty-company" style="padding-top: 0;">
{{ $t('tparty.company')}}
</span>
</label>
@@ -32,7 +34,7 @@
<div class="form-check">
<input class="form-check-input mt-0" type="radio" v-model="kind" value="contact" id="tpartyKindContact">
<label for="tpartyKindContact" class="required">
<span class="badge bg-thirdparty-contact" style="padding-top: 0;">
<span class="badge rounded-pill bg-thirdparty-contact" style="padding-top: 0;">
{{ $t('tparty.contact')}}
</span>
</label>

View File

@@ -82,7 +82,19 @@
<div class="item-row entity-bloc">
<div class="item-col">
{{ _self.label(thirdparty, options) }}
<span class="badge bg-thirdparty-{{ thirdparty.kind }}">{{ ('thirdparty.' ~ thirdparty.kind)|trans }}</span>
{% if thirdparty.kind == 'child' %}
<span class="badge rounded-pill bg-thirdparty">
<i class="fa fa-fw fa-user"></i>{{ 'thirdparty.child'|trans }}
</span>
{% elseif thirdparty.kind == 'company' %}
<span class="badge rounded-pill bg-thirdparty">
<i class="fa fa-fw fa-hospital-o"></i>{{ 'thirdparty.company'|trans }}
</span>
{% else %}
<span class="badge rounded-pill bg-thirdparty">
<i class="fa fa-fw fa-user-md"></i>{{ 'thirdparty.contact'|trans }}
</span>
{% endif %}
</div>
<div class="item-col">
{% if options['isConfidential'] %}
@@ -160,26 +172,33 @@
</div>
{% if options['showContacts'] and thirdparty.activeChildren|length > 0 %}
<div class="item-row">
{{ 'thirdparty.Children'|trans }}&nbsp;:
{% for c in thirdparty.activeChildren %}
{% include '@ChillMain/OnTheFly/_insert_vue_onthefly.html.twig' with {
targetEntity: { name: 'thirdparty', id: c.id },
action: 'show',
displayBadge: true,
buttonText: c|chill_entity_render_string
} %}
{% endfor %}
<div class="item-col"></div>
<div class="item-col">
<h5 class="me-2">{{ 'thirdparty.Children'|trans ~ ': ' }}</h5>
{% for c in thirdparty.activeChildren %}
{% include '@ChillMain/OnTheFly/_insert_vue_onthefly.html.twig' with {
targetEntity: { name: 'thirdparty', id: c.id },
action: 'show',
displayBadge: true,
buttonText: c|chill_entity_render_string
} %}
{% endfor %}
</div>
</div>
{% endif %}
{% if options['showParent'] and thirdparty.isChild %}
<div class="item-row">
{{ 'thirdparty.Contact of'|trans }}&nbsp;:
{% include '@ChillMain/OnTheFly/_insert_vue_onthefly.html.twig' with {
targetEntity: { name: 'thirdparty', id: thirdparty.parent.id },
action: 'show',
displayBadge: true,
buttonText: thirdparty.parent|chill_entity_render_string
} %}
<div class="item-col"></div>
<div class="item-col">
<h5 class="me-2">{{ 'thirdparty.Contact of'|trans ~ ': ' }}</h5>
{% include '@ChillMain/OnTheFly/_insert_vue_onthefly.html.twig' with {
targetEntity: { name: 'thirdparty', id: thirdparty.parent.id },
action: 'show',
displayBadge: true,
buttonText: thirdparty.parent|chill_entity_render_string
} %}
</div>
</div>
{% endif %}

View File

@@ -6,6 +6,26 @@
{% block content %}
{% embed '@ChillMain/CRUD/_index.html.twig' %}
{% macro rowCustomButtons(tp) %}
{% if is_granted('CHILL_3PARTY_3PARTY_UPDATE', tp) %}
<li>
<a href="{{ chill_path_add_return_path('chill_crud_3party_3party_edit',
{ 'id': (tp.isParent ? tp.id : tp.parent.id) }) }}"
title="{{ 'Edit'|trans }}"
class="btn btn-sm btn-update"></a>
</li>
{% endif %}
{% if is_granted('CHILL_3PARTY_3PARTY_SHOW', tp) %}
<li>
<a href="{{ chill_path_add_return_path('chill_crud_3party_3party_view',
{ 'id': (tp.isParent ? tp.id : tp.parent.id) }) }}"
title="{{ 'Show'|trans }}"
class="btn btn-sm btn-show"></a>
</li>
{% endif %}
{% endmacro %}
{% block index_header %}
<h1>{{ 'List of third parties'|trans }}</h1>
{% endblock %}
@@ -13,37 +33,25 @@
{% block table_entities %}
<div class="thirdparty-list my-5">
<div class="row justify-content-center">
<div>
<label class="counter">
<span>{{ paginator.totalItems }}</span> {{ 'third parties'|trans }}
</label>
<label class="counter text-end">
<span>{{ paginator.totalItems }}</span> {{ 'third parties'|trans }}
</label>
<div class="flex-table">
{% for tp in third_parties %}
<div class="item-bloc">
{{ tp|chill_entity_render_box({'render': 'bloc', 'addLink': false, 'showContacts': true, 'isConfidential': (tp.contactDataAnonymous ? true : false) }) }}
<div class="item-row separator">
<ul class="record_actions">
{% if is_granted('CHILL_3PARTY_3PARTY_UPDATE', tp) %}
<li>
<a href="{{ chill_path_add_return_path('chill_crud_3party_3party_edit',
{ 'id': (tp.isParent ? tp.id : tp.parent.id) }) }}" class="btn btn-sm btn-update"></a>
</li>
{% endif %}
{% if is_granted('CHILL_3PARTY_3PARTY_SHOW', tp) %}
<li>
<a href="{{ chill_path_add_return_path('chill_crud_3party_3party_view',
{ 'id': (tp.isParent ? tp.id : tp.parent.id) }) }}" class="btn btn-sm btn-show"></a>
</li>
{% endif %}
</ul>
</div>
</div>
{% endfor %}
</div>
<div class="flex-table">
{% for tp in third_parties %}
<div class="item-bloc">
{{ tp|chill_entity_render_box({
'render': 'bloc',
'showContacts': true,
'addLink': true,
'customButtons': { 'replace': _self.rowCustomButtons(tp) },
'isConfidential': (tp.contactDataAnonymous ? true : false)
}) }}
</div>
{% endfor %}
</div>
</div>
</div>
{% endblock %}

View File

@@ -12,10 +12,10 @@
{% block crud_content_header %}
<h1>
{{ title_ }}
<span class="badge bg-{{ thirdParty.active ? 'success' : 'danger' }}"
<span class="badge bg-{{ thirdParty.active ? 'success' : 'danger' }} float-end"
title="{{ (thirdParty.active ? 'shown to users' : 'not shown to users')|trans }}">
{{ (thirdParty.active ? 'Active' : 'Inactive')|trans }}
</span>
{{ (thirdParty.active ? 'Active' : 'Inactive')|trans }}
</span>
</h1>
{% endblock %}

View File

@@ -45,6 +45,7 @@ class ThirdPartyNormalizer implements NormalizerAwareInterface, NormalizerInterf
'parent' => $this->normalizer->normalize($thirdParty->getParent(), $format, $context),
'civility' => $this->normalizer->normalize($thirdParty->getCivility(), $format, $context),
'contactDataAnonymous' => $thirdParty->isContactDataAnonymous(),
'comment' => $thirdParty->getComment(),
];
}