Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add OGL question to DFO pub MRF #824

Merged
merged 2 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions app/Http/Controllers/ManuscriptRecordController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use Gate;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
use Illuminate\Support\Facades\Auth;
use Illuminate\Validation\Rule;
use Illuminate\Validation\Rules\Enum;

Expand All @@ -40,7 +41,7 @@ public function store(Request $request): JsonResource

$manuscriptRecord = new ManuscriptRecord($validated);
$manuscriptRecord->status = ManuscriptRecordStatus::DRAFT;
$manuscriptRecord->user_id = auth()->id();
$manuscriptRecord->user_id = Auth::id();
$manuscriptRecord->save();
$manuscriptRecord->refresh();

Expand Down Expand Up @@ -72,8 +73,10 @@ public function update(Request $request, ManuscriptRecord $manuscriptRecord): Js
'abstract' => 'nullable|string',
'pls' => 'nullable|string',
'relevant_to' => 'nullable|string',
'additional_information' => 'nullable|string',
'public_interest_information' => 'nullable|string',
'potential_public_interest' => 'boolean',
'do_not_apply_ogl' => 'boolean',
'no_ogl_explanation' => 'nullable|string',
]);

$manuscriptRecord->update($validated);
Expand Down
4 changes: 3 additions & 1 deletion app/Http/Resources/ManuscriptRecordResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ public function toArray($request)
'abstract' => $this->abstract ?? '',
'pls' => $this->pls ?? '',
'relevant_to' => $this->relevant_to ?? '',
'additional_information' => $this->additional_information ?? '',
'potential_public_interest' => $this->potential_public_interest,
'public_interest_information' => $this->public_interest_information ?? '',
'do_not_apply_ogl' => $this->do_not_apply_ogl,
'no_ogl_explanation' => $this->no_ogl_explanation ?? '',

// dates and times
'created_at' => $this->created_at,
Expand Down
5 changes: 4 additions & 1 deletion app/Models/ManuscriptRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,16 @@ class ManuscriptRecord extends Model implements Fundable, HasMedia
'type' => ManuscriptRecordType::class,
'status' => ManuscriptRecordStatus::class,
'potential_public_interest' => 'boolean',
'do_not_apply_ogl' => 'boolean',
];

// default values for optional fields
protected $attributes = [
'abstract' => '',
'pls' => '',
'relevant_to' => '',
'additional_information' => '',
'public_interest_information' => '',
'no_ogl_explanation' => '',
];

// logging options
Expand Down Expand Up @@ -233,6 +235,7 @@ public function validateIsFilled(bool $noExceptions = false): bool
'region_id' => 'required|exists:regions,id',
'functional_area_id' => 'required|exists:functional_areas,id',
'relevant_to' => 'required',
'no_ogl_explanation' => 'required_if:do_not_apply_ogl,true',
]);

$validator->after(function ($validator) {
Expand Down
2 changes: 1 addition & 1 deletion database/factories/ManuscriptRecordFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function filled()
'pls' => $this->faker->paragraph(),
'relevant_to' => $this->faker->paragraph(),
'potential_public_interest' => $this->faker->boolean(),
'additional_information' => $this->faker->paragraph(),
'public_interest_information' => $this->faker->paragraph(),
'functional_area_id' => FunctionalArea::factory()->create()->id,
])->afterCreating(function ($manuscript) {
$manuscript->manuscriptAuthors()->save(ManuscriptAuthor::factory()->make(['is_corresponding_author' => true])); // create a corresponding author
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('manuscript_records', function (Blueprint $table) {
$table->boolean('do_not_apply_ogl')->default(false);
$table->text('no_ogl_explanation')->nullable();
$table->renameColumn('additional_information', 'public_interest_information');
});
}
};
5 changes: 4 additions & 1 deletion resources/src/components/QuestionEditor.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup lang="ts">
import { QEditor } from 'quasar'
import DOMPurify from 'dompurify'
import { QEditor } from 'quasar'
import RequiredSpan from './RequiredSpan.vue'

const props = withDefaults(
Expand All @@ -10,11 +10,13 @@ const props = withDefaults(
disable?: boolean
readonly?: boolean
required?: boolean
hideEditor?: boolean
}>(),
{
disable: false,
readonly: false,
required: false,
hideEditor: false,
},
)

