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:
@@ -39,10 +39,12 @@
|
||||
<script>
|
||||
import { fb } from "~/helpers/fb"
|
||||
import { getSettingSubject } from "~/newstore/settings"
|
||||
import team_utils from "~/helpers/teams/utils"
|
||||
|
||||
export default {
|
||||
props: {
|
||||
show: Boolean,
|
||||
collectionsType: Object,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@@ -68,12 +70,38 @@ export default {
|
||||
this.$toast.info(this.$t("invalid_collection_name"))
|
||||
return
|
||||
}
|
||||
this.$store.commit("postwoman/addNewCollection", {
|
||||
name: this.$data.name,
|
||||
flag: "rest",
|
||||
})
|
||||
this.$emit("hide-modal")
|
||||
this.syncCollections()
|
||||
if (this.collectionsType.type == "my-collections") {
|
||||
this.$store.commit("postwoman/addNewCollection", {
|
||||
name: this.$data.name,
|
||||
flag: "rest",
|
||||
})
|
||||
this.syncCollections()
|
||||
} else if (this.collectionsType.type == "team-collections") {
|
||||
if (this.collectionsType.selectedTeam.myRole != "VIEWER") {
|
||||
team_utils
|
||||
.createNewRootCollection(
|
||||
this.$apollo,
|
||||
this.$data.name,
|
||||
this.collectionsType.selectedTeam.id
|
||||
)
|
||||
.then((data) => {
|
||||
// Result
|
||||
this.$toast.success(this.$t("collection_added"), {
|
||||
icon: "done",
|
||||
})
|
||||
console.log(data)
|
||||
this.$emit("update-team-collections")
|
||||
})
|
||||
.catch((error) => {
|
||||
// Error
|
||||
this.$toast.error(this.$t("error_occurred"), {
|
||||
icon: "done",
|
||||
})
|
||||
console.error(error)
|
||||
})
|
||||
}
|
||||
}
|
||||
this.hideModal()
|
||||
},
|
||||
hideModal() {
|
||||
this.$emit("hide-modal")
|
||||
|
||||
63
components/collections/ChooseType.vue
Normal file
63
components/collections/ChooseType.vue
Normal file
@@ -0,0 +1,63 @@
|
||||
<template>
|
||||
<div v-if="show">
|
||||
<SmartTabs styles="m-4" :id="'collections_tab'" v-on:tab-changed="updateCollectionsType">
|
||||
<SmartTab :id="'my-collections'" :label="'My Collections'" :selected="true"> </SmartTab>
|
||||
<SmartTab :id="'team-collections'" :label="'Team Collections'">
|
||||
<ul>
|
||||
<li>
|
||||
<span class="select-wrapper">
|
||||
<select
|
||||
type="text"
|
||||
id="team"
|
||||
class="team"
|
||||
autofocus
|
||||
@change="
|
||||
collectionsType.selectedTeam = myTeams[$event.target.value]
|
||||
$emit('update-team-collections')
|
||||
"
|
||||
>
|
||||
<option :key="undefined" :value="undefined" hidden disabled selected>
|
||||
Select team
|
||||
</option>
|
||||
<option v-for="(team, index) in myTeams" :key="index" :value="index">
|
||||
{{ team.name }}
|
||||
</option>
|
||||
</select>
|
||||
</span>
|
||||
</li>
|
||||
</ul>
|
||||
</SmartTab>
|
||||
</SmartTabs>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import gql from "graphql-tag"
|
||||
|
||||
export default {
|
||||
props: {
|
||||
collectionsType: Object,
|
||||
show: Boolean,
|
||||
},
|
||||
apollo: {
|
||||
myTeams: {
|
||||
query: gql`
|
||||
query GetMyTeams {
|
||||
myTeams {
|
||||
id
|
||||
name
|
||||
myRole
|
||||
}
|
||||
}
|
||||
`,
|
||||
pollInterval: 10000,
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
updateCollectionsType(tabID) {
|
||||
this.collectionsType.type = tabID
|
||||
this.$emit("update-team-collections")
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
@@ -13,7 +13,7 @@
|
||||
<i class="material-icons" v-show="!showChildren && !isFiltered">arrow_right</i>
|
||||
<i class="material-icons" v-show="showChildren || isFiltered">arrow_drop_down</i>
|
||||
<i class="material-icons">folder</i>
|
||||
<span>{{ collection.name }}</span>
|
||||
<span>{{ collection.name ? collection.name : collection.title }}</span>
|
||||
</button>
|
||||
<div>
|
||||
<button
|
||||
@@ -32,7 +32,31 @@
|
||||
>
|
||||
<i class="material-icons">check_box</i>
|
||||
</button>
|
||||
<v-popover>
|
||||
<div v-if="collectionsType.type !== 'my-collections' && showChildren">
|
||||
<button
|
||||
class="icon"
|
||||
v-if="cursor !== ''"
|
||||
@click="
|
||||
cursor = prevCursor
|
||||
pageNo -= 1
|
||||
"
|
||||
>
|
||||
Prev
|
||||
</button>
|
||||
<span v-if="cursor !== '' || (requests && requests.length === 10)">{{ pageNo }}</span>
|
||||
<button
|
||||
class="icon"
|
||||
v-if="requests && requests.length === 10"
|
||||
@click="
|
||||
prevCursor = cursor
|
||||
cursor = requests[requests.length - 1].id
|
||||
pageNo += 1
|
||||
"
|
||||
>
|
||||
Next
|
||||
</button>
|
||||
</div>
|
||||
<v-popover v-if="!saveRequest">
|
||||
<button class="tooltip-target icon" v-tooltip.left="$t('more')">
|
||||
<i class="material-icons">more_vert</i>
|
||||
</button>
|
||||
@@ -48,13 +72,43 @@
|
||||
</button>
|
||||
</div>
|
||||
<div>
|
||||
<button class="icon" @click="$emit('edit-collection')" v-close-popover>
|
||||
<button
|
||||
v-if="
|
||||
collectionsType.type == 'team-collections' &&
|
||||
collectionsType.selectedTeam.myRole == 'VIEWER'
|
||||
"
|
||||
class="icon"
|
||||
@click="$emit('edit-collection')"
|
||||
v-close-popover
|
||||
disabled
|
||||
>
|
||||
<i class="material-icons">create</i>
|
||||
<div v-tooltip.left="$t('disable_new_collection')">
|
||||
<span>{{ $t("edit") }}</span>
|
||||
</div>
|
||||
</button>
|
||||
<button v-else class="icon" @click="$emit('edit-collection')" v-close-popover>
|
||||
<i class="material-icons">create</i>
|
||||
<span>{{ $t("edit") }}</span>
|
||||
</button>
|
||||
</div>
|
||||
<div>
|
||||
<button class="icon" @click="confirmRemove = true" v-close-popover>
|
||||
<button
|
||||
v-if="
|
||||
collectionsType.type == 'team-collections' &&
|
||||
collectionsType.selectedTeam.myRole == 'VIEWER'
|
||||
"
|
||||
class="icon"
|
||||
@click="confirmRemove = true"
|
||||
v-close-popover
|
||||
disabled
|
||||
>
|
||||
<i class="material-icons">add</i>
|
||||
<div v-tooltip.left="$t('disable_new_collection')">
|
||||
<span>{{ $t("delete") }}</span>
|
||||
</div>
|
||||
</button>
|
||||
<button v-else class="icon" @click="confirmRemove = true" v-close-popover>
|
||||
<i class="material-icons">delete</i>
|
||||
<span>{{ $t("delete") }}</span>
|
||||
</button>
|
||||
@@ -66,8 +120,10 @@
|
||||
<div v-show="showChildren || isFiltered">
|
||||
<ul class="flex-col">
|
||||
<li
|
||||
v-for="(folder, index) in collection.folders"
|
||||
:key="folder.name"
|
||||
v-for="(folder, index) in collectionsType.type === 'my-collections'
|
||||
? collection.folders
|
||||
: folders"
|
||||
:key="folder.name ? folder.name : folder.title"
|
||||
class="ml-8 border-l border-brdColor"
|
||||
>
|
||||
<CollectionsFolder
|
||||
@@ -76,33 +132,62 @@
|
||||
:folder-path="`${collectionIndex}/${index}`"
|
||||
:collection-index="collectionIndex"
|
||||
:doc="doc"
|
||||
:saveRequest="saveRequest"
|
||||
:collectionsType="collectionsType"
|
||||
:isFiltered="isFiltered"
|
||||
@add-folder="$emit('add-folder', $event)"
|
||||
@edit-folder="$emit('edit-folder', $event)"
|
||||
@edit-request="$emit('edit-request', $event)"
|
||||
@update-team-collections="$emit('update-team-collections')"
|
||||
@select-folder="
|
||||
$emit('select-folder', {
|
||||
name:
|
||||
(collectionsType.type == 'my-collections' ? folder.name : folder.title) +
|
||||
'/' +
|
||||
$event.name,
|
||||
id: $event.id,
|
||||
reqIdx: $event.reqIdx,
|
||||
})
|
||||
"
|
||||
/>
|
||||
</li>
|
||||
</ul>
|
||||
<ul class="flex-col">
|
||||
<li
|
||||
v-for="(request, index) in collection.requests"
|
||||
v-for="(request, index) in collectionsType.type === 'my-collections'
|
||||
? collection.requests
|
||||
: requests"
|
||||
:key="index"
|
||||
class="ml-8 border-l border-brdColor"
|
||||
>
|
||||
<CollectionsRequest
|
||||
:request="request"
|
||||
:request="
|
||||
collectionsType.type === 'my-collections' ? request : JSON.parse(request.request)
|
||||
"
|
||||
:collection-index="collectionIndex"
|
||||
:folder-index="-1"
|
||||
:folder-name="collection.name"
|
||||
:request-index="index"
|
||||
:request-index="collectionsType.type === 'my-collections' ? index : request.id"
|
||||
:doc="doc"
|
||||
@edit-request="$emit('edit-request', $event)"
|
||||
:saveRequest="saveRequest"
|
||||
:collectionsType="collectionsType"
|
||||
@edit-request="editRequest($event)"
|
||||
@select-request="
|
||||
$emit('select-folder', {
|
||||
name: $event.name,
|
||||
id: collection.id,
|
||||
reqIdx: $event.idx,
|
||||
})
|
||||
"
|
||||
/>
|
||||
</li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li
|
||||
v-if="collection.folders.length === 0 && collection.requests.length === 0"
|
||||
v-if="
|
||||
(folders == undefined || folders.length === 0) &&
|
||||
(requests == undefined || requests.length === 0)
|
||||
"
|
||||
class="flex ml-8 border-l border-brdColor"
|
||||
>
|
||||
<p class="info">
|
||||
@@ -123,6 +208,7 @@
|
||||
<script>
|
||||
import { fb } from "~/helpers/fb"
|
||||
import { getSettingSubject } from "~/newstore/settings"
|
||||
import gql from "graphql-tag"
|
||||
|
||||
export default {
|
||||
props: {
|
||||
@@ -131,6 +217,8 @@ export default {
|
||||
doc: Boolean,
|
||||
isFiltered: Boolean,
|
||||
selected: Boolean,
|
||||
saveRequest: Boolean,
|
||||
collectionsType: Object,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@@ -138,6 +226,9 @@ export default {
|
||||
dragging: false,
|
||||
selectedFolder: {},
|
||||
confirmRemove: false,
|
||||
prevCursor: "",
|
||||
cursor: "",
|
||||
pageNo: 0,
|
||||
}
|
||||
},
|
||||
subscriptions() {
|
||||
@@ -145,7 +236,237 @@ export default {
|
||||
SYNC_COLLECTIONS: getSettingSubject("syncCollections"),
|
||||
}
|
||||
},
|
||||
apollo: {
|
||||
requests: {
|
||||
query: gql`
|
||||
query getCollectionRequests($collectionID: String!, $cursor: String) {
|
||||
requestsInCollection(collectionID: $collectionID, cursor: $cursor) {
|
||||
id
|
||||
title
|
||||
request
|
||||
}
|
||||
}
|
||||
`,
|
||||
subscribeToMore: [
|
||||
{
|
||||
document: gql`
|
||||
subscription teamRequestAdded($teamID: String!) {
|
||||
teamRequestAdded(teamID: $teamID) {
|
||||
id
|
||||
request
|
||||
title
|
||||
collection {
|
||||
id
|
||||
title
|
||||
}
|
||||
}
|
||||
}
|
||||
`,
|
||||
variables() {
|
||||
return { teamID: this.$props.collectionsType.selectedTeam.id }
|
||||
},
|
||||
skip() {
|
||||
return this.$props.collectionsType.selectedTeam === undefined
|
||||
},
|
||||
updateQuery(previousResult, { subscriptionData }) {
|
||||
if (
|
||||
subscriptionData.data.teamRequestAdded.collection.id === this.$props.collection.id
|
||||
) {
|
||||
previousResult.requestsInCollection.push({
|
||||
id: subscriptionData.data.teamRequestAdded.id,
|
||||
request: subscriptionData.data.teamRequestAdded.request,
|
||||
title: subscriptionData.data.teamRequestAdded.title,
|
||||
__typename: subscriptionData.data.teamRequestAdded.__typename,
|
||||
})
|
||||
return previousResult
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
document: gql`
|
||||
subscription teamRequestUpdated($teamID: String!) {
|
||||
teamRequestUpdated(teamID: $teamID) {
|
||||
id
|
||||
request
|
||||
title
|
||||
collection {
|
||||
id
|
||||
title
|
||||
}
|
||||
}
|
||||
}
|
||||
`,
|
||||
variables() {
|
||||
return { teamID: this.$props.collectionsType.selectedTeam.id }
|
||||
},
|
||||
skip() {
|
||||
return this.$props.collectionsType.selectedTeam === undefined
|
||||
},
|
||||
updateQuery(previousResult, { subscriptionData }) {
|
||||
if (
|
||||
subscriptionData.data.teamRequestUpdated.collection.id === this.$props.collection.id
|
||||
) {
|
||||
const index = previousResult.requestsInCollection.findIndex(
|
||||
(x) => x.id === subscriptionData.data.teamRequestUpdated.id
|
||||
)
|
||||
previousResult.requestsInCollection[index].title =
|
||||
subscriptionData.data.teamRequestUpdated.title
|
||||
previousResult.requestsInCollection[index].request =
|
||||
subscriptionData.data.teamRequestUpdated.request
|
||||
return previousResult
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
document: gql`
|
||||
subscription teamRequestDeleted($teamID: String!) {
|
||||
teamRequestDeleted(teamID: $teamID)
|
||||
}
|
||||
`,
|
||||
variables() {
|
||||
return { teamID: this.$props.collectionsType.selectedTeam.id }
|
||||
},
|
||||
skip() {
|
||||
return this.$props.collectionsType.selectedTeam === undefined
|
||||
},
|
||||
updateQuery(previousResult, { subscriptionData }) {
|
||||
const index = previousResult.requestsInCollection.findIndex(
|
||||
(x) => x.id === subscriptionData.data.teamRequestDeleted
|
||||
)
|
||||
if (index !== -1) previousResult.requestsInCollection.splice(index, 1)
|
||||
return previousResult
|
||||
},
|
||||
},
|
||||
],
|
||||
variables() {
|
||||
return {
|
||||
collectionID: this.$props.collection.id,
|
||||
cursor: this.$data.cursor,
|
||||
}
|
||||
},
|
||||
update: (response) => response.requestsInCollection,
|
||||
skip() {
|
||||
return this.$props.collection.id === undefined
|
||||
},
|
||||
fetchPolicy: "no-cache",
|
||||
},
|
||||
folders: {
|
||||
query: gql`
|
||||
query getCollectionChildren($collectionID: String!) {
|
||||
collection(collectionID: $collectionID) {
|
||||
children {
|
||||
id
|
||||
title
|
||||
}
|
||||
}
|
||||
}
|
||||
`,
|
||||
subscribeToMore: [
|
||||
{
|
||||
document: gql`
|
||||
subscription teamCollectionAdded($teamID: String!) {
|
||||
teamCollectionAdded(teamID: $teamID) {
|
||||
id
|
||||
title
|
||||
parent {
|
||||
id
|
||||
title
|
||||
}
|
||||
}
|
||||
}
|
||||
`,
|
||||
variables() {
|
||||
return { teamID: this.$props.collectionsType.selectedTeam.id }
|
||||
},
|
||||
skip() {
|
||||
return this.$props.collectionsType.selectedTeam === undefined
|
||||
},
|
||||
updateQuery(previousResult, { subscriptionData }) {
|
||||
if (subscriptionData.data.teamCollectionAdded.parent.id === this.$props.collection.id) {
|
||||
previousResult.collection.children.push({
|
||||
id: subscriptionData.data.teamCollectionAdded.id,
|
||||
title: subscriptionData.data.teamCollectionAdded.title,
|
||||
__typename: subscriptionData.data.teamCollectionAdded.__typename,
|
||||
})
|
||||
return previousResult
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
document: gql`
|
||||
subscription teamCollectionUpdated($teamID: String!) {
|
||||
teamCollectionUpdated(teamID: $teamID) {
|
||||
id
|
||||
title
|
||||
parent {
|
||||
id
|
||||
title
|
||||
}
|
||||
}
|
||||
}
|
||||
`,
|
||||
variables() {
|
||||
return { teamID: this.$props.collectionsType.selectedTeam.id }
|
||||
},
|
||||
skip() {
|
||||
return this.$props.collectionsType.selectedTeam === undefined
|
||||
},
|
||||
updateQuery(previousResult, { subscriptionData }) {
|
||||
if (
|
||||
subscriptionData.data.teamCollectionUpdated.parent.id === this.$props.collection.id
|
||||
) {
|
||||
const index = previousResult.collection.children.findIndex(
|
||||
(x) => x.id === subscriptionData.data.teamCollectionUpdated.id
|
||||
)
|
||||
previousResult.collection.children[index].title =
|
||||
subscriptionData.data.teamCollectionUpdated.title
|
||||
return previousResult
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
document: gql`
|
||||
subscription teamCollectionRemoved($teamID: String!) {
|
||||
teamCollectionRemoved(teamID: $teamID)
|
||||
}
|
||||
`,
|
||||
variables() {
|
||||
return { teamID: this.$props.collectionsType.selectedTeam.id }
|
||||
},
|
||||
skip() {
|
||||
return this.$props.collectionsType.selectedTeam === undefined
|
||||
},
|
||||
updateQuery(previousResult, { subscriptionData }) {
|
||||
const index = previousResult.collection.children.findIndex(
|
||||
(x) => x.id === subscriptionData.data.teamCollectionRemoved
|
||||
)
|
||||
if (index !== -1) previousResult.collection.children.splice(index, 1)
|
||||
return previousResult
|
||||
},
|
||||
},
|
||||
],
|
||||
variables() {
|
||||
return {
|
||||
collectionID: this.$props.collection.id,
|
||||
}
|
||||
},
|
||||
update: (response) => response.collection.children,
|
||||
skip() {
|
||||
return this.$props.collection.id === undefined
|
||||
},
|
||||
fetchPolicy: "no-cache",
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
editRequest(event) {
|
||||
this.$emit("edit-request", event)
|
||||
if (this.$props.saveRequest)
|
||||
this.$emit("select-folder", {
|
||||
name: this.$data.collection.name,
|
||||
id: this.$data.collection.id,
|
||||
reqIdx: event.requestIndex,
|
||||
})
|
||||
},
|
||||
syncCollections() {
|
||||
if (fb.currentUser !== null && this.SYNC_COLLECTIONS) {
|
||||
fb.writeCollections(
|
||||
@@ -155,17 +476,54 @@ export default {
|
||||
}
|
||||
},
|
||||
toggleShowChildren() {
|
||||
if (this.$props.saveRequest)
|
||||
this.$emit("select-folder", { name: "", id: this.$props.collection.id, reqIdx: "" })
|
||||
|
||||
this.showChildren = !this.showChildren
|
||||
},
|
||||
removeCollection() {
|
||||
this.$store.commit("postwoman/removeCollection", {
|
||||
collectionIndex: this.collectionIndex,
|
||||
flag: "rest",
|
||||
})
|
||||
this.$toast.error(this.$t("deleted"), {
|
||||
icon: "delete",
|
||||
})
|
||||
this.syncCollections()
|
||||
if (this.collectionsType.type == "my-collections") {
|
||||
this.$store.commit("postwoman/removeCollection", {
|
||||
collectionIndex: this.collectionIndex,
|
||||
flag: "rest",
|
||||
})
|
||||
this.$toast.error(this.$t("deleted"), {
|
||||
icon: "delete",
|
||||
})
|
||||
this.syncCollections()
|
||||
} else if (this.collectionsType.type == "team-collections") {
|
||||
if (this.collectionsType.selectedTeam.myRole != "VIEWER") {
|
||||
this.$apollo
|
||||
.mutate({
|
||||
// Query
|
||||
mutation: gql`
|
||||
mutation($collectionID: String!) {
|
||||
deleteCollection(collectionID: $collectionID)
|
||||
}
|
||||
`,
|
||||
// Parameters
|
||||
variables: {
|
||||
collectionID: this.collection.id,
|
||||
},
|
||||
})
|
||||
.then((data) => {
|
||||
// Result
|
||||
this.$toast.success(this.$t("deleted"), {
|
||||
icon: "delete",
|
||||
})
|
||||
console.log(data)
|
||||
this.$emit("update-team-collections")
|
||||
})
|
||||
.catch((error) => {
|
||||
// Error
|
||||
this.$toast.error(this.$t("error_occurred"), {
|
||||
icon: "done",
|
||||
})
|
||||
console.error(error)
|
||||
})
|
||||
}
|
||||
}
|
||||
this.confirmRemove = false
|
||||
},
|
||||
dropEvent({ dataTransfer }) {
|
||||
this.dragging = !this.dragging
|
||||
|
||||
@@ -39,12 +39,14 @@
|
||||
<script>
|
||||
import { fb } from "~/helpers/fb"
|
||||
import { getSettingSubject } from "~/newstore/settings"
|
||||
import team_utils from "~/helpers/teams/utils"
|
||||
|
||||
export default {
|
||||
props: {
|
||||
show: Boolean,
|
||||
editingCollection: Object,
|
||||
editingCollectionIndex: Number,
|
||||
collectionsType: Object,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@@ -70,20 +72,42 @@ export default {
|
||||
this.$toast.info(this.$t("invalid_collection_name"))
|
||||
return
|
||||
}
|
||||
const collectionUpdated = {
|
||||
...this.$props.editingCollection,
|
||||
name: this.$data.name,
|
||||
if (this.collectionsType.type == "my-collections") {
|
||||
const collectionUpdated = {
|
||||
...this.$props.editingCollection,
|
||||
name: this.$data.name,
|
||||
}
|
||||
this.$store.commit("postwoman/editCollection", {
|
||||
collection: collectionUpdated,
|
||||
collectionIndex: this.$props.editingCollectionIndex,
|
||||
flag: "rest",
|
||||
})
|
||||
this.syncCollections()
|
||||
} else if (this.collectionsType.type == "team-collections") {
|
||||
if (this.collectionsType.selectedTeam.myRole != "VIEWER") {
|
||||
team_utils
|
||||
.renameCollection(this.$apollo, this.$data.name, this.$props.editingCollection.id)
|
||||
.then((data) => {
|
||||
// Result
|
||||
this.$toast.success("Collection Renamed", {
|
||||
icon: "done",
|
||||
})
|
||||
this.$emit("update-team-collections")
|
||||
})
|
||||
.catch((error) => {
|
||||
// Error
|
||||
this.$toast.error(this.$t("error_occurred"), {
|
||||
icon: "done",
|
||||
})
|
||||
console.error(error)
|
||||
})
|
||||
}
|
||||
}
|
||||
this.$store.commit("postwoman/editCollection", {
|
||||
collection: collectionUpdated,
|
||||
collectionIndex: this.$props.editingCollectionIndex,
|
||||
flag: "rest",
|
||||
})
|
||||
this.$emit("hide-modal")
|
||||
this.syncCollections()
|
||||
this.hideModal()
|
||||
},
|
||||
hideModal() {
|
||||
this.$emit("hide-modal")
|
||||
this.$data.name = undefined
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
<script>
|
||||
import { fb } from "~/helpers/fb"
|
||||
import { getSettingSubject } from "~/newstore/settings"
|
||||
import team_utils from "~/helpers/teams/utils"
|
||||
|
||||
export default {
|
||||
props: {
|
||||
@@ -46,6 +47,7 @@ export default {
|
||||
collectionIndex: Number,
|
||||
folder: Object,
|
||||
folderIndex: Number,
|
||||
collectionsType: Object,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@@ -67,15 +69,37 @@ export default {
|
||||
}
|
||||
},
|
||||
editFolder() {
|
||||
this.$store.commit("postwoman/editFolder", {
|
||||
collectionIndex: this.$props.collectionIndex,
|
||||
folder: { ...this.$props.folder, name: this.$data.name },
|
||||
folderIndex: this.$props.folderIndex,
|
||||
folderName: this.$props.folder.name,
|
||||
flag: "rest",
|
||||
})
|
||||
if (this.collectionsType.type == "my-collections") {
|
||||
this.$store.commit("postwoman/editFolder", {
|
||||
collectionIndex: this.$props.collectionIndex,
|
||||
folder: { ...this.$props.folder, name: this.$data.name },
|
||||
folderIndex: this.$props.folderIndex,
|
||||
folderName: this.$props.folder.name,
|
||||
flag: "rest",
|
||||
})
|
||||
this.syncCollections()
|
||||
} else if (this.collectionsType.type == "team-collections") {
|
||||
if (this.collectionsType.selectedTeam.myRole != "VIEWER") {
|
||||
team_utils
|
||||
.renameCollection(this.$apollo, this.$data.name, this.folder.id)
|
||||
.then((data) => {
|
||||
// Result
|
||||
this.$toast.success(this.$t("folder_renamed"), {
|
||||
icon: "done",
|
||||
})
|
||||
this.$emit("update-team-collections")
|
||||
})
|
||||
.catch((error) => {
|
||||
// Error
|
||||
this.$toast.error(this.$t("error_occurred"), {
|
||||
icon: "done",
|
||||
})
|
||||
console.error(error)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
this.hideModal()
|
||||
this.syncCollections()
|
||||
},
|
||||
hideModal() {
|
||||
this.$emit("hide-modal")
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
<script>
|
||||
import { fb } from "~/helpers/fb"
|
||||
import { getSettingSubject } from "~/newstore/settings"
|
||||
import team_utils from "~/helpers/teams/utils"
|
||||
|
||||
export default {
|
||||
props: {
|
||||
@@ -47,7 +48,8 @@ export default {
|
||||
folderIndex: Number,
|
||||
folderName: String,
|
||||
request: Object,
|
||||
requestIndex: Number,
|
||||
requestIndex: [String, Number],
|
||||
collectionsType: Object,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@@ -76,17 +78,39 @@ export default {
|
||||
name: this.$data.requestUpdateData.name || this.$props.request.name,
|
||||
}
|
||||
|
||||
this.$store.commit("postwoman/editRequest", {
|
||||
requestCollectionIndex: this.$props.collectionIndex,
|
||||
requestFolderName: this.$props.folderName,
|
||||
requestFolderIndex: this.$props.folderIndex,
|
||||
requestNew: requestUpdated,
|
||||
requestIndex: this.$props.requestIndex,
|
||||
flag: "rest",
|
||||
})
|
||||
if (this.$props.collectionsType.type == "my-collections") {
|
||||
this.$store.commit("postwoman/editRequest", {
|
||||
requestCollectionIndex: this.$props.collectionIndex,
|
||||
requestFolderName: this.$props.folderName,
|
||||
requestFolderIndex: this.$props.folderIndex,
|
||||
requestNew: requestUpdated,
|
||||
requestIndex: this.$props.requestIndex,
|
||||
flag: "rest",
|
||||
})
|
||||
this.syncCollections()
|
||||
} else if (this.$props.collectionsType.type == "team-collections") {
|
||||
if (this.collectionsType.selectedTeam.myRole != "VIEWER") {
|
||||
let requestName = this.$data.requestUpdateData.name || this.$props.request.name
|
||||
team_utils
|
||||
.updateRequest(this.$apollo, requestUpdated, requestName, this.$props.requestIndex)
|
||||
.then((data) => {
|
||||
// Result
|
||||
this.$toast.success("Request Renamed", {
|
||||
icon: "done",
|
||||
})
|
||||
this.$emit("update-team-collections")
|
||||
})
|
||||
.catch((error) => {
|
||||
// Error
|
||||
this.$toast.error(this.$t("error_occurred"), {
|
||||
icon: "done",
|
||||
})
|
||||
console.error(error)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
this.hideModal()
|
||||
this.syncCollections()
|
||||
},
|
||||
hideModal() {
|
||||
this.$emit("hide-modal")
|
||||
|
||||
@@ -14,10 +14,34 @@
|
||||
<i class="material-icons" v-show="!showChildren && !isFiltered">arrow_right</i>
|
||||
<i class="material-icons" v-show="showChildren || isFiltered">arrow_drop_down</i>
|
||||
<i class="material-icons">folder_open</i>
|
||||
<span>{{ folder.name }}</span>
|
||||
<span>{{ folder.name ? folder.name : folder.title }}</span>
|
||||
</button>
|
||||
</div>
|
||||
<v-popover>
|
||||
<div v-if="collectionsType.type !== 'my-collections' && showChildren">
|
||||
<button
|
||||
class="icon"
|
||||
v-if="cursor !== ''"
|
||||
@click="
|
||||
cursor = prevCursor
|
||||
pageNo -= 1
|
||||
"
|
||||
>
|
||||
Prev
|
||||
</button>
|
||||
<span v-if="cursor !== '' || (requests && requests.length === 10)">{{ pageNo }}</span>
|
||||
<button
|
||||
class="icon"
|
||||
v-if="requests && requests.length === 10"
|
||||
@click="
|
||||
prevCursor = cursor
|
||||
cursor = requests[requests.length - 1].id
|
||||
pageNo += 1
|
||||
"
|
||||
>
|
||||
Next
|
||||
</button>
|
||||
</div>
|
||||
<v-popover v-if="!saveRequest">
|
||||
<button class="tooltip-target icon" v-tooltip.left="$t('more')">
|
||||
<i class="material-icons">more_vert</i>
|
||||
</button>
|
||||
@@ -52,9 +76,9 @@
|
||||
</v-popover>
|
||||
</div>
|
||||
<div v-show="showChildren || isFiltered">
|
||||
<ul v-if="folder.folders && folder.folders.length" class="flex-col">
|
||||
<ul v-if="folders && folders.length" class="flex-col">
|
||||
<li
|
||||
v-for="(subFolder, subFolderIndex) in folder.folders"
|
||||
v-for="(subFolder, subFolderIndex) in folders"
|
||||
:key="subFolder.name"
|
||||
class="ml-8 border-l border-brdColor"
|
||||
>
|
||||
@@ -63,38 +87,52 @@
|
||||
:folder-index="subFolderIndex"
|
||||
:collection-index="collectionIndex"
|
||||
:doc="doc"
|
||||
:saveRequest="saveRequest"
|
||||
:collectionsType="collectionsType"
|
||||
:folder-path="`${folderPath}/${subFolderIndex}`"
|
||||
@add-folder="$emit('add-folder', $event)"
|
||||
@edit-folder="$emit('edit-folder', $event)"
|
||||
@edit-request="$emit('edit-request', $event)"
|
||||
@update-team-collections="$emit('update-team-collections')"
|
||||
@select-folder="
|
||||
$emit('select-folder', {
|
||||
name: subFolder.name + '/' + $event.name,
|
||||
id: subFolder.id,
|
||||
reqIdx: $event.reqIdx,
|
||||
})
|
||||
"
|
||||
/>
|
||||
</li>
|
||||
</ul>
|
||||
<ul class="flex-col">
|
||||
<li
|
||||
v-for="(request, index) in folder.requests"
|
||||
v-for="(request, index) in requests"
|
||||
:key="index"
|
||||
class="flex ml-8 border-l border-brdColor"
|
||||
>
|
||||
<CollectionsRequest
|
||||
:request="request"
|
||||
:request="
|
||||
collectionsType.type == 'my-collections' ? request : JSON.parse(request.request)
|
||||
"
|
||||
:collection-index="collectionIndex"
|
||||
:folder-index="folderIndex"
|
||||
:folder-name="folder.name"
|
||||
:request-index="index"
|
||||
:request-index="collectionsType.type === 'my-collections' ? index : request.id"
|
||||
:doc="doc"
|
||||
:saveRequest="saveRequest"
|
||||
:collectionsType="collectionsType"
|
||||
@edit-request="$emit('edit-request', $event)"
|
||||
@select-request="
|
||||
$emit('select-folder', {
|
||||
name: $event.name,
|
||||
id: folder.id,
|
||||
reqIdx: $event.idx,
|
||||
})
|
||||
"
|
||||
/>
|
||||
</li>
|
||||
</ul>
|
||||
<ul
|
||||
v-if="
|
||||
folder.folders &&
|
||||
folder.folders.length === 0 &&
|
||||
folder.requests &&
|
||||
folder.requests.length === 0
|
||||
"
|
||||
>
|
||||
<ul v-if="folders && folders.length === 0 && requests && requests.length === 0">
|
||||
<li class="flex ml-8 border-l border-brdColor">
|
||||
<p class="info"><i class="material-icons">not_interested</i> {{ $t("folder_empty") }}</p>
|
||||
</li>
|
||||
@@ -112,6 +150,8 @@
|
||||
<script>
|
||||
import { fb } from "~/helpers/fb"
|
||||
import { getSettingSubject } from "~/newstore/settings"
|
||||
import team_utils from "~/helpers/teams/utils"
|
||||
import gql from "graphql-tag"
|
||||
|
||||
export default {
|
||||
name: "folder",
|
||||
@@ -121,13 +161,18 @@ export default {
|
||||
collectionIndex: Number,
|
||||
folderPath: String,
|
||||
doc: Boolean,
|
||||
saveRequest: Boolean,
|
||||
isFiltered: Boolean,
|
||||
collectionsType: Object,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
showChildren: false,
|
||||
dragging: false,
|
||||
confirmRemove: false,
|
||||
prevCursor: "",
|
||||
cursor: "",
|
||||
pageNo: 0,
|
||||
}
|
||||
},
|
||||
subscriptions() {
|
||||
@@ -135,6 +180,221 @@ export default {
|
||||
SYNC_COLLECTIONS: getSettingSubject("syncCollections"),
|
||||
}
|
||||
},
|
||||
apollo: {
|
||||
folders: {
|
||||
query: gql`
|
||||
query getCollectionChildren($collectionID: String!) {
|
||||
collection(collectionID: $collectionID) {
|
||||
children {
|
||||
id
|
||||
title
|
||||
}
|
||||
}
|
||||
}
|
||||
`,
|
||||
subscribeToMore: [
|
||||
{
|
||||
document: gql`
|
||||
subscription teamCollectionAdded($teamID: String!) {
|
||||
teamCollectionAdded(teamID: $teamID) {
|
||||
id
|
||||
title
|
||||
parent {
|
||||
id
|
||||
title
|
||||
}
|
||||
}
|
||||
}
|
||||
`,
|
||||
variables() {
|
||||
return { teamID: this.$props.collectionsType.selectedTeam.id }
|
||||
},
|
||||
skip() {
|
||||
return this.$props.collectionsType.selectedTeam === undefined
|
||||
},
|
||||
updateQuery(previousResult, { subscriptionData }) {
|
||||
if (subscriptionData.data.teamCollectionAdded.parent.id === this.$props.folder.id) {
|
||||
previousResult.collection.children.push({
|
||||
id: subscriptionData.data.teamCollectionAdded.id,
|
||||
title: subscriptionData.data.teamCollectionAdded.title,
|
||||
__typename: subscriptionData.data.teamCollectionAdded.__typename,
|
||||
})
|
||||
return previousResult
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
document: gql`
|
||||
subscription teamCollectionUpdated($teamID: String!) {
|
||||
teamCollectionUpdated(teamID: $teamID) {
|
||||
id
|
||||
title
|
||||
parent {
|
||||
id
|
||||
title
|
||||
}
|
||||
}
|
||||
}
|
||||
`,
|
||||
variables() {
|
||||
return { teamID: this.$props.collectionsType.selectedTeam.id }
|
||||
},
|
||||
skip() {
|
||||
return this.$props.collectionsType.selectedTeam === undefined
|
||||
},
|
||||
updateQuery(previousResult, { subscriptionData }) {
|
||||
if (subscriptionData.data.teamCollectionUpdated.parent.id === this.$props.folder.id) {
|
||||
const index = previousResult.collection.children.findIndex(
|
||||
(x) => x.id === subscriptionData.data.teamCollectionUpdated.id
|
||||
)
|
||||
previousResult.collection.children[index].title =
|
||||
subscriptionData.data.teamCollectionUpdated.title
|
||||
return previousResult
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
document: gql`
|
||||
subscription teamCollectionRemoved($teamID: String!) {
|
||||
teamCollectionRemoved(teamID: $teamID)
|
||||
}
|
||||
`,
|
||||
variables() {
|
||||
return { teamID: this.$props.collectionsType.selectedTeam.id }
|
||||
},
|
||||
skip() {
|
||||
return this.$props.collectionsType.selectedTeam === undefined
|
||||
},
|
||||
updateQuery(previousResult, { subscriptionData }) {
|
||||
const index = previousResult.collection.children.findIndex(
|
||||
(x) => x.id === subscriptionData.data.teamCollectionRemoved
|
||||
)
|
||||
if (index !== -1) previousResult.collection.children.splice(index, 1)
|
||||
return previousResult
|
||||
},
|
||||
},
|
||||
],
|
||||
variables() {
|
||||
return {
|
||||
collectionID: this.$props.folder.id,
|
||||
}
|
||||
},
|
||||
update: (response) => response.collection.children,
|
||||
skip() {
|
||||
return this.$props.collectionsType.selectedTeam === undefined
|
||||
},
|
||||
fetchPolicy: "no-cache",
|
||||
},
|
||||
requests: {
|
||||
query: gql`
|
||||
query getCollectionRequests($collectionID: String!, $cursor: String) {
|
||||
requestsInCollection(collectionID: $collectionID, cursor: $cursor) {
|
||||
id
|
||||
title
|
||||
request
|
||||
}
|
||||
}
|
||||
`,
|
||||
subscribeToMore: [
|
||||
{
|
||||
document: gql`
|
||||
subscription teamRequestAdded($teamID: String!) {
|
||||
teamRequestAdded(teamID: $teamID) {
|
||||
id
|
||||
request
|
||||
title
|
||||
collection {
|
||||
id
|
||||
title
|
||||
}
|
||||
}
|
||||
}
|
||||
`,
|
||||
variables() {
|
||||
return { teamID: this.$props.collectionsType.selectedTeam.id }
|
||||
},
|
||||
skip() {
|
||||
return this.$props.collectionsType.selectedTeam === undefined
|
||||
},
|
||||
updateQuery(previousResult, { subscriptionData }) {
|
||||
if (subscriptionData.data.teamRequestAdded.collection.id === this.$props.folder.id) {
|
||||
previousResult.requestsInCollection.push({
|
||||
id: subscriptionData.data.teamRequestAdded.id,
|
||||
request: subscriptionData.data.teamRequestAdded.request,
|
||||
title: subscriptionData.data.teamRequestAdded.title,
|
||||
__typename: subscriptionData.data.teamRequestAdded.__typename,
|
||||
})
|
||||
return previousResult
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
document: gql`
|
||||
subscription teamRequestUpdated($teamID: String!) {
|
||||
teamRequestUpdated(teamID: $teamID) {
|
||||
id
|
||||
request
|
||||
title
|
||||
collection {
|
||||
id
|
||||
title
|
||||
}
|
||||
}
|
||||
}
|
||||
`,
|
||||
variables() {
|
||||
return { teamID: this.$props.collectionsType.selectedTeam.id }
|
||||
},
|
||||
skip() {
|
||||
return this.$props.collectionsType.selectedTeam === undefined
|
||||
},
|
||||
updateQuery(previousResult, { subscriptionData }) {
|
||||
if (subscriptionData.data.teamRequestUpdated.collection.id === this.$props.folder.id) {
|
||||
const index = previousResult.requestsInCollection.findIndex(
|
||||
(x) => x.id === subscriptionData.data.teamRequestUpdated.id
|
||||
)
|
||||
previousResult.requestsInCollection[index].title =
|
||||
subscriptionData.data.teamRequestUpdated.title
|
||||
previousResult.requestsInCollection[index].request =
|
||||
subscriptionData.data.teamRequestUpdated.request
|
||||
return previousResult
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
document: gql`
|
||||
subscription teamRequestDeleted($teamID: String!) {
|
||||
teamRequestDeleted(teamID: $teamID)
|
||||
}
|
||||
`,
|
||||
variables() {
|
||||
return { teamID: this.$props.collectionsType.selectedTeam.id }
|
||||
},
|
||||
skip() {
|
||||
return this.$props.collectionsType.selectedTeam === undefined
|
||||
},
|
||||
updateQuery(previousResult, { subscriptionData }) {
|
||||
const index = previousResult.requestsInCollection.findIndex(
|
||||
(x) => x.id === subscriptionData.data.teamRequestDeleted
|
||||
)
|
||||
if (index !== -1) previousResult.requestsInCollection.splice(index, 1)
|
||||
return previousResult
|
||||
},
|
||||
},
|
||||
],
|
||||
variables() {
|
||||
return {
|
||||
collectionID: this.$props.folder.id,
|
||||
cursor: this.$data.cursor,
|
||||
}
|
||||
},
|
||||
update: (response) => response.requestsInCollection,
|
||||
skip() {
|
||||
return this.$props.collectionsType.selectedTeam === undefined
|
||||
},
|
||||
fetchPolicy: "no-cache",
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
syncCollections() {
|
||||
if (fb.currentUser !== null && this.SYNC_COLLECTIONS) {
|
||||
@@ -145,19 +405,45 @@ export default {
|
||||
}
|
||||
},
|
||||
toggleShowChildren() {
|
||||
if (this.$props.saveRequest)
|
||||
this.$emit("select-folder", { name: "", id: this.$props.folder.id, reqIdx: "" })
|
||||
this.showChildren = !this.showChildren
|
||||
},
|
||||
removeFolder() {
|
||||
this.$store.commit("postwoman/removeFolder", {
|
||||
collectionIndex: this.$props.collectionIndex,
|
||||
folderName: this.$props.folder.name,
|
||||
folderIndex: this.$props.folderIndex,
|
||||
flag: "rest",
|
||||
})
|
||||
this.syncCollections()
|
||||
this.$toast.error(this.$t("deleted"), {
|
||||
icon: "delete",
|
||||
})
|
||||
if (this.collectionsType.type == "my-collections") {
|
||||
this.$store.commit("postwoman/removeFolder", {
|
||||
collectionIndex: this.$props.collectionIndex,
|
||||
folderName: this.$props.folder.name,
|
||||
folderIndex: this.$props.folderIndex,
|
||||
flag: "rest",
|
||||
})
|
||||
this.syncCollections()
|
||||
this.$toast.error(this.$t("deleted"), {
|
||||
icon: "delete",
|
||||
})
|
||||
} else if (this.collectionsType.type == "team-collections") {
|
||||
if (this.collectionsType.selectedTeam.myRole != "VIEWER") {
|
||||
team_utils
|
||||
.deleteCollection(this.$apollo, this.folder.id)
|
||||
.then((data) => {
|
||||
// Result
|
||||
this.$toast.success(this.$t("deleted"), {
|
||||
icon: "delete",
|
||||
})
|
||||
console.log(data)
|
||||
this.$emit("update-team-collections")
|
||||
this.confirmRemove = false
|
||||
})
|
||||
.catch((error) => {
|
||||
// Error
|
||||
this.$toast.error(this.$t("error_occurred"), {
|
||||
icon: "done",
|
||||
})
|
||||
console.error(error)
|
||||
})
|
||||
this.$emit("update-team-collections")
|
||||
}
|
||||
}
|
||||
},
|
||||
dropEvent({ dataTransfer }) {
|
||||
this.dragging = !this.dragging
|
||||
|
||||
@@ -2,9 +2,17 @@
|
||||
<SmartModal v-if="show" @close="hideModal">
|
||||
<div slot="header">
|
||||
<div class="row-wrapper">
|
||||
<h3 class="title">{{ $t("import_export") }} {{ $t("collections") }}</h3>
|
||||
<h3 class="title">{{ $t(mode) }}</h3>
|
||||
<div>
|
||||
<v-popover>
|
||||
<button
|
||||
class="tooltip-target icon"
|
||||
v-if="mode != 'import_export'"
|
||||
@click="mode = 'import_export'"
|
||||
v-tooltip.left="$t('back')"
|
||||
>
|
||||
<i class="material-icons">arrow_left</i>
|
||||
</button>
|
||||
<v-popover v-if="mode == 'import_export' && collectionsType.type == 'my-collections'">
|
||||
<button class="tooltip-target icon" v-tooltip.left="$t('more')">
|
||||
<i class="material-icons">more_vert</i>
|
||||
</button>
|
||||
@@ -45,13 +53,18 @@
|
||||
</div>
|
||||
</div>
|
||||
<div slot="body" class="flex flex-col">
|
||||
<div class="flex flex-col items-start p-2">
|
||||
<div v-if="mode == 'import_export'" class="flex flex-col items-start p-2">
|
||||
<span
|
||||
v-tooltip="{
|
||||
content: !fb.currentUser ? $t('login_first') : $t('replace_current'),
|
||||
}"
|
||||
>
|
||||
<button :disabled="!fb.currentUser" class="icon" @click="syncCollections">
|
||||
<button
|
||||
:disabled="!fb.currentUser"
|
||||
v-if="collectionsType.type == 'my-collections'"
|
||||
class="icon"
|
||||
@click="syncCollections"
|
||||
>
|
||||
<i class="material-icons">folder_shared</i>
|
||||
<span>{{ $t("import_from_sync") }}</span>
|
||||
</button>
|
||||
@@ -86,26 +99,65 @@
|
||||
accept="application/json"
|
||||
/>
|
||||
</button>
|
||||
<button
|
||||
class="icon"
|
||||
@click="mode = 'import_from_my_collections'"
|
||||
v-tooltip="$t('replace_current')"
|
||||
v-if="collectionsType.type == 'team-collections'"
|
||||
>
|
||||
<i class="material-icons">folder_special</i>
|
||||
<span>{{ "Import from My Collections" }}</span>
|
||||
</button>
|
||||
<button
|
||||
class="icon"
|
||||
@click="
|
||||
() => {
|
||||
mode = 'export_as_json'
|
||||
getJSONCollection()
|
||||
}
|
||||
"
|
||||
v-tooltip="$t('show_code')"
|
||||
>
|
||||
<i class="material-icons">folder_special</i>
|
||||
<span>{{ "Export As JSON" }}</span>
|
||||
</button>
|
||||
</div>
|
||||
<div v-if="showJsonCode" class="row-wrapper">
|
||||
<div v-if="mode == 'import_from_my_collections'">
|
||||
<span class="select-wrapper">
|
||||
<select
|
||||
type="text"
|
||||
autofocus
|
||||
@change="
|
||||
($event) => {
|
||||
mySelectedCollectionID = $event.target.value
|
||||
}
|
||||
"
|
||||
>
|
||||
<option :key="undefined" :value="undefined" hidden disabled selected>
|
||||
Select Collection
|
||||
</option>
|
||||
<option v-for="(collection, index) in myCollections" :key="index" :value="index">
|
||||
{{ collection.name }}
|
||||
</option>
|
||||
</select>
|
||||
</span>
|
||||
<button
|
||||
class="icon primary"
|
||||
:disabled="mySelectedCollectionID == undefined"
|
||||
@click="importFromMyCollections"
|
||||
>
|
||||
{{ $t("import") }}
|
||||
</button>
|
||||
</div>
|
||||
<div v-if="mode == 'export_as_json'">
|
||||
<textarea v-model="collectionJson" rows="8" readonly></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div slot="footer">
|
||||
<div class="row-wrapper">
|
||||
<span>
|
||||
<SmartToggle :on="showJsonCode" @change="showJsonCode = $event">
|
||||
{{ $t("show_code") }}
|
||||
</SmartToggle>
|
||||
</span>
|
||||
<span>
|
||||
<button class="icon" @click="hideModal">
|
||||
{{ $t("cancel") }}
|
||||
</button>
|
||||
<button class="icon primary" @click="exportJSON" v-tooltip="$t('download_file')">
|
||||
{{ $t("export") }}
|
||||
</button>
|
||||
</span>
|
||||
<div class="row-wrapper">
|
||||
<span>
|
||||
<button class="icon primary" @click="exportJSON" v-tooltip="$t('download_file')">
|
||||
{{ $t("export") }}
|
||||
</button>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</SmartModal>
|
||||
@@ -114,12 +166,16 @@
|
||||
<script>
|
||||
import { fb } from "~/helpers/fb"
|
||||
import { getSettingSubject } from "~/newstore/settings"
|
||||
import team_utils from "~/helpers/teams/utils"
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
fb,
|
||||
showJsonCode: false,
|
||||
mode: "import_export",
|
||||
mySelectedCollectionID: undefined,
|
||||
collectionJson: "",
|
||||
}
|
||||
},
|
||||
subscriptions() {
|
||||
@@ -127,10 +183,13 @@ export default {
|
||||
},
|
||||
props: {
|
||||
show: Boolean,
|
||||
collectionsType: Object,
|
||||
},
|
||||
computed: {
|
||||
collectionJson() {
|
||||
return JSON.stringify(this.$store.state.postwoman.collections, null, 2)
|
||||
myCollections() {
|
||||
return fb.currentUser !== null
|
||||
? fb.currentCollections
|
||||
: this.$store.state.postwoman.collections
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
@@ -141,7 +200,7 @@ export default {
|
||||
{
|
||||
files: {
|
||||
"hoppscotch-collections.json": {
|
||||
content: this.collectionJson,
|
||||
content: this.getJSONCollection(),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -186,6 +245,8 @@ export default {
|
||||
})
|
||||
},
|
||||
hideModal() {
|
||||
this.mode = "import_export"
|
||||
this.mySelectedCollectionID = undefined
|
||||
this.$emit("hide-modal")
|
||||
},
|
||||
openDialogChooseFileToReplaceWith() {
|
||||
@@ -208,11 +269,27 @@ export default {
|
||||
collections = [this.parsePostmanCollection(collections)]
|
||||
} else {
|
||||
this.failedImport()
|
||||
return
|
||||
}
|
||||
this.$store.commit("postwoman/replaceCollections", { data: collections, flag: "rest" })
|
||||
this.fileImported()
|
||||
this.syncToFBCollections()
|
||||
if (this.collectionsType.type == "team-collections") {
|
||||
team_utils
|
||||
.replaceWithJSON(this.$apollo, collections, this.collectionsType.selectedTeam.id)
|
||||
.then((status) => {
|
||||
if (status) {
|
||||
this.$emit("update-team-collections")
|
||||
this.fileImported()
|
||||
} else {
|
||||
this.failedImport()
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log(error)
|
||||
this.failedImport()
|
||||
})
|
||||
} else {
|
||||
this.$store.commit("postwoman/replaceCollections", collections)
|
||||
this.fileImported()
|
||||
this.syncToFBCollections()
|
||||
}
|
||||
}
|
||||
reader.readAsText(this.$refs.inputChooseFileToReplaceWith.files[0])
|
||||
this.$refs.inputChooseFileToReplaceWith.value = ""
|
||||
@@ -235,13 +312,62 @@ export default {
|
||||
this.failedImport()
|
||||
return
|
||||
}
|
||||
this.$store.commit("postwoman/importCollections", { data: collections, flag: "rest" })
|
||||
this.fileImported()
|
||||
this.syncToFBCollections()
|
||||
if (this.collectionsType.type == "team-collections") {
|
||||
team_utils
|
||||
.importFromJSON(this.$apollo, collections, this.collectionsType.selectedTeam.id)
|
||||
.then((status) => {
|
||||
if (status) {
|
||||
this.$emit("update-team-collections")
|
||||
this.fileImported()
|
||||
} else {
|
||||
this.failedImport()
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log(error)
|
||||
this.failedImport()
|
||||
})
|
||||
} else {
|
||||
this.$store.commit("postwoman/importCollections", collections)
|
||||
this.syncToFBCollections()
|
||||
this.fileImported()
|
||||
}
|
||||
}
|
||||
reader.readAsText(this.$refs.inputChooseFileToImportFrom.files[0])
|
||||
this.$refs.inputChooseFileToImportFrom.value = ""
|
||||
},
|
||||
importFromMyCollections() {
|
||||
team_utils
|
||||
.importFromMyCollections(
|
||||
this.$apollo,
|
||||
this.mySelectedCollectionID,
|
||||
this.collectionsType.selectedTeam.id
|
||||
)
|
||||
.then((success) => {
|
||||
if (success) {
|
||||
this.fileImported()
|
||||
this.$emit("update-team-collections")
|
||||
} else {
|
||||
this.failedImport()
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log(error)
|
||||
this.failedImport()
|
||||
})
|
||||
},
|
||||
async getJSONCollection() {
|
||||
if (this.collectionsType.type == "my-collections") {
|
||||
this.collectionJson = JSON.stringify(this.$store.state.postwoman.collections, null, 2)
|
||||
} else {
|
||||
this.collectionJson = await team_utils.exportAsJSON(
|
||||
this.$apollo,
|
||||
this.collectionsType.selectedTeam.id
|
||||
)
|
||||
}
|
||||
console.log(this.collectionJson)
|
||||
return this.collectionJson
|
||||
},
|
||||
exportJSON() {
|
||||
let text = this.collectionJson
|
||||
text = text.replace(/\n/g, "\r\n")
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<span>{{ request.name }}</span>
|
||||
</button>
|
||||
</div>
|
||||
<v-popover>
|
||||
<v-popover v-if="!saveRequest">
|
||||
<button class="tooltip-target icon" v-tooltip="$t('more')">
|
||||
<i class="material-icons">more_vert</i>
|
||||
</button>
|
||||
@@ -62,6 +62,7 @@
|
||||
<script>
|
||||
import { fb } from "~/helpers/fb"
|
||||
import { getSettingSubject } from "~/newstore/settings"
|
||||
import team_utils from "~/helpers/teams/utils"
|
||||
|
||||
export default {
|
||||
props: {
|
||||
@@ -69,8 +70,10 @@ export default {
|
||||
collectionIndex: Number,
|
||||
folderIndex: Number,
|
||||
folderName: String,
|
||||
requestIndex: Number,
|
||||
requestIndex: [Number, String],
|
||||
doc: Boolean,
|
||||
saveRequest: Boolean,
|
||||
collectionsType: Object,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@@ -100,7 +103,12 @@ export default {
|
||||
}
|
||||
},
|
||||
selectRequest() {
|
||||
this.$store.commit("postwoman/selectRequest", { request: this.request })
|
||||
if (this.$props.saveRequest)
|
||||
this.$emit("select-request", {
|
||||
idx: this.$props.requestIndex,
|
||||
name: this.$props.request.name,
|
||||
})
|
||||
else this.$store.commit("postwoman/selectRequest", { request: this.request })
|
||||
},
|
||||
dragStart({ dataTransfer }) {
|
||||
this.dragging = !this.dragging
|
||||
@@ -110,17 +118,35 @@ export default {
|
||||
dataTransfer.setData("requestIndex", this.$props.requestIndex)
|
||||
},
|
||||
removeRequest() {
|
||||
this.$store.commit("postwoman/removeRequest", {
|
||||
collectionIndex: this.$props.collectionIndex,
|
||||
folderName: this.$props.folderName,
|
||||
requestIndex: this.$props.requestIndex,
|
||||
flag: "rest",
|
||||
})
|
||||
this.$toast.error(this.$t("deleted"), {
|
||||
icon: "delete",
|
||||
})
|
||||
this.confirmRemove = false
|
||||
this.syncCollections()
|
||||
if (this.$props.collectionsType.type == "my-collections") {
|
||||
this.$store.commit("postwoman/removeRequest", {
|
||||
collectionIndex: this.$props.collectionIndex,
|
||||
folderName: this.$props.folderName,
|
||||
requestIndex: this.$props.requestIndex,
|
||||
flag: "rest",
|
||||
})
|
||||
this.$toast.error(this.$t("deleted"), {
|
||||
icon: "delete",
|
||||
})
|
||||
this.syncCollections()
|
||||
} else if (this.$props.collectionsType.type == "team-collections") {
|
||||
team_utils
|
||||
.deleteRequest(this.$apollo, this.$props.requestIndex)
|
||||
.then((data) => {
|
||||
// Result
|
||||
this.$toast.success(this.$t("deleted"), {
|
||||
icon: "delete",
|
||||
})
|
||||
})
|
||||
.catch((error) => {
|
||||
// Error
|
||||
this.$toast.error(this.$t("error_occurred"), {
|
||||
icon: "done",
|
||||
})
|
||||
console.error(error)
|
||||
})
|
||||
this.$data.confirmRemove = false
|
||||
}
|
||||
},
|
||||
getRequestLabelColor(method) {
|
||||
return this.requestMethodLabels[method.toLowerCase()] || this.requestMethodLabels.default
|
||||
|
||||
@@ -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 + "/")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -5,16 +5,29 @@
|
||||
aria-label="Search"
|
||||
type="search"
|
||||
:placeholder="$t('search')"
|
||||
v-if="!saveRequest"
|
||||
v-model="filterText"
|
||||
class="rounded-t-lg"
|
||||
/>
|
||||
</div>
|
||||
<CollectionsAdd :show="showModalAdd" @hide-modal="displayModalAdd(false)" />
|
||||
<CollectionsChooseType
|
||||
:collectionsType="collectionsType"
|
||||
@update-team-collections="updateTeamCollections"
|
||||
:show="showTeamCollections"
|
||||
/>
|
||||
<CollectionsAdd
|
||||
:collectionsType="collectionsType"
|
||||
:show="showModalAdd"
|
||||
@update-team-collections="updateTeamCollections"
|
||||
@hide-modal="displayModalAdd(false)"
|
||||
/>
|
||||
<CollectionsEdit
|
||||
:show="showModalEdit"
|
||||
:editing-collection="editingCollection"
|
||||
:editing-collection-index="editingCollectionIndex"
|
||||
:collectionsType="collectionsType"
|
||||
@hide-modal="displayModalEdit(false)"
|
||||
@update-team-collections="updateTeamCollections"
|
||||
/>
|
||||
<CollectionsAddFolder
|
||||
:show="showModalAddFolder"
|
||||
@@ -28,6 +41,7 @@
|
||||
:collection-index="editingCollectionIndex"
|
||||
:folder="editingFolder"
|
||||
:folder-index="editingFolderIndex"
|
||||
:collectionsType="collectionsType"
|
||||
@hide-modal="displayModalEditFolder(false)"
|
||||
/>
|
||||
<CollectionsEditRequest
|
||||
@@ -37,18 +51,45 @@
|
||||
:folder-name="editingFolderName"
|
||||
:request="editingRequest"
|
||||
:request-index="editingRequestIndex"
|
||||
:collectionsType="collectionsType"
|
||||
@hide-modal="displayModalEditRequest(false)"
|
||||
@update-team-collections="updateTeamCollections"
|
||||
/>
|
||||
<CollectionsImportExport
|
||||
:show="showModalImportExport"
|
||||
:collectionsType="collectionsType"
|
||||
@hide-modal="displayModalImportExport(false)"
|
||||
@update-team-collections="updateTeamCollections"
|
||||
/>
|
||||
<div class="border-b row-wrapper border-brdColor">
|
||||
<button class="icon" @click="displayModalAdd(true)">
|
||||
<button
|
||||
v-if="
|
||||
collectionsType.type == 'team-collections' &&
|
||||
(collectionsType.selectedTeam == undefined ||
|
||||
collectionsType.selectedTeam.myRole == 'VIEWER') &&
|
||||
!saveRequest
|
||||
"
|
||||
class="icon"
|
||||
@click="displayModalAdd(true)"
|
||||
disabled
|
||||
>
|
||||
<i class="material-icons">add</i>
|
||||
<div v-tooltip.left="$t('disable_new_collection')">
|
||||
<span>{{ $t("new") }}</span>
|
||||
</div>
|
||||
</button>
|
||||
<button v-else-if="!saveRequest" class="icon" @click="displayModalAdd(true)">
|
||||
<i class="material-icons">add</i>
|
||||
<span>{{ $t("new") }}</span>
|
||||
</button>
|
||||
<button class="icon" @click="displayModalImportExport(true)">
|
||||
<button
|
||||
v-if="!saveRequest"
|
||||
:disabled="
|
||||
collectionsType.type == 'team-collections' && collectionsType.selectedTeam == undefined
|
||||
"
|
||||
class="icon"
|
||||
@click="displayModalImportExport(true)"
|
||||
>
|
||||
{{ $t("import_export") }}
|
||||
</button>
|
||||
</div>
|
||||
@@ -65,11 +106,26 @@
|
||||
:doc="doc"
|
||||
:isFiltered="filterText.length > 0"
|
||||
:selected="selected.some((coll) => coll == collection)"
|
||||
:saveRequest="saveRequest"
|
||||
:collectionsType="collectionsType"
|
||||
@edit-collection="editCollection(collection, index)"
|
||||
@add-folder="addFolder($event)"
|
||||
@edit-folder="editFolder($event)"
|
||||
@edit-request="editRequest($event)"
|
||||
@select-collection="$emit('use-collection', collection)"
|
||||
@update-team-collections="updateTeamCollections"
|
||||
@select-collection="$emit('use-collection', index)"
|
||||
@select-folder="
|
||||
$emit('select-folder', {
|
||||
folderName:
|
||||
(collectionsType.type == 'my-collections' ? collection.name : collection.title) +
|
||||
'/' +
|
||||
$event.name,
|
||||
collectionIndex: collectionsType.type == 'my-collections' ? index : $event.id,
|
||||
reqIdx: $event.reqIdx,
|
||||
collectionsType: collectionsType,
|
||||
folderId: $event.id,
|
||||
})
|
||||
"
|
||||
@unselect-collection="$emit('remove-collection', collection)"
|
||||
/>
|
||||
</li>
|
||||
@@ -90,11 +146,14 @@
|
||||
<script>
|
||||
import { fb } from "~/helpers/fb"
|
||||
import { getSettingSubject } from "~/newstore/settings"
|
||||
import gql from "graphql-tag"
|
||||
import team_utils from "~/helpers/teams/utils"
|
||||
|
||||
export default {
|
||||
props: {
|
||||
doc: Boolean,
|
||||
selected: { type: Array, default: () => [] },
|
||||
saveRequest: Boolean,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@@ -113,6 +172,11 @@ export default {
|
||||
editingRequest: undefined,
|
||||
editingRequestIndex: undefined,
|
||||
filterText: "",
|
||||
collectionsType: {
|
||||
type: "my-collections",
|
||||
selectedTeam: undefined,
|
||||
},
|
||||
teamCollections: {},
|
||||
}
|
||||
},
|
||||
subscriptions() {
|
||||
@@ -120,17 +184,59 @@ export default {
|
||||
SYNC_COLLECTIONS: getSettingSubject("syncCollections"),
|
||||
}
|
||||
},
|
||||
apollo: {
|
||||
myTeams: {
|
||||
query: gql`
|
||||
query GetMyTeams {
|
||||
myTeams {
|
||||
id
|
||||
name
|
||||
myRole
|
||||
}
|
||||
}
|
||||
`,
|
||||
pollInterval: 10000,
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
"collectionsType.type": function emitstuff() {
|
||||
this.$emit("update-collection", this.$data.collectionsType.type)
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
showTeamCollections() {
|
||||
if (fb.currentUser == null) {
|
||||
this.collectionsType.type = "my-collections"
|
||||
}
|
||||
return fb.currentUser !== null
|
||||
},
|
||||
collections() {
|
||||
return fb.currentUser !== null
|
||||
? fb.currentCollections
|
||||
: this.$store.state.postwoman.collections
|
||||
},
|
||||
filteredCollections() {
|
||||
const collections =
|
||||
fb.currentUser !== null ? fb.currentCollections : this.$store.state.postwoman.collections
|
||||
let collections = null
|
||||
if (this.collectionsType.type == "my-collections") {
|
||||
collections =
|
||||
fb.currentUser !== null ? fb.currentCollections : this.$store.state.postwoman.collections
|
||||
} else {
|
||||
if (
|
||||
this.collectionsType.selectedTeam &&
|
||||
this.collectionsType.selectedTeam.id in this.teamCollections
|
||||
) {
|
||||
collections = this.teamCollections[this.collectionsType.selectedTeam.id]
|
||||
} else {
|
||||
collections = []
|
||||
}
|
||||
}
|
||||
if (!this.filterText) {
|
||||
return collections
|
||||
}
|
||||
|
||||
if (!this.filterText) return collections
|
||||
if (this.collectionsType.type == "team-collections") {
|
||||
return []
|
||||
}
|
||||
|
||||
const filterText = this.filterText.toLowerCase()
|
||||
const filteredCollections = []
|
||||
@@ -154,7 +260,10 @@ export default {
|
||||
}
|
||||
}
|
||||
|
||||
if (filteredRequests.length + filteredFolders.length > 0) {
|
||||
if (
|
||||
filteredRequests.length + filteredFolders.length > 0 ||
|
||||
collection.name.toLowerCase().includes(filterText)
|
||||
) {
|
||||
const filteredCollection = Object.assign({}, collection)
|
||||
filteredCollection.requests = filteredRequests
|
||||
filteredCollection.folders = filteredFolders
|
||||
@@ -175,6 +284,18 @@ export default {
|
||||
document.addEventListener("keydown", this._keyListener.bind(this))
|
||||
},
|
||||
methods: {
|
||||
updateTeamCollections() {
|
||||
this.$emit("select-collection-type")
|
||||
if (this.collectionsType.selectedTeam == undefined) return
|
||||
team_utils
|
||||
.rootCollectionsOfTeam(this.$apollo, this.collectionsType.selectedTeam.id)
|
||||
.then((collections) => {
|
||||
this.$set(this.teamCollections, this.collectionsType.selectedTeam.id, collections)
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log(error)
|
||||
})
|
||||
},
|
||||
displayModalAdd(shouldDisplay) {
|
||||
this.showModalAdd = shouldDisplay
|
||||
},
|
||||
@@ -207,16 +328,50 @@ export default {
|
||||
this.displayModalEdit(true)
|
||||
this.syncCollections()
|
||||
},
|
||||
onAddFolder({ name, path }) {
|
||||
onAddFolder({ name, folder, path }) {
|
||||
const flag = "rest"
|
||||
this.$store.commit("postwoman/addFolder", {
|
||||
name,
|
||||
path,
|
||||
flag,
|
||||
})
|
||||
if (this.collectionsType.type === "my-collections") {
|
||||
this.$store.commit("postwoman/addFolder", {
|
||||
name,
|
||||
path,
|
||||
flag,
|
||||
})
|
||||
this.syncCollections()
|
||||
} else if (this.collectionsType.type === "team-collections") {
|
||||
if (this.collectionsType.selectedTeam.myRole != "VIEWER") {
|
||||
this.$apollo
|
||||
.mutate({
|
||||
mutation: gql`
|
||||
mutation($childTitle: String!, $collectionID: String!) {
|
||||
createChildCollection(childTitle: $childTitle, collectionID: $collectionID) {
|
||||
id
|
||||
}
|
||||
}
|
||||
`,
|
||||
// Parameters
|
||||
variables: {
|
||||
childTitle: name,
|
||||
collectionID: folder.id,
|
||||
},
|
||||
})
|
||||
.then((data) => {
|
||||
// Result
|
||||
this.$toast.success(this.$t("folder_added"), {
|
||||
icon: "done",
|
||||
})
|
||||
this.$emit("update-team-collections")
|
||||
})
|
||||
.catch((error) => {
|
||||
// Error
|
||||
this.$toast.error(this.$t("error_occurred"), {
|
||||
icon: "done",
|
||||
})
|
||||
console.error(error)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
this.displayModalAddFolder(false)
|
||||
this.syncCollections()
|
||||
},
|
||||
addFolder(payload) {
|
||||
const { folder, path } = payload
|
||||
@@ -229,6 +384,7 @@ export default {
|
||||
this.$data.editingCollectionIndex = collectionIndex
|
||||
this.$data.editingFolder = folder
|
||||
this.$data.editingFolderIndex = folderIndex
|
||||
this.$data.collectionsType = this.collectionsType
|
||||
this.displayModalEditFolder(true)
|
||||
this.syncCollections()
|
||||
},
|
||||
@@ -239,6 +395,7 @@ export default {
|
||||
this.$data.editingFolderName = folderName
|
||||
this.$data.editingRequest = request
|
||||
this.$data.editingRequestIndex = requestIndex
|
||||
this.$emit("select-request", requestIndex)
|
||||
this.displayModalEditRequest(true)
|
||||
this.syncCollections()
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user