Commit Graph

56 Commits

Author SHA1 Message Date
Andrew Nicols
6654ac1151 MDL-66312 js: Autocomplete promises were inside out
The pending promise should nott be resolved until the changes are
complete.
Previously the resolution of the pendingPromise was triggering the other
changes.
2019-08-16 11:40:16 +08:00
Shamim Rezaie
e75bf41538 MDL-63198 forms: click on scrollbar should not close the suggestions box 2019-08-05 13:13:45 +10:00
Ryan Wyllie
195ea4480b MDL-62497 javascript: build AMD modules with new transpiler 2019-07-19 14:12:49 +08:00
Mihail Geshoski
a6c735031a MDL-65751 lib: Replace deprecated jQuery functions 2019-07-17 09:59:44 +08:00
Shamim Rezaie
072a033a79 MDL-65102 core_form: autocomplete element to handle submit event 2019-03-27 19:00:27 +11:00
Huong Nguyen
efef2efdd6 MDL-63937 autocomplete: Add the indicator when processing the request 2019-02-21 10:08:16 +07:00
Andrew Nicols
e994dea0b3 MDL-62514 behat: Rewrite handling of autocomplete
This includes a minor restructure of the autocomplete JS to make use of
promises and improve tracking of pending JS.

In particular it improves the way in which throttled text input is
handled to ensure that the behat does not continue until:
- typing is fully complete; and
- all possible ajax requests have been sent; and
- all possible ajax requests complete; and
- the suggestions are updated.

