Commit 9b95b6dd authored by tibezh's avatar tibezh Committed by TravisCarden

Issue #2942220 by tibezh: Conding standards

parent edfa0309
......@@ -5,8 +5,8 @@
* Drush commands for the Checklist API module.
*/
use \Drupal\Core\Render\Element;
use \Drupal\user\Entity\User;
use Drupal\Core\Render\Element;
use Drupal\user\Entity\User;
/**
* Implements hook_drush_command().
......
......@@ -5,8 +5,8 @@
* Install, update, and uninstall functions for the Checklist API module.
*/
use \Drupal\Core\Render\Element;
use \Drupal\checklistapi\ChecklistapiChecklist;
use Drupal\Core\Render\Element;
use Drupal\checklistapi\ChecklistapiChecklist;
/**
* Update saved progress configuration to new schema.
......
(function ($) {
"use strict";
/**
* Updates the progress bar as checkboxes are changed.
*/
Drupal.behaviors.checklistapiUpdateProgressBar = {
attach: function (context) {
var total_items = $(':checkbox.checklistapi-item', context).length,
progress_bar = $('#checklistapi-checklist-form .progress__bar', context),
progress_percentage = $('#checklistapi-checklist-form .progress__percentage', context);
var total_items = $(':checkbox.checklistapi-item', context).length;
var progress_bar = $('#checklistapi-checklist-form .progress__bar', context);
var progress_percentage = $('#checklistapi-checklist-form .progress__percentage', context);
$(':checkbox.checklistapi-item', context).change(function () {
var num_items_checked = $(':checkbox.checklistapi-item:checked', context).length,
percent_complete = Math.round(num_items_checked / total_items * 100),
args = {};
var num_items_checked = $(':checkbox.checklistapi-item:checked', context).length;
var percent_complete = Math.round(num_items_checked / total_items * 100);
var args = {};
progress_bar.css('width', percent_complete + '%');
args['@complete'] = num_items_checked;
args['@total'] = total_items;
......@@ -28,8 +27,8 @@
Drupal.behaviors.checklistapiFieldsetSummaries = {
attach: function (context) {
$('#checklistapi-checklist-form .vertical-tabs__panes > details', context).drupalSetSummary(function (context) {
var total = $(':checkbox.checklistapi-item', context).length,
args = {};
var total = $(':checkbox.checklistapi-item', context).length;
var args = {};
if (total) {
args['@complete'] = $(':checkbox.checklistapi-item:checked', context).length;
args['@total'] = total;
......
......@@ -48,7 +48,7 @@ function checklistapi_checklist_access($id, $operation = 'any') {
* @param string $id
* The checklist ID.
*
* @return ChecklistapiChecklist|false
* @return Drupal\checklistapi\ChecklistapiChecklist|false
* A fully-loaded checklist object, or FALSE if the checklist is not found.
*/
function checklistapi_checklist_load($id) {
......
......@@ -4,5 +4,5 @@ description: Provides an example implementation of the Checklist API.
package: Example modules
core: 8.x
dependencies:
- checklistapi
- drupal:checklistapi
configure: checklistapi.checklists.example_checklist
......@@ -203,7 +203,7 @@ class ChecklistapiChecklist {
/**
* Gets the checklist form URL.
*
* @return Url
* @return \Drupal\Core\Url
* The URL to the checklist form.
*/
public function getUrl() {
......
......@@ -19,20 +19,20 @@ class ChecklistapiController extends ControllerBase {
public function report() {
// Define table header.
$header = [
['data' => t('Checklist')],
['data' => $this->t('Checklist')],
[
'data' => t('Progress'),
'data' => $this->t('Progress'),
'class' => [RESPONSIVE_PRIORITY_MEDIUM],
],
[
'data' => t('Last updated'),
'data' => $this->t('Last updated'),
'class' => [RESPONSIVE_PRIORITY_MEDIUM],
],
[
'data' => t('Last updated by'),
'data' => $this->t('Last updated by'),
'class' => [RESPONSIVE_PRIORITY_LOW],
],
['data' => t('Operations')],
['data' => $this->t('Operations')],
];
// Build table rows.
......@@ -41,11 +41,12 @@ class ChecklistapiController extends ControllerBase {
foreach ($definitions as $id => $definition) {
$checklist = checklistapi_checklist_load($id);
$row = [];
$row[] = [
'data' => ($checklist->userHasAccess()) ? \Drupal::l($checklist->title, $checklist->getUrl()) : drupal_placeholder($checklist->title),
'data' => ($checklist->userHasAccess()) ? $this->l($checklist->title, $checklist->getUrl()) : drupal_placeholder($checklist->title),
'title' => (!empty($checklist->description)) ? $checklist->description : '',
];
$row[] = t('@completed of @total (@percent%)', [
$row[] = $this->t('@completed of @total (@percent%)', [
'@completed' => $checklist->getNumberCompleted(),
'@total' => $checklist->getNumberOfItems(),
'@percent' => round($checklist->getPercentComplete()),
......@@ -58,7 +59,7 @@ class ChecklistapiController extends ControllerBase {
'#type' => 'operations',
'#links' => [
'clear' => [
'title' => t('Clear'),
'title' => $this->t('Clear'),
'url' => Url::fromRoute($checklist->getRouteName() . '.clear', [], [
'query' => $this->getDestinationArray(),
]),
......@@ -78,7 +79,7 @@ class ChecklistapiController extends ControllerBase {
'#theme' => 'table',
'#header' => $header,
'#rows' => $rows,
'#empty' => t('No checklists available.'),
'#empty' => $this->t('No checklists available.'),
];
return $output;
......
......@@ -80,4 +80,5 @@ class ChecklistapiChecklistClearForm extends ConfirmFormBase {
// Redirect back to checklist.
$form_state->setRedirect($form['#checklist']->getRouteName());
}
}
......@@ -6,7 +6,6 @@ use Drupal\Component\Utility\Xss;
use Drupal\Core\Form\FormInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Render\Element;
use Drupal\Core\Url;
use Drupal\user\Entity\User;
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment