mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Fixed: [Activity] allow to set a user null
Fix https://gitlab.com/Chill-Projet/chill-bundles/-/issues/74
This commit is contained in:
parent
4d734714a8
commit
cc69a3e86b
@ -195,7 +195,7 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac
|
|||||||
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User")
|
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User")
|
||||||
* @Groups({"docgen:read"})
|
* @Groups({"docgen:read"})
|
||||||
*/
|
*/
|
||||||
private User $user;
|
private ?User $user;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\ManyToMany(targetEntity="Chill\MainBundle\Entity\User")
|
* @ORM\ManyToMany(targetEntity="Chill\MainBundle\Entity\User")
|
||||||
@ -494,7 +494,7 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac
|
|||||||
return $this->activityType;
|
return $this->activityType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUser(): User
|
public function getUser(): ?User
|
||||||
{
|
{
|
||||||
return $this->user;
|
return $this->user;
|
||||||
}
|
}
|
||||||
@ -681,14 +681,14 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setUser(UserInterface $user): self
|
public function setUser(?User $user): self
|
||||||
{
|
{
|
||||||
$this->user = $user;
|
$this->user = $user;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setUsers(?Collection $users): self
|
public function setUsers(Collection $users): self
|
||||||
{
|
{
|
||||||
$this->users = $users;
|
$this->users = $users;
|
||||||
|
|
||||||
|
@ -225,6 +225,7 @@ class ActivityType extends AbstractType
|
|||||||
$builder->add('user', PickUserDynamicType::class, [
|
$builder->add('user', PickUserDynamicType::class, [
|
||||||
'label' => $activityType->getLabel('user'),
|
'label' => $activityType->getLabel('user'),
|
||||||
'required' => $activityType->isRequired('user'),
|
'required' => $activityType->isRequired('user'),
|
||||||
|
'multiple' => false,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@
|
|||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if activity.user and t.userVisible %}
|
{% if activity.user is not null and t.userVisible %}
|
||||||
<div class="wl-row">
|
<div class="wl-row">
|
||||||
<div class="wl-col title"><h3>{{ 'Referrer'|trans }}</h3></div>
|
<div class="wl-col title"><h3>{{ 'Referrer'|trans }}</h3></div>
|
||||||
<div class="wl-col list">
|
<div class="wl-col list">
|
||||||
|
@ -34,10 +34,12 @@
|
|||||||
|
|
||||||
<div class="item-row separator">
|
<div class="item-row separator">
|
||||||
<dl class="chill_view_data">
|
<dl class="chill_view_data">
|
||||||
<dt class="inline">{{ 'Referrer'|trans|capitalize }}</dt>
|
{%- if entity.user is not null %}
|
||||||
<dd>
|
<dt class="inline">{{ 'Referrer'|trans|capitalize }}</dt>
|
||||||
<span class="badge-user">{{ entity.user|chill_entity_render_box }}</span>
|
<dd>
|
||||||
</dd>
|
<span class="badge-user">{{ entity.user|chill_entity_render_box }}</span>
|
||||||
|
</dd>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{%- if entity.scope -%}
|
{%- if entity.scope -%}
|
||||||
<dt class="inline">{{ 'Scope'|trans }}</dt>
|
<dt class="inline">{{ 'Scope'|trans }}</dt>
|
||||||
|
@ -18,6 +18,7 @@ function loadDynamicPicker(element) {
|
|||||||
isMultiple = parseInt(el.dataset.multiple) === 1,
|
isMultiple = parseInt(el.dataset.multiple) === 1,
|
||||||
uniqId = el.dataset.uniqid,
|
uniqId = el.dataset.uniqid,
|
||||||
input = element.querySelector('[data-input-uniqid="'+ el.dataset.uniqid +'"]'),
|
input = element.querySelector('[data-input-uniqid="'+ el.dataset.uniqid +'"]'),
|
||||||
|
// the "picked" will always be an array, even if multiple is false
|
||||||
picked = isMultiple ?
|
picked = isMultiple ?
|
||||||
JSON.parse(input.value) : (
|
JSON.parse(input.value) : (
|
||||||
(input.value === '[]' || input.value === '') ?
|
(input.value === '[]' || input.value === '') ?
|
||||||
@ -54,15 +55,11 @@ function loadDynamicPicker(element) {
|
|||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
notPickedSuggested() {
|
notPickedSuggested() {
|
||||||
if (this.multiple) {
|
const pickedIds = new Set();
|
||||||
const pickedIds = new Set();
|
for (const p of this.picked) {
|
||||||
for (const p of this.picked) {
|
pickedIds.add(`${p.type}${p.id}`);
|
||||||
pickedIds.add(`${p.type}${p.id}`);
|
|
||||||
}
|
|
||||||
return this.suggested.filter(e => !pickedIds.has(`${e.type}${e.id}`))
|
|
||||||
}
|
}
|
||||||
|
return this.suggested.filter(e => !pickedIds.has(`${e.type}${e.id}`))
|
||||||
return this.suggested.filter(e => e.type !== this.picked.type && e.id !== e.picked.id);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@ -90,7 +87,11 @@ function loadDynamicPicker(element) {
|
|||||||
this.suggested.push(entity);
|
this.suggested.push(entity);
|
||||||
}
|
}
|
||||||
this.picked = this.picked.filter(e => !(e.type === entity.type && e.id === entity.id));
|
this.picked = this.picked.filter(e => !(e.type === entity.type && e.id === entity.id));
|
||||||
input.value = JSON.stringify(this.picked);
|
if (this.multiple) {
|
||||||
|
input.value = JSON.stringify(this.picked);
|
||||||
|
} else {
|
||||||
|
input.value = "";
|
||||||
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user