diff --git a/app/assets/javascripts/discourse/components/flag-selection.js.es6 b/app/assets/javascripts/discourse/components/flag-selection.js.es6 new file mode 100644 index 00000000000..b738e2c169d --- /dev/null +++ b/app/assets/javascripts/discourse/components/flag-selection.js.es6 @@ -0,0 +1,18 @@ +import { observes } from 'ember-addons/ember-computed-decorators'; + +// Mostly hacks because `flag.hbs` didn't use `radio-button` +export default Ember.Component.extend({ + _selectRadio() { + this.$("input[type='radio']").prop('checked', false); + + const nameKey = this.get('nameKey'); + if (!nameKey) { return; } + + this.$('#radio_' + nameKey).prop('checked', 'true'); + }, + + @observes('nameKey') + selectedChanged() { + Ember.run.next(this, this._selectRadio); + } +}); diff --git a/app/assets/javascripts/discourse/controllers/flag.js.es6 b/app/assets/javascripts/discourse/controllers/flag.js.es6 index 760390d3d41..b316091285c 100644 --- a/app/assets/javascripts/discourse/controllers/flag.js.es6 +++ b/app/assets/javascripts/discourse/controllers/flag.js.es6 @@ -1,6 +1,7 @@ import ModalFunctionality from 'discourse/mixins/modal-functionality'; import ActionSummary from 'discourse/models/action-summary'; import { MAX_MESSAGE_LENGTH } from 'discourse/models/post-action-type'; +import computed from 'ember-addons/ember-computed-decorators'; export default Ember.Controller.extend(ModalFunctionality, { userDetails: null, @@ -14,6 +15,11 @@ export default Ember.Controller.extend(ModalFunctionality, { this.set('selected', null); }, + @computed('flagTopic') + title(flagTopic) { + return flagTopic ? 'flagging_topic.title' : 'flagging.title'; + }, + flagsAvailable: function() { if (!this.get('flagTopic')) { // flagging post diff --git a/app/assets/javascripts/discourse/templates/components/flag-selection.hbs b/app/assets/javascripts/discourse/templates/components/flag-selection.hbs new file mode 100644 index 00000000000..4aadb91c823 --- /dev/null +++ b/app/assets/javascripts/discourse/templates/components/flag-selection.hbs @@ -0,0 +1,5 @@ +{{#each flags as |f|}} + {{yield f}} +{{else}} + {{i18n 'flagging.cant'}} +{{/each}} diff --git a/app/assets/javascripts/discourse/templates/modal/flag.hbs b/app/assets/javascripts/discourse/templates/modal/flag.hbs index bc002e26119..3b0da391233 100644 --- a/app/assets/javascripts/discourse/templates/modal/flag.hbs +++ b/app/assets/javascripts/discourse/templates/modal/flag.hbs @@ -1,7 +1,6 @@ -