Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🧹 Add HedySelect custom element #5540

Merged
merged 49 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
212a35b
adding dropdown class
jpelay May 15, 2024
3b74de4
replace dropdowns in customize adventure with hedy dropdowns
jpelay May 16, 2024
4884c6f
refactor some functions
jpelay May 16, 2024
bfc5e4b
fix some errors
jpelay May 16, 2024
72afa72
adding templates to their own file
jpelay May 16, 2024
ec082f4
generic arrow movement
jpelay May 16, 2024
5486f35
move select to their own file
jpelay May 16, 2024
dcd957b
for some reason it doesnt work in the custom elements file
jpelay May 16, 2024
73bf4db
test select in public adventures
jpelay May 16, 2024
1950c53
adding default label
jpelay May 20, 2024
b92137d
Merge branch 'main' into generic-dropdown
jpelay May 20, 2024
077f51c
🤖 Automatically update generated files
jpelay May 20, 2024
84e53c5
change selects of public adventures
jpelay May 20, 2024
8079e66
Merge branch 'generic-dropdown' of https://github.com/hedyorg/hedy in…
jpelay May 20, 2024
04aaeff
🤖 Automatically update generated files
jpelay May 20, 2024
464d82e
export from custom elements file
jpelay May 21, 2024
ac437de
🤖 Automatically update generated files
jpelay May 21, 2024
c8f6f01
change name of element and remove inner select
jpelay May 21, 2024
12d1f8d
Merge branch 'generic-dropdown' of https://github.com/hedyorg/hedy in…
jpelay May 21, 2024
a8faabb
🤖 Automatically update generated files
jpelay May 21, 2024
1b2df46
fix tests
jpelay Jun 13, 2024
ef93027
🤖 Automatically update generated files
jpelay Jun 13, 2024
b6c48e7
Merge branch main into class overview redesign
jpelay Jun 13, 2024
bbfb166
Merge branch 'generic-dropdown' of https://github.com/hedyorg/hedy in…
jpelay Jun 13, 2024
19762ad
🤖 Automatically update generated files
jpelay Jun 13, 2024
4c69249
fix public adventures
jpelay Jun 19, 2024
c253a3b
Merge branch 'main' into generic-dropdown
jpelay Jun 19, 2024
503ef8b
fix tests
jpelay Jun 19, 2024
31a76a3
close dropdowns when clicking outside
jpelay Jul 17, 2024
95485f0
replace explore page filters
jpelay Jul 17, 2024
4e1071b
🤖 Automatically update generated files
jpelay Jul 17, 2024
1822e37
add translation for level error
jpelay Jul 17, 2024
2ad551b
Merge branch 'generic-dropdown' of https://github.com/hedyorg/hedy in…
jpelay Jul 17, 2024
f6822db
Merge branch 'main' into generic-dropdown
jpelay Jul 18, 2024
656bae3
fix merge
jpelay Jul 18, 2024
2335deb
🤖 Automatically update generated files
jpelay Jul 18, 2024
a772d24
style adventure page a bit better
jpelay Jul 18, 2024
9d9820c
Merge branch 'main' into generic-dropdown
jpelay Jul 18, 2024
a4cdaff
🤖 Automatically update generated files
jpelay Jul 18, 2024
570341f
fix cypress tests
jpelay Jul 19, 2024
4895c91
fix translations
jpelay Jul 19, 2024
c012d18
🤖 Automatically update generated files
jpelay Jul 19, 2024
8237308
Merge branch 'main' into generic-dropdown
jpelay Jul 30, 2024
8bf516c
🤖 Automatically update generated files
jpelay Jul 30, 2024
b7926f8
fixed translations files
jpelay Jul 30, 2024
318b8bc
🤖 Automatically update generated files
jpelay Jul 30, 2024
cfd858a
Update messages.po
jpelay Jul 30, 2024
e0fac2e
🤖 Automatically update generated files
jpelay Jul 30, 2024
404683b
Merge branch 'main' into generic-dropdown
mergify[bot] Jul 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix tests
  • Loading branch information
