-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5430 from dodona-edu/enhance/search-action-discov…
…erability Make search actions and options more discoverable
- Loading branch information
Showing
26 changed files
with
298 additions
and
271 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import { customElement, property } from "lit/decorators.js"; | ||
import { DodonaElement } from "components/meta/dodona_element"; | ||
import { searchQueryState } from "state/SearchQuery"; | ||
import { html, TemplateResult } from "lit"; | ||
import { i18n } from "i18n/i18n"; | ||
|
||
export type Option = {param: string, label: string}; | ||
|
||
/** | ||
* This component represents a boolean option for search using a checkbox | ||
* The checkbox tracks whether the search option is curently active | ||
* | ||
* @element d-search-option | ||
* | ||
* @prop {string} param - the name of the search parameter | ||
* @prop {string} label - the label to be displayed next to the checkbox | ||
*/ | ||
@customElement("d-search-option") | ||
export class SearchOption extends DodonaElement { | ||
@property({ type: String }) | ||
param = ""; | ||
@property({ type: String }) | ||
label = ""; | ||
|
||
get active(): boolean { | ||
return searchQueryState.queryParams.get(this.param) !== undefined; | ||
} | ||
|
||
toggle(): void { | ||
if (this.active) { | ||
searchQueryState.queryParams.set(this.param, undefined); | ||
} else { | ||
searchQueryState.queryParams.set(this.param, "true"); | ||
} | ||
} | ||
|
||
render(): TemplateResult { | ||
return html` | ||
<div class="form-check"> | ||
<input | ||
class="form-check-input" | ||
type="checkbox" | ||
.checked=${this.active} | ||
@click="${() => this.toggle()}" | ||
id="check-${this.param}" | ||
> | ||
<label class="form-check-label" for="check-${this.param}"> | ||
${this.label} | ||
</label> | ||
</div> | ||
`; | ||
} | ||
} | ||
|
||
/** | ||
* This component represents a list op boolean options for search | ||
* The options are displayed in a dropdown | ||
* | ||
* @element d-search-options | ||
* | ||
* @prop {Option[]} options - the list of options to be displayed | ||
*/ | ||
@customElement("d-search-options") | ||
export class SearchOptions extends DodonaElement { | ||
@property({ type: Array }) | ||
options: Option[] = []; | ||
|
||
render(): TemplateResult { | ||
if (this.options.length === 0) { | ||
return html``; | ||
} | ||
|
||
return html` | ||
<div class="dropdown"> | ||
<a class="btn btn-icon dropdown-toggle" data-bs-toggle="dropdown"> | ||
<i class="mdi mdi-dots-vertical"></i> | ||
</a> | ||
<ul class="dropdown-menu dropdown-menu-end"> | ||
${this.options.map(o => html` | ||
<li><span class="dropdown-item-text "> | ||
<d-search-option param="${o.param}" label="${o.label}"></d-search-option> | ||
</span></li> | ||
`)} | ||
</ul> | ||
</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
Oops, something went wrong.