Skip to content

Commit

Permalink
fix: removing duplicate lines in the code
Browse files Browse the repository at this point in the history
  • Loading branch information
rsdeus committed Oct 16, 2024
1 parent a6ae46c commit 2517005
Showing 1 changed file with 23 additions and 25 deletions.
48 changes: 23 additions & 25 deletions decidim-core/app/packs/src/decidim/append_redirect_url_to_modals.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,32 +53,30 @@ $(() => {
}

$(document).on("click.zf.trigger", (event) => {
$(document).on("click.zf.trigger", (event) => {
// Try to get the <a> directly or find the closest parent <a>
let $target = $(event.target);
if (!$target.is('a')) {
$target = $target.closest('a'); // Find the closest parent <a> if the click is not directly on an <a>
}

// Check if an <a> was found
if ($target.length) {
const dialogTarget = `#${$target.data("dialog-open")}`;
const redirectUrl = $target.data("redirectUrl");

if (dialogTarget && redirectUrl) {
$("<input type='hidden' />")
.attr("id", "redirect_url")
.attr("name", "redirect_url")
.attr("value", redirectUrl)
.appendTo(`${dialogTarget} form`);

$(`${dialogTarget} a`).attr("href", (index, href) => {
const querystring = jQuery.param({"redirect_url": redirectUrl});
return href + (href.match(/\?/) ? "&" : "?") + querystring;
});
}
// Try to get the <a> directly or find the closest parent <a>
let $target = $(event.target);
if (!$target.is('a')) {

Check failure on line 58 in decidim-core/app/packs/src/decidim/append_redirect_url_to_modals.js

View workflow job for this annotation

GitHub Actions / Lint code (npm run lint)

Strings must use doublequote
$target = $target.closest('a'); // Find the closest parent <a> if the click is not directly on an <a>

Check failure on line 59 in decidim-core/app/packs/src/decidim/append_redirect_url_to_modals.js

View workflow job for this annotation

GitHub Actions / Lint code (npm run lint)

Strings must use doublequote

Check failure on line 59 in decidim-core/app/packs/src/decidim/append_redirect_url_to_modals.js

View workflow job for this annotation

GitHub Actions / Lint code (npm run lint)

Expected comment to be above code

Check failure on line 59 in decidim-core/app/packs/src/decidim/append_redirect_url_to_modals.js

View workflow job for this annotation

GitHub Actions / Lint code (npm run lint)

Unexpected comment inline with code
}

// Check if an <a> was found
if ($target.length) {
const dialogTarget = `#${$target.data("dialog-open")}`;
const redirectUrl = $target.data("redirectUrl");

if (dialogTarget && redirectUrl) {
$("<input type='hidden' />")
.attr("id", "redirect_url")

Check failure on line 69 in decidim-core/app/packs/src/decidim/append_redirect_url_to_modals.js

View workflow job for this annotation

GitHub Actions / Lint code (npm run lint)

Expected dot to be on same line as object
.attr("name", "redirect_url")

Check failure on line 70 in decidim-core/app/packs/src/decidim/append_redirect_url_to_modals.js

View workflow job for this annotation

GitHub Actions / Lint code (npm run lint)

Expected dot to be on same line as object
.attr("value", redirectUrl)

Check failure on line 71 in decidim-core/app/packs/src/decidim/append_redirect_url_to_modals.js

View workflow job for this annotation

GitHub Actions / Lint code (npm run lint)

Expected dot to be on same line as object
.appendTo(`${dialogTarget} form`);

Check failure on line 72 in decidim-core/app/packs/src/decidim/append_redirect_url_to_modals.js

View workflow job for this annotation

GitHub Actions / Lint code (npm run lint)

Expected dot to be on same line as object

$(`${dialogTarget} a`).attr("href", (index, href) => {
const querystring = jQuery.param({"redirect_url": redirectUrl});

Check failure on line 75 in decidim-core/app/packs/src/decidim/append_redirect_url_to_modals.js

View workflow job for this annotation

GitHub Actions / Lint code (npm run lint)

Expected indentation of 10 spaces but found 12
return href + (href.match(/\?/) ? "&" : "?") + querystring;

Check failure on line 76 in decidim-core/app/packs/src/decidim/append_redirect_url_to_modals.js

View workflow job for this annotation

GitHub Actions / Lint code (npm run lint)

Expected indentation of 10 spaces but found 12
});
}
});
}
});

$(document).on("closed.zf.reveal", (event) => {
Expand Down

0 comments on commit 2517005

Please sign in to comment.