mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 10:20:58 -06:00
DEV: Document showModal
, allow setting more config via DModalBody
Having these things configured at the invocation of showModal is a strange API, and means that any changes to the modal require updating the call sites. It makes much more sense for these to be defined as part of the modal's own template. This was already supported for many of the properties. This commit adds support for the `modalClass` and `titleAriaElementId` config to be passed to DModalBody. For now there is no deprecation message. Support for passing these things to `showModal` will be dropped as part of an upcoming conversion of modals from controllers to components.
This commit is contained in:
parent
f2482b5daa
commit
35f29bd25b
@ -41,6 +41,8 @@ export default class DModalBody extends Component {
|
||||
"submitOnEnter",
|
||||
"dismissable",
|
||||
"headerClass",
|
||||
"modalClass",
|
||||
"titleAriaElementId",
|
||||
])
|
||||
);
|
||||
}
|
||||
|
@ -93,7 +93,9 @@ export default class DModal extends Component {
|
||||
}
|
||||
|
||||
get ariaLabelledby() {
|
||||
if (this.args.titleAriaElementId) {
|
||||
if (this.modalBodyData.titleAriaElementId) {
|
||||
return this.modalBodyData.titleAriaElementId;
|
||||
} else if (this.args.titleAriaElementId) {
|
||||
return this.args.titleAriaElementId;
|
||||
} else if (this.args.title) {
|
||||
return "discourse-modal-title";
|
||||
|
@ -2,7 +2,23 @@ import I18n from "I18n";
|
||||
import { dasherize } from "@ember/string";
|
||||
import { getOwner } from "discourse-common/lib/get-owner";
|
||||
|
||||
export default function (name, opts) {
|
||||
/**
|
||||
* Render a modal
|
||||
*
|
||||
* @param {string} name - the controller/template name for the modal body.
|
||||
*
|
||||
* @param {Object} [options] - options
|
||||
* @param {string} [options.model] - An object which will be set as the `model` property on the controller
|
||||
* @param {boolean} [options.admin] - look under the admin namespace for the controller/template
|
||||
* @param {string} [options.templateName] - override the template name to render
|
||||
* @param {string} [options.title] - (deprecated) translation key for modal title. Pass `@title` to DModalBody instead
|
||||
* @param {string} [options.titleTranslated] - (deprecated) translated modal title. Pass `@rawTitle` to DModalBody instead
|
||||
* @param {string} [options.modalClass] - (deprecated) classname for modal. Pass `@modalClass` to DModalBody instead
|
||||
* @param {string} [options.titleAriaElementId] - (deprecated) Pass `@titleAriaElementId` to DModalBody instead
|
||||
*
|
||||
* @returns {Controller} The modal controller instance
|
||||
*/
|
||||
export default function showModal(name, opts) {
|
||||
opts = opts || {};
|
||||
|
||||
let container = getOwner(this);
|
||||
|
Loading…
Reference in New Issue
Block a user