Skip to content

Commit

Permalink
Add browse source scaffold #244
Browse files Browse the repository at this point in the history
  • Loading branch information
jlpereira committed Jan 22, 2025
1 parent 3bd09fb commit 7049613
Show file tree
Hide file tree
Showing 10 changed files with 105 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/controllers/tasks/sounds/browse_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class Tasks::Sounds::BrowseController < ApplicationController
include TaskControllerConfiguration

end
1 change: 1 addition & 0 deletions app/javascript/packs/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,4 @@ import '../vue/tasks/unify/objects/main.js'
import '../vue/tasks/images/new_filename_depicting_image/main.js'
import '../vue/tasks/biological_associations/new/main.js'
import '../vue/tasks/otus/duplicates/main.js'
import '../vue/tasks/sounds/browse/main.js'
12 changes: 12 additions & 0 deletions app/javascript/vue/routes/endpoints/Sound.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import baseCRUD from './base'

const permitParams = {
sound: {
name: Number,
sound_file: String
}
}

export const Sound = {
...baseCRUD('sounds', permitParams)
}
1 change: 1 addition & 0 deletions app/javascript/vue/routes/endpoints/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export { ProtocolRelationship } from './ProtocolRelationship'
export { Repository } from './Repository'
export { Serial } from './Serial'
export { SoftValidation } from './SoftValidation'
export { Sound } from './Sound'
export { Source } from './Source'
export { SqedDepiction } from './SqedDepiction'
export { Tag } from './Tag'
Expand Down
31 changes: 31 additions & 0 deletions app/javascript/vue/tasks/sounds/browse/App.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<template>
<h1>Browse sound</h1>
</template>

<script setup>
import { ref, onBeforeMount } from 'vue'
import { Sound } from '@/routes/endpoints'
import { getPagination, URLParamsToJSON } from '@/helpers'
import VPagination from '@/components/pagination.vue'
const per = ref(50)
const list = ref([])
const page = ref(1)
const currentSound = ref(null)
const pagination = ref(null)
Sound.where({ per: 50 }).then((response) => {
pagination.value = response
})
onBeforeMount(() => {
const params = URLParamsToJSON(window.location.href)
const soundId = params.sound_id
if (soundId) {
Sound.find(soundId).then(({ body }) => {
currentSound.value = body
})
}
})
</script>
26 changes: 26 additions & 0 deletions app/javascript/vue/tasks/sounds/browse/components/SoundList.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<template>
<table>
<thead>
<tr>
<th></th>
</tr>
</thead>
<tbody>
<tr
v-for="sound in sounds"
:key="sound.id"
>
<td>{{ sound.name }}</td>
</tr>
</tbody>
</table>
</template>

<script setup>
const props = defineProps({
sounds: {
type: Array,
default: () => []
}
})
</script>
16 changes: 16 additions & 0 deletions app/javascript/vue/tasks/sounds/browse/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { createApp } from 'vue'
import App from './App.vue'

function initApp(element) {
const app = createApp(App)

app.mount(element)
}

document.addEventListener('turbolinks:load', () => {
const el = document.querySelector('#vue-browse-sound')

if (el) {
initApp(el)
}
})
1 change: 1 addition & 0 deletions app/views/tasks/sounds/browse/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<div id="vue-browse-sound"></div>
7 changes: 7 additions & 0 deletions config/interface/hub/user_tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1006,3 +1006,10 @@ summarize_projects_controlled_vocabulary_terms_task:
categories:
status: prototype
description: 'Visualize controlled vocabulary terms across the projects you are a member of.'
browse_sounds_task:
hub: true
name: 'Browse sounds'
related:
categories:
status: prototype
description: 'TODO: Task description'
6 changes: 6 additions & 0 deletions config/routes/tasks.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
scope :tasks do
scope :sounds do
scope :browse, controller: 'tasks/sounds/browse' do
get '/', action: :index, as: 'browse_sounds_task'
end
end

scope :controlled_vocabulary_terms do
scope :projects_summary, controller: 'tasks/controlled_vocabulary_terms/projects_summary' do
get '/', action: :index, as: 'summarize_projects_controlled_vocabulary_terms_task'
Expand Down

0 comments on commit 7049613

Please sign in to comment.