Expand Down Expand Up @@ -66,6 +68,7 @@ function onPaste(e: ClipboardEvent) {
</div>
</div>
<QEditor
v-if="!hideEditor"
ref="editor"
v-model="value"
:disable="disable"
Expand Down
7 changes: 6 additions & 1 deletion resources/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,12 @@
"upload-manuscript": "Upload manuscript",
"upload-text": "Upload the most recent copy of your manuscript as a PDF. This file can be updated as required by the applicant, even after submitting the manuscript.",
"working-title-text": "Enter to the manuscript's working title. You will be able to modify the title when you update this manuscript status to published.",
"functional-area-text": "In order to improve reporting on research outputs, please select the relevant functional area for this manuscript."
"functional-area-text": "In order to improve reporting on research outputs, please select the relevant functional area for this manuscript.",
"no-ogl-explanation": "Report Licensing",
"no-ogl-explanation-text-field-text": "DFO is committed to the \"Open by Design and by Default\" principle of Open Science, which means that all DFO publications will be published under the latest version of the \"{url}\" Are there any specific reasons or concerns that would prevent your report from being licensed under this Open Government Licence?",
"ogl-link": "Open Government Licence - Canada",
"do_not_apply_ogl": "We have reasons not to apply an open license for this report.",
"ogl-provide-explanation": "Since you answered \"yes,\" please provide an explanation of why an open license cannot be applied to your report."
},
"my-manuscript-records": {
"actions-still-required": "Actions still required",
Expand Down
7 changes: 6 additions & 1 deletion resources/src/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,12 @@
"upload-manuscript": "Télécharger le manuscrit",
"upload-text": "Téléchargez la copie la plus récente de votre manuscrit au format PDF. \nCe fichier peut être mis à jour selon les besoins du demandeur, même après la soumission du manuscrit.",
"working-title-text": "Entrez le titre provisoir du manuscrit. \nVous pourrez modifier le titre lorsque vous mettrez à jour le statut de ce manuscrit à publié.",
"functional-area-text": "Afin d'améliorer les rapports sur les résultats de la recherche, veuillez sélectionner le domaine fonctionnel pertinent pour ce manuscrit."
"functional-area-text": "Afin d'améliorer les rapports sur les résultats de la recherche, veuillez sélectionner le domaine fonctionnel pertinent pour ce manuscrit.",
"no-ogl-explanation-text-field-text": "Le MPO s'engage à suivre le principe « ouvert par conception et par défaut » de la science ouverte. Par conséquent, toutes les publications du MPO seront publiées sous la dernière version de la « {url} ». Avez-vous des raisons de croire que votre rapport ne devrait pas être licencié sous cette licence du gouvernement ouvert?",
"ogl-link": "Licence du gouvernement ouvert – Canada",
"do_not_apply_ogl": "Nous avons des raisons de ne pas appliquer une licence ouverte pour ce rapport.",
"no-ogl-explanation": "Licence de rapport",
"ogl-provide-explanation": "Puisque vous avez répondu « oui », veuillez expliquer pourquoi une licence ouverte ne peut pas être appliquée à votre rapport."
},
"my-manuscript-records": {
"actions-still-required": "Actions encore nécessaires",
Expand Down
44 changes: 23 additions & 21 deletions resources/src/models/ManuscriptRecord/ManuscriptRecord.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import type { ManuscriptAuthorResource } from '@/models/ManuscriptAuthor/ManuscriptAuthor'
import type { FunctionalArea } from '../FunctionalArea/FunctionalArea'
import type { PublicationResource } from '../Publication/Publication'
import type { Region } from '../Region/Region'
import type {
Expand All @@ -7,10 +9,8 @@ import type {
ResourceList,
} from '../Resource'
import type { UserResource } from '../User/User'
import type { FunctionalArea } from '../FunctionalArea/FunctionalArea'
import type { ManuscriptAuthorResource } from '@/models/ManuscriptAuthor/ManuscriptAuthor'
import { SpatieQuery } from '@/api/SpatieQuery'
import { http } from '@/api/http'
import { SpatieQuery } from '@/api/SpatieQuery'

export type ManuscriptRecordType = 'primary' | 'secondary'

Expand Down Expand Up @@ -46,8 +46,10 @@ export interface ManuscriptRecord extends BaseManuscriptRecord {
abstract: string
pls: string
relevant_to: string
additional_information: string
potential_public_interest: boolean
public_interest_information: string
do_not_apply_ogl: boolean
no_ogl_explanation: string
readonly sent_for_review_at: string | null
readonly reviewed_at: string | null
submitted_to_journal_on: string | null
Expand Down Expand Up @@ -90,7 +92,7 @@ export class ManuscriptRecordService {
*/
public static async find(id: number) {
const response = await http.get<ManuscriptRecordResource>(
`${this.baseURL}/${id}`,
`${this.baseURL}/${id}`,
)
return response.data
}
Expand Down Expand Up @@ -137,21 +139,21 @@ export class ManuscriptRecordService {
const formData = new FormData()
formData.append('pdf', file)
const response = await http.post<FormData, MediaResource>(
`${this.baseURL}/${id}/files`,
formData,
{
headers: {
'Content-Type': 'multipart/form-data',
},
},
`${this.baseURL}/${id}/files`,
formData,
{
headers: {
'Content-Type': 'multipart/form-data',
},
},
)
return response.data
}

/** List all PDF files associated with this manuscript */
public static async listPDFs(id: number) {
const response = await http.get<MediaResourceList>(
`${this.baseURL}/${id}/files`,
`${this.baseURL}/${id}/files`,
)
return response.data
}
Expand All @@ -162,7 +164,7 @@ export class ManuscriptRecordService {
*/
public static async deletePDF(id: number, uuid: string) {
const response = await http.delete(
`${this.baseURL}/${id}/files/${uuid}`,
`${this.baseURL}/${id}/files/${uuid}`,
)
return response.status === 204
}
Expand All @@ -173,8 +175,8 @@ export class ManuscriptRecordService {
reviewer_user_id: userId,
}
const response = await http.put<any, ManuscriptRecordResource>(
`${this.baseURL}/${id}/submit-for-review`,
data,
`${this.baseURL}/${id}/submit-for-review`,
data,
)
return response.data
}
Expand All @@ -185,8 +187,8 @@ export class ManuscriptRecordService {
submitted_to_journal_on: date,
}
const response = await http.put<any, ManuscriptRecordResource>(
`${this.baseURL}/${id}/submitted`,
data,
`${this.baseURL}/${id}/submitted`,
data,
)
return response.data
}
Expand All @@ -204,16 +206,16 @@ export class ManuscriptRecordService {
journal_id: journalId,
}
const response = await http.put<any, ManuscriptRecordResource>(
`${this.baseURL}/${id}/accepted`,
data,
`${this.baseURL}/${id}/accepted`,
data,
)
return response.data
}

// Withdraw the manuscript
public static async withdraw(id: number) {
const response = await http.put<any, ManuscriptRecordResource>(
`${this.baseURL}/${id}/withdraw`,
`${this.baseURL}/${id}/withdraw`,
)
return response.data
}
Expand Down
Loading
Loading