2017-06-28 15:12:37 +01:00
|
|
|
import RestModel from 'discourse/models/rest';
|
|
|
|
import Category from 'discourse/models/category';
|
|
|
|
import computed from "ember-addons/ember-computed-decorators";
|
|
|
|
|
|
|
|
export default RestModel.extend({
|
2017-06-28 18:04:21 +01:00
|
|
|
available_filters: [
|
2017-07-03 15:53:26 +01:00
|
|
|
{ id: 'watch', name: I18n.t('chat_integration.filter.watch'), icon: 'exclamation-circle' },
|
|
|
|
{ id: 'follow', name: I18n.t('chat_integration.filter.follow'), icon: 'circle'},
|
|
|
|
{ id: 'mute', name: I18n.t('chat_integration.filter.mute'), icon: 'times-circle' }
|
2017-06-28 18:04:21 +01:00
|
|
|
],
|
|
|
|
|
2017-08-01 15:20:00 +01:00
|
|
|
available_types: [
|
|
|
|
{ id: 'normal', name: I18n.t('chat_integration.type.normal')},
|
|
|
|
{ id: 'group_message', name: I18n.t('chat_integration.type.group_message')},
|
|
|
|
{ id: 'group_mention', name: I18n.t('chat_integration.type.group_mention')}
|
|
|
|
],
|
|
|
|
|
2017-06-28 15:12:37 +01:00
|
|
|
category_id: null,
|
2017-06-29 17:50:54 +01:00
|
|
|
tags: null,
|
2017-07-18 16:17:03 +01:00
|
|
|
channel_id: null,
|
|
|
|
filter: 'watch',
|
2017-08-01 15:20:00 +01:00
|
|
|
type: 'normal',
|
2017-07-04 19:37:56 +01:00
|
|
|
error_key: null,
|
2017-06-28 15:12:37 +01:00
|
|
|
|
2017-08-21 16:46:43 +01:00
|
|
|
|
2017-08-01 15:20:00 +01:00
|
|
|
removeUnneededInfo: function(){
|
|
|
|
const type=this.get('type');
|
2017-08-02 11:33:50 +01:00
|
|
|
if(type==='normal'){
|
2017-08-01 15:20:00 +01:00
|
|
|
this.set('group_id', null);
|
|
|
|
}else{
|
|
|
|
this.set('category_id', null);
|
|
|
|
}
|
|
|
|
}.observes('type'),
|
|
|
|
|
2017-06-28 15:12:37 +01:00
|
|
|
@computed('category_id')
|
2017-06-29 17:50:54 +01:00
|
|
|
category(categoryId) {
|
|
|
|
if (categoryId){
|
|
|
|
return Category.findById(categoryId);
|
|
|
|
}else {
|
|
|
|
return false;
|
2017-06-28 15:12:37 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
@computed('filter')
|
|
|
|
filterName(filter) {
|
2017-07-03 15:53:26 +01:00
|
|
|
return I18n.t(`chat_integration.filter.${filter}`);
|
2017-06-29 17:50:54 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
updateProperties() {
|
2017-08-01 15:20:00 +01:00
|
|
|
var prop_names = ['type','category_id','group_id','tags','filter'];
|
2017-06-29 20:19:40 +01:00
|
|
|
return this.getProperties(prop_names);
|
|
|
|
},
|
|
|
|
|
|
|
|
createProperties() {
|
2017-08-01 15:20:00 +01:00
|
|
|
var prop_names = ['type','channel_id', 'category_id','group_id','tags','filter'];
|
2017-07-18 16:17:03 +01:00
|
|
|
return this.getProperties(prop_names);
|
2017-06-28 15:12:37 +01:00
|
|
|
}
|
2017-06-29 20:19:40 +01:00
|
|
|
|
2017-06-28 15:12:37 +01:00
|
|
|
});
|