mirror of
https://github.com/discourse/discourse.git
synced 2025-06-11 13:16:04 +08:00
Migrate flag modal to use components
This commit is contained in:
@ -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);
|
||||||
|
}
|
||||||
|
});
|
@ -1,6 +1,7 @@
|
|||||||
import ModalFunctionality from 'discourse/mixins/modal-functionality';
|
import ModalFunctionality from 'discourse/mixins/modal-functionality';
|
||||||
import ActionSummary from 'discourse/models/action-summary';
|
import ActionSummary from 'discourse/models/action-summary';
|
||||||
import { MAX_MESSAGE_LENGTH } from 'discourse/models/post-action-type';
|
import { MAX_MESSAGE_LENGTH } from 'discourse/models/post-action-type';
|
||||||
|
import computed from 'ember-addons/ember-computed-decorators';
|
||||||
|
|
||||||
export default Ember.Controller.extend(ModalFunctionality, {
|
export default Ember.Controller.extend(ModalFunctionality, {
|
||||||
userDetails: null,
|
userDetails: null,
|
||||||
@ -14,6 +15,11 @@ export default Ember.Controller.extend(ModalFunctionality, {
|
|||||||
this.set('selected', null);
|
this.set('selected', null);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@computed('flagTopic')
|
||||||
|
title(flagTopic) {
|
||||||
|
return flagTopic ? 'flagging_topic.title' : 'flagging.title';
|
||||||
|
},
|
||||||
|
|
||||||
flagsAvailable: function() {
|
flagsAvailable: function() {
|
||||||
if (!this.get('flagTopic')) {
|
if (!this.get('flagTopic')) {
|
||||||
// flagging post
|
// flagging post
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
{{#each flags as |f|}}
|
||||||
|
{{yield f}}
|
||||||
|
{{else}}
|
||||||
|
{{i18n 'flagging.cant'}}
|
||||||
|
{{/each}}
|
@ -1,7 +1,6 @@
|
|||||||
<div class="modal-body flag-modal">
|
{{#d-modal-body class="flag-modal" title=title}}
|
||||||
|
|
||||||
<form>
|
<form>
|
||||||
{{#each flagsAvailable as |f|}}
|
{{#flag-selection nameKey=selected.name_key flags=flagsAvailable as |f|}}
|
||||||
{{flag-action-type flag=f
|
{{flag-action-type flag=f
|
||||||
message=message
|
message=message
|
||||||
isWarning=isWarning
|
isWarning=isWarning
|
||||||
@ -9,12 +8,10 @@
|
|||||||
username=model.username
|
username=model.username
|
||||||
staffFlagsAvailable=staffFlagsAvailable
|
staffFlagsAvailable=staffFlagsAvailable
|
||||||
changePostActionType="changePostActionType"}}
|
changePostActionType="changePostActionType"}}
|
||||||
{{else}}
|
{{/flag-selection}}
|
||||||
{{i18n 'flagging.cant'}}
|
|
||||||
{{/each}}
|
|
||||||
</form>
|
</form>
|
||||||
|
{{/d-modal-body}}
|
||||||
|
|
||||||
</div>
|
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button class='btn btn-primary' {{action "createFlag"}} disabled={{submitDisabled}} title="{{i18n 'flagging.submit_tooltip'}}">{{{submitText}}}</button>
|
<button class='btn btn-primary' {{action "createFlag"}} disabled={{submitDisabled}} title="{{i18n 'flagging.submit_tooltip'}}">{{{submitText}}}</button>
|
||||||
|
|
||||||
|
@ -1,27 +0,0 @@
|
|||||||
import ModalBodyView from "discourse/views/modal-body";
|
|
||||||
|
|
||||||
export default ModalBodyView.extend({
|
|
||||||
templateName: 'modal/flag',
|
|
||||||
|
|
||||||
title: function() {
|
|
||||||
return this.get('controller.flagTopic') ? I18n.t('flagging_topic.title') : I18n.t('flagging.title');
|
|
||||||
}.property('controller.flagTopic'),
|
|
||||||
|
|
||||||
_selectRadio: function() {
|
|
||||||
this.$("input[type='radio']").prop('checked', false);
|
|
||||||
|
|
||||||
const nameKey = this.get('controller.selected.name_key');
|
|
||||||
if (!nameKey) { return; }
|
|
||||||
|
|
||||||
this.$('#radio_' + nameKey).prop('checked', 'true');
|
|
||||||
},
|
|
||||||
|
|
||||||
selectedChanged: function() {
|
|
||||||
Ember.run.next(this, this._selectRadio);
|
|
||||||
}.observes('controller.selected.name_key'),
|
|
||||||
|
|
||||||
// See: https://github.com/emberjs/ember.js/issues/10869
|
|
||||||
_selectedHack: function() {
|
|
||||||
this.removeObserver('controller.selected.name_key');
|
|
||||||
}.on('willDestroyElement')
|
|
||||||
});
|
|
@ -60,7 +60,6 @@
|
|||||||
//= require ./discourse/controllers/discovery-sortable
|
//= require ./discourse/controllers/discovery-sortable
|
||||||
//= require ./discourse/controllers/navigation/default
|
//= require ./discourse/controllers/navigation/default
|
||||||
//= require ./discourse/views/modal-body
|
//= require ./discourse/views/modal-body
|
||||||
//= require ./discourse/views/flag
|
|
||||||
//= require ./discourse/components/edit-category-panel
|
//= require ./discourse/components/edit-category-panel
|
||||||
//= require ./discourse/components/dropdown-button
|
//= require ./discourse/components/dropdown-button
|
||||||
//= require ./discourse/components/notifications-button
|
//= require ./discourse/components/notifications-button
|
||||||
|
Reference in New Issue
Block a user