Add onChange event listeners to #iptShape and #iptColour dropdown boxes. These will check that a shape and colour have been selected before enabling the #btnSubmit button. Add an onClick event listener to #btnSubmit to insert or update the #Shapes collection.
Once the #btnSubmit is clicked, the wixData.query function checks the #Shapes collection for whether the shape entered in #iptShape is already in the collection. If it does not exist within the collection, it executes the saveShape function to insert it into the collection. If it already exists in the collection, it updates its colour. The #txtMessage text displays whether an insert or update operation has occurred.
This code does not allow duplicate shape's to be entered into the #Shapes collection. Also, note that the insert and update permissions need to allow for the permissions of user which will be executing this code.