Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
LocoDelAssembly committed Jun 5, 2020
2 parents 72c08d8 + bdce820 commit d4a144e
Show file tree
Hide file tree
Showing 58 changed files with 498 additions and 344 deletions.
17 changes: 9 additions & 8 deletions Gemfile.lock
Expand Up @@ -119,7 +119,7 @@ GEM
closure_tree (7.1.0)
activerecord (>= 4.2.10)
with_advisory_lock (>= 4.0.0)
coderay (1.1.2)
coderay (1.1.3)
concurrent-ruby (1.1.6)
coveralls (0.8.23)
json (>= 1.8, < 3)
Expand Down Expand Up @@ -161,13 +161,13 @@ GEM
factory_bot_rails (5.2.0)
factory_bot (~> 5.2.0)
railties (>= 4.2.0)
faker (2.11.0)
faker (2.12.0)
i18n (>= 1.6, < 2)
faraday (0.17.3)
multipart-post (>= 1.2, < 3)
faraday_middleware (0.14.0)
faraday (>= 0.7.4, < 1.0)
ffi (1.12.2)
ffi (1.13.0)
ffi-geos (2.1.0)
ffi (>= 1.0.0)
formatador (0.2.5)
Expand Down Expand Up @@ -210,7 +210,7 @@ GEM
hashery (2.1.2)
hashie (3.6.0)
hiredis (0.6.3)
i18n (1.8.2)
i18n (1.8.3)
concurrent-ruby (~> 1.0)
indefinite_article (0.2.4)
activesupport
Expand Down Expand Up @@ -362,7 +362,7 @@ GEM
rb-fsevent (0.10.4)
rb-inotify (0.10.1)
ffi (~> 1.0)
rdf (3.1.1)
rdf (3.1.2)
hamster (~> 3.0)
link_header (~> 0.0, >= 0.0.8)
rdoc (6.2.1)
Expand Down Expand Up @@ -413,10 +413,11 @@ GEM
rspec-support (3.9.3)
rtesseract (3.0.5)
nokogiri
rubocop (0.84.0)
rubocop (0.85.0)
parallel (~> 1.10)
parser (>= 2.7.0.1)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.7)
rexml
rubocop-ast (>= 0.0.3)
ruby-progressbar (~> 1.7)
Expand All @@ -437,7 +438,7 @@ GEM
ruby-units (2.3.1)
rubyzip (2.3.0)
safe_yaml (1.0.5)
sassc (2.3.0)
sassc (2.4.0)
ffi (~> 1.9)
sassc-rails (2.1.2)
railties (>= 4.0.0)
Expand Down Expand Up @@ -532,7 +533,7 @@ GEM
semantic_range (>= 2.3.0)
websocket-driver (0.7.2)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.4)
websocket-extensions (0.1.5)
wikidata-client (0.0.12)
excon (~> 0.40)
faraday (~> 0.9)
Expand Down
6 changes: 5 additions & 1 deletion app/controllers/observation_matrix_columns_controller.rb
Expand Up @@ -2,6 +2,7 @@ class ObservationMatrixColumnsController < ApplicationController
include DataControllerConfiguration::ProjectDataControllerConfiguration

before_action :set_observation_matrix_column, only: [:show]
after_action -> { set_pagination_headers(:observation_matrix_columns) }, only: [:index], if: :json_request?

