toggleDropletsFilter: function()

in webapp/components/flow-design-system/fds-demo.js [770:790]


    toggleDropletsFilter: function (searchTerm) {
        let applySearchTerm = true;
        // check if the search term is already applied and remove it if true
        if (this.dropletsSearchTerms.length > 0) {
            const arrayLength = this.dropletsSearchTerms.length;
            for (let i = 0; i < arrayLength; i++) {
                const index = this.dropletsSearchTerms.indexOf(searchTerm);
                if (index > -1) {
                    this.dropletsSearchTerms.splice(index, 1);
                    applySearchTerm = false;
                }
            }
        }

        // if we just removed the search term do NOT apply it again
        if (applySearchTerm) {
            this.dropletsSearchTerms.push(searchTerm);
        }

        this.filterDroplets(this.activeDropletColumn.name, this.activeDropletColumn.sortOrder);
    },