Skip to content

Commit

Permalink
Fix materials links for category without layout for admin
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitrijOkeanij committed Oct 7, 2020
1 parent 6bd2ac9 commit 6c14aba
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 6 deletions.
7 changes: 5 additions & 2 deletions Client/src/admin/categories/CategoryForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -332,15 +332,18 @@ export default {
},
computed: {
layoutOptions() {
return Object.getOwnPropertyNames(this.$store.state.layouts.all)
return [{
label: this.$tl("noLayout"),
value: null
},...Object.getOwnPropertyNames(this.$store.state.layouts.all)
.filter(x => !x.startsWith("__"))
.map(x => this.$store.state.layouts.all[x])
.map(x => {
return {
label: this.$t(`LayoutNames.${x.name}`),
value: x.name
};
});
})];
},
parentCategoryTitle() {
return this?.all?.[this.category.parentId]?.title;
Expand Down
20 changes: 18 additions & 2 deletions Client/src/classes/Category.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { store } from "store";
import { extend } from "quasar";

export default class Category {
Expand All @@ -8,15 +9,30 @@ export default class Category {
get selectable() {
return this.categoryPersonalAccess?.MaterialWrite && this.isMaterialsContainer;
}

getRoute() {
return this.route ?? undefined;
}

getMaterialRoute(idOrName, hash) {
const route = this.getRoute();

if (!route || !route.name) return undefined;
if (!route || !route.name)
{
if(store.getters.isAdmin) {
return {
name: "CatView-mat",
params: {
categoryName: this.name,
idOrName: idOrName.toString(),
hash: hash ?? undefined
}
}
}
else
return undefined;

}

let rezRoute = extend(true, {}, route);

Expand Down
3 changes: 2 additions & 1 deletion Client/src/i18n/en-us/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ export default {
cachingPageCount: "Cache N pages",
noTypeLabel: "Without type",
layout: "Layout",
validation: {
noLayout: "No layout",
validation: {
name: {
required: "Enter category name (eng)",
minLength: "Name (eng) must be at least 2 letters",
Expand Down
1 change: 1 addition & 0 deletions Client/src/i18n/ru/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export default {
cachingPageCount: "Кэшировать N страниц",
noTypeLabel: "Без типа",
layout: "Шаблон",
noLayout: "Без шаблона",
validation: {
name: {
required: "Введите имя (eng) категории",
Expand Down
4 changes: 3 additions & 1 deletion Client/src/modules/articles/Article.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ export default {
return this.$store.getters.getCategory(this.article.categoryName);
},
to() {
return this.category.getMaterialRoute(this.article.name ?? this.article.id);
let rez = this.category.getMaterialRoute(this.article.name ?? this.article.id);
return rez;
}
}
};
Expand Down

0 comments on commit 6c14aba

Please sign in to comment.