]> git.cworth.org Git - lmno.games/blobdiff - empathy/empathy.jsx
Reject a category with a number of items of 0
[lmno.games] / empathy / empathy.jsx
index feff7775a99f782188474bab923da9e1580b8327..6acf526c3516da99cdf72f282c65ff5ad894a8be 100644 (file)
@@ -283,7 +283,7 @@ class CategoryRequest extends React.PureComponent {
     const match = category.match(/[0-9]+/);
     if (match) {
       const num_items = parseInt(match[0], 10);
-      if (num_items <= MAX_PROMPT_ITEMS)
+      if (num_items > 0 && num_items <= MAX_PROMPT_ITEMS)
         category_input.setCustomValidity("");
     }
   }
@@ -311,6 +311,12 @@ class CategoryRequest extends React.PureComponent {
       return;
     }
 
+    if (num_items < 1) {
+      category_input.setCustomValidity("Category must require at least one item.");
+      form.reportValidity();
+      return;
+    }
+
     const response = await fetch_post_json("prompts", {
       items: num_items,
       prompt: category
@@ -468,11 +474,9 @@ class Ambiguities extends React.PureComponent {
 
     for (let word of props.words) {
       const word_canon = canonize(word);
-      console.log("Canonized " + word + " to " + word_canon);
       let found_match = false;
       for (let set of word_sets) {
         const set_canon = canonize(set.values().next().value);
-        console.log("Comparing " + word_canon + " to " + set_canon);
         if (word_canon === set_canon) {
           set.add(word);
           found_match = true;;
@@ -505,7 +509,7 @@ class Ambiguities extends React.PureComponent {
     const response = await fetch_post_json(
       `judged/${this.props.prompt.id}`,{
         word_groups: this.state.word_sets.map(set => Array.from(set)),
-        kudos: Array.from(this.state.starred)
+        kudos: this.state.starred ? Array.from(this.state.starred) : null
       }
     );
 
@@ -597,7 +601,7 @@ class Ambiguities extends React.PureComponent {
           className="vote-button"
           onClick={() => fetch_post_json(`end-judging/${this.props.prompt.id}`) }
         >
-          Move On
+          Move On Without Their Input
           <div className="vote-choices">
             {[...this.props.votes].map(v => {
               return (
@@ -792,7 +796,7 @@ class ActivePrompt extends React.PureComponent {
           className="vote-button"
           onClick={() => fetch_post_json(`end-answers/${this.props.prompt.id}`) }
         >
-          Move On
+          Move On Without Their Answers
           <div className="vote-choices">
             {[...this.props.votes].map(v => {
               return (