mirror of
https://github.com/Einundzwanzig-Podcast/einundzwanzig-portal.git
synced 2025-12-11 06:46:47 +00:00
voting added
This commit is contained in:
@@ -8,6 +8,7 @@ use App\Models\User;
|
|||||||
use App\Models\Vote;
|
use App\Models\Vote;
|
||||||
use Illuminate\Validation\Rule;
|
use Illuminate\Validation\Rule;
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
|
use RalphJSmit\Laravel\SEO\Support\SEOData;
|
||||||
|
|
||||||
class ProjectProposalVoting extends Component
|
class ProjectProposalVoting extends Component
|
||||||
{
|
{
|
||||||
@@ -49,6 +50,9 @@ class ProjectProposalVoting extends Component
|
|||||||
$this->vote->project_proposal_id = $this->projectProposal->id;
|
$this->vote->project_proposal_id = $this->projectProposal->id;
|
||||||
$this->vote->value = false;
|
$this->vote->value = false;
|
||||||
}
|
}
|
||||||
|
if (!$this->fromUrl) {
|
||||||
|
$this->fromUrl = url()->previous();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function yes()
|
public function yes()
|
||||||
@@ -102,6 +106,12 @@ class ProjectProposalVoting extends Component
|
|||||||
})
|
})
|
||||||
->orderByDesc('votes_count')
|
->orderByDesc('votes_count')
|
||||||
->get(),
|
->get(),
|
||||||
|
])->layout('layouts.app', [
|
||||||
|
'SEOData' => new SEOData(
|
||||||
|
title: __('Project Proposal'),
|
||||||
|
description: __('Submit a project proposal and let the community vote on it through the elected voters. All other community members can also vote.'),
|
||||||
|
image: asset('img/voting.jpg')
|
||||||
|
),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
public/img/voting.jpg
Normal file
BIN
public/img/voting.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 107 KiB |
@@ -19,29 +19,42 @@
|
|||||||
|
|
||||||
<form class="space-y-8 divide-y divide-gray-700 pb-24">
|
<form class="space-y-8 divide-y divide-gray-700 pb-24">
|
||||||
<div class="space-y-8 divide-y divide-gray-700 sm:space-y-5">
|
<div class="space-y-8 divide-y divide-gray-700 sm:space-y-5">
|
||||||
<div class="mt-6 sm:mt-5 space-y-6 sm:space-y-5">
|
<div class="grid grid-cols-1 sm:grid-cols-2 gap-2">
|
||||||
|
|
||||||
<div class="w-full flex space-x-4">
|
|
||||||
<x-button lg primary wire:click="yes">
|
|
||||||
Yes, support it!
|
|
||||||
</x-button>
|
|
||||||
<x-button lg primary wire:click="no">
|
|
||||||
No, don't support it!
|
|
||||||
</x-button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<x-input.group :for="md5('vote.reason')" :label="__('Reason')">
|
<div class="border-b border-gray-200 bg-dark px-4 py-5 sm:px-6">
|
||||||
<x-textarea autocomplete="off" wire:model.debounce="vote.reason"
|
<h3 class="text-base font-semibold leading-6 text-gray-200">{{ __('Description') }}</h3>
|
||||||
:placeholder="__('Reason')"/>
|
</div>
|
||||||
</x-input.group>
|
|
||||||
|
<div class="prose prose-invert leading-normal">
|
||||||
|
<x-markdown>
|
||||||
|
{!! $projectProposal->description !!}
|
||||||
|
</x-markdown>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div wire:ignore>
|
<div class="sm:mt-5 space-y-6 sm:space-y-5">
|
||||||
<script src="https://cdn.jsdelivr.net/npm/apexcharts"></script>
|
<div class="w-full flex space-x-4">
|
||||||
|
<x-button lg primary wire:click="yes">
|
||||||
|
Yes, support it!
|
||||||
|
</x-button>
|
||||||
|
<x-button lg primary wire:click="no">
|
||||||
|
No, don't support it!
|
||||||
|
</x-button>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div
|
<div>
|
||||||
x-data="{
|
<x-input.group :for="md5('vote.reason')" :label="__('Reason')">
|
||||||
|
<x-textarea autocomplete="off" wire:model.debounce="vote.reason"
|
||||||
|
:placeholder="__('Reason')"/>
|
||||||
|
</x-input.group>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div wire:ignore>
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/apexcharts"></script>
|
||||||
|
|
||||||
|
<div
|
||||||
|
x-data="{
|
||||||
yes: [{{ $entitledVoters->pluck('votes')->collapse()->where('value', 1)->count() }},{{ $otherVoters->pluck('votes')->collapse()->where('value', 1)->count() }}],
|
yes: [{{ $entitledVoters->pluck('votes')->collapse()->where('value', 1)->count() }},{{ $otherVoters->pluck('votes')->collapse()->where('value', 1)->count() }}],
|
||||||
no: [{{ $entitledVoters->pluck('votes')->collapse()->where('value', 0)->count() }},{{ $otherVoters->pluck('votes')->collapse()->where('value', 0)->count() }}],
|
no: [{{ $entitledVoters->pluck('votes')->collapse()->where('value', 0)->count() }},{{ $otherVoters->pluck('votes')->collapse()->where('value', 0)->count() }}],
|
||||||
labels: ['{{ __('Entitled voters') }}', '{{ __('Other voters') }}',],
|
labels: ['{{ __('Entitled voters') }}', '{{ __('Other voters') }}',],
|
||||||
@@ -58,7 +71,7 @@
|
|||||||
get options() {
|
get options() {
|
||||||
return {
|
return {
|
||||||
theme: { palette: 'palette3' },
|
theme: { palette: 'palette3' },
|
||||||
chart: { type: 'bar', toolbar: true, height: 350, stacked: true, stackType: '100%'},
|
chart: { type: 'bar', toolbar: true, height: 200, stacked: true, stackType: '100%'},
|
||||||
xaxis: { categories: this.labels },
|
xaxis: { categories: this.labels },
|
||||||
plotOptions: { bar: { horizontal: true } },
|
plotOptions: { bar: { horizontal: true } },
|
||||||
series: [
|
series: [
|
||||||
@@ -74,92 +87,93 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
class="w-full"
|
class="w-full"
|
||||||
>
|
>
|
||||||
<div x-ref="chart" class="rounded-lg bg-white p-8"></div>
|
<div x-ref="chart" class="rounded-lg bg-white p-8"></div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="w-full grid grid-cols-2">
|
<div class="w-full grid grid-cols-2">
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<div class="border-b border-gray-200 bg-dark px-4 py-5 sm:px-6">
|
<div class="border-b border-gray-200 bg-dark px-4 py-5 sm:px-6">
|
||||||
<h3 class="text-base font-semibold leading-6 text-gray-200">{{ __('Entitled voters') }}</h3>
|
<h3 class="text-base font-semibold leading-6 text-gray-200">{{ __('Entitled voters') }}</h3>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<ul role="list" class="divide-y divide-gray-200">
|
||||||
|
|
||||||
|
@foreach($entitledVoters as $voter)
|
||||||
|
@php
|
||||||
|
$vote = $voter->votes->first();
|
||||||
|
if (!$voter->votes->first()) {
|
||||||
|
$text = __('not voted yet');
|
||||||
|
} elseif (!$vote->value) {
|
||||||
|
$text = __('Reason') . ': ' . $voter->votes->first()?->reason;
|
||||||
|
}
|
||||||
|
@endphp
|
||||||
|
<li class="flex py-4">
|
||||||
|
<img class="h-10 w-10 rounded-full" src="{{ $voter->profile_photo_url }}"
|
||||||
|
alt="">
|
||||||
|
<div class="ml-3">
|
||||||
|
<p class="text-sm font-medium text-gray-200">
|
||||||
|
{{ $voter->name }}
|
||||||
|
@if($voter->votes->first()?->value)
|
||||||
|
<x-badge green>{{ __('Yes') }}</x-badge>
|
||||||
|
@endif
|
||||||
|
@if($voter->votes->first() && !$voter->votes->first()?->value)
|
||||||
|
<x-badge red>{{ __('No') }}</x-badge>
|
||||||
|
@endif
|
||||||
|
</p>
|
||||||
|
<p class="text-sm text-gray-300">
|
||||||
|
{{ $text ?? '' }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
@endforeach
|
||||||
|
|
||||||
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<ul role="list" class="divide-y divide-gray-200">
|
<div>
|
||||||
|
<div class="border-b border-gray-200 bg-dark px-4 py-5 sm:px-6">
|
||||||
|
<h3 class="text-base font-semibold leading-6 text-gray-200">{{ __('Other voters') }}</h3>
|
||||||
|
</div>
|
||||||
|
|
||||||
@foreach($entitledVoters as $voter)
|
<ul role="list" class="divide-y divide-gray-200">
|
||||||
@php
|
|
||||||
$vote = $voter->votes->first();
|
|
||||||
if (!$voter->votes->first()) {
|
|
||||||
$text = __('not voted yet');
|
|
||||||
} elseif (!$vote->value) {
|
|
||||||
$text = __('Reason') . ': ' . $voter->votes->first()?->reason;
|
|
||||||
}
|
|
||||||
@endphp
|
|
||||||
<li class="flex py-4">
|
|
||||||
<img class="h-10 w-10 rounded-full" src="{{ $voter->profile_photo_url }}"
|
|
||||||
alt="">
|
|
||||||
<div class="ml-3">
|
|
||||||
<p class="text-sm font-medium text-gray-200">
|
|
||||||
{{ $voter->name }}
|
|
||||||
@if($voter->votes->first()?->value)
|
|
||||||
<x-badge green>{{ __('Yes') }}</x-badge>
|
|
||||||
@endif
|
|
||||||
@if($voter->votes->first() && !$voter->votes->first()?->value)
|
|
||||||
<x-badge red>{{ __('No') }}</x-badge>
|
|
||||||
@endif
|
|
||||||
</p>
|
|
||||||
<p class="text-sm text-gray-300">
|
|
||||||
{{ $text ?? '' }}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
@endforeach
|
|
||||||
|
|
||||||
</ul>
|
@foreach($otherVoters as $voter)
|
||||||
</div>
|
@php
|
||||||
|
$vote = $voter->votes->first();
|
||||||
|
if (!$voter->votes->first()) {
|
||||||
|
$text = __('not voted yet');
|
||||||
|
} elseif (!$vote->value) {
|
||||||
|
$text = __('Reason') . ': ' . $voter->votes->first()?->reason;
|
||||||
|
}
|
||||||
|
@endphp
|
||||||
|
<li class="flex py-4">
|
||||||
|
<img class="h-10 w-10 rounded-full" src="{{ $voter->profile_photo_url }}"
|
||||||
|
alt="">
|
||||||
|
<div class="ml-3">
|
||||||
|
<p class="text-sm font-medium text-gray-200">
|
||||||
|
{{ $voter->name }}
|
||||||
|
@if($voter->votes->first()?->value)
|
||||||
|
<x-badge green>{{ __('Yes') }}</x-badge>
|
||||||
|
@endif
|
||||||
|
@if($voter->votes->first() && !$voter->votes->first()?->value)
|
||||||
|
<x-badge red>{{ __('No') }}</x-badge>
|
||||||
|
@endif
|
||||||
|
</p>
|
||||||
|
<p class="text-sm text-gray-300">
|
||||||
|
{{ $text ?? '' }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
@endforeach
|
||||||
|
|
||||||
<div>
|
</ul>
|
||||||
<div class="border-b border-gray-200 bg-dark px-4 py-5 sm:px-6">
|
|
||||||
<h3 class="text-base font-semibold leading-6 text-gray-200">{{ __('Other voters') }}</h3>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<ul role="list" class="divide-y divide-gray-200">
|
|
||||||
|
|
||||||
@foreach($otherVoters as $voter)
|
|
||||||
@php
|
|
||||||
$vote = $voter->votes->first();
|
|
||||||
if (!$voter->votes->first()) {
|
|
||||||
$text = __('not voted yet');
|
|
||||||
} elseif (!$vote->value) {
|
|
||||||
$text = __('Reason') . ': ' . $voter->votes->first()?->reason;
|
|
||||||
}
|
|
||||||
@endphp
|
|
||||||
<li class="flex py-4">
|
|
||||||
<img class="h-10 w-10 rounded-full" src="{{ $voter->profile_photo_url }}"
|
|
||||||
alt="">
|
|
||||||
<div class="ml-3">
|
|
||||||
<p class="text-sm font-medium text-gray-200">
|
|
||||||
{{ $voter->name }}
|
|
||||||
@if($voter->votes->first()?->value)
|
|
||||||
<x-badge green>{{ __('Yes') }}</x-badge>
|
|
||||||
@endif
|
|
||||||
@if($voter->votes->first() && !$voter->votes->first()?->value)
|
|
||||||
<x-badge red>{{ __('No') }}</x-badge>
|
|
||||||
@endif
|
|
||||||
</p>
|
|
||||||
<p class="text-sm text-gray-300">
|
|
||||||
{{ $text ?? '' }}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
@endforeach
|
|
||||||
|
|
||||||
</ul>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user