hotfix (dashboard): display allow email contact in card box client
- Added the `allowEmailContact` property to the `CardBoxClient` component to display the email contact status. - Added the `allowEmailContact` computed property to the `Person` model to determine if email contact is allowed based on the related datasets. - Preloaded the datasets relation in the `AuthorsController` to access the pivot attributes. - Updated the `Dashboard.vue` to pass the `allowEmailContact` prop to the `CardBoxClient` component. - Updated the `array_contains_types` validation rule to correct the error message for descriptions. - Updated the `FormCheckRadio.vue` to correctly handle the radio button and checkbox components.
This commit is contained in:
parent
09f65359f9
commit
f89b119b18
6 changed files with 31 additions and 49 deletions
|
@ -9,6 +9,7 @@ export default class AuthorsController {
|
|||
// where exists (select * from gba.documents inner join gba.link_documents_persons on "documents"."id" = "link_documents_persons"."document_id"
|
||||
// where ("link_documents_persons"."role" = 'author') and ("persons"."id" = "link_documents_persons"."person_id"));
|
||||
const authors = await Person.query()
|
||||
.preload('datasets')
|
||||
.where('name_type', 'Personal')
|
||||
.whereHas('datasets', (dQuery) => {
|
||||
dQuery.wherePivot('role', 'author');
|
||||
|
|
|
@ -3,7 +3,7 @@ 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";
|
||||
import type { ManyToMany } from '@adonisjs/lucid/types/relations';
|
||||
|
||||
export default class Person extends BaseModel {
|
||||
public static namingStrategy = new SnakeCaseNamingStrategy();
|
||||
|
@ -64,9 +64,8 @@ export default class Person extends BaseModel {
|
|||
// return '2023-03-21 08:45:00';
|
||||
// }
|
||||
|
||||
|
||||
@computed({
|
||||
serializeAs: 'dataset_count',
|
||||
serializeAs: 'dataset_count',
|
||||
})
|
||||
public get datasetCount() {
|
||||
const stock = this.$extras.datasets_count; //my pivot column name was "stock"
|
||||
|
@ -79,6 +78,16 @@ export default class Person extends BaseModel {
|
|||
return contributor_type;
|
||||
}
|
||||
|
||||
@computed({ serializeAs: 'allow_email_contact' })
|
||||
public get allowEmailContact() {
|
||||
// If the datasets relation is missing or empty, return false instead of null.
|
||||
if (!this.datasets || this.datasets.length === 0) {
|
||||
return false;
|
||||
}
|
||||
// Otherwise return the pivot attribute from the first related dataset.
|
||||
return this.datasets[0].$extras?.pivot_allow_email_contact;
|
||||
}
|
||||
|
||||
@manyToMany(() => Dataset, {
|
||||
pivotForeignKey: 'person_id',
|
||||
pivotRelatedForeignKey: 'document_id',
|
||||
|
|
Loading…
Add table
editor.link_modal.header
Reference in a new issue