Skip to content

Commit

Permalink
Tweaks #337
Browse files Browse the repository at this point in the history
  • Loading branch information
jlpereira committed Jan 23, 2019
1 parent c9ac9d7 commit a74bffc
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,37 @@
v-model="view"
:add-option="moreOptions"
:options="options"/>
<autocomplete
url="/geographic_areas/autocomplete"
min="2"
param="term"
placeholder="Select a geographic area"
@getItem="selectGeographicArea"
display="label"
ref="autocomplete"
label="label_html"/>
<template>
<autocomplete
v-if="view == 'search'"
url="/geographic_areas/autocomplete"
min="2"
param="term"
placeholder="Select a geographic area"
@getItem="selectGeographicArea"
display="label"
ref="autocomplete"
label="label_html"/>
<ul
class="no_bullets"
v-else>
<li
v-for="item in lists[view]"
:key="item.id">
<label>
<input
type="radio"
:checked="item.id == geographicArea"
@click="selectGeographicArea(item)">
{{ item.name }}
</label>
</li>
</ul>
</template>
<template v-if="selected">
<div class="middle separate-top">
<span data-icon="ok"/>
<span class="separate-right"> {{ selected.label }}</span>
<span class="separate-right"> {{ (selected['label'] ? selected.label : selected.name) }}</span>
<span
class="circle-button button-default btn-undo"
@click="clearSelection"/>
Expand All @@ -35,6 +53,7 @@
import { GetterNames } from '../../../../store/getters/getters.js'
import { MutationNames } from '../../../../store/mutations/mutations.js'
import { GetGeographicSmartSelector } from '../../../../request/resources.js'
import OrderSmartSelector from 'helpers/smartSelector/orderSmartSelector'
export default {
components: {
Expand All @@ -53,9 +72,9 @@
},
data() {
return {
moreOptions: ['Look back', 'Search'],
moreOptions: ['search'],
options: [],
view: undefined,
view: 'search',
lists: [],
selected: undefined
}
Expand All @@ -72,11 +91,7 @@
GetSmartSelector() {
GetGeographicSmartSelector().then(response => {
let result = response
Object.keys(result).forEach(key => (!result[key].length) && delete result[key])
this.options = Object.keys(result)
if(Object.keys(result).length) {
this.view = Object.keys(result)[0]
}
this.options = OrderSmartSelector(Object.keys(result))
this.lists = response
})
},
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/vue/tasks/digitize/request/resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ const GetTaxonDeterminatorSmartSelector = function () {
}

const GetGeographicSmartSelector = function () {
return ajaxCall('get', `/geographic_areas/select_options`)
return ajaxCall('get', `/geographic_areas/select_options?target=CollectingEvent`)
}

const GetOtuSmartSelector = function () {
Expand Down

0 comments on commit a74bffc

Please sign in to comment.