Skip to content

Commit

Permalink
Merge branch 'main' into disable-sort
Browse files Browse the repository at this point in the history
  • Loading branch information
CvX committed Nov 29, 2024
2 parents 2bd56e7 + 6f682ac commit fa72591
Show file tree
Hide file tree
Showing 14 changed files with 279 additions and 169 deletions.
Original file line number Diff line number Diff line change
@@ -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/";
},
});
}
}
Original file line number Diff line number Diff line change
@@ -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";
},
});
}
}
Original file line number Diff line number Diff line change
@@ -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";
},
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -15,7 +15,7 @@ export default DiscoursePostEventAdapter.extend({
type: "DELETE",
}
);
},
}

update(store, type, id, attrs) {
const data = {};
Expand All @@ -28,7 +28,7 @@ export default DiscoursePostEventAdapter.extend({
).then(function (json) {
return new Result(json[typeField], json);
});
},
}

createRecord(store, type, attrs) {
const data = {};
Expand All @@ -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"];
Expand All @@ -61,5 +61,5 @@ export default DiscoursePostEventAdapter.extend({
}

return this.appendQueryParams(path, findArgs);
},
});
}
}
Original file line number Diff line number Diff line change
@@ -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";
},
});
}
}
Original file line number Diff line number Diff line change
@@ -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) {
Expand All @@ -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) {
Expand All @@ -43,5 +44,5 @@ export default Component.extend({
.then(() => this.set("isHolidayDisabled", false))
.catch(popupAjaxError)
.finally(() => this.set("loading", false));
},
});
}
}
Original file line number Diff line number Diff line change
@@ -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 = [
Expand All @@ -23,5 +23,5 @@ export default Component.extend({
btn.rel = "noopener noreferrer";
btn.download = "bulk-invite-sample.csv";
btn.click();
},
});
}
}
29 changes: 17 additions & 12 deletions assets/javascripts/discourse/components/region-input.js
Original file line number Diff line number Diff line change
@@ -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 = [];

Expand All @@ -35,5 +40,5 @@ export default ComboBoxComponent.extend({
})).sort((a, b) => a.name.localeCompare(b.name))
);
return regions;
}),
});
}
}
25 changes: 13 additions & 12 deletions assets/javascripts/discourse/components/upcoming-events-calendar.js
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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;
Expand Down Expand Up @@ -123,7 +124,7 @@ export default Component.extend({

this._calendar.render();
});
},
}

_loadCalendar() {
return new Promise((resolve) => {
Expand All @@ -139,5 +140,5 @@ export default Component.extend({
});
});
});
},
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -24,5 +24,5 @@ export default Controller.extend({
})
.catch(popupAjaxError)
.finally(() => this.set("loading", false));
},
});
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import Controller from "@ember/controller";

export default Controller.extend({});
export default class DiscoursePostEventUpcomingEventsIndexController extends Controller {}
Original file line number Diff line number Diff line change
@@ -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";
},
});
}
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"private": true,
"devDependencies": {
"@discourse/lint-configs": "2.2.1",
"@discourse/lint-configs": "2.2.2",
"ember-template-lint": "6.0.0",
"eslint": "9.14.0",
"eslint": "9.15.0",
"prettier": "2.8.8"
},
"engines": {
Expand Down
Loading

0 comments on commit fa72591

Please sign in to comment.