feat: confirmation

This commit is contained in:
saji_kk
2024-09-05 17:02:23 +03:30
parent c11ae8a447
commit 21c3410e25
6 changed files with 176 additions and 188 deletions
@@ -0,0 +1,40 @@
<template>
<v-form>
<v-container grid-list-xs fluid>
<material-card class color="black" title="Confirmation">
<div class="text-center"> Are you sure?</div>
<v-layout row wrap>
<v-layout align-center justify-center wrap class="px-5 mt-2">
<v-btn @click="changeRole" class="WM-CyanBlueGradient-BG" style="padding:10px 60px">
<v-icon class="white--text mr-2 caption">fas fa-plus</v-icon>
<span class="white--text">Confirm</span>
</v-btn>
<v-btn @click="closeModal" class="WM-NoShadow WM-Outline-Btn WM-Border WM-Border-Black ml-5">
<v-icon class="black--text mr-2 caption">fas fa-times</v-icon>
<span class="black--text">Close</span>
</v-btn>
</v-layout>
</v-layout>
</material-card>
</v-container>
</v-form>
</template>
<script>
import { mapGetters, mapMutations } from "vuex";
export default {
methods: {
...mapMutations("modal", ["closeModal"]),
async changeRole() {
this.getModal?.success()
}
},
computed: {
...mapGetters("modal", ["getModal"])
}
};
</script>
<style>
.text-center {
text-align: center;
}
</style>
+1
View File
@@ -25,6 +25,7 @@ import App from './App.vue'
import i18n from '@/i18n'
import router from '@/router'
import store from '@/store'
import VueLazyLoad from 'vue-lazyload';
Vue.use(VueLazyLoad)
import { ApiService, TokenService } from '@/services'
+1
View File
@@ -1,4 +1,5 @@
export default {
getModal: (state) => state.currentModal,
getCurrentModal: (state) => {
return state.currentModal.name
},
+1
View File
@@ -5,6 +5,7 @@ export default {
if (data.properties) {
state.currentModal.properties = data.properties;
}
if(data.success) state.currentModal.success = data.success;
},
setResultModal: (state, data) => {
state.currentModal.result = data;
+46 -37
View File
@@ -13,7 +13,7 @@
</v-flex>
<v-spacer></v-spacer>
<v-flex xs12 md2 sm2 class="text-xs-right">
<router-link :to="{name: 'AddMedicalCenter'}">
<router-link :to="{ name: 'AddMedicalCenter' }">
<v-btn class="WM-NoShadow WM-Outline-Btn WM-Border WM-Border-Black">
<v-icon class="black--text mr-2 caption">fas fa-plus</v-icon>
<span class="black--text">Add</span>
@@ -28,10 +28,7 @@
<v-flex md12>
<v-data-table :headers="headers" :items="items" hide-actions>
<template slot="headerCell" slot-scope="{ header }">
<span
class="subheading font-weight-light text-white text--darken-3"
v-text="header.text"
/>
<span class="subheading font-weight-light text-white text--darken-3" v-text="header.text" />
</template>
<template slot="items" slot-scope="{ item }">
<td class="headline font-weight-light WM-NoLetterSpacing">{{ item.name }}</td>
@@ -39,35 +36,36 @@
<td class="title font-weight-light">{{ item.users_count }} Operator</td>
<td class="text-xs-right FlexBtn Height-MD-80 Height-SM-48">
<v-tooltip bottom open-on-hover>
<template v-slot:activator="{ on, attrs }">
<router-link class="LinkBtn" :to="{name : 'EditMedicalCenter', params : {medicalCenter : item.id}}">
<v-btn v-bind="attrs" v-on="on" color="cyan" class="mr-2 WM-ActionButton">
<v-icon class="white--text mr-2 caption">fas fa-pen</v-icon>
<span>Edit</span>
</v-btn>
</router-link>
</template>
<span>Edit</span>
<template v-slot:activator="{ on, attrs }">
<router-link class="LinkBtn"
:to="{ name: 'EditMedicalCenter', params: { medicalCenter: item.id } }">
<v-btn v-bind="attrs" v-on="on" color="cyan" class="mr-2 WM-ActionButton">
<v-icon class="white--text mr-2 caption">fas fa-pen</v-icon>
<span>Edit</span>
</v-btn>
</router-link>
</template>
<span>Edit</span>
</v-tooltip>
<v-tooltip bottom open-on-hover>
<template v-slot:activator="{ on, attrs }">
<router-link class="LinkBtn" :to="{name : 'OperatorList', params : {medicalCenter : item.id}}">
<v-btn v-bind="attrs" v-on="on" color="orange darken-1" class="mr-2 WM-ActionButton">
<v-icon class="white--text mr-2 caption">fas fa-user</v-icon>
<span>Operator</span>
</v-btn>
</router-link>
</template>
<span>Operator</span>
<template v-slot:activator="{ on, attrs }">
<router-link class="LinkBtn" :to="{ name: 'OperatorList', params: { medicalCenter: item.id } }">
<v-btn v-bind="attrs" v-on="on" color="orange darken-1" class="mr-2 WM-ActionButton">
<v-icon class="white--text mr-2 caption">fas fa-user</v-icon>
<span>Operator</span>
</v-btn>
</router-link>
</template>
<span>Operator</span>
</v-tooltip>
<v-tooltip bottom open-on-hover>
<template v-slot:activator="{ on, attrs }">
<v-btn v-bind="attrs" v-on="on" color="pink" @click="remove(item.id)" class="WM-ActionButton">
<v-icon class="white--text mr-2 caption">fas fa-times</v-icon>
<template v-slot:activator="{ on, attrs }">
<v-btn v-bind="attrs" v-on="on" color="pink" @click="remove(item.id)" class="WM-ActionButton">
<v-icon class="white--text mr-2 caption">fas fa-times</v-icon>
<span>Remove</span>
</v-btn>
</template>
<span>Remove</span>
</v-btn>
</template>
<span>Remove</span>
</v-tooltip>
</td>
</template>
@@ -79,7 +77,7 @@
<v-pagination color="black" v-model="currentPage" :length="lastPage" :total-visible="6"></v-pagination>
</div>
<v-layout row wrap align-center justify-center class="mt-3">
<router-link :to="{name: 'Dashboard'}">
<router-link :to="{ name: 'Dashboard' }">
<v-btn class="WM-NoShadow WM-Outline-Btn WM-Border WM-Border-Black ml-5">
<v-icon class="black--text mr-2 caption">fas fa-chevron-left</v-icon>
<span class="black--text">Back</span>
@@ -93,6 +91,7 @@
<script>
import { ApiService } from "@/services";
import { urls } from "@/config/urls";
import { mapMutations } from 'vuex'
export default {
data: () => ({
headers: [
@@ -129,6 +128,7 @@ export default {
this.load();
},
methods: {
...mapMutations("modal", ["changeCurrentModal", "closeModal"]),
async load(page = 1) {
let filter = `?page=${page}&name=${this.filter.name}`;
const result = await ApiService.get(urls.listMedicalCenter(filter));
@@ -137,14 +137,23 @@ export default {
this.lastPage = result.data.data.last_page;
},
async remove(id) {
const result = await ApiService.delete(urls.deleteMedicalCenter(id));
if (result && result.status == 200) {
for (const key in this.items) {
if (this.items.hasOwnProperty(key) && this.items[key].id == id) {
this.items.splice(key, 1);
this.changeCurrentModal({
modal: "modal-user-confirmation",
properties: {
width: '30'
},
success: async () => {
const result = await ApiService.delete(urls.deleteMedicalCenter(id));
this.closeModal();
if (result && result.status == 200) {
for (const key in this.items) {
if (this.items[key].id == id) {
this.items.splice(key, 1);
}
}
}
}
}
},
});
}
},
watch: {
+87 -151
View File
@@ -4,105 +4,49 @@
<v-layout align-center justify-center wrap class="px-5 mb-3">
<v-flex xs12 md3 sm3 class="WM-FlexCenter">
<v-icon class="fa fa-align-left mr-2 WM-Margin-B-8"></v-icon>
<v-text-field
class="py-3 pr-3"
color="black"
name="name"
label="Name"
v-model="filter.name"
></v-text-field>
<v-text-field class="py-3 pr-3" color="black" name="name" label="Name"
v-model="filter.name"></v-text-field>
</v-flex>
<v-flex xs12 md3 sm3 class="WM-FlexCenter pl-3">
<v-icon class="fa fa-hospital-o mr-2 WM-Margin-B-8"></v-icon>
<v-autocomplete
class="py-3 pr-3"
v-model="filter.medical_center_id"
label="Hospital"
color="black"
:items="medicalCenters"
item-text="name"
item-value="id"
></v-autocomplete>
<v-autocomplete class="py-3 pr-3" v-model="filter.medical_center_id" label="Hospital" color="black"
:items="medicalCenters" item-text="name" item-value="id"></v-autocomplete>
</v-flex>
<v-flex xs12 md3 sm3 class="WM-FlexCenter pl-3">
<v-icon class="fa fa-phone mr-2 WM-Margin-B-8"></v-icon>
<v-text-field
class="py-3 pr-3"
color="black"
name="CellPhone"
label="CellPhone"
v-model="filter.cell_number"
></v-text-field>
<v-text-field class="py-3 pr-3" color="black" name="CellPhone" label="CellPhone"
v-model="filter.cell_number"></v-text-field>
</v-flex>
<v-flex xs12 md3 sm3 class="WM-FlexCenter pl-3">
<v-icon class="fa fa-check mr-2 WM-Margin-B-8"></v-icon>
<v-select
class="py-3 pr-3"
color="black"
name="role"
label="Role"
:items="roles"
v-model="filter.role"
></v-select>
<v-select class="py-3 pr-3" color="black" name="role" label="Role" :items="roles"
v-model="filter.role"></v-select>
</v-flex>
</v-layout>
<v-layout class="px-5 mb-3">
<v-flex xs12 sm12 md2 class="WM-FlexCenter">
<v-icon class="far fa-calendar-alt mr-2"></v-icon>
<v-menu
lazy
:close-on-content-click="true"
transition="v-scale-transition"
offset-y
v-model="fromMenu"
>
<v-text-field
required
slot="activator"
label="FromDate"
color="black"
v-model="filter.fromPicker"
></v-text-field>
<v-date-picker
color="pink"
no-title
v-model="filter.fromPicker"
:date-format="date => new Date(date).toDateString()"
></v-date-picker>
<v-menu lazy :close-on-content-click="true" transition="v-scale-transition" offset-y
v-model="fromMenu">
<v-text-field required slot="activator" label="FromDate" color="black"
v-model="filter.fromPicker"></v-text-field>
<v-date-picker color="pink" no-title v-model="filter.fromPicker"
:date-format="date => new Date(date).toDateString()"></v-date-picker>
</v-menu>
</v-flex>
<v-flex xs12 sm12 md2 class="WM-FlexCenter pl-3">
<v-icon class="far fa-calendar-alt mr-2"></v-icon>
<v-menu
lazy
:close-on-content-click="true"
transition="v-scale-transition"
offset-y
v-model="upToMenu"
>
<v-text-field
required
slot="activator"
label="UpToDate"
color="black"
v-model="filter.upToPicker"
></v-text-field>
<v-date-picker
color="pink"
no-title
v-model="filter.upToPicker"
:date-format="date => new Date(date).toDateString()"
></v-date-picker>
<v-menu lazy :close-on-content-click="true" transition="v-scale-transition" offset-y
v-model="upToMenu">
<v-text-field required slot="activator" label="UpToDate" color="black"
v-model="filter.upToPicker"></v-text-field>
<v-date-picker color="pink" no-title v-model="filter.upToPicker"
:date-format="date => new Date(date).toDateString()"></v-date-picker>
</v-menu>
</v-flex>
<!-- <v-spacer></v-spacer> -->
<v-flex wrap xs12 md2 sm12 class="WM-Align-R ml-4">
<v-btn
class="WM-CyanBlueGradient-BG"
style="padding:10px 60px"
@click="load(undefined)"
>
<v-btn class="WM-CyanBlueGradient-BG" style="padding:10px 60px" @click="load(undefined)">
<v-icon class="white--text mr-2 caption">fas fa-search</v-icon>
<span class="white--text">Filter</span>
</v-btn>
@@ -116,74 +60,59 @@
<v-flex xs12 md12 sm12>
<v-data-table :headers="headers" :items="items" hide-actions>
<template slot="headerCell" slot-scope="{ header }">
<span
class="subheading font-weight-light text-white text--darken-3"
v-text="header.text"
/>
<span class="subheading font-weight-light text-white text--darken-3" v-text="header.text" />
</template>
<template slot="items" slot-scope="{ item }">
<td class="headline font-weight-light">
{{item.name}}
{{ item.name }}
<br>
<span class="WM-Font-14">{{item.cell_number}}</span>
<span class="WM-Font-14">{{ item.cell_number }}</span>
</td>
<td class="title font-weight-light">{{item.created_at}}</td>
<td class="title font-weight-light">{{ item.created_at }}</td>
<td class="title font-weight-light">
<span v-for="(role, key) in item.roles" :key="key">{{ role.name }}</span>
</td>
<td class="title font-weight-light">{{item.medical_center.name}}</td>
<td class="title font-weight-light">{{ item.medical_center.name }}</td>
<td class="text-xs-right FlexBtn">
<v-tooltip bottom open-on-hover>
<template v-slot:activator="{ on, attrs }">
<v-btn
v-bind="attrs" v-on="on"
:color="item.status == 'Active' ? 'green' : 'red'"
@click="changeStatus(item.id)"
class="mr-2 WM-ActionButton"
v-if="$hasRole('Admin|Supervisor')"
>
<template v-if="item.status == 'Active'">
<v-icon class="white--text mr-2 caption">fa fa-pause</v-icon>
<span v-if="item.status == 'Active'">Suspended</span>
</template>
<template v-else>
<v-icon class="white--text mr-2 caption">fa fa-pause</v-icon>
<span>Active</span>
</template>
</v-btn>
</template>
<span v-if="item.status == 'Active'">Suspended</span>
<span v-else>Active</span>
<template v-slot:activator="{ on, attrs }">
<v-btn v-bind="attrs" v-on="on"
:color="item.status == 'Active' ? 'green' : 'red'"
@click="changeStatus(item.id)" class="mr-2 WM-ActionButton"
v-if="$hasRole('Admin|Supervisor')">
<template v-if="item.status == 'Active'">
<v-icon class="white--text mr-2 caption">fa fa-pause</v-icon>
<span v-if="item.status == 'Active'">Suspended</span>
</template>
<template v-else>
<v-icon class="white--text mr-2 caption">fa fa-pause</v-icon>
<span>Active</span>
</template>
</v-btn>
</template>
<span v-if="item.status == 'Active'">Suspended</span>
<span v-else>Active</span>
</v-tooltip>
<v-tooltip bottom open-on-hover>
<template v-slot:activator="{ on, attrs }">
<v-btn
v-bind="attrs" v-on="on"
color="orange darken-1"
@click="changeRoleModal(item)"
class="mr-2 WM-ActionButton"
v-if="$hasRole('Admin')"
>
<v-icon class="white--text mr-2 caption">fas fa-user-tag</v-icon>
<template v-slot:activator="{ on, attrs }">
<v-btn v-bind="attrs" v-on="on" color="orange darken-1"
@click="changeRoleModal(item)" class="mr-2 WM-ActionButton"
v-if="$hasRole('Admin')">
<v-icon class="white--text mr-2 caption">fas fa-user-tag</v-icon>
<span>Role</span>
</v-btn>
</template>
<span>Role</span>
</v-btn>
</template>
<span>Role</span>
</v-tooltip>
<v-tooltip bottom open-on-hover>
<template v-slot:activator="{ on, attrs }">
<v-btn
v-bind="attrs" v-on="on"
color="pink"
v-if="$hasRole('Admin')"
class="WM-ActionButton"
@click="remove(item.id)"
>
<v-icon class="white--text mr-2 caption">fas fa-times</v-icon>
<template v-slot:activator="{ on, attrs }">
<v-btn v-bind="attrs" v-on="on" color="pink" v-if="$hasRole('Admin')"
class="WM-ActionButton" @click="remove(item.id)">
<v-icon class="white--text mr-2 caption">fas fa-times</v-icon>
<span>Remove</span>
</v-btn>
</template>
<span>Remove</span>
</v-btn>
</template>
<span>Remove</span>
</v-tooltip>
</td>
</template>
@@ -194,15 +123,10 @@
<v-divider></v-divider>
</v-layout>
<div class="text-xs-center mt-2" v-if="lastPage > 1">
<v-pagination
color="black"
v-model="currentPage"
:length="lastPage"
:total-visible="6"
></v-pagination>
<v-pagination color="black" v-model="currentPage" :length="lastPage" :total-visible="6"></v-pagination>
</div>
<v-layout row wrap align-center justify-center class="mt-3">
<router-link :to="{name: 'Dashboard'}">
<router-link :to="{ name: 'Dashboard' }">
<v-btn class="WM-NoShadow WM-Outline-Btn WM-Border WM-Border-Black ml-5">
<v-icon class="black--text mr-2 caption">fas fa-chevron-left</v-icon>
<span class="black--text">Back</span>
@@ -298,7 +222,7 @@ export default {
this.$router.push({ name: `Dashboard` });
}
},
...mapMutations("modal", ["changeCurrentModal"]),
...mapMutations("modal", ["changeCurrentModal", "closeModal"]),
changeRoleModal(user) {
this.changeCurrentModal({
modal: "modal-user-role",
@@ -306,17 +230,26 @@ export default {
});
},
async remove(userId) {
const result = await ApiService.delete(urls.deleteUser(userId));
if (result && result.status == 200) {
for (const key in this.items) {
if (
this.items.hasOwnProperty(key) &&
this.items[key].id == userId
) {
this.items.splice(key, 1);
this.changeCurrentModal({
modal: "modal-user-confirmation",
properties: {
userId,
width: '30'
},
success: async () => {
const result = await ApiService.delete(urls.deleteUser(userId));
this.closeModal();
if (result && result.status == 200) {
for (const key in this.items) {
if (
this.items[key].id == userId
) {
this.items.splice(key, 1);
}
}
}
}
}
},
});
},
async fillSelectFilter() {
const result = await ApiService.get(urls.listFilterItemsTestResult);
@@ -344,12 +277,15 @@ export default {
</script>
<style>
.v-btn--floating {
padding: 0!important;
padding: 0 !important;
}
.theme--light.v-btn.v-btn--flat {
color: rgba(0,0,0,.87)!important;
color: rgba(0, 0, 0, .87) !important;
}
.v-btn--floating, .v-btn--icon:before {
border-radius: 50%!important;
.v-btn--floating,
.v-btn--icon:before {
border-radius: 50% !important;
}
</style>