Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aa8fbd7
commit 7067103
Showing
5 changed files
with
49 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 14 additions & 6 deletions
20
assets/javascripts/discourse/components/modal/add-event.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,18 @@ | ||
{{#d-modal-body class="add-event-modal" id="event-modal" title=title}} | ||
<DModal | ||
@closeModal={{@closeModal}} | ||
class="add-event-modal" | ||
id="event-modal" | ||
@flash={{this.flash}} | ||
@title={{this.title}} | ||
> | ||
<:body> | ||
{{event-form | ||
event=model.event | ||
updateEvent=(action 'updateEvent')}} | ||
{{/d-modal-body}} | ||
</:body> | ||
<:footer> | ||
{{d-button action=(action "saveEvent") class="btn-primary" label="add_event.event_add"}} | ||
<a href class="clear" {{on "click" (fn this.clear)}}>{{i18n 'add_event.event_clear'}}</a> | ||
</:footer> | ||
|
||
<div class="modal-footer"> | ||
{{d-button action=(action "saveEvent") class="btn-primary" label="add_event.event_add"}} | ||
<a href class="clear" {{on "click" (fn this.clear)}}>{{i18n 'add_event.event_clear'}}</a> | ||
</div> | ||
</DModal> |
43 changes: 22 additions & 21 deletions
43
assets/javascripts/discourse/components/modal/add-event.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,31 @@ | ||
import ModalFunctionality from "discourse/mixins/modal-functionality"; | ||
import Controller from "@ember/controller"; | ||
import Component from "@ember/component"; | ||
import I18n from "I18n"; | ||
import { action } from "@ember/object"; | ||
|
||
export default Controller.extend(ModalFunctionality, { | ||
title: "add_event.modal_title", | ||
export default class AddEventModal extends Component { | ||
title = I18n.t("add_event.modal_title"); | ||
|
||
@action | ||
clear() { | ||
event?.preventDefault(); | ||
this.set("bufferedEvent", null); | ||
}, | ||
} | ||
|
||
actions: { | ||
saveEvent() { | ||
if (this.valid) { | ||
this.get("model.update")(this.bufferedEvent); | ||
this.send("closeModal"); | ||
} else { | ||
this.flash(I18n.t("add_event.error"), "error"); | ||
} | ||
}, | ||
@action | ||
saveEvent() { | ||
if (this.valid) { | ||
this.get("model.update")(this.bufferedEvent); | ||
this.closeModal(); | ||
} else { | ||
this.setProperties({ | ||
flash: I18n.t("add_event.error"), | ||
flashType: "error", | ||
}); | ||
} | ||
} | ||
|
||
updateEvent(event, valid) { | ||
this.set("bufferedEvent", event); | ||
this.set("valid", valid); | ||
}, | ||
}, | ||
}); | ||
@action | ||
updateEvent(event, valid) { | ||
this.set("bufferedEvent", event); | ||
this.set("valid", valid); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
import { helperContext, registerUnbound } from "discourse-common/lib/helpers"; | ||
import { helper } from '@ember/component/helper'; | ||
import { htmlSafe } from "@ember/template"; | ||
import { eventLabel } from "../lib/date-utilities"; | ||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner"; | ||
|
||
export default registerUnbound("event-label", function (event, args) { | ||
let siteSettings = helperContext().siteSettings; | ||
export function eventLabelHelper([event, args]) { | ||
let siteSettings = getOwnerWithFallback(this).lookup('site-settings:main'); | ||
return htmlSafe(eventLabel(event, Object.assign({}, args, { siteSettings }))); | ||
}); | ||
}; | ||
|
||
export default helper(eventLabelHelper); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters