UX: Use '-' as default category slug (#8607)

This replaces the default slug from 'ID-category' to '-'.
This commit is contained in:
Dan Ungureanu 2020-01-23 16:44:29 +02:00 committed by Régis Hanol
parent 4f677854d3
commit 6279d0e8b5
2 changed files with 8 additions and 12 deletions

View File

@ -266,12 +266,8 @@ Category.reopenClass({
result = Category.slugFor(parentCategory) + separator;
}
const id = get(category, "id"),
slug = get(category, "slug");
return !slug || slug.trim().length === 0
? `${result}${id}-category`
: result + slug;
const slug = get(category, "slug");
return !slug || slug.trim().length === 0 ? `${result}-` : result + slug;
},
list() {

View File

@ -17,13 +17,13 @@ QUnit.test("slugFor", assert => {
);
slugFor(
store.createRecord("category", { id: 123, slug: "" }),
"123-category",
"It returns id-category for empty strings"
"-",
"It returns - for empty slugs"
);
slugFor(
store.createRecord("category", { id: 456 }),
"456-category",
"It returns id-category for undefined slugs"
"-",
"It returns - for undefined slugs"
);
slugFor(
store.createRecord("category", { slug: "熱帶風暴畫眉" }),
@ -46,14 +46,14 @@ QUnit.test("slugFor", assert => {
slugFor(
store.createRecord("category", { id: 555, parentCategory: parentCategory }),
"darth/555-category",
"darth/-",
"it uses the parent slug before the child and then uses id"
);
parentCategory.set("slug", null);
slugFor(
store.createRecord("category", { id: 555, parentCategory: parentCategory }),
"345-category/555-category",
"-/-",
"it uses the parent before the child and uses ids for both"
);
});