Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Job offer #10

Merged
merged 5 commits into from
Oct 9, 2024
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
89 changes: 89 additions & 0 deletions src/Form/Type/UiElement/JobOfferUiElementType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<?php

/*
* This file is part of Monsieur Biz's SyliusUiElementsPlugin for Sylius.
* (c) Monsieur Biz <[email protected]>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace MonsieurBiz\SyliusUiElementsPlugin\Form\Type\UiElement;

use MonsieurBiz\SyliusRichEditorPlugin\Attribute\AsUiElement;
use MonsieurBiz\SyliusRichEditorPlugin\Attribute\TemplatesUiElement;
use MonsieurBiz\SyliusRichEditorPlugin\Form\Type\WysiwygType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\UrlType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Validator\Constraints as Assert;

#[AsUiElement(
code: 'monsieurbiz_ui_elements.job_offer_ui_element',
icon: 'clipboard',
title: 'monsieurbiz_ui_elements.ui_element.job_offer_ui_element.title',
description: 'monsieurbiz_ui_elements.ui_element.job_offer_ui_element.description',
templates: new TemplatesUiElement(
adminRender: '@MonsieurBizSyliusUiElementsPlugin/Admin/UiElement/job_offer_ui_element.html.twig',
frontRender: '@MonsieurBizSyliusUiElementsPlugin/Shop/UiElement/job_offer_ui_element.html.twig',
),
wireframe: 'job-offer',
)]
final class JobOfferUiElementType extends AbstractType
{
public const DISPLAY_SYNTHESIS = 'synthesis';

public const DISPLAY_COMPLETE = 'complete';

/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('display', ChoiceType::class, [
'label' => 'monsieurbiz_ui_elements.ui_element.job_offer_ui_element.fields.display',
'required' => true,
'constraints' => [
new Assert\NotBlank(),
],
'choices' => [
'monsieurbiz_ui_elements.ui_element.job_offer_ui_element.choices.display.synthesis' => self::DISPLAY_SYNTHESIS,
'monsieurbiz_ui_elements.ui_element.job_offer_ui_element.choices.display.complete' => self::DISPLAY_COMPLETE,
],
])
->add('title', TextType::class, [
'label' => 'monsieurbiz_ui_elements.common.fields.title',
'required' => true,
'constraints' => [
new Assert\NotBlank(),
],
])
->add('contract', TextType::class, [
'label' => 'monsieurbiz_ui_elements.ui_element.job_offer_ui_element.fields.contract',
'required' => true,
'constraints' => [
new Assert\NotBlank(),
],
])
->add('localisation', TextType::class, [
'label' => 'monsieurbiz_ui_elements.ui_element.job_offer_ui_element.fields.localisation',
'required' => true,
'constraints' => [
new Assert\NotBlank(),
],
])
->add('content', WysiwygType::class, [
'label' => 'monsieurbiz_ui_elements.common.fields.content',
'required' => false,
])
->add('url', UrlType::class, [
Kiwikoti marked this conversation as resolved.
Show resolved Hide resolved
'label' => 'monsieurbiz_ui_elements.ui_element.job_offer_ui_element.fields.url',
'required' => false,
])
;
}
}
13 changes: 13 additions & 0 deletions src/Resources/translations/messages.en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,16 @@ monsieurbiz_ui_elements:
buttons:
add_element: "Add element"
delete_element: "Delete element"
job_offer_ui_element:
title: "Job offer Element"
description: "Job offer with display in synthesis or complete"
choices:
display:
synthesis: "Synthesis"
complete: "Complete"
fields:
display: "Display"
contract: "Contract"
localisation: "Localisation"
content: "Content"
url: "Link"
13 changes: 13 additions & 0 deletions src/Resources/translations/messages.fr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,16 @@ monsieurbiz_ui_elements:
buttons:
add_element: "Ajouter un élément"
delete_element: "Supprimer un élément"
job_offer_ui_element:
title: "Lame offre d'emploi"
description: "Affichage d'une offre d'emploi symntéthique ou complète"
choices:
display:
synthesis: "Synthèse"
complete: "Complète"
fields:
display: "Affichage"
contract: "Contrat"
localisation: "Localisation"
content: "Contenu"
url: "Lien"
47 changes: 47 additions & 0 deletions src/Resources/views/Admin/UiElement/job_offer_ui_element.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{#
UI Element template
type: job_offer_ui_element
element fields:
- display
- title
- contract
- localisation
- content
- url
#}
<div class="ui segment">
{% if element.display == constant('MonsieurBiz\\SyliusUiElementsPlugin\\Form\\Type\\UiElement\\JobOfferUiElementType::DISPLAY_SYNTHESIS') %}
<a href="{{ element.url|default('#') }}" target="_blank" rel="noopener noreferrer">
{% if element.title|default('') is not empty %}
<h2>{{ element.title }}</h2>
{% endif %}
<div class="ui stackable grid">
{% if element.contract|default('') is not empty %}
<div class="column"><i class="icon edit outline"></i>{{ element.contract }}</div>
{% endif %}
{% if element.localisation|default('') is not empty %}
<div class="column"><i class="icon map marker alternate"></i>{{ element.localisation }}</div>
{% endif %}
</div>
</a>
{% elseif element.display == constant('MonsieurBiz\\SyliusUiElementsPlugin\\Form\\Type\\UiElement\\JobOfferUiElementType::DISPLAY_COMPLETE') %}
<div>
{% if element.title|default('') is not empty %}
<h2>{{ element.title }}</h2>
{% endif %}
<div class="ui stackable grid">
{% if element.contract|default('') is not empty %}
<div class="column"><i class="icon edit outline"></i>{{ element.contract }}</div>
{% endif %}
{% if element.localisation|default('') is not empty %}
<div class="column"><i class="icon map marker alternate"></i>{{ element.localisation }}</div>
{% endif %}
</div>
{% if element.content|default('') %}
<div class="content">
{{ element.content|raw }}
</div>
{% endif %}
</div>
{% endif %}
</div>
47 changes: 47 additions & 0 deletions src/Resources/views/Shop/UiElement/job_offer_ui_element.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{#
UI Element template
type: job_offer_ui_element
element fields:
- display
- title
- contract
- localisation
- content
- url
#}
<div class="ui segment">
{% if element.display == constant('MonsieurBiz\\SyliusUiElementsPlugin\\Form\\Type\\UiElement\\JobOfferUiElementType::DISPLAY_SYNTHESIS') %}
<a href="{{ element.url|default('#') }}">
{% if element.title|default('') is not empty %}
<h2>{{ element.title }}</h2>
{% endif %}
<div class="ui stackable grid">
{% if element.contract|default('') is not empty %}
<div class="column"><i class="icon edit outline"></i>{{ element.contract }}</div>
{% endif %}
{% if element.localisation|default('') is not empty %}
<div class="column"><i class="icon map marker alternate"></i>{{ element.localisation }}</div>
{% endif %}
</div>
</a>
{% elseif element.display == constant('MonsieurBiz\\SyliusUiElementsPlugin\\Form\\Type\\UiElement\\JobOfferUiElementType::DISPLAY_COMPLETE') %}
<div>
{% if element.title|default('') is not empty %}
<h2>{{ element.title }}</h2>
{% endif %}
<div class="ui stackable grid">
{% if element.contract|default('') is not empty %}
<div class="column"><i class="icon edit outline"></i>{{ element.contract }}</div>
{% endif %}
{% if element.localisation|default('') is not empty %}
<div class="column"><i class="icon map marker alternate"></i>{{ element.localisation }}</div>
{% endif %}
</div>
{% if element.content|default('') %}
<div class="content">
{{ element.content|raw }}
</div>
{% endif %}
</div>
{% endif %}
</div>
3 changes: 3 additions & 0 deletions src/Resources/views/Wireframe/job-offer.svg.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<svg width="230" height="100" viewBox="0 0 230 100" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect width="230" height="100" rx="5" fill="#7A8CCE" fill-opacity="0.1"></rect>
</svg>
Loading