Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HfPopUp component created and used. #1602

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/elements/HfNotes.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<p
class="my-4 border rounded-lg p-2 modal-text"
class="border rounded-lg p-2 modal-text"
v-html="notes"
:style="backroundThemeCss"
>
Expand Down
39 changes: 39 additions & 0 deletions src/components/elements/HfPopUp.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<template>
<b-modal v-model="show" hide-footer ref="modal-1" :title="Header" centered>
<slot />
</b-modal>
</template>

<script>
export default {
data() {
return {
show: false,
};
},
props: {
Header: {
type: String,
require: true,
},
},
created() {
this.openModal();
this.closeModal();
},
methods: {
openModal() {
this.$root.$on("modal-show", () => {
this.show = true;
});
},
closeModal() {
this.$root.$on("modal-close", () => {
this.show = false;
});
},
},
};
</script>

<style></style>
5 changes: 4 additions & 1 deletion src/utils/messages/admin/Notes.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ may take sometime and screen may freeze. Once done, you will get
selected records in excel sheet. The winner selection is primarly based
on their "<b>score</b>" unless checked "<b>randomly</b>".`

const DELETE_EVENT_NOTE=`<b>Caution :</b> This action will delete this event and associated participants.
Please enter the event id to proceed.`
module.exports={
LOTTERY_NOTES
LOTTERY_NOTES,
DELETE_EVENT_NOTE
}
187 changes: 156 additions & 31 deletions src/views/admin/Events.vue
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,29 @@ i {
:message="msg"
>
</hf-page-message>
<hf-pop-up
Header="Delete Event"
>
<hf-notes
:notes="deleteNote"
></hf-notes>
<div class="row g-3 align-items-center w-100 mt-4">
<div class="col-lg-3 col-md-3 text-left">
<label for="DeleteId" class="col-form-label">Event Id :</label>
</div>
<div class=" col-lg-9 col-md-9 px-0">
<input v-model="DeleteId" type="text" placeholder="6241c8057f5e...e2eaec05d" id="DeleteId" class="form-control w-100" >
</div>
</div>
<div class="mt-5 text-center">
<hf-buttons
name="Delete"
@executeAction="deleteEvent()"
title="Delete an event"
customClass="btn btn-danger"
></hf-buttons>
</div>
</hf-pop-up>
<div class="row" style="margin-top: 2%">
<div
class="col-md-4"
Expand Down Expand Up @@ -442,9 +465,15 @@ import HfButtons from "../../components/elements/HfButtons.vue"
import Messages from "../../utils/messages/admin/en";
import HfPageMessage from '../../components/elements/HfPageMessage.vue';
import HfSearchBox from "../../components/elements/HfSearchBox.vue"
import HfPopUp from "../../components/elements/HfPopUp.vue"
import HfNotes from '../../components/elements/HfNotes.vue';
const {DELETE_EVENT_NOTE} = require("../../utils/messages/admin/Notes")
export default {
name: "Investor",
components: { Loading, Paginate, CreateProjectSlide, HfPageMessage, HfButtons, HfSearchBox},
components: { Loading, Paginate, CreateProjectSlide,
HfPageMessage, HfButtons, HfSearchBox, HfPopUp,
HfNotes
},

data() {
return {
Expand All @@ -466,6 +495,8 @@ export default {
tags: [],
slug: "",
},
DeleteId:"",
projectToDelete:{},
selected: [],
tagToSearch: [
// {text: 'Select Tag To filter events', value: null,},
Expand Down Expand Up @@ -559,7 +590,8 @@ export default {
fullPage: true,
user: {},
errors: [],
msg:Messages.EVENTS.NO_EVENT_FOUND
msg:Messages.EVENTS.NO_EVENT_FOUND,
deleteNote:DELETE_EVENT_NOTE
};
},

Expand Down Expand Up @@ -1036,45 +1068,27 @@ export default {

return this.paginateChange(this.currentPage);
},
async deleteProject(project) {
async deleteEvent(){

try {
await this.$swal
.fire({
html: `
<div><b style="color:red">CAUTION :</b> <b style="color:tomato" >This action will delete this event and associated participants.<br>Please enter the event id to proceed.</b></div>
<input type="name" id="name" class="swal2-input" placeholder="6241c8057f5e...e2eaec05d">`,
confirmButtonText: '<span style="color:white">Confirm</span>',
confirmButtonColor: "red",
icon: "warning",
focusConfirm: false,
showCloseButton: true,
allowOutsideClick: false,
preConfirm: () => {
const eventID = this.$swal
.getPopup()
.querySelector("#name").value;
if (eventID === "") {
this.$swal.showValidationMessage(`Please enter event id`);
}
return { eventId: eventID };
},
})
.then(async (data) => {
if(this.DeleteId===""){
this.notifyErr("Please enter event id")
}
this.isLoading = true;
this.project = { ...project };
this.project = { ...this.projectToDelete };

if (data.value) {
if (data.value.eventId === project._id) {
if (this.DeleteId) {
if (this.DeleteId === this.projectToDelete._id) {
for(let i=0;i<this.projects.length;i++){
if (this.projects[i].projectName.includes(project.projectName)) {
if (this.projects[i].projectName.includes(this.projectToDelete.projectName)) {
const pageNum = Math.floor( i==0?i:(i-1) / this.perPage);
this.currentPage = pageNum + 1;
break
}
}
this.currentPage = this.currentPage ;
if (!this.project._id) throw new Error("No project found");
const url = `${this.$config.studioServer.BASE_URL}api/v1/project/${project._id}`;
const url = `${this.$config.studioServer.BASE_URL}api/v1/project/${this.projectToDelete._id}`;
const headers = {
Authorization: `Bearer ${this.authToken}`,
AccessToken: `Bearer ${this.accessToken}`,
Expand Down Expand Up @@ -1118,6 +1132,7 @@ export default {
if (!resp.ok) {
return this.notifyErr(json);
} else {
this.$root.$emit('modal-close');
this.notifySuccess("Event is deleted successfully");
}
} else {
Expand All @@ -1129,13 +1144,121 @@ export default {
);
}
}
});
this.paginateChange(this.currentPage);
} catch (e) {
this.notifyErr(e.message);
} finally {
this.isLoading = false;
}


},
async deleteProject(project) {
this.resetAllValues();
this.projectToDelete = project;
this.$root.$emit('modal-show');
// this.deleteEvent()
// try {
// await this.$swal
// .fire({
// html: `
// <div><b style="color:red">CAUTION :</b> <b style="color:tomato" >This action will delete this event and associated participants.<br>Please enter the event id to proceed.</b></div>
// <input type="name" id="name" class="swal2-input" placeholder="6241c8057f5e...e2eaec05d">`,
// confirmButtonText: '<span style="color:white">Confirm</span>',
// confirmButtonColor: "red",
// icon: "warning",
// focusConfirm: false,
// showCloseButton: true,
// allowOutsideClick: false,
// preConfirm: () => {
// const eventID = this.$swal
// .getPopup()
// .querySelector("#name").value;
// if (eventID === "") {
// this.$swal.showValidationMessage(`Please enter event id`);
// }
// return { eventId: eventID };
// },
// })
// .then(async (data) => {
// this.isLoading = true;
// this.project = { ...project };

