diff --git a/src/sa_web/jstemplates/place-detail.html b/src/sa_web/jstemplates/place-detail.html index 3e62046448..45564e42d7 100644 --- a/src/sa_web/jstemplates/place-detail.html +++ b/src/sa_web/jstemplates/place-detail.html @@ -40,7 +40,7 @@

{{ survey_count }} {{ survey_label_by_count }} {{^if survey_config}} - View On Map + View On Map {{/if}} @@ -48,18 +48,76 @@

{{# attachments }} -
- {{ name }} -
+
+ {{ name }} +
{{/ attachments }} - {{#each_place_item "submitter_name" "name" "location_type"}} -
- {{label}} -

{{nlToBr value }}

-
+ + {{#each_place_item "submitter_name" "name" "location_type" "fullTitle" "title" "name"}} +
+ {{ prompt }} + + {{#is type "datetime"}} +

{{nlToBr content}}

+ {{/is}} + + {{#is type "text"}} +

{{nlToBr content}}

+ {{/is}} + + {{#is type "textarea"}} +

{{nlToBr content}}

+ {{/is}} + + {{#is type "radio_big_buttons"}} +
    + {{#each content}} + {{#if selected}} +
  • {{ label }}
  • + {{/if}} + {{/each}} +
+ {{/is}} + + {{#is type "checkbox_big_buttons"}} +
    + {{#each content}} + {{#if selected}} +
  • {{ label }}
  • + {{/if}} + {{/each}} +
+ {{/is}} + + {{#is type "binary_toggle"}} +
    +
  • + {{#if content.selected}} + {{ content.selectedLabel }} + {{else}} + {{ content.unselectedLabel }} + {{/if}} +
  • +
+ {{/is}} + + {{#is type "dropdown"}} + {{#each content}} + {{#if selected}} +
    +
  • + {{nlToBr label}} +
  • +
+ {{/if}} + {{/each}} + {{/is}} + +
+
{{/each_place_item }}
{{#if survey_config}} -
- {{/if}} +
+ {{/if}} \ No newline at end of file diff --git a/src/sa_web/static/js/handlebars-helpers.js b/src/sa_web/static/js/handlebars-helpers.js index 35cadd66c9..74de18e11f 100644 --- a/src/sa_web/static/js/handlebars-helpers.js +++ b/src/sa_web/static/js/handlebars-helpers.js @@ -181,25 +181,66 @@ var Shareabouts = Shareabouts || {}; options = args.slice(-1)[0]; exclusions = args.slice(0, args.length-1); + // iterate through all the form fields for this location_type _.each(selectedCategoryConfig.fields, function(item, i) { - // filter for the correct label/value pair - var display_value = _.filter(item.content, function(option) { - return option.value == self[item.name]; - })[0] || {}; + // handle input types on a case-by-case basis, building an appropriate + // context object for each + var userInput = self[item.name], + fieldType = item.type, + content, + wasAnswered = false; + + if (fieldType === "text" || fieldType === "textarea" || fieldType === "datetime") { + // case: plain text + content = userInput || ""; + if (content !== "") { + wasAnswered = true; + } + } else if (fieldType === "checkbox_big_buttons" || fieldType === "radio_big_buttons" || fieldType === "dropdown") { + // case: checkboxes, radio buttons, and dropdowns + // if input is not an array, convert to an array of length 1 + if (!$.isArray(self[item.name])) { + userInput = [self[item.name]]; + } + content = []; + _.each(item.content, function(option) { + var selected = false; + if (_.contains(userInput, option.value)) { + selected = true; + wasAnswered = true; + } + content.push({ + value: option.value, + label: option.label, + selected: selected + }); + }); + } else if (fieldType === "binary_toggle") { + // case: binary toggle buttons + // NOTE: we assume that the first option listed under content + // corresponds to the "on" value of the toggle input + content = { + selectedValue: item.content[0].value, + selectedLabel: item.content[0].label, + unselectedValue: item.content[1].value, + unselectedLabel: item.content[1].label, + selected: (userInput == item.content[0].value) ? true : false + } + wasAnswered = true; + } var newItem = { name: item.name, - label: item.display_prompt, - // get the (possibly) translated label from a dropdown, radio, or select input, or get free text entry - value: display_value.label || this[item.name], - type: item.type + type: item.type, + content: content, + prompt: item.display_prompt, + wasAnswered: wasAnswered }; - // if not an exclusion and not private data and not an empty response if (_.contains(exclusions, item.name) === false && item.name.indexOf('private-') !== 0 && - newItem.value != undefined && - newItem.value !== "") { + newItem.content != undefined && + newItem.wasAnswered === true) { result += options.fn(newItem); } }, this); diff --git a/src/sa_web/static/scss/_content.scss b/src/sa_web/static/scss/_content.scss index 06921bbaee..2bc96676a9 100644 --- a/src/sa_web/static/scss/_content.scss +++ b/src/sa_web/static/scss/_content.scss @@ -147,6 +147,30 @@ a.close-btn { } } +.place-items { + .place-item { + margin-top: 20px; + margin-bottom: 20px; + } + + ul { + margin: 0; + } + + .place-label { + font-weight: bold; + } + + .place-value { + color: #777777; + word-break: break-all; + } + + .multi-select-response { + padding: 0; + } +} + .place-submission-details { display: block; padding-left: 3.75em;