Extension:Page Forms/Select2 for autocompletion/Progress Report

Switching Semantic Forms Autocompletion to Select2
 Public URL:  https://www.mediawiki.org/wiki/User:Jatin.me/GSoC14  Bugzilla report: Bug 61974 Announcement:  http://lists.wikimedia.org/pipermail/wikitech-l/2014-March/075276.html Status:  https://www.mediawiki.org/wiki/Extension:Semantic_Forms/Select2_for_autocompletion/Progress_Report

Goals for the first half of the internship

 * Introducing the Select2 JS library to the current autocompletion system of Semantic Forms. Having discussed it with my mentors, we have decided to do this in conjunction with the jQuery UI Autocomplete which is used currently in SF for autocompletion.
 * Making 'combobox' input type in SF use this new Select2 library for autocompletion and see if everything works fine with this.
 * Make remote autocompletion work for combobox input type.
 * Switching the #forminput parser function which also supports autocompletion, on possible page names to use Select2 as well - and probably switch it to a combo box interface, for consistency.
 * Switching 'Semantic property' field in Special:CreateTemplate page also to Select2 combobox.

Communication plan

 * Email - I will keep mentor updated about the progress.
 * Skype and gtalk - Skype and gtalk have been my primary means of communication with mentors.
 * IRC Channel - I also go on the #semantic-mediawiki channel during the working hours.
 * Mailing list - semediawiki-user mailing list will be used to communicate progress.

Lessons learned since 21st April

 * Report to your mentors regularly about the progress of the project because mentors will help in rectifying flaws, which you may not notice, before its too late.
 * Do not make things complex, keep them easy and simple.
 * Prioritize tasks to be done and focus on important deliverables.
 * Discussions and feedback make thing better.

Week 1: 19 May to 25 May

 * I dove into the Semantic Forms code for autocompletion, got myself familiar with it and understood how this all works. Here are some of the related files:
 * Included the stuff related to Select2 JS library into the SF extension.
 * Included the stuff related to Select2 JS library into the SF extension.
 * Included the stuff related to Select2 JS library into the SF extension.
 * Included the stuff related to Select2 JS library into the SF extension.
 * Included the stuff related to Select2 JS library into the SF extension.
 * Included the stuff related to Select2 JS library into the SF extension.
 * Included the stuff related to Select2 JS library into the SF extension.
 * Included the stuff related to Select2 JS library into the SF extension.
 * Included the stuff related to Select2 JS library into the SF extension.
 * Included the stuff related to Select2 JS library into the SF extension.
 * Included the stuff related to Select2 JS library into the SF extension.
 * Included the stuff related to Select2 JS library into the SF extension.
 * Included the stuff related to Select2 JS library into the SF extension.
 * Tested if the Select2 library is successfully included and working fine with SF.
 * Started working on making 'combobox' input type use Select2 for autocompletion.

Week 2: 26 May to 1 June
Combo box using Select2 for autocompletion|none]]
 * Tested 'combobox' using Select2 for autocompletion.[[File:ComboSelect2.png|link=https://www.mediawiki.org/wiki/Extension:Semantic_Forms/Select2_for_autocompletion/File:ComboSelect2.png|thumb|160x160px|


 * Added a new attribute 'placeholder' to 'combobox'.
 * Started working on remote autocompletion for combobox.
 * Learnt Modular Javascript and started writing JS modules for making combobox use Select2 for autocompletion. I also wrote a small blog about Modular JS (see here).

Week 3: 2 June to 8 June

 * Completed module for autocompletion of combobox from local values.
 * Understood how Select2 does remote autocompletion and tried to integrate it to the module of combobox for autocompletion.
 * Integration successful, now combobox can do remote autocompletion if 'remote autocompletion' parameter is specified in the field tag.
 * Worked on the 'values from url' parameter for the combobox, now values for autocompletion can also be fetched from outside the wiki (other wikis or some other external url).

Week 4: 9 June to 15 June

 * Started working on switching  to Select2 for autocompletion.
 * Found some bugs in the existing code of in   function. It produces some weird outputs when some parameters are not given in specific order. This problem is occurring due to the support for unnamed parameters by.
 * Having discussed with my mentor, we have decided to get rid of these unnamed parameters and remove its support by the #forminput.
 * We also discussed about removing 'remote autocompletion' parameter and letting code SF decide itself whether to do local or remote autocompletion based on the number of values for autocompletion, if there are more than a certain number of values, which is settable via, then switch to remote autocompletion.
 * Working on the above two points discussed with the mentors.

Week 5: 16 June to 22 June

 * Removed support for unnamed parameters by.
 * Made 'remote autocompletion' parameter optional. Introduced a global variable  which is settable via , this variable will decide when to switch to remote autocompletion and when to keep it local.
 * Switched 'Semantic property' field in page to Select2 combobox.
 * Worked on making 'values dependent on' parameter supported by new Select2 combobox.

Week 6: 23 June to 29 June

 * Completed GSoC mid term evaluation.


 * Restored the support of unnamed parameters by, because removing them would break some wikis.
 * Also, removed Select2 combobox for, because that added two more steps for creating a new page with the form.
 * 'values dependent on' parameter is now fully supported by the combobox.
 * Submitted the final patch for Select2 combobox.

Week 7: 30 June to 6 July

 * Started working on adding a new input type - tokens, this input type can be used wherever multiple values are allowed.
 * Changed the structure of Select2 files for autocompletion by introducing a new base class that has some basic properties which can be inherited and extended by combobox and tokens.
 * Worked on a unified solution for making 'values dependent on' parameter supported by tokens and combobox,.
 * Found some issues with existing 'dependent field' autocompletion, like for same substring many calls were made to the API, this slowed down the forms.

Week 8: 7 July to 13 July

 * Fixed the issue of SF making more than 1 API calls for a single substring in the case of 'dependent field'.
 * Introduced new input type 'Tokens' with basic functionality.
 * Made the values in "tokens" re-arrangable, using drag-and-drop; this is done using jQuery UI's sortable.
 * Solved an issue with the handling of "values dependent on" - it wasn't working correctly when editing an existing page.
 * Solved an issue with combobox input, it only autocomplete on the first letter of the whole string, not the first letter of every word.

Week 9: 14 July to 20 July

 * Added accent-folding functionality for characters with accent - it doesn’t matter whether users searches for cafe, café or even çåFé; the results will be the same.
 * Submitted the final patch for Select2 tokens.
 * Started working on displaying additional data like thumbnail image and description along with autocomplete values in combobox and tokens.
 * After a lot of discussion with the mentor, we came up with a solution that requires involving External Data(ED) extension to fetch data from any url and use that data to display the results. The fact that we are using ED is because it supports a large number of formats like JSON, CSV, XML and data from LDAP or databases.

Week 10: 21 July to 27 July

 * Worked on integrating feature for displaying additional data in autocompletion for a field of input type combobox.
 * Introduced new parameters -  ,    and    to be used while autocompleting on external data.
 * Integration successful, now values fetched using ED extension can be used for autocompletion :). patch

Week 11: 28 July to 3 August

 * Extended autocompletion on external data to tokens input type, now it can also autocomplete on values fetched using ED. patch
 * Solved some minor bugs related to external data autocompletion - If in the values fetched using ED has a field for images and instead of full image URL only image name is retrieved, then it will search local wiki for its full URL.

Week 12: 4 August to 10 August

 * Reviewed the code and solved minor bugs related to the new functionalities added. patch
 * Worked on general clean up of javascript code - made SF javascript files pass JSHint test.

Week 13: 11 August to 18 August

 * Worked on documentation and other minor bugs.