DEV: apply coding standards (#59)
This commit is contained in:
parent
84a051fbf2
commit
9b0aac2100
|
@ -2,3 +2,6 @@
|
|||
gems/
|
||||
/node_modules
|
||||
.on-save.json
|
||||
node_modules
|
||||
yarn-error.log
|
||||
.rubocop-https---raw-githubusercontent-com-discourse-*
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
{}
|
|
@ -0,0 +1,4 @@
|
|||
module.exports = {
|
||||
plugins: ["ember-template-lint-plugin-discourse"],
|
||||
extends: "discourse:recommended",
|
||||
};
|
|
@ -14,7 +14,7 @@ export default {
|
|||
setupComponent(args, component) {
|
||||
component.setProperties({
|
||||
holidayEmojiName: `:${HOLIDAY_EMOJI_NAME}:`,
|
||||
holidayEmoji: emojiUrlFor(HOLIDAY_EMOJI_NAME)
|
||||
holidayEmoji: emojiUrlFor(HOLIDAY_EMOJI_NAME),
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
export default {
|
||||
shouldRender(_, ctx) {
|
||||
return ctx.siteSettings.calendar_categories_outlet === ctx.name;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
export default {
|
||||
shouldRender(_, ctx) {
|
||||
return ctx.siteSettings.calendar_categories_outlet === ctx.name;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
|
@ -15,11 +15,11 @@ export default {
|
|||
"custom_fields.holidays-region",
|
||||
TIME_ZONE_TO_REGION[moment.tz.guess()] || "us"
|
||||
);
|
||||
}
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
shouldRender(args, component) {
|
||||
return component.siteSettings.calendar_enabled;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
|
@ -3,5 +3,5 @@ import RestAdapter from "discourse/adapters/rest";
|
|||
export default RestAdapter.extend({
|
||||
basePath() {
|
||||
return "/discourse-post-event/";
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
|
@ -11,5 +11,5 @@ export default DiscoursePostEventAdapter.extend({
|
|||
|
||||
apiNameFor() {
|
||||
return "event";
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
|
@ -3,5 +3,5 @@ import DiscoursePostEventNestedAdapter from "./discourse-post-event-nested-adapt
|
|||
export default DiscoursePostEventNestedAdapter.extend({
|
||||
apiNameFor() {
|
||||
return "invitee";
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
|
@ -9,10 +9,10 @@ export default DiscoursePostEventAdapter.extend({
|
|||
return ajax(
|
||||
this.pathFor(store, type, {
|
||||
post_id: record.post_id,
|
||||
id: record.id
|
||||
id: record.id,
|
||||
}),
|
||||
{
|
||||
type: "DELETE"
|
||||
type: "DELETE",
|
||||
}
|
||||
);
|
||||
},
|
||||
|
@ -25,7 +25,7 @@ export default DiscoursePostEventAdapter.extend({
|
|||
return ajax(
|
||||
this.pathFor(store, type, { id, post_id: attrs.post_id }),
|
||||
this.getPayload("PUT", data)
|
||||
).then(function(json) {
|
||||
).then(function (json) {
|
||||
return new Result(json[typeField], json);
|
||||
});
|
||||
},
|
||||
|
@ -37,7 +37,7 @@ export default DiscoursePostEventAdapter.extend({
|
|||
return ajax(
|
||||
this.pathFor(store, type, attrs),
|
||||
this.getPayload("POST", data)
|
||||
).then(function(json) {
|
||||
).then(function (json) {
|
||||
return new Result(json[typeField], json);
|
||||
});
|
||||
},
|
||||
|
@ -61,5 +61,5 @@ export default DiscoursePostEventAdapter.extend({
|
|||
}
|
||||
|
||||
return this.appendQueryParams(path, findArgs);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
|
@ -3,5 +3,5 @@ import DiscoursePostEventNestedAdapter from "./discourse-post-event-nested-adapt
|
|||
export default DiscoursePostEventNestedAdapter.extend({
|
||||
apiNameFor() {
|
||||
return "reminder";
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
|
@ -8,11 +8,11 @@ export default Component.extend({
|
|||
["my_awesome_group", "going"],
|
||||
["lucy", "interested"],
|
||||
["mark", "not_going"],
|
||||
["sam", "unknown"]
|
||||
["sam", "unknown"],
|
||||
];
|
||||
|
||||
let csv = "";
|
||||
sampleData.forEach(row => {
|
||||
sampleData.forEach((row) => {
|
||||
csv += row.join(",");
|
||||
csv += "\n";
|
||||
});
|
||||
|
@ -23,5 +23,5 @@ export default Component.extend({
|
|||
btn.rel = "noopener noreferrer";
|
||||
btn.download = "bulk-invite-sample.csv";
|
||||
btn.click();
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
|
@ -2,5 +2,5 @@ import Component from "@ember/component";
|
|||
|
||||
export default Component.extend({
|
||||
enabled: true,
|
||||
class: null
|
||||
class: null,
|
||||
});
|
||||
|
|
|
@ -9,20 +9,20 @@ export default ComboBoxComponent.extend({
|
|||
|
||||
selectKitOptions: {
|
||||
filterable: true,
|
||||
allowAny: false
|
||||
allowAny: false,
|
||||
},
|
||||
|
||||
content: computed(function() {
|
||||
content: computed(function () {
|
||||
const localeNames = {};
|
||||
JSON.parse(this.siteSettings.available_locales).forEach(locale => {
|
||||
JSON.parse(this.siteSettings.available_locales).forEach((locale) => {
|
||||
localeNames[locale.value] = locale.name;
|
||||
});
|
||||
|
||||
return HOLIDAY_REGIONS.map(region => {
|
||||
return HOLIDAY_REGIONS.map((region) => {
|
||||
return {
|
||||
name: I18n.t(`discourse_calendar.region.names.${region}`),
|
||||
id: region
|
||||
id: region,
|
||||
};
|
||||
}).sort((a, b) => a.name.localeCompare(b.name));
|
||||
})
|
||||
}),
|
||||
});
|
||||
|
|
|
@ -40,14 +40,14 @@ export default Component.extend({
|
|||
this._loadCalendar().then(() => {
|
||||
this._calendar = new window.FullCalendar.Calendar(calendarNode, {});
|
||||
|
||||
(this.events || []).forEach(event => {
|
||||
(this.events || []).forEach((event) => {
|
||||
const { starts_at, ends_at, post } = event;
|
||||
this._calendar.addEvent({
|
||||
title: formatEventName(event),
|
||||
start: starts_at,
|
||||
end: ends_at || starts_at,
|
||||
allDay: !isNotFullDayEvent(moment(starts_at), moment(ends_at)),
|
||||
url: getURL(`/t/-/${post.topic.id}/${post.post_number}`)
|
||||
url: getURL(`/t/-/${post.topic.id}/${post.post_number}`),
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -56,7 +56,7 @@ export default Component.extend({
|
|||
},
|
||||
|
||||
_loadCalendar() {
|
||||
return new Promise(resolve => {
|
||||
return new Promise((resolve) => {
|
||||
loadScript(
|
||||
"/plugins/discourse-calendar/javascripts/fullcalendar-with-moment-timezone.min.js"
|
||||
).then(() => {
|
||||
|
@ -69,5 +69,5 @@ export default Component.extend({
|
|||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import I18n from "I18n";
|
||||
import TextLib from "discourse/lib/text";
|
||||
import Group from "discourse/models/group";
|
||||
import ModalFunctionality from "discourse/mixins/modal-functionality";
|
||||
|
@ -23,7 +24,7 @@ export default Controller.extend(ModalFunctionality, {
|
|||
"every_day",
|
||||
"every_month",
|
||||
"every_weekday",
|
||||
"every_week"
|
||||
"every_week",
|
||||
]);
|
||||
},
|
||||
|
||||
|
@ -32,12 +33,12 @@ export default Controller.extend(ModalFunctionality, {
|
|||
return this.model.eventModel.isNew
|
||||
? "create_event_title"
|
||||
: "update_event_title";
|
||||
}
|
||||
},
|
||||
}),
|
||||
|
||||
allowedCustomFields: computed(
|
||||
"siteSettings.discourse_post_event_allowed_custom_fields",
|
||||
function() {
|
||||
function () {
|
||||
return this.siteSettings.discourse_post_event_allowed_custom_fields
|
||||
.split("|")
|
||||
.filter(Boolean);
|
||||
|
@ -65,7 +66,7 @@ export default Controller.extend(ModalFunctionality, {
|
|||
if (newStatus === "private") {
|
||||
this.setRawInvitees(
|
||||
null,
|
||||
this.model.eventModel.raw_invitees.filter(x => x !== "trust_level_0")
|
||||
this.model.eventModel.raw_invitees.filter((x) => x !== "trust_level_0")
|
||||
);
|
||||
}
|
||||
this.set("model.eventModel.status", newStatus);
|
||||
|
@ -97,7 +98,7 @@ export default Controller.extend(ModalFunctionality, {
|
|||
return this.model.eventModel.starts_at
|
||||
? moment(this.model.eventModel.starts_at)
|
||||
: moment();
|
||||
}
|
||||
},
|
||||
}),
|
||||
|
||||
endsAt: computed("model.eventModel.ends_at", {
|
||||
|
@ -105,7 +106,7 @@ export default Controller.extend(ModalFunctionality, {
|
|||
return (
|
||||
this.model.eventModel.ends_at && moment(this.model.eventModel.ends_at)
|
||||
);
|
||||
}
|
||||
},
|
||||
}),
|
||||
|
||||
standaloneEvent: equal("model.eventModel.status", "standalone"),
|
||||
|
@ -116,7 +117,7 @@ export default Controller.extend(ModalFunctionality, {
|
|||
onChangeDates(changes) {
|
||||
this.model.eventModel.setProperties({
|
||||
starts_at: changes.from,
|
||||
ends_at: changes.to
|
||||
ends_at: changes.to,
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -126,27 +127,27 @@ export default Controller.extend(ModalFunctionality, {
|
|||
I18n.t("discourse_post_event.builder_modal.confirm_delete"),
|
||||
I18n.t("no_value"),
|
||||
I18n.t("yes_value"),
|
||||
confirmed => {
|
||||
(confirmed) => {
|
||||
if (confirmed) {
|
||||
return this.store
|
||||
.find("post", this.model.eventModel.id)
|
||||
.then(post => {
|
||||
.then((post) => {
|
||||
const raw = post.raw;
|
||||
const newRaw = this._removeRawEvent(raw);
|
||||
const props = {
|
||||
raw: newRaw,
|
||||
edit_reason: I18n.t("discourse_post_event.destroy_event")
|
||||
edit_reason: I18n.t("discourse_post_event.destroy_event"),
|
||||
};
|
||||
|
||||
return TextLib.cookAsync(newRaw).then(cooked => {
|
||||
return TextLib.cookAsync(newRaw).then((cooked) => {
|
||||
props.cooked = cooked.string;
|
||||
return post
|
||||
.save(props)
|
||||
.catch(e => this.flash(extractError(e), "error"))
|
||||
.then(result => result && this.send("closeModal"));
|
||||
.catch((e) => this.flash(extractError(e), "error"))
|
||||
.then((result) => result && this.send("closeModal"));
|
||||
});
|
||||
})
|
||||
.catch(e => this.flash(extractError(e), "error"));
|
||||
.catch((e) => this.flash(extractError(e), "error"));
|
||||
}
|
||||
}
|
||||
);
|
||||
|
@ -166,7 +167,7 @@ export default Controller.extend(ModalFunctionality, {
|
|||
this.siteSettings
|
||||
);
|
||||
const markdownParams = [];
|
||||
Object.keys(eventParams).forEach(key => {
|
||||
Object.keys(eventParams).forEach((key) => {
|
||||
let value = eventParams[key];
|
||||
markdownParams.push(`${key}="${value}"`);
|
||||
});
|
||||
|
@ -177,7 +178,7 @@ export default Controller.extend(ModalFunctionality, {
|
|||
|
||||
@action
|
||||
updateEvent() {
|
||||
return this.store.find("post", this.model.eventModel.id).then(post => {
|
||||
return this.store.find("post", this.model.eventModel.id).then((post) => {
|
||||
const raw = post.raw;
|
||||
const eventParams = buildParams(
|
||||
this.startsAt,
|
||||
|
@ -191,15 +192,15 @@ export default Controller.extend(ModalFunctionality, {
|
|||
if (newRaw) {
|
||||
const props = {
|
||||
raw: newRaw,
|
||||
edit_reason: I18n.t("discourse_post_event.edit_reason")
|
||||
edit_reason: I18n.t("discourse_post_event.edit_reason"),
|
||||
};
|
||||
|
||||
return TextLib.cookAsync(newRaw).then(cooked => {
|
||||
return TextLib.cookAsync(newRaw).then((cooked) => {
|
||||
props.cooked = cooked.string;
|
||||
return post
|
||||
.save(props)
|
||||
.catch(e => this.flash(extractError(e), "error"))
|
||||
.then(result => result && this.send("closeModal"));
|
||||
.catch((e) => this.flash(extractError(e), "error"))
|
||||
.then((result) => result && this.send("closeModal"));
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -208,5 +209,5 @@ export default Controller.extend(ModalFunctionality, {
|
|||
_removeRawEvent(raw) {
|
||||
const eventRegex = new RegExp(`\\[event\\s(.*?)\\]\\n\\[\\/event\\]`, "m");
|
||||
return raw.replace(eventRegex, "");
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
|
@ -19,26 +19,26 @@ export default Controller.extend(ModalFunctionality, {
|
|||
this.set("bulkInviteStatuses", [
|
||||
{
|
||||
label: I18n.t("discourse_post_event.models.invitee.status.unknown"),
|
||||
name: "unknown"
|
||||
name: "unknown",
|
||||
},
|
||||
{
|
||||
label: I18n.t("discourse_post_event.models.invitee.status.going"),
|
||||
name: "going"
|
||||
name: "going",
|
||||
},
|
||||
{
|
||||
label: I18n.t("discourse_post_event.models.invitee.status.not_going"),
|
||||
name: "not_going"
|
||||
name: "not_going",
|
||||
},
|
||||
{
|
||||
label: I18n.t("discourse_post_event.models.invitee.status.interested"),
|
||||
name: "interested"
|
||||
}
|
||||
name: "interested",
|
||||
},
|
||||
]);
|
||||
},
|
||||
|
||||
onShow() {
|
||||
this.set("bulkInvites", [
|
||||
EmberObject.create({ identifier: null, attendance: "unknown" })
|
||||
EmberObject.create({ identifier: null, attendance: "unknown" }),
|
||||
]);
|
||||
},
|
||||
|
||||
|
@ -53,7 +53,7 @@ export default Controller.extend(ModalFunctionality, {
|
|||
setBulkInviteDisabled() {
|
||||
this.set(
|
||||
"bulkInviteDisabled",
|
||||
this.bulkInvites.filter(x => isPresent(x.identifier)).length === 0
|
||||
this.bulkInvites.filter((x) => isPresent(x.identifier)).length === 0
|
||||
);
|
||||
},
|
||||
|
||||
|
@ -66,16 +66,16 @@ export default Controller.extend(ModalFunctionality, {
|
|||
dataType: "json",
|
||||
contentType: "application/json",
|
||||
data: JSON.stringify({
|
||||
invitees: this.bulkInvites.filter(x => isPresent(x.identifier))
|
||||
})
|
||||
invitees: this.bulkInvites.filter((x) => isPresent(x.identifier)),
|
||||
}),
|
||||
}
|
||||
)
|
||||
.then(data => {
|
||||
.then((data) => {
|
||||
if (data.success) {
|
||||
this.send("closeModal");
|
||||
}
|
||||
})
|
||||
.catch(e => this.flash(extractError(e), "error"));
|
||||
.catch((e) => this.flash(extractError(e), "error"));
|
||||
},
|
||||
|
||||
@action
|
||||
|
@ -84,7 +84,7 @@ export default Controller.extend(ModalFunctionality, {
|
|||
|
||||
if (!this.bulkInvites.length) {
|
||||
this.set("bulkInvites", [
|
||||
EmberObject.create({ identifier: null, attendance: "unknown" })
|
||||
EmberObject.create({ identifier: null, attendance: "unknown" }),
|
||||
]);
|
||||
}
|
||||
},
|
||||
|
@ -104,5 +104,5 @@ export default Controller.extend(ModalFunctionality, {
|
|||
this.send("closeModal");
|
||||
}
|
||||
);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
|
@ -20,9 +20,9 @@ export default Controller.extend(ModalFunctionality, {
|
|||
invite() {
|
||||
return ajax(`/discourse-post-event/events/${this.model.id}/invite.json`, {
|
||||
data: { invites: this.invitedNames || [] },
|
||||
type: "POST"
|
||||
type: "POST",
|
||||
})
|
||||
.then(() => this.send("closeModal"))
|
||||
.catch(e => this.flash(extractError(e), "error"));
|
||||
}
|
||||
.catch((e) => this.flash(extractError(e), "error"));
|
||||
},
|
||||
});
|
||||
|
|
|
@ -28,9 +28,9 @@ export default Controller.extend(ModalFunctionality, {
|
|||
this.store
|
||||
.findAll("discourse-post-event-invitee", {
|
||||
filter,
|
||||
post_id: this.model.id
|
||||
post_id: this.model.id,
|
||||
})
|
||||
.then(invitees => this.set("invitees", invitees))
|
||||
.then((invitees) => this.set("invitees", invitees))
|
||||
.finally(() => this.set("isLoading", false));
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
export default function() {
|
||||
export default function () {
|
||||
this.route(
|
||||
"discourse-post-event-upcoming-events",
|
||||
{ path: "/upcoming-events" },
|
||||
function() {
|
||||
function () {
|
||||
this.route("index", { path: "/" });
|
||||
}
|
||||
);
|
||||
|
|
|
@ -11,14 +11,14 @@ const ATTRIBUTES = {
|
|||
status: {
|
||||
transform(value) {
|
||||
return STATUSES[value];
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const STATUSES = {
|
||||
standalone: 0,
|
||||
public: 1,
|
||||
private: 2
|
||||
private: 2,
|
||||
};
|
||||
|
||||
const Event = RestModel.extend({
|
||||
|
@ -33,7 +33,7 @@ const Event = RestModel.extend({
|
|||
type: "PUT",
|
||||
dataType: "json",
|
||||
contentType: "application/json",
|
||||
data: JSON.stringify({ event: data })
|
||||
data: JSON.stringify({ event: data }),
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -49,7 +49,7 @@ const Event = RestModel.extend({
|
|||
|
||||
_transformProps(props) {
|
||||
const attributesKeys = Object.keys(ATTRIBUTES);
|
||||
attributesKeys.forEach(key => {
|
||||
attributesKeys.forEach((key) => {
|
||||
const attribute = ATTRIBUTES[key];
|
||||
if (attribute.transform) {
|
||||
props[key] = attribute.transform(props[key]);
|
||||
|
@ -63,7 +63,7 @@ const Event = RestModel.extend({
|
|||
|
||||
beforeCreate(props) {
|
||||
this._transformProps(props);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
export default Event;
|
||||
|
|
|
@ -5,5 +5,5 @@ export default RestModel.extend({
|
|||
this._super(...arguments);
|
||||
|
||||
this.__type = "discourse-post-event-invitee";
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
|
@ -5,5 +5,5 @@ export default RestModel.extend({
|
|||
this._super(...arguments);
|
||||
|
||||
this.__type = "discourse-post-event-reminder";
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
|
@ -3,7 +3,7 @@ import Route from "@ember/routing/route";
|
|||
import { on } from "@ember/object/evented";
|
||||
|
||||
export default Route.extend({
|
||||
enforcePostEventEnabled: on("activate", function() {
|
||||
enforcePostEventEnabled: on("activate", function () {
|
||||
if (!this.siteSettings.discourse_post_event_enabled) {
|
||||
DiscourseURL.redirectTo("/404");
|
||||
}
|
||||
|
@ -11,5 +11,5 @@ export default Route.extend({
|
|||
|
||||
model(params) {
|
||||
return this.store.findAll("discourse-post-event-event", params);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
|
@ -13,5 +13,5 @@ export default createWidget("discourse-group-timezone-new-day", {
|
|||
{{this.attrs.groupedTimezone.afterDate}}
|
||||
{{d-icon "chevron-right"}}
|
||||
</span>
|
||||
`
|
||||
`,
|
||||
});
|
||||
|
|
|
@ -20,7 +20,7 @@ export default createWidget("discourse-group-timezone", {
|
|||
|
||||
transform(attrs) {
|
||||
return {
|
||||
formatedTime: attrs.groupedTimezone.nowWithOffset.format("LT")
|
||||
formatedTime: attrs.groupedTimezone.nowWithOffset.format("LT"),
|
||||
};
|
||||
},
|
||||
|
||||
|
@ -44,5 +44,5 @@ export default createWidget("discourse-group-timezone", {
|
|||
}}
|
||||
{{/each}}
|
||||
</ul>
|
||||
`
|
||||
`,
|
||||
});
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import I18n from "I18n";
|
||||
import { createWidget } from "discourse/widgets/widget";
|
||||
import { throttle } from "@ember/runloop";
|
||||
|
||||
|
@ -11,7 +12,7 @@ export default createWidget("discourse-group-timezones-filter", {
|
|||
changeFilterThrottler(filter) {
|
||||
throttle(
|
||||
this,
|
||||
function() {
|
||||
function () {
|
||||
this.sendWidgetAction("onChangeFilter", filter);
|
||||
},
|
||||
100
|
||||
|
@ -21,7 +22,7 @@ export default createWidget("discourse-group-timezones-filter", {
|
|||
buildAttributes() {
|
||||
return {
|
||||
type: "text",
|
||||
placeholder: I18n.t("group_timezones.search")
|
||||
placeholder: I18n.t("group_timezones.search"),
|
||||
};
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import I18n from "I18n";
|
||||
import hbs from "discourse/widgets/hbs-compiler";
|
||||
import { createWidget } from "discourse/widgets/widget";
|
||||
|
||||
|
@ -7,8 +8,8 @@ export default createWidget("discourse-group-timezones-header", {
|
|||
transform(attrs) {
|
||||
return {
|
||||
title: I18n.t("group_timezones.group_availability", {
|
||||
group: attrs.group
|
||||
})
|
||||
group: attrs.group,
|
||||
}),
|
||||
};
|
||||
},
|
||||
|
||||
|
@ -24,5 +25,5 @@ export default createWidget("discourse-group-timezones-header", {
|
|||
{{transformed.title}}
|
||||
</span>
|
||||
{{attach widget="discourse-group-timezones-filter"}}
|
||||
`
|
||||
`,
|
||||
});
|
||||
|
|
|
@ -20,13 +20,13 @@ export default createWidget("discourse-group-timezones-member", {
|
|||
{
|
||||
attributes: {
|
||||
class: "group-timezones-member-avatar",
|
||||
"data-user-card": username
|
||||
}
|
||||
"data-user-card": username,
|
||||
},
|
||||
},
|
||||
avatarImg("small", {
|
||||
template: avatar_template,
|
||||
username: name || formatUsername(username)
|
||||
username: name || formatUsername(username),
|
||||
})
|
||||
);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
|
@ -18,7 +18,7 @@ export default createWidget("discourse-group-timezones-reset", {
|
|||
|
||||
transform(attrs) {
|
||||
return {
|
||||
isDisabled: attrs.localTimeOffset === 0
|
||||
isDisabled: attrs.localTimeOffset === 0,
|
||||
};
|
||||
},
|
||||
|
||||
|
@ -31,5 +31,5 @@ export default createWidget("discourse-group-timezones-reset", {
|
|||
icon="undo"
|
||||
)
|
||||
}}
|
||||
`
|
||||
`,
|
||||
});
|
||||
|
|
|
@ -15,7 +15,7 @@ export default createWidget("discourse-group-timezones-slider", {
|
|||
changeOffsetThrottler(offset) {
|
||||
throttle(
|
||||
this,
|
||||
function() {
|
||||
function () {
|
||||
this.sendWidgetAction("onChangeCurrentUserTimeOffset", offset);
|
||||
},
|
||||
75
|
||||
|
@ -28,7 +28,7 @@ export default createWidget("discourse-group-timezones-slider", {
|
|||
value: 0,
|
||||
min: -48,
|
||||
max: 48,
|
||||
type: "range"
|
||||
type: "range",
|
||||
};
|
||||
},
|
||||
|
||||
|
@ -36,5 +36,5 @@ export default createWidget("discourse-group-timezones-slider", {
|
|||
const value = parseInt(event.target.value, 10);
|
||||
const offset = value * 15;
|
||||
this.changeOffsetThrottler(offset);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
|
@ -13,7 +13,7 @@ export default createWidget("discourse-group-timezones-time-traveler", {
|
|||
}
|
||||
|
||||
return {
|
||||
localTimeWithOffset: date.format("HH:mm")
|
||||
localTimeWithOffset: date.format("HH:mm"),
|
||||
};
|
||||
},
|
||||
|
||||
|
@ -31,5 +31,5 @@ export default createWidget("discourse-group-timezones-time-traveler", {
|
|||
localTimeOffset=attrs.localTimeOffset
|
||||
)
|
||||
}}
|
||||
`
|
||||
`,
|
||||
});
|
||||
|
|
|
@ -5,7 +5,7 @@ import roundTime from "discourse/plugins/discourse-calendar/lib/round-time";
|
|||
export default createWidget("discourse-group-timezones", {
|
||||
tagName: "div.group-timezones",
|
||||
|
||||
buildKey: attrs => `group-timezones-${attrs.id}`,
|
||||
buildKey: (attrs) => `group-timezones-${attrs.id}`,
|
||||
|
||||
buildClasses(attrs) {
|
||||
return attrs.size;
|
||||
|
@ -13,13 +13,13 @@ export default createWidget("discourse-group-timezones", {
|
|||
|
||||
buildAttributes(attrs) {
|
||||
return {
|
||||
id: attrs.id
|
||||
id: attrs.id,
|
||||
};
|
||||
},
|
||||
|
||||
defaultState() {
|
||||
return {
|
||||
localTimeOffset: 0
|
||||
localTimeOffset: 0,
|
||||
};
|
||||
},
|
||||
|
||||
|
@ -31,7 +31,7 @@ export default createWidget("discourse-group-timezones", {
|
|||
const members = attrs.members || [];
|
||||
let groupedTimezones = [];
|
||||
|
||||
members.filterBy("timezone").forEach(member => {
|
||||
members.filterBy("timezone").forEach((member) => {
|
||||
if (this._shouldAddMemberToGroup(this.state.filter, member)) {
|
||||
const timezone = member.timezone;
|
||||
const identifier = parseInt(moment.tz(timezone).format("YYYYMDHm"), 10);
|
||||
|
@ -52,7 +52,7 @@ export default createWidget("discourse-group-timezones", {
|
|||
closeToWorkingHours: this._closeToWorkingHours(now, workingDays),
|
||||
inWorkingHours: this._inWorkingHours(now, workingDays),
|
||||
utcOffset: this._utcOffset(offset),
|
||||
members: [member]
|
||||
members: [member],
|
||||
};
|
||||
groupedTimezones.push(groupedTimezone);
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ export default createWidget("discourse-group-timezones", {
|
|||
|
||||
groupedTimezones = groupedTimezones
|
||||
.sortBy("offset")
|
||||
.filter(g => g.members.length);
|
||||
.filter((g) => g.members.length);
|
||||
|
||||
let newDayIndex;
|
||||
groupedTimezones.forEach((groupedTimezone, index) => {
|
||||
|
@ -81,7 +81,7 @@ export default createWidget("discourse-group-timezones", {
|
|||
beforeDate: groupedTimezones[newDayIndex - 1].nowWithOffset.format(
|
||||
"dddd"
|
||||
),
|
||||
afterDate: groupedTimezones[newDayIndex].nowWithOffset.format("dddd")
|
||||
afterDate: groupedTimezones[newDayIndex].nowWithOffset.format("dddd"),
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -175,11 +175,11 @@ export default createWidget("discourse-group-timezones", {
|
|||
|
||||
_workingDays() {
|
||||
const enMoment = moment().locale("en");
|
||||
const getIsoWeekday = day =>
|
||||
const getIsoWeekday = (day) =>
|
||||
enMoment.localeData()._weekdays.indexOf(day) || 7;
|
||||
return this.siteSettings.working_days
|
||||
.split("|")
|
||||
.filter(Boolean)
|
||||
.map(x => getIsoWeekday(x));
|
||||
}
|
||||
.map((x) => getIsoWeekday(x));
|
||||
},
|
||||
});
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import I18n from "I18n";
|
||||
import RawHtml from "discourse/widgets/raw-html";
|
||||
import { iconNode } from "discourse-common/lib/icon-library";
|
||||
import { h } from "virtual-dom";
|
||||
|
@ -10,14 +11,14 @@ export default createWidget("discourse-post-event-dates", {
|
|||
this.sendWidgetAction("showAllInvitees", {
|
||||
postId,
|
||||
title: "title_participated",
|
||||
extraClass: "participated"
|
||||
extraClass: "participated",
|
||||
});
|
||||
},
|
||||
|
||||
html(attrs) {
|
||||
const content = [
|
||||
iconNode("clock"),
|
||||
h("span.date", new RawHtml({ html: `<span>${attrs.localDates}</span>` }))
|
||||
h("span.date", new RawHtml({ html: `<span>${attrs.localDates}</span>` })),
|
||||
];
|
||||
|
||||
if (
|
||||
|
@ -26,13 +27,13 @@ export default createWidget("discourse-post-event-dates", {
|
|||
) {
|
||||
let participants;
|
||||
const label = I18n.t("discourse_post_event.event_ui.participants", {
|
||||
count: attrs.eventModel.stats.going
|
||||
count: attrs.eventModel.stats.going,
|
||||
});
|
||||
if (attrs.eventModel.stats.going > 0) {
|
||||
participants = this.attach("link", {
|
||||
action: "showAllParticipatingInvitees",
|
||||
actionParam: attrs.eventModel.id,
|
||||
contents: () => label
|
||||
contents: () => label,
|
||||
});
|
||||
} else {
|
||||
participants = label;
|
||||
|
@ -42,5 +43,5 @@ export default createWidget("discourse-post-event-dates", {
|
|||
}
|
||||
|
||||
return content;
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
|
@ -14,20 +14,20 @@ export default createWidget("discourse-post-event-creator", {
|
|||
{
|
||||
attributes: {
|
||||
class: "topic-invitee-avatar",
|
||||
"data-user-card": username
|
||||
}
|
||||
"data-user-card": username,
|
||||
},
|
||||
},
|
||||
[
|
||||
avatarImg("tiny", {
|
||||
template: avatar_template,
|
||||
username: name || formatUsername(username)
|
||||
username: name || formatUsername(username),
|
||||
}),
|
||||
h(
|
||||
"span",
|
||||
{ attributes: { class: "username" } },
|
||||
name || formatUsername(username)
|
||||
)
|
||||
),
|
||||
]
|
||||
);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import I18n from "I18n";
|
||||
import { isPresent } from "@ember/utils";
|
||||
import { h } from "virtual-dom";
|
||||
import { avatarImg } from "discourse/widgets/post";
|
||||
|
@ -43,8 +44,8 @@ export default createWidget("discourse-post-event-invitee", {
|
|||
const avatarContent = [
|
||||
avatarImg(this.site.mobileView ? "tiny" : "large", {
|
||||
template: avatar_template,
|
||||
username: name || formatUsername(username)
|
||||
})
|
||||
username: name || formatUsername(username),
|
||||
}),
|
||||
];
|
||||
|
||||
if (statusIcon) {
|
||||
|
@ -53,7 +54,7 @@ export default createWidget("discourse-post-event-invitee", {
|
|||
primary_group_name: I18n.t(
|
||||
`discourse_post_event.models.invitee.status.${attrs.invitee.status}`
|
||||
),
|
||||
primary_group_flair_url: statusIcon
|
||||
primary_group_flair_url: statusIcon,
|
||||
})
|
||||
);
|
||||
}
|
||||
|
@ -62,10 +63,10 @@ export default createWidget("discourse-post-event-invitee", {
|
|||
{
|
||||
attributes: {
|
||||
class: "topic-invitee-avatar",
|
||||
"data-user-card": username
|
||||
}
|
||||
"data-user-card": username,
|
||||
},
|
||||
},
|
||||
avatarContent
|
||||
);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
|
@ -6,7 +6,7 @@ export default createWidget("discourse-post-event-invitees", {
|
|||
|
||||
transform(attrs) {
|
||||
return {
|
||||
isPrivateEvent: attrs.eventModel.status === "private"
|
||||
isPrivateEvent: attrs.eventModel.status === "private",
|
||||
};
|
||||
},
|
||||
|
||||
|
@ -39,5 +39,5 @@ export default createWidget("discourse-post-event-invitees", {
|
|||
}}
|
||||
{{/each}}
|
||||
</ul>
|
||||
`
|
||||
`,
|
||||
});
|
||||
|
|
|
@ -4,7 +4,7 @@ import hbs from "discourse/widgets/hbs-compiler";
|
|||
export default createWidget("discourse-post-event-status", {
|
||||
tagName: "div.event-status",
|
||||
|
||||
buildKey: attrs => `discourse-post-event-status-${attrs.id}`,
|
||||
buildKey: (attrs) => `discourse-post-event-status-${attrs.id}`,
|
||||
|
||||
buildClasses(attrs) {
|
||||
if (attrs.watchingInvitee) {
|
||||
|
@ -16,7 +16,7 @@ export default createWidget("discourse-post-event-status", {
|
|||
const status = attrs.watchingInvitee ? attrs.watchingInvitee.status : null;
|
||||
|
||||
return {
|
||||
onChange: data => {
|
||||
onChange: (data) => {
|
||||
this.state.icon = null;
|
||||
this.state.label = data.label;
|
||||
this.state.options.headerClass = "disabled";
|
||||
|
@ -25,12 +25,12 @@ export default createWidget("discourse-post-event-status", {
|
|||
icon: this._headerIconForStatus(status),
|
||||
options: {
|
||||
caret: true,
|
||||
headerClass: ""
|
||||
headerClass: "",
|
||||
},
|
||||
label: status
|
||||
? `discourse_post_event.models.invitee.status.${status}`
|
||||
: "discourse_post_event.models.invitee.status.unknown",
|
||||
statuses: this._statusesForStatus(status)
|
||||
statuses: this._statusesForStatus(status),
|
||||
};
|
||||
},
|
||||
|
||||
|
@ -39,7 +39,7 @@ export default createWidget("discourse-post-event-status", {
|
|||
mightAttend:
|
||||
attrs.watchingInvitee &&
|
||||
(attrs.watchingInvitee.status === "going" ||
|
||||
attrs.watchingInvitee.status === "interested")
|
||||
attrs.watchingInvitee.status === "interested"),
|
||||
};
|
||||
},
|
||||
|
||||
|
@ -68,49 +68,49 @@ export default createWidget("discourse-post-event-status", {
|
|||
return [
|
||||
{
|
||||
id: "going",
|
||||
label: "discourse_post_event.models.invitee.status.going"
|
||||
label: "discourse_post_event.models.invitee.status.going",
|
||||
},
|
||||
{
|
||||
id: "interested",
|
||||
label: "discourse_post_event.models.invitee.status.interested"
|
||||
label: "discourse_post_event.models.invitee.status.interested",
|
||||
},
|
||||
"separator",
|
||||
{
|
||||
id: "not_going",
|
||||
label: "discourse_post_event.models.invitee.status.not_going"
|
||||
}
|
||||
label: "discourse_post_event.models.invitee.status.not_going",
|
||||
},
|
||||
];
|
||||
case "interested":
|
||||
return [
|
||||
{
|
||||
id: "going",
|
||||
label: "discourse_post_event.models.invitee.status.going"
|
||||
label: "discourse_post_event.models.invitee.status.going",
|
||||
},
|
||||
{
|
||||
id: "interested",
|
||||
label: "discourse_post_event.models.invitee.status.interested"
|
||||
label: "discourse_post_event.models.invitee.status.interested",
|
||||
},
|
||||
"separator",
|
||||
{
|
||||
id: "not_going",
|
||||
label: "discourse_post_event.models.invitee.status.not_going"
|
||||
}
|
||||
label: "discourse_post_event.models.invitee.status.not_going",
|
||||
},
|
||||
];
|
||||
case "not_going":
|
||||
return [
|
||||
{
|
||||
id: "going",
|
||||
label: "discourse_post_event.models.invitee.status.going"
|
||||
label: "discourse_post_event.models.invitee.status.going",
|
||||
},
|
||||
{
|
||||
id: "not_going",
|
||||
label: "discourse_post_event.models.invitee.status.not_going"
|
||||
label: "discourse_post_event.models.invitee.status.not_going",
|
||||
},
|
||||
"separator",
|
||||
{
|
||||
id: "interested",
|
||||
label: "discourse_post_event.models.invitee.status.interested"
|
||||
}
|
||||
label: "discourse_post_event.models.invitee.status.interested",
|
||||
},
|
||||
];
|
||||
}
|
||||
},
|
||||
|
@ -124,5 +124,5 @@ export default createWidget("discourse-post-event-status", {
|
|||
case "not_going":
|
||||
return "times";
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
|
@ -14,11 +14,11 @@ export default createWidget("discourse-post-event-url", {
|
|||
attributes: {
|
||||
href: attrs.url,
|
||||
target: "_blank",
|
||||
rel: "noopener noreferrer"
|
||||
}
|
||||
rel: "noopener noreferrer",
|
||||
},
|
||||
},
|
||||
attrs.url
|
||||
)
|
||||
),
|
||||
];
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import I18n from "I18n";
|
||||
import TextLib from "discourse/lib/text";
|
||||
import { exportEntity } from "discourse/lib/export-csv";
|
||||
import { emojiUnescape } from "discourse/lib/text";
|
||||
|
@ -14,7 +15,7 @@ import { buildParams, replaceRaw } from "../../lib/raw-event-helper";
|
|||
export default createWidget("discourse-post-event", {
|
||||
tagName: "div.discourse-post-event-widget",
|
||||
|
||||
buildKey: attrs => `discourse-post-event-${attrs.id}`,
|
||||
buildKey: (attrs) => `discourse-post-event-${attrs.id}`,
|
||||
|
||||
buildClasses() {
|
||||
if (this.state.event) {
|
||||
|
@ -23,9 +24,9 @@ export default createWidget("discourse-post-event", {
|
|||
},
|
||||
|
||||
inviteUserOrGroup(postId) {
|
||||
this.store.find("discourse-post-event-event", postId).then(eventModel => {
|
||||
this.store.find("discourse-post-event-event", postId).then((eventModel) => {
|
||||
showModal("discourse-post-event-invite-user-or-group", {
|
||||
model: eventModel
|
||||
model: eventModel,
|
||||
});
|
||||
});
|
||||
},
|
||||
|
@ -36,21 +37,21 @@ export default createWidget("discourse-post-event", {
|
|||
const extraClass = params.extraClass || "invited";
|
||||
const name = "discourse-post-event-invitees";
|
||||
|
||||
this.store.find("discourse-post-event-event", postId).then(eventModel => {
|
||||
this.store.find("discourse-post-event-event", postId).then((eventModel) => {
|
||||
showModal(name, {
|
||||
model: eventModel,
|
||||
title: `discourse_post_event.invitees_modal.${title}`,
|
||||
modalClass: [`${dasherize(name).toLowerCase()}-modal`, extraClass].join(
|
||||
" "
|
||||
)
|
||||
),
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
editPostEvent(postId) {
|
||||
this.store.find("discourse-post-event-event", postId).then(eventModel => {
|
||||
this.store.find("discourse-post-event-event", postId).then((eventModel) => {
|
||||
showModal("discourse-post-event-builder", {
|
||||
model: { eventModel, topicId: eventModel.post.topic.id }
|
||||
model: { eventModel, topicId: eventModel.post.topic.id },
|
||||
});
|
||||
});
|
||||
},
|
||||
|
@ -60,9 +61,9 @@ export default createWidget("discourse-post-event", {
|
|||
I18n.t("discourse_post_event.builder_modal.confirm_close"),
|
||||
I18n.t("no_value"),
|
||||
I18n.t("yes_value"),
|
||||
confirmed => {
|
||||
(confirmed) => {
|
||||
if (confirmed) {
|
||||
return this.store.find("post", eventModel.id).then(post => {
|
||||
return this.store.find("post", eventModel.id).then((post) => {
|
||||
const raw = post.raw;
|
||||
const startsAt = eventModel.starts_at
|
||||
? moment(eventModel.starts_at)
|
||||
|
@ -80,10 +81,10 @@ export default createWidget("discourse-post-event", {
|
|||
if (newRaw) {
|
||||
const props = {
|
||||
raw: newRaw,
|
||||
edit_reason: I18n.t("discourse_post_event.edit_reason")
|
||||
edit_reason: I18n.t("discourse_post_event.edit_reason"),
|
||||
};
|
||||
|
||||
return TextLib.cookAsync(newRaw).then(cooked => {
|
||||
return TextLib.cookAsync(newRaw).then((cooked) => {
|
||||
props.cooked = cooked.string;
|
||||
return post.save(props);
|
||||
});
|
||||
|
@ -110,20 +111,20 @@ export default createWidget("discourse-post-event", {
|
|||
|
||||
defaultState(attrs) {
|
||||
return {
|
||||
eventModel: attrs.eventModel
|
||||
eventModel: attrs.eventModel,
|
||||
};
|
||||
},
|
||||
|
||||
exportPostEvent(postId) {
|
||||
exportEntity("post_event", {
|
||||
name: "post_event",
|
||||
id: postId
|
||||
id: postId,
|
||||
});
|
||||
},
|
||||
|
||||
bulkInvite(eventModel) {
|
||||
showModal("discourse-post-event-bulk-invite", {
|
||||
model: { eventModel }
|
||||
model: { eventModel },
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -169,7 +170,7 @@ export default createWidget("discourse-post-event", {
|
|||
isStandaloneEvent: eventModel.status === "standalone",
|
||||
canActOnEvent:
|
||||
this.currentUser &&
|
||||
this.state.eventModel.can_act_on_discourse_post_event
|
||||
this.state.eventModel.can_act_on_discourse_post_event,
|
||||
};
|
||||
},
|
||||
|
||||
|
@ -261,5 +262,5 @@ export default createWidget("discourse-post-event", {
|
|||
}
|
||||
|
||||
return topicTitle;
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
|
@ -27,6 +27,6 @@ createWidgetFrom(
|
|||
|
||||
icon(notificationName, data) {
|
||||
return iconNode(`notification.${data.message}`);
|
||||
}
|
||||
},
|
||||
}
|
||||
);
|
||||
|
|
|
@ -24,5 +24,5 @@ createWidgetFrom(DefaultNotificationItem, "event-reminder-notification-item", {
|
|||
|
||||
icon(notificationName, data) {
|
||||
return iconNode(`notification.${data.message}`);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
|
@ -13,5 +13,5 @@ export default createWidget("going-button", {
|
|||
<span class="label">
|
||||
{{i18n "discourse_post_event.models.invitee.status.going"}}
|
||||
</span>
|
||||
`
|
||||
`,
|
||||
});
|
||||
|
|
|
@ -13,5 +13,5 @@ export default createWidget("interested-button", {
|
|||
<span class="label">
|
||||
{{i18n "discourse_post_event.models.invitee.status.interested"}}
|
||||
</span>
|
||||
`
|
||||
`,
|
||||
});
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import I18n from "I18n";
|
||||
import { createWidget } from "discourse/widgets/widget";
|
||||
import hbs from "discourse/widgets/hbs-compiler";
|
||||
|
||||
|
@ -9,8 +10,8 @@ export default createWidget("more-dropdown", {
|
|||
transform(attrs) {
|
||||
return {
|
||||
content: this._buildContent(attrs),
|
||||
onChange: item => this.sendWidgetAction(item.id, item.param),
|
||||
options: {}
|
||||
onChange: (item) => this.sendWidgetAction(item.id, item.param),
|
||||
options: {},
|
||||
};
|
||||
},
|
||||
|
||||
|
@ -42,7 +43,7 @@ export default createWidget("more-dropdown", {
|
|||
content.push({
|
||||
id: "addToCalendar",
|
||||
icon: "file",
|
||||
label: "discourse_post_event.event_ui.add_to_calendar"
|
||||
label: "discourse_post_event.event_ui.add_to_calendar",
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -53,7 +54,7 @@ export default createWidget("more-dropdown", {
|
|||
translatedLabel: I18n.t(
|
||||
"discourse_post_event.event_ui.send_pm_to_creator",
|
||||
{ username: attrs.eventModel.creator.username }
|
||||
)
|
||||
),
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -62,7 +63,7 @@ export default createWidget("more-dropdown", {
|
|||
id: "inviteUserOrGroup",
|
||||
icon: "user-plus",
|
||||
label: "discourse_post_event.event_ui.invite",
|
||||
param: attrs.eventModel.id
|
||||
param: attrs.eventModel.id,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -73,7 +74,7 @@ export default createWidget("more-dropdown", {
|
|||
icon: "file-csv",
|
||||
id: "exportPostEvent",
|
||||
label: "discourse_post_event.event_ui.export_event",
|
||||
param: attrs.eventModel.id
|
||||
param: attrs.eventModel.id,
|
||||
});
|
||||
|
||||
if (!attrs.eventModel.is_expired && !attrs.eventModel.is_standalone) {
|
||||
|
@ -81,7 +82,7 @@ export default createWidget("more-dropdown", {
|
|||
icon: "file-upload",
|
||||
id: "bulkInvite",
|
||||
label: "discourse_post_event.event_ui.bulk_invite",
|
||||
param: attrs.eventModel
|
||||
param: attrs.eventModel,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -89,7 +90,7 @@ export default createWidget("more-dropdown", {
|
|||
icon: "pencil-alt",
|
||||
id: "editPostEvent",
|
||||
label: "discourse_post_event.event_ui.edit_event",
|
||||
param: attrs.eventModel.id
|
||||
param: attrs.eventModel.id,
|
||||
});
|
||||
|
||||
if (!attrs.eventModel.is_expired) {
|
||||
|
@ -98,11 +99,11 @@ export default createWidget("more-dropdown", {
|
|||
id: "closeEvent",
|
||||
label: "discourse_post_event.event_ui.close_event",
|
||||
class: "danger",
|
||||
param: attrs.eventModel
|
||||
param: attrs.eventModel,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return content;
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
|
@ -4,4 +4,4 @@ export function formatEventName(event) {
|
|||
return event.name || event.post.topic.title;
|
||||
}
|
||||
|
||||
export default htmlHelper(event => formatEventName(event));
|
||||
export default htmlHelper((event) => formatEventName(event));
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import guessDateFormat from "discourse/plugins/discourse-calendar/lib/guess-best-date-format";
|
||||
import { htmlHelper } from "discourse-common/lib/helpers";
|
||||
|
||||
export default htmlHelper(date => {
|
||||
export default htmlHelper((date) => {
|
||||
date = moment.utc(date).tz(moment.tz.guess());
|
||||
const format = guessDateFormat(date);
|
||||
return date.format(format);
|
||||
|
|
|
@ -4,7 +4,7 @@ import { htmlHelper } from "discourse-common/lib/helpers";
|
|||
import { htmlSafe } from "@ember/template";
|
||||
import { formatUsername } from "discourse/lib/utilities";
|
||||
|
||||
export default htmlHelper(invitee => {
|
||||
export default htmlHelper((invitee) => {
|
||||
const path = userPath(invitee.user.username);
|
||||
const template = `
|
||||
<a href="${path}" data-user-card="${invitee.user.username}">
|
||||
|
|
|
@ -4,7 +4,7 @@ import showModal from "discourse/lib/show-modal";
|
|||
function initializeEventBuilder(api) {
|
||||
const currentUser = api.getCurrentUser();
|
||||
|
||||
api.addToolbarPopupMenuOptionsCallback(composerController => {
|
||||
api.addToolbarPopupMenuOptionsCallback((composerController) => {
|
||||
if (!currentUser || !currentUser.can_create_discourse_post_event) {
|
||||
return;
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ function initializeEventBuilder(api) {
|
|||
id: "insertEvent",
|
||||
group: "insertions",
|
||||
icon: "calendar-day",
|
||||
action: "insertEvent"
|
||||
action: "insertEvent",
|
||||
};
|
||||
}
|
||||
});
|
||||
|
@ -40,10 +40,10 @@ function initializeEventBuilder(api) {
|
|||
|
||||
showModal("discourse-post-event-builder").setProperties({
|
||||
toolbarEvent: this.toolbarEvent,
|
||||
model: { eventModel }
|
||||
model: { eventModel },
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -55,5 +55,5 @@ export default {
|
|||
if (siteSettings.discourse_post_event_enabled) {
|
||||
withPluginApi("0.8.7", initializeEventBuilder);
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
|
@ -5,7 +5,7 @@ function initializeHamburgerMenu(api) {
|
|||
return {
|
||||
icon: "calendar-day",
|
||||
route: "discourse-post-event-upcoming-events",
|
||||
label: "discourse_post_event.upcoming_events.title"
|
||||
label: "discourse_post_event.upcoming_events.title",
|
||||
};
|
||||
});
|
||||
}
|
||||
|
@ -18,5 +18,5 @@ export default {
|
|||
if (siteSettings.discourse_post_event_enabled) {
|
||||
withPluginApi("0.8.7", initializeHamburgerMenu);
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import I18n from "I18n";
|
||||
import { withPluginApi } from "discourse/lib/plugin-api";
|
||||
import { iconHTML } from "discourse-common/lib/icon-library";
|
||||
import { later, cancel } from "@ember/runloop";
|
||||
|
@ -9,7 +10,7 @@ function applyFlairOnMention(element, username) {
|
|||
const href = getURL(`/u/${username.toLowerCase()}`);
|
||||
const mentions = element.querySelectorAll(`a.mention[href="${href}"]`);
|
||||
|
||||
mentions.forEach(mention => {
|
||||
mentions.forEach((mention) => {
|
||||
if (!mention.querySelector(".d-icon-calendar-alt")) {
|
||||
mention.insertAdjacentHTML("beforeend", iconHTML("calendar-alt"));
|
||||
}
|
||||
|
@ -21,11 +22,11 @@ export default {
|
|||
name: "add-holiday-flair",
|
||||
|
||||
initialize() {
|
||||
withPluginApi("0.10.1", api => {
|
||||
withPluginApi("0.10.1", (api) => {
|
||||
const usernames = api.container.lookup("site:main").users_on_holiday;
|
||||
|
||||
if (usernames && usernames.length > 0) {
|
||||
api.addUsernameSelectorDecorator(username => {
|
||||
api.addUsernameSelectorDecorator((username) => {
|
||||
if (usernames.includes(username)) {
|
||||
return `<span class="on-holiday">${iconHTML(
|
||||
"calendar-alt"
|
||||
|
@ -35,7 +36,7 @@ export default {
|
|||
}
|
||||
});
|
||||
|
||||
withPluginApi("0.8", api => {
|
||||
withPluginApi("0.8", (api) => {
|
||||
const usernames = api.container.lookup("site:main").users_on_holiday;
|
||||
|
||||
if (usernames && usernames.length > 0) {
|
||||
|
@ -47,7 +48,7 @@ export default {
|
|||
($el, helper) => {
|
||||
if (helper) {
|
||||
// decorating a post
|
||||
usernames.forEach(username =>
|
||||
usernames.forEach((username) =>
|
||||
applyFlairOnMention($el[0], username)
|
||||
);
|
||||
} else {
|
||||
|
@ -55,7 +56,7 @@ export default {
|
|||
flairHandler && cancel(flairHandler);
|
||||
flairHandler = later(
|
||||
() =>
|
||||
usernames.forEach(username =>
|
||||
usernames.forEach((username) =>
|
||||
applyFlairOnMention($el[0], username)
|
||||
),
|
||||
1000
|
||||
|
@ -65,16 +66,16 @@ export default {
|
|||
{ id: "discourse-calendar-holiday-flair" }
|
||||
);
|
||||
|
||||
api.addPosterIcon(cfs => {
|
||||
api.addPosterIcon((cfs) => {
|
||||
if (cfs.on_holiday) {
|
||||
return {
|
||||
emoji: "desert_island",
|
||||
className: "holiday",
|
||||
title: I18n.t("discourse_calendar.on_holiday")
|
||||
title: I18n.t("discourse_calendar.on_holiday"),
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
|
@ -46,5 +46,5 @@ export default {
|
|||
if (siteSettings.discourse_post_event_enabled) {
|
||||
withPluginApi("0.8.40", initializeDecorateTopicTitle);
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
|
@ -53,12 +53,12 @@ function initializeDiscourseCalendar(api) {
|
|||
const settings = Discourse.SiteSettings.calendar_categories
|
||||
.split("|")
|
||||
.filter(Boolean)
|
||||
.map(stringSetting => {
|
||||
.map((stringSetting) => {
|
||||
const data = {};
|
||||
stringSetting
|
||||
.split(";")
|
||||
.filter(Boolean)
|
||||
.forEach(s => {
|
||||
.forEach((s) => {
|
||||
const parts = s.split("=");
|
||||
data[parts[0]] = parts[1];
|
||||
});
|
||||
|
@ -81,7 +81,7 @@ function initializeDiscourseCalendar(api) {
|
|||
const options = [`postId=${postId}`];
|
||||
|
||||
const optionals = ["weekends", "tzPicker", "defaultView"];
|
||||
optionals.forEach(optional => {
|
||||
optionals.forEach((optional) => {
|
||||
if (isPresent(categorySetting[optional])) {
|
||||
options.push(
|
||||
`${optional}=${escapeExpression(categorySetting[optional])}`
|
||||
|
@ -92,7 +92,7 @@ function initializeDiscourseCalendar(api) {
|
|||
const rawCalendar = `[calendar ${options.join(" ")}]\n[/calendar]`;
|
||||
const cookRaw = cookAsync(rawCalendar);
|
||||
const loadPost = ajax(`/posts/${postId}.json`);
|
||||
Promise.all([cookRaw, loadPost]).then(results => {
|
||||
Promise.all([cookRaw, loadPost]).then((results) => {
|
||||
const cooked = results[0];
|
||||
const post = results[1];
|
||||
const $cooked = $(cooked.string);
|
||||
|
@ -106,23 +106,26 @@ function initializeDiscourseCalendar(api) {
|
|||
|
||||
api.decorateCooked(attachCalendar, {
|
||||
onlyStream: true,
|
||||
id: "discourse-calendar"
|
||||
id: "discourse-calendar",
|
||||
});
|
||||
|
||||
api.cleanupStream(cleanUp);
|
||||
|
||||
api.registerCustomPostMessageCallback("calendar_change", topicController => {
|
||||
const stream = topicController.get("model.postStream");
|
||||
const post = stream.findLoadedPost(stream.get("firstPostId"));
|
||||
const $op = $(".topic-post article#post_1");
|
||||
const $calendar = $op.find(".calendar").first();
|
||||
api.registerCustomPostMessageCallback(
|
||||
"calendar_change",
|
||||
(topicController) => {
|
||||
const stream = topicController.get("model.postStream");
|
||||
const post = stream.findLoadedPost(stream.get("firstPostId"));
|
||||
const $op = $(".topic-post article#post_1");
|
||||
const $calendar = $op.find(".calendar").first();
|
||||
|
||||
if (post && $calendar.length > 0) {
|
||||
ajax(`/posts/${post.id}.json`).then(post =>
|
||||
loadFullCalendar().then(() => render($calendar, post))
|
||||
);
|
||||
if (post && $calendar.length > 0) {
|
||||
ajax(`/posts/${post.id}.json`).then((post) =>
|
||||
loadFullCalendar().then(() => render($calendar, post))
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
);
|
||||
|
||||
function render($calendar, post) {
|
||||
$calendar = $calendar.empty();
|
||||
|
@ -189,21 +192,21 @@ function initializeDiscourseCalendar(api) {
|
|||
month: "long",
|
||||
year: "numeric",
|
||||
day: "numeric",
|
||||
weekday: "long"
|
||||
}
|
||||
}
|
||||
weekday: "long",
|
||||
},
|
||||
},
|
||||
},
|
||||
header: {
|
||||
left: "prev,next today",
|
||||
center: "title",
|
||||
right: "month,basicWeek,listNextYear"
|
||||
right: "month,basicWeek,listNextYear",
|
||||
},
|
||||
datesRender: info => {
|
||||
datesRender: (info) => {
|
||||
if (showAddToCalendar) {
|
||||
_insertAddToCalendarLinks(info);
|
||||
$calendarTitle.innerText = info.view.title;
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -223,18 +226,18 @@ function initializeDiscourseCalendar(api) {
|
|||
|
||||
return {
|
||||
weeklyRecurring: html.attr("data-recurring") === "1.weeks",
|
||||
dateTime: moment.tz(dateTime, timezone || "Etc/UTC")
|
||||
dateTime: moment.tz(dateTime, timezone || "Etc/UTC"),
|
||||
};
|
||||
}
|
||||
|
||||
function _buildEventObject(from, to) {
|
||||
const hasTimeSpecified = d => {
|
||||
const hasTimeSpecified = (d) => {
|
||||
return d.hours() !== 0 || d.minutes() !== 0 || d.seconds() !== 0;
|
||||
};
|
||||
|
||||
let event = {
|
||||
start: from.dateTime.toDate(),
|
||||
allDay: false
|
||||
allDay: false,
|
||||
};
|
||||
|
||||
if (to) {
|
||||
|
@ -252,7 +255,7 @@ function initializeDiscourseCalendar(api) {
|
|||
event.startTime = {
|
||||
hours: from.dateTime.hours(),
|
||||
minutes: from.dateTime.minutes(),
|
||||
seconds: from.dateTime.seconds()
|
||||
seconds: from.dateTime.seconds(),
|
||||
};
|
||||
event.daysOfWeek = [from.dateTime.isoWeekday()];
|
||||
}
|
||||
|
@ -266,9 +269,9 @@ function initializeDiscourseCalendar(api) {
|
|||
.html()
|
||||
.trim()
|
||||
.split("<br>")
|
||||
.forEach(line => {
|
||||
.forEach((line) => {
|
||||
const html = $.parseHTML(line);
|
||||
const htmlDates = html.filter(h =>
|
||||
const htmlDates = html.filter((h) =>
|
||||
$(h).hasClass("discourse-local-date")
|
||||
);
|
||||
|
||||
|
@ -292,7 +295,7 @@ function initializeDiscourseCalendar(api) {
|
|||
if (hiddenDays) {
|
||||
calendar.setOption(
|
||||
"hiddenDays",
|
||||
hiddenDays.split(",").map(d => parseInt(d))
|
||||
hiddenDays.split(",").map((d) => parseInt(d))
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -327,13 +330,13 @@ function initializeDiscourseCalendar(api) {
|
|||
detail.from
|
||||
? {
|
||||
dateTime: moment(detail.from),
|
||||
weeklyRecurring: detail.recurring === "1.weeks"
|
||||
weeklyRecurring: detail.recurring === "1.weeks",
|
||||
}
|
||||
: null,
|
||||
detail.to
|
||||
? {
|
||||
dateTime: moment(detail.to),
|
||||
weeklyRecurring: detail.recurring === "1.weeks"
|
||||
weeklyRecurring: detail.recurring === "1.weeks",
|
||||
}
|
||||
: null
|
||||
);
|
||||
|
@ -358,7 +361,7 @@ function initializeDiscourseCalendar(api) {
|
|||
10
|
||||
);
|
||||
|
||||
const text = detail.message.split("\n").filter(e => e);
|
||||
const text = detail.message.split("\n").filter((e) => e);
|
||||
if (
|
||||
text.length &&
|
||||
post.topic_id &&
|
||||
|
@ -388,7 +391,7 @@ function initializeDiscourseCalendar(api) {
|
|||
|
||||
Object.keys(detail.localEvents)
|
||||
.sort()
|
||||
.forEach(key => {
|
||||
.forEach((key) => {
|
||||
const localEvent = detail.localEvents[key];
|
||||
htmlContent += `<b>${key}</b>: ${localEvent.usernames
|
||||
.sort()
|
||||
|
@ -428,7 +431,7 @@ function initializeDiscourseCalendar(api) {
|
|||
function _setDynamicCalendarEvents(calendar, post) {
|
||||
const groupedEvents = [];
|
||||
|
||||
(post.calendar_details || []).forEach(detail => {
|
||||
(post.calendar_details || []).forEach((detail) => {
|
||||
switch (detail.type) {
|
||||
case "grouped":
|
||||
groupedEvents.push(detail);
|
||||
|
@ -440,7 +443,7 @@ function initializeDiscourseCalendar(api) {
|
|||
});
|
||||
|
||||
const formatedGroupedEvents = {};
|
||||
groupedEvents.forEach(groupedEvent => {
|
||||
groupedEvents.forEach((groupedEvent) => {
|
||||
const minDate = moment(groupedEvent.from)
|
||||
.utc()
|
||||
.startOf("day")
|
||||
|
@ -454,13 +457,13 @@ function initializeDiscourseCalendar(api) {
|
|||
formatedGroupedEvents[identifier] = formatedGroupedEvents[identifier] || {
|
||||
from: minDate,
|
||||
to: maxDate || minDate,
|
||||
localEvents: {}
|
||||
localEvents: {},
|
||||
};
|
||||
|
||||
formatedGroupedEvents[identifier].localEvents[
|
||||
groupedEvent.name
|
||||
] = formatedGroupedEvents[identifier].localEvents[groupedEvent.name] || {
|
||||
usernames: []
|
||||
usernames: [],
|
||||
};
|
||||
|
||||
formatedGroupedEvents[identifier].localEvents[
|
||||
|
@ -472,7 +475,7 @@ function initializeDiscourseCalendar(api) {
|
|||
);
|
||||
});
|
||||
|
||||
Object.keys(formatedGroupedEvents).forEach(key => {
|
||||
Object.keys(formatedGroupedEvents).forEach((key) => {
|
||||
const formatedGroupedEvent = formatedGroupedEvents[key];
|
||||
_addGroupedEvent(calendar, post, formatedGroupedEvent);
|
||||
});
|
||||
|
@ -496,12 +499,12 @@ function initializeDiscourseCalendar(api) {
|
|||
let $timezonePicker = $(".discourse-calendar-timezone-picker");
|
||||
|
||||
if ($timezonePicker.length) {
|
||||
$timezonePicker.on("change", function(event) {
|
||||
$timezonePicker.on("change", function (event) {
|
||||
calendar.setOption("timeZone", event.target.value);
|
||||
_insertAddToCalendarLinks(calendar);
|
||||
});
|
||||
|
||||
moment.tz.names().forEach(timezone => {
|
||||
moment.tz.names().forEach((timezone) => {
|
||||
$timezonePicker.append(new Option(timezone, timezone));
|
||||
});
|
||||
|
||||
|
@ -551,17 +554,13 @@ function initializeDiscourseCalendar(api) {
|
|||
function _formatDateForGoogleApi(date, allDay = false) {
|
||||
if (!allDay) return date.toISOString().replace(/-|:|\.\d\d\d/g, "");
|
||||
|
||||
return moment(date)
|
||||
.utc()
|
||||
.format("YYYYMMDD");
|
||||
return moment(date).utc().format("YYYYMMDD");
|
||||
}
|
||||
|
||||
function _endDateForAllDayEvent(startDate, allDay) {
|
||||
const unit = allDay ? "days" : "hours";
|
||||
return _formatDateForGoogleApi(
|
||||
moment(startDate)
|
||||
.add(1, unit)
|
||||
.toDate(),
|
||||
moment(startDate).add(1, unit).toDate(),
|
||||
allDay
|
||||
);
|
||||
}
|
||||
|
@ -584,5 +583,5 @@ export default {
|
|||
if (siteSettings.calendar_enabled) {
|
||||
withPluginApi("0.8.22", initializeDiscourseCalendar);
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
|
@ -6,11 +6,11 @@ export default {
|
|||
name: "discourse-group-timezones",
|
||||
|
||||
initialize() {
|
||||
withPluginApi("0.8.7", api => {
|
||||
withPluginApi("0.8.7", (api) => {
|
||||
let _glued = [];
|
||||
|
||||
function cleanUp() {
|
||||
_glued.forEach(g => g.cleanUp());
|
||||
_glued.forEach((g) => g.cleanUp());
|
||||
_glued = [];
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ export default {
|
|||
group,
|
||||
usersOnHoliday:
|
||||
api.container.lookup("site:main").users_on_holiday || [],
|
||||
size: groupTimezone.getAttribute("data-size") || "medium"
|
||||
size: groupTimezone.getAttribute("data-size") || "medium",
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -59,10 +59,10 @@ export default {
|
|||
}
|
||||
|
||||
api.decorateCooked(_attachPostWithGroupTimezones, {
|
||||
id: "discourse-group-timezones"
|
||||
id: "discourse-group-timezones",
|
||||
});
|
||||
|
||||
api.cleanupStream(cleanUp);
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import I18n from "I18n";
|
||||
import guessDateFormat from "discourse/plugins/discourse-calendar/lib/guess-best-date-format";
|
||||
import { cookAsync } from "discourse/lib/text";
|
||||
import WidgetGlue from "discourse/widgets/glue";
|
||||
|
@ -13,8 +14,9 @@ function _validEventPreview(eventContainer) {
|
|||
eventContainer.innerHTML = "";
|
||||
eventContainer.classList.add("discourse-post-event-preview");
|
||||
|
||||
const statusLocaleKey = `discourse_post_event.models.event.status.${eventContainer
|
||||
.dataset.status || "public"}.title`;
|
||||
const statusLocaleKey = `discourse_post_event.models.event.status.${
|
||||
eventContainer.dataset.status || "public"
|
||||
}.title`;
|
||||
if (I18n.lookup(statusLocaleKey, { locale: "en" })) {
|
||||
const statusContainer = document.createElement("div");
|
||||
statusContainer.classList.add("event-preview-status");
|
||||
|
@ -74,7 +76,7 @@ function _decorateEventPreview(api, cooked) {
|
|||
let _glued = [];
|
||||
|
||||
function cleanUp() {
|
||||
_glued.forEach(g => g.cleanUp());
|
||||
_glued.forEach((g) => g.cleanUp());
|
||||
_glued = [];
|
||||
}
|
||||
|
||||
|
@ -139,14 +141,14 @@ function _attachWidget(api, cooked, eventModel) {
|
|||
);
|
||||
}
|
||||
|
||||
cookAsync(dates.join("<span> → </span>")).then(result => {
|
||||
cookAsync(dates.join("<span> → </span>")).then((result) => {
|
||||
eventContainer.classList.remove("is-loading");
|
||||
eventContainer.classList.add("is-loaded");
|
||||
|
||||
const glue = new WidgetGlue("discourse-post-event", getRegister(api), {
|
||||
eventModel,
|
||||
widgetHeight,
|
||||
localDates: $(result.string).html()
|
||||
localDates: $(result.string).html(),
|
||||
});
|
||||
|
||||
glue.appendTo(glueContainer);
|
||||
|
@ -168,7 +170,7 @@ function _attachWidget(api, cooked, eventModel) {
|
|||
const glue = new WidgetGlue("discourse-post-event", getRegister(api), {
|
||||
eventModel,
|
||||
widgetHeight,
|
||||
localDates
|
||||
localDates,
|
||||
});
|
||||
|
||||
glue.appendTo(glueContainer);
|
||||
|
@ -199,7 +201,7 @@ function initializeDiscoursePostEventDecorator(api) {
|
|||
}
|
||||
},
|
||||
{
|
||||
id: "discourse-post-event-decorator"
|
||||
id: "discourse-post-event-decorator",
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -244,7 +246,7 @@ function initializeDiscoursePostEventDecorator(api) {
|
|||
|
||||
this.messageBus.subscribe(
|
||||
"/discourse-post-event/" + this.get("model.id"),
|
||||
msg => {
|
||||
(msg) => {
|
||||
const postNode = document.querySelector(
|
||||
`.onscreen-post[data-post-id="${msg.id}"] .cooked`
|
||||
);
|
||||
|
@ -252,7 +254,7 @@ function initializeDiscoursePostEventDecorator(api) {
|
|||
if (postNode) {
|
||||
this.store
|
||||
.find("discourse-post-event-event", msg.id)
|
||||
.then(eventModel => _decorateEvent(api, postNode, eventModel))
|
||||
.then((eventModel) => _decorateEvent(api, postNode, eventModel))
|
||||
.catch(() => _decorateEvent(api, postNode));
|
||||
}
|
||||
}
|
||||
|
@ -261,7 +263,7 @@ function initializeDiscoursePostEventDecorator(api) {
|
|||
unsubscribe() {
|
||||
this.messageBus.unsubscribe("/discourse-post-event/*");
|
||||
this._super(...arguments);
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -273,5 +275,5 @@ export default {
|
|||
if (siteSettings.discourse_post_event_enabled) {
|
||||
withPluginApi("0.8.7", initializeDiscoursePostEventDecorator);
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const calendarRule = {
|
||||
tag: "calendar",
|
||||
|
||||
before: function(state, info) {
|
||||
before: function (state, info) {
|
||||
let wrapperDivToken = state.push("div_calendar_wrap", "div", 1);
|
||||
wrapperDivToken.attrs = [["class", "discourse-calendar-wrap"]];
|
||||
|
||||
|
@ -25,13 +25,13 @@ const calendarRule = {
|
|||
mainCalendarDivToken.attrs = [
|
||||
["class", "calendar"],
|
||||
["data-calendar-type", info.attrs.type || "dynamic"],
|
||||
["data-calendar-default-timezone", info.attrs.defaultTimezone]
|
||||
["data-calendar-default-timezone", info.attrs.defaultTimezone],
|
||||
];
|
||||
|
||||
if (info.attrs.defaultView) {
|
||||
mainCalendarDivToken.attrs.push([
|
||||
"data-calendar-default-view",
|
||||
info.attrs.defaultView
|
||||
info.attrs.defaultView,
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -42,39 +42,39 @@ const calendarRule = {
|
|||
if (info.attrs.showAddToCalendar) {
|
||||
mainCalendarDivToken.attrs.push([
|
||||
"data-calendar-show-add-to-calendar",
|
||||
info.attrs.showAddToCalendar === "true"
|
||||
info.attrs.showAddToCalendar === "true",
|
||||
]);
|
||||
}
|
||||
|
||||
if (info.attrs.hiddenDays) {
|
||||
mainCalendarDivToken.attrs.push([
|
||||
"data-hidden-days",
|
||||
info.attrs.hiddenDays
|
||||
info.attrs.hiddenDays,
|
||||
]);
|
||||
}
|
||||
},
|
||||
|
||||
after: function(state) {
|
||||
after: function (state) {
|
||||
state.push("div_calendar", "div", -1);
|
||||
state.push("div_calendar_wrap", "div", -1);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
const groupTimezoneRule = {
|
||||
tag: "timezones",
|
||||
|
||||
before: function(state, info) {
|
||||
before: function (state, info) {
|
||||
const wrapperDivToken = state.push("div_group_timezones", "div", 1);
|
||||
wrapperDivToken.attrs = [
|
||||
["class", "group-timezones"],
|
||||
["data-group", info.attrs.group],
|
||||
["data-size", info.attrs.size || "medium"]
|
||||
["data-size", info.attrs.size || "medium"],
|
||||
];
|
||||
},
|
||||
|
||||
after: function(state) {
|
||||
after: function (state) {
|
||||
state.push("div_group_timezones", "div", -1);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
function _renderTimezonePicker(state) {
|
||||
|
@ -99,7 +99,7 @@ export function setup(helper) {
|
|||
"div[data-hidden-days]",
|
||||
"div.group-timezones",
|
||||
"div[data-group]",
|
||||
"div[data-size]"
|
||||
"div[data-size]",
|
||||
]);
|
||||
|
||||
helper.registerOptions((opts, siteSettings) => {
|
||||
|
@ -108,7 +108,7 @@ export function setup(helper) {
|
|||
] = !!siteSettings.calendar_enabled;
|
||||
});
|
||||
|
||||
helper.registerPlugin(md => {
|
||||
helper.registerPlugin((md) => {
|
||||
const features = md.options.discourse.features;
|
||||
if (features["discourse-calendar-enabled"]) {
|
||||
md.block.bbcode.ruler.push("discourse-calendar", calendarRule);
|
||||
|
|
|
@ -8,7 +8,7 @@ const rule = {
|
|||
|
||||
token.attrs = [["class", "discourse-post-event"]];
|
||||
|
||||
Object.keys(info.attrs).forEach(key => {
|
||||
Object.keys(info.attrs).forEach((key) => {
|
||||
const value = info.attrs[key];
|
||||
|
||||
if (typeof value !== undefined) {
|
||||
|
@ -17,11 +17,11 @@ const rule = {
|
|||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
function dasherize(input) {
|
||||
return input.replace(/[A-Z]/g, function(char, index) {
|
||||
return input.replace(/[A-Z]/g, function (char, index) {
|
||||
return (index !== 0 ? "-" : "") + char.toLowerCase();
|
||||
});
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ export function setup(helper) {
|
|||
siteSettings.discourse_post_event_enabled;
|
||||
});
|
||||
|
||||
helper.registerPlugin(md =>
|
||||
helper.registerPlugin((md) =>
|
||||
md.block.bbcode.ruler.push("discourse-post-event", rule)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -2,13 +2,9 @@ export function buildParams(startsAt, endsAt, eventModel, siteSettings) {
|
|||
const params = {};
|
||||
|
||||
if (startsAt) {
|
||||
params.start = moment(startsAt)
|
||||
.utc()
|
||||
.format("YYYY-MM-DD HH:mm");
|
||||
params.start = moment(startsAt).utc().format("YYYY-MM-DD HH:mm");
|
||||
} else {
|
||||
params.start = moment()
|
||||
.utc()
|
||||
.format("YYYY-MM-DD HH:mm");
|
||||
params.start = moment().utc().format("YYYY-MM-DD HH:mm");
|
||||
}
|
||||
|
||||
if (eventModel.status) {
|
||||
|
@ -28,9 +24,7 @@ export function buildParams(startsAt, endsAt, eventModel, siteSettings) {
|
|||
}
|
||||
|
||||
if (endsAt) {
|
||||
params.end = moment(endsAt)
|
||||
.utc()
|
||||
.format("YYYY-MM-DD HH:mm");
|
||||
params.end = moment(endsAt).utc().format("YYYY-MM-DD HH:mm");
|
||||
}
|
||||
|
||||
if (eventModel.status === "private") {
|
||||
|
@ -43,7 +37,7 @@ export function buildParams(startsAt, endsAt, eventModel, siteSettings) {
|
|||
|
||||
if (eventModel.reminders && eventModel.reminders.length) {
|
||||
params.reminders = eventModel.reminders
|
||||
.map(r => {
|
||||
.map((r) => {
|
||||
// we create a new intermediate object to avoid changes in the UI while
|
||||
// we prepare the values for request
|
||||
const reminder = Object.assign({}, r);
|
||||
|
@ -63,7 +57,7 @@ export function buildParams(startsAt, endsAt, eventModel, siteSettings) {
|
|||
siteSettings.discourse_post_event_allowed_custom_fields
|
||||
.split("|")
|
||||
.filter(Boolean)
|
||||
.forEach(setting => {
|
||||
.forEach((setting) => {
|
||||
const param = camelCase(setting);
|
||||
if (typeof eventModel.custom_fields[setting] !== undefined) {
|
||||
params[param] = eventModel.custom_fields[setting];
|
||||
|
@ -79,7 +73,7 @@ export function replaceRaw(params, raw) {
|
|||
|
||||
if (eventMatches && eventMatches[1]) {
|
||||
const markdownParams = [];
|
||||
Object.keys(params).forEach(param => {
|
||||
Object.keys(params).forEach((param) => {
|
||||
const value = params[param];
|
||||
if (value && value.length) {
|
||||
markdownParams.push(`${param}="${params[param]}"`);
|
||||
|
@ -93,7 +87,7 @@ export function replaceRaw(params, raw) {
|
|||
}
|
||||
|
||||
function camelCase(input) {
|
||||
return input.toLowerCase().replace(/-(.)/g, function(match, group1) {
|
||||
return input.toLowerCase().replace(/-(.)/g, function (match, group1) {
|
||||
return group1.toUpperCase();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -251,7 +251,7 @@ export const HOLIDAY_REGIONS = [
|
|||
"sg",
|
||||
"my",
|
||||
"th",
|
||||
"ng"
|
||||
"ng",
|
||||
];
|
||||
|
||||
export const TIME_ZONE_TO_REGION = {
|
||||
|
@ -453,5 +453,5 @@ export const TIME_ZONE_TO_REGION = {
|
|||
"Europe/Vaduz": "li",
|
||||
"Europe/Ljubljana": "si",
|
||||
"Europe/Bratislava": "sk",
|
||||
"America/St_Thomas": "vi"
|
||||
"America/St_Thomas": "vi",
|
||||
};
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
// https://github.com/WebDevTmas/moment-round
|
||||
if (typeof moment.fn.round !== "function") {
|
||||
moment.fn.round = function(precision, key, direction) {
|
||||
moment.fn.round = function (precision, key, direction) {
|
||||
direction = direction || "round";
|
||||
var _this = this; //cache of this
|
||||
var methods = {
|
||||
hours: { name: "Hours", maxValue: 24 },
|
||||
minutes: { name: "Minutes", maxValue: 60 },
|
||||
seconds: { name: "Seconds", maxValue: 60 },
|
||||
milliseconds: { name: "Milliseconds", maxValue: 1000 }
|
||||
milliseconds: { name: "Milliseconds", maxValue: 1000 },
|
||||
};
|
||||
var keys = {
|
||||
mm: methods.milliseconds.name,
|
||||
|
@ -22,7 +22,7 @@ if (typeof moment.fn.round !== "function") {
|
|||
H: methods.hours.name,
|
||||
h: methods.hours.name,
|
||||
hours: methods.hours.name,
|
||||
Hours: methods.hours.name
|
||||
Hours: methods.hours.name,
|
||||
};
|
||||
var value = 0;
|
||||
var rounded = false;
|
||||
|
@ -66,13 +66,13 @@ if (typeof moment.fn.round !== "function") {
|
|||
}
|
||||
|
||||
if (typeof moment.fn.ceil !== "function") {
|
||||
moment.fn.ceil = function(precision, key) {
|
||||
moment.fn.ceil = function (precision, key) {
|
||||
return this.round(precision, key, "ceil");
|
||||
};
|
||||
}
|
||||
|
||||
if (typeof moment.fn.floor !== "function") {
|
||||
moment.fn.floor = function(precision, key) {
|
||||
moment.fn.floor = function (precision, key) {
|
||||
return this.round(precision, key, "floor");
|
||||
};
|
||||
}
|
||||
|
|
|
@ -5,6 +5,6 @@
|
|||
"author": "Discourse",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"eslint-config-discourse": "latest"
|
||||
"eslint-config-discourse": "^1.1.3"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ acceptance("Discourse Calendar - Holiday Flair", {
|
|||
loggedIn: true,
|
||||
settings: { calendar_enabled: true },
|
||||
site: {
|
||||
users_on_holiday: ["foo"]
|
||||
users_on_holiday: ["foo"],
|
||||
},
|
||||
|
||||
pretend(server, helper) {
|
||||
|
@ -25,8 +25,8 @@ acceptance("Discourse Calendar - Holiday Flair", {
|
|||
username: "foo",
|
||||
name: "Foo",
|
||||
avatar_template:
|
||||
"/letter_avatar_proxy/v4/letter/f/3be4f8/{size}.png"
|
||||
}
|
||||
"/letter_avatar_proxy/v4/letter/f/3be4f8/{size}.png",
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
|
@ -42,22 +42,22 @@ acceptance("Discourse Calendar - Holiday Flair", {
|
|||
username: "bar",
|
||||
name: "Bar",
|
||||
avatar_template:
|
||||
"/letter_avatar_proxy/v4/letter/b/3be4f8/{size}.png"
|
||||
}
|
||||
}
|
||||
"/letter_avatar_proxy/v4/letter/b/3be4f8/{size}.png",
|
||||
},
|
||||
},
|
||||
],
|
||||
meta: {
|
||||
last_updated_at: "2020-01-01T12:00:00.000Z",
|
||||
total_rows_directory_items: 2,
|
||||
load_more_directory_items:
|
||||
"/directory_items?order=likes_received&page=1&period=weekly"
|
||||
}
|
||||
"/directory_items?order=likes_received&page=1&period=weekly",
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
QUnit.test("shows holiday emoji in directory", async assert => {
|
||||
QUnit.test("shows holiday emoji in directory", async (assert) => {
|
||||
await visit("/u");
|
||||
assert.equal(find(".holiday-flair").length, 1);
|
||||
assert.equal(find("div[data-username='foo'] .holiday-flair").length, 1);
|
||||
|
|
Loading…
Reference in New Issue