All checks were successful
CI / container-job (push) Successful in 49s
- Modified Api/Authors.Controller.ts to use only personal types and sort by dataset_count. - Completely rewritten AvatarController.ts. - Added new Api/CollectionsController.ts for querying collections and collection_roles. - Modified Api/DatasetController.ts to preload titles, identifier and order by server_date_published. - Modified FileController.ts to serve files from /storage/app/data/ instead of /storage/app/public. - Added new Api/UserController for requesting submitters (getSubmitters). - Improved OaiController.ts with performant DB queries for better ResumptionToken handling. - Modified Submitter/DatasetController.ts by adding a categorize method for library classification. - Rewritten ResumptionToken.ts. - Improved TokenWorkerService.ts to utilize browser fingerprint. - Edited dataset.ts by adding the doiIdentifier property. - Enhanced person.ts to improve the fullName property. - Completely rewritten AsideMenuItem.vue component. - Updated CarBoxClient.vue to use TypeScript. - Added new CardBoxDataset.vue for displaying recent datasets on the dashboard. - Completely rewritten TableSampleClients.vue for the dashboard. - Completely rewritten UserAvatar.vue. - Made small layout changes in Dashboard.vue. - Added new Category.vue for browsing scientific collections. - Adapted the pinia store in main.ts. - Added additional routes in start/routes.ts and start/api/routes.ts. - Improved referenceValidation.ts for better ISBN existence checking. - NPM dependency updates.
89 lines
2.5 KiB
TypeScript
89 lines
2.5 KiB
TypeScript
import { column, SnakeCaseNamingStrategy, computed, manyToMany } from '@adonisjs/lucid/orm';
|
|
import { DateTime } from 'luxon';
|
|
import dayjs from 'dayjs';
|
|
import Dataset from './dataset.js';
|
|
import BaseModel from './base_model.js';
|
|
import type { ManyToMany } from "@adonisjs/lucid/types/relations";
|
|
|
|
export default class Person extends BaseModel {
|
|
public static namingStrategy = new SnakeCaseNamingStrategy();
|
|
public static primaryKey = 'id';
|
|
public static table = 'persons';
|
|
public static selfAssignPrimaryKey = false;
|
|
// only the academic_title, email, first_name, identifier_orcid, last_name and name_type attributes are allowed to be mass assigned.
|
|
public static fillable: string[] = ['academic_title', 'email', 'first_name', 'identifier_orcid', 'last_name', 'name_type'];
|
|
|
|
@column({
|
|
isPrimary: true,
|
|
})
|
|
public id: number;
|
|
|
|
@column({ columnName: 'academic_title' })
|
|
public academicTitle: string;
|
|
|
|
@column()
|
|
public email: string;
|
|
|
|
@column({})
|
|
public firstName: string;
|
|
|
|
@column({})
|
|
public lastName: string;
|
|
|
|
@column({})
|
|
public identifierOrcid: string;
|
|
|
|
@column({})
|
|
public status: boolean;
|
|
|
|
@column({})
|
|
public nameType: string;
|
|
|
|
@column.dateTime({
|
|
serialize: (value: Date | null) => {
|
|
return value ? dayjs(value).format('MMMM D YYYY HH:mm a') : value;
|
|
},
|
|
autoCreate: true,
|
|
})
|
|
public createdAt: DateTime;
|
|
|
|
@computed({
|
|
serializeAs: 'name',
|
|
})
|
|
public get fullName() {
|
|
return [this.firstName, this.lastName].filter(Boolean).join(' ');
|
|
}
|
|
|
|
// @computed()
|
|
// public get progress(): number {
|
|
// return 50;
|
|
// }
|
|
|
|
// @computed()
|
|
// public get created_at() {
|
|
// return '2023-03-21 08:45:00';
|
|
// }
|
|
|
|
|
|
@computed({
|
|
serializeAs: 'dataset_count',
|
|
})
|
|
public get datasetCount() {
|
|
const stock = this.$extras.datasets_count; //my pivot column name was "stock"
|
|
return Number(stock);
|
|
}
|
|
|
|
@computed()
|
|
public get pivot_contributor_type() {
|
|
const contributor_type = this.$extras.pivot_contributor_type; //my pivot column name was "stock"
|
|
return contributor_type;
|
|
}
|
|
|
|
@manyToMany(() => Dataset, {
|
|
pivotForeignKey: 'person_id',
|
|
pivotRelatedForeignKey: 'document_id',
|
|
pivotTable: 'link_documents_persons',
|
|
pivotColumns: ['role', 'sort_order', 'allow_email_contact'],
|
|
})
|
|
public datasets: ManyToMany<typeof Dataset>;
|
|
}
|