Skip to content

Commit c96e4d3

Browse files
committed
Updated modal dialog. Spell corrections. Added PdfColumnTranslatorTrait.
1 parent b7ad382 commit c96e4d3

193 files changed

Lines changed: 768 additions & 641 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Ce programme est distribué avec une [licence propriétaire](LICENSE.md) et une
1616
[![PHP](https://img.shields.io/badge/PHP-8.2.16-informational?logo=php)](https://www.php.net)
1717
[![MySQL](https://img.shields.io/badge/MySQL-5.7.32-informational?logo=mysql)](https://www.mysql.com)
1818
[![Apache](https://img.shields.io/badge/Apache-2.4.51-informational?logo=apache)](https://httpd.apache.org)
19+
[![PhpStorm](https://img.shields.io/badge/PhpStorm-2024.1.1-informational?logo=phpstorm)](https://www.jetbrains.com/phpstorm)
1920

2021
## Qualité du code
2122

‎composer.lock‎

Lines changed: 16 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎public/js/extensions/bootstrap-table-extensions.js‎

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ function loadingTemplate(message) {
4444
}
4545

4646
/**
47-
* JQuery extension for Bootstrap tables, rows and cells.
47+
* JQuery extension for Bootstrap tables rows and cells.
4848
*/
4949
(function ($) {
5050
'use strict';
@@ -204,7 +204,7 @@ function loadingTemplate(message) {
204204

205205
// data?
206206
if (data.length !== 0) {
207-
// hide empty data message
207+
// hide the empty data message
208208
$this.hideCustomViewMessage();
209209
const params = $this.getParameters();
210210
const selector = '.custom-view-actions:eq(%index%)';
@@ -230,7 +230,7 @@ function loadingTemplate(message) {
230230
}
231231
$this.highlight();
232232
} else {
233-
// show empty data message
233+
// show the empty data message
234234
$this.showCustomViewMessage();
235235
}
236236
$this.saveParameters();
@@ -932,8 +932,26 @@ function loadingTemplate(message) {
932932
options = options ? options : $this.getOptions();
933933
pageNumber = pageNumber || options.pageNumber;
934934
const text = $('#modal-page').data('page');
935-
return text.replace('%page%', pageNumber)
936-
.replace('%pages%', options.totalPages);
935+
return text.replace('%page%', $.formatInt(pageNumber))
936+
.replace('%pages%', $.formatInt(options.totalPages));
937+
},
938+
939+
/**
940+
* Format the records range.
941+
*
942+
* @param {Options} [options] the options to get pages from.
943+
* @param {number} [pageNumber] the optional current page.
944+
*/
945+
formatRecords: function (options, pageNumber) {
946+
const $this = $(this);
947+
options = options ? options : $this.getOptions();
948+
pageNumber = pageNumber || options.pageNumber;
949+
const pageSize = options.pageSize;
950+
const record = Math.max(1 + (pageNumber - 1) * pageSize, 1);
951+
const records = Math.min(record + pageSize - 1, options.totalRows);
952+
const text = $('#modal-page').data('record');
953+
return text.replace('%record%', $.formatInt(record))
954+
.replace('%records%', $.formatInt(records));
937955
},
938956

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

949967
const $this = $(this);
950968
const $range = $('#page-range');
951-
const $label = $('#page-label');
969+
const $labelRecord = $('#page-record');
970+
const $labelLabel = $('#page-label');
952971
const $button = $('#page-button');
953972
$dialog.on('keydown', function (e) {
954973
if (e.key === 'Enter') {
@@ -982,9 +1001,12 @@ function loadingTemplate(message) {
9821001
}
9831002

9841003
$range.on('input', function () {
985-
const title = $this.formatPages($range.data('options'), $range.intVal());
1004+
const value = $range.intVal();
1005+
const title = $this.formatPages($range.data('options'), value);
1006+
const records = $this.formatRecords($range.data('options'), value);
9861007
$range.attr('title', title);
987-
$label.text(title);
1008+
$labelLabel.text(title);
1009+
$labelRecord.text(records);
9881010
});
9891011

9901012
$button.on('click', function () {

‎public/js/extensions/jquery-extensions.js‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@
4848
},
4949

5050
/**
51-
* Returns if the given data is a boolean.
51+
* Returns if the given data is boolean.
5252
*
5353
* @param {any} data - The data to evaluate.
54-
* @return {boolean} true if a boolean.
54+
* @return {boolean} true if boolean.
5555
*/
5656
isBoolean: function (data) {
5757
return typeof data === 'boolean';
@@ -102,7 +102,7 @@
102102
},
103103

104104
/**
105-
* Format a value with 0 decimal and grouping separator.
105+
* Format a value with 0 decimal and the grouping separator.
106106
*
107107
* @param {number} value - the value to format.
108108
* @returns {string} the formatted value.
@@ -145,7 +145,7 @@
145145
$.fn.extend({
146146

147147
/**
148-
* Check if the element is visible into area of the browser window.
148+
* Check if the element is visible into the area of the browser window.
149149
*
150150
* @param {int} bottomMargin - The bottom margin (default to 50).
151151
* @return {boolean} true if visible, false if not.
@@ -395,7 +395,7 @@
395395
return false;
396396
}
397397

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

522522
/**
523-
* Returns if the given attribute exist and is not false or null.
523+
* Returns if the given attribute exists and is not false or null.
524524
*
525525
* @param {string} name - the attribute name to check existence for.
526526
* @return {boolean} true if the attribute name is set.

‎src/Controller/AbstractController.php‎

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,6 @@ public function getAddressFrom(): Address
7979
return new Address($email, $name);
8080
}
8181

82-
/**
83-
* Gets the application service.
84-
*
85-
* @throws \LogicException if the service can not be found
86-
*/
87-
public function getApplication(): ApplicationService
88-
{
89-
return $this->getUserService()->getApplication();
90-
}
91-
9282
/**
9383
* Gets the application name and version.
9484
*/
@@ -105,18 +95,28 @@ public function getApplicationOwnerUrl(): string
10595
return $this->getParameterString('app_owner_url');
10696
}
10797

98+
/**
99+
* Gets the application service.
100+
*
101+
* @throws \LogicException if the service cannot be found
102+
*/
103+
public function getApplicationService(): ApplicationService
104+
{
105+
return $this->getUserService()->getApplication();
106+
}
107+
108108
/**
109109
* Gets the minimum margin, in percent, for a calculation.
110110
*/
111111
public function getMinMargin(): float
112112
{
113-
return $this->getApplication()->getMinMargin();
113+
return $this->getApplicationService()->getMinMargin();
114114
}
115115

116116
/**
117117
* Gets the request stack.
118118
*
119-
* @throws \LogicException if the service can not be found
119+
* @throws \LogicException if the service cannot be found
120120
*
121121
* @psalm-suppress MixedAssignment
122122
* @psalm-suppress MixedReturnStatement
@@ -137,17 +137,18 @@ public function getRequestStack(): RequestStack
137137

138138
public static function getSubscribedServices(): array
139139
{
140-
return \array_merge(parent::getSubscribedServices(), [
140+
return [
141+
...parent::getSubscribedServices(),
141142
UserService::class,
142143
TranslatorInterface::class,
143144
UrlGeneratorService::class,
144-
]);
145+
];
145146
}
146147

147148
/**
148149
* Gets the translator.
149150
*
150-
* @throws \LogicException if the service can not be found
151+
* @throws \LogicException if the service cannot be found
151152
*/
152153
public function getTranslator(): TranslatorInterface
153154
{
@@ -165,7 +166,7 @@ public function getTranslator(): TranslatorInterface
165166
/**
166167
* Gets the URL generator service.
167168
*
168-
* @throws \LogicException if the service can not be found
169+
* @throws \LogicException if the service cannot be found
169170
*/
170171
public function getUrlGenerator(): UrlGeneratorService
171172
{
@@ -193,7 +194,7 @@ public function getUserIdentifier(): ?string
193194
/**
194195
* Gets the user service.
195196
*
196-
* @throws \LogicException if the service can not be found
197+
* @throws \LogicException if the service cannot be found
197198
*/
198199
public function getUserService(): UserService
199200
{
@@ -209,7 +210,7 @@ public function getUserService(): UserService
209210
}
210211

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

318319
/**
319-
* Returns a Json response with false as result.
320+
* Returns a Json response with false as the result.
320321
*
321322
* @param array $data the data to merge within the response
322323
*/
@@ -326,7 +327,7 @@ protected function jsonFalse(array $data = []): JsonResponse
326327
}
327328

328329
/**
329-
* Returns a Json response with true as result.
330+
* Returns a Json response with true as the result.
330331
*
331332
* @param array $data the data to merge within the response
332333
*/

‎src/Controller/AbstractEntityController.php‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ protected function deleteEntity(
130130
}
131131

132132
/**
133-
* This function delete the given entity from the database.
133+
* This function deletes the given entity from the database.
134134
*
135135
* @psalm-param TEntity $item
136136
*/
@@ -286,9 +286,9 @@ protected function renderWordDocument(WordDocument $doc, bool $inline = true, st
286286
}
287287

288288
/**
289-
* This function save the given entity to the database.
289+
* This function saves the given entity to the database.
290290
*
291-
* Derived class can update entity before it is saved to the database.
291+
* Derived class can update the entity before it is saved to the database.
292292
*
293293
* @psalm-param TEntity $item
294294
*/

‎src/Controller/AdminController.php‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function clearCache(
6464
$form = $this->createForm(FormType::class);
6565
if ($this->handleRequestForm($request, $form)) {
6666
$this->getUserService()->clearCache();
67-
$this->getApplication()->clearCache();
67+
$this->getApplicationService()->clearCache();
6868

6969
try {
7070
if ($service->clear()) {
@@ -130,7 +130,7 @@ public function dumpSql(KernelInterface $kernel): Response
130130
#[GetPost(path: '/parameters', name: 'admin_parameters')]
131131
public function parameters(Request $request): Response
132132
{
133-
$application = $this->getApplication();
133+
$application = $this->getApplicationService();
134134
$data = $application->getProperties();
135135
$form = $this->createForm(ApplicationParametersType::class, $data);
136136
if ($this->handleRequestForm($request, $form)) {
@@ -156,7 +156,7 @@ public function parameters(Request $request): Response
156156
#[GetPost(path: '/rights/admin', name: 'admin_rights_admin')]
157157
public function rightsAdmin(Request $request, RoleBuilderService $service): Response
158158
{
159-
$application = $this->getApplication();
159+
$application = $this->getApplicationService();
160160
$roleName = RoleInterface::ROLE_ADMIN;
161161
$rights = $application->getAdminRights();
162162
$default = $service->getRoleAdmin();
@@ -171,7 +171,7 @@ public function rightsAdmin(Request $request, RoleBuilderService $service): Resp
171171
#[GetPost(path: '/rights/user', name: 'admin_rights_user')]
172172
public function rightsUser(Request $request, RoleBuilderService $service): Response
173173
{
174-
$application = $this->getApplication();
174+
$application = $this->getApplicationService();
175175
$roleName = RoleInterface::ROLE_USER;
176176
$rights = $application->getUserRights();
177177
$default = $service->getRoleUser();

‎src/Controller/AjaxCalculationController.php‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ public function renderTaskDialog(TaskRepository $repository): JsonResponse
6767

6868
/**
6969
* Update the total of a calculation.
70+
*
71+
* @throws \Doctrine\ORM\Exception\ORMException
7072
*/
7173
#[Post(path: '/update', name: 'ajax_update')]
7274
public function update(Request $request, CalculationService $service, LoggerInterface $logger): JsonResponse

0 commit comments

Comments
 (0)