Skip to content
Permalink
Browse files

Merge pull request #15859 from jolelievre/clickable-row

Add clickable row option for grid actions
  • Loading branch information
matks committed Oct 11, 2019
2 parents 9e8b598 + b7ecc51 commit 0d202a6ae182ebe9d96de7e172b1856fe208e209
Showing with 175 additions and 147 deletions.
  1. +42 −0 admin-dev/themes/new-theme/js/components/grid/extension/link-row-action-extension.js
  2. +1 −0 admin-dev/themes/new-theme/js/pages/cms-page/index.js
  3. +2 −0 admin-dev/themes/new-theme/js/pages/currency/index.js
  4. +2 −0 admin-dev/themes/new-theme/js/pages/employee/index.js
  5. +2 −0 admin-dev/themes/new-theme/js/pages/manufacturer/index.js
  6. +2 −0 admin-dev/themes/new-theme/js/pages/supplier/index.js
  7. +2 −0 admin-dev/themes/new-theme/js/pages/tax/index.js
  8. +2 −0 admin-dev/themes/new-theme/js/pages/webservice/index.js
  9. +2 −2 admin-dev/themes/new-theme/public/backup.bundle.js
  10. +11 −11 admin-dev/themes/new-theme/public/category.bundle.js
  11. +6 −6 admin-dev/themes/new-theme/public/cms_page.bundle.js
  12. +3 −3 admin-dev/themes/new-theme/public/contacts.bundle.js
  13. +26 −2 admin-dev/themes/new-theme/public/currency.bundle.js
  14. +3 −3 admin-dev/themes/new-theme/public/customer.bundle.js
  15. +2 −26 admin-dev/themes/new-theme/public/employee.bundle.js
  16. +3 −3 admin-dev/themes/new-theme/public/language.bundle.js
  17. +4 −28 admin-dev/themes/new-theme/public/manufacturer.bundle.js
  18. +4 −4 admin-dev/themes/new-theme/public/meta.bundle.js
  19. +3 −3 admin-dev/themes/new-theme/public/profiles.bundle.js
  20. +2 −2 admin-dev/themes/new-theme/public/sql_manager.bundle.js
  21. +26 −2 admin-dev/themes/new-theme/public/supplier.bundle.js
  22. +2 −26 admin-dev/themes/new-theme/public/tax.bundle.js
  23. +2 −26 admin-dev/themes/new-theme/public/webservice.bundle.js
  24. +2 −0 src/Core/Grid/Action/Row/Type/LinkRowAction.php
  25. +1 −0 src/Core/Grid/Definition/Factory/BackupDefinitionFactory.php
  26. +2 −0 src/Core/Grid/Definition/Factory/CategoryGridDefinitionFactory.php
  27. +1 −0 src/Core/Grid/Definition/Factory/CmsPageCategoryDefinitionFactory.php
  28. +1 −0 src/Core/Grid/Definition/Factory/CmsPageDefinitionFactory.php
  29. +1 −0 src/Core/Grid/Definition/Factory/ContactGridDefinitionFactory.php
  30. +1 −0 src/Core/Grid/Definition/Factory/CurrencyGridDefinitionFactory.php
  31. +1 −0 src/Core/Grid/Definition/Factory/CustomerGridDefinitionFactory.php
  32. +1 −0 src/Core/Grid/Definition/Factory/EmployeeGridDefinitionFactory.php
  33. +1 −0 src/Core/Grid/Definition/Factory/LanguageGridDefinitionFactory.php
  34. +1 −0 src/Core/Grid/Definition/Factory/ManufacturerAddressGridDefinitionFactory.php
  35. +1 −0 src/Core/Grid/Definition/Factory/ManufacturerGridDefinitionFactory.php
  36. +1 −0 src/Core/Grid/Definition/Factory/MetaGridDefinitionFactory.php
  37. +1 −0 src/Core/Grid/Definition/Factory/ProfileGridDefinitionFactory.php
  38. +1 −0 src/Core/Grid/Definition/Factory/RequestSqlGridDefinitionFactory.php
  39. +1 −0 src/Core/Grid/Definition/Factory/SupplierGridDefinitionFactory.php
  40. +1 −0 src/Core/Grid/Definition/Factory/TaxGridDefinitionFactory.php
  41. +1 −0 src/Core/Grid/Definition/Factory/WebserviceKeyDefinitionFactory.php
  42. +1 −0 src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Actions/Row/link.html.twig
