commit
0913aada3b
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,71 @@
|
||||
<template>
|
||||
<v-dialog v-model="modal" :width="properties.width || '40%'" transition="slide-x-transition">
|
||||
<v-card class="RTL">
|
||||
<v-card-title class="red lighten-5" primary-title>
|
||||
<WM-PartTitle
|
||||
class="WM-Margin-T-20"
|
||||
:TitleFa="properties.name || 'عنوان'"
|
||||
:TitleEn="properties.name_en || 'title'"
|
||||
:color="properties.color || 'orange'"
|
||||
></WM-PartTitle>
|
||||
</v-card-title>
|
||||
<v-card-text>
|
||||
<div
|
||||
class="WM-Align-R WM-Margin-T-10"
|
||||
>{{ properties.description || 'پیام'}}</div>
|
||||
</v-card-text>
|
||||
|
||||
<v-divider></v-divider>
|
||||
<v-card-actions>
|
||||
<v-spacer></v-spacer>
|
||||
<v-btn
|
||||
:color="properties.color || 'orange'"
|
||||
depressed
|
||||
dark
|
||||
@click="$_closeModalStack()"
|
||||
>
|
||||
<v-icon dark right>fas fa-trash-alt</v-icon>
|
||||
متوجه شدم!
|
||||
</v-btn>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapActions, mapGetters } from "vuex";
|
||||
import axios from 'axios';
|
||||
import { url } from '@Common/mixins/urls';
|
||||
export default {
|
||||
name: "modal_modal_helper",
|
||||
data: () => ({
|
||||
properties: {}
|
||||
}),
|
||||
computed: {
|
||||
...mapGetters("modal", ["isModalStack", "getModal"]),
|
||||
modal: {
|
||||
get() {
|
||||
return this.isModalStack(this.$options.name);
|
||||
},
|
||||
set(value) {
|
||||
if (!value) {
|
||||
this.$_closeModalStack();
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
async getDate() {
|
||||
if (this.modal) {
|
||||
let response = await axios.get(url('help', {help: this.getModal(this.$options.name).slug}));
|
||||
if (response && response.status == 200) {
|
||||
this.properties = response.data.data;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getDate();
|
||||
},
|
||||
};
|
||||
</script>
|
@ -0,0 +1,9 @@
|
||||
import { getTime } from "@Global/utils/date/time";
|
||||
export default {
|
||||
setCurrentTime:({ commit }) => {
|
||||
commit('SET_CURRENT_TIME', getTime());
|
||||
setInterval(function() {
|
||||
commit('SET_CURRENT_TIME', getTime());
|
||||
}, 2000);
|
||||
},
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
export default {
|
||||
getCurrentModule: state => state.current_module,
|
||||
getCurrentModuleInfo: state => state.current_module_info,
|
||||
getCurrentTime: state => state.time_now,
|
||||
}
|
@ -1,59 +1,64 @@
|
||||
export default {
|
||||
$_openModal: ({ rootState }, modal) => {
|
||||
let modalArray = modal.split("/");
|
||||
if (modalArray.length == 2) {
|
||||
rootState[modalArray[0]]['modal'][modalArray[1]] = true;
|
||||
} else {
|
||||
rootState.modal[modalArray[0]] = true;
|
||||
}
|
||||
},
|
||||
$_closeModal: ({ state, rootState }, modal) => {
|
||||
let modalArray = modal.split("/");
|
||||
if (modalArray.length == 2) {
|
||||
rootState[modalArray[0]]['modal'][modalArray[1]] = false;
|
||||
} else {
|
||||
rootState.modal[modalArray[0]] = false;
|
||||
}
|
||||
state.properties = null;
|
||||
},
|
||||
|
||||
|
||||
$_openModalCallback ({ dispatch }, data) {
|
||||
dispatch(data.module + '/openModal' + data.type.charAt(0).toUpperCase() + data.type.slice(1), data, { root: true });
|
||||
},
|
||||
$_closeModalCallback: ({ dispatch }, data) => {
|
||||
dispatch(data.module + '/closeModal' + data.type.charAt(0).toUpperCase() + data.type.slice(1) , data, { root: true });
|
||||
},
|
||||
|
||||
|
||||
$_openModalStack({ state, rootState }, data) { // data: {name, rel, model, form_data, data, modal_pop_data, type}
|
||||
data.name = 'modal_' + data.name;
|
||||
if (state.modals.findIndex(x => x.name == data.name) == -1) {
|
||||
state.modals.push(data);
|
||||
let module = data.name.split("_");
|
||||
|
||||
rootState[module[1]].relation = data.rel ? data.rel : {};
|
||||
rootState[module[1]].current_model = data.model ? data.model : {};
|
||||
if (data.rel) {
|
||||
rootState[module[1]].relation = data.rel
|
||||
state.rel.push(data.rel);
|
||||
}
|
||||
if (data.model) {
|
||||
rootState[module[1]].current_model = data.model;
|
||||
state.model.push(data.model);
|
||||
}
|
||||
rootState[module[1]].page_type = data.page_type ? data.page_type : 'modal';
|
||||
}
|
||||
},
|
||||
$_closeModalStack({ state, rootState }) {
|
||||
if (state.modals.length) {
|
||||
let last_data = [...state.modals].pop();
|
||||
let module = last_data.name.split("_")[1];
|
||||
|
||||
if (state.modals.length > 1) {
|
||||
state.modals[state.modals.length - 2]['last_modal_data'] = last_data;
|
||||
} else {
|
||||
rootState[module].page_type = '';
|
||||
}
|
||||
|
||||
if(last_data.rel) {
|
||||
state.rel.pop();
|
||||
if (state.rel.length) {
|
||||
rootState[module].relation = state.rel[state.rel.length - 1];
|
||||
} else {
|
||||
rootState[module].relation = {};
|
||||
}
|
||||
}
|
||||
if(last_data.model) {
|
||||
state.model.pop();
|
||||
if (state.model.length) {
|
||||
rootState[module].current_model = state.model[state.model.length - 1];
|
||||
} else {
|
||||
rootState[module].current_model = {};
|
||||
}
|
||||
}
|
||||
let module = last_data.name.split("_");
|
||||
rootState[module[1]].relation = {};
|
||||
rootState[module[1]].current_model = {};
|
||||
rootState[module[1]].page_type = '';
|
||||
state.modals.pop();
|
||||
}
|
||||
},
|
||||
|
||||
$_dialog:({state, commit}, properties) => {
|
||||
state.modal.dialog = true;
|
||||
$_dialog:({commit, dispatch}, properties) => {
|
||||
properties['name'] = 'modal_dialog';
|
||||
dispatch('$_openModalStack', properties);
|
||||
|
||||
commit('SET_DIALOG_TYPE', properties.type);
|
||||
commit('SET_DIALOG_PROPERTIES', properties);
|
||||
},
|
||||
|
||||
$_helper:({dispatch}, slug) => {
|
||||
let data = {};
|
||||
data['name'] = 'modal_helper';
|
||||
data['slug'] = slug;
|
||||
dispatch('$_openModalStack', data);
|
||||
},
|
||||
};
|
||||
|
@ -0,0 +1,16 @@
|
||||
|
||||
const formatToYMD = function (date = null, split = "-" ) {
|
||||
if (!date) {
|
||||
date = new Date();
|
||||
}
|
||||
let month = `${date.getMonth() + 1}`;
|
||||
let day = `${date.getDate()}`;
|
||||
const year = date.getFullYear();
|
||||
|
||||
if (month.length < 2) month = `0${month}`;
|
||||
if (day.length < 2) day = `0${day}`;
|
||||
|
||||
return [year, month, day].join(split);
|
||||
}
|
||||
|
||||
export {formatToYMD};
|
@ -0,0 +1,9 @@
|
||||
import moment from "jalali-moment";
|
||||
|
||||
const convertToJalali = function (date = null, format = "jYYYY/jMM/jDD", defaultDate = 'مشخص نشده است.' ) {
|
||||
return date ? moment(date).format(format) : defaultDate ;
|
||||
}
|
||||
const convertNowToJalali = function (date = null, format = "jYYYY/jMM/jDD" ) {
|
||||
return date ? moment(date).format(format) : moment(new Date()).format(format) ;
|
||||
}
|
||||
export { convertToJalali, convertNowToJalali };
|
@ -0,0 +1,14 @@
|
||||
const getTime = (date = null) => {
|
||||
|
||||
date = date ? date : new Date();
|
||||
let h = addZero(date.getHours());
|
||||
let m = addZero(date.getMinutes());
|
||||
return h + ":" + m;
|
||||
};
|
||||
const addZero= (i) => {
|
||||
if (i < 10) {
|
||||
i = "0" + i;
|
||||
}
|
||||
return i;
|
||||
};
|
||||
export { getTime };
|
Loading…
Reference in new issue