Skip to content
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
30 changes: 28 additions & 2 deletions app/Livewire/Reporting/StudySelection.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
class StudySelection extends Component
{
public $currentProject;
public $selected_criterias = [];
public $criterias = [];


public function mount()
{
Expand All @@ -20,8 +23,31 @@ public function mount()

// Busca o projeto e lança uma exceção se não for encontrado
$this->currentProject = ProjectModel::findOrFail($projectId);

// Carrega os critérios do banco de dados
$this->criterias = EvaluationCriteria::all()->keyBy('id')->toArray();
}

public function changePreSelected($criteriaId, $type)
{
if (!isset($this->criterias[$criteriaId])) {
return;
}

// Aqui você pode definir alguma lógica específica para o tipo do critério
if ($type === 'Inclusion') {
// Exemplo: faz algo se for um critério de inclusão
} else {
// Exemplo: faz algo diferente para outro tipo
}

// Apenas como exemplo, armazenamos o critério como "selecionado"
if (!in_array($criteriaId, $this->selected_criterias)) {
$this->selected_criterias[] = $criteriaId;
}
}


public function getPapersPerStatusSelection()
{
// Consulta para pegar os papers vinculados ao projeto corrente, agrupados por status de seleção
Expand All @@ -35,7 +61,7 @@ public function getPapersPerStatusSelection()
->get();

// Mapear os resultados para o formato necessário
return $papers->map(function($paper) {
return $papers->map(function ($paper) {
return [
'name' => $paper->status_description,
'y' => (int) $paper->total // Total de papers por status
Expand Down Expand Up @@ -119,6 +145,6 @@ public function render()
// Obtenha os dados de critérios por usuário
$criteriaData = $this->getCriteriaPerUser();

return view('livewire.reporting.study-selection', compact('papersPerStatus','criteriaData','papersByUserAndStatus'));
return view('livewire.reporting.study-selection', compact('papersPerStatus', 'criteriaData', 'papersByUserAndStatus'));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
<!-- O restante do conteúdo do paperModal -->
<div class="row">
<div class="col-4">
@livewire('conducting.study-selection.paper-authors', ['paperId' => $paper['id_paper'],
'projectId' => $this->projectId], key($paper['id_paper']))
@livewire('conducting.study-selection.paper-authors', ['paperId' => $paper['id_paper'], 'projectId' => $this->projectId], key($paper['id_paper']))
</div>
<div class="col-2">
<b>{{ __('project/conducting.study-selection.modal.year' )}}:</b>
Expand All @@ -36,7 +35,9 @@
<i class="fa-solid fa-link"></i>
URL
</a>
<a class="btn py-1 px-3 btn-outline-primary" data-toggle="tooltip"
<a class="btn py-1 px-3 btn-outline-primary"
data-toggle="tooltip"

data-original-title="Buscar no Google Scholar"
href="https://scholar.google.com/scholar?q={{ urlencode($paper['title']) }}"
target="_blank">
Expand All @@ -57,16 +58,11 @@
<table class="table table-striped table-bordered mb-3">
<thead>
<tr>
<th class="w-5 align-middle text-center">
{{ __('project/conducting.study-selection.modal.table.select' )}}
</th>
<th class="w-5 align-middle text-center">{{ __('project/conducting.study-selection.modal.table.select' )}}</th>
<th class="w-5 align-middle text-center">ID</th>
<th class="w-70 align-middle text-wrap">
{{ __('project/conducting.study-selection.modal.table.description' )}}
</th>
<th class="w-5 align-middle text-center">
{{ __('project/conducting.study-selection.modal.table.type' )}}
</th>
<th class="w-70 align-middle text-wrap">{{ __('project/conducting.study-selection.modal.table.description' )}}</th>
<th class="w-5 align-middle text-center">{{ __('project/conducting.study-selection.modal.table.type' )}}</th>

</tr>
</thead>
<tbody>
Expand All @@ -75,10 +71,11 @@
<td class="w-5 align-middle text-center">
<input type="checkbox" id="criteria-{{ $criteria['id_criteria'] }}"
wire:key="criteria-{{ $criteria['id_criteria'] }}"
wire:model="selected_criterias"
wire:change="changePreSelected({{ $criteria['id_criteria'] }}, '{{ $criteria['type'] }}')"
value="{{ $criteria['id_criteria'] }}" @if(in_array($criteria['id_criteria'],
$selected_criterias)) checked @endif @if(!$canEdit) disabled @endif>
wire:model.defer="selected_criterias"
value="{{ $criteria['id_criteria'] }}"
@if(in_array($criteria['id_criteria'], $selected_criterias)) checked @endif
@if(!$canEdit) disabled @endif
>
</td>
<td class="w-5 align-middle text-center">{{ $criteria['id'] }}</td>
<td class="w-70 align-middle text-wrap">{{ $criteria['description'] }}</td>
Expand All @@ -89,6 +86,7 @@
</tbody>
</table>
<hr />

<div class="d-flex flex-column mt-3">
<label>{{ __('project/conducting.study-selection.modal.paper-conflict-note' )}}</label>
<textarea id="note" class="form-control" rows="2" wire:model="note" wire:blur="saveNote"
Expand All @@ -97,6 +95,8 @@
</textarea>
</div>



<hr />
<!-- Verificação do status -->
@if($paper['status_selection'] != 1 && $paper['status_selection'] != 2)
Expand Down Expand Up @@ -124,12 +124,17 @@
</div>
@endif
@endif
<div class="text-center mt-3">
<button class="btn btn-primary" wire:click="applySelectedCriterias">
Aplicar Seleção
</button>
</div>

</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary"
data-bs-dismiss="modal">{{ __('project/conducting.study-selection.modal.close' )}}</button>
</div>

</div>
</div>
</div>
Expand All @@ -155,10 +160,22 @@

@script
<script>
$(document).ready(function() {
// Show the paper modal
$wire.on('show-paper', () => {
$('#paperModal').modal('show');
$(document).ready(function() {
// Show the paper modal
$wire.on('show-paper', () => {
$('#paperModal').modal('show');
});

// Show the success modal on success event
Livewire.on('show-success', () => {
$('#paperModal').modal('hide'); // Hide the paper modal
$('#successModal').modal('show'); // Show the success modal
});

// Handle the closing of success modal to reopen the paper modal
$('#successModal').on('hidden.bs.modal', function() {
$('#paperModal').modal('show'); // Reopen the paper modal after success modal is closed
});
});

// Show toast on success event
Expand All @@ -181,13 +198,14 @@
Livewire.emit('show-sucess-quality');
});

$wire.on('paper-modal', ([{
message,
type
}]) => {
toasty({
$wire.on('paper-modal', ([{
message,
type
}]) => {
toasty({
message,
type
});
});
});
</script>
Expand Down
Loading