mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 22:53:49 +00:00
Merge branch 'master' into calendar/docgen-add-generation
This commit is contained in:
@@ -14,7 +14,7 @@ namespace Chill\MainBundle\Controller;
|
||||
use Chill\MainBundle\CRUD\Controller\ApiController;
|
||||
use Chill\MainBundle\Pagination\PaginatorFactory;
|
||||
use Chill\MainBundle\Repository\CountryRepository;
|
||||
use Chill\MainBundle\Repository\PostalCodeRepository;
|
||||
use Chill\MainBundle\Repository\PostalCodeRepositoryInterface;
|
||||
use Chill\MainBundle\Serializer\Model\Collection;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
@@ -30,11 +30,11 @@ final class PostalCodeAPIController extends ApiController
|
||||
|
||||
private PaginatorFactory $paginatorFactory;
|
||||
|
||||
private PostalCodeRepository $postalCodeRepository;
|
||||
private PostalCodeRepositoryInterface $postalCodeRepository;
|
||||
|
||||
public function __construct(
|
||||
CountryRepository $countryRepository,
|
||||
PostalCodeRepository $postalCodeRepository,
|
||||
PostalCodeRepositoryInterface $postalCodeRepository,
|
||||
PaginatorFactory $paginatorFactory
|
||||
) {
|
||||
$this->countryRepository = $countryRepository;
|
||||
|
@@ -27,6 +27,7 @@ use Chill\MainBundle\Doctrine\DQL\GetJsonFieldByKey;
|
||||
use Chill\MainBundle\Doctrine\DQL\JsonAggregate;
|
||||
use Chill\MainBundle\Doctrine\DQL\JsonbArrayLength;
|
||||
use Chill\MainBundle\Doctrine\DQL\JsonbExistsInArray;
|
||||
use Chill\MainBundle\Doctrine\DQL\JsonExtract;
|
||||
use Chill\MainBundle\Doctrine\DQL\OverlapsI;
|
||||
use Chill\MainBundle\Doctrine\DQL\Replace;
|
||||
use Chill\MainBundle\Doctrine\DQL\Similarity;
|
||||
@@ -234,6 +235,7 @@ class ChillMainExtension extends Extension implements
|
||||
'GET_JSON_FIELD_BY_KEY' => GetJsonFieldByKey::class,
|
||||
'AGGREGATE' => JsonAggregate::class,
|
||||
'REPLACE' => Replace::class,
|
||||
'JSON_EXTRACT' => JsonExtract::class,
|
||||
],
|
||||
'numeric_functions' => [
|
||||
'JSONB_EXISTS_IN_ARRAY' => JsonbExistsInArray::class,
|
||||
|
43
src/Bundle/ChillMainBundle/Doctrine/DQL/JsonExtract.php
Normal file
43
src/Bundle/ChillMainBundle/Doctrine/DQL/JsonExtract.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\MainBundle\Doctrine\DQL;
|
||||
|
||||
use Doctrine\ORM\Query\AST\Functions\FunctionNode;
|
||||
use Doctrine\ORM\Query\Lexer;
|
||||
use Doctrine\ORM\Query\Parser;
|
||||
use Doctrine\ORM\Query\SqlWalker;
|
||||
|
||||
class JsonExtract extends FunctionNode
|
||||
{
|
||||
private $element;
|
||||
|
||||
private $keyToExtract;
|
||||
|
||||
public function getSql(SqlWalker $sqlWalker)
|
||||
{
|
||||
return sprintf('%s->>%s', $this->element->dispatch($sqlWalker), $this->keyToExtract->dispatch($sqlWalker));
|
||||
}
|
||||
|
||||
public function parse(Parser $parser)
|
||||
{
|
||||
$parser->match(Lexer::T_IDENTIFIER);
|
||||
$parser->match(Lexer::T_OPEN_PARENTHESIS);
|
||||
|
||||
$this->element = $parser->ArithmeticPrimary();
|
||||
|
||||
$parser->match(Lexer::T_COMMA);
|
||||
|
||||
$this->keyToExtract = $parser->ArithmeticExpression();
|
||||
|
||||
$parser->match(Lexer::T_CLOSE_PARENTHESIS);
|
||||
}
|
||||
}
|
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\MainBundle\Form\Type\DataTransformer;
|
||||
|
||||
use Chill\MainBundle\Entity\PostalCode;
|
||||
use Chill\MainBundle\Repository\PostalCodeRepositoryInterface;
|
||||
use Symfony\Component\Form\DataTransformerInterface;
|
||||
use Symfony\Component\Form\Exception\TransformationFailedException;
|
||||
use function gettype;
|
||||
use function is_int;
|
||||
|
||||
class PostalCodeToIdTransformer implements DataTransformerInterface
|
||||
{
|
||||
private PostalCodeRepositoryInterface $postalCodeRepository;
|
||||
|
||||
public function __construct(PostalCodeRepositoryInterface $postalCodeRepository)
|
||||
{
|
||||
$this->postalCodeRepository = $postalCodeRepository;
|
||||
}
|
||||
|
||||
public function reverseTransform($value)
|
||||
{
|
||||
if (null === $value || trim('') === $value) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!is_int((int) $value)) {
|
||||
throw new TransformationFailedException('Cannot transform ' . gettype($value));
|
||||
}
|
||||
|
||||
return $this->postalCodeRepository->find((int) $value);
|
||||
}
|
||||
|
||||
public function transform($value)
|
||||
{
|
||||
if (null === $value) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($value instanceof PostalCode) {
|
||||
return $value->getId();
|
||||
}
|
||||
|
||||
throw new TransformationFailedException('Could not reverseTransform ' . gettype($value));
|
||||
}
|
||||
}
|
49
src/Bundle/ChillMainBundle/Form/Type/PickPostalCodeType.php
Normal file
49
src/Bundle/ChillMainBundle/Form/Type/PickPostalCodeType.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\MainBundle\Form\Type;
|
||||
|
||||
use Chill\MainBundle\Entity\PostalCode;
|
||||
use Chill\MainBundle\Form\Type\DataTransformer\PostalCodeToIdTransformer;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
use Symfony\Component\Form\FormView;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class PickPostalCodeType extends AbstractType
|
||||
{
|
||||
private PostalCodeToIdTransformer $postalCodeToIdTransformer;
|
||||
|
||||
public function __construct(PostalCodeToIdTransformer $postalCodeToIdTransformer)
|
||||
{
|
||||
$this->postalCodeToIdTransformer = $postalCodeToIdTransformer;
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder->addViewTransformer($this->postalCodeToIdTransformer);
|
||||
}
|
||||
|
||||
public function buildView(FormView $view, FormInterface $form, array $options)
|
||||
{
|
||||
$view->vars['uniqid'] = $view->vars['attr']['data-input-postal-code'] = uniqid('input_pick_postal_code_');
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver
|
||||
->setDefault('class', PostalCode::class)
|
||||
->setDefault('multiple', false)
|
||||
->setAllowedTypes('multiple', ['bool'])
|
||||
->setDefault('compound', false);
|
||||
}
|
||||
}
|
@@ -18,10 +18,9 @@ use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Doctrine\ORM\Query\ResultSetMapping;
|
||||
use Doctrine\ORM\Query\ResultSetMappingBuilder;
|
||||
use Doctrine\Persistence\ObjectRepository;
|
||||
use RuntimeException;
|
||||
|
||||
final class PostalCodeRepository implements ObjectRepository
|
||||
final class PostalCodeRepository implements PostalCodeRepositoryInterface
|
||||
{
|
||||
private EntityManagerInterface $entityManager;
|
||||
|
||||
@@ -29,7 +28,7 @@ final class PostalCodeRepository implements ObjectRepository
|
||||
|
||||
public function __construct(EntityManagerInterface $entityManager)
|
||||
{
|
||||
$this->repository = $entityManager->getRepository(PostalCode::class);
|
||||
$this->repository = $entityManager->getRepository($this->getClassName());
|
||||
$this->entityManager = $entityManager;
|
||||
}
|
||||
|
||||
@@ -51,20 +50,11 @@ final class PostalCodeRepository implements ObjectRepository
|
||||
return $this->repository->find($id, $lockMode, $lockVersion);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PostalCode[]
|
||||
*/
|
||||
public function findAll(): array
|
||||
{
|
||||
return $this->repository->findAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed|null $limit
|
||||
* @param mixed|null $offset
|
||||
*
|
||||
* @return PostalCode[]
|
||||
*/
|
||||
public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null): array
|
||||
{
|
||||
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
|
||||
@@ -95,7 +85,7 @@ final class PostalCodeRepository implements ObjectRepository
|
||||
return $this->repository->findOneBy($criteria, $orderBy);
|
||||
}
|
||||
|
||||
public function getClassName()
|
||||
public function getClassName(): string
|
||||
{
|
||||
return PostalCode::class;
|
||||
}
|
||||
|
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\MainBundle\Repository;
|
||||
|
||||
use Chill\MainBundle\Entity\Country;
|
||||
use Chill\MainBundle\Entity\PostalCode;
|
||||
use Doctrine\Persistence\ObjectRepository;
|
||||
|
||||
interface PostalCodeRepositoryInterface extends ObjectRepository
|
||||
{
|
||||
public function countByPattern(string $pattern, ?Country $country): int;
|
||||
|
||||
public function find($id, $lockMode = null, $lockVersion = null): ?PostalCode;
|
||||
|
||||
/**
|
||||
* @return PostalCode[]
|
||||
*/
|
||||
public function findAll(): array;
|
||||
|
||||
/**
|
||||
* @param mixed|null $limit
|
||||
* @param mixed|null $offset
|
||||
*
|
||||
* @return PostalCode[]
|
||||
*/
|
||||
public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null): array;
|
||||
|
||||
public function findByPattern(string $pattern, ?Country $country, ?int $start = 0, ?int $limit = 50): array;
|
||||
|
||||
public function findOneBy(array $criteria, ?array $orderBy = null): ?PostalCode;
|
||||
|
||||
public function getClassName(): string;
|
||||
}
|
@@ -0,0 +1,60 @@
|
||||
import { createApp } from 'vue';
|
||||
import PickPostalCode from 'ChillMainAssets/vuejs/PickPostalCode/PickPostalCode';
|
||||
import { _createI18n } from 'ChillMainAssets/vuejs/_js/i18n';
|
||||
import { appMessages } from 'ChillMainAssets/vuejs/PickEntity/i18n';
|
||||
import { makeFetch } from 'ChillMainAssets/lib/api/apiMethods';
|
||||
|
||||
const i18n = _createI18n(appMessages);
|
||||
|
||||
|
||||
function loadOnePicker(el, input, uniqId, city) {
|
||||
const app = createApp({
|
||||
template: '<pick-postal-code @select-city="onCitySelected" @removeCity="onCityRemoved" :picked="city"></pick-postal-code>',
|
||||
components: {
|
||||
PickPostalCode,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
city: city,
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onCitySelected(city) {
|
||||
this.city = city;
|
||||
input.value = city.id;
|
||||
},
|
||||
onCityRemoved(city) {
|
||||
this.city = null;
|
||||
input.value = '';
|
||||
}
|
||||
}
|
||||
})
|
||||
.use(i18n)
|
||||
.mount(el);
|
||||
}
|
||||
|
||||
function loadDynamicPickers(element) {
|
||||
|
||||
let apps = element.querySelectorAll('[data-module="pick-postal-code"]');
|
||||
|
||||
apps.forEach(function(el) {
|
||||
|
||||
const
|
||||
uniqId = el.dataset.uniqid,
|
||||
input = document.querySelector(`input[data-input-uniqid="${uniqId}"]`),
|
||||
cityIdValue = input.value === '' ? null : input.value
|
||||
;
|
||||
|
||||
if (cityIdValue !== null) {
|
||||
makeFetch('GET', `/api/1.0/main/postal-code/${cityIdValue}.json`).then(city => {
|
||||
loadOnePicker(el, input, uniqId, city);
|
||||
})
|
||||
} else {
|
||||
loadOnePicker(el, input, uniqId, null);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function(e) {
|
||||
loadDynamicPickers(document)
|
||||
})
|
@@ -0,0 +1,29 @@
|
||||
# Pickpostalcode
|
||||
|
||||
Allow to pick a postal code.
|
||||
|
||||
In use with module `mod_pick_postal_code`, associated with `PickPostalCodeType` in php.
|
||||
|
||||
## Usage
|
||||
|
||||
`<pick-postal-code @select-city="onCitySelected" @removeCity="onCityRemoved" :picked="city"></pick-postal-code>`
|
||||
|
||||
## Props
|
||||
|
||||
* `picked`: the city picked. A javascript object (a city). Null if empty.
|
||||
* `country`: country to restraint search on picked. May be null.
|
||||
|
||||
## Emits
|
||||
|
||||
### `selectCity`
|
||||
|
||||
When a city is onCitySelected.
|
||||
|
||||
Argument: a js object, representing a city
|
||||
|
||||
### `removeCity`
|
||||
|
||||
When a city is removed.
|
||||
|
||||
|
||||
Argument: a js object, representing a city
|
@@ -0,0 +1,107 @@
|
||||
<template>
|
||||
<div class="PickPostalCode">
|
||||
<vue-multiselect
|
||||
id="citySelector"
|
||||
@search-change="listenInputSearch"
|
||||
ref="citySelector"
|
||||
v-model="internalPicked"
|
||||
@select="selectCity"
|
||||
@remove="remove"
|
||||
name=""
|
||||
track-by="id"
|
||||
label="value"
|
||||
:custom-label="transName"
|
||||
:placeholder="$t('select_city')"
|
||||
:select-label="$t('multiselect.select_label')"
|
||||
:deselect-label="$t('multiselect.deselect_label')"
|
||||
:selected-label="$t('multiselect.selected_label')"
|
||||
:taggable="true"
|
||||
:multiple="false"
|
||||
:internal-search="false"
|
||||
:loading="isLoading"
|
||||
:options="cities"></vue-multiselect>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="js">
|
||||
|
||||
import VueMultiselect from "vue-multiselect";
|
||||
import {reactive, defineProps, onMounted} from "vue";
|
||||
import {fetchCities, searchCities} from "./api";
|
||||
|
||||
export default {
|
||||
components: {
|
||||
VueMultiselect,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
cities: [],
|
||||
internalPicked: null,
|
||||
isLoading: false,
|
||||
abortControllers: [],
|
||||
}
|
||||
},
|
||||
emits: ['pickCity', 'removeCity'],
|
||||
props: {
|
||||
picked: {
|
||||
type: Object,
|
||||
required: false,
|
||||
default: null
|
||||
},
|
||||
country: {
|
||||
type: Object,
|
||||
required: false,
|
||||
default: null
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
if (this.picked !== null) {
|
||||
this.internalPicked = this.picked;
|
||||
this.cities.push(this.picked);
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
transName(value) {
|
||||
return (value.code && value.name) ? `${value.name} (${value.code})` : '';
|
||||
},
|
||||
selectCity(city) {
|
||||
this.$emit('selectCity', city);
|
||||
},
|
||||
listenInputSearch(query) {
|
||||
if (query.length <= 2) {
|
||||
return;
|
||||
}
|
||||
|
||||
let c = this.abortControllers.pop();
|
||||
|
||||
while (typeof c !== 'undefined') {
|
||||
c.abort();
|
||||
c = this.abortControllers.pop();
|
||||
}
|
||||
|
||||
this.isLoading = true;
|
||||
let controller = new AbortController();
|
||||
this.abortControllers.push(controller);
|
||||
|
||||
searchCities(query, this.country, controller).then(
|
||||
newCities => {
|
||||
this.cities = this.cities.filter(city => city.id === this.picked);
|
||||
newCities.forEach(item => {
|
||||
this.cities.push(item);
|
||||
})
|
||||
this.isLoading = false;
|
||||
|
||||
return Promise.resolve();
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log(error); //TODO better error handling
|
||||
this.isLoading = false;
|
||||
});
|
||||
},
|
||||
remove(item) {
|
||||
this.$emit('removeCity', item);
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
</script>
|
@@ -0,0 +1,3 @@
|
||||
.PickPostalCode {
|
||||
|
||||
}
|
@@ -0,0 +1,43 @@
|
||||
import {makeFetch, fetchResults} from 'ChillMainAssets/lib/api/apiMethods';
|
||||
|
||||
/**
|
||||
* Endpoint chill_api_single_postal_code__index
|
||||
* method GET, get Cities Object
|
||||
* @params {object} a country object
|
||||
* @returns {Promise} a promise containing all Postal Code objects filtered with country
|
||||
*/
|
||||
const fetchCities = (country) => {
|
||||
// warning: do not use fetchResults (in apiMethods): we need only a **part** of the results in the db
|
||||
const params = new URLSearchParams({item_per_page: 100});
|
||||
|
||||
if (country !== null) {
|
||||
params.append('country', country.id);
|
||||
}
|
||||
|
||||
return makeFetch('GET', `/api/1.0/main/postal-code.json?${params.toString()}`).then(r => Promise.resolve(r.results));
|
||||
};
|
||||
|
||||
/**
|
||||
* Endpoint chill_main_postalcodeapi_search
|
||||
* method GET, get Cities Object
|
||||
* @params {string} search a search string
|
||||
* @params {object} country a country object
|
||||
* @params {AbortController} an abort controller
|
||||
* @returns {Promise} a promise containing all Postal Code objects filtered with country and a search string
|
||||
*/
|
||||
const searchCities = (search, country, controller) => {
|
||||
const url = '/api/1.0/main/postal-code/search.json?';
|
||||
const params = new URLSearchParams({q: search});
|
||||
|
||||
if (country !== null) {
|
||||
Object.assign('country', country.id);
|
||||
}
|
||||
|
||||
return makeFetch('GET', url + params, null, {signal: controller.signal})
|
||||
.then(result => Promise.resolve(result.results));
|
||||
};
|
||||
|
||||
export {
|
||||
fetchCities,
|
||||
searchCities,
|
||||
};
|
@@ -251,3 +251,9 @@
|
||||
<input type="hidden" {{ block('widget_attributes') }} {% if value is not empty %}value="{{ value|escape('html_attr') }}" {% endif %} data-input-uniqid="{{ form.vars['uniqid'] }}"/>
|
||||
<div data-module="pick-dynamic" data-types="{{ form.vars['types']|json_encode }}" data-multiple="{{ form.vars['multiple'] }}" data-uniqid="{{ form.vars['uniqid'] }}"></div>
|
||||
{% endblock %}
|
||||
|
||||
{% block pick_postal_code_widget %}
|
||||
{{ form_help(form)}}
|
||||
<input type="hidden" {{ block('widget_attributes') }} {% if value is not empty %}value="{{ value }}" {% endif %} data-input-uniqid="{{ form.vars['uniqid'] }}"/>
|
||||
<div data-module="pick-postal-code" data-uniqid="{{ form.vars['uniqid'] }}"></div>
|
||||
{% endblock %}
|
||||
|
@@ -95,6 +95,15 @@
|
||||
</ul>
|
||||
{% endif %}
|
||||
|
||||
{% if entity_workflow.currentStep.destEmail|length > 0 %}
|
||||
<p><b>{{ 'workflow.An access key was also sent to those addresses'|trans }} :</b></p>
|
||||
<ul>
|
||||
{% for e in entity_workflow.currentStep.destEmail -%}
|
||||
<li><a href="mailto:{{ e|escape('html_attr') }}">{{ e }}</a></li>
|
||||
{%- endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
|
||||
{% if entity_workflow.currentStep.destUserByAccessKey|length > 0 %}
|
||||
<p><b>{{ 'workflow.Those users are also granted to apply a transition by using an access key'|trans }} :</b></p>
|
||||
<ul>
|
||||
@@ -103,6 +112,21 @@
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
|
||||
{% if is_granted('CHILL_MAIN_WORKFLOW_LINK_SHOW', entity_workflow) %}
|
||||
<p><b>{{ 'workflow.This link grant any user to apply a transition'|trans }} :</b></p>
|
||||
|
||||
{% set link = absolute_url(path('chill_main_workflow_grant_access_by_key', {'id': entity_workflow.currentStep.id, 'accessKey': entity_workflow.currentStep.accessKey})) %}
|
||||
<div class="input-group mb-3">
|
||||
<input type="text" readonly value="{{ link|e('html_attr') }}" class="form-control">
|
||||
<button class="btn btn-secondary" type="button" id="button-copy" onclick="navigator.clipboard.writeText('{{ link|e('html_attr') }}').then(() => { window.alert({{ ('"' ~ 'workflow.Access link copied'|trans ~ ' !"') |e('html_attr') }})});"><i class="fa fa-files-o"></i></button>
|
||||
<a class="btn btn-secondary" type="button" id="button-email"
|
||||
href="mailto:?body={{ ((('workflow.The workflow may be accssed through this link'|trans)~':')|e('url')) ~ '%0D%0A%0D%0A' ~ link|e('url') }}"><i class="fa fa-envelope"></i></a>
|
||||
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
|
@@ -81,6 +81,15 @@
|
||||
</ul>
|
||||
{% endif %}
|
||||
|
||||
{% if entity_workflow.currentStep.destEmail|length > 0 %}
|
||||
<p><b>{{ 'workflow.An access key was also sent to those addresses'|trans }} :</b></p>
|
||||
<ul>
|
||||
{% for e in entity_workflow.currentStep.destEmail -%}
|
||||
<li><a href="mailto:{{ e|escape('html_attr') }}">{{ e }}</a></li>
|
||||
{%- endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
|
||||
{% if step.destUserByAccessKey|length > 0 %}
|
||||
<p><b>{{ 'workflow.Those users are also granted to apply a transition by using an access key'|trans }} :</b></p>
|
||||
<ul>
|
||||
|
@@ -190,8 +190,6 @@ class AuthorizationHelper implements AuthorizationHelperInterface
|
||||
/**
|
||||
* Return all reachable scope for a given user, center and role.
|
||||
*
|
||||
* @deprecated Use getReachableCircles
|
||||
*
|
||||
* @param Center|Center[] $center
|
||||
*
|
||||
* @return array|Scope[]
|
||||
|
@@ -27,6 +27,8 @@ class EntityWorkflowVoter extends Voter
|
||||
|
||||
public const SEE = 'CHILL_MAIN_WORKFLOW_SEE';
|
||||
|
||||
public const SHOW_ENTITY_LINK = 'CHILL_MAIN_WORKFLOW_LINK_SHOW';
|
||||
|
||||
private EntityWorkflowManager $manager;
|
||||
|
||||
private Security $security;
|
||||
@@ -80,6 +82,19 @@ class EntityWorkflowVoter extends Voter
|
||||
case self::DELETE:
|
||||
return $subject->getStep() === 'initial';
|
||||
|
||||
case self::SHOW_ENTITY_LINK:
|
||||
if ($subject->getStep() === 'initial') {
|
||||
return false;
|
||||
}
|
||||
|
||||
$currentStep = $subject->getCurrentStepChained();
|
||||
|
||||
if ($currentStep->isFinal()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $currentStep->getPrevious()->getTransitionBy() === $this->security->getUser();
|
||||
|
||||
default:
|
||||
throw new UnexpectedValueException("attribute {$attribute} not supported");
|
||||
}
|
||||
@@ -91,6 +106,7 @@ class EntityWorkflowVoter extends Voter
|
||||
self::SEE,
|
||||
self::CREATE,
|
||||
self::DELETE,
|
||||
self::SHOW_ENTITY_LINK,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@@ -11,6 +11,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\MainBundle\Service\Import;
|
||||
|
||||
use Exception;
|
||||
use League\Csv\Reader;
|
||||
use League\Csv\Statement;
|
||||
use RuntimeException;
|
||||
|
@@ -17,6 +17,7 @@ namespace Chill\MainBundle\Test;
|
||||
* **Usage : ** You must set up trait with `setUpTrait` before use
|
||||
* and use tearDownTrait after usage.
|
||||
*
|
||||
* @deprecated use @see{\Prophecy\PhpUnit\ProphecyTrait} instead
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
* @deprecated use @class{Prophecy\PhpUnit\ProphecyTrait} instead
|
||||
|
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DQL;
|
||||
|
||||
use Chill\MainBundle\Entity\Country;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @coversNothing
|
||||
*/
|
||||
final class JsonExtractTest extends KernelTestCase
|
||||
{
|
||||
private EntityManagerInterface $em;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
self::bootKernel();
|
||||
|
||||
$this->em = self::$container->get(EntityManagerInterface::class);
|
||||
}
|
||||
|
||||
public function dataGenerateDql(): iterable
|
||||
{
|
||||
yield ['SELECT JSON_EXTRACT(c.name, \'fr\') FROM ' . Country::class . ' c', []];
|
||||
|
||||
yield ['SELECT JSON_EXTRACT(c.name, :lang) FROM ' . Country::class . ' c', ['lang' => 'fr']];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider dataGenerateDql
|
||||
*/
|
||||
public function testJsonExtract(string $dql, array $args)
|
||||
{
|
||||
$results = $this->em->createQuery($dql)
|
||||
->setMaxResults(2)
|
||||
->setParameters($args)
|
||||
->getResult();
|
||||
|
||||
$this->assertIsArray($results, 'simply test that the query return a result');
|
||||
}
|
||||
}
|
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Form\Type;
|
||||
|
||||
use Chill\MainBundle\Entity\PostalCode;
|
||||
use Chill\MainBundle\Form\Type\DataTransformer\PostalCodeToIdTransformer;
|
||||
use Chill\MainBundle\Form\Type\PickPostalCodeType;
|
||||
use Chill\MainBundle\Repository\PostalCodeRepositoryInterface;
|
||||
use Prophecy\Argument;
|
||||
use Prophecy\PhpUnit\ProphecyTrait;
|
||||
use ReflectionClass;
|
||||
use Symfony\Component\Form\Extension\Core\Type\FormType;
|
||||
use Symfony\Component\Form\PreloadedExtension;
|
||||
use Symfony\Component\Form\Test\TypeTestCase;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @coversNothing
|
||||
*/
|
||||
final class PickPostalCodeTypeTest extends TypeTestCase
|
||||
{
|
||||
use ProphecyTrait;
|
||||
|
||||
public function testSubmitValidData(): void
|
||||
{
|
||||
$builder = $this->factory->createBuilder(FormType::class, ['postal_code' => null]);
|
||||
$builder->add('postal_code', PickPostalCodeType::class);
|
||||
$form = $builder->getForm();
|
||||
|
||||
$form->submit(['postal_code' => '1']);
|
||||
|
||||
$this->assertTrue($form->isSynchronized());
|
||||
|
||||
$this->assertEquals(1, $form['postal_code']->getData()->getId());
|
||||
}
|
||||
|
||||
protected function getExtensions()
|
||||
{
|
||||
$postalCodeRepository = $this->prophesize(PostalCodeRepositoryInterface::class);
|
||||
$postalCodeRepository->find(Argument::any())
|
||||
->will(static function ($args) {
|
||||
$postalCode = new PostalCode();
|
||||
$reflectionClass = new ReflectionClass($postalCode);
|
||||
$id = $reflectionClass->getProperty('id');
|
||||
$id->setAccessible(true);
|
||||
$id->setValue($postalCode, (int) $args[0]);
|
||||
|
||||
return $postalCode;
|
||||
});
|
||||
|
||||
$type = new PickPostalCodeType(
|
||||
new PostalCodeToIdTransformer(
|
||||
$postalCodeRepository->reveal()
|
||||
)
|
||||
);
|
||||
|
||||
return [
|
||||
new PreloadedExtension([$type], []),
|
||||
];
|
||||
}
|
||||
}
|
@@ -72,7 +72,7 @@ final class ValidPhonenumber extends ConstraintValidator
|
||||
}
|
||||
|
||||
if (false === $isValid) {
|
||||
$this->context->addViolation($message, ['%phonenumber%' => $value]);
|
||||
$this->context->addViolation($message, ['%phonenumber%' => $value, '%formatted%' => $this->phonenumberHelper->format($value)]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -70,6 +70,7 @@ module.exports = function(encore, entries)
|
||||
encore.addEntry('mod_entity_workflow_subscribe', __dirname + '/Resources/public/module/entity-workflow-subscribe/index.js');
|
||||
encore.addEntry('mod_entity_workflow_pick', __dirname + '/Resources/public/module/entity-workflow-pick/index.js');
|
||||
encore.addEntry('mod_wopi_link', __dirname + '/Resources/public/module/wopi-link/index.js');
|
||||
encore.addEntry('mod_pick_postal_code', __dirname + '/Resources/public/module/pick-postal-code/index.js');
|
||||
|
||||
// Vue entrypoints
|
||||
encore.addEntry('vue_address', __dirname + '/Resources/public/vuejs/Address/index.js');
|
||||
|
@@ -454,7 +454,6 @@ workflow:
|
||||
Delete workflow: Supprimer le workflow
|
||||
Steps is not waiting for transition. Maybe someone apply the transition before you ?: L'étape que vous cherchez a déjà été modifiée par un autre utilisateur. Peut-être quelqu'un a-t-il modifié cette étape avant vous ?
|
||||
You get access to this step: Vous avez acquis les droits pour appliquer une transition sur ce workflow.
|
||||
Those users are also granted to apply a transition by using an access key: Ces utilisateurs peuvent également valider cette étape, grâce à un lien d'accès
|
||||
dest by email: Liens d'autorisation par email
|
||||
dest by email help: Les adresses email mentionnées ici recevront un lien d'accès. Ce lien d'accès permettra à l'utilisateur de valider cette étape.
|
||||
Add an email: Ajouter une adresse email
|
||||
@@ -466,6 +465,11 @@ workflow:
|
||||
Previous workflow transitionned help: Workflows où vous avez exécuté une action.
|
||||
For: Pour
|
||||
You must select a next step, pick another decision if no next steps are available: Il faut une prochaine étape. Choissisez une autre décision si nécessaire.
|
||||
An access key was also sent to those addresses: Un lien d'accès a été envoyé à ces addresses
|
||||
Those users are also granted to apply a transition by using an access key: Ces utilisateurs ont obtennu l'accès grâce au lien reçu par email
|
||||
Access link copied: Lien d'accès copié
|
||||
This link grant any user to apply a transition: Le lien d'accès suivant permet d'appliquer une transition
|
||||
The workflow may be accssed through this link: Une transition peut être appliquée sur ce workflow grâce au lien d'accès suivant
|
||||
|
||||
|
||||
Subscribe final: Recevoir une notification à l'étape finale
|
||||
|
Reference in New Issue
Block a user