insert-bbb.js.es6 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import Controller from "@ember/controller";
  2. import ModalFunctionality from "discourse/mixins/modal-functionality";
  3. import discourseComputed from "discourse-common/utils/decorators";
  4. import { isEmpty } from "@ember/utils";
  5. export default Controller.extend(ModalFunctionality, {
  6. keyDown(e) {
  7. if (e.keyCode === 13) {
  8. e.preventDefault();
  9. e.stopPropagation();
  10. return false;
  11. }
  12. },
  13. onShow() {
  14. this.setProperties({
  15. meetingID: "",
  16. attendeePW: "",
  17. moderatorPW: "",
  18. buttonText: "",
  19. mobileIframe: false,
  20. desktopIframe: true,
  21. });
  22. },
  23. randomID() {
  24. return Math.random().toString(36).slice(-8);
  25. },
  26. @discourseComputed("meetingID")
  27. insertDisabled(meetingID) {
  28. return isEmpty(meetingID);
  29. },
  30. actions: {
  31. insert() {
  32. const btnTxt = this.buttonText ? ` label="${this.buttonText}"` : "";
  33. this.toolbarEvent.addText(
  34. `[wrap=discourse-bbb meetingID="${
  35. this.meetingID
  36. }"${btnTxt} attendeePW="${this.randomID()}" moderatorPW="${this.randomID()}" mobileIframe="${
  37. this.mobileIframe
  38. }" desktopIframe="${this.desktopIframe}"][/wrap]`
  39. );
  40. this.send("closeModal");
  41. },
  42. cancel() {
  43. this.send("closeModal");
  44. },
  45. },
  46. });