Skip to content

Commit

Permalink
IP-284, IP-287, IP-286, IP-285: created relevant files
Browse files Browse the repository at this point in the history
  • Loading branch information
papandrk committed Nov 20, 2024
1 parent 12b08b5 commit bfdf472
Show file tree
Hide file tree
Showing 13 changed files with 411 additions and 0 deletions.
7 changes: 7 additions & 0 deletions app/BusinessLogicLayer/Solution/SolutionManager.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

namespace App\BusinessLogicLayer\Solution;

class SolutionManager {
public function __construct() {}
}
17 changes: 17 additions & 0 deletions app/BusinessLogicLayer/Solution/SolutionStatusManager.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace App\BusinessLogicLayer\Solution;

use App\Repository\Solution\SolutionStatusLkpRepository;

class SolutionStatusManager {
protected SolutionStatusLkpRepository $solutionStatusLkpRepository;

public function __construct(SolutionStatusLkpRepository $solutionStatusLkpRepository) {
$this->solutionStatusLkpRepository = $solutionStatusLkpRepository;
}

public function getAllSolutionStatusesLkp() {
return $this->solutionStatusLkpRepository->all();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

namespace App\BusinessLogicLayer\Solution;

class SolutionTranslationManager {
public function __construct() {}
}
50 changes: 50 additions & 0 deletions app/Http/Controllers/Solution/SolutionController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

namespace App\Http\Controllers\Solution;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;

class SolutionController extends Controller {
/**
* Display a listing of the resource.
*/
public function index() {
//
}

/**
* Show the form for creating a new resource.
*/
public function create() {
//
}

/**
* Store a newly created resource in storage.
*/
public function store(Request $request) {
//
}

/**
* Show the form for editing the specified resource.
*/
public function edit(string $id) {
//
}

/**
* Update the specified resource in storage.
*/
public function update(Request $request, string $id) {
//
}

/**
* Remove the specified resource from storage.
*/
public function destroy(string $id) {
//
}
}
15 changes: 15 additions & 0 deletions app/Repository/Solution/SolutionRepository.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace App\Repository\Solution;

use App\Models\Solution\Solution;
use App\Repository\Repository;

class SolutionRepository extends Repository {
/**
* {@inheritDoc}
*/
public function getModelClassName() {
return Solution::class;
}
}
15 changes: 15 additions & 0 deletions app/Repository/Solution/SolutionStatusLkpRepository.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace App\Repository\Solution;

use App\Models\Solution\SolutionStatusLkp;
use App\Repository\Repository;

class SolutionStatusLkpRepository extends Repository {
/**
* {@inheritDoc}
*/
public function getModelClassName() {
return SolutionStatusLkp::class;
}
}
15 changes: 15 additions & 0 deletions app/Repository/Solution/SolutionTranslationRepository.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace App\Repository\Solution;

use App\Models\Solution\SolutionTranslation;
use App\Repository\Repository;

class SolutionTranslationRepository extends Repository {
/**
* {@inheritDoc}
*/
public function getModelClassName() {
return SolutionTranslation::class;
}
}
5 changes: 5 additions & 0 deletions app/ViewModels/Solution/CreateEditSolution.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

namespace App\ViewModels\Solution;

class CreateEditSolution {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
@extends('backoffice.layout')

@section('content-header')
<h1>{{ $viewModel->isEditMode() ? 'Edit' : 'Create' }}
Problem {{ $viewModel->isEditMode() ? ': ' . $viewModel->problem->defaultTranslation->name : '' }}
<small class="font-weight-light">(required fields are marked with <span class="red">*</span>)</small></h1>
@endsection

@push('css')
@vite('resources/assets/sass/problem/create-edit-problem.scss')
@endpush

@section('content')

<form id="problem-form" enctype="multipart/form-data" method="POST"
action="{{ $viewModel->isEditMode() ? route('problems.update', $viewModel->problem) : route('problems.store') }}">

@if($viewModel->isEditMode())
@method('PUT')
@endif

@csrf

<div class="container-fluid p-0">
<ul class="nav nav-tabs mt-4" id="myTab" role="tablist">
<li class="nav-item" role="presentation">
<a class="nav-link active" id="basic-details-tab" data-toggle="tab" href="#basic-details" role="tab"
aria-controls="basic-details" aria-selected="true">Basic Details</a>
</li>
<li class="nav-item" role="presentation">
<a class="nav-link" id="translations-tab" data-toggle="tab" href="#translations" role="tab"
aria-controls="translations" aria-selected="false">Translations</a>
</li>
</ul>
<div class="tab-content " id="myTabContent">
<div class="tab-pane fade show active " id="basic-details" role="tabpanel"
aria-labelledby="basic-details-tab">
@include('backoffice.management.problem.create-edit.partials.basic-details')

</div>
<div class="tab-pane fade " id="translations" role="tabpanel" aria-labelledby="translations-tab">
@include('backoffice.management.problem.create-edit.partials.translations')
</div>
</div>
<div>
<div class="container-fluid p-0">
<div class="row p-0">
<div class="col-lg-2 col-md-3 col-sm-12">
<input class="btn btn-primary btn-slim w-100 mb-3"
id="submit-form"
type="submit" value="Save">
</div>
</div>
</div>
</div>
</div>
</form>

@endsection

@push('scripts')
@vite('resources/assets/js/problem/manage-problem.js')
@endpush
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
<div class="row">
<div class="col-sm-12">
<div class="card">
<div class="card-body">

<div class="form-row">
<div class="form-group col-sm-12">
<label for="problem-owner-project">Project the problem belongs to (<span
class="red">*</span>)</label>
<select
id="problem-owner-project"
name="problem-owner-project"
class="form-control {{ $errors->has('problem-owner-project') ? 'is-invalid' : '' }}"
required
{{ $errors->has('problem-owner-project') ? 'aria-describedby="problem-owner-project-feedback"' : '' }}
>
<option disabled selected value="">Choose...</option>
@foreach ($viewModel->projects as $project)
<option
@if ($viewModel->problem->project_id == $project->id || old('problem-owner-project') == $project->id)
selected
@endif
value="{{ $project->id }}"
>
{{ $project->defaultTranslation->name }}
</option>
@endforeach
</select>
<div id="problem-owner-project-feedback" class="invalid-feedback">
<strong>{{ $errors->first('problem-owner-project') }}</strong></div>
</div>
</div>

<div class="form-row">
<div class="form-group col-sm-12">
<label for="problem-default-language">Problem Default Language (<span
class="red">*</span>)</label>
<select
id="problem-default-language"
name="problem-default-language"
class="form-control {{ $errors->has('problem-default-language') ? 'is-invalid' : '' }}"
required
>
@foreach ($viewModel->languagesLkp as $language)
<option
@if ($viewModel->shouldLanguageBeSelected($language))
selected
@endif
value="{{ $language->id }}"
>
{{ $language->language_name }}
</option>
@endforeach
</select>
<div id="problem-default-language-feedback" class="invalid-feedback">
<strong>{{ $errors->first('problem-default-language') }}</strong></div>
</div>
</div>

<div class="form-row">
<div class="form-group col-sm-12">
<label for="problem-title">Problem Default Title (<span class="red">*</span>)</label>
<input type="text"
id="problem-title"
name="problem-title"
class="form-control {{ $errors->has('problem-title') ? 'is-invalid' : '' }}"
required
placeholder="Problem Title"
maxlength="100"
{{ $errors->has('problem-title') ? 'aria-describedby="problem-title-feedback"' : '' }}
value="{{ old('problem-title') ? old('problem-title') : $viewModel->problem->defaultTranslation->title }}"
>
<div id="problem-title-feedback" class="invalid-feedback">
<strong>{{ $errors->first('problem-title') }}</strong></div>
</div>
</div>

<div class="form-row">
<div class="form-group col-sm-12">
<label for="problem-description">Problem Default Description (<span
class="red">*</span>)</label>
<textarea
id="problem-description"
name="problem-description"
class="form-control {{ $errors->has('problem-description') ? 'is-invalid' : '' }}"
required
rows="6"
placeholder="Problem Description"
maxlength="400"
{{ $errors->has('problem-description') ? 'aria-describedby="problem-description-feedback"' : '' }}
>{{ old('problem-description') ? old('problem-description') : $viewModel->problem->defaultTranslation->description }}</textarea>
<div id="problem-description-feedback" class="invalid-feedback">
<strong>{{ $errors->first('problem-description') }}</strong></div>
</div>
</div>

<div class="form-row">
<div class="form-group col-sm-12">
<label for="problem-status">Problem Status (<span class="red">*</span>)</label>
<select
id="problem-status"
name="problem-status"
class="form-control {{ $errors->has('problem-status') ? 'is-invalid' : '' }}"
required
{{ $errors->has('problem-status') ? 'aria-describedby="problem-status-feedback"' : '' }}
>
@foreach ($viewModel->problemStatusesLkp as $status)
<option
@if ($viewModel->problem->status_id == $status->id || old('problem-status') == $status->id)
selected
@endif
value="{{ $status->id }}"
>
{{ $status->title }}
</option>
@endforeach
</select>
<div id="problem-status-feedback" class="invalid-feedback">
<strong>{{ $errors->first('problem-status') }}</strong></div>
</div>
</div>

@if($viewModel->isEditMode())
<div class="form-row">
<div class="form-group col-sm-12">
<label for="problem-slug">Problem Slug (<span class="red">*</span>)
<span class="text-sm explanation-text">
(It defines the problems's url, for example:
<ul>
<li><i>For english | https://crowdsourcing.ecas.org/en/project-slug/problem-slug</i></li>
<li><i>For greek | https://crowdsourcing.ecas.org/gr/project-slug/problem-slug</i></li>
<li><i>For dutch | https://crowdsourcing.ecas.org/nl/project-slug/problem-slug</i></li>
</ul>
The slug must be unique and can contain only letters, numbers, and dashes.)
</span>
</label>
<input type="text"
id="problem-slug"
name="problem-slug"
class="form-control {{ $errors->has('problem-slug') ? 'is-invalid' : '' }}"
required
placeholder="Problem Slug"
maxlength="111"
value="{{ old('problem-slug') ? old('problem-slug') : $viewModel->problem->slug }}"
>
<div id="problem-slug-feedback" class="invalid-feedback">
<strong>{{ $errors->first('problem-slug') }}</strong></div>
</div>
</div>
@endif

<div class="form-row js-image-input-container">
<div class="col-sm-12">
<div class="form-group input-file-wrapper">
<label for="problem-image">Problem Image (max-size: 2MB)</label></label>
<small>In order to update the currently selected image, please choose a new image by
clicking the button below.</small><br>
<input type="file"
id="problem-image"
name="problem-image"
class="form-control p-2 h-auto {{ $errors->has('problem-image') ? 'is-invalid' : '' }} js-image-input"
accept="image/png,image/jpeg,image/jpg"
placeholder="Problem Image"
>
<div id="problem-image-feedback" class="invalid-feedback">
<strong>{{ $errors->first('problem-image') }}</strong></div>
</div>
<div class="image-preview-container">
<img
loading="lazy"
class="selected-image-preview js-selected-image-preview"
src="{{ $viewModel->problem->img_url ? asset($viewModel->problem->img_url) : '/images/problem_default_image.png' }}"
alt="">
</div>
</div>
</div>

</div>
</div>
</div>
</div>
Loading

0 comments on commit bfdf472

Please sign in to comment.