DEV: Convert to native class syntax (#653)
This commit is contained in:
parent
cb32ce6506
commit
6f682acae3
|
|
@ -1,7 +1,7 @@
|
|||
import RestAdapter from "discourse/adapters/rest";
|
||||
|
||||
export default RestAdapter.extend({
|
||||
export default class DiscoursePostEventAdapter extends RestAdapter {
|
||||
basePath() {
|
||||
return "/discourse-post-event/";
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
import { underscore } from "@ember/string";
|
||||
import DiscoursePostEventAdapter from "./discourse-post-event-adapter";
|
||||
|
||||
export default DiscoursePostEventAdapter.extend({
|
||||
export default class DiscoursePostEventEvent extends DiscoursePostEventAdapter {
|
||||
pathFor(store, type, findArgs) {
|
||||
const path =
|
||||
this.basePath(store, type, findArgs) +
|
||||
underscore(store.pluralize(this.apiNameFor(type)));
|
||||
return this.appendQueryParams(path, findArgs);
|
||||
},
|
||||
}
|
||||
|
||||
apiNameFor() {
|
||||
return "event";
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import DiscoursePostEventNestedAdapter from "./discourse-post-event-nested-adapter";
|
||||
|
||||
export default DiscoursePostEventNestedAdapter.extend({
|
||||
export default class DiscoursePostEventInvitee extends DiscoursePostEventNestedAdapter {
|
||||
apiNameFor() {
|
||||
return "invitee";
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import { Result } from "discourse/adapters/rest";
|
|||
import { ajax } from "discourse/lib/ajax";
|
||||
import DiscoursePostEventAdapter from "./discourse-post-event-adapter";
|
||||
|
||||
export default DiscoursePostEventAdapter.extend({
|
||||
export default class DiscoursePostEventNestedAdapter extends DiscoursePostEventAdapter {
|
||||
// TODO: destroy/update/create should be improved in core to allow for nested models
|
||||
destroyRecord(store, type, record) {
|
||||
return ajax(
|
||||
|
|
@ -15,7 +15,7 @@ export default DiscoursePostEventAdapter.extend({
|
|||
type: "DELETE",
|
||||
}
|
||||
);
|
||||
},
|
||||
}
|
||||
|
||||
update(store, type, id, attrs) {
|
||||
const data = {};
|
||||
|
|
@ -28,7 +28,7 @@ export default DiscoursePostEventAdapter.extend({
|
|||
).then(function (json) {
|
||||
return new Result(json[typeField], json);
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
createRecord(store, type, attrs) {
|
||||
const data = {};
|
||||
|
|
@ -40,7 +40,7 @@ export default DiscoursePostEventAdapter.extend({
|
|||
).then(function (json) {
|
||||
return new Result(json[typeField], json);
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
pathFor(store, type, findArgs) {
|
||||
const post_id = findArgs["post_id"];
|
||||
|
|
@ -61,5 +61,5 @@ export default DiscoursePostEventAdapter.extend({
|
|||
}
|
||||
|
||||
return this.appendQueryParams(path, findArgs);
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import DiscoursePostEventNestedAdapter from "./discourse-post-event-nested-adapter";
|
||||
|
||||
export default DiscoursePostEventNestedAdapter.extend({
|
||||
export default class DiscoursePostEventReminder extends DiscoursePostEventNestedAdapter {
|
||||
apiNameFor() {
|
||||
return "reminder";
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,13 +1,14 @@
|
|||
import Component from "@ember/component";
|
||||
import { action } from "@ember/object";
|
||||
import { classNameBindings, tagName } from "@ember-decorators/component";
|
||||
import { ajax } from "discourse/lib/ajax";
|
||||
import { popupAjaxError } from "discourse/lib/ajax-error";
|
||||
|
||||
export default Component.extend({
|
||||
tagName: "tr",
|
||||
classNameBindings: ["isHolidayDisabled:disabled"],
|
||||
loading: false,
|
||||
isHolidayDisabled: false,
|
||||
@tagName("tr")
|
||||
@classNameBindings("isHolidayDisabled:disabled")
|
||||
export default class AdminHolidaysListItem extends Component {
|
||||
loading = false;
|
||||
isHolidayDisabled = false;
|
||||
|
||||
@action
|
||||
disableHoliday(holiday, region_code) {
|
||||
|
|
@ -25,7 +26,7 @@ export default Component.extend({
|
|||
.then(() => this.set("isHolidayDisabled", true))
|
||||
.catch(popupAjaxError)
|
||||
.finally(() => this.set("loading", false));
|
||||
},
|
||||
}
|
||||
|
||||
@action
|
||||
enableHoliday(holiday, region_code) {
|
||||
|
|
@ -43,5 +44,5 @@ export default Component.extend({
|
|||
.then(() => this.set("isHolidayDisabled", false))
|
||||
.catch(popupAjaxError)
|
||||
.finally(() => this.set("loading", false));
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import Component from "@ember/component";
|
||||
import { action } from "@ember/object";
|
||||
|
||||
export default Component.extend({
|
||||
export default class BulkInviteSampleCsvFile extends Component {
|
||||
@action
|
||||
downloadSampleCsv() {
|
||||
const sampleData = [
|
||||
|
|
@ -23,5 +23,5 @@ export default Component.extend({
|
|||
btn.rel = "noopener noreferrer";
|
||||
btn.download = "bulk-invite-sample.csv";
|
||||
btn.click();
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,19 +1,24 @@
|
|||
import { computed } from "@ember/object";
|
||||
import { classNames } from "@ember-decorators/component";
|
||||
import I18n from "I18n";
|
||||
import ComboBoxComponent from "select-kit/components/combo-box";
|
||||
import {
|
||||
pluginApiIdentifiers,
|
||||
selectKitOptions,
|
||||
} from "select-kit/components/select-kit";
|
||||
import { HOLIDAY_REGIONS } from "../lib/regions";
|
||||
|
||||
export default ComboBoxComponent.extend({
|
||||
pluginApiIdentifiers: ["timezone-input"],
|
||||
classNames: ["timezone-input", "region-input"],
|
||||
allowNoneRegion: false,
|
||||
@selectKitOptions({
|
||||
filterable: true,
|
||||
allowAny: false,
|
||||
})
|
||||
@pluginApiIdentifiers("timezone-input")
|
||||
@classNames("timezone-input", "region-input")
|
||||
export default class RegionInput extends ComboBoxComponent {
|
||||
allowNoneRegion = false;
|
||||
|
||||
selectKitOptions: {
|
||||
filterable: true,
|
||||
allowAny: false,
|
||||
},
|
||||
|
||||
content: computed(function () {
|
||||
@computed
|
||||
get content() {
|
||||
const localeNames = {};
|
||||
let regions = [];
|
||||
|
||||
|
|
@ -35,5 +40,5 @@ export default ComboBoxComponent.extend({
|
|||
})).sort((a, b) => a.name.localeCompare(b.name))
|
||||
);
|
||||
return regions;
|
||||
}),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import Component from "@ember/component";
|
||||
import { schedule } from "@ember/runloop";
|
||||
import { tagName } from "@ember-decorators/component";
|
||||
import { Promise } from "rsvp";
|
||||
import loadScript from "discourse/lib/load-script";
|
||||
import Category from "discourse/models/category";
|
||||
|
|
@ -9,28 +10,28 @@ import addRecurrentEvents from "../lib/add-recurrent-events";
|
|||
import fullCalendarDefaultOptions from "../lib/full-calendar-default-options";
|
||||
import { isNotFullDayEvent } from "../lib/guess-best-date-format";
|
||||
|
||||
export default Component.extend({
|
||||
tagName: "",
|
||||
events: null,
|
||||
@tagName("")
|
||||
export default class UpcomingEventsCalendar extends Component {
|
||||
events = null;
|
||||
|
||||
init() {
|
||||
this._super(...arguments);
|
||||
super.init(...arguments);
|
||||
|
||||
this._calendar = null;
|
||||
},
|
||||
}
|
||||
|
||||
willDestroyElement() {
|
||||
this._super(...arguments);
|
||||
super.willDestroyElement(...arguments);
|
||||
|
||||
this._calendar && this._calendar.destroy();
|
||||
this._calendar = null;
|
||||
},
|
||||
}
|
||||
|
||||
didInsertElement() {
|
||||
this._super(...arguments);
|
||||
super.didInsertElement(...arguments);
|
||||
|
||||
this._renderCalendar();
|
||||
},
|
||||
}
|
||||
|
||||
_renderCalendar() {
|
||||
const siteSettings = this.site.siteSettings;
|
||||
|
|
@ -123,7 +124,7 @@ export default Component.extend({
|
|||
|
||||
this._calendar.render();
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
_loadCalendar() {
|
||||
return new Promise((resolve) => {
|
||||
|
|
@ -139,5 +140,5 @@ export default Component.extend({
|
|||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,9 +3,9 @@ import { action } from "@ember/object";
|
|||
import { ajax } from "discourse/lib/ajax";
|
||||
import { popupAjaxError } from "discourse/lib/ajax-error";
|
||||
|
||||
export default Controller.extend({
|
||||
selectedRegion: null,
|
||||
loading: false,
|
||||
export default class AdminPluginsCalendarController extends Controller {
|
||||
selectedRegion = null;
|
||||
loading = false;
|
||||
|
||||
@action
|
||||
async getHolidays(region_code) {
|
||||
|
|
@ -24,5 +24,5 @@ export default Controller.extend({
|
|||
})
|
||||
.catch(popupAjaxError)
|
||||
.finally(() => this.set("loading", false));
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
import Controller from "@ember/controller";
|
||||
|
||||
export default Controller.extend({});
|
||||
export default class DiscoursePostEventUpcomingEventsIndexController extends Controller {}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
import RestModel from "discourse/models/rest";
|
||||
|
||||
export default RestModel.extend({
|
||||
export default class DiscoursePostEventReminder extends RestModel {
|
||||
init() {
|
||||
this._super(...arguments);
|
||||
super.init(...arguments);
|
||||
|
||||
this.__type = "discourse-post-event-reminder";
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue