Fix advanced search editing bug

When an existing search criteria is being edited, if the query has been
deleted remove it from the criteria, similiarly clear the included
excluded tags.