// if (data.value) {
// if (data.value.eventId === project._id) {
// for(let i=0;i<this.projects.length;i++){
// if (this.projects[i].projectName.includes(project.projectName)) {
// const pageNum = Math.floor( i==0?i:(i-1) / this.perPage);
// this.currentPage = pageNum + 1;
// break
// }
// }
// this.currentPage = this.currentPage ;
// if (!this.project._id) throw new Error("No project found");
// const url = `${this.$config.studioServer.BASE_URL}api/v1/project/${project._id}`;
// const headers = {
// Authorization: `Bearer ${this.authToken}`,
// AccessToken: `Bearer ${this.accessToken}`,
// };
// const resp = await fetch(url, {
// headers,
// method: "DELETE",
// });
// const json = await resp.json();
// //ToDO:- check if its a json
// if (!json || !json.isArchived) {
// throw new Error("Could not delete the event");
// }
// // console.log(this.projects.length)
// const index = this.projects
// .map((project) => project._id)
// .indexOf(json._id);

// // console.log(index)
// this.projects.splice(index, 1);
// // console.log(this.projects.length)
// this.projectsToShow = this.projects.slice(0, this.perPage);

// const tempProject = JSON.parse(
// localStorage.getItem("userProjects")
// );
// localStorage.removeItem("userProjects");

// if(tempProject){
// tempProject.projects.splice(index, 1);
// localStorage.setItem(
// "userProjects",
// JSON.stringify({
// projects: tempProject.projects,
// count: tempProject.projects.length,
// })
// );
// }

// if (json) {
// if (!resp.ok) {
// return this.notifyErr(json);
// } else {
// this.notifySuccess("Event is deleted successfully");
// }
// } else {
// throw new Error("Error while deleting event");
// }
// } else {
// throw new Error(
// "Looks like you were about to delete a event by mistake"
// );
// }
// }
// });
// this.paginateChange(this.currentPage);
// } catch (e) {
// this.notifyErr(e.message);
// } finally {
// this.isLoading = false;
// }

},

async saveProject() {
Expand Down Expand Up @@ -1428,6 +1551,8 @@ export default {
referralPoint: 5,
tags: [],
}),
this.DeleteId="",
this.projectToDelete={};
(this.eventActionList = []),
(this.tagsTemp = []),
(this.selectedSocialMedia = null),
Expand Down
Loading