# GET /matrix_columns
# GET /matrix_columns.json
Expand All @@ -12,7 +13,10 @@ def index
render '/shared/data/all/index'
end
format.json {
@observation_matrix_columns = ObservationMatrixColumn.where(filter_params).where(project_id: sessions_current_project_id).order('observation_matrix_columns.position')
@observation_matrix_columns = ObservationMatrixColumn.where(filter_params)
.where(project_id: sessions_current_project_id)
.order('observation_matrix_columns.position')
.page(params[:page]).per(params[:per])
}
end
end
Expand Down
14 changes: 8 additions & 6 deletions app/javascript/vue/tasks/descriptor/app.vue
Expand Up @@ -77,7 +77,7 @@
<component
v-if="descriptor.type && showDescriptor"
:is="loadComponent + 'Component'"
@save="saveDescriptor"
@save="saveDescriptor($event, false)"
v-model="descriptor"
/>
</div>
Expand Down Expand Up @@ -201,14 +201,14 @@ export default {
short_name: undefined
}
},
saveDescriptor (descriptor) {
saveDescriptor (descriptor, redirect = true) {
this.saving = true
if (this.descriptor.id) {
UpdateDescriptor(descriptor).then(response => {
this.descriptor = response
this.saving = false
TW.workbench.alert.create('Descriptor was successfully updated.', 'notice')
if (this.matrix) {
if (this.matrix && redirect) {
window.open(`/tasks/observation_matrices/new_matrix/${this.matrixId}`, '_self')
}
}, rejected => {
Expand All @@ -221,7 +221,7 @@ export default {
this.setParameters()
TW.workbench.alert.create('Descriptor was successfully created.', 'notice')
if (this.matrix) {
this.addToMatrix(this.descriptor)
this.addToMatrix(this.descriptor, redirect)
}
}, rejected => {
this.saving = false
Expand All @@ -235,15 +235,17 @@ export default {
TW.workbench.alert.create('Descriptor was successfully deleted.', 'notice')
})
},
addToMatrix (descriptor) {
addToMatrix (descriptor, redirect) {
const data = {
descriptor_id: descriptor.id,
observation_matrix_id: this.matrix.id,
type: 'ObservationMatrixColumnItem::SingleDescriptor'
}
CreateObservationMatrixColumn(data).then(() => {
TW.workbench.alert.create('Descriptor was successfully added to the matrix.', 'notice')
window.open(`/tasks/observation_matrices/new_matrix/${this.matrixId}`, '_self')
if (redirect) {
window.open(`/tasks/observation_matrices/new_matrix/${this.matrixId}`, '_self')
}
})
},
loadMatrix (id) {
Expand Down
41 changes: 28 additions & 13 deletions app/javascript/vue/tasks/new_matrix/app.vue
@@ -1,36 +1,46 @@
<template>
<div id="vue_new_matrix_task">
<spinner-component
v-if="settings.loadingRows || settings.loadingColumns"
legend="Loading..."
:full-screen="true"/>
<div class="flex-separate middle">
<h1>{{ (matrix.id ? 'Edit' : 'New') }} matrix</h1>
<h1>{{ (matrix.id ? 'Edit' : 'New') }} observation matrix</h1>
<div class="horizontal-left-content">
<ul class="context-menu">
<li>
<a
<li>
<a
href="/tasks/observation_matrices/observation_matrix_hub/index">
Hub
</a>
</li>
<li>
<a
href="/tasks/observation_matrices/dashboard/index">
Dashboard
</a>
</li>
<li>
<a :href="`/tasks/observation_matrices/view/${matrix.id}`">
View
</a>
</li>

<li>
<a href="/otus/new">New Otu</a>
<a href="/otus/new">New OTU</a>
</li>
<li>
<a
v-if="matrix.id"
:href="`/tasks/descriptors/new_descriptor?observation_matrix_id=${matrix.id}`">New Descriptor
:href="`/tasks/descriptors/new_descriptor?observation_matrix_id=${matrix.id}`">New descriptor
</a>
<a
v-else
:href="`/tasks/descriptors/new_descriptor`">New Descriptor
:href="`/tasks/descriptors/new_descriptor`">New descriptor
</a>
</li>
<li>
<a href="/tasks/accessions/comprehensive/index">New Collection Object</a>
<a href="/tasks/accessions/comprehensive/index">New collection object</a>
</li>
<li>
<pin-component
Expand Down Expand Up @@ -80,6 +90,7 @@ import RowsFixed from './components/rows/fixed'
import columnsFixed from './components/columns/fixed'
import RadialAnnotator from 'components/radials/annotator/annotator'
import PinComponent from 'components/pin.vue'
import SpinnerComponent from 'components/spinner'
import rowsDynamic from './components/rows/dynamic'
import columnDynamic from './components/columns/dynamic'
Expand All @@ -96,23 +107,27 @@ export default {
columnsFixed,
columnDynamic,
RadialAnnotator,
PinComponent
PinComponent,
SpinnerComponent
},
computed: {
matrix() {
matrix () {
return this.$store.getters[GetterNames.GetMatrix]
},
isRow() {
isRow () {
return (this.$store.getters[GetterNames.GetMatrixView] == 'row' ? true : false)
},
isFixed() {
isFixed () {
return (this.$store.getters[GetterNames.GetMatrixMode] == 'fixed' ? true : false)
},
columnList() {
columnList () {
return this.$store.getters[GetterNames.GetMatrixColumns]
},
matrixId() {
matrixId () {
return this.$store.getters[GetterNames.GetMatrix].id
},
settings () {
return this.$store.getters[GetterNames.GetSettings]
}
},
data() {
Expand Down
Expand Up @@ -137,8 +137,8 @@ export default {
if (newVal) {
this.isLoading = true
GetObservationMatrices().then(response => {
response.splice(response.findIndex(item => { return this.matrixId === item.id }), 1)
this.observationMatrices = response
response.body.splice(response.body.findIndex(item => { return this.matrixId === item.id }), 1)
this.observationMatrices = response.body
this.isLoading = false
})
}
Expand All @@ -156,8 +156,8 @@ export default {
methods: {
loadDescriptors (matrixId) {
this.isLoading = true
GetMatrixObservationColumns(matrixId).then(response => {
this.descriptors = response
GetMatrixObservationColumns(matrixId, { per: 500 }).then(response => {
this.descriptors = response.body
this.isLoading = false
})
},
Expand Down
Expand Up @@ -58,8 +58,8 @@ export default {
},
mounted() {
GetSmartSelector('keywords').then(response => {
this.smartOptions = this.smartOptions.filter(value => Object.keys(response).includes(value))
this.selectorLists = response
this.smartOptions = this.smartOptions.filter(value => Object.keys(response.body).includes(value))
this.selectorLists = response.body
})
},
methods: {
Expand Down
Expand Up @@ -58,8 +58,8 @@
},
mounted() {
GetMatrixColumnMetadata().then(response => {
this.smartOptions = Object.keys(response)
this.lists = response
this.smartOptions = Object.keys(response.body)
this.lists = response.body
})
},
methods: {
Expand Down
Expand Up @@ -53,9 +53,7 @@
batch_type: 'tags',
klass: 'Descriptor'
}
console.log(object);
CreateColumnBatchLoad(object).then((response) => {
console.log(response);
this.$store.dispatch(ActionNames.GetMatrixObservationColumns, this.matrixId)
})
}
Expand Down
29 changes: 8 additions & 21 deletions app/javascript/vue/tasks/new_matrix/components/columns/search.vue
@@ -1,24 +1,17 @@
<template>
<div>
<p>Select</p>
<div class="flex-wrap">
<div class="field">
<autocomplete
min="2"
:display="displayAutocomplete"
:placeholder="`Select a descriptor`"
:clear-after="true"
placeholder="Select a descriptor"
label="label"
@getItem="setResult"
@getItem="createColumnItem($event.id)"
url="/descriptors/autocomplete"
param="term"/>
</div>
</div>
<button
:disabled="!objectId"
class="normal-input button button-submit"
type="button"
@click="createColumnItem">Create
</button>
</div>
</template>
<script>
Expand All @@ -37,26 +30,20 @@ export default {
return this.$store.getters[GetterNames.GetMatrix]
}
},
data() {
data () {
return {
displayAutocomplete: undefined,
objectId: undefined,
objectId: undefined
}
},
methods: {
createColumnItem() {
let data = {
createColumnItem (id) {
const data = {
observation_matrix_id: this.matrix.id,
descriptor_id: this.objectId,
descriptor_id: id,
type: 'ObservationMatrixColumnItem::SingleDescriptor'
}
this.displayAutocomplete = undefined
this.objectId = undefined
this.$store.dispatch(ActionNames.CreateColumnItem, data)
},
setResult(descriptor) {
this.objectId = descriptor.id
this.displayAutocomplete = descriptor.label
}
}
}
Expand Down
Expand Up @@ -83,18 +83,18 @@ export default {
this.$store.commit(MutationNames.SetMatrixMode, (value ? 'fixed' : 'dynamic'))
}
},
validateData() {
validateData () {
return this.$store.getters[GetterNames.GetMatrix].name &&
!this.$store.getters[GetterNames.GetMatrix].id
}
},
methods: {
create() {
create () {
CreateMatrix(this.matrix).then(response => {
this.matrix = response
});
this.matrix = response.body
})
},
updateMatrix() {
updateMatrix () {
this.$store.dispatch(ActionNames.UpdateMatrix)
}
}
Expand Down
Expand Up @@ -45,7 +45,7 @@
klass: classType
}
CreateRowBatchLoad(object).then((response) => {
this.$store.dispatch(ActionNames.GetMatrixObservationRows, this.matrixId)
this.$store.dispatch(ActionNames.GetMatrixObservationRows, { per: 500 })
})
}
}
Expand Down

0 comments on commit d4a144e

Please sign in to comment.