Skip to content

Commit

Permalink
Merge branch 'development' into page
Browse files Browse the repository at this point in the history
  • Loading branch information
mjy committed Dec 7, 2019
2 parents dcfc738 + e16726c commit 01af0ab
Show file tree
Hide file tree
Showing 68 changed files with 662 additions and 200 deletions.
3 changes: 2 additions & 1 deletion app/controllers/biological_associations_controller.rb
Expand Up @@ -104,7 +104,8 @@ def biological_association_params
:biological_association_object_id, :biological_association_object_type,
:subject_global_id,
:object_global_id,
origin_citation_attributes: [:id, :_destroy, :source_id, :pages]
origin_citation_attributes: [:id, :_destroy, :source_id, :pages],
citations_attributes: [:id, :is_original, :_destroy, :source_id, :pages, :citation_object_id, :citation_object_type],
)
end
end
2 changes: 1 addition & 1 deletion app/controllers/collection_objects_controller.rb
Expand Up @@ -283,7 +283,7 @@ def collection_object_params
:total, :preparation_type_id, :repository_id,
:ranged_lot_category_id, :collecting_event_id,
:buffered_collecting_event, :buffered_determinations,
:buffered_other_labels, :deaccessioned_at, :deaccession_reason,
:buffered_other_labels, :accessioned_at, :deaccessioned_at, :deaccession_reason,
:contained_in,
collecting_event_attributes: [], # needs to be filled out!
data_attributes_attributes: [ :id, :_destroy, :controlled_vocabulary_term_id, :type, :attribute_subject_id, :attribute_subject_type, :value ]
Expand Down
1 change: 0 additions & 1 deletion app/controllers/sources_controller.rb
Expand Up @@ -196,7 +196,6 @@ def filter_params
params.permit(:query_term, :project_id, :recent, author_ids: [])
end


def set_source
@source = Source.find(params[:id])
@recent_object = @source
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/tasks/sources/find_controller.rb
Expand Up @@ -13,6 +13,8 @@ def find
render :index
end

protected

def filter_params
params.permit(:query_term).merge(project_id: sessions_current_project_id, recent: true)
end
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/workbench/sessions_helper.rb
Expand Up @@ -204,7 +204,7 @@ def favorites?(kind, name)
end

def project_settings_link
(sessions_project_selected? && is_superuser?) ? link_to('Project', project_path(sessions_current_project)) : nil
(sessions_project_selected? && is_superuser?) ? link_to('Project', project_path(sessions_current_project), data: {project_id: sessions_current_project_id}) : nil
end

