### Major Features - Add comprehensive ORCID validation with checksum verification - Implement unsaved changes detection and auto-save functionality - Enhanced form component reactivity and state management ### ORCID Implementation - Create custom VineJS ORCID validation rule with MOD-11-2 algorithm - Add ORCID fields to Person model and TablePersons component - Update dataset validators to include ORCID validation - Add descriptive placeholder text for ORCID input fields ### UI/UX Improvements - Add UnsavedChangesWarning component with detailed change tracking - Improve FormCheckRadio and FormCheckRadioGroup reactivity - Enhanced BaseButton with proper disabled state handling - Better error handling and user feedback in file validation ### Data Management - Implement sophisticated change detection for all dataset fields - Add proper handling of array ordering for authors/contributors - Improve license selection with better state management - Enhanced subject/keyword processing with duplicate detection ### Technical Improvements - Optimize search indexing with conditional updates based on modification dates - Update person model column mapping for ORCID - Improve validation error messages and user guidance - Better handling of file uploads and deletion tracking ### Dependencies - Update various npm packages (AWS SDK, Babel, Vite, etc.) - Add baseline-browser-mapping for better browser compatibility ### Bug Fixes - Fix form reactivity issues with checkbox/radio groups - Improve error handling in file validation rules - Better handling of edge cases in change detection
80 lines
3.2 KiB
TypeScript
80 lines
3.2 KiB
TypeScript
import type { HttpContext } from '@adonisjs/core/http';
|
|
// import Person from 'App/Models/Person';
|
|
import Dataset from '#models/dataset';
|
|
import { StatusCodes } from 'http-status-codes';
|
|
|
|
// node ace make:controller Author
|
|
export default class DatasetController {
|
|
public async index({}: HttpContext) {
|
|
// Select datasets with server_state 'published' or 'deleted' and sort by the last published date
|
|
const datasets = await Dataset.query()
|
|
.where(function (query) {
|
|
query.where('server_state', 'published').orWhere('server_state', 'deleted');
|
|
})
|
|
.preload('titles')
|
|
.preload('identifier')
|
|
.orderBy('server_date_published', 'desc');
|
|
|
|
return datasets;
|
|
}
|
|
|
|
public async findAll({ response }: HttpContext) {
|
|
try {
|
|
const datasets = await Dataset.query()
|
|
.where('server_state', 'published')
|
|
.orWhere('server_state', 'deleted')
|
|
.preload('descriptions') // Preload any relationships you need
|
|
.orderBy('server_date_published');
|
|
return response.status(StatusCodes.OK).json(datasets);
|
|
} catch (error) {
|
|
return response.status(500).json({
|
|
message: error.message || 'Some error occurred while retrieving datasets.',
|
|
});
|
|
}
|
|
}
|
|
|
|
public async findOne({ params }: HttpContext) {
|
|
const datasets = await Dataset.query()
|
|
.where('publish_id', params.publish_id)
|
|
.preload('titles')
|
|
.preload('descriptions')
|
|
.preload('user', (builder) => {
|
|
builder.select(['id', 'firstName', 'lastName', 'avatar', 'login']);
|
|
})
|
|
.preload('authors', (builder) => {
|
|
builder
|
|
.select(['id', 'academic_title', 'first_name', 'last_name', 'identifier_orcid', 'status', 'name_type'])
|
|
.withCount('datasets', (query) => {
|
|
query.as('datasets_count');
|
|
})
|
|
.pivotColumns(['role', 'sort_order'])
|
|
.orderBy('pivot_sort_order', 'asc');
|
|
})
|
|
.preload('contributors', (builder) => {
|
|
builder
|
|
.select(['id', 'academic_title', 'first_name', 'last_name', 'identifier_orcid', 'status', 'name_type'])
|
|
.withCount('datasets', (query) => {
|
|
query.as('datasets_count');
|
|
})
|
|
.pivotColumns(['role', 'sort_order', 'contributor_type'])
|
|
.orderBy('pivot_sort_order', 'asc');
|
|
})
|
|
.preload('subjects')
|
|
.preload('coverage')
|
|
.preload('licenses')
|
|
.preload('references')
|
|
.preload('project')
|
|
.preload('referenced_by', (builder) => {
|
|
builder.preload('dataset', (builder) => {
|
|
builder.preload('identifier');
|
|
});
|
|
})
|
|
.preload('files', (builder) => {
|
|
builder.preload('hashvalues');
|
|
})
|
|
.preload('identifier')
|
|
.firstOrFail();
|
|
|
|
return datasets;
|
|
}
|
|
}
|