Skip to content

Commit f020c77

Browse files
author
Guy Brand
committed
(chore): update readme and release notes for the 0.3.3 release
1 parent c94a2e1 commit f020c77

File tree

2 files changed

+89
-38
lines changed

2 files changed

+89
-38
lines changed

README.md

+74-35
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ ion-autocomplete
77

88
> Configurable Ionic directive for an autocomplete dropdown.
99
10+
:warning: Please follow the [Guidelines to report an issue](#guidelines-to-report-an-issue)
11+
1012
#Table of contents
1113

1214
- [Demo](#demo)
@@ -35,9 +37,12 @@ ion-autocomplete
3537
- [Template data](#template-data)
3638
- [Loading icon](#loading-icon)
3739
- [Manage externally](#manage-externally)
40+
- [Selected items](#selected-items)
41+
- [Clear on select](#clear-on-select)
3842
- [Using expressions in value keys](#using-expressions-in-value-keys)
3943
- [Debouncing](#debouncing)
4044
- [Usage inside an Ionic modal](#usage-inside-an-ionic-modal)
45+
- [Guidelines to report an issue](#guidelines-to-report-an-issue)
4146
- [Release notes](#release-notes)
4247
- [Acknowledgements](#acknowledgements)
4348
- [License](#license)
@@ -103,7 +108,7 @@ To use the `ion-autocomplete` directive in single select mode you need set the `
103108
<input ion-autocomplete type="text" readonly="readonly" class="ion-autocomplete" autocomplete="off" max-selected-items="1" />
104109
```
105110

106-
If you want to use it in multiple select mode you do not need to add anything special, just the following snippet to your template:
111+
If you want to use it in multiple select mode you do not need to add anything special, just the following snippet to your template:
107112
```html
108113
//usage with the attribute restriction
109114
<input ion-autocomplete type="text" readonly="readonly" class="ion-autocomplete" autocomplete="off" />
@@ -291,25 +296,31 @@ You are able to set the `max-selected-items` attribute to any number to set the
291296
<input ion-autocomplete type="text" readonly="readonly" class="ion-autocomplete" autocomplete="off" ng-model="model" max-selected-items="3" />
292297
```
293298

294-
Then the user is just able to select three items out of the returned items and also delete them again. The given `ng-model` is an
299+
Then the user is just able to select three items out of the returned items and also delete them again. The given `ng-model` is an
295300
array if multiple items are selected.
296301

302+
You can also set a scope variable instead of a fixed value such that you can dynamically change the `max-selected-items` property according to your
303+
requirements.
304+
297305
### The `items-clicked-method`
298306

299-
You are able to pass a function to the `items-clicked-method` attribute to be notified when an item is clicked. The name of the
307+
You are able to pass a function to the `items-clicked-method` attribute to be notified when an item is clicked. The name of the
300308
parameter of the function must be `callback`. Here is an example:
301309

302310
Define the callback in your scope:
303311
```javascript
304312
$scope.clickedMethod = function (callback) {
305313
// print out the selected item
306-
console.log(callback.item);
307-
314+
console.log(callback.item);
315+
308316
// print out the component id
309317
console.log(callback.componentId);
310-
318+
311319
// print out the selected items if the multiple select flag is set to true and multiple elements are selected
312-
console.log(callback.selectedItems);
320+
console.log(callback.selectedItems);
321+
322+
// print out the selected items as an array
323+
console.log(callback.selectedItemsArray);
313324
}
314325
```
315326

@@ -322,7 +333,7 @@ Then you get a callback object with the clicked/selected item and the selected i
322333

323334
### The `items-removed-method`
324335

325-
You are able to pass a function to the `items-removed-method` attribute to be notified when an item is removed from a multi-select list. The name of the
336+
You are able to pass a function to the `items-removed-method` attribute to be notified when an item is removed from a multi-select list. The name of the
326337
parameter of the function must be `callback`. It is similar to items-clicked-method. This attribute has no defined behaviour for a single select list.
327338

328339
Here is an example:
@@ -331,13 +342,16 @@ Define the callback in your scope:
331342
```javascript
332343
$scope.removedMethod = function (callback) {
333344
// print out the removed item
334-
console.log(callback.item);
345+
console.log(callback.item);
335346

336347
// print out the component id
337348
console.log(callback.componentId);
338-
349+
339350
// print out the selected items
340-
console.log(callback.selectedItems);
351+
console.log(callback.selectedItems);
352+
353+
// print out the selected items as an array
354+
console.log(callback.selectedItemsArray);
341355
}
342356
```
343357

@@ -350,16 +364,16 @@ Then you get a callback object with the removed item and the selected items.
350364

351365
### External model
352366

353-
The two way binded external model (`external-model` attribute on the component) is used to prepopulate the selected items with the model value. The [`model-to-item-method`](#the-model-to-item-method) is used to get the view item to the model and then the item is selected in the
354-
component. Be aware that the `external-model` is not updated by the component when an item is selected. It is just used to prepopulate or clear the selected items. If you need to get the current selected items you are able
367+
The two way binded external model (`external-model` attribute on the component) is used to prepopulate the selected items with the model value. The [`model-to-item-method`](#the-model-to-item-method) is used to get the view item to the model and then the item is selected in the
368+
component. Be aware that the `external-model` is not updated by the component when an item is selected. It is just used to prepopulate or clear the selected items. If you need to get the current selected items you are able
355369
to read the value of the `ng-model`. For an example have a look at the [`model-to-item-method`](#the-model-to-item-method) documentation.
356370

357371
If you need to clear the selected items then you are able to set the `external-model` to an empty array (another value is not clearing the selected items).
358372

359373
### The `model-to-item-method`
360374

361-
This method is used if you want to prepopulate the model of the `ion-autocomplete` component. The [external model](#external-model) needs
362-
to have the same data as it would have when you select the items by hand. The component then takes the model values
375+
This method is used if you want to prepopulate the model of the `ion-autocomplete` component. The [external model](#external-model) needs
376+
to have the same data as it would have when you select the items by hand. The component then takes the model values
363377
and calls the specified `model-to-item-method` to resolve the item from the back end and select it such that it is preselected.
364378

365379
Here a small example:
@@ -368,7 +382,7 @@ Define the `model-to-item-method` and `external-model` in your scope:
368382
```javascript
369383
$scope.modelToItemMethod = function (modelValue) {
370384

371-
// get the full model item from the model value and return it. You need to implement the `getModelItem` method by yourself
385+
// get the full model item from the model value and return it. You need to implement the `getModelItem` method by yourself
372386
// as this is just a sample. The method needs to retrieve the whole item (like the `items-method`) from just the model value.
373387
var modelItem = getModelItem(modelValue);
374388
return modelItem;
@@ -392,17 +406,20 @@ Note that the parameter for the `model-to-item-method` needs to be named `modelV
392406

393407
### The `cancel-button-clicked-method` (same as done button)
394408

395-
You are able to pass a function to the `cancel-button-clicked-method` attribute to be notified when the cancel/done button is clicked to close the modal. The name of the
409+
You are able to pass a function to the `cancel-button-clicked-method` attribute to be notified when the cancel/done button is clicked to close the modal. The name of the
396410
parameter of the function must be `callback`. Here is an example:
397411

398412
Define the callback in your scope:
399413
```javascript
400-
$scope.cancelButtonClickedMethod = function (callback) {
414+
$scope.cancelButtonClickedMethod = function (callback) {
401415
// print out the component id
402416
console.log(callback.componentId);
403-
417+
404418
// print out the selected items
405-
console.log(callback.selectedItems);
419+
console.log(callback.selectedItems);
420+
421+
// print out the selected items as an array
422+
console.log(callback.selectedItemsArray);
406423
}
407424
```
408425

@@ -415,15 +432,15 @@ Then you get a callback object with the selected items and the component id.
415432

416433
### Component Id
417434

418-
The component id is an attribute on the `ion-autocomplete` component which sets a given id to the component. This id is then returned in
435+
The component id is an attribute on the `ion-autocomplete` component which sets a given id to the component. This id is then returned in
419436
the callback object of the [`items-clicked-method`](#the-items-clicked-method) and as a second parameter of the [`items-method`](#the-items-method).
420437
Here an example:
421438
```html
422439
<input ion-autocomplete type="text" readonly="readonly" class="ion-autocomplete" autocomplete="off" ng-model="model" component-id="component1" />`
423440
```
424441

425-
You are able to set this is on each component if you have multiple components built up in a ng-repeat where you do not want to have multiple `items-method`
426-
for each component because you want to display other items in each component. You will also get it in the `items-clicked-method` callback object such that you just
442+
You are able to set this is on each component if you have multiple components built up in a ng-repeat where you do not want to have multiple `items-method`
443+
for each component because you want to display other items in each component. You will also get it in the `items-clicked-method` callback object such that you just
427444
need to define one callback method and you can distinguish the calls with the `componentId` attribute right inside the method.
428445

429446
### Placeholder
@@ -462,13 +479,13 @@ You are also able to set an own template for the autocomplete component (default
462479
<input ion-autocomplete type="text" readonly="readonly" class="ion-autocomplete" autocomplete="off" ng-model="model" template-url="templates/template.html" />`
463480
```
464481

465-
This way you are able to override the default template (the `template` variable [here](https://github.com/guylabs/ion-autocomplete/blob/master/src/ion-autocomplete.js#L68))
482+
This way you are able to override the default template (the `template` variable [here](https://github.com/guylabs/ion-autocomplete/blob/master/src/ion-autocomplete.js#L68))
466483
and use your own template. The component will use the default template if the `template-url` is not defined.
467484

468485
You are able to use all the configurable attributes as expressions in your template. I would advise to use the default template as base template
469486
and then add your custom additions to it.
470487

471-
> Please also take care when you change how the items are shown or what method is called if an item is clicked,
488+
> Please also take care when you change how the items are shown or what method is called if an item is clicked,
472489
> because changing this could make the component unusable.
473490
474491
You will need to set the proper `randomCssClass` for the outer most div container in your template and you can get the value by using the `{{viewModel.randomCssClass}}` expression
@@ -480,8 +497,8 @@ like in the following example:
480497

481498
### Template data
482499

483-
If you change the template with the `template-url` and want to pass in additional data then you are able to set
484-
the `template-data` attribute on the directive. If you for example have a `templateData.testData` expression in your own
500+
If you change the template with the `template-url` and want to pass in additional data then you are able to set
501+
the `template-data` attribute on the directive. If you for example have a `templateData.testData` expression in your own
485502
template like this:
486503
```html
487504
...
@@ -503,13 +520,13 @@ Then the expression in your template gets resolved properly.
503520

504521
### Loading icon
505522

506-
If you want to display a loading icon when the `items-method` promise gets resolved then you need to set the `loading-icon`
507-
attribute to a value given by the Ionic spinner: http://ionicframework.com/docs/api/directive/ionSpinner. Then the spinner should
508-
be shown at the right side of the search input field.
523+
If you want to display a loading icon when the `items-method` promise gets resolved then you need to set the `loading-icon`
524+
attribute to a value given by the Ionic spinner: http://ionicframework.com/docs/api/directive/ionSpinner. Then the spinner should
525+
be shown at the right side of the search input field.
509526

510527
### Manage externally
511528

512-
To manage the `ion-autocomplete` component externally means that you need to handle when the search modal is shown. To enable this functionality
529+
To manage the `ion-autocomplete` component externally means that you need to handle when the search modal is shown. To enable this functionality
513530
you need to set the `manage-externally` attribute to `true` and then you can call the `showModal()` method on the controller. Here an example:
514531

515532
```javascript
@@ -525,16 +542,24 @@ this.clickButton = function () {
525542
}
526543
```
527544

528-
Then you will need to click on the button to open the search modal. This functionality is useful if the user wants to edit the selected item inside the
545+
Then you will need to click on the button to open the search modal. This functionality is useful if the user wants to edit the selected item inside the
529546
input field after she/he selected the item/s.
530547

531548
### Selected items
532549

533-
If you want to clear the selected items programmatically, then you are able to set the `selected-items` attribute with a two way binded model value which then gets updated
550+
If you want to clear the selected items programmatically, then you are able to set the `selected-items` attribute with a two way binded model value which then gets updated
534551
when the items get selected. If you want to clear them just set the given model value to an empty array.
535552

536553
Please *do not* use it for pre populating the selected items. For this use the standard `ng-model` value and [the `model-to-item-method`](#the-model-to-item-method).
537554

555+
### Clear on select
556+
557+
This option is to clear the search input when an item is selected. You need to set it to `true` as in the following example to enable this functionality:
558+
559+
```javascript
560+
<input ion-autocomplete type="text" class="ion-autocomplete" autocomplete="off" ng-model="model" clear-on-select="true" />
561+
```
562+
538563
## Using expressions in value keys
539564

540565
All value keys are parsed with the Angular `$parse` service such that you are able to use expressions like in the following
@@ -564,9 +589,9 @@ name attribute of the child object:
564589
## Debouncing
565590

566591
If you want to debounce the search input field request, then you are able to set the `ng-model-options` attribute on the input field where you define the `ion-autocomplete`
567-
directive. These options will then be added to the search input field. Be aware that when you add a debounce the update of the model value will also be debounced the
592+
directive. These options will then be added to the search input field. Be aware that when you add a debounce the update of the model value will also be debounced the
568593
same amount as the request to the `items-method`. Here a small example:
569-
594+
570595
```html
571596
<input ion-autocomplete type="text" readonly="readonly" class="ion-autocomplete" autocomplete="off" ng-model="model" ng-model-options="{debounce:1000}" />
572597
```
@@ -581,6 +606,20 @@ $scope.$on('$destroy', function () {
581606
});
582607
```
583608

609+
# Guidelines to report an issue
610+
611+
Please follow these rules when you create an issue here in Github:
612+
613+
1. Have a meaningful title of the issue.
614+
2. Describe exactly how to reproduce the issue and create a Codepen based on the [demo](#demo) Codepen which reproduces the issue.
615+
3. Show how you configured the directive with all the options.
616+
4. Write down the Ionic version you use and which version of the directive.
617+
618+
These steps are needed to be able to analyze the issue properly without asking much questions. It is also useful for others when the issues
619+
exactly describe what the problem is and in which environment it happened.
620+
621+
For feature request please add a proper title and describe it as much as possible and also tell about the requirement you have.
622+
584623
# Release notes
585624

586625
Check them here: [Release notes](https://github.com/guylabs/ion-autocomplete/blob/master/RELEASENOTES.md)

RELEASENOTES.md

+15-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# Release notes of ion-autocomplete
22

3+
## Version 0.3.3
4+
5+
* Tag: [0.3.3](https://github.com/guylabs/ion-autocomplete/tree/v0.3.3)
6+
* Release: [ion-autocomplete-0.3.3.zip](https://github.com/guylabs/ion-autocomplete/archive/v0.3.3.zip)
7+
8+
### Changes
9+
10+
* Several bugs are fixed.
11+
* New `clearOnSelect` option - [#186](https://github.com/guylabs/ion-autocomplete/pull/186)
12+
* The `maxSelectedItems` option is now two way binded allowing for dynamic values - [#140](https://github.com/guylabs/ion-autocomplete/issues/140)
13+
* Added a new property `selectedItemsArray` to the callback responses - [#115](https://github.com/guylabs/ion-autocomplete/issues/115)
14+
315
## Version 0.3.2
416

517
* Tag: [0.3.2](https://github.com/guylabs/ion-autocomplete/tree/v0.3.2)
@@ -32,7 +44,7 @@ is now returned as object and not as an array with one element. If you use a cus
3244

3345
* As of version `0.3.1` the `multiple-select` attribute has been dropped in favor of the `max-selected-items` attribute.
3446
Please have a look at the documentation here https://github.com/guylabs/ion-autocomplete#the-max-selected-items on how to migrate this.
35-
* The `search-items` attribute has been removed as now the initialization of the `search-items` is done in the `items-method`. See the
47+
* The `search-items` attribute has been removed as now the initialization of the `search-items` is done in the `items-method`. See the
3648
new documentation here https://github.com/guylabs/ion-autocomplete#the-items-method.
3749

3850
## Version 0.3.0
@@ -49,8 +61,8 @@ new documentation here https://github.com/guylabs/ion-autocomplete#the-items-met
4961

5062
### Migration notes
5163

52-
* As of version `0.3.0` the component does not support the element restriction anymore, such that you are just able to
53-
use the attribute restriction on all your elements. This means that you need to convert all `<ion-autocomplete ... />`
64+
* As of version `0.3.0` the component does not support the element restriction anymore, such that you are just able to
65+
use the attribute restriction on all your elements. This means that you need to convert all `<ion-autocomplete ... />`
5466
tags to the following tag: `<input ion-autocomplete type="text" readonly="readonly" class="ion-autocomplete" autocomplete="off" ... />`
5567

5668
## Version 0.2.3

0 commit comments

Comments
 (0)