def administration_link
Expand Down
4 changes: 2 additions & 2 deletions app/javascript/vue/components/defaultConfidence.vue
Expand Up @@ -9,7 +9,7 @@
arrow-size="small"
:inertia="true"
:arrow="true"
:content="`<p>Create confidence: ${getDefaultElement().firstChild.firstChild.textContent}.<br>Used already on more of ${confidenceCount} objects</p>`">
:content="`<p>Create confidence: ${getDefaultElement().firstChild.firstChild.textContent}.<br>Used already on ${confidenceCount} ${confidenceCount > 200 ? 'or more' : '' } objects</p>`">
<template v-slot:trigger>
<div
class="default_tag_widget circle-button btn-confidences btn-submit"
Expand All @@ -25,7 +25,7 @@
arrow-size="small"
:inertia="true"
:arrow="true"
:content="`<p>Remove confidence: ${getDefaultElement().firstChild.firstChild.textContent}.<br>Used already on more of ${confidenceCount} objects</p>`">
:content="`<p>Remove confidence: ${getDefaultElement().firstChild.firstChild.textContent}.<br>Used already on ${confidenceCount} ${confidenceCount > 200 ? 'or more' : '' } objects</p>`">
<template v-slot:trigger>
<div
class="default_tag_widget circle-button btn-confidences btn-delete"
Expand Down
4 changes: 2 additions & 2 deletions app/javascript/vue/components/defaultTag.vue
Expand Up @@ -9,7 +9,7 @@
arrow-size="small"
:inertia="true"
:arrow="true"
:content="`<p>Create tag: ${getDefaultElement().firstChild.firstChild.textContent}.${showCount ? `<br>Used already on more of ${countTag} objects</p>` : ''}`">
:content="`<p>Create tag: ${getDefaultElement().firstChild.firstChild.textContent}.${showCount ? `<br>Used already on ${countTag} ${countTag > 200 ? 'or more' : '' } objects</p>` : ''}`">
<template v-slot:trigger>
<div
class="default_tag_widget circle-button btn-tag-add"
Expand All @@ -25,7 +25,7 @@
arrow-size="small"
:inertia="true"
:arrow="true"
:content="`<p>Remove tag: ${getDefaultElement().firstChild.firstChild.textContent}.${showCount ? `<br>Used already on more of ${countTag} objects</p>` : ''}`">
:content="`<p>Remove tag: ${getDefaultElement().firstChild.firstChild.textContent}.${showCount ? `<br>Used already on ${countTag} ${countTag > 200 ? 'or more' : '' } objects</p>` : ''}`">
<template v-slot:trigger>
<div
class="default_tag_widget circle-button btn-tag-delete"
Expand Down
Expand Up @@ -14,6 +14,7 @@
<source-picker
@create="setSource"
ref="source"
@lock="lockSource = $event"
:display="displayLabel"/>
<button
type="button"
Expand All @@ -33,6 +34,7 @@
:show-spinner="false"/>
<geographic-area
class="separate-bottom"
@lock="lockGeo = $event"
:created-list="list"
@select="asserted_distribution.geographic_area_id = $event; createAsserted()"/>
</div>
Expand Down Expand Up @@ -110,7 +112,9 @@
asserted_distribution: this.newAsserted(),
displayLabel: undefined,
displayGeographic: undefined,
editTitle: undefined
editTitle: undefined,
lockSource: false,
lockGeo: false
}
},
mounted() {
Expand All @@ -119,7 +123,6 @@
methods: {
createAsserted() {
if(!this.existingArea) {
this.asserted_distribution.citations_attributes[0]['is_original'] = true
this.create('/asserted_distributions.json', { asserted_distribution: this.asserted_distribution }).then(response => {
this.addToList(response.body)
})
Expand All @@ -146,7 +149,9 @@
},
addToList(item) {
this.editTitle = item.object_tag
this.$refs.source.cleanInput()
if(!this.lockSource) {
this.$refs.source.cleanInput()
}
if(this.idIndex > -1) {
this.$set(this.list, this.idIndex, item)
}
Expand All @@ -168,19 +173,21 @@
return {
id: undefined,
otu_id: this.splittedGlobalId,
geographic_area_id: undefined,
geographic_area_id: this.lockGeo ? this.asserted_distribution.geographic_area_id : undefined,
citations: [],
citations_attributes: [{
citations_attributes: this.lockSource ? this.asserted_distribution.citations_attributes : [{
source_id: undefined,
pages: undefined
pages: undefined,
is_original: undefined
}],
is_absent: undefined
}
},
setSource(source) {
this.asserted_distribution.citations_attributes[0].source_id = source.source_id
this.asserted_distribution.citations_attributes[0].pages = source.pages
this.asserted_distribution.is_absent = source.is_absent
this.asserted_distribution.citations_attributes[0].is_absent = source.is_absent
this.asserted_distribution.citations_attributes[0].is_original = source.is_original
}
},
}
Expand Down
Expand Up @@ -3,11 +3,14 @@
<div>
<fieldset>
<legend>Geographic area</legend>
<switch-component
:options="Object.keys(smartGeographics)"
v-model="view"
:add-option="['search']"
name="switch-geographic"/>
<div class="horizontal-left-content">
<switch-component
class="separate-right"
:options="Object.keys(smartGeographics)"
v-model="view"
:add-option="['search']"
name="switch-geographic"/>
</div>
<template v-if="smartGeographics[view]">
<tag-item
v-for="item in smartGeographics[view]"
Expand Down Expand Up @@ -36,13 +39,15 @@
import SwitchComponent from '../shared/switch.vue'
import Autocomplete from 'components/autocomplete.vue'
import CRUD from '../../request/crud'
import LockComponent from 'components/lock'
export default {
mixins: [CRUD],
components: {
TagItem,
SwitchComponent,
Autocomplete
Autocomplete,
LockComponent
},
props: {
createdList: {
Expand All @@ -54,7 +59,13 @@
return {
view: undefined,
smartGeographics: [],
selected: undefined
selected: undefined,
lock: false
}
},
watch: {
lock(newVal) {
this.$emit('lock', newVal)
}
},
mounted() {
Expand Down
Expand Up @@ -26,14 +26,23 @@
@click="cleanCitation"
class="separate-left"
data-icon="reset"/>
<lock-component v-model="lock"/>
</template>
</div>
<div class="flex-separate">
<input
class="normal-input inline pages"
v-model="citation.pages"
placeholder="pages"
type="text">
<div>
<input
class="normal-input inline pages"
v-model="citation.pages"
placeholder="pages"
type="text">
<label class="inline middle">
<input
v-model="citation.is_original"
type="checkbox">
Is original
</label>
</div>
<label class="inline middle">
<input
v-model="citation.is_absent"
Expand All @@ -47,11 +56,13 @@
<script>
import DefaultElement from 'components/getDefaultPin.vue'
import Autocomplete from 'components/autocomplete.vue'
import LockComponent from 'components/lock'
export default {
components: {
DefaultElement,
Autocomplete
Autocomplete,
LockComponent
},
props: {
display: {
Expand All @@ -67,7 +78,8 @@
data() {
return {
autocompleteLabel: undefined,
citation: this.newCitation()
citation: this.newCitation(),
lock: false
}
},
watch: {
Expand All @@ -79,6 +91,9 @@
},
display(newVal) {
this.autocompleteLabel = newVal
},
lock(newVal) {
this.$emit('lock', newVal)
}
},
methods: {
Expand All @@ -87,6 +102,7 @@
source_id: undefined,
is_absent: false,
pages: undefined,
is_original: undefined
}
},
sendCitation() {
Expand Down
Expand Up @@ -161,7 +161,7 @@ export default {
biological_relationship_id: this.biologicalRelationship.id,
object_global_id: (this.flip ? this.globalId : this.biologicalRelation.global_id),
subject_global_id: (this.flip ? this.biologicalRelation.global_id : this.globalId),
origin_citation_attributes: this.citation
citations_attributes: [this.citation]
}
this.create('/biological_associations.json', { biological_association: data }).then(response => {
Expand All @@ -179,7 +179,7 @@ export default {
}
if (this.citation) {
data.origin_citation_attributes = this.citation
data.citations_attributes = [this.citation]
}
this.update(`/biological_associations/${data.id}.json`, { biological_association: data }).then(response => {
Expand Down
Expand Up @@ -77,7 +77,7 @@
return {
annotated_global_entity: decodeURIComponent(this.globalId),
source_id: undefined,
is_original: false,
is_original: undefined,
pages: undefined,
}
},
Expand Down
1 change: 1 addition & 0 deletions app/javascript/vue/components/role_picker.vue
Expand Up @@ -306,6 +306,7 @@
}
this.roles_attributes.push(person)
this.$emit('input', this.roles_attributes)
this.$refs.autocomplete.cleanInput()
this.expandPerson = false
this.person_attributes = this.makeNewPerson()
this.$emit('create', person)
Expand Down
9 changes: 6 additions & 3 deletions app/javascript/vue/helpers/ajaxCall.js
Expand Up @@ -7,10 +7,14 @@ const ajaxCall = function (type, url, data = null) {
Vue.http.headers.common['X-CSRF-Token'] = document.querySelector('meta[name="csrf-token"]').getAttribute('content')
return new Promise(function (resolve, reject) {
Vue.http[type](url, data).then(response => {
console.log(response)
if (process.env.NODE_ENV !== 'production') {
console.log(response)
}
return resolve(response)
}, response => {
console.log(response)
if (process.env.NODE_ENV !== 'production') {
console.log(response)
}
handleError(response.body)
return reject(response)
})
Expand All @@ -23,7 +27,6 @@ const handleError = function (json) {
let errorMessage = ''

errors.forEach(function (item) {
console.log(item)
errorMessage += json[item].join('<br>') + '<br>'
})

Expand Down
Expand Up @@ -76,9 +76,12 @@
:show-message="checkValidation"
legend="Namespace and identifier needs to be set to be save."/>
</div>
<span
v-if="!namespace && identifier && identifier.length"
style="color: red">Namespace is needed.</span>
<span
v-if="existingIdentifier"
style="color: red">Identifier already exists</span>
style="color: red">Identifier already exists, and it won't be saved.</span>
</div>
</div>
</div>
Expand Down Expand Up @@ -188,6 +191,9 @@
collectionObject(newVal, oldVal) {
if (!newVal.id || newVal.id == oldVal.id) return
this.loadSmartSelector()
},
existingIdentifier(newVal) {
this.settings.saveIdentifier = !newVal
}
},
mounted() {
Expand Down

0 comments on commit 01af0ab

Please sign in to comment.