FIX: removes the need for intermediate property and updates code (#114)
Before this commit, changing the value of the reminder frequency on a user notifications page was not working. This commit also get rid of a few deprecations warning.
This commit is contained in:
parent
158cb01ac1
commit
977f7592f4
|
@ -1,10 +1,14 @@
|
|||
import I18n from "I18n";
|
||||
import computed from "discourse-common/utils/decorators";
|
||||
import { or } from "@ember/object/computed";
|
||||
import discourseComputed from "discourse-common/utils/decorators";
|
||||
|
||||
export default Ember.Component.extend({
|
||||
selectedFrequency: null,
|
||||
selectedFrequency: or(
|
||||
"user.custom_fields.remind_assigns_frequency",
|
||||
"siteSettings.remind_assigns_frequency"
|
||||
),
|
||||
|
||||
@computed("user.reminders_frequency")
|
||||
@discourseComputed("user.reminders_frequency")
|
||||
availableFrequencies(userRemindersFrequency) {
|
||||
return userRemindersFrequency.map((freq) => {
|
||||
return {
|
||||
|
@ -14,24 +18,4 @@ export default Ember.Component.extend({
|
|||
};
|
||||
});
|
||||
},
|
||||
|
||||
didInsertElement() {
|
||||
this._super(...arguments);
|
||||
|
||||
let currentFrequency = this.get(
|
||||
"user.custom_fields.remind_assigns_frequency"
|
||||
);
|
||||
|
||||
if (currentFrequency === undefined) {
|
||||
currentFrequency = this.get("siteSettings.remind_assigns_frequency");
|
||||
}
|
||||
|
||||
this.set("selectedFrequency", currentFrequency);
|
||||
},
|
||||
|
||||
actions: {
|
||||
setFrequency(newFrequency) {
|
||||
this.set("user.custom_fields.remind_assigns_frequency", newFrequency);
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
<div class="controls controls-dropdown">
|
||||
<label>{{i18n "discourse_assign.reminders_frequency.description"}}</label>
|
||||
{{combo-box
|
||||
valueAttribute="value"
|
||||
valueProperty="value"
|
||||
content=availableFrequencies
|
||||
value=selectedFrequency
|
||||
onSelect=(action "setFrequency")
|
||||
onChange=(mut user.custom_fields.remind_assigns_frequency)
|
||||
}}
|
||||
</div>
|
||||
{{/if}}
|
||||
|
|
Loading…
Reference in New Issue