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

Tag Implementation Done #918

Merged
merged 1 commit into from
Feb 13, 2022
Merged
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
34 changes: 22 additions & 12 deletions src/components/admin/createProjectSlider/CreateProjectSlide.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,16 @@
>
<b-card-body>
<general-config
v-on="$listeners"
:isProjectEditing="isProjectEditing"
:themeColor="themeColor"
:fontColor="fontColor"
:fontColorDefault="fontColorDefault"
:themeColorDefault="themeColorDefault"
:project="project"
:eventActionList="tag"
eventActionType="TAGS"
:options="getTagDb"
/>
</b-card-body>
</b-collapse>
Expand Down Expand Up @@ -256,7 +260,7 @@
</b-card>
<!-- -->
<!-- Tags Config -->
<b-card no-body class="mb-1">
<!-- <b-card no-body class="mb-1">
<b-card-header
header-tag="header"
class="p-1 accordin-header accordion-header-theme"
Expand Down Expand Up @@ -286,7 +290,7 @@
/>
</b-card-body>
</b-collapse>
</b-card>
</b-card> -->
</div>
<button
class="btn btn-primary mt-3 button-theme"
Expand Down Expand Up @@ -354,11 +358,27 @@ export default {
},
tagList:{
type: Array,
},
tagFdb:{
type: Array,
}
},