A number of conditions existed where behat would move on to the next
step too early in a race condition effect between Behat and Autocomplete.
2019-01-30 08:24:32 +08:00
Mirko Otto
5cfd7a7286 MDL-62756 form: Remove any click handler first.
The handler has the old state variable. Remove any click handler first.
2018-12-14 10:26:58 +01:00
David Mudrák
5cdf8d49c7 MDL-62848 form: Fix missing support for {{#js}} helper in autocomplete
The form-autocomplete module uses three Mustache templates
core/form_autocomplete_input, core/form_autocomplete_suggestions and
core/form_autocomplete_selection. However, it did not support executing
the JS that is eventually part of those templates.
2018-08-31 14:51:05 +02:00
David Matamoros
18e2f40377 MDL-58409 core_form: needs clean in autocomplete element 2018-08-07 10:59:34 +02:00
David Mudrák
9411beb384 MDL-60874 core_form: allow autocomplete AJAX handlers return a string
Custom AJAX handlers for the form autocomplete fields can now optionally
return string in their processResults() callback. If a string is
returned, it is displayed instead of the list of suggested items.

The string is displayed same way as we inform about no available
suggestions.
2018-07-16 21:27:25 +02:00
sam marshall
a97c937033 MDL-61028 core_form: Autocomplete field to support HTML selection
When using the AJAX autocomplete field, it allows JavaScript to add
custom HTML to selected options. For example, the user field from
the assign roles page includes an icon and other information by the
user's name.

Once you submit the form and the page reloads, there was no way to
provide this information back to the autocomplete field. HTML
<option> tag was used for the value names but it may only contain
text, not tags, so including it in the normal value did not work.

This change adds a new option for the autocomplete field that lets
you include HTML to override the default (text-only) value of the
label used to represent each option.
2018-04-20 16:42:54 +01:00
Andrew Nicols
78162bf5cf MDL-60773 core: Add pendingJS checks for autocomplete interactions 2017-11-17 13:52:04 +08:00
Damyon Wiese
b7df2485e6 MDL-59867 autocomplete: Prevent duplicate ids.
Rendering a form with 2 autocompletes in it can get messed up because of duplicated ids.
2017-09-07 09:31:57 +08:00
Andrew Nicols
85419c5b2e Merge branch 'MDL-59828-master' of git://github.com/damyon/moodle 2017-08-29 11:56:28 +08:00
Damyon Wiese
d8e57f02a7 MDL-59828 autocomplete: Sizing issues on themes
We want to avoid page jumps wherever possible. This change uses the original select element as a "proxy" to reserve the space
in the DOM for the enhanced auto-complete when the JS runs.

It uses visibility: hidden to make the select not rendered - but still take up space.

The exact sizing for the CSS was determined by testing and reverse engineering the bootstrap calculations.

The size of user pictures in selectors was reduced to avoid flicker when switching between no selection and a selected user. I
could have reserved a larger amount of space, but it looks worse for pickers with no pictures.
2017-08-25 15:07:40 +08:00
Jun Pataleta
68a0485c5c MDL-59836 core_amd: Use only one input event handler
* We have duplicate input event handlers for the autocomplete element
which are both firing when the input element's value is being set.
In case an AJAX handler is defined for the autocomplete suggestions,
this causes the autocomplete suggestions so show "No suggestions" first
and then load the results from the AJAX handler a little bit later.
2017-08-18 11:19:08 +08:00
Jun Pataleta
198d72913f MDL-59366 core_amd: Modifications for form-autocomplete
* New optional parameter 'closeSuggestionsOnSelect' for the enhance()
function for form-autocomplete. Setting this to true will close the
suggestions popup immediately after an option has been selected. If not
specified, it defaults to true for single-select elements and false
for multiple-select elements.

Part of MDL-59290.
2017-07-28 16:11:38 +08:00
Damyon Wiese
ddc1482026 MDL-59527 autocomplete: Don't fetch ajax twice 2017-07-20 09:52:05 +08:00
David Monllao
7d04eaca5c Merge branch 'MDL-59527-master' of git://github.com/damyon/moodle 2017-07-17 14:07:59 +02:00
Damyon Wiese
47dd535097 MDL-59527 forms: Race cond with ajax autocomplete
Sometimes (rarely) the auto complete will show "No suggestions" when there are valid suggestions.
2017-07-14 12:41:14 +08:00
David Monllao
eac6f51590 Merge branch 'MDL-59368-master' of git://github.com/damyon/moodle 2017-07-12 16:46:49 +02:00
Damyon Wiese
f3ecea3af4 MDL-59368 groups: Peer review fixes
* Fix coalesce on postgres.
* The edit icon's alt shows the HTML entities causing
* enrol/tests/behat/add_to_group.feature Contains a '@doit' tag which I assume is there from testing.
* group/classes/output/user_groups_editable.php
** Missing MOODLE_INTERNAL check.
** Unused variables context_system and moodle_exception.
** The PHPDocs for the constructors are wrong.
** export_for_template() returns an array, not stdClass (according to parent docs).
** Change moodle_exception to coding_exception at the beginning.
* group/lib.php
** Missing docs for core_group_inplace_editable().
* user/classes/participants_table.php
** The docs for the class variables $groups, $course and $context need a '\' beforehand as they are in a namespace.
** I would prefer $this->context = $context; and $this->groups = ... to be done at the end of the constructor with the other class variable assignments.
** You could get rid of the class variable courseid if we are setting course and use $this->course->id instead.
** The function col_groups has @param \stdclass $row but it should be $data
* lib/amd/src/form-autocomplete.js and lib/amd/src/inplace_editable.js
** Some issues here CiBot has pointed out.
* lib/classes/output/inplace_editable.php
** @see should be on a new line.
2017-07-12 10:09:09 +08:00
Damyon Wiese
13426bae93 MDL-59368 inplace_editable: Focus on auto-complete
Also fix JS coding style and build the amd.
2017-07-12 10:07:58 +08:00
Damyon Wiese
786e014c5c MDL-59365 autocomplete: Keep the suggestions open
If the list allows multiple selections, don't auto-close the suggestions list
every time something is chosen.
2017-07-11 13:47:28 +01:00
Nadav Kavalerchik
e375029ea0 MDL-53349 Autocomplete: Support multi lingual COMMA keycode (44) 2017-02-01 16:00:41 +08:00
Dan Poltawski
9b62a3eb71 MDL-55048 js: rebuilt files with new version of uglifyjs 2016-07-11 15:53:10 +01:00
Dan Poltawski
7f70d548fe MDL-54939 amd: build modified files 2016-06-17 09:03:18 +01:00
Frederic Massart
1eaba735f5 MDL-53730 form: Autocomplete triggers change event on change only 2016-05-06 09:27:29 +08:00
Jun Pataleta
1388b618d9 MDL-53942 form_autocomplete: Properly set noSelectionString 2016-04-26 13:41:29 +08:00
Eloy Lafuente (stronk7)
11c673f3a3 Merge branch 'MDL-53167-master' of git://github.com/merrill-oakland/moodle 2016-04-12 21:34:41 +02:00
Dan Poltawski
5702a8289b Merge branch 'MDL-52954-master' of git://github.com/damyon/moodle 2016-04-11 09:52:40 +01:00
Eric Merrill
427e3cbcd6 MDL-53167 search: Add ability to limit courses searched 2016-04-07 14:41:59 -04:00
Damyon Wiese
bb690849c9 MDL-52954 assign: Rebuild the assignment single grade page. 2016-03-30 13:47:21 +08:00
Marina Glancy
eb97811bee MDL-52760 forms: notify form changes in autocomplete element 2016-03-18 08:16:55 +08:00
Damyon Wiese
6f326bd204 MDL-27628 enrol_meta: Use new multi-course selector
Allows adding multiple instances of the meta enrol plugin at once.

I had to add support to the autocomplete element for filling the field from behat
when it was not using tags. I also had to make the shortnames more easily searchable
and unique in the behat feature file.
2016-03-09 13:32:08 +08:00
Damyon Wiese
91ab264cf5 MDL-51324 forms: fix autocomplete element double selection bug
Incorrect types were preventing the currently selected values from
being removed from the new values returned via ajax.

Also fix a selection bug with autocomplete+ajax+singleselect.
2016-03-09 13:30:27 +08:00
Damyon Wiese
235ef57a3d MDL-51324 forms: Add a new course selector
This is a squashed commit containing a number of changes:

This is an ajax driven course selector that has searching etc. It can select single, or multiple courses.
Make course selector accept a list of courses to exclude
courseselector - lookup coursename on setValue
Use the get_course_display_name_in_list function to generate the course names
Add a throttle to auto-complete to reduce spamming the server
Do a single query to fetch all the courses in the mform element when validation fails
Fix core course search function to return results when there are less than 2 chars in the query.
Handle setData with an empty array in new course selector
2016-03-09 13:30:18 +08:00
Dan Poltawski
f992dcf6e8 MDL-52204 js: fix 'used before defined' errors
Newer versions of jshint detect this coding error, we fix it
by simply reordering the definition of methods.
2015-12-04 11:43:10 +00:00
Ryan Wyllie
e1db2b4112 MDL-52042 autocomplete: close suggestion box
Close the suggestion box when the input loses focus for more
than half a second.
2015-11-09 07:32:56 +00:00
Damyon Wiese
861c1dea98 MDL-51970 autocomplete: Fix for a regression in MDL-51964
This was causing the suggestions list to never open.
Picked up in testing for MDL-51970.
2015-11-04 16:29:47 +08:00
Damyon Wiese
273b255673 MDL-51970 autocomplete: Small refactor because too many options
Each function was taking 8-10 args - combine them all in state and options
objects and pass those around instead.
2015-11-02 10:22:53 +08:00
Damyon Wiese
97d2ea7f87 MDL-51970 autocomplete: Add an option to hide the suggestions
This is used by tags when official tags are disabled.
2015-11-02 10:21:57 +08:00
Damyon Wiese
be9b036a33 MDL-51964 autocomplete: IE11 fires spurious "input" events
We need to check for "real" changes to the input value because
ie11 is just firing events willy nilly.
2015-11-02 10:11:13 +08:00
Andrew Nicols
63a03a8b05 Merge branch 'wip-MDL-51966-master' of https://github.com/marinaglancy/moodle 2015-10-30 07:31:28 +08:00
Marina Glancy
ecbc2a2f25 MDL-51966 forms: case-insensitive search in autocomplete 2015-10-29 15:10:20 +08:00
Dan Poltawski
de342562cc Merge branch 'wip-MDL-51919-master' of git://github.com/abgreeve/moodle 2015-10-28 12:48:18 +00:00
Dan Poltawski
b2aaab60f3 Merge branch 'MDL-51838-master' of git://github.com/damyon/moodle 2015-10-28 11:53:53 +00:00
Adrian Greeve
527bde6e0f MDL-51919 forms lib: Autocomplete doesn't hide prematurely.
Quickly navigating via the keyboard to an autocomplete
element and hitting down would result in the selections
being displayed and then quickly removed. This has now
been fixed.
2015-10-28 14:15:26 +08:00
Adrian Greeve
d304952b43 MDL-51840 forms lib: keyboard navigation with ajax works.
Ajax autocomplete forms can now be navigated properly with
the keyboard.
2015-10-26 15:03:42 +08:00