Skip to content

Commit

Permalink
Removed some redundant Gate checks
Browse files Browse the repository at this point in the history
  • Loading branch information
PavlosIsaris committed Nov 14, 2024
1 parent 9df3584 commit 15bc67a
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 96 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -196,27 +196,7 @@ export default {
const deleteTranslation = async (language) => {
const translation = translations.value.find((t) => t.language_id === language.id);
const swal = (await import("bootstrap-sweetalert")).default;
swal(
{
title: "Are you sure?",
text: "The translation will be deleted",
type: "warning",
showCancelButton: true,
confirmButtonClass: "btn-danger",
confirmButtonText: "Yes, delete it!",
cancelButtonText: "No, cancel!",
closeOnConfirm: true,
closeOnCancel: true,
},
(isConfirm) => {
if (isConfirm) {
translations.value.splice(translations.value.indexOf(translation), 1);
} else {
checkedLanguages.value.push(language);
}
},
);
translations.value.splice(translations.value.indexOf(translation), 1);
};
const getOriginalEnglishTranslation = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,14 @@
<div class="col-md-12">
<div class="form-group">
<label for="status_id">Project status</label>
@if(!Gate::check('manage-platform-content'))
<small class="text-blue">(The project status can only be changed by a platform
administrator.)</small>
@endif

<small class="text-blue">(The project status can only be changed by a platform
administrator.)</small>
<select id="status_id" class="form-control" name="status_id">
@foreach ($viewModel->projectStatusesLkp as $status)
<option
@if(!Gate::allows('manage-platform-content'))
disabled
@endif
@if ($viewModel->project->status_id == $status->id || old('status_id') == $status->id)
selected
selected
@endif
value="{{ $status->id }}">
{{ $status->title }}
Expand Down Expand Up @@ -95,7 +91,7 @@
@foreach ($viewModel->languagesLkp as $language)
<option
@if ($viewModel->shouldLanguageBeSelected($language))
selected
selected
@endif
value="{{ $language->id }}">
{{ $language->language_name }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,36 @@

<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>
<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"' : '' }}
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 }}"
@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 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>
<label for="problem-default-language">Problem Default Language (<span
class="red">*</span>)</label>
<select
id="problem-default-language"
name="problem-default-language"
Expand All @@ -49,72 +52,71 @@ class="form-control {{ $errors->has('problem-default-language') ? 'is-invalid' :
</option>
@endforeach
</select>
<div id="problem-default-language-feedback" class="invalid-feedback"><strong>{{ $errors->first('problem-default-language') }}</strong></div>
<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 }}"
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 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>
<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"
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 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>
@if(!Gate::check('manage-platform-content')){{-- bookmark2 - do we need this? --}}
<small class="text-blue">(The problem status can only be changed by a platform administrator.)</small>{{-- bookmark2 - and content-manager? do we need this? --}}
@endif
<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"' : '' }}
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(!Gate::check('manage-platform-content'))
disabled{{-- bookmark2 - do we need this? --}}
@endif
@if ($viewModel->problem->status_id == $status->id || old('problem-status') == $status->id)
selected
@endif
value="{{ $status->id }}"
@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 id="problem-status-feedback" class="invalid-feedback">
<strong>{{ $errors->first('problem-status') }}</strong></div>
</div>
</div>

Expand All @@ -133,15 +135,16 @@ class="form-control {{ $errors->has('problem-status') ? 'is-invalid' : '' }}"
</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 }}"
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 id="problem-slug-feedback" class="invalid-feedback">
<strong>{{ $errors->first('problem-slug') }}</strong></div>
</div>
</div>
@endif
Expand All @@ -150,22 +153,24 @@ class="form-control {{ $errors->has('problem-slug') ? 'is-invalid' : '' }}"
<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>
<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"
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 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="">
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>
Expand Down

0 comments on commit 15bc67a

Please sign in to comment.