computed: {
// a computed getter
getTagDb: function () {
if(this.tagFdb && this.tagFdb.length >0){
for(let index = 0; index < this.tagFdb.length; index++){
this.options.tagDetails.push({
text:this.tagFdb[index].tagName, value:this.tagFdb[index].type
})
}
return this.options.tagDetails
}
else{
return [];
}
},
customList: function () {
if (this.actionList && this.actionList.length > 0) {
return this.actionList.filter(
Expand Down Expand Up @@ -475,16 +495,6 @@ export default {
],
tagDetails: [
{ text: "Select Tag Type", value: null },
{ text: "Play 2 Earn", value: "PLAY2EARN_TAG" },
{ text: "Air Drop", value: "AIRDROP_TAG" },
{ text: "Ethereum", value: "ETHEREUM_TAG" },
{ text: "Polygon", value: "POLYGON_TAG" },
{ text: "Avalanche", value: "AVALANCHE_TAG" },
{ text: "Harmony", value: "HARMONY_TAG" },
{ text: "Decentralized Identity", value: "DID_TAG" },
{ text: "NFT", value: "NFT_TAG" },
{ text: "Meta Verse", value: "METAVERSE_TAG" },
{ text: "DEFI", value: "DEFI_TAG" },
],
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
<i style="color: gray" v-if="eventAction.type.includes('INPUT_HYPERLINK')" class="fa fa-link"></i>
<i style="color: gray" v-if="eventAction.type.includes('INFO_TEXT')" class="fa fa-info-circle"></i>
<i style="color: gray" v-if="eventAction.type.includes('PRIZE_')" class="fas fa-gift"></i>
<i style="color: gray" v-if="eventAction.type.includes('_TAG')" class="fas fa-tags"></i>
<img style="padding-right: 5px" src="../../../../assets/external-link.svg" v-if="eventAction.type.includes('HYPERLINK_URL')" height="22px" />
<img style="padding-right: 5px" src="/img/ethereum.2b470564.svg" v-if="eventAction.type.includes('BLOCKCHAIN_ETH')" height="22px" />
<img style="padding-right: 5px" src="/img/ethereum.2b470564.svg" v-if="eventAction.type.includes('ETHEREUM_ERC20')" height="22px" />
Expand All @@ -34,7 +33,7 @@
<img style="padding-right: 5px;" src="../../../../assets/avalanche.png" v-if="eventAction.type.includes('BLOCKCHAIN_AVAX')" height="20px" />
<img style="padding-right: 5px;" src="../../../../assets/Reef.svg" v-if="eventAction.type.includes('BLOCKCHAIN_REEF')" height="20px" />
</span>
<span>{{ eventAction.type.includes('_TAG')? CapitaliseString(eventAction.type):truncate1(eventAction.title, 8)}}</span>
<span>{{ truncate1(eventAction.title, 8)}}</span>
<span style="color: gray;padding-left: 5px"><i style="" class="fas fa-minus-circle"></i></span>
</div>
</div>
Expand Down Expand Up @@ -258,7 +257,7 @@ export default {
},
computed:{
noSocialhandle(){
if(this.eventActionType !='CUSTOM' && this.eventActionType !='BLOCKCHAIN' && this.eventActionType !='SMARTCONTRACT' && this.selected.type!='TWITTER_RETWEET' && this.selected.type!='DISCORD_JOIN' && this.eventActionType !='PRIZE' && this.eventActionType!=='TAGS'){
if(this.eventActionType !='CUSTOM' && this.eventActionType !='BLOCKCHAIN' && this.eventActionType !='SMARTCONTRACT' && this.selected.type!='TWITTER_RETWEET' && this.selected.type!='DISCORD_JOIN' && this.eventActionType !='PRIZE'){
return true;
}
else{
Expand All @@ -275,7 +274,7 @@ export default {
},

placeH(){
if(this.eventActionType != 'SOCIAL' && this.selected.type !='HYPERLINK_URL' && this.selected.type !='INFO_TEXT' && this.eventActionType !='PRIZE' && this.selected.type!='REEF_ERC20' && this.eventActionType!=='TAGS')
if(this.eventActionType != 'SOCIAL' && this.selected.type !='HYPERLINK_URL' && this.selected.type !='INFO_TEXT' && this.eventActionType !='PRIZE' && this.selected.type!='REEF_ERC20')
{
return true;
}
Expand All @@ -292,7 +291,7 @@ export default {
}
},
noScore(){
if((this.eventActionType === 'CUSTOM' && this.selected.type ==='INFO_TEXT') || this.eventActionType ==='PRIZE' || this.eventActionType==='TAGS'){
if((this.eventActionType === 'CUSTOM' && this.selected.type ==='INFO_TEXT') || this.eventActionType ==='PRIZE'){
return true;
}
else{
Expand Down Expand Up @@ -549,13 +548,6 @@ export default {
this.notifyErr(Messages.EVENTS.ACTIONS.PRIZECARD.PRIZE_PER_WINNER_NOT_URL)
}
break;
case "TAGS":{
if(this.selected.type===null){
isvalid= false;
this.notifyErr("Please select tag");
}
}
break;
default:
this.notifyErr(Messages.EVENTS.ACTIONS.INVALID_EVENT_TYPE)
}
Expand Down
201 changes: 194 additions & 7 deletions src/components/admin/createProjectSlider/components/GeneralConfig.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,58 @@
<style scoped>
.inputInfo{
color: #808080b5;
font-size: smaller;
}

.pointer {
cursor: pointer;
}
.selected-media-wrapper{
margin-top: 20px;
border: 1px dashed;
max-height: 100px;
background-color: #f5f5f5;
border-radius: 10px;

}
.card i{
cursor: pointer;
}
.card{
transition: all 0.5s;

}
.card i{
margin-right: 4px;
}
.flash{
cursor: pointer;
background-color: #1faa596b;
border: 0;
box-shadow: 2px 0 10px rgb(0 0 0 / 10%);
animation: flash 0.4s cubic-bezier(1, 0, 0, 1);
}

.fa-minus-circle{
font-size: 14px;
}
@keyframes flash {
0%{
opacity: 0;

}
100%{
opacity: 1;
}
}

.button-theme{
background-color: #F1B319;
border-collapse: #F1B319;
color: black;
border: 0;

}
.datetime-picker{
background-color: #fff;
background-clip: padding-box;
Expand Down Expand Up @@ -103,24 +155,71 @@
/>
</div>
</div>
<!-- Tile -->
<div v-if="eventActionList.length" style="overflow-y:auto" class="selected-media-wrapper d-flex p-2 mb-4" >
<div @click="handleEventActionClick(idx)"
v-for="(eventAction, idx) in eventActionList" v-bind:Key="idx" >
<div v-if="!eventActionList[idx].isDeleted" :class="flash == idx ?
'flash card rounded m-1 p-1 d-flex flex-row align-items-center' :
'card rounded m-1 p-1 d-flex flex-row align-items-center pointer'"
style="min-width: 120px">
<span>
<i style="color: gray" v-if="eventAction.type.includes('_TAG')" class="fas fa-tags"></i>
</span>
<span>{{ CapitaliseString(eventAction.type)}}</span>
<span style="color: gray;padding-left: 5px"><i style="" class="fas fa-minus-circle"></i></span>
</div>
</div>
</div>

<!-- Tile End -->
<div >

<div class="row g-3 align-items-center w-100 mt-4" v-if="flash==idx" >
<div class=" text-left col-lg-3 col-md-3 text-left">
<label for="type" class="col-form-label">Choose tag<span style="color: red">*</span>: </label>
</div>
<div class="col-lg-9 col-md-9 px-0" >
<b-form-select v-model="selected.type" :options="options"></b-form-select>
</div>
</div>

<div class="row g-3 justify-content-md-end w-100 mt-4" v-if="isCreate==true">
<div class="col-lg-6 col-md-9 px-0">
<button @click="handleEventActionAdd()" class="btn button-theme" type="button"> {{eventActionList.includes(selected) ? "Delete" : "Add"}}</button>
</div>
</div>
<div class="row g-3 justify-content-md-end w-100 mt-4" v-else>
<div class="col-lg-6 col-md-9 px-0">
<button @click="handleEventActionDelete()" class="btn btn-danger slight-left-margin" type="button"> Delete</button>
</div>
</div>
</div>

</div>
</template>

<script>
import Datepicker from 'vuejs-datetimepicker'


import notificationMixins from "../../../../mixins/notificationMixins"
import Messages from "../../../../utils/messages/admin/en"
export default {
name: "GeneralConfig",
components: {Datepicker},
data(){
return{
themeColorLocal: this.themeColor,
fontColorLocal: this.fontColor
idx:null,
flash: null,
isCreate: true,
currentSelectedId :0,
themeColorLocal: this.themeColor,
fontColorLocal: this.fontColor,
selected :{
"type": null,
"id": "",
},
}

},
},
props:{
project:{
type: Object
Expand All @@ -139,8 +238,96 @@ export default {
},
isProjectEditing: {
type: Boolean
},
eventActionType: {
type: String,
},
eventActionList : {
type: Array,
required: true,
},
options: {
type: Array
}
}
},
async mounted(){
this.$root.$on('callClearFromProject',()=>{this.clearSelected()})
},
methods:{
CapitaliseString(string) {
let res = string.split('_');
let first = res[0][0].toUpperCase() + res[0].substring(1).toLowerCase()
return first +' '
},
handleEventActionAdd(){
// Code to Add an Action
let isvalid = this.handleEventActionValidation()
if(isvalid) {
this.selected["id"] = this.eventActionType + "_" + this.eventActionList.length;
this.eventActionList.push(this.selected);
this.$emit("updateTagActions", {
type: "ADD",
data: this.selected
});
this.clearSelected()
}

},
handleEventActionDelete(){

// Code to delete an Action
const actionToDelete = this.eventActionList[this.currentSelectedId];
this.eventActionList.splice(this.currentSelectedId, 1);
this.$emit("updateTagActions", {
type: "DELETE",
data: actionToDelete
})
this.clearSelected();
this.isCreate=true

},
clearSelected () {
this.flash=null;
this.isCreate=true
let clearData = {
"type": null,

}
this.selected = clearData
this.currentSelectedId = null
},

handleEventActionValidation() {
let isvalid = true

//////
//// WARNINGS: This is worst way of handeling validation
//// You should return or break the moment first error occured
//// But here you are checking all validation every time - waste of time!
////////////
switch (this.eventActionType) {
case "TAGS":
if(this.selected.type===null){
isvalid = false
this.notifyErr(Messages.EVENTS.CREATE_EDIT_EVENT.CHOOSE_TAG)
}
break;
default:
this.notifyErr(Messages.EVENTS.ACTIONS.INVALID_EVENT_TYPE)
}
return isvalid
},
handleEventActionClick(idx){
this.flash=idx
let updateData = this.eventActionList[idx]
this.currentSelectedId = idx;

this.selected = updateData;
this.isCreate=false

},
},
mixins: [notificationMixins]
};


Expand Down
4 changes: 3 additions & 1 deletion src/utils/messages/admin/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ const EVENTS = {
PROJECT_DATE_TIME: "Please specify a start and end date",
PROJECT_BLOCKCHAIN_TYPE: "Please provide Blockchain Type",
THEME_NOT_WHITE: "Theme color cannot be white",
THEME_COLOR_NOT_SAME: "Theme color and font color cannot be same"
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"
},

ACTIONS:{
Expand Down
Loading