parent
667e6dff7c
commit
3d4311194c
|
@ -107,16 +107,16 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- categories -->
|
<!-- categories -->
|
||||||
<md-chips ng-model="editor.card.categories">
|
<md-chips ng-model="editor.card.categories"
|
||||||
|
md-transform-chip="{ value: $chip }">
|
||||||
<md-chip-template>{{$chip.value}}</md-chip-template>
|
<md-chip-template>{{$chip.value}}</md-chip-template>
|
||||||
<md-autocomplete
|
<md-autocomplete
|
||||||
md-selected-item="editor.categories.selected"
|
md-selected-item="editor.categories.selected"
|
||||||
md-selected-item-change="editor.card.$addCategory(category)"
|
|
||||||
md-search-text="editor.categories.searchText"
|
md-search-text="editor.categories.searchText"
|
||||||
md-items="category in editor.card.constructor.filterCategories(editor.categories.searchText)"
|
md-items="category in editor.card.constructor.filterCategories(editor.categories.searchText)"
|
||||||
md-min-length="0"
|
md-min-length="0"
|
||||||
label:placeholder="Add a category">
|
label:placeholder="Add a category">
|
||||||
<span md-highlight-text="editor.categories.searchText">{{category}}</span>
|
<span md-highlight-text="editor.categories.searchText">{{category.value}}</span>
|
||||||
</md-autocomplete>
|
</md-autocomplete>
|
||||||
</md-chips>
|
</md-chips>
|
||||||
|
|
||||||
|
|
|
@ -93,8 +93,10 @@
|
||||||
*/
|
*/
|
||||||
Card.filterCategories = function(query) {
|
Card.filterCategories = function(query) {
|
||||||
var re = new RegExp(query, 'i');
|
var re = new RegExp(query, 'i');
|
||||||
return _.filter(Card.$categories, function(category) {
|
return _.map(_.filter(Card.$categories, function(category) {
|
||||||
return category.search(re) != -1;
|
return category.search(re) != -1;
|
||||||
|
}), function(category) {
|
||||||
|
return { value: category };
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -315,17 +317,19 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
Card.prototype.$addCategory = function(category) {
|
Card.prototype.$addCategory = function(category) {
|
||||||
if (angular.isUndefined(this.categories)) {
|
if (category) {
|
||||||
this.categories = [{value: category}];
|
if (angular.isUndefined(this.categories)) {
|
||||||
}
|
this.categories = [{value: category}];
|
||||||
else {
|
}
|
||||||
for (var i = 0; i < this.categories.length; i++) {
|
else {
|
||||||
if (this.categories[i].value == category) {
|
for (var i = 0; i < this.categories.length; i++) {
|
||||||
break;
|
if (this.categories[i].value == category) {
|
||||||
}
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (i == this.categories.length)
|
||||||
|
this.categories.push({value: category});
|
||||||
}
|
}
|
||||||
if (i == this.categories.length)
|
|
||||||
this.categories.push({value: category});
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue