My dynamic category page includes a list of tasks that should be grouped by Client Name. Users are able to search a table of tasks by task title, or they can use a drop-down to view by task status. I found the code for this functionality on this youtube video .
I love the way it works, except for the fact that for some reason, when users select from the list of options, the results pull in tasks their tasks, but it also displays the tasks of other clients. Obviously, my goal when creating the dynamic category page, was that the results would be filtered by client name. I’m guessing that something in the code for the search bar and/or drop-down, is impacting the category page functionality.
I’ve pasted all of the code I’m using on the page below. Can anyone help me figure this out?
$w.onReady(function () {
$w(“#button59”).target = “_self”;
$w(“#button57”).target = “_self”;
$w(“#button58”).target = “_self”;
$w(“#image9”).target = “_self”;
});
import wixData from “wix-data”;
$w.onReady(() => {
wixData.query(‘Key’)
.find()
.then(res => {
let options = [{“value”: ‘’, ‘label’: ‘Any Status’}];
options.push(…res.items.map(status => {
return {‘value’: status.value, ‘label’: status.label};
}));
$w(‘#iStatus’).options = options;
})
});
let lastFilterTitle;
let lastFilterKey;
let debounceTimer;
export function iTitle_keyPress(event, $w) {
if (debounceTimer) {
clearTimeout(debounceTimer);
debounceTimer = undefined;
}
debounceTimer = setTimeout(() => {
filter($w(‘#iTitle’).value, lastFilterKey);
}, 200);
}
function filter(title, taskStatus) {
if (lastFilterTitle !== title || lastFilterKey !== taskStatus) {
let newFilter = wixData.filter();
if (title)
newFilter = newFilter.contains(‘title’, title);
if (taskStatus)
newFilter = newFilter.eq(‘taskStatus’, taskStatus);
$w(‘#dynamicDataset’).setFilter(newFilter);
lastFilterTitle = title;
lastFilterKey = taskStatus;
}
}
export function iStatus_change(event,$w) {
filter(lastFilterTitle, $w(‘#iStatus’).value);
}
import {local} from “wix-storage”;
const linkField = “link-TaskDatabase-title”; // replace this value
$w.onReady(function () {
$w(“#dynamicDataset”).onReady(() => {
const numberOfItems = $w(“#dynamicDataset”).getTotalCount();
$w("#dynamicDataset").getItems(0, numberOfItems)
.then( (result) => {
const dynamicPageURLs = result.items.map(item => item[linkField]);
local.setItem('dynamicPageURLs', dynamicPageURLs);
} )
.catch( (err) => {
console.log(err.code, err.message);
} );
} );
} );