migrate the ProjectsList according to the solution
This commit is contained in:
parent
3f0ae4d413
commit
2a10218809
|
@ -33,41 +33,40 @@ export default {
|
||||||
const activeSearchTerm = ref('');
|
const activeSearchTerm = ref('');
|
||||||
const enteredSearchTerm = ref('');
|
const enteredSearchTerm = ref('');
|
||||||
|
|
||||||
const hasProjects = computed(function() {
|
|
||||||
return props.user.projects && availableProjects.value.length > 0;
|
|
||||||
});
|
|
||||||
const availableProjects = computed(function() {
|
const availableProjects = computed(function() {
|
||||||
if (activeSearchTerm.value) {
|
if (activeSearchTerm.value) {
|
||||||
return props.user.projects.filter(prj =>
|
return props.user.projects.filter(prj =>
|
||||||
prj.title.includes(activeSearchTerm)
|
prj.title.includes(activeSearchTerm.value)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return props.user.projects;
|
return props.user.projects;
|
||||||
});
|
});
|
||||||
|
|
||||||
watch(enteredSearchTerm, function(val) {
|
const hasProjects = computed(function() {
|
||||||
|
return props.user.projects && availableProjects.value.length > 0;
|
||||||
|
});
|
||||||
|
|
||||||
|
watch(enteredSearchTerm, function(newValue) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (val === enteredSearchTerm.value) {
|
if (newValue === enteredSearchTerm.value) {
|
||||||
activeSearchTerm.value = val;
|
activeSearchTerm.value = newValue;
|
||||||
}
|
}
|
||||||
}, 300);
|
}, 300);
|
||||||
});
|
});
|
||||||
|
watch(props.user, function() {
|
||||||
|
enteredSearchTerm.value = '';
|
||||||
|
});
|
||||||
|
|
||||||
function updateSearch(val) {
|
function updateSearch(val) {
|
||||||
enteredSearchTerm.value = val;
|
enteredSearchTerm.value = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
function userSearch() {
|
|
||||||
enteredSearchTerm.value = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
enteredSearchTerm,
|
enteredSearchTerm,
|
||||||
activeSearchTerm,
|
activeSearchTerm,
|
||||||
hasProjects,
|
hasProjects,
|
||||||
availableProjects,
|
availableProjects,
|
||||||
updateSearch,
|
updateSearch
|
||||||
userSearch
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Reference in New Issue