mirror of
https://github.com/discourse/discourse.git
synced 2024-11-29 08:53:44 +08:00
FIX: Allow for cateogry edit routes of unknown depth (#11426)
* FIX: Allow for cateogry edit routes of unknown depth * DEV: remove unused files
This commit is contained in:
parent
59ef48c0b9
commit
4c118e4d7a
|
@ -490,12 +490,6 @@ Category.reopenClass({
|
||||||
return ajax(`/c/${id}/show.json`);
|
return ajax(`/c/${id}/show.json`);
|
||||||
},
|
},
|
||||||
|
|
||||||
reloadBySlug(slug, parentSlug) {
|
|
||||||
return parentSlug
|
|
||||||
? ajax(`/c/${parentSlug}/${slug}/find_by_slug.json`)
|
|
||||||
: ajax(`/c/${slug}/find_by_slug.json`);
|
|
||||||
},
|
|
||||||
|
|
||||||
reloadBySlugPath(slugPath) {
|
reloadBySlugPath(slugPath) {
|
||||||
return ajax(`/c/${slugPath}/find_by_slug.json`);
|
return ajax(`/c/${slugPath}/find_by_slug.json`);
|
||||||
},
|
},
|
||||||
|
@ -507,7 +501,7 @@ Category.reopenClass({
|
||||||
this._includePermissions(result.category, store, site)
|
this._includePermissions(result.category, store, site)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return this.reloadBySlug(params.slug, params.parentSlug).then((result) =>
|
return this.reloadBySlugPath(params.slug).then((result) =>
|
||||||
this._includePermissions(result.category, store, site)
|
this._includePermissions(result.category, store, site)
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
|
@ -22,16 +22,9 @@ export default function () {
|
||||||
this.route("topicBySlugOrId", { path: "/t/:slugOrId", resetNamespace: true });
|
this.route("topicBySlugOrId", { path: "/t/:slugOrId", resetNamespace: true });
|
||||||
|
|
||||||
this.route("newCategory", { path: "/new-category" });
|
this.route("newCategory", { path: "/new-category" });
|
||||||
this.route("editCategory", { path: "/c/:slug/edit" }, function () {
|
this.route("editCategory", { path: "/c/*slug/edit" }, function () {
|
||||||
this.route("tabs", { path: "/:tab" });
|
this.route("tabs", { path: "/:tab" });
|
||||||
});
|
});
|
||||||
this.route(
|
|
||||||
"editChildCategory",
|
|
||||||
{ path: "/c/:parentSlug/:slug/edit" },
|
|
||||||
function () {
|
|
||||||
this.route("tabs", { path: "/:tab" });
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
this.route("discovery", { path: "/", resetNamespace: true }, function () {
|
this.route("discovery", { path: "/", resetNamespace: true }, function () {
|
||||||
// top
|
// top
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
import DiscourseRoute from "discourse/routes/discourse";
|
|
||||||
|
|
||||||
export default DiscourseRoute.extend({
|
|
||||||
afterModel() {
|
|
||||||
const params = this.paramsFor("editChildCategory");
|
|
||||||
this.replaceWith(`/c/${params.parentSlug}/${params.slug}/edit/general`);
|
|
||||||
},
|
|
||||||
});
|
|
|
@ -1,19 +0,0 @@
|
||||||
import DiscourseRoute from "discourse/routes/discourse";
|
|
||||||
|
|
||||||
export default DiscourseRoute.extend({
|
|
||||||
model() {
|
|
||||||
return this.modelFor("editChildCategory");
|
|
||||||
},
|
|
||||||
|
|
||||||
renderTemplate() {
|
|
||||||
this.render("edit-category-tabs", {
|
|
||||||
controller: "edit-category-tabs",
|
|
||||||
model: this.currentModel,
|
|
||||||
});
|
|
||||||
|
|
||||||
this.controllerFor("editCategory.tabs").set(
|
|
||||||
"parentParams",
|
|
||||||
this.paramsFor("editChildCategory")
|
|
||||||
);
|
|
||||||
},
|
|
||||||
});
|
|
|
@ -1,19 +0,0 @@
|
||||||
import Category from "discourse/models/category";
|
|
||||||
import DiscourseRoute from "discourse/routes/discourse";
|
|
||||||
import I18n from "I18n";
|
|
||||||
|
|
||||||
export default DiscourseRoute.extend({
|
|
||||||
model(params) {
|
|
||||||
return Category.reloadCategoryWithPermissions(
|
|
||||||
params,
|
|
||||||
this.store,
|
|
||||||
this.site
|
|
||||||
);
|
|
||||||
},
|
|
||||||
|
|
||||||
titleToken() {
|
|
||||||
return I18n.t("category.edit_dialog_title", {
|
|
||||||
categoryName: this.currentModel.name,
|
|
||||||
});
|
|
||||||
},
|
|
||||||
});
|
|
|
@ -204,7 +204,7 @@ class CategoriesController < ApplicationController
|
||||||
|
|
||||||
def find_by_slug
|
def find_by_slug
|
||||||
params.require(:category_slug)
|
params.require(:category_slug)
|
||||||
@category = Category.find_by_slug(params[:category_slug], params[:parent_category_slug])
|
@category = Category.find_by_slug_path(params[:category_slug].split('/'))
|
||||||
|
|
||||||
raise Discourse::NotFound unless @category.present?
|
raise Discourse::NotFound unless @category.present?
|
||||||
|
|
||||||
|
|
|
@ -681,10 +681,8 @@ Discourse::Application.routes.draw do
|
||||||
|
|
||||||
get "c/:id/show" => "categories#show"
|
get "c/:id/show" => "categories#show"
|
||||||
|
|
||||||
get "c/:category_slug/find_by_slug" => "categories#find_by_slug"
|
get "c/*category_slug/find_by_slug" => "categories#find_by_slug"
|
||||||
get "c/:parent_category_slug/:category_slug/find_by_slug" => "categories#find_by_slug"
|
get "c/*category_slug/edit(/:tab)" => "categories#find_by_slug", constraints: { format: 'html' }
|
||||||
get "c/:category_slug/edit(/:tab)" => "categories#find_by_slug", constraints: { format: 'html' }
|
|
||||||
get "c/:parent_category_slug/:category_slug/edit(/:tab)" => "categories#find_by_slug", constraints: { format: 'html' }
|
|
||||||
get "/new-category" => "categories#show", constraints: { format: 'html' }
|
get "/new-category" => "categories#show", constraints: { format: 'html' }
|
||||||
|
|
||||||
get "c/*category_slug_path_with_id.rss" => "list#category_feed", format: :rss
|
get "c/*category_slug_path_with_id.rss" => "list#category_feed", format: :rss
|
||||||
|
|
Loading…
Reference in New Issue
Block a user