Merge pull request #3718 from guerler/add_tags_to_label_000

Show tags in select search field
This commit is contained in:
Dannon Baker
2017-03-06 15:51:41 -05:00
committed by GitHub
10 changed files with 22 additions and 11 deletions
@@ -130,8 +130,11 @@ var View = Backbone.View.extend({
if ( this.model.get( 'searchable' ) ) {
this.data2 = [];
_.each( this.data, function( option, index ) {
var tags = _.reduce( option.tags, function( memo, tag ) { return memo + ' ' + tag }, '');
self.data2.push( { order: index, id: option.value, text: option.label, tags: tags } );
var filterstr = _.reduce( option.tags, function( memo, tag ) { return memo + tag + ' ' }, '' );
var filterhtml = '<div class="ui-tags">' +
_.reduce( option.tags, function( memo, tag ) { return memo + '&nbsp;<div class="label label-info">' + tag + '</div>' }, '' )
+ '</div>';
self.data2.push( { order: index, id: option.value, text: option.label, filterhtml: filterhtml, filterstr: filterstr } );
});
this.$select.data( 'select2' ) && this.$select.select2( 'destroy' );
this.$select.select2({
@@ -141,12 +144,15 @@ var View = Backbone.View.extend({
query : function( q ) {
var pagesize = self.model.get( 'pagesize' );
var results = _.filter( self.data2, function ( e ) {
return self._match( q.term, e.text ) || self._match( q.term, e.tags );
return self._match( q.term, e.text ) || self._match( q.term, e.filterstr );
});
q.callback({
results: results.slice( ( q.page - 1 ) * pagesize, q.page * pagesize ),
more : results.length >= q.page * pagesize
});
},
formatResult : function( result ) {
return result.text + result.filterhtml;
}
});
this.$( '.select2-container .select2-search input' ).off( 'blur' );
+5
View File
@@ -68,6 +68,11 @@
font-weight: bold;
}
.ui-tags {
word-wrap: break-word;
padding-right: 25px;
}
.ui-message {
padding: 2px 10px 2px 10px;
margin-top: @ui-margin-vertical-large;
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long