Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

make enumlabels hint work on array with items.enum

  • Loading branch information...
commit db216fb612d05f27a9c040691a24574704a41685 1 parent 8882e55
Mariano Guerra authored

Showing 2 changed files with 31 additions and 0 deletions. Show diff stats Hide diff stats

  1. +27 0 js/demos.js
  2. +4 0 src/addons/enumlabels.js
27 js/demos.js
@@ -580,6 +580,33 @@
580 580 }
581 581 ],
582 582 [
  583 + "Array with enum options and enumlabels hint (addon)",
  584 + "",
  585 + {
  586 + "order": [
  587 + "names"
  588 + ],
  589 + "properties": {
  590 + "names": {
  591 + "type": "array",
  592 + "title": "Names",
  593 + "je:hint": "enumlabels",
  594 + "je:enumlabels": {
  595 + "pablo": "Pablo",
  596 + "ignacio": "Ignacio",
  597 + "mariano": "Mariano",
  598 + "luis": "Luis",
  599 + "marisel": "Maria Isabel"
  600 + },
  601 + "items": {
  602 + "type": "string",
  603 + "enum": ["pablo", "ignacio", "mariano", "luis", "marisel"]
  604 + }
  605 + }
  606 + }
  607 + }
  608 + ],
  609 + [
583 610 "Array with enum options",
584 611 "no type specified for items defaults to string",
585 612 {
4 src/addons/enumlabels.js
@@ -19,6 +19,7 @@
19 19 var formatHints = JsonEdit.defaults.hintedFormatters;
20 20
21 21 formatHints.string = formatHints.string || {};
  22 + formatHints.array = formatHints.array || {};
22 23
23 24 formatHints.string.enumlabels = function (name, type, id, opts, required, priv, util) {
24 25 var i, obj = priv.formatForType(name, type, id, opts, required, util),
@@ -41,6 +42,9 @@
41 42 return obj;
42 43 };
43 44
  45 + // will work when array schema has items.enum set
  46 + formatHints.array.enumlabels = formatHints.string.enumlabels;
  47 +
44 48 // no need for collectHints since it's a common input field
45 49 return JsonEdit;
46 50 }));

0 comments on commit db216fb

Please sign in to comment.
Something went wrong with that request. Please try again.