Skip to content

Commit 9d5a920

Browse files
committed
Prepare 1.8.0 release
1 parent 7a8a000 commit 9d5a920

File tree

5 files changed

+62
-4
lines changed

5 files changed

+62
-4
lines changed

CHANGELOG.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
# CHANGELOG
22

3-
### Unreleased Changes
3+
### Version 1.8.0
44

5-
[Compare changes](https://github.com/codevise/activeadmin-searchable_select/compare/1-7-stable...master)
5+
2023-08-17
66

7-
None so far.
7+
[Compare changes](https://github.com/codevise/activeadmin-searchable_select/compare/1-7-stable...v1.8.0)
8+
9+
- Update webdrivers to fix specs for Chrome 115
10+
([#47](https://github.com/codevise/activeadmin-searchable_select/pull/47))
11+
- Add support for Active Admin 3.0
12+
([#45](https://github.com/codevise/activeadmin-searchable_select/pull/45))
813

914
See
1015
[1-7-stable branch](https://github.com/codevise/activeadmin-searchable_select/blob/1-7-stable/CHANGELOG.md)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module ActiveAdmin
22
module SearchableSelect
3-
VERSION = '1.8.0.dev'.freeze
3+
VERSION = '1.8.0'.freeze
44
end
55
end

src/searchable_select.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import 'select2';
2+
import './searchable_select/init';

src/searchable_select.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@import "select2";
2+
3+
.searchable_select.input .select2-container {
4+
min-width: 30%;
5+
}

src/searchable_select/init.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
(function() {
2+
function initSearchableSelects(inputs, extra) {
3+
inputs.each(function() {
4+
var item = $(this);
5+
6+
// reading from data allows <input data-searchable_select='{"tags": ['some']}'>
7+
// to be passed to select2
8+
var options = $.extend(extra || {}, item.data('searchableSelect'));
9+
var url = item.data('ajaxUrl');
10+
11+
if (url) {
12+
$.extend(options, {
13+
ajax: {
14+
url: url,
15+
dataType: 'json',
16+
17+
data: function (params) {
18+
return {
19+
term: params.term,
20+
page: pageParamWithBaseZero(params)
21+
};
22+
}
23+
}
24+
});
25+
}
26+
27+
item.select2(options);
28+
});
29+
}
30+
31+
function pageParamWithBaseZero(params) {
32+
return params.page ? params.page - 1 : undefined;
33+
}
34+
35+
$(document).on('has_many_add:after', '.has_many_container', function(e, fieldset) {
36+
initSearchableSelects(fieldset.find('.searchable-select-input'));
37+
});
38+
39+
$(document).on('page:load turbolinks:load', function() {
40+
initSearchableSelects($(".searchable-select-input"), {placeholder: ""});
41+
});
42+
43+
$(function() {
44+
initSearchableSelects($(".searchable-select-input"));
45+
});
46+
}());

0 commit comments

Comments
 (0)