jpelay committed Jun 13, 2024
commit 1b2df4645d7852396b0a7bc32985f257533186d1
3 changes: 2 additions & 1 deletion static/js/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@ export function initializeApp(options: InitializeAppOptions) {

// All input elements with data-autosubmit="true" automatically submit their enclosing form
$('*[data-autosubmit="true"]').on('change', (ev) => {
$(ev.target).closest('form').trigger('submit');
const form = ev.target.closest('form') as HTMLFormElement
form['trigger']('submit');
});

initializeLoginLinks();
Expand Down
4 changes: 3 additions & 1 deletion static/js/appbundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -104656,7 +104656,9 @@ def note_with_error(value, err):
});
});
$('*[data-autosubmit="true"]').on("change", (ev) => {
$(ev.target).closest("form").trigger("submit");
const form = ev.target.closest("form");
console.log(form.elements);
form["trigger"]("submit");
});
initializeLoginLinks();
initializeActivity();
Expand Down
4 changes: 2 additions & 2 deletions static/js/appbundle.js.map

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions templates/explore.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,24 @@
</div>
</form>
</div>
<div class="w-full mb-4" id="program_filter">
<form method="GET">
<div class="flex flex-row px-4 w-full items-center border border-gray-400 py-2 rounded-lg gap-4">
<custom-select name="adventure" id="explore_page_adventure" data-autosubmit="true" class="w-2/3" data-type="single">
<option hidden {% if not filtered_adventure %} selected{% endif %} value="">&mdash; {{ _('adventure') }} &mdash;</option>
{% for adventure_key, name in adventures_names.items() %}
<option hidden value="{{ adventure_key }}" {% if adventure_key == filtered_adventure %}selected{% endif %}>{{ name }}</option>
{% endfor %}
</custom-select>
<custom-select name="level" id="explore_page_level" data-autosubmit="true" class="w-1/3" data-type="single">
<option hidden {% if not filtered_adventure %}selected{% endif %} value="">&mdash; {{_('level')}} &mdash;</option>
{% for i in range(1, (max_level + 1)) %}
<option hidden value="{{ i }}" {% if filtered_level and i|string == filtered_level %}selected{% endif %}>{{ i }}</option>
{% endfor %}
</custom-select>
</div>
</form>
</div>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • still see the old dropdowns
  • if i click on the option in the new select custom elements, the filtering isn't reflected on the ui
    image

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, thanks for pointing this out! Fixed it with HTMX 😄

<!-- Only show our selected favourites when not filtering -->
{% if not filtered_level and not filtered_adventure and favourite_programs %}
<div class="border rounded-lg border-yellow-500 mb-4 py-2">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ describe('Levels Dropdown Select test', () => {
goToEditAdventure();

// Tests level field interaction
cy.get("#level_select")
cy.get("#levels_dropdown")
.should('be.visible')
.should('not.be.disabled')
.click()

cy.get(`#levels_dropdown > div.option[data-value="${level}"]`)
cy.get(`#levels_dropdown > div > div > div.option[data-value="${level}"`)
.click()

cy.get(`#levels_dropdown > div.option[data-value="${level}"]`)
cy.get(`#levels_dropdown > div > div > div.option[data-value="${level}"`)
.should('have.class', 'selected')
})
}
Expand Down
14 changes: 7 additions & 7 deletions tests/cypress/e2e/public_adventures/public_adventures.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ describe("Able to browse all public adventures and use filters", () => {
});

it("should have level 1 as the default one", () => {
cy.get("#level-select").should('have.attr', 'data-value', '1')
cy.get("#level-select > div > div > div.option.selected").should('have.attr', 'data-value', '1')
})

it("should be able to filter by levels", () => {
cy.get("#level-select")
.click()

cy.get('#level_dropdown').should('be.visible');
cy.get('#level-select > div > div.dropdown-menu').should('be.visible');

cy.get("#adventures").should("contain.text", "adventure1")
cy.get("#adventures").should("contain.text", "adventure2")
cy.get("#level_dropdown .option[data-value='2']")
cy.get("#level-select > div > div > div.option[data-value='2']")
.click()

cy.get("#adventures").should("contain.text", "adventure1")
Expand All @@ -30,11 +30,11 @@ describe("Able to browse all public adventures and use filters", () => {
cy.get("#language-select")
.click()

cy.get('#lang_dropdown').should('be.visible');
cy.get('#language-select > div > div.dropdown-menu').should('be.visible');

cy.get("#adventures").should("contain.text", "adventure1")
cy.get("#adventures").should("contain.text", "adventure2")
cy.get("#lang_dropdown .option[data-value='en']")
cy.get("#language-select > div > div > div.option[data-value='English']")
.click()

cy.get("#adventures").should("contain.text", "adventure1")
Expand All @@ -45,11 +45,11 @@ describe("Able to browse all public adventures and use filters", () => {
cy.get("#tag-select")
.click()

cy.get('#tags_dropdown').should('be.visible');
cy.get('#tag-select > div > div.dropdown-menu').should('be.visible');

cy.get("#adventures").should("contain.text", "adventure1")
cy.get("#adventures").should("contain.text", "adventure2")
cy.get("#tags_dropdown .option[data-value='test']")
cy.get("#tag-select > div > div.dropdown-menu > .option[data-value='test']")
.click()

cy.get("#adventures").should("contain.text", "adventure1")
Expand Down
Loading