Skip to content

Commit

Permalink
Updated modal dialog. Spell corrections. Added PdfColumnTranslatorTrait.
Browse files Browse the repository at this point in the history
  • Loading branch information
laurentmuller committed May 2, 2024
1 parent b7ad382 commit c96e4d3
Show file tree
Hide file tree
Showing 193 changed files with 768 additions and 641 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Ce programme est distribué avec une [licence propriétaire](LICENSE.md) et une
[![PHP](https://img.shields.io/badge/PHP-8.2.16-informational?logo=php)](https://www.php.net)
[![MySQL](https://img.shields.io/badge/MySQL-5.7.32-informational?logo=mysql)](https://www.mysql.com)
[![Apache](https://img.shields.io/badge/Apache-2.4.51-informational?logo=apache)](https://httpd.apache.org)
[![PhpStorm](https://img.shields.io/badge/PhpStorm-2024.1.1-informational?logo=phpstorm)](https://www.jetbrains.com/phpstorm)

## Qualité du code

Expand Down
27 changes: 16 additions & 11 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 30 additions & 8 deletions public/js/extensions/bootstrap-table-extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function loadingTemplate(message) {
}

/**
* JQuery extension for Bootstrap tables, rows and cells.
* JQuery extension for Bootstrap tables rows and cells.
*/
(function ($) {
'use strict';
Expand Down Expand Up @@ -204,7 +204,7 @@ function loadingTemplate(message) {

// data?
if (data.length !== 0) {
// hide empty data message
// hide the empty data message
$this.hideCustomViewMessage();
const params = $this.getParameters();
const selector = '.custom-view-actions:eq(%index%)';
Expand All @@ -230,7 +230,7 @@ function loadingTemplate(message) {
}
$this.highlight();
} else {
// show empty data message
// show the empty data message
$this.showCustomViewMessage();
}
$this.saveParameters();
Expand Down Expand Up @@ -932,8 +932,26 @@ function loadingTemplate(message) {
options = options ? options : $this.getOptions();
pageNumber = pageNumber || options.pageNumber;
const text = $('#modal-page').data('page');
return text.replace('%page%', pageNumber)
.replace('%pages%', options.totalPages);
return text.replace('%page%', $.formatInt(pageNumber))
.replace('%pages%', $.formatInt(options.totalPages));
},

/**
* Format the records range.
*
* @param {Options} [options] the options to get pages from.
* @param {number} [pageNumber] the optional current page.
*/
formatRecords: function (options, pageNumber) {
const $this = $(this);
options = options ? options : $this.getOptions();
pageNumber = pageNumber || options.pageNumber;
const pageSize = options.pageSize;
const record = Math.max(1 + (pageNumber - 1) * pageSize, 1);
const records = Math.min(record + pageSize - 1, options.totalRows);
const text = $('#modal-page').data('record');
return text.replace('%record%', $.formatInt(record))
.replace('%records%', $.formatInt(records));
},

/**
Expand All @@ -948,7 +966,8 @@ function loadingTemplate(message) {

const $this = $(this);
const $range = $('#page-range');
const $label = $('#page-label');
const $labelRecord = $('#page-record');
const $labelLabel = $('#page-label');
const $button = $('#page-button');
$dialog.on('keydown', function (e) {
if (e.key === 'Enter') {
Expand Down Expand Up @@ -982,9 +1001,12 @@ function loadingTemplate(message) {
}

$range.on('input', function () {
const title = $this.formatPages($range.data('options'), $range.intVal());
const value = $range.intVal();
const title = $this.formatPages($range.data('options'), value);
const records = $this.formatRecords($range.data('options'), value);
$range.attr('title', title);
$label.text(title);
$labelLabel.text(title);
$labelRecord.text(records);
});

$button.on('click', function () {
Expand Down
12 changes: 6 additions & 6 deletions public/js/extensions/jquery-extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@
},

/**
* Returns if the given data is a boolean.
* Returns if the given data is boolean.
*
* @param {any} data - The data to evaluate.
* @return {boolean} true if a boolean.
* @return {boolean} true if boolean.
*/
isBoolean: function (data) {
return typeof data === 'boolean';
Expand Down Expand Up @@ -102,7 +102,7 @@
},

/**
* Format a value with 0 decimal and grouping separator.
* Format a value with 0 decimal and the grouping separator.
*
* @param {number} value - the value to format.
* @returns {string} the formatted value.
Expand Down Expand Up @@ -145,7 +145,7 @@
$.fn.extend({

/**
* Check if the element is visible into area of the browser window.
* Check if the element is visible into the area of the browser window.
*
* @param {int} bottomMargin - The bottom margin (default to 50).
* @return {boolean} true if visible, false if not.
Expand Down Expand Up @@ -395,7 +395,7 @@
return false;
}

// check type (copied from accept method)
// check the type (copied from accept method)
let type = $(this).attr('accept') || false;
if (type) {
type = type.replace(/[\-\[\]\/\{\}\(\)\+\?\.\\\^\$\|]/g, '\\$&')
Expand Down Expand Up @@ -520,7 +520,7 @@
},

/**
* Returns if the given attribute exist and is not false or null.
* Returns if the given attribute exists and is not false or null.
*
* @param {string} name - the attribute name to check existence for.
* @return {boolean} true if the attribute name is set.
Expand Down
41 changes: 21 additions & 20 deletions src/Controller/AbstractController.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,6 @@ public function getAddressFrom(): Address
return new Address($email, $name);
}

/**
* Gets the application service.
*
* @throws \LogicException if the service can not be found
*/
public function getApplication(): ApplicationService
{
return $this->getUserService()->getApplication();
}

/**
* Gets the application name and version.
*/
Expand All @@ -105,18 +95,28 @@ public function getApplicationOwnerUrl(): string
return $this->getParameterString('app_owner_url');
}

/**
* Gets the application service.
*
* @throws \LogicException if the service cannot be found
*/
public function getApplicationService(): ApplicationService
{
return $this->getUserService()->getApplication();
}

/**
* Gets the minimum margin, in percent, for a calculation.
*/
public function getMinMargin(): float
{
return $this->getApplication()->getMinMargin();
return $this->getApplicationService()->getMinMargin();
}

/**
* Gets the request stack.
*
* @throws \LogicException if the service can not be found
* @throws \LogicException if the service cannot be found
*
* @psalm-suppress MixedAssignment
* @psalm-suppress MixedReturnStatement
Expand All @@ -137,17 +137,18 @@ public function getRequestStack(): RequestStack

public static function getSubscribedServices(): array
{
return \array_merge(parent::getSubscribedServices(), [
return [
...parent::getSubscribedServices(),
UserService::class,
TranslatorInterface::class,
UrlGeneratorService::class,
]);
];
}

/**
* Gets the translator.
*
* @throws \LogicException if the service can not be found
* @throws \LogicException if the service cannot be found
*/
public function getTranslator(): TranslatorInterface
{
Expand All @@ -165,7 +166,7 @@ public function getTranslator(): TranslatorInterface
/**
* Gets the URL generator service.
*
* @throws \LogicException if the service can not be found
* @throws \LogicException if the service cannot be found
*/
public function getUrlGenerator(): UrlGeneratorService
{
Expand Down Expand Up @@ -193,7 +194,7 @@ public function getUserIdentifier(): ?string
/**
* Gets the user service.
*
* @throws \LogicException if the service can not be found
* @throws \LogicException if the service cannot be found
*/
public function getUserService(): UserService
{
Expand All @@ -209,7 +210,7 @@ public function getUserService(): UserService
}

/**
* Display a message, if not empty; and redirect to the home page.
* Display a message, if not empty, and redirect to the home page.
*
* If the request is not null, and the caller parameter is set, redirect to it.
*/
Expand Down Expand Up @@ -316,7 +317,7 @@ protected function jsonException(\Exception $e, ?string $message = null): JsonRe
}

/**
* Returns a Json response with false as result.
* Returns a Json response with false as the result.
*
* @param array $data the data to merge within the response
*/
Expand All @@ -326,7 +327,7 @@ protected function jsonFalse(array $data = []): JsonResponse
}

/**
* Returns a Json response with true as result.
* Returns a Json response with true as the result.
*
* @param array $data the data to merge within the response
*/
Expand Down
6 changes: 3 additions & 3 deletions src/Controller/AbstractEntityController.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ protected function deleteEntity(
}

/**
* This function delete the given entity from the database.
* This function deletes the given entity from the database.
*
* @psalm-param TEntity $item
*/
Expand Down Expand Up @@ -286,9 +286,9 @@ protected function renderWordDocument(WordDocument $doc, bool $inline = true, st
}

/**
* This function save the given entity to the database.
* This function saves the given entity to the database.
*
* Derived class can update entity before it is saved to the database.
* Derived class can update the entity before it is saved to the database.
*
* @psalm-param TEntity $item
*/
Expand Down
8 changes: 4 additions & 4 deletions src/Controller/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function clearCache(
$form = $this->createForm(FormType::class);
if ($this->handleRequestForm($request, $form)) {
$this->getUserService()->clearCache();
$this->getApplication()->clearCache();
$this->getApplicationService()->clearCache();

try {
if ($service->clear()) {
Expand Down Expand Up @@ -130,7 +130,7 @@ public function dumpSql(KernelInterface $kernel): Response
#[GetPost(path: '/parameters', name: 'admin_parameters')]
public function parameters(Request $request): Response
{
$application = $this->getApplication();
$application = $this->getApplicationService();
$data = $application->getProperties();
$form = $this->createForm(ApplicationParametersType::class, $data);
if ($this->handleRequestForm($request, $form)) {
Expand All @@ -156,7 +156,7 @@ public function parameters(Request $request): Response
#[GetPost(path: '/rights/admin', name: 'admin_rights_admin')]
public function rightsAdmin(Request $request, RoleBuilderService $service): Response
{
$application = $this->getApplication();
$application = $this->getApplicationService();
$roleName = RoleInterface::ROLE_ADMIN;
$rights = $application->getAdminRights();
$default = $service->getRoleAdmin();
Expand All @@ -171,7 +171,7 @@ public function rightsAdmin(Request $request, RoleBuilderService $service): Resp
#[GetPost(path: '/rights/user', name: 'admin_rights_user')]
public function rightsUser(Request $request, RoleBuilderService $service): Response
{
$application = $this->getApplication();
$application = $this->getApplicationService();
$roleName = RoleInterface::ROLE_USER;
$rights = $application->getUserRights();
$default = $service->getRoleUser();
Expand Down
2 changes: 2 additions & 0 deletions src/Controller/AjaxCalculationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ public function renderTaskDialog(TaskRepository $repository): JsonResponse

/**
* Update the total of a calculation.
*
* @throws \Doctrine\ORM\Exception\ORMException
*/
#[Post(path: '/update', name: 'ajax_update')]
public function update(Request $request, CalculationService $service, LoggerInterface $logger): JsonResponse
Expand Down
Loading

0 comments on commit c96e4d3

Please sign in to comment.