128 lines
4.0 KiB
JavaScript
128 lines
4.0 KiB
JavaScript
import { mapState } from "pinia";
|
|
|
|
export const link_types = [
|
|
{ id: 1, label: "تصویر" },
|
|
{ id: 2, label: "فایل" },
|
|
{ id: 3, label: "آپارات" },
|
|
{ id: 4, label: "سایر" },
|
|
];
|
|
export const all_statuses = [
|
|
{ id: 0, label: "مشخص نشده" },
|
|
{ id: 1, label: "نیازمند تکمیل" },
|
|
{ id: 2, label: "نیازمند تناسب سنجی" },
|
|
{ id: 3, label: "تکمیل اولیه" },
|
|
{ id: 4, label: "در مرحله داوری" },
|
|
{ id: 5, label: "منتظر تایید" },
|
|
{ id: 6, label: "تایید" },
|
|
];
|
|
export const commonMixin = {
|
|
computed: {
|
|
...mapState(useCommonStore, ["mediaAssetsUrl","userPermisionGetter"]),
|
|
|
|
canCreateInShowPage() {},
|
|
canDeleteInShowPage() {},
|
|
canCreateProperty() {
|
|
const permission = this.$route.meta.parent + "-properties_create";
|
|
const canCreate = this.userPermisionGetter?.includes(permission);
|
|
return canCreate;
|
|
},
|
|
updateKey() {
|
|
const permission = this.$route.name + "-properties_update";
|
|
return this.userPermisionGetter?.includes(permission);
|
|
},
|
|
canDeleteProperty() {
|
|
return this.userPermisionGetter?.includes(
|
|
this.$route.meta.parent + "-properties_delete"
|
|
);
|
|
},
|
|
},
|
|
methods: {
|
|
getStatusTitle(state_id = undefined) {
|
|
if (state_id in this.all_statuses)
|
|
return this.all_statuses[state_id].label;
|
|
else return "نامعین";
|
|
},
|
|
getEntityName(type_id) {
|
|
if (!type_id) return "نامشخص";
|
|
if (type_id == 1) return "'گفتگو'";
|
|
if (type_id == 2) return "مساله";
|
|
else if (type_id == 3) return "پاسخ";
|
|
else if (type_id == 4) return "معیار";
|
|
|
|
return "نامعین";
|
|
},
|
|
getEntityTitle(type_id) {
|
|
if (!type_id) return "نامشخص";
|
|
if (type_id == 1) return "'گفتگوهای'";
|
|
else if (type_id == 2) return "مسائل";
|
|
else if (type_id == 3) return "پاسخهای";
|
|
else if (type_id == 4) return "معیارهای";
|
|
|
|
return "نامعین";
|
|
},
|
|
getEntityKey(type_id) {
|
|
if (!type_id) return "نامشخص";
|
|
if (type_id == 1) return "'گفتگوهای'";
|
|
else if (type_id == 2) return "issue";
|
|
else if (type_id == 3) return "answer";
|
|
else if (type_id == 4) return "crition";
|
|
|
|
return "نامعین";
|
|
},
|
|
getEntityTypeId(key) {
|
|
if (key == "talk") return 1;
|
|
else if (key == "issue") return 2;
|
|
else if (key == "issues") return 2;
|
|
else if (key == "answer") return 3;
|
|
else if (key == "crition") return 4;
|
|
else if (key == "critions") return 4;
|
|
|
|
return 0;
|
|
},
|
|
getRelationTypeId(key) {
|
|
if (key == "answer") return 1;
|
|
},
|
|
relationType(relationTypeId) {
|
|
switch (parseInt(relationTypeId)) {
|
|
case 8:
|
|
return "جزئی از";
|
|
case 9:
|
|
return "هم افزا با";
|
|
case 10:
|
|
return "مغایر با";
|
|
default:
|
|
return "جزئی از";
|
|
}
|
|
},
|
|
getFilePath(file, isThumb = false) {
|
|
if (isThumb && file && file.startsWith("media/images/"))
|
|
file = file.replace("media/images/", "media/images/thumbnail/");
|
|
return this.mediaAssetsUrl + file;
|
|
},
|
|
getFileExtension(filename) {
|
|
return filename?.split(".").pop();
|
|
},
|
|
isImage(fileName) {
|
|
return ["jpg", "jpeg", "png", "webp"].includes(
|
|
this.getFileExtension(fileName)
|
|
);
|
|
},
|
|
isImageLinkType(type) {
|
|
return type == this.link_types[0].label;
|
|
},
|
|
isFileLinkType(type) {
|
|
return type == this.link_types[1].label;
|
|
},
|
|
isAparatLinkType(type) {
|
|
return type == this.link_types[2].label;
|
|
},
|
|
getAparatIframe(url) {
|
|
var html =
|
|
'<div class="h_iframe-aparat_embed_frame"><span style="display: block;%"></span><iframe src="https://www.aparat.com/video/video/embed/videohash/{{id-aparat}}/vt/frame" allowFullScreen="true" webkitallowfullscreen="true" mozallowfullscreen="true"></iframe></div>';
|
|
var id = url.split("/").pop();
|
|
html = html.replace("{{id-aparat}}", id);
|
|
return html;
|
|
},
|
|
},
|
|
};
|