-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add edit challenge modal and api (#101)
* add edit challenge modal and api * Update _clickToAddList.scss * Update main.scss Co-authored-by: Aviral Jain <avi.aviral140@gmail.com>
- Loading branch information
1 parent
f0b09ed
commit 36d28d9
Showing
10 changed files
with
23,554 additions
and
24 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<template> | ||
<div class="clickToAddListContainer"> | ||
<transition name="fade" appear v-for="(item, index) in list" :key="index"> | ||
<div class="clickToAddListItem"> | ||
<input | ||
class="editChallAssetLinkInput" | ||
:value="item" | ||
ref="link" | ||
@keyup="$emit('valueChanged', $event.target.value, index)" | ||
/> | ||
<img :src="cross" @click="$emit('deleteItem', index)" /> | ||
</div> | ||
</transition> | ||
<p class="addListItem" @click="addNewItem">+ Add another link</p> | ||
</div> | ||
</template> | ||
<script> | ||
import { cross } from "../constants/images"; | ||
export default { | ||
name: "ClickToAddList", | ||
props: ["list"], | ||
data() { | ||
return { | ||
cross, | ||
isCreated: false, | ||
}; | ||
}, | ||
methods: { | ||
addNewItem() { | ||
this.list.push(""); | ||
}, | ||
}, | ||
updated() { | ||
if (this.isCreated) this.$refs.link[this.list.length - 1].focus(); | ||
this.isCreated = true; | ||
}, | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,174 @@ | ||
<template> | ||
<div class="edit-chall-modal"> | ||
<div class="edit-chall-modal-header"> | ||
<div class="heading">EDIT CHALLENGE</div> | ||
<button class="modal-close-button close-cross" @click="$emit('close')"> | ||
<img :src="cross" /> | ||
</button> | ||
</div> | ||
<div class="edit-chall-modal-body form"> | ||
<p class="adFormFields">Name</p> | ||
<input v-model="name" class="adminFormTitle readonly" readonly /> | ||
<p class="adFormFields">Flag</p> | ||
<input | ||
v-model="flag" | ||
placeholder="Enter the Flag" | ||
class="adminFormTitle" | ||
/> | ||
<p class="adFormFields">Hints</p> | ||
<textarea | ||
v-model="hints" | ||
placeholder="Enter the Hints to be displayed " | ||
></textarea> | ||
<p class="adFormFields">Description</p> | ||
<textarea | ||
v-model="description" | ||
placeholder="Enter the description" | ||
></textarea> | ||
<p class="adFormFields">Tags</p> | ||
<input | ||
v-model="tags" | ||
placeholder="Enter the Tags" | ||
class="adminFormTitle" | ||
/> | ||
<p class="editFormFieldNote"> | ||
Use four colons (::::) to separate multiple values | ||
</p> | ||
<div class="editChallModalFormGroup"> | ||
<div class="editChallModalInputGroup width65"> | ||
<p class="adFormFields">Ports</p> | ||
<input | ||
v-model="ports" | ||
placeholder="Enter the ports" | ||
class="adminFormTitle" | ||
/> | ||
<p class="editFormFieldNote"> | ||
Use comma(,) to separate multiple values | ||
</p> | ||
</div> | ||
<div class="editChallModalInputGroup width30"> | ||
<p class="adFormFields">Points</p> | ||
<input | ||
v-model="points" | ||
placeholder="Enter the points" | ||
class="adminFormTitle" | ||
/> | ||
</div> | ||
</div> | ||
<p class="adFormFields">Asset Links</p> | ||
<ClickToAddList | ||
:list="assetLinks" | ||
@addNewItem="addNewAsset" | ||
@deleteItem="deleteAsset" | ||
@valueChanged="assetChanged" | ||
/> | ||
<p class="adFormFields">Additional Links</p> | ||
<ClickToAddList | ||
:list="additionalLinks" | ||
@addNewItem="addNewAdditionalLink" | ||
@deleteItem="deleteAdditionalLink" | ||
@valueChanged="additionalLinkChanged" | ||
/> | ||
</div> | ||
<div class="actionButtons"> | ||
<button | ||
class="action-cta challenge-action-btn discard-button" | ||
@click="$emit('close')" | ||
> | ||
Discard | ||
</button> | ||
<Button | ||
text="Save Changes" | ||
variant="primary-cta" | ||
:onclick="updateConfigs" | ||
/> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import { cross } from "../constants/images"; | ||
import configService from "../api/admin/configureAPI"; | ||
import UploadComponent from "@/components/UploadComponent.vue"; | ||
import ChallCard from "@/components/ChallCard.vue"; | ||
import Button from "@/components/Button.vue"; | ||
import ErrorBox from "@/components/ErrorBox.vue"; | ||
import ClickToAddList from "@/components/ClickToAddList.vue"; | ||
export default { | ||
name: "PreviewModal", | ||
props: ["challenge"], | ||
data() { | ||
return { | ||
cross, | ||
assetLinks: [], | ||
additionalLinks: [], | ||
challengeInfo: {}, | ||
}; | ||
}, | ||
components: { | ||
Button, | ||
ClickToAddList, | ||
}, | ||
mounted() { | ||
console.log(this.challenge) | ||
this.challengeInfo = Object.assign({}, this.challenge); | ||
this.updateChallengeInfo(); | ||
}, | ||
methods: { | ||
async updateConfigs() { | ||
await configService | ||
.updateChallengeConfig({ | ||
name: this.name, | ||
flag: this.flag, | ||
hints: this.hints, | ||
description: this.description, | ||
tags: this.tags, | ||
ports: this.ports, | ||
points: this.points, | ||
assetLinks: this.assetLinks.filter((e) => e), | ||
additionalLinks: this.additionalLinks.filter((e) => e), | ||
}) | ||
.then((res) => { | ||
this.$emit("close"); | ||
this.$router.go(); | ||
}) | ||
.catch((err) => { | ||
console.log(err); | ||
}); | ||
}, | ||
addNewAsset() { | ||
this.assetLinks.push(""); | ||
}, | ||
deleteAsset(index) { | ||
this.assetLinks.splice(index, 1); | ||
}, | ||
assetChanged(value, index) { | ||
this.assetLinks[index] = value; | ||
}, | ||
addNewAdditionalLink() { | ||
this.additionalLinks.push(""); | ||
}, | ||
deleteAdditionalLink(index) { | ||
this.additionalLinks.splice(index, 1); | ||
}, | ||
additionalLinkChanged(value, index) { | ||
this.additionalLinks[index] = value; | ||
}, | ||
updateChallengeInfo() { | ||
this.name = this.challengeInfo.name; | ||
this.flag = this.challengeInfo.flag; | ||
this.hints = this.challengeInfo.hints; | ||
this.description = this.challengeInfo.description; | ||
this.tags = this.challengeInfo.tags.join("::::"); | ||
this.ports = this.challengeInfo.ports.join(); | ||
this.points = this.challengeInfo.points; | ||
this.assetLinks = | ||
this.challengeInfo.assets[0] === "" ? [] : this.challengeInfo.assets; | ||
this.additionalLinks = | ||
this.challengeInfo.additionalLinks[0] === "" | ||
? [] | ||
: this.challengeInfo.additionalLinks; | ||
}, | ||
}, | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
.clickToAddListContainer{ | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: space-between; | ||
width: 100%; | ||
.clickToAddListItem{ | ||
margin-bottom: 0.375rem; | ||
box-sizing: border-box; | ||
height: 2rem; | ||
border-radius: 0.3125rem; | ||
border: 1px solid $theme-color-grey-high-transp; | ||
@extend %font-style-basic; | ||
width: 100%; | ||
display: flex; | ||
flex-direction: row; | ||
justify-content: space-around; | ||
align-items: center; | ||
input{ | ||
border: 0; | ||
height: 85%; | ||
width: 85%; | ||
} | ||
input:focus{ | ||
border: 0; | ||
outline: 0; | ||
} | ||
img{ | ||
height: 32%; | ||
cursor: pointer; | ||
} | ||
} | ||
.addListItem{ | ||
font-size: 0.875rem; | ||
cursor: pointer; | ||
color: $theme-color-dark-orange; | ||
text-align: left; | ||
} | ||
.addListItem:hover{text-decoration: underline; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.