-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
IP-188: quick 'n' dirty problem creation form
- Loading branch information
Showing
7 changed files
with
310 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
app/ViewModels/CrowdSourcingProject/Problem/CreateEditProblem.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
namespace App\ViewModels\CrowdSourcingProject\Problem; | ||
|
||
use App\Models\CrowdSourcingProject\Problem\CrowdSourcingProjectProblem; | ||
|
||
class CreateEditProblem { | ||
public CrowdSourcingProjectProblem $crowdSourcingProjectProblem; | ||
public function __construct(CrowdSourcingProjectProblem $crowdSourcingProjectProblem) { | ||
$this->crowdSourcingProjectProblem = $crowdSourcingProjectProblem; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
196 changes: 196 additions & 0 deletions
196
resources/views/loggedin-environment/management/problem/create-edit/form-page.blade.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,196 @@ | ||
Problems | ||
<pre> | ||
0 => "id" | ||
1 => "project_id" | ||
2 => "slug" | ||
3 => "status_id" | ||
4 => "img_url" | ||
5 => "default_language_id" | ||
|
||
?? => "user_creator_id" | ||
|
||
defaultTranslation(): HasOne | ||
translations(): HasMany | ||
</pre> | ||
|
||
ProblemTranslations | ||
<pre> | ||
0 => "problem_id" | ||
1 => "language_id" | ||
2 => "title" | ||
3 => "description" | ||
|
||
problem(): BelongsTo | ||
language(): BelongsTo | ||
</pre> | ||
|
||
{{-- | ||
<form id="problem-form" enctype="multipart/form-data" method="POST" | ||
action="{{ $viewModel->isEditMode() ? route('problems.update', $viewModel->problem) : route('problems.store') }}"> | ||
--}} | ||
|
||
<form id="problem-form" enctype="multipart/form-data"{{-- bookmark2 - enctype? --}} method="POST" | ||
action="{{ route('problems.store') }}"> | ||
|
||
{{-- | ||
@if($viewModel->isEditMode()) | ||
@method('PUT') | ||
@endif | ||
--}} | ||
|
||
@csrf | ||
|
||
<div class="container"> | ||
<div class="row"> | ||
<div class="col-12"> | ||
<div class="card"> | ||
<div class="card-body"> | ||
|
||
<div class="row"> | ||
<label class="col-sm-12 control-label" for="problem-title">Problem Title (<span class="red">*</span>)</label> | ||
<div class="col-sm-12"> | ||
<div class="form-group has-feedback {{ $errors->has('problem-title') ? 'has-error' : '' }}"> | ||
<input type="text" | ||
id="problem-title" | ||
name="problem-title" | ||
class="form-control" | ||
required | ||
placeholder="Problem Title" | ||
{{-- value="{{ old('problem-title') ? old('problem-title') : $viewModel->problem->defaultTranslation->title }}" bookmark2 --}} | ||
value="{{ old('problem-title') ? old('problem-title') : '' }}" | ||
> | ||
<span class="help-block"><strong>{{ $errors->first('problem-title') }}</strong></span> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div class="row"> | ||
<label class="col-sm-12 control-label" for="problem-description">Problem Description (<span class="red">*</span>)</label> | ||
<div class="col-sm-12"> | ||
<div class="form-group has-feedback {{ $errors->has('problem-description') ? 'has-error' : '' }}"> | ||
<textarea | ||
id="problem-description" | ||
name="problem-description" | ||
class="form-control" | ||
required | ||
rows="6" | ||
placeholder="Problem Description" | ||
>{{-- {{ old('problem-description') ? old('problem-description') : $viewModel->problem->defaultTranslation->description }} bookmark2 --}}{{ old('problem-description') ? old('problem-description') : '' }}</textarea> | ||
<span class="help-block"><strong>{{ $errors->first('problem-description') }}</strong></span> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div class="row"> | ||
<label class="col-sm-12 control-label" for="problem-status">Problem Status (<span class="red">*</span>)</label> | ||
<div class="col-sm-12"> | ||
<div class="form-group has-feedback {{ $errors->has('problem-status') ? 'has-error' : '' }}"> | ||
<input type="text" | ||
id="problem-status" | ||
name="problem-status" | ||
class="form-control" | ||
required | ||
placeholder="Problem Status" | ||
{{-- value="{{ old('problem-status') ? old('problem-status') : $viewModel->problem->status_id }}" bookmark2 --}} | ||
value="{{ old('problem-status') ? old('problem-status') : '' }}" | ||
> | ||
<span class="help-block"><strong>{{ $errors->first('problem-status') }}</strong></span> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div class="row" style="display: none;{{-- bookmark2 --}}"> | ||
<div class="col-md-12"> | ||
<div class="form-group"> | ||
<label for="problem-status-2">Problem Status</label> | ||
@if(!Gate::check('manage-platform-content')) | ||
<small class="text-blue">(The problem status can only be changed by a platform administrator.)</small>{{-- bookmark2 - is this what we want? --}} | ||
@endif | ||
<select id="problem-status-2" class="form-control" name="problem-status-2"> | ||
{{-- @foreach ($viewModel->problemStatusesLkp as $status) --}} | ||
<option | ||
@if(!Gate::allows('manage-platform-content')) | ||
disabled{{-- bookmark2 - is this what we want? --}} | ||
@endif | ||
{{-- @if ($viewModel->problem->status_id == $status->id || old('problem-status-2') == $status->id) --}} | ||
selected | ||
{{-- @endif --}} | ||
{{-- value="{{ $status->id }}"> --}} | ||
value="1"> | ||
{{-- {{ $status->title }} --}} | ||
Draft | ||
</option> | ||
{{-- @endforeach --}} | ||
</select> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div class="row"> | ||
<label class="col-sm-12 control-label" for="problem-default-language">Problem Default Language (<span class="red">*</span>)</label> | ||
<div class="col-sm-12"> | ||
<div class="form-group has-feedback {{ $errors->has('problem-default-language') ? 'has-error' : '' }}"> | ||
<input type="text" | ||
id="problem-default-language" | ||
name="problem-default-language" | ||
class="form-control" | ||
required | ||
placeholder="Problem Default Language" | ||
{{-- value="{{ old('problem-default-language') ? old('problem-default-language') : $viewModel->problem->default_language_id }}" bookmark2 --}} | ||
value="{{ old('problem-default-language') ? old('problem-default-language') : '' }}" | ||
> | ||
<span class="help-block"><strong>{{ $errors->first('problem-default-language') }}</strong></span> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div class="row" style="display: none;{{-- bookmark2 --}}"> | ||
<div class="col-md-12"> | ||
<div class="form-group"> | ||
<label for="problem-default-language-2">Problem Default Language</label> | ||
<select id="problem-default-language-2" class="form-control" name="problem-default-language-2"> | ||
{{-- @foreach ($viewModel->languagesLkp as $language) --}} | ||
<option | ||
{{-- @if ($viewModel->shouldLanguageBeSelected($language)) --}} | ||
selected | ||
{{-- @endif --}} | ||
{{-- value="{{ $language->id }}"> --}} | ||
value="1"> | ||
{{-- {{ $language->language_name }} --}} | ||
English | ||
</option> | ||
{{-- @endforeach --}} | ||
</select> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
{{-- <div class="row"> | ||
<label class="col-md-12 control-label" for="slug">Project Slug | ||
<br>(it defines the project's url, for example: | ||
<br><i>For english | https://crowdsourcing.ecas.org/en/your-project-slug</i>) | ||
<br><i>For greek | https://crowdsourcing.ecas.org/gr/your-project-slug</i>) | ||
<br><i>For dutch | https://crowdsourcing.ecas.org/nl/your-project-slug</i>) | ||
<br>The url can contain only letters, numbers, and dashes. | ||
<br>If left empty, we will take care of creating the URL, based on the project name. | ||
<br>Please note that once you publish the project you <i>cannot</i> change the slug. | ||
</label> | ||
<div class="col-sm-12"> | ||
<div class="form-group has-feedback {{ $errors->has('slug') ? 'has-error' : '' }}"> | ||
<input id="slug" type="text" class="form-control" name="slug" | ||
value="{{ old('slug') ? old('slug') : $viewModel->project->slug }}" | ||
placeholder="Project Slug"> | ||
<span class="help-block"><strong>{{ $errors->first('slug') }}</strong></span> | ||
</div> | ||
</div> | ||
</div> --}} | ||
|
||
<input type="submit"> | ||
|
||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
</form> |
20 changes: 20 additions & 0 deletions
20
resources/views/loggedin-environment/management/problem/index.blade.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
@php | ||
// var_dump($viewModel); | ||
@endphp | ||
|
||
<ol> | ||
@foreach ($viewModel['problems'] as $problem) | ||
<li> | ||
id: {{ $problem->id }} <br> | ||
slug: {{ $problem->slug }} <br> | ||
default_language_id: {{ $problem->default_language_id }} <br> | ||
@foreach ($problem->translations as $translation) | ||
@if ($translation->language_id === $problem->default_language_id) | ||
default_lang_title: {{ $translation->title }} <br> | ||
default_lang_desc: {{ $translation->description }} <br> | ||
@endif | ||
@endforeach | ||
</li> | ||
<hr> | ||
@endforeach | ||
</ol> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters