move modals to glimmer components
Dieser Commit ist enthalten in:
Ursprung
d71d9976b8
Commit
6572b32706
10 geänderte Dateien mit 107 neuen und 101 gelöschten Zeilen
|
@ -0,0 +1,35 @@
|
||||||
|
<DModal @closeModal={{@closeModal}} @title={{this.title}}>
|
||||||
|
{{#if loading}}
|
||||||
|
<LoadingSpinner size="large" />
|
||||||
|
{{else}}
|
||||||
|
<div class="edit-directory-columns-container">
|
||||||
|
{{#each this.args.model.columns as |column|}}
|
||||||
|
<div class="edit-directory-column">
|
||||||
|
<div class="left-content">
|
||||||
|
<label class="column-name">
|
||||||
|
<Input @type="checkbox" @checked={{column.enabled}} />
|
||||||
|
{{directory-table-header-title
|
||||||
|
field=column.label
|
||||||
|
translated=true
|
||||||
|
}}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{{/each}}
|
||||||
|
</div>
|
||||||
|
{{/if}}
|
||||||
|
<div class="modal-footer">
|
||||||
|
<DButton
|
||||||
|
class="btn-primary"
|
||||||
|
@label="directory.edit_columns.save"
|
||||||
|
@action={{action "save"}}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<DButton
|
||||||
|
class="btn-secondary reset-to-default"
|
||||||
|
@label="directory.edit_columns.reset_to_default"
|
||||||
|
@action={{action "resetToDefault"}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</DModal>
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
import Component from "@glimmer/component";
|
||||||
|
import { action } from "@ember/object";
|
||||||
|
|
||||||
|
export default class AdminWizardsColumnComponent extends Component {
|
||||||
|
title = I18n.t("admin.wizard.edit_columns");
|
||||||
|
|
||||||
|
@action save() {
|
||||||
|
this.args.closeModal();
|
||||||
|
}
|
||||||
|
|
||||||
|
@action resetToDefault() {
|
||||||
|
this.args.model.reset();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
<DModal
|
||||||
|
@closeModal={{@closeModal}}
|
||||||
|
class="next-session-time-modal"
|
||||||
|
@title={{this.title}}
|
||||||
|
>
|
||||||
|
<DateTimeInput
|
||||||
|
@date={{this.bufferedDateTime}}
|
||||||
|
@onChange={{action "dateTimeChanged"}}
|
||||||
|
@showTime="true"
|
||||||
|
@clearable="true"
|
||||||
|
/>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<DButton
|
||||||
|
@action={{action "submit"}}
|
||||||
|
class="btn-primary"
|
||||||
|
@label="admin.wizard.after_time_modal.done"
|
||||||
|
disabled={{this.submitDisabled}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</DModal>
|
|
@ -0,0 +1,29 @@
|
||||||
|
import Component from "@glimmer/component";
|
||||||
|
import { tracked } from "@glimmer/tracking";
|
||||||
|
import { action } from "@ember/object";
|
||||||
|
|
||||||
|
export default class NextSessionScheduledComponent extends Component {
|
||||||
|
@tracked bufferedDateTime;
|
||||||
|
title = I18n.t("admin.wizard.after_time_modal.title");
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
super(...arguments);
|
||||||
|
this.bufferedDateTime = this.args.model.dateTime
|
||||||
|
? moment(this.args.model.dateTime)
|
||||||
|
: moment(Date.now());
|
||||||
|
}
|
||||||
|
|
||||||
|
get submitDisabled() {
|
||||||
|
return moment().isAfter(this.bufferedDateTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
@action submit() {
|
||||||
|
const dateTime = this.bufferedDateTime;
|
||||||
|
this.args.model.update(moment(dateTime).utc().toISOString());
|
||||||
|
this.args.closeModal();
|
||||||
|
}
|
||||||
|
|
||||||
|
@action dateTimeChanged(dateTime) {
|
||||||
|
this.bufferedDateTime = dateTime;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,14 +0,0 @@
|
||||||
import Controller from "@ember/controller";
|
|
||||||
import ModalFunctionality from "discourse/mixins/modal-functionality";
|
|
||||||
|
|
||||||
export default Controller.extend(ModalFunctionality, {
|
|
||||||
actions: {
|
|
||||||
save() {
|
|
||||||
this.send("closeModal");
|
|
||||||
},
|
|
||||||
|
|
||||||
resetToDefault() {
|
|
||||||
this.get("model.reset")();
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
|
@ -2,11 +2,13 @@ import Controller from "@ember/controller";
|
||||||
import { empty } from "@ember/object/computed";
|
import { empty } from "@ember/object/computed";
|
||||||
import discourseComputed from "discourse-common/utils/decorators";
|
import discourseComputed from "discourse-common/utils/decorators";
|
||||||
import { fmt } from "discourse/lib/computed";
|
import { fmt } from "discourse/lib/computed";
|
||||||
import showModal from "discourse/lib/show-modal";
|
import { inject as service } from "@ember/service";
|
||||||
|
import AdminWizardsColumnsModal from "../components/modal/admin-wizards-columns";
|
||||||
import CustomWizardAdmin from "../models/custom-wizard-admin";
|
import CustomWizardAdmin from "../models/custom-wizard-admin";
|
||||||
import { formatModel } from "../lib/wizard-submission";
|
import { formatModel } from "../lib/wizard-submission";
|
||||||
|
|
||||||
export default Controller.extend({
|
export default Controller.extend({
|
||||||
|
modal: service(),
|
||||||
downloadUrl: fmt("wizard.id", "/admin/wizards/submissions/%@/download"),
|
downloadUrl: fmt("wizard.id", "/admin/wizards/submissions/%@/download"),
|
||||||
noResults: empty("submissions"),
|
noResults: empty("submissions"),
|
||||||
page: 0,
|
page: 0,
|
||||||
|
@ -57,7 +59,7 @@ export default Controller.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
showEditColumnsModal() {
|
showEditColumnsModal() {
|
||||||
return showModal("admin-wizards-columns", {
|
return this.modal.show(AdminWizardsColumnsModal, {
|
||||||
model: {
|
model: {
|
||||||
columns: this.get("fields"),
|
columns: this.get("fields"),
|
||||||
reset: () => {
|
reset: () => {
|
||||||
|
|
|
@ -3,7 +3,8 @@ import {
|
||||||
observes,
|
observes,
|
||||||
} from "discourse-common/utils/decorators";
|
} from "discourse-common/utils/decorators";
|
||||||
import { notEmpty } from "@ember/object/computed";
|
import { notEmpty } from "@ember/object/computed";
|
||||||
import showModal from "discourse/lib/show-modal";
|
import { inject as service } from "@ember/service";
|
||||||
|
import NextSessionScheduledModal from "../components/modal/next-session-scheduled";
|
||||||
import { generateId, wizardFieldList } from "../lib/wizard";
|
import { generateId, wizardFieldList } from "../lib/wizard";
|
||||||
import { dasherize } from "@ember/string";
|
import { dasherize } from "@ember/string";
|
||||||
import { later, scheduleOnce } from "@ember/runloop";
|
import { later, scheduleOnce } from "@ember/runloop";
|
||||||
|
@ -13,6 +14,7 @@ import I18n from "I18n";
|
||||||
import { filterValues } from "discourse/plugins/discourse-custom-wizard/discourse/lib/wizard-schema";
|
import { filterValues } from "discourse/plugins/discourse-custom-wizard/discourse/lib/wizard-schema";
|
||||||
|
|
||||||
export default Controller.extend({
|
export default Controller.extend({
|
||||||
|
modal: service(),
|
||||||
hasName: notEmpty("wizard.name"),
|
hasName: notEmpty("wizard.name"),
|
||||||
|
|
||||||
@observes("currentStep")
|
@observes("currentStep")
|
||||||
|
@ -126,7 +128,7 @@ export default Controller.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
setNextSessionScheduled() {
|
setNextSessionScheduled() {
|
||||||
let controller = showModal("next-session-scheduled", {
|
this.modal.show(NextSessionScheduledModal, {
|
||||||
model: {
|
model: {
|
||||||
dateTime: this.wizard.after_time_scheduled,
|
dateTime: this.wizard.after_time_scheduled,
|
||||||
update: (dateTime) =>
|
update: (dateTime) =>
|
||||||
|
@ -134,7 +136,7 @@ export default Controller.extend({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
controller.setup();
|
// controller.setup();
|
||||||
},
|
},
|
||||||
|
|
||||||
copyUrl() {
|
copyUrl() {
|
||||||
|
|
|
@ -1,30 +0,0 @@
|
||||||
import { default as discourseComputed } from "discourse-common/utils/decorators";
|
|
||||||
import Controller from "@ember/controller";
|
|
||||||
|
|
||||||
export default Controller.extend({
|
|
||||||
title: "admin.wizard.after_time_modal.title",
|
|
||||||
|
|
||||||
setup() {
|
|
||||||
this.set(
|
|
||||||
"bufferedDateTime",
|
|
||||||
this.model.dateTime ? moment(this.model.dateTime) : moment(Date.now())
|
|
||||||
);
|
|
||||||
},
|
|
||||||
|
|
||||||
@discourseComputed("bufferedDateTime")
|
|
||||||
submitDisabled(dateTime) {
|
|
||||||
return moment().isAfter(dateTime);
|
|
||||||
},
|
|
||||||
|
|
||||||
actions: {
|
|
||||||
submit() {
|
|
||||||
const dateTime = this.get("bufferedDateTime");
|
|
||||||
this.get("model.update")(moment(dateTime).utc().toISOString());
|
|
||||||
this.send("closeModal");
|
|
||||||
},
|
|
||||||
|
|
||||||
dateTimeChanged(dateTime) {
|
|
||||||
this.set("bufferedDateTime", dateTime);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
|
@ -1,35 +0,0 @@
|
||||||
{{#d-modal-body title="admin.wizard.edit_columns"}}
|
|
||||||
{{#if loading}}
|
|
||||||
{{loading-spinner size="large"}}
|
|
||||||
{{else}}
|
|
||||||
<div class="edit-directory-columns-container">
|
|
||||||
{{#each model.columns as |column|}}
|
|
||||||
<div class="edit-directory-column">
|
|
||||||
<div class="left-content">
|
|
||||||
<label class="column-name">
|
|
||||||
{{input type="checkbox" checked=column.enabled}}
|
|
||||||
{{directory-table-header-title
|
|
||||||
field=column.label
|
|
||||||
translated=true
|
|
||||||
}}
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{/each}}
|
|
||||||
</div>
|
|
||||||
{{/if}}
|
|
||||||
{{/d-modal-body}}
|
|
||||||
|
|
||||||
<div class="modal-footer">
|
|
||||||
{{d-button
|
|
||||||
class="btn-primary"
|
|
||||||
label="directory.edit_columns.save"
|
|
||||||
action=(action "save")
|
|
||||||
}}
|
|
||||||
|
|
||||||
{{d-button
|
|
||||||
class="btn-secondary reset-to-default"
|
|
||||||
label="directory.edit_columns.reset_to_default"
|
|
||||||
action=(action "resetToDefault")
|
|
||||||
}}
|
|
||||||
</div>
|
|
|
@ -1,17 +0,0 @@
|
||||||
{{#d-modal-body class="next-session-time-modal" title=title}}
|
|
||||||
{{date-time-input
|
|
||||||
date=bufferedDateTime
|
|
||||||
onChange=(action "dateTimeChanged")
|
|
||||||
showTime=true
|
|
||||||
clearable=true
|
|
||||||
}}
|
|
||||||
{{/d-modal-body}}
|
|
||||||
|
|
||||||
<div class="modal-footer">
|
|
||||||
{{d-button
|
|
||||||
action=(action "submit")
|
|
||||||
class="btn-primary"
|
|
||||||
label="admin.wizard.after_time_modal.done"
|
|
||||||
disabled=submitDisabled
|
|
||||||
}}
|
|
||||||
</div>
|
|
Laden …
In neuem Issue referenzieren