TextBoxEntryFactory.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. 'use strict';
  2. var escapeHTML = require('../Utils').escapeHTML;
  3. var entryFieldDescription = require('./EntryFieldDescription');
  4. var textBox = function(options, defaultParameters) {
  5. var resource = defaultParameters,
  6. label = options.label || resource.id,
  7. canBeShown = !!options.show && typeof options.show === 'function',
  8. description = options.description;
  9. resource.html =
  10. '<label for="activiti-' + escapeHTML(resource.id) + '" ' +
  11. (canBeShown ? 'data-show="isShown"' : '') +
  12. '>' + label + '</label>' +
  13. '<div class="bpp-field-wrapper" ' +
  14. (canBeShown ? 'data-show="isShown"' : '') +
  15. '>' +
  16. '<div contenteditable="true" id="activiti-' + escapeHTML(resource.id) + '" ' +
  17. 'name="' + escapeHTML(options.modelProperty) + '" />' +
  18. '</div>';
  19. // add description below text box entry field
  20. if (description) {
  21. resource.html += entryFieldDescription(description);
  22. }
  23. if (canBeShown) {
  24. resource.isShown = function() {
  25. return options.show.apply(resource, arguments);
  26. };
  27. }
  28. resource.cssClasses = ['bpp-textbox'];
  29. return resource;
  30. };
  31. module.exports = textBox;