-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix labels, bugs and improve exit modal
- Fix labels pointing to correct field IDs - fix info modals opening after markup changes - Improve the exit modal + only show it when changes have happened
- Loading branch information
Showing
21 changed files
with
174 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
app/cells/decidim/plans/section_type_edit/field_text_multiline/show.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
const currentAllocationZero = () => { | ||
const $budgetSummary = $(".budget-summary__progressbox"); | ||
return parseInt($budgetSummary.attr("data-current-allocation"), 10) === 0; | ||
} | ||
|
||
const isSafeUrl = (exitUrl) => { | ||
if (!exitUrl) { | ||
return false | ||
} | ||
|
||
const safeUrls = []; | ||
|
||
let safe = false; | ||
safeUrls.forEach((url) => { | ||
if (exitUrl.startsWith(url)) { | ||
safe = true | ||
} | ||
}); | ||
|
||
return safe; | ||
} | ||
|
||
const allowExitFrom = ($el) => { | ||
if (currentAllocationZero()) { | ||
return true | ||
} else if ($el.attr("target") === "_blank") { | ||
return true; | ||
} else if ($el.hasClass("info-modal-link")) { | ||
return true; | ||
} else if ($el.attr("id") === "exit-notification-link") { | ||
return true; | ||
} else if ($el.parents("[data-reveal]").length > 0) { | ||
return true; | ||
} else if (isSafeUrl($el.attr("href"))) { | ||
return true | ||
} | ||
|
||
return false; | ||
} | ||
|
||
$(() => { | ||
const $exitNotification = $("#exit-notification"); | ||
const $exitLink = $("#exit-notification-link"); | ||
const defaultExitUrl = $exitLink.attr("href"); | ||
const defaultExitLinkText = $exitLink.text(); | ||
let exitLinkText = defaultExitLinkText; | ||
let formChanged = false; | ||
|
||
if ($exitNotification.length < 1) { | ||
// Do not apply when not inside the voting pipeline | ||
return; | ||
} | ||
|
||
const openExitNotification = (url, method = null) => { | ||
if (method && method !== "get") { | ||
$exitLink.attr("data-method", method); | ||
} else { | ||
$exitLink.removeAttr("data-method"); | ||
} | ||
|
||
$exitLink.attr("href", url); | ||
$exitLink.html(exitLinkText); | ||
$exitNotification.foundation("open"); | ||
}; | ||
|
||
$(document).on("click", "a", (event) => { | ||
exitLinkText = defaultExitLinkText; | ||
|
||
const $link = $(event.currentTarget); | ||
if (formChanged && !allowExitFrom($link)) { | ||
event.preventDefault(); | ||
openExitNotification($link.attr("href"), $link.data("method")); | ||
} | ||
}); | ||
|
||
$("input, textarea, select", ".plans-form").on("change", () => { | ||
formChanged = true; | ||
}); | ||
|
||
// Custom handling for the header sign out so that it won't trigger the | ||
// logout form submit and so that it changes the exit link text. This does | ||
// not trigger the document link click listener because it has the | ||
// data-method attribute to trigger a form submit event. | ||
$(".header a.sign-out-link").on("click", (event) => { | ||
event.preventDefault(); | ||
event.stopPropagation(); | ||
|
||
const $link = $(event.currentTarget); | ||
exitLinkText = $link.text(); | ||
openExitNotification($link.attr("href"), $link.data("method")); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<div class="reveal" data-reveal id="exit-notification" role="dialog" aria-modal="true" aria-labelledby="exit-notification-label" aria-live="polite"> | ||
<div class="reveal__header"> | ||
<h3 id="exit-notification-label" class="reveal__title"><%= t(".title") %></h3> | ||
<button class="close-button" data-close aria-label="<%= t(".close_modal") %>" type="button"> | ||
<span aria-hidden="true">×</span> | ||
</button> | ||
</div> | ||
<div class="static__content"> | ||
<p><%= t(".message") %></p> | ||
</div> | ||
|
||
<div class="buttons buttons-row"> | ||
<a href="<%= plans_path %>" id="exit-notification-link" class="button primary"> | ||
<%= t(".buttons.exit") %> | ||
</a> | ||
<button type="button" class="button primary hollow" data-close> | ||
<%= t(".buttons.cancel") %> | ||
</button> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.