@@ -35,6 +35,16 @@ export default class LinkRowActionExtension {
* @param {Grid} grid
*/
extend(grid) {
this.initRowLinks(grid);
this.initConfirmableActions(grid);
}

/**
* Extend grid
*
* @param {Grid} grid
*/
initConfirmableActions(grid) {
grid.getContainer().on('click', '.js-link-row-action', (event) => {
const confirmMessage = $(event.currentTarget).data('confirm-message');

@@ -43,4 +53,36 @@ export default class LinkRowActionExtension {
}
});
}

/**
* Add a click event on rows that matches the first link action (if present)
*
* @param {Grid} grid
*/
initRowLinks(grid) {
$('tr', grid.getContainer()).each(function initEachRow() {
const $parentRow = $(this);

$('.js-link-row-action[data-clickable-row=1]:first', $parentRow).each(function propagateFirstLinkAction() {
const $rowAction = $(this);
const $parentCell = $rowAction.closest('td');

/*
* Only search for cells with non clickable contents to avoid conflicts with
* previous cell behaviour (action, toggle, ...)
*/
const clickableCells = $('td.data-type, td.identifier-type, td.badge-type, td.position-type', $parentRow)
.not($parentCell)
;

clickableCells.addClass('cursor-pointer').click(() => {
const confirmMessage = $rowAction.data('confirm-message');

if (!confirmMessage.length || confirm(confirmMessage)) {
document.location = $rowAction.attr('href');
}
});
});
});
}
}
@@ -87,6 +87,7 @@ $(() => {
cmsGrid.addExtension(new SubmitBulkExtension());
cmsGrid.addExtension(new SubmitRowActionExtension());
cmsGrid.addExtension(new PositionExtension());
cmsGrid.addExtension(new LinkRowActionExtension());

const helperBlock = new ShowcaseCard('cms-pages-showcase-card');
helperBlock.addExtension(new ShowcaseCardCloseExtension());
@@ -31,6 +31,7 @@ import ColumnTogglingExtension from '../../components/grid/extension/column-togg
import SubmitRowActionExtension from '../../components/grid/extension/action/row/submit-row-action-extension';
import ChoiceTree from '../../components/form/choice-tree';
import ExchangeRatesUpdateScheduler from './ExchangeRatesUpdateScheduler';
import LinkRowActionExtension from '../../components/grid/extension/link-row-action-extension';

const $ = window.$;

@@ -41,6 +42,7 @@ $(() => {
currency.addExtension(new ReloadListActionExtension());
currency.addExtension(new ColumnTogglingExtension());
currency.addExtension(new SubmitRowActionExtension());
currency.addExtension(new LinkRowActionExtension());

const choiceTree = new ChoiceTree('#currency_shop_association');
choiceTree.enableAutoCheckChildren();
@@ -34,6 +34,7 @@ import SubmitRowActionExtension from '../../components/grid/extension/action/row
import ColumnTogglingExtension from '../../components/grid/extension/column-toggling-extension';
import ShowcaseCard from '../../components/showcase-card/showcase-card';
import ShowcaseCardCloseExtension from '../../components/showcase-card/extension/showcase-card-close-extension';
import LinkRowActionExtension from '../../components/grid/extension/link-row-action-extension';

const $ = window.$;

@@ -48,6 +49,7 @@ $(() => {
employeeGrid.addExtension(new SubmitBulkActionExtension());
employeeGrid.addExtension(new SubmitRowActionExtension());
employeeGrid.addExtension(new ColumnTogglingExtension());
employeeGrid.addExtension(new LinkRowActionExtension());

const showcaseCard = new ShowcaseCard('employeesShowcaseCard');
showcaseCard.addExtension(new ShowcaseCardCloseExtension());
@@ -38,6 +38,7 @@ import ExportToSqlManagerExtension from '../../components/grid/extension/export-
import ChoiceTree from '../../components/form/choice-tree';
import TranslatableField from '../../components/translatable-field';
import TinyMCEEditor from '../../components/tinymce-editor';
import LinkRowActionExtension from '../../components/grid/extension/link-row-action-extension';

const $ = window.$;

@@ -52,6 +53,7 @@ $(() => {
grid.addExtension(new SubmitRowActionExtension());
grid.addExtension(new SubmitBulkExtension());
grid.addExtension(new BulkActionCheckboxExtension());
grid.addExtension(new LinkRowActionExtension());
});

new TranslatableInput();
@@ -33,6 +33,7 @@ import BulkActionCheckboxExtension from "../../components/grid/extension/bulk-ac
import SubmitBulkActionExtension from "../../components/grid/extension/submit-bulk-action-extension";
import ReloadListExtension from "../../components/grid/extension/reload-list-extension";
import ExportToSqlManagerExtension from "../../components/grid/extension/export-to-sql-manager-extension";
import LinkRowActionExtension from '../../components/grid/extension/link-row-action-extension';

const $ = window.$;

@@ -47,4 +48,5 @@ $(() => {
supplierGrid.addExtension(new SubmitBulkActionExtension());
supplierGrid.addExtension(new ReloadListExtension());
supplierGrid.addExtension(new ExportToSqlManagerExtension());
supplierGrid.addExtension(new LinkRowActionExtension());
});
@@ -34,6 +34,7 @@ import BulkActionCheckboxExtension from '../../components/grid/extension/bulk-ac
import ExportToSqlManagerExtension from '../../components/grid/extension/export-to-sql-manager-extension';
import DisplayInCartOptionHandler from './display-in-cart-option-handler';
import TranslatableInput from '../../components/translatable-input';
import LinkRowActionExtension from '../../components/grid/extension/link-row-action-extension';

const $ = window.$;

@@ -48,6 +49,7 @@ $(() => {
taxGrid.addExtension(new SubmitRowActionExtension());
taxGrid.addExtension(new SubmitBulkExtension());
taxGrid.addExtension(new BulkActionCheckboxExtension());
taxGrid.addExtension(new LinkRowActionExtension());
new DisplayInCartOptionHandler();
new TranslatableInput();
});
@@ -36,6 +36,7 @@ import ChoiceTree from "../../components/form/choice-tree";
import GeneratableInput from "../../components/generatable-input";
import MultipleChoiceTable from "../../components/multiple-choice-table";
import PermissionsRowSelector from "./permissions-row-selector";
import LinkRowActionExtension from '../../components/grid/extension/link-row-action-extension';

const $ = window.$;

@@ -50,6 +51,7 @@ $(() => {
webserviceGrid.addExtension(new SubmitBulkActionExtension());
webserviceGrid.addExtension(new SubmitRowActionExtension());
webserviceGrid.addExtension(new BulkActionCheckboxExtension());
webserviceGrid.addExtension(new LinkRowActionExtension());

// needed for shop association input in form
new ChoiceTree('#webservice_key_shop_association').enableAutoCheckChildren();

Some generated files are not rendered by default. Learn more.

0 comments on commit 0d202a6

Please sign in to comment.
You can’t perform that action at this time.