merge feat/teams-new-ui

Co-authored-by: Isha Gupta <40794215+IshaGupta18@users.noreply.github.com>
Co-authored-by: Liyas Thomas <liyascthomas@gmail.com>
Co-authored-by: Osheen Sachdev <45964755+oshhh@users.noreply.github.com>
Co-authored-by: Rohan Rajpal <rohan46000@gmail.com>
Co-authored-by: Raghav Gupta <raghav.gupta0307@gmail.com>
This commit is contained in:
Liyas Thomas
2021-04-26 09:37:18 +00:00
committed by GitHub
parent 6a8019c7a0
commit 1bc57f159c
27 changed files with 8278 additions and 298 deletions

View File

@@ -13,45 +13,13 @@
<div slot="body" class="flex flex-col">
<label for="selectLabel">{{ $t("token_req_name") }}</label>
<input type="text" id="selectLabel" v-model="requestData.name" @keyup.enter="saveRequestAs" />
<ul>
<li>
<label for="selectCollection">{{ $t("collection") }}</label>
<span class="select-wrapper">
<select type="text" id="selectCollection" v-model="requestData.collectionIndex">
<option :key="undefined" :value="undefined" hidden disabled selected>
{{ $t("select_collection") }}
</option>
<option
v-for="(collection, index) in $store.state.postwoman.collections"
:key="index"
:value="index"
>
{{ collection.name }}
</option>
</select>
</span>
</li>
</ul>
<label>{{ $t("folder") }}</label>
<SmartAutoComplete
:placeholder="$t('search')"
:source="folders"
:spellcheck="false"
v-model="requestData.folderName"
<label for="selectLabel">Request path</label>
<input readonly :value="path" />
<collections
@select-folder="changeRequestDetails($event)"
@update-collection="collectionsType.type = $event"
:saveRequest="true"
/>
<ul>
<li>
<label for="selectRequest">{{ $t("request") }}</label>
<span class="select-wrapper">
<select type="text" id="selectRequest" v-model="requestData.requestIndex">
<option :key="undefined" :value="undefined">/</option>
<option v-for="(folder, index) in requests" :key="index" :value="index">
{{ folder.name }}
</option>
</select>
</span>
</li>
</ul>
</div>
<div slot="footer">
<div class="row-wrapper">
@@ -72,6 +40,7 @@
<script>
import { fb } from "~/helpers/fb"
import { getSettingSubject } from "~/newstore/settings"
import team_utils from "~/helpers/teams/utils"
export default {
props: {
@@ -81,12 +50,17 @@ export default {
data() {
return {
defaultRequestName: "Untitled Request",
path: "Path will appear here",
requestData: {
name: undefined,
collectionIndex: undefined,
folderName: undefined,
requestIndex: undefined,
},
collectionsType: {
type: "my-collections",
selectedTeam: undefined,
},
}
},
subscriptions() {
@@ -149,6 +123,15 @@ export default {
},
},
methods: {
changeRequestDetails(data) {
this.$data.requestData.folderName = data.folderName.split("/").slice(-2)[0]
this.$data.path = data.folderName
this.$data.requestData.collectionIndex = data.collectionIndex
this.$data.requestData.requestIndex = data.reqIdx
if (data.collectionsType.type !== "my-collections") {
this.$data.collectionsType = data.collectionsType
}
},
syncCollections() {
if (fb.currentUser !== null && this.SYNC_COLLECTIONS) {
fb.writeCollections(
@@ -178,16 +161,35 @@ export default {
collection: this.$data.requestData.collectionIndex,
}
this.$store.commit("postwoman/saveRequestAs", {
request: requestUpdated,
collectionIndex: this.$data.requestData.collectionIndex,
folderName: this.$data.requestData.folderName,
requestIndex: this.$data.requestData.requestIndex,
flag: "rest",
})
if (this.$data.collectionsType.type === "my-collections") {
this.$store.commit("postwoman/saveRequestAs", {
request: requestUpdated,
collectionIndex: this.$data.requestData.collectionIndex,
folderName: this.$data.requestData.folderName,
requestIndex: this.$data.requestData.requestIndex,
flag: "rest",
})
this.syncCollections()
} else {
if (this.$data.requestData.requestIndex) {
team_utils.overwriteRequestTeams(
this.$apollo,
JSON.stringify(requestUpdated),
requestUpdated.name,
this.$data.requestData.requestIndex
)
} else {
team_utils.saveRequestAsTeams(
this.$apollo,
JSON.stringify(requestUpdated),
requestUpdated.name,
this.$data.collectionsType.selectedTeam.id,
this.$data.requestData.collectionIndex
)
}
}
this.hideModal()
this.syncCollections()
},
hideModal() {
this.$emit("hide-modal")
@@ -195,12 +197,12 @@ export default {
},
}
function getFolderNames(folders, namesList) {
function getFolderNames(folders, namesList, folderName = "") {
if (folders.length) {
folders.forEach((folder) => {
namesList.push(folder.name)
namesList.push(folderName + folder.name)
if (folder.folders && folder.folders.length) {
getFolderNames(folder.folders, namesList)
getFolderNames(folder.folders, namesList, folder.name + "/")
}
})
}