Skip to content

Commit

Permalink
Merge pull request #1183 from hypersign-protocol/backlog
Browse files Browse the repository at this point in the history
added slug
  • Loading branch information
Pratap2018 authored May 25, 2022
2 parents cb31be8 + fcfdb2a commit 1cf7210
Show file tree
Hide file tree
Showing 4 changed files with 151 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,17 @@
</div>
</div>

<div class="row g-3 align-items-center w-100 mt-4">
<div class="col-lg-3 col-md-3 text-left">
<tool-tips infoMessage="Slug of the event. It should be unique across the platform"></tool-tips><label for="slug" class="col-form-label">
</label><label for="slug"
class="col-form-label">Event Slug<span style="color: red">*</span>: </label>
</div>
<div class=" col-lg-9 col-md-9 px-0">
<input v-model="project.slug" type="text" placeholder="demo-giveaway" id="slug" class="form-control w-100" >
</div>
</div>

<div v-if="isProjectEditing" class="row g-3 align-items-center w-100 mt-4">
<div class="col-lg-3 col-md-3 text-left">
<tool-tips infoMessage="Event status"></tool-tips><label for="projectStatus" class="col-form-label">Status: </label>
Expand Down
8 changes: 7 additions & 1 deletion src/mixins/fieldValidationMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,13 @@ export function isValidText(str) {
return false;
}
}

