diff --git a/checklistapi.drush.inc b/checklistapi.drush.inc index 038191d..790a453 100644 --- a/checklistapi.drush.inc +++ b/checklistapi.drush.inc @@ -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(). diff --git a/checklistapi.install b/checklistapi.install index ceb0815..3e6f64a 100644 --- a/checklistapi.install +++ b/checklistapi.install @@ -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. diff --git a/checklistapi.js b/checklistapi.js index 888bdda..e2ce45e 100644 --- a/checklistapi.js +++ b/checklistapi.js @@ -1,18 +1,17 @@ (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; diff --git a/checklistapi.module b/checklistapi.module index f2b1beb..0624f97 100644 --- a/checklistapi.module +++ b/checklistapi.module @@ -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) { diff --git a/checklistapiexample/checklistapiexample.info.yml b/checklistapiexample/checklistapiexample.info.yml index d358889..6e885ec 100644 --- a/checklistapiexample/checklistapiexample.info.yml +++ b/checklistapiexample/checklistapiexample.info.yml @@ -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 diff --git a/src/ChecklistapiChecklist.php b/src/ChecklistapiChecklist.php index 7d96716..ba76dda 100644 --- a/src/ChecklistapiChecklist.php +++ b/src/ChecklistapiChecklist.php @@ -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() { diff --git a/src/Controller/ChecklistapiController.php b/src/Controller/ChecklistapiController.php index c4b8255..93f391c 100644 --- a/src/Controller/ChecklistapiController.php +++ b/src/Controller/ChecklistapiController.php @@ -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; diff --git a/src/Form/ChecklistapiChecklistClearForm.php b/src/Form/ChecklistapiChecklistClearForm.php index 59a85e5..d51d3a5 100644 --- a/src/Form/ChecklistapiChecklistClearForm.php +++ b/src/Form/ChecklistapiChecklistClearForm.php @@ -80,4 +80,5 @@ class ChecklistapiChecklistClearForm extends ConfirmFormBase { // Redirect back to checklist. $form_state->setRedirect($form['#checklist']->getRouteName()); } + } diff --git a/src/Form/ChecklistapiChecklistForm.php b/src/Form/ChecklistapiChecklistForm.php index 7b22148..2424e63 100644 --- a/src/Form/ChecklistapiChecklistForm.php +++ b/src/Form/ChecklistapiChecklistForm.php @@ -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; /**