mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 03:40:00 +08:00
apply prettier on gigantic find and replace (#7604)
This commit is contained in:
parent
373b8a2139
commit
d93f753b17
|
@ -15,9 +15,7 @@ export default Ember.Component.extend({
|
|||
{
|
||||
data: rawData.map(r => r.y),
|
||||
label: model.get("title"),
|
||||
backgroundColor: `rgba(200,220,240,${
|
||||
this.type === "bar" ? 1 : 0.3
|
||||
})`,
|
||||
backgroundColor: `rgba(200,220,240,${this.type === "bar" ? 1 : 0.3})`,
|
||||
borderColor: "#08C"
|
||||
}
|
||||
]
|
||||
|
|
|
@ -75,11 +75,7 @@ export default Ember.Component.extend({
|
|||
this._super(...arguments);
|
||||
|
||||
if (this.report) {
|
||||
this._renderReport(
|
||||
this.report,
|
||||
this.forcedModes,
|
||||
this.currentMode
|
||||
);
|
||||
this._renderReport(this.report, this.forcedModes, this.currentMode);
|
||||
} else if (this.dataSourceName) {
|
||||
this._fetchReport();
|
||||
}
|
||||
|
@ -271,11 +267,7 @@ export default Ember.Component.extend({
|
|||
this.set("showFilteringUI", false);
|
||||
}
|
||||
|
||||
this._renderReport(
|
||||
report,
|
||||
this.forcedModes,
|
||||
this.currentMode
|
||||
);
|
||||
this._renderReport(report, this.forcedModes, this.currentMode);
|
||||
},
|
||||
|
||||
_renderReport(report, forcedModes, currentMode) {
|
||||
|
|
|
@ -46,10 +46,7 @@ export default Ember.Component.extend(bufferedProperty("host"), {
|
|||
host
|
||||
.save(props)
|
||||
.then(() => {
|
||||
host.set(
|
||||
"category",
|
||||
Discourse.Category.findById(this.categoryId)
|
||||
);
|
||||
host.set("category", Discourse.Category.findById(this.categoryId));
|
||||
this.set("editToggled", false);
|
||||
})
|
||||
.catch(popupAjaxError);
|
||||
|
@ -58,11 +55,9 @@ export default Ember.Component.extend(bufferedProperty("host"), {
|
|||
delete() {
|
||||
bootbox.confirm(I18n.t("admin.embedding.confirm_delete"), result => {
|
||||
if (result) {
|
||||
this.host
|
||||
.destroyRecord()
|
||||
.then(() => {
|
||||
this.deleteHost(this.host);
|
||||
});
|
||||
this.host.destroyRecord().then(() => {
|
||||
this.deleteHost(this.host);
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
|
|
|
@ -19,8 +19,8 @@ export default Ember.Component.extend({
|
|||
this.set("show", true);
|
||||
|
||||
if (!this.location) {
|
||||
ajax("/admin/users/ip-info", { data: { ip: this.ip } }).then(
|
||||
location => this.set("location", Ember.Object.create(location))
|
||||
ajax("/admin/users/ip-info", { data: { ip: this.ip } }).then(location =>
|
||||
this.set("location", Ember.Object.create(location))
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -109,9 +109,7 @@ export default Ember.Component.extend(
|
|||
buffer.push(iconHTML(icon));
|
||||
buffer.push("<span class='ru-label'>" + this.text + "</span>");
|
||||
buffer.push(
|
||||
"<span class='ru-progress' style='width:" +
|
||||
this.progress +
|
||||
"%'></span>"
|
||||
"<span class='ru-progress' style='width:" + this.progress + "%'></span>"
|
||||
);
|
||||
},
|
||||
|
||||
|
|
|
@ -29,8 +29,7 @@ export default Ember.Component.extend({
|
|||
},
|
||||
|
||||
addValue() {
|
||||
if (this._checkInvalidInput([this.newKey, this.newSecret]))
|
||||
return;
|
||||
if (this._checkInvalidInput([this.newKey, this.newSecret])) return;
|
||||
this._addValue(this.newKey, this.newSecret);
|
||||
this.setProperties({ newKey: "", newSecret: "" });
|
||||
},
|
||||
|
|
|
@ -79,10 +79,7 @@ export default Ember.Component.extend({
|
|||
return;
|
||||
}
|
||||
|
||||
this.set(
|
||||
"values",
|
||||
this.collection.join(this.inputDelimiter || "\n")
|
||||
);
|
||||
this.set("values", this.collection.join(this.inputDelimiter || "\n"));
|
||||
},
|
||||
|
||||
_splitValues(values, delimiter) {
|
||||
|
|
|
@ -29,9 +29,7 @@ export default Ember.Component.extend({
|
|||
@computed("word")
|
||||
isUniqueWord(word) {
|
||||
const words = this.filteredContent || [];
|
||||
const filtered = words.filter(
|
||||
content => content.action === this.actionKey
|
||||
);
|
||||
const filtered = words.filter(content => content.action === this.actionKey);
|
||||
return filtered.every(
|
||||
content => content.word.toLowerCase() !== word.toLowerCase()
|
||||
);
|
||||
|
|
|
@ -23,10 +23,7 @@ export default Ember.Controller.extend({
|
|||
|
||||
actions: {
|
||||
newColorSchemeWithBase(baseKey) {
|
||||
const base = this.baseColorSchemes.findBy(
|
||||
"base_scheme_id",
|
||||
baseKey
|
||||
);
|
||||
const base = this.baseColorSchemes.findBy("base_scheme_id", baseKey);
|
||||
const newColorScheme = Ember.copy(base, true);
|
||||
newColorScheme.setProperties({
|
||||
name: I18n.t("admin.customize.colors.new_name"),
|
||||
|
|
|
@ -36,30 +36,18 @@ export default Ember.Controller.extend({
|
|||
actions: {
|
||||
save() {
|
||||
this.set("saving", true);
|
||||
this.model
|
||||
.saveChanges("theme_fields")
|
||||
.finally(() => {
|
||||
this.set("saving", false);
|
||||
});
|
||||
this.model.saveChanges("theme_fields").finally(() => {
|
||||
this.set("saving", false);
|
||||
});
|
||||
},
|
||||
|
||||
fieldAdded(target, name) {
|
||||
this.replaceRoute(
|
||||
this.editRouteName,
|
||||
this.get("model.id"),
|
||||
target,
|
||||
name
|
||||
);
|
||||
this.replaceRoute(this.editRouteName, this.get("model.id"), target, name);
|
||||
},
|
||||
|
||||
onlyOverriddenChanged(onlyShowOverridden) {
|
||||
if (onlyShowOverridden) {
|
||||
if (
|
||||
!this.model.hasEdited(
|
||||
this.currentTargetName,
|
||||
this.fieldName
|
||||
)
|
||||
) {
|
||||
if (!this.model.hasEdited(this.currentTargetName, this.fieldName)) {
|
||||
let firstTarget = this.get("model.targets").find(t => t.edited);
|
||||
let firstField = this.get(`model.fields.${firstTarget.name}`).find(
|
||||
f => f.edited
|
||||
|
|
|
@ -39,11 +39,7 @@ export default Ember.Controller.extend({
|
|||
this.set("sendingEmail", true);
|
||||
this.set("sentEmail", false);
|
||||
|
||||
EmailPreview.sendDigest(
|
||||
this.username,
|
||||
this.lastSeen,
|
||||
this.email
|
||||
)
|
||||
EmailPreview.sendDigest(this.username, this.lastSeen, this.email)
|
||||
.then(result => {
|
||||
if (result.errors) {
|
||||
bootbox.alert(result.errors);
|
||||
|
|
|
@ -12,9 +12,7 @@ export default Ember.Controller.extend({
|
|||
|
||||
let filter;
|
||||
if (this.filter) {
|
||||
filter = this.filter
|
||||
.toLowerCase()
|
||||
.trim();
|
||||
filter = this.filter.toLowerCase().trim();
|
||||
}
|
||||
|
||||
if ((!filter || 0 === filter.length) && !this.onlyOverridden) {
|
||||
|
|
|
@ -209,9 +209,7 @@ export default Ember.Controller.extend(CanCheckEmails, {
|
|||
this.adminTools.showSuspendModal(this.model);
|
||||
},
|
||||
unsuspend() {
|
||||
this.model
|
||||
.unsuspend()
|
||||
.catch(popupAjaxError);
|
||||
this.model.unsuspend().catch(popupAjaxError);
|
||||
},
|
||||
showSilenceModal() {
|
||||
this.adminTools.showSilenceModal(this.model);
|
||||
|
|
|
@ -92,9 +92,7 @@ export default Ember.Controller.extend({
|
|||
.save()
|
||||
.then(() => {
|
||||
this.set("saved", true);
|
||||
this.adminWebHooks
|
||||
.get("model")
|
||||
.addObject(model);
|
||||
this.adminWebHooks.get("model").addObject(model);
|
||||
|
||||
if (isNew) {
|
||||
this.transitionToRoute("adminWebHooks.show", model.get("id"));
|
||||
|
@ -135,9 +133,7 @@ export default Ember.Controller.extend({
|
|||
model
|
||||
.destroyRecord()
|
||||
.then(() => {
|
||||
this.adminWebHooks
|
||||
.get("model")
|
||||
.removeObject(model);
|
||||
this.adminWebHooks.get("model").removeObject(model);
|
||||
this.transitionToRoute("adminWebHooks");
|
||||
})
|
||||
.catch(popupAjaxError);
|
||||
|
|
|
@ -273,10 +273,7 @@ export default Ember.Controller.extend(ModalFunctionality, {
|
|||
this.set("loading", true);
|
||||
ajax(this.importUrl, options)
|
||||
.then(result => {
|
||||
const theme = this.store.createRecord(
|
||||
this.recordType,
|
||||
result.theme
|
||||
);
|
||||
const theme = this.store.createRecord(this.recordType, result.theme);
|
||||
this.adminCustomizeThemes.send("addTheme", theme);
|
||||
this.send("closeModal");
|
||||
})
|
||||
|
|
|
@ -76,12 +76,7 @@ const ColorSchemeColor = Discourse.Model.extend({
|
|||
@observes("hex")
|
||||
hexValueChanged() {
|
||||
if (this.hex) {
|
||||
this.set(
|
||||
"hex",
|
||||
this.hex
|
||||
.toString()
|
||||
.replace(/[^0-9a-fA-F]/g, "")
|
||||
);
|
||||
this.set("hex", this.hex.toString().replace(/[^0-9a-fA-F]/g, ""));
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -30,10 +30,9 @@ const ScreenedIpAddress = Discourse.Model.extend({
|
|||
},
|
||||
|
||||
destroy() {
|
||||
return ajax(
|
||||
"/admin/logs/screened_ip_addresses/" + this.id + ".json",
|
||||
{ type: "DELETE" }
|
||||
);
|
||||
return ajax("/admin/logs/screened_ip_addresses/" + this.id + ".json", {
|
||||
type: "DELETE"
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -50,23 +50,17 @@ export default Discourse.Model.extend({
|
|||
topics_viewed: this.topics_viewed >= this.min_topics_viewed,
|
||||
posts_read: this.posts_read >= this.min_posts_read,
|
||||
topics_viewed_all_time:
|
||||
this.topics_viewed_all_time >=
|
||||
this.min_topics_viewed_all_time,
|
||||
this.topics_viewed_all_time >= this.min_topics_viewed_all_time,
|
||||
posts_read_all_time:
|
||||
this.posts_read_all_time >= this.min_posts_read_all_time,
|
||||
flagged_posts:
|
||||
this.num_flagged_posts <= this.max_flagged_posts,
|
||||
flagged_by_users:
|
||||
this.num_flagged_by_users <= this.max_flagged_by_users,
|
||||
flagged_posts: this.num_flagged_posts <= this.max_flagged_posts,
|
||||
flagged_by_users: this.num_flagged_by_users <= this.max_flagged_by_users,
|
||||
likes_given: this.num_likes_given >= this.min_likes_given,
|
||||
likes_received:
|
||||
this.num_likes_received >= this.min_likes_received,
|
||||
likes_received: this.num_likes_received >= this.min_likes_received,
|
||||
likes_received_days:
|
||||
this.num_likes_received_days >=
|
||||
this.min_likes_received_days,
|
||||
this.num_likes_received_days >= this.min_likes_received_days,
|
||||
likes_received_users:
|
||||
this.num_likes_received_users >=
|
||||
this.min_likes_received_users,
|
||||
this.num_likes_received_users >= this.min_likes_received_users,
|
||||
level_locked: this.trust_level_locked,
|
||||
silenced: this.get("penalty_counts.silenced") === 0,
|
||||
suspended: this.get("penalty_counts.suspended") === 0
|
||||
|
|
|
@ -24,9 +24,7 @@ export default Ember.Component.extend({
|
|||
|
||||
self.$("input").autocomplete({
|
||||
allowAny: false,
|
||||
items: _.isArray(this.badgeNames)
|
||||
? this.badgeNames
|
||||
: [this.badgeNames],
|
||||
items: _.isArray(this.badgeNames) ? this.badgeNames : [this.badgeNames],
|
||||
single: this.single,
|
||||
updateData: opts && opts.updateData ? opts.updateData : false,
|
||||
onChangeItems: function(items) {
|
||||
|
|
|
@ -11,16 +11,12 @@ export default Ember.Component.extend({
|
|||
|
||||
@computed("categories.[].uploaded_logo.url")
|
||||
anyLogos() {
|
||||
return this.categories.any(
|
||||
c => !Ember.isEmpty(c.get("uploaded_logo.url"))
|
||||
);
|
||||
return this.categories.any(c => !Ember.isEmpty(c.get("uploaded_logo.url")));
|
||||
},
|
||||
|
||||
@computed("categories.[].subcategories")
|
||||
hasSubcategories() {
|
||||
return this.categories.any(
|
||||
c => !Ember.isEmpty(c.get("subcategories"))
|
||||
);
|
||||
return this.categories.any(c => !Ember.isEmpty(c.get("subcategories")));
|
||||
},
|
||||
|
||||
click(e) {
|
||||
|
|
|
@ -87,10 +87,7 @@ export default Ember.Component.extend(KeyEnterEscape, {
|
|||
|
||||
@observes("composeState")
|
||||
disableFullscreen() {
|
||||
if (
|
||||
this.composeState !== Composer.OPEN &&
|
||||
positioningWorkaround.blur
|
||||
) {
|
||||
if (this.composeState !== Composer.OPEN && positioningWorkaround.blur) {
|
||||
positioningWorkaround.blur();
|
||||
}
|
||||
},
|
||||
|
|
|
@ -341,14 +341,7 @@ export default Ember.Component.extend({
|
|||
this.set("shouldBuildScrollMap", false);
|
||||
}
|
||||
|
||||
Ember.run.throttle(
|
||||
this,
|
||||
$callback,
|
||||
$input,
|
||||
$preview,
|
||||
this.scrollMap,
|
||||
20
|
||||
);
|
||||
Ember.run.throttle(this, $callback, $input, $preview, this.scrollMap, 20);
|
||||
},
|
||||
|
||||
_teardownInputPreviewSync() {
|
||||
|
@ -739,10 +732,7 @@ export default Ember.Component.extend({
|
|||
|
||||
this._setUploadPlaceholderSend(data);
|
||||
|
||||
this.appEvents.trigger(
|
||||
"composer:insert-text",
|
||||
this.uploadPlaceholder
|
||||
);
|
||||
this.appEvents.trigger("composer:insert-text", this.uploadPlaceholder);
|
||||
|
||||
if (data.xhr && data.originalFiles.length === 1) {
|
||||
this.set("isCancellable", true);
|
||||
|
@ -963,11 +953,7 @@ export default Ember.Component.extend({
|
|||
unshift: true
|
||||
});
|
||||
|
||||
if (
|
||||
this.allowUpload &&
|
||||
this.uploadIcon &&
|
||||
!this.site.mobileView
|
||||
) {
|
||||
if (this.allowUpload && this.uploadIcon && !this.site.mobileView) {
|
||||
toolbar.addButton({
|
||||
id: "upload",
|
||||
group: "insertions",
|
||||
|
|
|
@ -64,9 +64,7 @@ export default Ember.Component.extend({
|
|||
titleMaxLength() {
|
||||
// maxLength gets in the way of pasting long links, so don't use it if featured links are allowed.
|
||||
// Validation will display a message if titles are too long.
|
||||
return this.watchForLink
|
||||
? null
|
||||
: this.siteSettings.max_topic_title_length;
|
||||
return this.watchForLink ? null : this.siteSettings.max_topic_title_length;
|
||||
},
|
||||
|
||||
@observes("composer.titleLength", "watchForLink")
|
||||
|
|
|
@ -27,10 +27,7 @@ export default Ember.Component.extend({
|
|||
}
|
||||
});
|
||||
|
||||
if (
|
||||
topicCount < this.requiredTopics ||
|
||||
postCount < this.requiredPosts
|
||||
) {
|
||||
if (topicCount < this.requiredTopics || postCount < this.requiredPosts) {
|
||||
this.set("enabled", true);
|
||||
this.fetchLiveStats();
|
||||
}
|
||||
|
|
|
@ -55,10 +55,7 @@ export default Ember.Component.extend({
|
|||
click() {
|
||||
if (typeof this.action === "string") {
|
||||
this.sendAction("action", this.actionParam);
|
||||
} else if (
|
||||
typeof this.action === "object" &&
|
||||
this.action.value
|
||||
) {
|
||||
} else if (typeof this.action === "object" && this.action.value) {
|
||||
this.action.value(this.actionParam);
|
||||
} else if (typeof this.action === "function") {
|
||||
this.action(this.actionParam);
|
||||
|
|
|
@ -39,16 +39,14 @@ const DiscoveryTopicsListComponent = Ember.Component.extend(
|
|||
actions: {
|
||||
loadMore() {
|
||||
Discourse.updateContextCount(0);
|
||||
this.model
|
||||
.loadMore()
|
||||
.then(hasMoreResults => {
|
||||
Ember.run.schedule("afterRender", () => this.saveScrollPosition());
|
||||
if (!hasMoreResults) {
|
||||
this.eyeline.flushRest();
|
||||
} else if ($(window).height() >= $(document).height()) {
|
||||
this.send("loadMore");
|
||||
}
|
||||
});
|
||||
this.model.loadMore().then(hasMoreResults => {
|
||||
Ember.run.schedule("afterRender", () => this.saveScrollPosition());
|
||||
if (!hasMoreResults) {
|
||||
this.eyeline.flushRest();
|
||||
} else if ($(window).height() >= $(document).height()) {
|
||||
this.send("loadMore");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,9 +63,7 @@ export default Ember.Component.extend({
|
|||
if (Ember.isEmpty(this.get("model.usernames"))) {
|
||||
return;
|
||||
}
|
||||
this.model
|
||||
.addMembers(this.get("model.usernames"))
|
||||
.catch(popupAjaxError);
|
||||
this.model.addMembers(this.get("model.usernames")).catch(popupAjaxError);
|
||||
this.set("model.usernames", null);
|
||||
},
|
||||
|
||||
|
|
|
@ -12,9 +12,7 @@ export default Ember.Component.extend(
|
|||
buildBuffer(buffer) {
|
||||
const reason = this.get("validation.reason");
|
||||
if (reason) {
|
||||
buffer.push(
|
||||
iconHTML(this.good ? "check" : "times") + " " + reason
|
||||
);
|
||||
buffer.push(iconHTML(this.good ? "check" : "times") + " " + reason);
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
|
@ -127,9 +127,7 @@ export default Ember.Component.extend({
|
|||
|
||||
@computed("inviteModel", "inviteModel.details.can_invite_via_email")
|
||||
canInviteViaEmail(inviteModel, canInviteViaEmail) {
|
||||
return this.inviteModel === this.currentUser
|
||||
? true
|
||||
: canInviteViaEmail;
|
||||
return this.inviteModel === this.currentUser ? true : canInviteViaEmail;
|
||||
},
|
||||
|
||||
@computed("isPM", "canInviteViaEmail")
|
||||
|
@ -184,10 +182,7 @@ export default Ember.Component.extend({
|
|||
|
||||
@computed("emailOrUsername")
|
||||
showCustomMessage(emailOrUsername) {
|
||||
return (
|
||||
this.inviteModel === this.currentUser ||
|
||||
emailValid(emailOrUsername)
|
||||
);
|
||||
return this.inviteModel === this.currentUser || emailValid(emailOrUsername);
|
||||
},
|
||||
|
||||
// Instructional text for the modal.
|
||||
|
@ -386,11 +381,7 @@ export default Ember.Component.extend({
|
|||
}
|
||||
|
||||
return model
|
||||
.generateInviteLink(
|
||||
this.emailOrUsername.trim(),
|
||||
groupNames,
|
||||
topicId
|
||||
)
|
||||
.generateInviteLink(this.emailOrUsername.trim(), groupNames, topicId)
|
||||
.then(result => {
|
||||
model.setProperties({
|
||||
saving: false,
|
||||
|
|
|
@ -181,9 +181,7 @@ export default Ember.Component.extend(
|
|||
|
||||
actions: {
|
||||
toggleBookmark() {
|
||||
this.topic
|
||||
.toggleBookmark()
|
||||
.finally(() => this.rerenderBuffer());
|
||||
this.topic.toggleBookmark().finally(() => this.rerenderBuffer());
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -173,8 +173,7 @@ export default Ember.Controller.extend(
|
|||
}
|
||||
if (
|
||||
this.get("emailValidation.ok") &&
|
||||
(Ember.isEmpty(this.accountUsername) ||
|
||||
this.get("authOptions.email"))
|
||||
(Ember.isEmpty(this.accountUsername) || this.get("authOptions.email"))
|
||||
) {
|
||||
// If email is valid and username has not been entered yet,
|
||||
// or email and username were filled automatically by 3rd parth auth,
|
||||
|
|
|
@ -85,9 +85,7 @@ export default Ember.Controller.extend(ModalFunctionality, {
|
|||
this.set("model.closed", result.closed);
|
||||
} else {
|
||||
const topicTimer =
|
||||
this.isPublic === "true"
|
||||
? "topic_timer"
|
||||
: "private_topic_timer";
|
||||
this.isPublic === "true" ? "topic_timer" : "private_topic_timer";
|
||||
this.set(`model.${topicTimer}`, Ember.Object.create({}));
|
||||
|
||||
this.setProperties({
|
||||
|
|
|
@ -291,9 +291,7 @@ export default Ember.Controller.extend({
|
|||
},
|
||||
|
||||
selectAll() {
|
||||
this.selected.addObjects(
|
||||
this.get("model.posts").map(r => r.topic)
|
||||
);
|
||||
this.selected.addObjects(this.get("model.posts").map(r => r.topic));
|
||||
// Doing this the proper way is a HUGE pain,
|
||||
// we can hack this to work by observing each on the array
|
||||
// in the component, however, when we select ANYTHING, we would force
|
||||
|
|
|
@ -180,9 +180,7 @@ export default Ember.Controller.extend(ModalFunctionality, {
|
|||
@computed("model.previous_hidden", "model.current_hidden", "displayingInline")
|
||||
hiddenClasses(prevHidden, currentHidden, displayingInline) {
|
||||
if (displayingInline) {
|
||||
return this.isEitherRevisionHidden
|
||||
? "hidden-revision-either"
|
||||
: null;
|
||||
return this.isEitherRevisionHidden ? "hidden-revision-either" : null;
|
||||
} else {
|
||||
var result = [];
|
||||
if (prevHidden) {
|
||||
|
|
|
@ -97,9 +97,7 @@ export default Ember.Controller.extend(
|
|||
result.errors.password &&
|
||||
result.errors.password.length > 0
|
||||
) {
|
||||
this.rejectedPasswords.pushObject(
|
||||
this.accountPassword
|
||||
);
|
||||
this.rejectedPasswords.pushObject(this.accountPassword);
|
||||
this.rejectedPasswordsMessages.set(
|
||||
this.accountPassword,
|
||||
result.errors.password[0]
|
||||
|
|
|
@ -15,10 +15,7 @@ export default Ember.Controller.extend(ModalFunctionality, {
|
|||
actions: {
|
||||
jump() {
|
||||
if (this.postNumber) {
|
||||
this._jumpToIndex(
|
||||
this.filteredPostsCount,
|
||||
this.postNumber
|
||||
);
|
||||
this._jumpToIndex(this.filteredPostsCount, this.postNumber);
|
||||
} else if (this.postDate) {
|
||||
this._jumpToDate(this.postDate);
|
||||
}
|
||||
|
|
|
@ -69,9 +69,7 @@ export default Ember.Controller.extend(PasswordValidation, {
|
|||
result.errors.password &&
|
||||
result.errors.password.length > 0
|
||||
) {
|
||||
this.rejectedPasswords.pushObject(
|
||||
this.accountPassword
|
||||
);
|
||||
this.rejectedPasswords.pushObject(this.accountPassword);
|
||||
this.rejectedPasswordsMessages.set(
|
||||
this.accountPassword,
|
||||
result.errors.password[0]
|
||||
|
|
|
@ -61,23 +61,21 @@ export default Ember.Controller.extend({
|
|||
const self = this;
|
||||
this.set("saving", true);
|
||||
|
||||
return this.model
|
||||
.changeEmail(this.newEmail)
|
||||
.then(
|
||||
() => self.set("success", true),
|
||||
e => {
|
||||
self.setProperties({ error: true, saving: false });
|
||||
if (
|
||||
e.jqXHR.responseJSON &&
|
||||
e.jqXHR.responseJSON.errors &&
|
||||
e.jqXHR.responseJSON.errors[0]
|
||||
) {
|
||||
self.set("errorMessage", e.jqXHR.responseJSON.errors[0]);
|
||||
} else {
|
||||
self.set("errorMessage", I18n.t("user.change_email.error"));
|
||||
}
|
||||
return this.model.changeEmail(this.newEmail).then(
|
||||
() => self.set("success", true),
|
||||
e => {
|
||||
self.setProperties({ error: true, saving: false });
|
||||
if (
|
||||
e.jqXHR.responseJSON &&
|
||||
e.jqXHR.responseJSON.errors &&
|
||||
e.jqXHR.responseJSON.errors[0]
|
||||
) {
|
||||
self.set("errorMessage", e.jqXHR.responseJSON.errors[0]);
|
||||
} else {
|
||||
self.set("errorMessage", I18n.t("user.change_email.error"));
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -75,9 +75,7 @@ export default Ember.Controller.extend({
|
|||
.changeUsername(this.newUsername)
|
||||
.then(() => {
|
||||
DiscourseURL.redirectTo(
|
||||
userPath(
|
||||
this.newUsername.toLowerCase() + "/preferences"
|
||||
)
|
||||
userPath(this.newUsername.toLowerCase() + "/preferences")
|
||||
);
|
||||
})
|
||||
.catch(popupAjaxError)
|
||||
|
|
|
@ -25,9 +25,7 @@ export default Ember.Controller.extend(PreferencesTabController, {
|
|||
if (!user.get("ignored")) {
|
||||
const usernames = this.ignoredUsernames
|
||||
.split(",")
|
||||
.removeAt(
|
||||
this.ignoredUsernames.split(",").length - 1
|
||||
)
|
||||
.removeAt(this.ignoredUsernames.split(",").length - 1)
|
||||
.join(",");
|
||||
this.set("ignoredUsernames", usernames);
|
||||
}
|
||||
|
@ -36,9 +34,7 @@ export default Ember.Controller.extend(PreferencesTabController, {
|
|||
});
|
||||
}
|
||||
} else {
|
||||
return this.model
|
||||
.save(["ignored_usernames"])
|
||||
.catch(popupAjaxError);
|
||||
return this.model.save(["ignored_usernames"]).catch(popupAjaxError);
|
||||
}
|
||||
},
|
||||
save() {
|
||||
|
|
|
@ -14,12 +14,10 @@ export default Ember.Controller.extend({
|
|||
destroy => {
|
||||
if (destroy) {
|
||||
const c = this.get("tagGroups.model");
|
||||
return this.model
|
||||
.destroy()
|
||||
.then(() => {
|
||||
c.removeObject(this.model);
|
||||
this.transitionToRoute("tagGroups");
|
||||
});
|
||||
return this.model.destroy().then(() => {
|
||||
c.removeObject(this.model);
|
||||
this.transitionToRoute("tagGroups");
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
|
|
|
@ -607,16 +607,14 @@ export default Ember.Controller.extend(bufferedProperty("model"), {
|
|||
} else if (post) {
|
||||
return post.toggleBookmark().catch(popupAjaxError);
|
||||
} else {
|
||||
return this.model
|
||||
.toggleBookmark()
|
||||
.then(changedIds => {
|
||||
if (!changedIds) {
|
||||
return;
|
||||
}
|
||||
changedIds.forEach(id =>
|
||||
this.appEvents.trigger("post-stream:refresh", { id })
|
||||
);
|
||||
});
|
||||
return this.model.toggleBookmark().then(changedIds => {
|
||||
if (!changedIds) {
|
||||
return;
|
||||
}
|
||||
changedIds.forEach(id =>
|
||||
this.appEvents.trigger("post-stream:refresh", { id })
|
||||
);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -842,11 +840,9 @@ export default Ember.Controller.extend(bufferedProperty("model"), {
|
|||
toggleClosed() {
|
||||
const topic = this.model;
|
||||
|
||||
this.model
|
||||
.toggleStatus("closed")
|
||||
.then(result => {
|
||||
topic.set("topic_status_update", result.topic_status_update);
|
||||
});
|
||||
this.model.toggleStatus("closed").then(result => {
|
||||
topic.set("topic_status_update", result.topic_status_update);
|
||||
});
|
||||
},
|
||||
|
||||
recoverTopic() {
|
||||
|
@ -1044,9 +1040,7 @@ export default Ember.Controller.extend(bufferedProperty("model"), {
|
|||
);
|
||||
} else {
|
||||
postStream.loadPostByPostNumber(postNumber).then(p => {
|
||||
DiscourseURL.routeTo(
|
||||
this.model.urlForPostNumber(p.get("post_number"))
|
||||
);
|
||||
DiscourseURL.routeTo(this.model.urlForPostNumber(p.get("post_number")));
|
||||
});
|
||||
}
|
||||
},
|
||||
|
@ -1197,10 +1191,7 @@ export default Ember.Controller.extend(bufferedProperty("model"), {
|
|||
},
|
||||
|
||||
postSelected(post) {
|
||||
return (
|
||||
this.selectedAllPost ||
|
||||
this.selectedPostIds.includes(post.id)
|
||||
);
|
||||
return this.selectedAllPost || this.selectedPostIds.includes(post.id);
|
||||
},
|
||||
|
||||
@computed
|
||||
|
|
|
@ -26,11 +26,9 @@ export default Ember.Controller.extend({
|
|||
|
||||
@observes("searchTerm")
|
||||
_searchTermChanged: debounce(function() {
|
||||
Invite.findInvitedBy(
|
||||
this.user,
|
||||
this.filter,
|
||||
this.searchTerm
|
||||
).then(invites => this.set("model", invites));
|
||||
Invite.findInvitedBy(this.user, this.filter, this.searchTerm).then(
|
||||
invites => this.set("model", invites)
|
||||
);
|
||||
}, 250),
|
||||
|
||||
inviteRedeemed: Ember.computed.equal("filter", "redeemed"),
|
||||
|
|
|
@ -106,8 +106,7 @@ export default Ember.Mixin.create({
|
|||
}.on("didInsertElement"),
|
||||
|
||||
_destroy: function() {
|
||||
this.messageBus &&
|
||||
this.messageBus.unsubscribe("/uploads/" + this.type);
|
||||
this.messageBus && this.messageBus.unsubscribe("/uploads/" + this.type);
|
||||
|
||||
const $upload = this.$();
|
||||
try {
|
||||
|
|
|
@ -4,9 +4,7 @@ import RestModel from "discourse/models/rest";
|
|||
export default RestModel.extend({
|
||||
@computed("name")
|
||||
i18nNameKey() {
|
||||
return this.name
|
||||
.toLowerCase()
|
||||
.replace(/\s/g, "_");
|
||||
return this.name.toLowerCase().replace(/\s/g, "_");
|
||||
},
|
||||
|
||||
@computed("name")
|
||||
|
|
|
@ -41,33 +41,27 @@ const Group = RestModel.extend({
|
|||
return;
|
||||
}
|
||||
|
||||
const offset = Math.min(
|
||||
this.user_count,
|
||||
Math.max(this.offset, 0)
|
||||
const offset = Math.min(this.user_count, Math.max(this.offset, 0));
|
||||
|
||||
return Group.loadMembers(this.name, offset, this.limit, params).then(
|
||||
result => {
|
||||
var ownerIds = {};
|
||||
result.owners.forEach(owner => (ownerIds[owner.id] = true));
|
||||
|
||||
this.setProperties({
|
||||
user_count: result.meta.total,
|
||||
limit: result.meta.limit,
|
||||
offset: result.meta.offset,
|
||||
members: result.members.map(member => {
|
||||
if (ownerIds[member.id]) {
|
||||
member.owner = true;
|
||||
}
|
||||
return User.create(member);
|
||||
}),
|
||||
owners: result.owners.map(owner => User.create(owner))
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
return Group.loadMembers(
|
||||
this.name,
|
||||
offset,
|
||||
this.limit,
|
||||
params
|
||||
).then(result => {
|
||||
var ownerIds = {};
|
||||
result.owners.forEach(owner => (ownerIds[owner.id] = true));
|
||||
|
||||
this.setProperties({
|
||||
user_count: result.meta.total,
|
||||
limit: result.meta.limit,
|
||||
offset: result.meta.offset,
|
||||
members: result.members.map(member => {
|
||||
if (ownerIds[member.id]) {
|
||||
member.owner = true;
|
||||
}
|
||||
return User.create(member);
|
||||
}),
|
||||
owners: result.owners.map(owner => User.create(owner))
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
removeOwner(member) {
|
||||
|
@ -251,16 +245,14 @@ const Group = RestModel.extend({
|
|||
data.category_id = parseInt(opts.categoryId);
|
||||
}
|
||||
|
||||
return ajax(`/groups/${this.name}/${type}.json`, { data }).then(
|
||||
posts => {
|
||||
return posts.map(p => {
|
||||
p.user = User.create(p.user);
|
||||
p.topic = Topic.create(p.topic);
|
||||
p.category = Category.findById(p.category_id);
|
||||
return Ember.Object.create(p);
|
||||
});
|
||||
}
|
||||
);
|
||||
return ajax(`/groups/${this.name}/${type}.json`, { data }).then(posts => {
|
||||
return posts.map(p => {
|
||||
p.user = User.create(p.user);
|
||||
p.topic = Topic.create(p.topic);
|
||||
p.category = Category.findById(p.category_id);
|
||||
return Ember.Object.create(p);
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
setNotification(notification_level, userId) {
|
||||
|
|
|
@ -3,25 +3,17 @@ import computed from "ember-addons/ember-computed-decorators";
|
|||
const LoginMethod = Ember.Object.extend({
|
||||
@computed
|
||||
title() {
|
||||
return (
|
||||
this.title_override || I18n.t(`login.${this.name}.title`)
|
||||
);
|
||||
return this.title_override || I18n.t(`login.${this.name}.title`);
|
||||
},
|
||||
|
||||
@computed
|
||||
prettyName() {
|
||||
return (
|
||||
this.pretty_name_override ||
|
||||
I18n.t(`login.${this.name}.name`)
|
||||
);
|
||||
return this.pretty_name_override || I18n.t(`login.${this.name}.name`);
|
||||
},
|
||||
|
||||
@computed
|
||||
message() {
|
||||
return (
|
||||
this.message_override ||
|
||||
I18n.t("login." + this.name + ".message")
|
||||
);
|
||||
return this.message_override || I18n.t("login." + this.name + ".message");
|
||||
},
|
||||
|
||||
doLogin({ reconnect = false, fullScreenLogin = true } = {}) {
|
||||
|
|
|
@ -487,9 +487,7 @@ export default RestModel.extend({
|
|||
**/
|
||||
undoPost(post) {
|
||||
this.stream.removeObject(-1);
|
||||
this.postsWithPlaceholders.removePost(() =>
|
||||
this.posts.removeObject(post)
|
||||
);
|
||||
this.postsWithPlaceholders.removePost(() => this.posts.removeObject(post));
|
||||
this._identityMap[-1] = null;
|
||||
|
||||
const topic = this.topic;
|
||||
|
@ -520,9 +518,7 @@ export default RestModel.extend({
|
|||
|
||||
if (!posts.includes(stored)) {
|
||||
if (!this.loadingBelow) {
|
||||
this.postsWithPlaceholders.appendPost(() =>
|
||||
posts.pushObject(stored)
|
||||
);
|
||||
this.postsWithPlaceholders.appendPost(() => posts.pushObject(stored));
|
||||
} else {
|
||||
posts.pushObject(stored);
|
||||
}
|
||||
|
|
|
@ -91,9 +91,7 @@ const Post = RestModel.extend({
|
|||
internalLinks() {
|
||||
if (Ember.isEmpty(this.link_counts)) return null;
|
||||
|
||||
return this.link_counts
|
||||
.filterBy("internal")
|
||||
.filterBy("title");
|
||||
return this.link_counts.filterBy("internal").filterBy("title");
|
||||
},
|
||||
|
||||
@computed("actions_summary.@each.can_act")
|
||||
|
|
|
@ -69,11 +69,7 @@ const Topic = RestModel.extend({
|
|||
const maxUserCount = 5;
|
||||
const posterCount = users.length;
|
||||
|
||||
if (
|
||||
this.isPrivateMessage &&
|
||||
participants &&
|
||||
posterCount < maxUserCount
|
||||
) {
|
||||
if (this.isPrivateMessage && participants && posterCount < maxUserCount) {
|
||||
let pushOffset = 0;
|
||||
if (posterCount > 1) {
|
||||
const lastUser = users[posterCount - 1];
|
||||
|
|
|
@ -50,13 +50,9 @@ const UserAction = RestModel.extend({
|
|||
|
||||
if (this.postReplyType) {
|
||||
if (this.reply_to_post_number) {
|
||||
return this.sameUser
|
||||
? "you_replied_to_post"
|
||||
: "user_replied_to_post";
|
||||
return this.sameUser ? "you_replied_to_post" : "user_replied_to_post";
|
||||
} else {
|
||||
return this.sameUser
|
||||
? "you_replied_to_topic"
|
||||
: "user_replied_to_topic";
|
||||
return this.sameUser ? "you_replied_to_topic" : "user_replied_to_topic";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -64,9 +60,7 @@ const UserAction = RestModel.extend({
|
|||
if (this.sameUser) {
|
||||
return "you_mentioned_user";
|
||||
} else {
|
||||
return this.targetUser
|
||||
? "user_mentioned_you"
|
||||
: "user_mentioned_user";
|
||||
return this.targetUser ? "user_mentioned_you" : "user_mentioned_user";
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -102,20 +96,12 @@ const UserAction = RestModel.extend({
|
|||
|
||||
@computed()
|
||||
postUrl() {
|
||||
return postUrl(
|
||||
this.slug,
|
||||
this.topic_id,
|
||||
this.post_number
|
||||
);
|
||||
return postUrl(this.slug, this.topic_id, this.post_number);
|
||||
},
|
||||
|
||||
@computed()
|
||||
replyUrl() {
|
||||
return postUrl(
|
||||
this.slug,
|
||||
this.topic_id,
|
||||
this.reply_to_post_number
|
||||
);
|
||||
return postUrl(this.slug, this.topic_id, this.reply_to_post_number);
|
||||
},
|
||||
|
||||
replyType: Ember.computed.equal("action_type", UserActionTypes.replies),
|
||||
|
|
|
@ -24,11 +24,7 @@ export default RestModel.extend({
|
|||
postUrl(topicId) {
|
||||
if (!topicId) return;
|
||||
|
||||
return postUrl(
|
||||
this.slug,
|
||||
this.topic_id,
|
||||
this.post_number
|
||||
);
|
||||
return postUrl(this.slug, this.topic_id, this.post_number);
|
||||
},
|
||||
|
||||
@computed("draft_key")
|
||||
|
|
|
@ -218,13 +218,10 @@ const User = RestModel.extend({
|
|||
silencedTillDate: longDate,
|
||||
|
||||
changeUsername(new_username) {
|
||||
return ajax(
|
||||
userPath(`${this.username_lower}/preferences/username`),
|
||||
{
|
||||
type: "PUT",
|
||||
data: { new_username }
|
||||
}
|
||||
);
|
||||
return ajax(userPath(`${this.username_lower}/preferences/username`), {
|
||||
type: "PUT",
|
||||
data: { new_username }
|
||||
});
|
||||
},
|
||||
|
||||
changeEmail(email) {
|
||||
|
@ -390,13 +387,10 @@ const User = RestModel.extend({
|
|||
},
|
||||
|
||||
revokeAssociatedAccount(providerName) {
|
||||
return ajax(
|
||||
userPath(`${this.username}/preferences/revoke-account`),
|
||||
{
|
||||
data: { provider_name: providerName },
|
||||
type: "POST"
|
||||
}
|
||||
);
|
||||
return ajax(userPath(`${this.username}/preferences/revoke-account`), {
|
||||
data: { provider_name: providerName },
|
||||
type: "POST"
|
||||
});
|
||||
},
|
||||
|
||||
loadUserAction(id) {
|
||||
|
@ -528,17 +522,17 @@ const User = RestModel.extend({
|
|||
},
|
||||
|
||||
pickAvatar(upload_id, type) {
|
||||
return ajax(
|
||||
userPath(`${this.username_lower}/preferences/avatar/pick`),
|
||||
{ type: "PUT", data: { upload_id, type } }
|
||||
);
|
||||
return ajax(userPath(`${this.username_lower}/preferences/avatar/pick`), {
|
||||
type: "PUT",
|
||||
data: { upload_id, type }
|
||||
});
|
||||
},
|
||||
|
||||
selectAvatar(avatarUrl) {
|
||||
return ajax(
|
||||
userPath(`${this.username_lower}/preferences/avatar/select`),
|
||||
{ type: "PUT", data: { url: avatarUrl } }
|
||||
);
|
||||
return ajax(userPath(`${this.username_lower}/preferences/avatar/select`), {
|
||||
type: "PUT",
|
||||
data: { url: avatarUrl }
|
||||
});
|
||||
},
|
||||
|
||||
isAllowedToUploadAFile(type) {
|
||||
|
@ -657,49 +651,47 @@ const User = RestModel.extend({
|
|||
// let { store } = this; would fail in tests
|
||||
const store = Discourse.__container__.lookup("service:store");
|
||||
|
||||
return ajax(userPath(`${this.username_lower}/summary.json`)).then(
|
||||
json => {
|
||||
const summary = json.user_summary;
|
||||
const topicMap = {};
|
||||
const badgeMap = {};
|
||||
return ajax(userPath(`${this.username_lower}/summary.json`)).then(json => {
|
||||
const summary = json.user_summary;
|
||||
const topicMap = {};
|
||||
const badgeMap = {};
|
||||
|
||||
json.topics.forEach(
|
||||
t => (topicMap[t.id] = store.createRecord("topic", t))
|
||||
);
|
||||
Badge.createFromJson(json).forEach(b => (badgeMap[b.id] = b));
|
||||
json.topics.forEach(
|
||||
t => (topicMap[t.id] = store.createRecord("topic", t))
|
||||
);
|
||||
Badge.createFromJson(json).forEach(b => (badgeMap[b.id] = b));
|
||||
|
||||
summary.topics = summary.topic_ids.map(id => topicMap[id]);
|
||||
summary.topics = summary.topic_ids.map(id => topicMap[id]);
|
||||
|
||||
summary.replies.forEach(r => {
|
||||
r.topic = topicMap[r.topic_id];
|
||||
r.url = r.topic.urlForPostNumber(r.post_number);
|
||||
r.createdAt = new Date(r.created_at);
|
||||
summary.replies.forEach(r => {
|
||||
r.topic = topicMap[r.topic_id];
|
||||
r.url = r.topic.urlForPostNumber(r.post_number);
|
||||
r.createdAt = new Date(r.created_at);
|
||||
});
|
||||
|
||||
summary.links.forEach(l => {
|
||||
l.topic = topicMap[l.topic_id];
|
||||
l.post_url = l.topic.urlForPostNumber(l.post_number);
|
||||
});
|
||||
|
||||
if (summary.badges) {
|
||||
summary.badges = summary.badges.map(ub => {
|
||||
const badge = badgeMap[ub.badge_id];
|
||||
badge.count = ub.count;
|
||||
return badge;
|
||||
});
|
||||
|
||||
summary.links.forEach(l => {
|
||||
l.topic = topicMap[l.topic_id];
|
||||
l.post_url = l.topic.urlForPostNumber(l.post_number);
|
||||
});
|
||||
|
||||
if (summary.badges) {
|
||||
summary.badges = summary.badges.map(ub => {
|
||||
const badge = badgeMap[ub.badge_id];
|
||||
badge.count = ub.count;
|
||||
return badge;
|
||||
});
|
||||
}
|
||||
|
||||
if (summary.top_categories) {
|
||||
summary.top_categories.forEach(c => {
|
||||
if (c.parent_category_id) {
|
||||
c.parentCategory = Category.findById(c.parent_category_id);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return summary;
|
||||
}
|
||||
);
|
||||
|
||||
if (summary.top_categories) {
|
||||
summary.top_categories.forEach(c => {
|
||||
if (c.parent_category_id) {
|
||||
c.parentCategory = Category.findById(c.parent_category_id);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return summary;
|
||||
});
|
||||
},
|
||||
|
||||
canManageGroup(group) {
|
||||
|
|
|
@ -12,8 +12,7 @@ export default Discourse.Route.extend(ViewingActionType, {
|
|||
afterModel(model, transition) {
|
||||
return model.filterBy({
|
||||
filter: this.userActionType,
|
||||
noContentHelpKey:
|
||||
this.noContentHelpKey || "user_activity.no_default",
|
||||
noContentHelpKey: this.noContentHelpKey || "user_activity.no_default",
|
||||
actingUsername: transition.to.queryParams.acting_username
|
||||
});
|
||||
},
|
||||
|
|
|
@ -46,8 +46,7 @@ export default MultiSelectComponent.extend({
|
|||
const blacklist = Ember.makeArray(this.blacklist);
|
||||
return Category.list().filter(category => {
|
||||
return (
|
||||
this.categories.includes(category) ||
|
||||
!blacklist.includes(category)
|
||||
this.categories.includes(category) || !blacklist.includes(category)
|
||||
);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -39,9 +39,7 @@ export default MultiSelectComponent.extend({
|
|||
},
|
||||
|
||||
computeValues() {
|
||||
return this.settingValue
|
||||
.split(this.tokenSeparator)
|
||||
.filter(c => c);
|
||||
return this.settingValue.split(this.tokenSeparator).filter(c => c);
|
||||
},
|
||||
|
||||
_handleTabOnKeyDown(event) {
|
||||
|
|
|
@ -154,8 +154,7 @@ export default ComboBox.extend(TagsMixin, {
|
|||
}
|
||||
|
||||
if (!this.hasReachedMinimum && isEmpty(this.selection)) {
|
||||
const key =
|
||||
this.minimumLabel || "select_kit.min_content_not_reached";
|
||||
const key = this.minimumLabel || "select_kit.min_content_not_reached";
|
||||
const label = I18n.t(key, { count: this.minimum });
|
||||
content.title = content.name = content.label = label;
|
||||
}
|
||||
|
|
|
@ -168,14 +168,11 @@ export default SelectKitComponent.extend({
|
|||
|
||||
if (this.noneLabel) {
|
||||
if (!this.hasSelection) {
|
||||
content.title = content.name = content.label = I18n.t(
|
||||
this.noneLabel
|
||||
);
|
||||
content.title = content.name = content.label = I18n.t(this.noneLabel);
|
||||
}
|
||||
} else {
|
||||
if (!this.hasReachedMinimum) {
|
||||
const key =
|
||||
this.minimumLabel || "select_kit.min_content_not_reached";
|
||||
const key = this.minimumLabel || "select_kit.min_content_not_reached";
|
||||
content.title = content.name = content.label = I18n.t(key, {
|
||||
count: this.minimum
|
||||
});
|
||||
|
@ -243,10 +240,7 @@ export default SelectKitComponent.extend({
|
|||
if (isEmpty(this.collectionComputedContent)) {
|
||||
if (this.createRowComputedContent) {
|
||||
this.highlight(this.createRowComputedContent);
|
||||
} else if (
|
||||
this.noneRowComputedContent &&
|
||||
this.hasSelection
|
||||
) {
|
||||
} else if (this.noneRowComputedContent && this.hasSelection) {
|
||||
this.highlight(this.noneRowComputedContent);
|
||||
}
|
||||
} else {
|
||||
|
@ -260,10 +254,7 @@ export default SelectKitComponent.extend({
|
|||
!computedContentItem ||
|
||||
computedContentItem.__sk_row_type === "noneRow"
|
||||
) {
|
||||
applyOnSelectNonePluginApiCallbacks(
|
||||
this.pluginApiIdentifiers,
|
||||
this
|
||||
);
|
||||
applyOnSelectNonePluginApiCallbacks(this.pluginApiIdentifiers, this);
|
||||
this._boundaryActionHandler("onSelectNone");
|
||||
this.clearSelection();
|
||||
return;
|
||||
|
|
|
@ -157,9 +157,7 @@ export default SelectKitComponent.extend({
|
|||
|
||||
@computed("selection")
|
||||
hasSelection(selection) {
|
||||
return (
|
||||
selection !== this.noneRowComputedContent && !isNone(selection)
|
||||
);
|
||||
return selection !== this.noneRowComputedContent && !isNone(selection);
|
||||
},
|
||||
|
||||
@computed(
|
||||
|
@ -180,19 +178,12 @@ export default SelectKitComponent.extend({
|
|||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
!isEmpty(this.filter) &&
|
||||
!isEmpty(this.collectionComputedContent)
|
||||
) {
|
||||
if (!isEmpty(this.filter) && !isEmpty(this.collectionComputedContent)) {
|
||||
this.highlight(this.get("collectionComputedContent.firstObject"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
!this.isAsync &&
|
||||
this.hasSelection &&
|
||||
isEmpty(this.filter)
|
||||
) {
|
||||
if (!this.isAsync && this.hasSelection && isEmpty(this.filter)) {
|
||||
this.highlight(get(makeArray(this.selection), "firstObject"));
|
||||
return;
|
||||
}
|
||||
|
@ -235,10 +226,7 @@ export default SelectKitComponent.extend({
|
|||
!computedContentItem ||
|
||||
computedContentItem.__sk_row_type === "noneRow"
|
||||
) {
|
||||
applyOnSelectNonePluginApiCallbacks(
|
||||
this.pluginApiIdentifiers,
|
||||
this
|
||||
);
|
||||
applyOnSelectNonePluginApiCallbacks(this.pluginApiIdentifiers, this);
|
||||
this._boundaryActionHandler("onSelectNone");
|
||||
this._boundaryActionHandler("onSelectAny", computedContentItem);
|
||||
this.clearSelection();
|
||||
|
|
|
@ -105,9 +105,10 @@ export default MultiSelectComponent.extend(TagsMixin, {
|
|||
};
|
||||
|
||||
if (selectedTags.length || this.blacklist.length) {
|
||||
data.selected_tags = _.uniq(
|
||||
selectedTags.concat(this.blacklist)
|
||||
).slice(0, 100);
|
||||
data.selected_tags = _.uniq(selectedTags.concat(this.blacklist)).slice(
|
||||
0,
|
||||
100
|
||||
);
|
||||
}
|
||||
|
||||
if (!this.everyTag) data.filterForInput = true;
|
||||
|
|
|
@ -180,10 +180,7 @@ export default Ember.Mixin.create({
|
|||
const offsetBottom = this.element.getBoundingClientRect().bottom;
|
||||
const windowWidth = $(window).width();
|
||||
|
||||
if (
|
||||
this.fullWidthOnMobile &&
|
||||
(this.site && this.site.isMobileDevice)
|
||||
) {
|
||||
if (this.fullWidthOnMobile && (this.site && this.site.isMobileDevice)) {
|
||||
const margin = 10;
|
||||
const relativeLeft = this.$().offset().left - $(window).scrollLeft();
|
||||
options.left = margin - relativeLeft;
|
||||
|
@ -218,8 +215,7 @@ export default Ember.Mixin.create({
|
|||
if (this._isRTL()) {
|
||||
options.right = this.horizontalOffset;
|
||||
} else {
|
||||
options.left =
|
||||
-bodyWidth + elementWidth - this.horizontalOffset;
|
||||
options.left = -bodyWidth + elementWidth - this.horizontalOffset;
|
||||
}
|
||||
} else {
|
||||
this.$()
|
||||
|
@ -227,16 +223,14 @@ export default Ember.Mixin.create({
|
|||
.removeClass("is-left-aligned");
|
||||
|
||||
if (this._isRTL()) {
|
||||
options.right =
|
||||
-bodyWidth + elementWidth - this.horizontalOffset;
|
||||
options.right = -bodyWidth + elementWidth - this.horizontalOffset;
|
||||
} else {
|
||||
options.left = this.horizontalOffset;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const fullHeight =
|
||||
this.verticalOffset + bodyHeight + componentHeight;
|
||||
const fullHeight = this.verticalOffset + bodyHeight + componentHeight;
|
||||
const hasBelowSpace = $(window).height() - offsetBottom - fullHeight >= -1;
|
||||
const hasAboveSpace = offsetTop - fullHeight - discourseHeaderHeight >= -1;
|
||||
const headerHeight = this._computedStyle(this.$header()[0], "height");
|
||||
|
|
|
@ -55,11 +55,7 @@ export default Ember.Mixin.create({
|
|||
},
|
||||
|
||||
_castInteger(value) {
|
||||
if (
|
||||
this.castInteger &&
|
||||
Ember.isPresent(value) &&
|
||||
this._isNumeric(value)
|
||||
) {
|
||||
if (this.castInteger && Ember.isPresent(value) && this._isNumeric(value)) {
|
||||
return parseInt(value, 10);
|
||||
}
|
||||
|
||||
|
|
|
@ -79,9 +79,7 @@ export function createPreviewComponent(width, height, obj) {
|
|||
return false;
|
||||
}
|
||||
|
||||
const colors = this.wizard.getCurrentColors(
|
||||
this.colorsId
|
||||
);
|
||||
const colors = this.wizard.getCurrentColors(this.colorsId);
|
||||
if (!colors) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -11,18 +11,8 @@ componentTest("with value", {
|
|||
template: "{{category-chooser value=2}}",
|
||||
|
||||
test(assert) {
|
||||
assert.equal(
|
||||
this.subject
|
||||
.header()
|
||||
.value(),
|
||||
2
|
||||
);
|
||||
assert.equal(
|
||||
this.subject
|
||||
.header()
|
||||
.title(),
|
||||
"feature"
|
||||
);
|
||||
assert.equal(this.subject.header().value(), 2);
|
||||
assert.equal(this.subject.header().title(), "feature");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -32,11 +22,7 @@ componentTest("with excludeCategoryId", {
|
|||
async test(assert) {
|
||||
await this.subject.expand();
|
||||
|
||||
assert.notOk(
|
||||
this.subject
|
||||
.rowByValue(2)
|
||||
.exists()
|
||||
);
|
||||
assert.notOk(this.subject.rowByValue(2).exists());
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -47,29 +33,15 @@ componentTest("with scopedCategoryId", {
|
|||
await this.subject.expand();
|
||||
|
||||
assert.equal(
|
||||
this.subject
|
||||
.rowByIndex(0)
|
||||
.title(),
|
||||
this.subject.rowByIndex(0).title(),
|
||||
"Discussion about features or potential features of Discourse: how they work, why they work, etc."
|
||||
);
|
||||
assert.equal(this.subject.rowByIndex(0).value(), 2);
|
||||
assert.equal(
|
||||
this.subject
|
||||
.rowByIndex(0)
|
||||
.value(),
|
||||
2
|
||||
);
|
||||
assert.equal(
|
||||
this.subject
|
||||
.rowByIndex(1)
|
||||
.title(),
|
||||
this.subject.rowByIndex(1).title(),
|
||||
"My idea here is to have mini specs for features we would like built but have no bandwidth to build"
|
||||
);
|
||||
assert.equal(
|
||||
this.subject
|
||||
.rowByIndex(1)
|
||||
.value(),
|
||||
26
|
||||
);
|
||||
assert.equal(this.subject.rowByIndex(1).value(), 26);
|
||||
assert.equal(this.subject.rows().length, 2);
|
||||
|
||||
await this.subject.fillInFilter("dev");
|
||||
|
@ -86,18 +58,8 @@ componentTest("with allowUncategorized=null", {
|
|||
},
|
||||
|
||||
test(assert) {
|
||||
assert.equal(
|
||||
this.subject
|
||||
.header()
|
||||
.value(),
|
||||
null
|
||||
);
|
||||
assert.equal(
|
||||
this.subject
|
||||
.header()
|
||||
.title(),
|
||||
"category"
|
||||
);
|
||||
assert.equal(this.subject.header().value(), null);
|
||||
assert.equal(this.subject.header().title(), "category");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -109,18 +71,8 @@ componentTest("with allowUncategorized=null rootNone=true", {
|
|||
},
|
||||
|
||||
test(assert) {
|
||||
assert.equal(
|
||||
this.subject
|
||||
.header()
|
||||
.value(),
|
||||
null
|
||||
);
|
||||
assert.equal(
|
||||
this.subject
|
||||
.header()
|
||||
.title(),
|
||||
"category"
|
||||
);
|
||||
assert.equal(this.subject.header().value(), null);
|
||||
assert.equal(this.subject.header().title(), "category");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -134,18 +86,8 @@ componentTest("with disallowed uncategorized, rootNone and rootNoneLabel", {
|
|||
},
|
||||
|
||||
test(assert) {
|
||||
assert.equal(
|
||||
this.subject
|
||||
.header()
|
||||
.value(),
|
||||
null
|
||||
);
|
||||
assert.equal(
|
||||
this.subject
|
||||
.header()
|
||||
.title(),
|
||||
"category"
|
||||
);
|
||||
assert.equal(this.subject.header().value(), null);
|
||||
assert.equal(this.subject.header().title(), "category");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -157,18 +99,8 @@ componentTest("with allowed uncategorized", {
|
|||
},
|
||||
|
||||
test(assert) {
|
||||
assert.equal(
|
||||
this.subject
|
||||
.header()
|
||||
.value(),
|
||||
null
|
||||
);
|
||||
assert.equal(
|
||||
this.subject
|
||||
.header()
|
||||
.title(),
|
||||
"uncategorized"
|
||||
);
|
||||
assert.equal(this.subject.header().value(), null);
|
||||
assert.equal(this.subject.header().title(), "uncategorized");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -180,18 +112,8 @@ componentTest("with allowed uncategorized and rootNone", {
|
|||
},
|
||||
|
||||
test(assert) {
|
||||
assert.equal(
|
||||
this.subject
|
||||
.header()
|
||||
.value(),
|
||||
null
|
||||
);
|
||||
assert.equal(
|
||||
this.subject
|
||||
.header()
|
||||
.title(),
|
||||
"(no category)"
|
||||
);
|
||||
assert.equal(this.subject.header().value(), null);
|
||||
assert.equal(this.subject.header().title(), "(no category)");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -205,17 +127,7 @@ componentTest("with allowed uncategorized rootNone and rootNoneLabel", {
|
|||
},
|
||||
|
||||
test(assert) {
|
||||
assert.equal(
|
||||
this.subject
|
||||
.header()
|
||||
.value(),
|
||||
null
|
||||
);
|
||||
assert.equal(
|
||||
this.subject
|
||||
.header()
|
||||
.title(),
|
||||
"root none label"
|
||||
);
|
||||
assert.equal(this.subject.header().value(), null);
|
||||
assert.equal(this.subject.header().title(), "root none label");
|
||||
}
|
||||
});
|
||||
|
|
|
@ -25,25 +25,19 @@ componentTest("subcatgories - no selection", {
|
|||
|
||||
async test(assert) {
|
||||
assert.equal(
|
||||
this.subject
|
||||
.header()
|
||||
.title(),
|
||||
this.subject.header().title(),
|
||||
I18n.t("categories.all_subcategories")
|
||||
);
|
||||
|
||||
await this.subject.expand();
|
||||
|
||||
assert.equal(
|
||||
this.subject
|
||||
.rowByIndex(0)
|
||||
.name(),
|
||||
this.subject.rowByIndex(0).name(),
|
||||
I18n.t("categories.no_subcategory")
|
||||
);
|
||||
|
||||
assert.equal(
|
||||
this.subject
|
||||
.rowByIndex(1)
|
||||
.name(),
|
||||
this.subject.rowByIndex(1).name(),
|
||||
this.get("childCategories.firstObject.name")
|
||||
);
|
||||
}
|
||||
|
@ -67,25 +61,19 @@ componentTest("subcatgories - selection", {
|
|||
|
||||
async test(assert) {
|
||||
assert.equal(
|
||||
this.subject
|
||||
.header()
|
||||
.title(),
|
||||
this.subject.header().title(),
|
||||
this.get("childCategories.firstObject.name")
|
||||
);
|
||||
|
||||
await this.subject.expand();
|
||||
|
||||
assert.equal(
|
||||
this.subject
|
||||
.rowByIndex(0)
|
||||
.name(),
|
||||
this.subject.rowByIndex(0).name(),
|
||||
I18n.t("categories.all_subcategories")
|
||||
);
|
||||
|
||||
assert.equal(
|
||||
this.subject
|
||||
.rowByIndex(1)
|
||||
.name(),
|
||||
this.subject.rowByIndex(1).name(),
|
||||
I18n.t("categories.no_subcategory")
|
||||
);
|
||||
}
|
||||
|
|
|
@ -16,16 +16,9 @@ componentTest("default", {
|
|||
},
|
||||
|
||||
test(assert) {
|
||||
assert.equal(
|
||||
this.subject
|
||||
.header()
|
||||
.value(),
|
||||
2
|
||||
);
|
||||
assert.equal(this.subject.header().value(), 2);
|
||||
assert.notOk(
|
||||
this.subject
|
||||
.rowByValue(2)
|
||||
.exists(),
|
||||
this.subject.rowByValue(2).exists(),
|
||||
"selected categories are not in the list"
|
||||
);
|
||||
}
|
||||
|
@ -43,15 +36,11 @@ componentTest("with blacklist", {
|
|||
await this.subject.expand();
|
||||
|
||||
assert.ok(
|
||||
this.subject
|
||||
.rowByValue(6)
|
||||
.exists(),
|
||||
this.subject.rowByValue(6).exists(),
|
||||
"not blacklisted categories are in the list"
|
||||
);
|
||||
assert.notOk(
|
||||
this.subject
|
||||
.rowByValue(8)
|
||||
.exists(),
|
||||
this.subject.rowByValue(8).exists(),
|
||||
"blacklisted categories are not in the list"
|
||||
);
|
||||
}
|
||||
|
@ -70,9 +59,7 @@ componentTest("interactions", {
|
|||
await this.subject.selectRowByValue(8);
|
||||
|
||||
assert.equal(
|
||||
this.subject
|
||||
.header()
|
||||
.value(),
|
||||
this.subject.header().value(),
|
||||
"2,6,8",
|
||||
"it adds the selected category"
|
||||
);
|
||||
|
@ -84,9 +71,7 @@ componentTest("interactions", {
|
|||
await this.subject.keyboard("backspace");
|
||||
|
||||
assert.equal(
|
||||
this.subject
|
||||
.header()
|
||||
.value(),
|
||||
this.subject.header().value(),
|
||||
"2,6",
|
||||
"it removes the last selected category"
|
||||
);
|
||||
|
|
|
@ -15,24 +15,9 @@ componentTest("default", {
|
|||
async test(assert) {
|
||||
await this.subject.expand();
|
||||
|
||||
assert.equal(
|
||||
this.subject
|
||||
.header()
|
||||
.name(),
|
||||
"hello"
|
||||
);
|
||||
assert.equal(
|
||||
this.subject
|
||||
.rowByValue(1)
|
||||
.name(),
|
||||
"hello"
|
||||
);
|
||||
assert.equal(
|
||||
this.subject
|
||||
.rowByValue(2)
|
||||
.name(),
|
||||
"world"
|
||||
);
|
||||
assert.equal(this.subject.header().name(), "hello");
|
||||
assert.equal(this.subject.rowByValue(1).name(), "hello");
|
||||
assert.equal(this.subject.rowByValue(2).name(), "world");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -48,18 +33,8 @@ componentTest("with valueAttribute", {
|
|||
async test(assert) {
|
||||
await this.subject.expand();
|
||||
|
||||
assert.equal(
|
||||
this.subject
|
||||
.rowByValue(0)
|
||||
.name(),
|
||||
"hello"
|
||||
);
|
||||
assert.equal(
|
||||
this.subject
|
||||
.rowByValue(1)
|
||||
.name(),
|
||||
"world"
|
||||
);
|
||||
assert.equal(this.subject.rowByValue(0).name(), "hello");
|
||||
assert.equal(this.subject.rowByValue(1).name(), "world");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -72,18 +47,8 @@ componentTest("with nameProperty", {
|
|||
async test(assert) {
|
||||
await this.subject.expand();
|
||||
|
||||
assert.equal(
|
||||
this.subject
|
||||
.rowByValue(0)
|
||||
.name(),
|
||||
"hello"
|
||||
);
|
||||
assert.equal(
|
||||
this.subject
|
||||
.rowByValue(1)
|
||||
.name(),
|
||||
"world"
|
||||
);
|
||||
assert.equal(this.subject.rowByValue(0).name(), "hello");
|
||||
assert.equal(this.subject.rowByValue(1).name(), "world");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -96,18 +61,8 @@ componentTest("with an array as content", {
|
|||
async test(assert) {
|
||||
await this.subject.expand();
|
||||
|
||||
assert.equal(
|
||||
this.subject
|
||||
.rowByValue("evil")
|
||||
.name(),
|
||||
"evil"
|
||||
);
|
||||
assert.equal(
|
||||
this.subject
|
||||
.rowByValue("trout")
|
||||
.name(),
|
||||
"trout"
|
||||
);
|
||||
assert.equal(this.subject.rowByValue("evil").name(), "evil");
|
||||
assert.equal(this.subject.rowByValue("trout").name(), "trout");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -122,30 +77,10 @@ componentTest("with value and none as a string", {
|
|||
async test(assert) {
|
||||
await this.subject.expand();
|
||||
|
||||
assert.equal(
|
||||
this.subject
|
||||
.noneRow()
|
||||
.name(),
|
||||
"none"
|
||||
);
|
||||
assert.equal(
|
||||
this.subject
|
||||
.rowByValue("evil")
|
||||
.name(),
|
||||
"evil"
|
||||
);
|
||||
assert.equal(
|
||||
this.subject
|
||||
.rowByValue("trout")
|
||||
.name(),
|
||||
"trout"
|
||||
);
|
||||
assert.equal(
|
||||
this.subject
|
||||
.header()
|
||||
.name(),
|
||||
"trout"
|
||||
);
|
||||
assert.equal(this.subject.noneRow().name(), "none");
|
||||
assert.equal(this.subject.rowByValue("evil").name(), "evil");
|
||||
assert.equal(this.subject.rowByValue("trout").name(), "trout");
|
||||
assert.equal(this.subject.header().name(), "trout");
|
||||
assert.equal(this.value, "trout");
|
||||
|
||||
await this.subject.selectNoneRow();
|
||||
|
@ -165,30 +100,10 @@ componentTest("with value and none as an object", {
|
|||
async test(assert) {
|
||||
await this.subject.expand();
|
||||
|
||||
assert.equal(
|
||||
this.subject
|
||||
.noneRow()
|
||||
.name(),
|
||||
"none"
|
||||
);
|
||||
assert.equal(
|
||||
this.subject
|
||||
.rowByValue("evil")
|
||||
.name(),
|
||||
"evil"
|
||||
);
|
||||
assert.equal(
|
||||
this.subject
|
||||
.rowByValue("trout")
|
||||
.name(),
|
||||
"trout"
|
||||
);
|
||||
assert.equal(
|
||||
this.subject
|
||||
.header()
|
||||
.name(),
|
||||
"evil"
|
||||
);
|
||||
assert.equal(this.subject.noneRow().name(), "none");
|
||||
assert.equal(this.subject.rowByValue("evil").name(), "evil");
|
||||
assert.equal(this.subject.rowByValue("trout").name(), "trout");
|
||||
assert.equal(this.subject.header().name(), "evil");
|
||||
assert.equal(this.value, "evil");
|
||||
|
||||
await this.subject.selectNoneRow();
|
||||
|
@ -209,12 +124,7 @@ componentTest("with no value and none as an object", {
|
|||
async test(assert) {
|
||||
await this.subject.expand();
|
||||
|
||||
assert.equal(
|
||||
this.subject
|
||||
.header()
|
||||
.name(),
|
||||
"none"
|
||||
);
|
||||
assert.equal(this.subject.header().name(), "none");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -230,12 +140,7 @@ componentTest("with no value and none string", {
|
|||
async test(assert) {
|
||||
await this.subject.expand();
|
||||
|
||||
assert.equal(
|
||||
this.subject
|
||||
.header()
|
||||
.name(),
|
||||
"none"
|
||||
);
|
||||
assert.equal(this.subject.header().name(), "none");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -250,9 +155,7 @@ componentTest("with no value and no none", {
|
|||
await this.subject.expand();
|
||||
|
||||
assert.equal(
|
||||
this.subject
|
||||
.header()
|
||||
.name(),
|
||||
this.subject.header().name(),
|
||||
"evil",
|
||||
"it sets the first row as value"
|
||||
);
|
||||
|
@ -270,9 +173,7 @@ componentTest("with empty string as value", {
|
|||
await this.subject.expand();
|
||||
|
||||
assert.equal(
|
||||
this.subject
|
||||
.header()
|
||||
.name(),
|
||||
this.subject.header().name(),
|
||||
"evil",
|
||||
"it sets the first row as value"
|
||||
);
|
||||
|
@ -292,9 +193,7 @@ componentTest("with noneLabel", {
|
|||
await this.subject.expand();
|
||||
|
||||
assert.equal(
|
||||
this.subject
|
||||
.header()
|
||||
.name(),
|
||||
this.subject.header().name(),
|
||||
"none",
|
||||
"it displays noneLabel as the header name"
|
||||
);
|
||||
|
|
|
@ -248,10 +248,7 @@ testCase("link modal (link with description)", async function(assert) {
|
|||
await fillIn(".insert-link input.link-text", "evil trout");
|
||||
await click(".insert-link button.btn-primary");
|
||||
assert.equal(find(".insert-link.hidden").length, 1);
|
||||
assert.equal(
|
||||
this.value,
|
||||
"hello world.[evil trout](http://eviltrout.com)"
|
||||
);
|
||||
assert.equal(this.value, "hello world.[evil trout](http://eviltrout.com)");
|
||||
});
|
||||
|
||||
componentTest("advanced code", {
|
||||
|
@ -347,10 +344,7 @@ third line`
|
|||
textarea.selectionEnd = 10;
|
||||
|
||||
await click("button.code");
|
||||
assert.equal(
|
||||
this.value,
|
||||
"first `line`\n\nsecond line\n\nthird line"
|
||||
);
|
||||
assert.equal(this.value, "first `line`\n\nsecond line\n\nthird line");
|
||||
assert.equal(textarea.selectionStart, 7);
|
||||
assert.equal(textarea.selectionEnd, 11);
|
||||
|
||||
|
@ -363,10 +357,7 @@ third line`
|
|||
textarea.selectionEnd = 23;
|
||||
|
||||
await click("button.code");
|
||||
assert.equal(
|
||||
this.value,
|
||||
" first line\n\n second line\n\nthird line"
|
||||
);
|
||||
assert.equal(this.value, " first line\n\n second line\n\nthird line");
|
||||
assert.equal(textarea.selectionStart, 0);
|
||||
assert.equal(textarea.selectionEnd, 31);
|
||||
|
||||
|
|
|
@ -43,17 +43,13 @@ componentTest("default", {
|
|||
await this.subject.expand();
|
||||
|
||||
assert.equal(
|
||||
this.subject
|
||||
.rowByIndex(0)
|
||||
.name(),
|
||||
this.subject.rowByIndex(0).name(),
|
||||
"bianca",
|
||||
"it has the correct tag"
|
||||
);
|
||||
|
||||
assert.equal(
|
||||
this.subject
|
||||
.rowByIndex(1)
|
||||
.name(),
|
||||
this.subject.rowByIndex(1).name(),
|
||||
"régis",
|
||||
"it has the correct tag"
|
||||
);
|
||||
|
|
|
@ -18,12 +18,7 @@ componentTest("with objects and values", {
|
|||
},
|
||||
|
||||
test(assert) {
|
||||
assert.equal(
|
||||
this.subject
|
||||
.header()
|
||||
.value(),
|
||||
"1,2"
|
||||
);
|
||||
assert.equal(this.subject.header().value(), "1,2");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -61,24 +56,16 @@ componentTest("interactions", {
|
|||
await this.subject.expand();
|
||||
|
||||
assert.equal(
|
||||
this.subject
|
||||
.highlightedRow()
|
||||
.name(),
|
||||
this.subject.highlightedRow().name(),
|
||||
"robin",
|
||||
"it highlights the first content row"
|
||||
);
|
||||
|
||||
await this.set("none", "test.none");
|
||||
|
||||
assert.ok(
|
||||
this.subject
|
||||
.noneRow()
|
||||
.exists()
|
||||
);
|
||||
assert.ok(this.subject.noneRow().exists());
|
||||
assert.equal(
|
||||
this.subject
|
||||
.highlightedRow()
|
||||
.name(),
|
||||
this.subject.highlightedRow().name(),
|
||||
"robin",
|
||||
"it highlights the first content row"
|
||||
);
|
||||
|
@ -87,9 +74,7 @@ componentTest("interactions", {
|
|||
await this.subject.expand();
|
||||
|
||||
assert.equal(
|
||||
this.subject
|
||||
.highlightedRow()
|
||||
.name(),
|
||||
this.subject.highlightedRow().name(),
|
||||
"none",
|
||||
"it highlights none row if no content"
|
||||
);
|
||||
|
@ -97,9 +82,7 @@ componentTest("interactions", {
|
|||
await this.subject.fillInFilter("joffrey");
|
||||
|
||||
assert.equal(
|
||||
this.subject
|
||||
.highlightedRow()
|
||||
.name(),
|
||||
this.subject.highlightedRow().name(),
|
||||
"joffrey",
|
||||
"it highlights create row when filling filter"
|
||||
);
|
||||
|
@ -107,9 +90,7 @@ componentTest("interactions", {
|
|||
await this.subject.keyboard("enter");
|
||||
|
||||
assert.equal(
|
||||
this.subject
|
||||
.highlightedRow()
|
||||
.name(),
|
||||
this.subject.highlightedRow().name(),
|
||||
"none",
|
||||
"it highlights none row after creating content and no content left"
|
||||
);
|
||||
|
@ -140,9 +121,7 @@ componentTest("interactions", {
|
|||
"it removes the previous highlighted selected content"
|
||||
);
|
||||
assert.notOk(
|
||||
this.subject
|
||||
.rowByValue("joffrey")
|
||||
.exists(),
|
||||
this.subject.rowByValue("joffrey").exists(),
|
||||
"generated content shouldn’t appear in content when removed"
|
||||
);
|
||||
|
||||
|
@ -191,12 +170,7 @@ componentTest("with limitMatches", {
|
|||
async test(assert) {
|
||||
await this.subject.expand();
|
||||
|
||||
assert.equal(
|
||||
this.subject
|
||||
.el()
|
||||
.find(".select-kit-row").length,
|
||||
2
|
||||
);
|
||||
assert.equal(this.subject.el().find(".select-kit-row").length, 2);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -210,19 +184,11 @@ componentTest("with minimum", {
|
|||
async test(assert) {
|
||||
await this.subject.expand();
|
||||
|
||||
assert.equal(
|
||||
this.subject.validationMessage(),
|
||||
"Select at least 1 item."
|
||||
);
|
||||
assert.equal(this.subject.validationMessage(), "Select at least 1 item.");
|
||||
|
||||
await this.subject.selectRowByValue("sam");
|
||||
|
||||
assert.equal(
|
||||
this.subject
|
||||
.header()
|
||||
.label(),
|
||||
"sam"
|
||||
);
|
||||
assert.equal(this.subject.header().label(), "sam");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -242,12 +208,7 @@ componentTest("with minimumLabel", {
|
|||
|
||||
await this.subject.selectRowByValue("jeff");
|
||||
|
||||
assert.equal(
|
||||
this.subject
|
||||
.header()
|
||||
.label(),
|
||||
"jeff"
|
||||
);
|
||||
assert.equal(this.subject.header().label(), "jeff");
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -27,20 +27,10 @@ componentTest("updating the content refreshes the list", {
|
|||
},
|
||||
|
||||
async test(assert) {
|
||||
assert.equal(
|
||||
this.subject
|
||||
.header()
|
||||
.name(),
|
||||
"pinned"
|
||||
);
|
||||
assert.equal(this.subject.header().name(), "pinned");
|
||||
|
||||
await this.set("pinned", false);
|
||||
|
||||
assert.equal(
|
||||
this.subject
|
||||
.header()
|
||||
.name(),
|
||||
"unpinned"
|
||||
);
|
||||
assert.equal(this.subject.header().name(), "unpinned");
|
||||
}
|
||||
});
|
||||
|
|
|
@ -19,21 +19,11 @@ componentTest("updating the content refreshes the list", {
|
|||
async test(assert) {
|
||||
await this.subject.expand();
|
||||
|
||||
assert.equal(
|
||||
this.subject
|
||||
.rowByValue(1)
|
||||
.name(),
|
||||
"BEFORE"
|
||||
);
|
||||
assert.equal(this.subject.rowByValue(1).name(), "BEFORE");
|
||||
|
||||
await this.set("content", [{ id: 1, name: "AFTER" }]);
|
||||
|
||||
assert.equal(
|
||||
this.subject
|
||||
.rowByValue(1)
|
||||
.name(),
|
||||
"AFTER"
|
||||
);
|
||||
assert.equal(this.subject.rowByValue(1).name(), "AFTER");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -49,9 +39,7 @@ componentTest("accepts a value by reference", {
|
|||
await this.subject.expand();
|
||||
|
||||
assert.equal(
|
||||
this.subject
|
||||
.selectedRow()
|
||||
.name(),
|
||||
this.subject.selectedRow().name(),
|
||||
"robin",
|
||||
"it highlights the row corresponding to the value"
|
||||
);
|
||||
|
@ -67,9 +55,7 @@ componentTest("no default icon", {
|
|||
|
||||
test(assert) {
|
||||
assert.equal(
|
||||
this.subject
|
||||
.header()
|
||||
.icon().length,
|
||||
this.subject.header().icon().length,
|
||||
0,
|
||||
"it doesn’t have an icon if not specified"
|
||||
);
|
||||
|
@ -82,14 +68,7 @@ componentTest("default search icon", {
|
|||
async test(assert) {
|
||||
await this.subject.expand();
|
||||
|
||||
assert.ok(
|
||||
exists(
|
||||
this.subject
|
||||
.filter()
|
||||
.icon()
|
||||
),
|
||||
"it has an icon"
|
||||
);
|
||||
assert.ok(exists(this.subject.filter().icon()), "it has an icon");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -99,14 +78,7 @@ componentTest("with no search icon", {
|
|||
async test(assert) {
|
||||
await this.subject.expand();
|
||||
|
||||
assert.notOk(
|
||||
exists(
|
||||
this.subject
|
||||
.filter()
|
||||
.icon()
|
||||
),
|
||||
"it has no icon"
|
||||
);
|
||||
assert.notOk(exists(this.subject.filter().icon()), "it has no icon");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -151,12 +123,7 @@ componentTest("accepts custom value/name keys", {
|
|||
async test(assert) {
|
||||
await this.subject.expand();
|
||||
|
||||
assert.equal(
|
||||
this.subject
|
||||
.selectedRow()
|
||||
.name(),
|
||||
"robin"
|
||||
);
|
||||
assert.equal(this.subject.selectedRow().name(), "robin");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -186,19 +153,12 @@ componentTest("dynamic headerText", {
|
|||
async test(assert) {
|
||||
await this.subject.expand();
|
||||
|
||||
assert.equal(
|
||||
this.subject
|
||||
.header()
|
||||
.name(),
|
||||
"robin"
|
||||
);
|
||||
assert.equal(this.subject.header().name(), "robin");
|
||||
|
||||
await this.subject.selectRowByValue(2);
|
||||
|
||||
assert.equal(
|
||||
this.subject
|
||||
.header()
|
||||
.name(),
|
||||
this.subject.header().name(),
|
||||
"regis",
|
||||
"it changes header text"
|
||||
);
|
||||
|
@ -243,19 +203,12 @@ componentTest("supports converting select value to integer", {
|
|||
async test(assert) {
|
||||
await this.subject.expand();
|
||||
|
||||
assert.equal(
|
||||
this.subject
|
||||
.selectedRow()
|
||||
.name(),
|
||||
"régis"
|
||||
);
|
||||
assert.equal(this.subject.selectedRow().name(), "régis");
|
||||
|
||||
await this.set("value", 1);
|
||||
|
||||
assert.equal(
|
||||
this.subject
|
||||
.selectedRow()
|
||||
.name(),
|
||||
this.subject.selectedRow().name(),
|
||||
"robin",
|
||||
"it works with dynamic content"
|
||||
);
|
||||
|
@ -276,19 +229,12 @@ componentTest("supports converting string as boolean to boolean", {
|
|||
async test(assert) {
|
||||
await this.subject.expand();
|
||||
|
||||
assert.equal(
|
||||
this.subject
|
||||
.selectedRow()
|
||||
.name(),
|
||||
"ASC"
|
||||
);
|
||||
assert.equal(this.subject.selectedRow().name(), "ASC");
|
||||
|
||||
await this.set("value", false);
|
||||
|
||||
assert.equal(
|
||||
this.subject
|
||||
.selectedRow()
|
||||
.name(),
|
||||
this.subject.selectedRow().name(),
|
||||
"DESC",
|
||||
"it works with dynamic content"
|
||||
);
|
||||
|
@ -308,9 +254,7 @@ componentTest("supports keyboard events", {
|
|||
await this.subject.keyboard("down");
|
||||
|
||||
assert.equal(
|
||||
this.subject
|
||||
.highlightedRow()
|
||||
.title(),
|
||||
this.subject.highlightedRow().title(),
|
||||
"regis",
|
||||
"the next row is highlighted"
|
||||
);
|
||||
|
@ -318,9 +262,7 @@ componentTest("supports keyboard events", {
|
|||
await this.subject.keyboard("down");
|
||||
|
||||
assert.equal(
|
||||
this.subject
|
||||
.highlightedRow()
|
||||
.title(),
|
||||
this.subject.highlightedRow().title(),
|
||||
"robin",
|
||||
"it returns to the first row"
|
||||
);
|
||||
|
@ -328,9 +270,7 @@ componentTest("supports keyboard events", {
|
|||
await this.subject.keyboard("up");
|
||||
|
||||
assert.equal(
|
||||
this.subject
|
||||
.highlightedRow()
|
||||
.title(),
|
||||
this.subject.highlightedRow().title(),
|
||||
"regis",
|
||||
"it highlights the last row"
|
||||
);
|
||||
|
@ -338,9 +278,7 @@ componentTest("supports keyboard events", {
|
|||
await this.subject.keyboard("enter");
|
||||
|
||||
assert.equal(
|
||||
this.subject
|
||||
.selectedRow()
|
||||
.title(),
|
||||
this.subject.selectedRow().title(),
|
||||
"regis",
|
||||
"it selects the row when pressing enter"
|
||||
);
|
||||
|
@ -352,10 +290,7 @@ componentTest("supports keyboard events", {
|
|||
await this.subject.expand();
|
||||
await this.subject.keyboard("escape");
|
||||
|
||||
assert.notOk(
|
||||
this.subject.isExpanded(),
|
||||
"it collapses the select box"
|
||||
);
|
||||
assert.notOk(this.subject.isExpanded(), "it collapses the select box");
|
||||
|
||||
await this.subject.expand();
|
||||
await this.subject.fillInFilter("regis");
|
||||
|
@ -381,11 +316,7 @@ componentTest("with allowInitialValueMutation", {
|
|||
},
|
||||
|
||||
test(assert) {
|
||||
assert.equal(
|
||||
this.value,
|
||||
"1",
|
||||
"it mutates the value on initial rendering"
|
||||
);
|
||||
assert.equal(this.value, "1", "it mutates the value on initial rendering");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -405,12 +336,7 @@ componentTest("support appending content through plugin api", {
|
|||
await this.subject.expand();
|
||||
|
||||
assert.equal(this.subject.rows().length, 2);
|
||||
assert.equal(
|
||||
this.subject
|
||||
.rowByIndex(1)
|
||||
.name(),
|
||||
"regis"
|
||||
);
|
||||
assert.equal(this.subject.rowByIndex(1).name(), "regis");
|
||||
|
||||
clearCallbacks();
|
||||
}
|
||||
|
@ -439,12 +365,7 @@ componentTest("support modifying content through plugin api", {
|
|||
await this.subject.expand();
|
||||
|
||||
assert.equal(this.subject.rows().length, 3);
|
||||
assert.equal(
|
||||
this.subject
|
||||
.rowByIndex(1)
|
||||
.name(),
|
||||
"sam"
|
||||
);
|
||||
assert.equal(this.subject.rowByIndex(1).name(), "sam");
|
||||
|
||||
clearCallbacks();
|
||||
}
|
||||
|
@ -467,12 +388,7 @@ componentTest("support prepending content through plugin api", {
|
|||
await this.subject.expand();
|
||||
|
||||
assert.equal(this.subject.rows().length, 2);
|
||||
assert.equal(
|
||||
this.subject
|
||||
.rowByIndex(0)
|
||||
.name(),
|
||||
"regis"
|
||||
);
|
||||
assert.equal(this.subject.rowByIndex(0).name(), "regis");
|
||||
|
||||
clearCallbacks();
|
||||
}
|
||||
|
@ -551,21 +467,11 @@ componentTest("with nameChanges", {
|
|||
async test(assert) {
|
||||
await this.subject.expand();
|
||||
|
||||
assert.equal(
|
||||
this.subject
|
||||
.header()
|
||||
.name(),
|
||||
"robin"
|
||||
);
|
||||
assert.equal(this.subject.header().name(), "robin");
|
||||
|
||||
await this.set("robin.name", "robin2");
|
||||
|
||||
assert.equal(
|
||||
this.subject
|
||||
.header()
|
||||
.name(),
|
||||
"robin2"
|
||||
);
|
||||
assert.equal(this.subject.header().name(), "robin2");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -579,18 +485,8 @@ componentTest("with null value", {
|
|||
async test(assert) {
|
||||
await this.subject.expand();
|
||||
|
||||
assert.equal(
|
||||
this.subject
|
||||
.header()
|
||||
.name(),
|
||||
"robin"
|
||||
);
|
||||
assert.equal(
|
||||
this.subject
|
||||
.header()
|
||||
.value(),
|
||||
undefined
|
||||
);
|
||||
assert.equal(this.subject.header().name(), "robin");
|
||||
assert.equal(this.subject.header().value(), undefined);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -616,12 +512,7 @@ componentTest("with title", {
|
|||
},
|
||||
|
||||
test(assert) {
|
||||
assert.equal(
|
||||
this.subject
|
||||
.header()
|
||||
.title(),
|
||||
"My title"
|
||||
);
|
||||
assert.equal(this.subject.header().title(), "My title");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -642,12 +533,7 @@ componentTest("support modifying header computed content through plugin api", {
|
|||
},
|
||||
|
||||
test(assert) {
|
||||
assert.equal(
|
||||
this.subject
|
||||
.header()
|
||||
.title(),
|
||||
"Not so evil"
|
||||
);
|
||||
assert.equal(this.subject.header().title(), "Not so evil");
|
||||
|
||||
clearCallbacks();
|
||||
}
|
||||
|
@ -663,12 +549,7 @@ componentTest("with limitMatches", {
|
|||
async test(assert) {
|
||||
await this.subject.expand();
|
||||
|
||||
assert.equal(
|
||||
this.subject
|
||||
.el()
|
||||
.find(".select-kit-row").length,
|
||||
2
|
||||
);
|
||||
assert.equal(this.subject.el().find(".select-kit-row").length, 2);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -683,19 +564,11 @@ componentTest("with minimum", {
|
|||
async test(assert) {
|
||||
await this.subject.expand();
|
||||
|
||||
assert.equal(
|
||||
this.subject.validationMessage(),
|
||||
"Select at least 1 item."
|
||||
);
|
||||
assert.equal(this.subject.validationMessage(), "Select at least 1 item.");
|
||||
|
||||
await this.subject.selectRowByValue("sam");
|
||||
|
||||
assert.equal(
|
||||
this.subject
|
||||
.header()
|
||||
.label(),
|
||||
"sam"
|
||||
);
|
||||
assert.equal(this.subject.header().label(), "sam");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -715,12 +588,7 @@ componentTest("with minimumLabel", {
|
|||
|
||||
await this.subject.selectRowByValue("jeff");
|
||||
|
||||
assert.equal(
|
||||
this.subject
|
||||
.header()
|
||||
.label(),
|
||||
"jeff"
|
||||
);
|
||||
assert.equal(this.subject.header().label(), "jeff");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -736,12 +604,7 @@ componentTest("with accents in filter", {
|
|||
await this.subject.fillInFilter("jéff");
|
||||
|
||||
assert.equal(this.subject.rows().length, 1);
|
||||
assert.equal(
|
||||
this.subject
|
||||
.rowByIndex(0)
|
||||
.name(),
|
||||
"jeff"
|
||||
);
|
||||
assert.equal(this.subject.rowByIndex(0).name(), "jeff");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -757,12 +620,7 @@ componentTest("with accents in content", {
|
|||
await this.subject.fillInFilter("jeff");
|
||||
|
||||
assert.equal(this.subject.rows().length, 1);
|
||||
assert.equal(
|
||||
this.subject
|
||||
.rowByIndex(0)
|
||||
.name(),
|
||||
"jéff"
|
||||
);
|
||||
assert.equal(this.subject.rowByIndex(0).name(), "jéff");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -771,15 +629,9 @@ componentTest("with no content and allowAny", {
|
|||
|
||||
skip: true,
|
||||
async test(assert) {
|
||||
await click(
|
||||
this.subject
|
||||
.header()
|
||||
.el()
|
||||
);
|
||||
await click(this.subject.header().el());
|
||||
|
||||
const $filter = this.subject
|
||||
.filter()
|
||||
.el();
|
||||
const $filter = this.subject.filter().el();
|
||||
|
||||
assert.ok($filter.hasClass("is-focused"));
|
||||
assert.ok(!$filter.hasClass("is-hidden"));
|
||||
|
|
|
@ -41,35 +41,27 @@ componentTest("default", {
|
|||
await this.subject.expand();
|
||||
|
||||
assert.equal(
|
||||
this.subject
|
||||
.rowByIndex(1)
|
||||
.name(),
|
||||
this.subject.rowByIndex(1).name(),
|
||||
"jeff",
|
||||
"it has the correct tag"
|
||||
);
|
||||
|
||||
assert.equal(
|
||||
this.subject
|
||||
.rowByIndex(2)
|
||||
.name(),
|
||||
this.subject.rowByIndex(2).name(),
|
||||
"neil",
|
||||
"it has the correct tag"
|
||||
);
|
||||
|
||||
await this.subject.fillInFilter("rég");
|
||||
assert.equal(
|
||||
this.subject
|
||||
.rowByIndex(0)
|
||||
.name(),
|
||||
this.subject.rowByIndex(0).name(),
|
||||
"régis",
|
||||
"it displays the searched tag"
|
||||
);
|
||||
|
||||
await this.subject.fillInFilter("");
|
||||
assert.equal(
|
||||
this.subject
|
||||
.rowByIndex(1)
|
||||
.name(),
|
||||
this.subject.rowByIndex(1).name(),
|
||||
"jeff",
|
||||
"it returns top tags for an empty search"
|
||||
);
|
||||
|
@ -96,9 +88,7 @@ componentTest("no tags", {
|
|||
await this.subject.expand();
|
||||
|
||||
assert.equal(
|
||||
this.subject
|
||||
.rowByIndex(1)
|
||||
.name(),
|
||||
this.subject.rowByIndex(1).name(),
|
||||
undefined,
|
||||
"it has no tags and doesn’t crash"
|
||||
);
|
||||
|
|
|
@ -24,22 +24,10 @@ componentTest("default", {
|
|||
async test(assert) {
|
||||
await this.subject.expand();
|
||||
|
||||
assert.equal(
|
||||
this.subject
|
||||
.header()
|
||||
.title(),
|
||||
"Topic Controls"
|
||||
);
|
||||
assert.equal(
|
||||
this.subject
|
||||
.header()
|
||||
.value(),
|
||||
null
|
||||
);
|
||||
assert.equal(this.subject.header().title(), "Topic Controls");
|
||||
assert.equal(this.subject.header().value(), null);
|
||||
assert.notOk(
|
||||
this.subject
|
||||
.selectedRow()
|
||||
.exists(),
|
||||
this.subject.selectedRow().exists(),
|
||||
"it doesn’t preselect first row"
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user