export function isValidSlug(str){
if(str.match(/^([a-z0-9])*(-([a-z0-9])*)*$/)){
return true
}else{
return false
}
}
// Note: this will check is str is undefined, null, " ", ""
export function isEmpty(str) {
if (str == " ") {
Expand Down
6 changes: 4 additions & 2 deletions src/utils/messages/admin/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ const EVENTS = {
},
VALIDATION:{
INVALID_PROJECT_NAME: "Please provide valid Event Name",
INVALID_LOGO_URL: "Banner Url is not Valid"
INVALID_LOGO_URL: "Banner Url is not Valid",
INVALID_SLUG:"Please enter a valid Event Slug.",
EMPTY_SLUG: "Slug can not be empty"
},
CREATE_EDIT_EVENT: {
PROJECT_FETCHED: "Event is fetched. Event Name ",
Expand All @@ -33,7 +35,7 @@ const EVENTS = {
THEME_COLOR_NOT_SAME: "Theme color and font color cannot be same",
CHOOSE_ATLEAST_ONE_TAG: "Please choose atleast one tag",
CHOOSE_TAG:"Please choose Tag",
DUPLICATE_TAG:"Duplicate tags are not allowed"
DUPLICATE_TAG:"Duplicate tags are not allowed",
},

ACTIONS:{
Expand Down
155 changes: 129 additions & 26 deletions src/views/admin/Events.vue
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,13 @@ i {
class="mb-2"
@error="onBannerError($event)"
>
<ul style="list-style-type: none; padding-left: 0px; font-size: x-small">
<ul
style="
list-style-type: none;
padding-left: 0px;
font-size: x-small;
"
>
<li data-toggle="tooltip" data-placement="bottom" title="EventId">
<i class="far fa-id-card"></i
><span class="card-title">{{ project._id }}</span>
Expand Down Expand Up @@ -330,14 +336,24 @@ i {
:key="tag.id"
pill
variant="secondary"
style="margin-left: 2px;"

style="margin-left: 2px"
>{{ tag.type.split("_")[0] }}</b-badge
>
</small>
<small style="float: right">
<span @click="editProject(project)" title="Click to edit this event" style="cursor:pointer">
<i class="fas fa-pencil-alt"></i>
<span
@click="editProject(project)"
title="Click to edit this event"
style="cursor: pointer"
>
<i class="fas fa-pencil-alt"></i>
</span>
<span
@click="cloneProject(project)"
title="Click to clone this event"
style="cursor: pointer"
>
<i class="fa fa-clone"></i>
</span>
<span
v-if="project.projectStatus == true"
Expand Down Expand Up @@ -388,10 +404,11 @@ import {
truncate,
checkTitle,
checkValue,
isValidSlug,
} from "../../mixins/fieldValidationMixin.js";
import CreateProjectSlide from "../../components/admin/createProjectSlider/CreateProjectSlide.vue";
import dayjs from "dayjs";
import eventBus from '../../eventBus';
import eventBus from "../../eventBus";
import Messages from "../../utils/messages/admin/en";
Expand All @@ -417,6 +434,7 @@ export default {
refereePoint: 10,
referralPoint: 5,
tags: [],
slug: "",
},
selected: [],
tagToSearch: [
Expand Down Expand Up @@ -490,6 +508,7 @@ export default {
fontColorDefault: "#ffffff",
isProjectEditing: false,
isProjectClonning: false,
cols: [
"Project Id",
Expand Down Expand Up @@ -865,7 +884,6 @@ export default {
this.resetAllValues();
this.isProjectEditing = true;
this.project = { ...project };
this.project.fromDate = dayjs(project.fromDate).format(
"YYYY-MM-DD hh:mm:ss"
);
Expand Down Expand Up @@ -909,14 +927,83 @@ export default {
this.fontColor =
project.fontColor !== undefined ? project.fontColor : this.fontColor;
this.projectStatus = project.projectStatus;
// console.log(project.actions)
this.eventActionList = project.actions;
this.tagsTemp = project.tags;
this.$root.$emit("bv::toggle::collapse", "sidebar-right");
this.$root.$emit("callClearFromProject");
},
async cloneProject(project) {
this.resetAllValues();
this.isProjectEditing = false;
this.isProjectClonning = true;
this.project = { ...project };
if (this.isProjectClonning) {
this.project.projectName = this.project._id + "_copy";
this.project._id = "";
this.project.slug = "";
this.project.investorsCount = 0;
}
this.project.fromDate = dayjs(project.fromDate).format(
"YYYY-MM-DD hh:mm:ss"
);
this.project.toDate = dayjs(project.toDate).format("YYYY-MM-DD hh:mm:ss");
// CHECK IF TELEGRAM AND TWITTER EXISTS AND UPDATE THE DATA STRUCTURE
this.project.social = {
twitter: {
isEnabled: true,
twitterHandle: this.project.twitterHandle,
twitterPostFormat: this.project.twitterPostFormat,
},
telegram: {
isEnabled: true,
telegramHandle: this.project.telegramHandle,
telegramAnnouncementChannel: this.project.telegramAnnouncementChannel,
},
};
this.socialOptions.forEach((media) => {
if (media.value) {
media.value.fields.map((field) => {
field.value = this.project[field.name];
});
}
});
this.socialOptions.map((x) => {
if (x.value) {
this.addedSocialMedias.push(x.value);
}
});
this.blockchainType =
project.blockchainType !== undefined
? project.blockchainType
: this.blockchainType;
this.contractType = project.contractType;
this.themeColor =
project.themeColor !== undefined ? project.themeColor : this.themeColor;
this.fontColor =
project.fontColor !== undefined ? project.fontColor : this.fontColor;
this.projectStatus = project.projectStatus;
this.eventActionList = project.actions;
this.eventActionList = this.eventActionList.map(
({ _id, eventId, __v, ...rest }) => {
return rest;
}
);
let index = this.eventActionList
.map((action) => action.title)
.indexOf("Hypersign Authentication");
this.eventActionList.splice(index, 1);
index = this.eventActionList
.map((action) => action.title)
.indexOf("Subscribe Notification");
this.eventActionList.splice(index, 1);
this.tagsTemp = project.tags;
await this.saveProject();
},
async saveProject() {
try {
if (this.checkIfEverythingIsFilled() !== true) {
Expand All @@ -926,7 +1013,9 @@ export default {
if (this.isProjectNameValid() !== true) {
return this.notifyErr(this.isProjectNameValid());
}
if (this.isValidSlug() !== true) {
return this.notifyErr(this.isValidSlug());
}
if (this.isLogoUrlValid() !== true) {
return this.notifyErr(this.isLogoUrlValid());
}
Expand Down Expand Up @@ -980,7 +1069,6 @@ export default {
method,
header: headers,
});
if (!this.isProjectEditing) {
//// not using this for the time being just to test
// this.whitelistingLink = window.location.origin + ( resp.data.slug && resp.data.slug != "" ? "/form/" + resp.data.slug : "/form?projectId=" + resp.data._id )
Expand All @@ -1002,6 +1090,12 @@ export default {
if (this.isProjectEditing) {
await this.fetchProjects();
this.$root.$emit("bv::toggle::collapse", "sidebar-right");
this.isProjectEditing = false;
return;
}
if (this.isProjectClonning) {
await this.fetchProjects();
this.isProjectClonning = false;
return;
}
Expand Down Expand Up @@ -1030,32 +1124,27 @@ export default {
},
checkIfEverythingIsFilled() {
for (let index = 0; index < this.eventActionList.length; index++) {
if (
this.eventActionList[index].score === null ||
this.eventActionList[index].score === ""
) {
return Messages.EVENTS.ACTIONS.SCORE_IS_NUM_ANY_LEFT;
}
if (this.eventActionList[index].type === null) {
if (this.eventActionList[index].type === null) {
return Messages.EVENTS.CHECK_ALL_TYPE;
}
if(this.eventActionList[index].type==="SUMSUB_KYC"){
if(this.eventActionList[index].slug===""){
if (this.eventActionList[index].type === "SUMSUB_KYC") {
if (this.eventActionList[index].slug === "") {
return Messages.EVENTS.ACTIONS.KYCACCORDIN.KYC_SLUG;
}
}
if(isValidURL (this.eventActionList[index].title)!==undefined){
return Messages.EVENTS.ACTIONS.TITLE_URL;
}
if (isValidURL(this.eventActionList[index].title) !== undefined) {
return Messages.EVENTS.ACTIONS.TITLE_URL;
}
}
// for (let index = 0; index < this.eventActionList.length; index++) {
// }
const eventActionTitle = checkTitle(this.eventActionList, "title");
Expand All @@ -1076,11 +1165,10 @@ export default {
x.type !== "BLOCKCHAIN_AVAX" &&
x.type !== "BLOCKCHAIN_REEF" &&
x.type !== "BLOCKCHAIN_TEZ" &&
x.type !== "BLOCKCHAIN_CARDANO" &&
x.type !== "BLOCKCHAIN_CARDANO" &&
x.type !== "PRIZE_CARD" &&
x.type !== "PUSH_NOTIFICATION"&&
x.type!=="SUMSUB_KYC"
x.type !== "PUSH_NOTIFICATION" &&
x.type !== "SUMSUB_KYC"
);
const filteredValueList = checkValue(eventActionValue, "value");
if (filteredValueList.includes(false)) {
Expand Down Expand Up @@ -1130,6 +1218,21 @@ export default {
}
return true;
},
isValidSlug() {
console.log(this.isProjectClonning)
if (this.isProjectClonning && this.project.slug =="") {
return true;
} else {
if (!this.project.slug) {
return Messages.EVENTS.VALIDATION.EMPTY_SLUG;
}
if (!isValidSlug(this.project.slug)) {
return Messages.EVENTS.VALIDATION.INVALID_SLUG;
}
}
return true;
},
clear() {
this.isProjectEditing = false;
Expand Down

0 comments on commit 1cf7210

Please sign in to comment.