Add group messages support to admin UI, and add a ‘type’ field for further improvements
This commit is contained in:
@@ -37,12 +37,12 @@ export default Ember.Controller.extend({
|
||||
|
||||
createRule(channel){
|
||||
this.set('modalShowing', true);
|
||||
var model = {rule: this.store.createRecord('rule',{channel_id: channel.id}), channel:channel, provider:this.get('model.provider')};
|
||||
var model = {rule: this.store.createRecord('rule',{channel_id: channel.id}), channel:channel, provider:this.get('model.provider'), groups:this.get('model.groups')};
|
||||
showModal('admin-plugins-chat-edit-rule', { model: model, admin: true });
|
||||
},
|
||||
editRule(rule, channel){
|
||||
this.set('modalShowing', true);
|
||||
var model = {rule: rule, channel:channel, provider:this.get('model.provider')};
|
||||
var model = {rule: rule, channel:channel, provider:this.get('model.provider'), groups:this.get('model.groups')};
|
||||
showModal('admin-plugins-chat-edit-rule', { model: model, admin: true });
|
||||
},
|
||||
|
||||
|
||||
@@ -3,9 +3,9 @@ import ModalFunctionality from 'discourse/mixins/modal-functionality';
|
||||
import { ajax } from 'discourse/lib/ajax';
|
||||
import { extractError } from 'discourse/lib/ajax-error';
|
||||
import InputValidation from 'discourse/models/input-validation';
|
||||
import computed from "ember-addons/ember-computed-decorators";
|
||||
|
||||
export default Ember.Controller.extend(ModalFunctionality, {
|
||||
|
||||
setupKeydown: function() {
|
||||
Ember.run.schedule('afterRender', () => {
|
||||
$('#chat_integration_edit_channel_modal').keydown(e => {
|
||||
@@ -16,11 +16,15 @@ export default Ember.Controller.extend(ModalFunctionality, {
|
||||
});
|
||||
}.on('init'),
|
||||
|
||||
|
||||
saveDisabled: function(){
|
||||
return false;
|
||||
}.property(),
|
||||
|
||||
@computed('model.rule.type')
|
||||
showCategory: function(type){
|
||||
return (type == "normal")
|
||||
},
|
||||
|
||||
actions: {
|
||||
cancel: function(){
|
||||
this.send('closeModal');
|
||||
|
||||
@@ -9,12 +9,29 @@ export default RestModel.extend({
|
||||
{ id: 'mute', name: I18n.t('chat_integration.filter.mute'), icon: 'times-circle' }
|
||||
],
|
||||
|
||||
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')}
|
||||
],
|
||||
|
||||
category_id: null,
|
||||
tags: null,
|
||||
channel_id: null,
|
||||
filter: 'watch',
|
||||
type: 'normal',
|
||||
error_key: null,
|
||||
|
||||
|
||||
removeUnneededInfo: function(){
|
||||
const type=this.get('type');
|
||||
if(type=='normal'){
|
||||
this.set('group_id', null);
|
||||
}else{
|
||||
this.set('category_id', null);
|
||||
}
|
||||
}.observes('type'),
|
||||
|
||||
@computed('category_id')
|
||||
category(categoryId) {
|
||||
if (categoryId){
|
||||
@@ -30,12 +47,12 @@ export default RestModel.extend({
|
||||
},
|
||||
|
||||
updateProperties() {
|
||||
var prop_names = ['category_id','group_id','tags','filter'];
|
||||
var prop_names = ['type','category_id','group_id','tags','filter'];
|
||||
return this.getProperties(prop_names);
|
||||
},
|
||||
|
||||
createProperties() {
|
||||
var prop_names = ['channel_id', 'category_id','group_id','tags','filter'];
|
||||
var prop_names = ['type','channel_id', 'category_id','group_id','tags','filter'];
|
||||
return this.getProperties(prop_names);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
import { ajax } from 'discourse/lib/ajax';
|
||||
import Group from 'discourse/models/group';
|
||||
|
||||
export default Discourse.Route.extend({
|
||||
|
||||
model(params, transition) {
|
||||
return Ember.RSVP.hash({
|
||||
channels: this.store.findAll('channel', {provider: params.provider}),
|
||||
provider: this.modelFor("admin-plugins-chat").findBy('id',params.provider)
|
||||
provider: this.modelFor("admin-plugins-chat").findBy('id',params.provider),
|
||||
groups: Group.findAll().then(groups => {
|
||||
return groups.filter(g => !g.get('automatic'));
|
||||
})
|
||||
}).then(value => {
|
||||
value.channels.forEach(channel => {
|
||||
channel.set('rules', channel.rules.map(rule => {
|
||||
|
||||
@@ -25,6 +25,17 @@
|
||||
<td></td>
|
||||
</tr>
|
||||
|
||||
<tr class="input">
|
||||
<td class="label"><label for='filter'>{{i18n "chat_integration.edit_rule_modal.type"}}</label></td>
|
||||
<td>
|
||||
{{combo-box name="type" content=model.rule.available_types value=model.rule.type}}
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="instructions">
|
||||
<td></td>
|
||||
<td><label>{{i18n 'chat_integration.edit_rule_modal.instructions.type'}}</label></td>
|
||||
</tr>
|
||||
|
||||
<tr class="input">
|
||||
<td class="label"><label for='filter'>{{i18n "chat_integration.edit_rule_modal.filter"}}</label></td>
|
||||
<td>
|
||||
@@ -36,22 +47,37 @@
|
||||
<td><label>{{i18n 'chat_integration.edit_rule_modal.instructions.filter'}}</label></td>
|
||||
</tr>
|
||||
|
||||
<tr class="input">
|
||||
<td class="label"><label for='category'>{{i18n "chat_integration.edit_rule_modal.category"}}</label></td>
|
||||
<td>
|
||||
{{category-chooser
|
||||
name="category"
|
||||
value=model.rule.category_id
|
||||
rootNoneLabel="chat_integration.all_categories"
|
||||
rootNone=true
|
||||
overrideWidths=false
|
||||
}}
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="instructions">
|
||||
<td></td>
|
||||
<td><label>{{i18n 'chat_integration.edit_rule_modal.instructions.category'}}</label></td>
|
||||
</tr>
|
||||
{{#if showCategory}}
|
||||
<tr class="input">
|
||||
<td class="label"><label for='category'>{{i18n "chat_integration.edit_rule_modal.category"}}</label></td>
|
||||
<td>
|
||||
{{category-chooser
|
||||
name="category"
|
||||
value=model.rule.category_id
|
||||
rootNoneLabel="chat_integration.all_categories"
|
||||
rootNone=true
|
||||
overrideWidths=false
|
||||
}}
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="instructions">
|
||||
<td></td>
|
||||
<td><label>{{i18n 'chat_integration.edit_rule_modal.instructions.category'}}</label></td>
|
||||
</tr>
|
||||
{{else}}
|
||||
<tr class="input">
|
||||
<td class="label"><label for='group'>{{i18n "chat_integration.edit_rule_modal.group"}}</label></td>
|
||||
<td>
|
||||
{{combo-box content=model.groups valueAttribute="id" value=model.rule.group_id none="chat_integration.choose_group"}}
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="instructions">
|
||||
<td></td>
|
||||
<td><label>{{i18n 'chat_integration.edit_rule_modal.instructions.group'}}</label></td>
|
||||
</tr>
|
||||
{{/if}}
|
||||
|
||||
|
||||
|
||||
{{#if siteSettings.tagging_enabled}}
|
||||
<tr class="input">
|
||||
|
||||
Reference in New Issue
Block a user