Vineyards by wine - no longer used

All the vineyards are listed.
You can narrow your choice by wine style

arrow&v
arrow&v

This is an  invisible page providing backup and explanation of the code running two dropdown boxes. (no longer used - keep for future use)

One dropdown is named styleDropdown and the other is named grapeDropdown.

grapeDropdown should be disabled upon loading.

import wixData from 'wix-data';

 

$w.onReady(function () {

    styleDropDown1();

});

 

function styleDropDown1 (){

// This function finds the unique values of style from the Varietals collection to populate the styleDropdown

     wixData.query("Varietals")

     .limit(1000)

      .find()

      .then(results => {

           const uniqueTitles = getUniqueTitles(results.items);

           $w("#styleDropdown").options = buildOptions(uniqueTitles);

      });

  function getUniqueTitles(items) {

        const titlesOnly = items.map(item => item.colour);

     return [...new Set(titlesOnly)];

    }

 

    function buildOptions(uniqueList) {

        return uniqueList.map(curr => {

            return {label:curr, value:curr};

        });

    }

}

 

export function styleDropdown_change_1(event) {

    // This function activates the grapeDropdown whenever the styleDropdown is changed

uniqueDropDown2();

$w("#grapeDropdown").enable();

}

 

function uniqueDropDown2 (){

// This function uses the style and populates the grapeDropdown

    wixData.query("Varietals")

        .contains("colour", $w("#styleDropdown").value)

        .limit(1000)

      .find()

      .then(results => {

           const uniqueTitles = getUniqueTitles(results.items);

           $w("#grapeDropdown").options = buildOptions(uniqueTitles);

      });

  function getUniqueTitles(items) {

        const titlesOnly = items.map(item => item.grape);

     return [...new Set(titlesOnly)];

    }

 

    function buildOptions(uniqueList) {

        return uniqueList.map(curr => {

            return {label:curr, value:curr};

        });

    }

}

Then there are 2 datasets, one holding the grape chosen, one filtering the vineyards by the grape chosen

More