mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
vue activity: fix duplicates and add condition in initial loading
This commit is contained in:
parent
b705c5910f
commit
beca41774e
@ -108,15 +108,14 @@ class Activity implements HasCenterInterface, HasScopeInterface
|
|||||||
* @ORM\JoinTable(name="chill_activity_activity_chill_person_socialissue")
|
* @ORM\JoinTable(name="chill_activity_activity_chill_person_socialissue")
|
||||||
* @Groups({"read"})
|
* @Groups({"read"})
|
||||||
*/
|
*/
|
||||||
private $socialIssues;
|
private ?Collection $socialIssues = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\ManyToMany(targetEntity="Chill\PersonBundle\Entity\SocialWork\SocialAction")
|
* @ORM\ManyToMany(targetEntity="Chill\PersonBundle\Entity\SocialWork\SocialAction")
|
||||||
* @ORM\JoinTable(name="chill_activity_activity_chill_person_socialaction")
|
* @ORM\JoinTable(name="chill_activity_activity_chill_person_socialaction")
|
||||||
* @Groups({"read"})
|
* @Groups({"read"})
|
||||||
*/
|
*/
|
||||||
private $socialActions;
|
private ?Collection $socialActions = null;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\ManyToOne(targetEntity="Chill\ActivityBundle\Entity\ActivityType")
|
* @ORM\ManyToOne(targetEntity="Chill\ActivityBundle\Entity\ActivityType")
|
||||||
@ -283,7 +282,7 @@ class Activity implements HasCenterInterface, HasScopeInterface
|
|||||||
return $this->socialIssues;
|
return $this->socialIssues;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addSocialIssue(SocialIssue $socialIssue): self
|
public function addSocialIssue(?SocialIssue $socialIssue): self
|
||||||
{
|
{
|
||||||
if (!$this->socialIssues->contains($socialIssue)) {
|
if (!$this->socialIssues->contains($socialIssue)) {
|
||||||
$this->socialIssues[] = $socialIssue;
|
$this->socialIssues[] = $socialIssue;
|
||||||
@ -307,7 +306,7 @@ class Activity implements HasCenterInterface, HasScopeInterface
|
|||||||
return $this->socialActions;
|
return $this->socialActions;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addSocialAction(SocialAction $socialAction): self
|
public function addSocialAction(?SocialAction $socialAction): self
|
||||||
{
|
{
|
||||||
if (!$this->socialActions->contains($socialAction)) {
|
if (!$this->socialActions->contains($socialAction)) {
|
||||||
$this->socialActions[] = $socialAction;
|
$this->socialActions[] = $socialAction;
|
||||||
|
@ -120,24 +120,30 @@ export default {
|
|||||||
getSocialIssues().then(response => new Promise((resolve, reject) => {
|
getSocialIssues().then(response => new Promise((resolve, reject) => {
|
||||||
this.$store.commit('updateIssuesOther', response.results);
|
this.$store.commit('updateIssuesOther', response.results);
|
||||||
|
|
||||||
|
// ajoute dans la liste les issues déjà associées (si elles ne s'y trouvent pas déjà)
|
||||||
this.socialIssuesSelected.forEach(issue => {
|
this.socialIssuesSelected.forEach(issue => {
|
||||||
this.$store.commit('addIssueInList', issue);
|
if (this.socialIssuesList.filter(i => i.id === issue.id).length !== 1) {
|
||||||
|
this.$store.commit('addIssueInList', issue);
|
||||||
|
}
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
console.log(this.socialIssuesOther.length, this.socialIssuesOther);
|
// enlève du multiselect les issues qui sont dans la liste des checkbox
|
||||||
this.socialIssuesList.forEach(issue => {
|
this.socialIssuesList.forEach(issue => {
|
||||||
this.$store.commit('removeIssueInOther', issue);
|
this.$store.commit('removeIssueInOther', issue);
|
||||||
}, this);
|
}, this);
|
||||||
console.log(this.socialIssuesOther.length); // grr !!!
|
|
||||||
// TODO décompter les issues initiales du multiselect
|
|
||||||
|
|
||||||
|
// filtre les issues
|
||||||
this.$store.commit('filterList', 'issues');
|
this.$store.commit('filterList', 'issues');
|
||||||
|
|
||||||
|
// ajoute dans la liste les actions déjà associées (si elles ne s'y trouvent pas déjà)
|
||||||
this.socialActionsSelected.forEach(action => {
|
this.socialActionsSelected.forEach(action => {
|
||||||
this.$store.commit('addActionInList', action);
|
this.$store.commit('addActionInList', action);
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
|
// filtre les actions
|
||||||
this.$store.commit('filterList', 'actions');
|
this.$store.commit('filterList', 'actions');
|
||||||
|
|
||||||
|
|
||||||
this.issueIsLoading = false;
|
this.issueIsLoading = false;
|
||||||
resolve();
|
resolve();
|
||||||
}));
|
}));
|
||||||
@ -175,22 +181,25 @@ export default {
|
|||||||
|
|
||||||
this.$store.commit('resetActionsList');
|
this.$store.commit('resetActionsList');
|
||||||
|
|
||||||
|
// remettre les ActionsSelected dans ActionsList
|
||||||
|
|
||||||
this.socialIssuesSelected.forEach(item => {
|
this.socialIssuesSelected.forEach(item => {
|
||||||
console.log('for issue', item.id);
|
//console.log('for issue', item.id);
|
||||||
|
|
||||||
this.actionIsLoading = true;
|
this.actionIsLoading = true;
|
||||||
getSocialActionByIssue(item.id)
|
getSocialActionByIssue(item.id)
|
||||||
.then(actions => new Promise((resolve, reject) => {
|
.then(actions => new Promise((resolve, reject) => {
|
||||||
|
|
||||||
actions.results.forEach(action => {
|
actions.results.forEach(action => {
|
||||||
this.$store.commit('addActionInList', action);
|
this.$store.commit('addActionInList', action);
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
this.$store.commit('filterList', 'actions');
|
this.$store.commit('filterList', 'actions');
|
||||||
|
|
||||||
this.actionIsLoading = false;
|
this.actionIsLoading = false;
|
||||||
resolve();
|
resolve();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
}, this);
|
}, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,47 +29,44 @@ const store = createStore({
|
|||||||
|
|
||||||
// SocialIssueAcc
|
// SocialIssueAcc
|
||||||
addIssueInList(state, issue) {
|
addIssueInList(state, issue) {
|
||||||
console.log('add list issue', issue.id);
|
//console.log('add issue list', issue.id);
|
||||||
state.activity.accompanyingPeriod.socialIssues.push(issue);
|
state.activity.accompanyingPeriod.socialIssues.push(issue);
|
||||||
},
|
},
|
||||||
addIssueSelected(state, issue) {
|
addIssueSelected(state, issue) {
|
||||||
console.log('add selected issue', issue.id);
|
//console.log('add issue selected', issue.id);
|
||||||
state.activity.socialIssues.push(issue);
|
state.activity.socialIssues.push(issue);
|
||||||
},
|
},
|
||||||
updateIssuesSelected(state, issues) {
|
updateIssuesSelected(state, issues) {
|
||||||
console.log('update selected issues', issues);
|
//console.log('update issues selected', issues);
|
||||||
state.activity.socialIssues = issues;
|
state.activity.socialIssues = issues;
|
||||||
},
|
},
|
||||||
updateIssuesOther(state, payload) {
|
updateIssuesOther(state, payload) {
|
||||||
console.log('update other issues');
|
//console.log('update issues other');
|
||||||
state.socialIssuesOther = payload;
|
state.socialIssuesOther = payload;
|
||||||
},
|
},
|
||||||
removeIssueInOther(state, issue) {
|
removeIssueInOther(state, issue) {
|
||||||
console.log('remove other issue', issue.id);
|
//console.log('remove issue other', issue.id);
|
||||||
state.socialIssuesOther = state.socialIssuesOther.filter(item => item !== issue);
|
state.socialIssuesOther = state.socialIssuesOther.filter(i => i.id !== issue.id);
|
||||||
},
|
},
|
||||||
resetActionsList(state) {
|
resetActionsList(state) {
|
||||||
console.log('reset actions list');
|
//console.log('reset list actions');
|
||||||
state.socialActionsList = [];
|
state.socialActionsList = [];
|
||||||
},
|
},
|
||||||
addActionInList(state, action) {
|
addActionInList(state, action) {
|
||||||
console.log('add list action', action.id);
|
//console.log('add action list', action.id);
|
||||||
state.socialActionsList.push(action);
|
state.socialActionsList.push(action);
|
||||||
},
|
},
|
||||||
updateActionsSelected(state, actions) {
|
updateActionsSelected(state, actions) {
|
||||||
console.log('update selected actions', actions);
|
//console.log('update actions selected', actions);
|
||||||
state.activity.socialActions = actions;
|
state.activity.socialActions = actions;
|
||||||
},
|
},
|
||||||
filterList(state, list) {
|
filterList(state, list) {
|
||||||
const filterList = (list) => {
|
const filterList = (list) => {
|
||||||
console.log('filter ' + list.length + ' items: uniq'); // grr !!!
|
// remove duplicates entries
|
||||||
// TODO un filtrage qui enlève les doublons
|
list = list.filter((value, index) => list.findIndex(array => array.id === value.id) === index);
|
||||||
//list = list.filter((v, i, a) => a.indexOf(v) === i);
|
// alpha sort
|
||||||
let _list = [...new Set(list)];
|
list.sort((a,b) => (a.text > b.text) ? 1 : ((b.text > a.text) ? -1 : 0));
|
||||||
|
return list;
|
||||||
console.log('filter ' + list.length + ' items: sort', list);
|
|
||||||
_list.sort((a,b) => (a.text > b.text) ? 1 : ((b.text > a.text) ? -1 : 0));
|
|
||||||
return _list;
|
|
||||||
};
|
};
|
||||||
if (list === 'issues') {
|
if (list === 'issues') {
|
||||||
state.activity.accompanyingPeriod.socialIssues = filterList(state.activity.accompanyingPeriod.socialIssues);
|
state.activity.accompanyingPeriod.socialIssues = filterList(state.activity.accompanyingPeriod.socialIssues);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user