Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 883a423e

Přidáno uživatelem Tomáš Ballák před téměř 4 roky(ů)

change the name of dataset in popup buble

Zobrazit rozdíly:

website/public/js/zcu-heatmap.js
19 19
var info = []
20 20
let currentInfo = 0
21 21

  
22
const datasetDictNameDisplayName = {}
22 23
var datasetSelected = []
23 24

  
24 25
const globalMarkersHolder = {}
......
54 55
const genPopUpControls = (controls) => {
55 56
  return `<div class="popup-controls">${controls ? controls.reduce((sum, item) => sum + item, '') : ''}</div>`
56 57
}
57
const multipleDatasetsPopUp = (sum, currentPos, maxPos, datasetName) => {
58
  const header = `<strong>Dataset a počet:</strong><div id="place-info">${datasetName}</div>`
58
const genMultipleDatasetsPopUp = (sum, currentPos, maxPos, datasetName) => {
59
  const header = `<strong id="dataset-info">${datasetName}</strong>`
59 60
  const digitInfo = `<div id="number-info"><span id="digit-info">${sum}</span></div>`
60 61
  const { previousButton, nextButton, posInfo } = genPopUpControlButtons(currentPos, maxPos)
61 62
  return `
......
69 70
  className: className
70 71
}).setLatLng([lat / num, lng / num])
71 72

  
72
const genPopUp = (place, number, sum, currentPos, maxPos) => {
73
  const header = `<strong>Zařízení a počet:</strong><div id="place-info">${place}</div>`
73
const genPopUp = (datasetName, place, number, sum, currentPos, maxPos) => {
74
  const header = `<strong>${datasetName}</strong><div id="place-info">${place}</div>`
74 75
  const currentNum = `<span id="digit-info">${number}</span>`
75 76
  // eslint-disable-next-line eqeqeq
76 77
  const sumNum = `<span id="total-info" style="font-size: large">${(sum && (sum != number)) ? '/' + sum : ''}</span>`
......
175 176
    const info_ = infoDict.items
176 177
    const { place, number } = info_[currentInfo]
177 178
    prepareLayerPopUp(lat, lng, i, `popup-${infoDict.datasetName}`)
178
      .setContent(genPopUp(place, number, total, currentInfo + 1, info_.length))
179
      .setContent(genPopUp(datasetDictNameDisplayName[infoDict.datasetName], place, number, total, currentInfo + 1, info_.length))
179 180
      .openOn(mymap)
180 181
    if (info_.length === 1) {
181 182
      $('#previous-info-btn').prop('disabled', true)
......
185 186
  } else {
186 187
    const { datasetName, number } = getElFromObjectInfo(currentInfo)
187 188
    prepareLayerPopUp(lat, lng, i, `popup-${datasetName}`)
188
      .setContent(multipleDatasetsPopUp(number, currentInfo + 1, getInfoLength(), datasetName))
189
      .setContent(genMultipleDatasetsPopUp(number, currentInfo + 1, getInfoLength(), datasetDictNameDisplayName[datasetName]))
189 190
      .openOn(mymap)
190 191
  }
191 192
}
......
209 210
  const previousInfo = hasInfoMultipleDatasets() ? getElFromObjectInfo(previousInfoNum) : getElFromObjectInfo(0).items[previousInfoNum]
210 211
  const info_ = hasInfoMultipleDatasets() ? getElFromObjectInfo(currentInfo) : getElFromObjectInfo(0).items[currentInfo]
211 212
  const infoLength = getInfoLength()
213
  const datasetInfo = $('#dataset-info')
214
  if (datasetInfo) {
215
    $(datasetInfo).html(datasetDictNameDisplayName[info_.datasetName])
216
  }
212 217
  $('#place-info').html(info_.place ? info_.place : info_.datasetName)
213 218
  $('#digit-info').html(info_.number)
214 219
  $('#count-info').html(currentInfo + 1 + ' z ' + infoLength)
......
327 332
      const { x, y, name } = data[key_][key]
328 333
      const pop =
329 334
          prepareLayerPopUp(x, y, 1, `popup-${key_}`)
330
            .setContent(genPopUp(name, 0, 0, 1, 1))
335
            .setContent(genPopUp(datasetDictNameDisplayName[key_], name, 0, 0, 1, 1))
331 336
      const newCircle =
332 337
        L.circle([x, y], { radius: 2, fillOpacity: 0.8, color: '#004fb3', fillColor: '#004fb3', bubblingMouseEvents: true })
333 338
          .bindPopup(pop)
......
498 503
    if (input[0].checked) {
499 504
      datasetSelected.push(inputVal)
500 505
    }
506
    datasetDictNameDisplayName[inputVal] = $(input).data('dataset-display-name')
501 507
  })
502 508
  $('#submit-btn').prop('name', '')
503 509
}
website/templates/heatmap.html.twig
50 50
                form_widget(form.time, {
51 51
                  'id' : 'time',
52 52
                  'attr' : {
53
                    'class' : 'custom-select'
53
                    'class' : 'custom-select',
54 54
                  },
55 55
                })
56 56
              }}             
......
67 67
              <label class="dropdown-item custom-dropdown-item">
68 68
              <div class="custom-control custom-checkbox custom-checkbox-{{oneType.vars.value}}">
69 69
              {{ form_widget(oneType, {
70
                attr: {'class': "custom-control-input custom-control-input-#{oneType.vars.value}"}
70
                attr: {
71
                  'class': "custom-control-input custom-control-input-#{oneType.vars.value}",
72
                  'data-dataset-display-name': "#{oneType.vars.label}"
73
                  }
71 74
              }) }}
72 75
              {{ form_label(oneType, null, {
73 76
                'label_attr': {'class': 'custom-control-label'}

Také k dispozici: Unified diff