Initial refactor of the collections list and friends
This commit is contained in:
@@ -37,71 +37,18 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { fb } from "~/helpers/fb"
|
|
||||||
import { getSettingSubject } from "~/newstore/settings"
|
|
||||||
import * as team_utils from "~/helpers/teams/utils"
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
show: Boolean,
|
show: Boolean,
|
||||||
collectionsType: Object,
|
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
name: undefined,
|
name: undefined,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
subscriptions() {
|
|
||||||
return {
|
|
||||||
SYNC_COLLECTIONS: getSettingSubject("syncCollections"),
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
methods: {
|
||||||
syncCollections() {
|
|
||||||
if (fb.currentUser !== null && this.SYNC_COLLECTIONS) {
|
|
||||||
fb.writeCollections(
|
|
||||||
JSON.parse(JSON.stringify(this.$store.state.postwoman.collections)),
|
|
||||||
"collections"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
addNewCollection() {
|
addNewCollection() {
|
||||||
if (!this.$data.name) {
|
this.$emit("submit", this.name)
|
||||||
this.$toast.info(this.$t("invalid_collection_name"))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
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() {
|
hideModal() {
|
||||||
this.$emit("hide-modal")
|
this.$emit("hide-modal")
|
||||||
|
|||||||
@@ -11,10 +11,7 @@
|
|||||||
id="team"
|
id="team"
|
||||||
class="team"
|
class="team"
|
||||||
autofocus
|
autofocus
|
||||||
@change="
|
@change="updateSelectedTeam(myTeams[$event.target.value])"
|
||||||
collectionsType.selectedTeam = myTeams[$event.target.value]
|
|
||||||
$emit('update-team-collections')
|
|
||||||
"
|
|
||||||
>
|
>
|
||||||
<option :key="undefined" :value="undefined" hidden disabled selected>
|
<option :key="undefined" :value="undefined" hidden disabled selected>
|
||||||
Select team
|
Select team
|
||||||
@@ -36,7 +33,6 @@ import gql from "graphql-tag"
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
collectionsType: Object,
|
|
||||||
show: Boolean,
|
show: Boolean,
|
||||||
},
|
},
|
||||||
apollo: {
|
apollo: {
|
||||||
@@ -55,8 +51,10 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
updateCollectionsType(tabID) {
|
updateCollectionsType(tabID) {
|
||||||
this.collectionsType.type = tabID
|
this.$emit("update-collection-type", tabID)
|
||||||
this.$emit("update-team-collections")
|
},
|
||||||
|
updateSelectedTeam(team) {
|
||||||
|
this.$emit("update-selected-team", team)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -389,7 +389,6 @@ export default {
|
|||||||
)
|
)
|
||||||
},
|
},
|
||||||
updateQuery(previousResult, { subscriptionData }) {
|
updateQuery(previousResult, { subscriptionData }) {
|
||||||
debugger
|
|
||||||
if (
|
if (
|
||||||
subscriptionData.data.teamCollectionAdded.parent &&
|
subscriptionData.data.teamCollectionAdded.parent &&
|
||||||
subscriptionData.data.teamCollectionAdded.parent.id === this.$props.collection.id
|
subscriptionData.data.teamCollectionAdded.parent.id === this.$props.collection.id
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
type="text"
|
type="text"
|
||||||
id="selectLabel"
|
id="selectLabel"
|
||||||
v-model="name"
|
v-model="name"
|
||||||
:placeholder="editingCollection.name"
|
:placeholder="placeholderCollName"
|
||||||
@keyup.enter="saveCollection"
|
@keyup.enter="saveCollection"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -37,73 +37,19 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { fb } from "~/helpers/fb"
|
|
||||||
import { getSettingSubject } from "~/newstore/settings"
|
|
||||||
import * as team_utils from "~/helpers/teams/utils"
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
show: Boolean,
|
show: Boolean,
|
||||||
editingCollection: Object,
|
placeholderCollName: String,
|
||||||
editingCollectionIndex: Number,
|
|
||||||
collectionsType: Object,
|
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
name: undefined,
|
name: undefined,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
subscriptions() {
|
|
||||||
return {
|
|
||||||
SYNC_COLLECTIONS: getSettingSubject("syncCollections"),
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
methods: {
|
||||||
syncCollections() {
|
|
||||||
if (fb.currentUser !== null && this.SYNC_COLLECTIONS) {
|
|
||||||
fb.writeCollections(
|
|
||||||
JSON.parse(JSON.stringify(this.$store.state.postwoman.collections)),
|
|
||||||
"collections"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
saveCollection() {
|
saveCollection() {
|
||||||
if (!this.$data.name) {
|
this.$emit("submit", this.name)
|
||||||
this.$toast.info(this.$t("invalid_collection_name"))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
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.hideModal()
|
|
||||||
},
|
},
|
||||||
hideModal() {
|
hideModal() {
|
||||||
this.$emit("hide-modal")
|
this.$emit("hide-modal")
|
||||||
|
|||||||
@@ -37,69 +37,18 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { fb } from "~/helpers/fb"
|
|
||||||
import { getSettingSubject } from "~/newstore/settings"
|
|
||||||
import * as team_utils from "~/helpers/teams/utils"
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
show: Boolean,
|
show: Boolean,
|
||||||
collectionIndex: Number,
|
|
||||||
folder: Object,
|
|
||||||
folderIndex: Number,
|
|
||||||
collectionsType: Object,
|
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
name: undefined,
|
name: undefined,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
subscriptions() {
|
|
||||||
return {
|
|
||||||
SYNC_COLLECTIONS: getSettingSubject("syncCollections"),
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
methods: {
|
||||||
syncCollections() {
|
|
||||||
if (fb.currentUser !== null && this.SYNC_COLLECTIONS) {
|
|
||||||
fb.writeCollections(
|
|
||||||
JSON.parse(JSON.stringify(this.$store.state.postwoman.collections)),
|
|
||||||
"collections"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
editFolder() {
|
editFolder() {
|
||||||
if (this.collectionsType.type == "my-collections") {
|
this.$emit("submit", this.name)
|
||||||
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()
|
|
||||||
},
|
},
|
||||||
hideModal() {
|
hideModal() {
|
||||||
this.$emit("hide-modal")
|
this.$emit("hide-modal")
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
id="selectLabel"
|
id="selectLabel"
|
||||||
v-model="requestUpdateData.name"
|
v-model="requestUpdateData.name"
|
||||||
@keyup.enter="saveRequest"
|
@keyup.enter="saveRequest"
|
||||||
:placeholder="request.name"
|
:placeholder="placeholderReqName"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div slot="footer">
|
<div slot="footer">
|
||||||
@@ -37,19 +37,10 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { fb } from "~/helpers/fb"
|
|
||||||
import { getSettingSubject } from "~/newstore/settings"
|
|
||||||
import * as team_utils from "~/helpers/teams/utils"
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
show: Boolean,
|
show: Boolean,
|
||||||
collectionIndex: Number,
|
placeholderReqName: String,
|
||||||
folderIndex: Number,
|
|
||||||
folderName: String,
|
|
||||||
request: Object,
|
|
||||||
requestIndex: [String, Number],
|
|
||||||
collectionsType: Object,
|
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@@ -58,59 +49,9 @@ export default {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
subscriptions() {
|
|
||||||
return {
|
|
||||||
SYNC_COLLECTIONS: getSettingSubject("syncCollections"),
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
methods: {
|
||||||
syncCollections() {
|
|
||||||
if (fb.currentUser !== null && this.SYNC_COLLECTIONS) {
|
|
||||||
fb.writeCollections(
|
|
||||||
JSON.parse(JSON.stringify(this.$store.state.postwoman.collections)),
|
|
||||||
"collections"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
saveRequest() {
|
saveRequest() {
|
||||||
const requestUpdated = {
|
this.$emit("submit", this.requestUpdateData)
|
||||||
...this.$props.request,
|
|
||||||
name: this.$data.requestUpdateData.name || this.$props.request.name,
|
|
||||||
}
|
|
||||||
|
|
||||||
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()
|
|
||||||
},
|
},
|
||||||
hideModal() {
|
hideModal() {
|
||||||
this.$emit("hide-modal")
|
this.$emit("hide-modal")
|
||||||
|
|||||||
@@ -179,7 +179,9 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
subscriptions() {
|
subscriptions() {
|
||||||
SYNC_COLLECTIONS: getSettingSubject("syncCollections")
|
return {
|
||||||
|
SYNC_COLLECTIONS: getSettingSubject("syncCollections"),
|
||||||
|
}
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
show: Boolean,
|
show: Boolean,
|
||||||
@@ -275,7 +277,6 @@ export default {
|
|||||||
.replaceWithJSON(this.$apollo, collections, this.collectionsType.selectedTeam.id)
|
.replaceWithJSON(this.$apollo, collections, this.collectionsType.selectedTeam.id)
|
||||||
.then((status) => {
|
.then((status) => {
|
||||||
if (status) {
|
if (status) {
|
||||||
this.$emit("update-team-collections")
|
|
||||||
this.fileImported()
|
this.fileImported()
|
||||||
} else {
|
} else {
|
||||||
this.failedImport()
|
this.failedImport()
|
||||||
|
|||||||
@@ -12,22 +12,20 @@
|
|||||||
</div>
|
</div>
|
||||||
<CollectionsChooseType
|
<CollectionsChooseType
|
||||||
:collectionsType="collectionsType"
|
:collectionsType="collectionsType"
|
||||||
@update-team-collections="updateTeamCollections"
|
|
||||||
:show="showTeamCollections"
|
:show="showTeamCollections"
|
||||||
|
@update-collection-type="updateCollectionType"
|
||||||
|
@update-selected-team="updateSelectedTeam"
|
||||||
/>
|
/>
|
||||||
<CollectionsAdd
|
<CollectionsAdd
|
||||||
:collectionsType="collectionsType"
|
|
||||||
:show="showModalAdd"
|
:show="showModalAdd"
|
||||||
@update-team-collections="updateTeamCollections"
|
@submit="addNewRootCollection"
|
||||||
@hide-modal="displayModalAdd(false)"
|
@hide-modal="displayModalAdd(false)"
|
||||||
/>
|
/>
|
||||||
<CollectionsEdit
|
<CollectionsEdit
|
||||||
:show="showModalEdit"
|
:show="showModalEdit"
|
||||||
:editing-collection="editingCollection"
|
:editing-coll-name="editingCollection ? editingCollection.name : ''"
|
||||||
:editing-collection-index="editingCollectionIndex"
|
|
||||||
:collectionsType="collectionsType"
|
|
||||||
@hide-modal="displayModalEdit(false)"
|
@hide-modal="displayModalEdit(false)"
|
||||||
@update-team-collections="updateTeamCollections"
|
@submit="updateEditingCollection"
|
||||||
/>
|
/>
|
||||||
<CollectionsAddFolder
|
<CollectionsAddFolder
|
||||||
:show="showModalAddFolder"
|
:show="showModalAddFolder"
|
||||||
@@ -38,22 +36,14 @@
|
|||||||
/>
|
/>
|
||||||
<CollectionsEditFolder
|
<CollectionsEditFolder
|
||||||
:show="showModalEditFolder"
|
:show="showModalEditFolder"
|
||||||
:collection-index="editingCollectionIndex"
|
@submit="updateEditingFolder"
|
||||||
:folder="editingFolder"
|
|
||||||
:folder-index="editingFolderIndex"
|
|
||||||
:collectionsType="collectionsType"
|
|
||||||
@hide-modal="displayModalEditFolder(false)"
|
@hide-modal="displayModalEditFolder(false)"
|
||||||
/>
|
/>
|
||||||
<CollectionsEditRequest
|
<CollectionsEditRequest
|
||||||
:show="showModalEditRequest"
|
:show="showModalEditRequest"
|
||||||
:collection-index="editingCollectionIndex"
|
:placeholder-req-name="editingRequest ? editingRequest.name : ''"
|
||||||
:folder-index="editingFolderIndex"
|
@submit="updateEditingRequest"
|
||||||
:folder-name="editingFolderName"
|
|
||||||
:request="editingRequest"
|
|
||||||
:request-index="editingRequestIndex"
|
|
||||||
:collectionsType="collectionsType"
|
|
||||||
@hide-modal="displayModalEditRequest(false)"
|
@hide-modal="displayModalEditRequest(false)"
|
||||||
@update-team-collections="updateTeamCollections"
|
|
||||||
/>
|
/>
|
||||||
<CollectionsImportExport
|
<CollectionsImportExport
|
||||||
:show="showModalImportExport"
|
:show="showModalImportExport"
|
||||||
@@ -147,8 +137,8 @@
|
|||||||
import { fb } from "~/helpers/fb"
|
import { fb } from "~/helpers/fb"
|
||||||
import { getSettingSubject } from "~/newstore/settings"
|
import { getSettingSubject } from "~/newstore/settings"
|
||||||
import gql from "graphql-tag"
|
import gql from "graphql-tag"
|
||||||
import * as team_utils from "~/helpers/teams/utils"
|
|
||||||
import TeamCollectionAdapter from "~/helpers/teams/TeamCollectionAdapter"
|
import TeamCollectionAdapter from "~/helpers/teams/TeamCollectionAdapter"
|
||||||
|
import * as team_utils from "~/helpers/teams/utils"
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
@@ -177,7 +167,6 @@ export default {
|
|||||||
type: "my-collections",
|
type: "my-collections",
|
||||||
selectedTeam: undefined,
|
selectedTeam: undefined,
|
||||||
},
|
},
|
||||||
teamCollections: {},
|
|
||||||
teamCollectionAdapter: new TeamCollectionAdapter(null),
|
teamCollectionAdapter: new TeamCollectionAdapter(null),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -187,108 +176,6 @@ export default {
|
|||||||
teamCollectionsNew: this.teamCollectionAdapter.collections$,
|
teamCollectionsNew: this.teamCollectionAdapter.collections$,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
apollo: {
|
|
||||||
myTeams: {
|
|
||||||
query: gql`
|
|
||||||
query GetMyTeams {
|
|
||||||
myTeams {
|
|
||||||
id
|
|
||||||
name
|
|
||||||
myRole
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`,
|
|
||||||
pollInterval: 10000,
|
|
||||||
},
|
|
||||||
|
|
||||||
$subscribe: {
|
|
||||||
teamsCollectionAdded: {
|
|
||||||
query: gql`
|
|
||||||
subscription teamCollectionAdded($teamID: String!) {
|
|
||||||
teamCollectionAdded(teamID: $teamID) {
|
|
||||||
id
|
|
||||||
title
|
|
||||||
parent {
|
|
||||||
id
|
|
||||||
title
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`,
|
|
||||||
variables() {
|
|
||||||
return {
|
|
||||||
teamID: this.collectionsType.selectedTeam.id,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
skip() {
|
|
||||||
return this.collectionsType.selectedTeam == undefined
|
|
||||||
},
|
|
||||||
result({ data }) {
|
|
||||||
console.log(data)
|
|
||||||
|
|
||||||
if (data.teamCollectionAdded.parent == null) {
|
|
||||||
debugger
|
|
||||||
|
|
||||||
this.teamCollections[this.collectionsType.selectedTeam.id].push({
|
|
||||||
id: data.teamCollectionAdded.id,
|
|
||||||
title: data.teamCollectionAdded.title,
|
|
||||||
__typename: data.teamCollectionAdded.__typename,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
teamsCollectionUpdated: {
|
|
||||||
query: gql`
|
|
||||||
subscription teamCollectionUpdated($teamID: String!) {
|
|
||||||
teamCollectionUpdated(teamID: $teamID) {
|
|
||||||
id
|
|
||||||
title
|
|
||||||
parent {
|
|
||||||
id
|
|
||||||
title
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`,
|
|
||||||
variables() {
|
|
||||||
return {
|
|
||||||
teamID: this.collectionsType.selectedTeam.id,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
skip() {
|
|
||||||
return this.collectionsType.selectedTeam == undefined
|
|
||||||
},
|
|
||||||
result({ data }) {
|
|
||||||
const current = this.teamCollections[this.collectionsType.selectedTeam.id]
|
|
||||||
const index = current.findIndex((x) => x.id === data.teamCollectionUpdated.id)
|
|
||||||
if (index >= 0) {
|
|
||||||
current[index].title = data.teamCollectionUpdated.title
|
|
||||||
}
|
|
||||||
this.teamCollections[this.collectionsType.selectedTeam.id] = current
|
|
||||||
},
|
|
||||||
},
|
|
||||||
teamsCollectionRemoved: {
|
|
||||||
query: gql`
|
|
||||||
subscription teamCollectionRemoved($teamID: String!) {
|
|
||||||
teamCollectionRemoved(teamID: $teamID)
|
|
||||||
}
|
|
||||||
`,
|
|
||||||
variables() {
|
|
||||||
return {
|
|
||||||
teamID: this.collectionsType.selectedTeam.id,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
skip() {
|
|
||||||
return this.collectionsType.selectedTeam == undefined
|
|
||||||
},
|
|
||||||
result({ data }) {
|
|
||||||
this.teamCollections[this.collectionsType.selectedTeam.id] = this.teamCollections[
|
|
||||||
this.collectionsType.selectedTeam.id
|
|
||||||
].filter((x) => x.id !== data.teamCollectionRemoved)
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
watch: {
|
watch: {
|
||||||
"collectionsType.type": function emitstuff() {
|
"collectionsType.type": function emitstuff() {
|
||||||
this.$emit("update-collection", this.$data.collectionsType.type)
|
this.$emit("update-collection", this.$data.collectionsType.type)
|
||||||
@@ -315,15 +202,9 @@ export default {
|
|||||||
collections =
|
collections =
|
||||||
fb.currentUser !== null ? fb.currentCollections : this.$store.state.postwoman.collections
|
fb.currentUser !== null ? fb.currentCollections : this.$store.state.postwoman.collections
|
||||||
} else {
|
} else {
|
||||||
if (
|
collections = this.teamCollectionsNew
|
||||||
this.collectionsType.selectedTeam &&
|
|
||||||
this.collectionsType.selectedTeam.id in this.teamCollections
|
|
||||||
) {
|
|
||||||
collections = this.teamCollectionsNew
|
|
||||||
} else {
|
|
||||||
collections = []
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.filterText) {
|
if (!this.filterText) {
|
||||||
return collections
|
return collections
|
||||||
}
|
}
|
||||||
@@ -341,7 +222,9 @@ export default {
|
|||||||
for (let request of collection.requests) {
|
for (let request of collection.requests) {
|
||||||
if (request.name.toLowerCase().includes(filterText)) filteredRequests.push(request)
|
if (request.name.toLowerCase().includes(filterText)) filteredRequests.push(request)
|
||||||
}
|
}
|
||||||
for (let folder of collection.folders) {
|
for (let folder of this.collectionsType.type === "team-collections"
|
||||||
|
? collection.children
|
||||||
|
: collection.folders) {
|
||||||
const filteredFolderRequests = []
|
const filteredFolderRequests = []
|
||||||
for (let request of folder.requests) {
|
for (let request of folder.requests) {
|
||||||
if (request.name.toLowerCase().includes(filterText))
|
if (request.name.toLowerCase().includes(filterText))
|
||||||
@@ -379,16 +262,158 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
updateTeamCollections() {
|
updateTeamCollections() {
|
||||||
this.$emit("select-collection-type")
|
// TODO: Remove this at some point
|
||||||
if (this.collectionsType.selectedTeam == undefined) return
|
},
|
||||||
team_utils
|
updateSelectedTeam(newSelectedTeam) {
|
||||||
.rootCollectionsOfTeam(this.$apollo, this.collectionsType.selectedTeam.id)
|
this.collectionsType.selectedTeam = newSelectedTeam
|
||||||
.then((collections) => {
|
},
|
||||||
this.$set(this.teamCollections, this.collectionsType.selectedTeam.id, collections)
|
updateCollectionType(newCollectionType) {
|
||||||
|
this.collectionsType.type = newCollectionType
|
||||||
|
},
|
||||||
|
// Intented to be called by the CollectionAdd modal submit event
|
||||||
|
addNewRootCollection(name) {
|
||||||
|
if (!name) {
|
||||||
|
this.$toast.info(this.$t("invalid_collection_name"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (this.collectionsType.type === "my-collections") {
|
||||||
|
this.$store.commit("postwoman/addNewCollection", {
|
||||||
|
name,
|
||||||
|
flag: "rest",
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
|
||||||
console.log(error)
|
this.syncCollections()
|
||||||
|
} else if (
|
||||||
|
this.collectionsType.type === "team-collections" &&
|
||||||
|
this.collectionsType.selectedTeam.myRole !== "VIEWER"
|
||||||
|
) {
|
||||||
|
team_utils
|
||||||
|
.createNewRootCollection(this.$apollo, name, this.collectionsType.selectedTeam.id)
|
||||||
|
.then(() => {
|
||||||
|
this.$toast.success(this.$t("collection_added"), {
|
||||||
|
icon: "done",
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
this.$toast.error(this.$t("error_occurred"), {
|
||||||
|
icon: "done",
|
||||||
|
})
|
||||||
|
console.error(error)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
this.displayModalAdd(false)
|
||||||
|
},
|
||||||
|
// Intented to be called by CollectionEdit modal submit event
|
||||||
|
updateEditingCollection(newName) {
|
||||||
|
if (!newName) {
|
||||||
|
this.$toast.info(this.$t("invalid_collection_name"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (this.collectionsType.type === "my-collections") {
|
||||||
|
const collectionUpdated = {
|
||||||
|
...this.editingCollection,
|
||||||
|
name: newName,
|
||||||
|
}
|
||||||
|
this.$store.commit("postwoman/editCollection", {
|
||||||
|
collection: collectionUpdated,
|
||||||
|
collectionIndex: this.editingCollectionIndex,
|
||||||
|
flag: "rest",
|
||||||
})
|
})
|
||||||
|
this.syncCollections()
|
||||||
|
} else if (
|
||||||
|
this.collectionsType.type === "team-collections" &&
|
||||||
|
this.collectionsType.selectedTeam.myRole !== "VIEWER"
|
||||||
|
) {
|
||||||
|
team_utils
|
||||||
|
.renameCollection(this.$apollo, newName, this.editingCollection.id)
|
||||||
|
.then(() => {
|
||||||
|
// TODO: $t translations ?
|
||||||
|
this.$toast.success("Collection Renamed", {
|
||||||
|
icon: "done",
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
this.$toast.error(this.$t("error_occurred"), {
|
||||||
|
icon: "done",
|
||||||
|
})
|
||||||
|
console.error(error)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
this.displayModalEdit(false)
|
||||||
|
},
|
||||||
|
// Intended to be called by CollectionEditFolder modal submit event
|
||||||
|
updateEditingFolder(name) {
|
||||||
|
if (this.collectionsType.type == "my-collections") {
|
||||||
|
this.$store.commit("postwoman/editFolder", {
|
||||||
|
collectionIndex: this.editingCollectionIndex,
|
||||||
|
folder: { ...this.editingFolder, name: name },
|
||||||
|
folderIndex: this.editingFolderIndex,
|
||||||
|
folderName: this.editingFolder.name,
|
||||||
|
flag: "rest",
|
||||||
|
})
|
||||||
|
this.syncCollections()
|
||||||
|
} else if (
|
||||||
|
this.collectionsType.type == "team-collections" &&
|
||||||
|
this.collectionsType.selectedTeam.myRole !== "VIEWER"
|
||||||
|
) {
|
||||||
|
team_utils
|
||||||
|
.renameCollection(this.$apollo, name, this.editingFolder.id)
|
||||||
|
.then(() => {
|
||||||
|
// Result
|
||||||
|
this.$toast.success(this.$t("folder_renamed"), {
|
||||||
|
icon: "done",
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
// Error
|
||||||
|
this.$toast.error(this.$t("error_occurred"), {
|
||||||
|
icon: "done",
|
||||||
|
})
|
||||||
|
console.error(error)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
this.displayModalEditFolder(false)
|
||||||
|
},
|
||||||
|
// Intented to by called by CollectionsEditRequest modal submit event
|
||||||
|
updateEditingRequest(requestUpdateData) {
|
||||||
|
const requestUpdated = {
|
||||||
|
...this.editingRequest,
|
||||||
|
name: requestUpdateData.name || this.editingRequest.name,
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.collectionsType.type == "my-collections") {
|
||||||
|
this.$store.commit("postwoman/editRequest", {
|
||||||
|
requestCollectionIndex: this.editingCollectionIndex,
|
||||||
|
requestFolderName: this.editingFolderName,
|
||||||
|
requestFolderIndex: this.editingFolderIndex,
|
||||||
|
requestNew: requestUpdated,
|
||||||
|
requestIndex: this.editingRequestIndex,
|
||||||
|
flag: "rest",
|
||||||
|
})
|
||||||
|
this.syncCollections()
|
||||||
|
} else if (
|
||||||
|
this.collectionsType.type === "team-collections" &&
|
||||||
|
this.collectionsType.selectedTeam.myRole !== "VIEWER"
|
||||||
|
) {
|
||||||
|
let requestName = requestUpdateData.name || this.editingRequest.name
|
||||||
|
team_utils
|
||||||
|
.updateRequest(this.$apollo, requestUpdated, requestName, this.editingRequestIndex)
|
||||||
|
.then(() => {
|
||||||
|
this.$toast.success("Request Renamed", {
|
||||||
|
icon: "done",
|
||||||
|
})
|
||||||
|
this.$emit("update-team-collections")
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
this.$toast.error(this.$t("error_occurred"), {
|
||||||
|
icon: "done",
|
||||||
|
})
|
||||||
|
console.error(error)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
this.displayModalEditRequest(false)
|
||||||
},
|
},
|
||||||
displayModalAdd(shouldDisplay) {
|
displayModalAdd(shouldDisplay) {
|
||||||
this.showModalAdd = shouldDisplay
|
this.showModalAdd = shouldDisplay
|
||||||
@@ -436,7 +461,7 @@ export default {
|
|||||||
this.$apollo
|
this.$apollo
|
||||||
.mutate({
|
.mutate({
|
||||||
mutation: gql`
|
mutation: gql`
|
||||||
mutation($childTitle: String!, $collectionID: String!) {
|
mutation CreateChildCollection($childTitle: String!, $collectionID: String!) {
|
||||||
createChildCollection(childTitle: $childTitle, collectionID: $collectionID) {
|
createChildCollection(childTitle: $childTitle, collectionID: $collectionID) {
|
||||||
id
|
id
|
||||||
}
|
}
|
||||||
@@ -448,7 +473,7 @@ export default {
|
|||||||
collectionID: folder.id,
|
collectionID: folder.id,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.then((data) => {
|
.then(() => {
|
||||||
// Result
|
// Result
|
||||||
this.$toast.success(this.$t("folder_added"), {
|
this.$toast.success(this.$t("folder_added"), {
|
||||||
icon: "done",
|
icon: "done",
|
||||||
|
|||||||
@@ -166,12 +166,7 @@ export default class TeamCollectionAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async loadRootCollections(): Promise<void> {
|
private async loadRootCollections(): Promise<void> {
|
||||||
const colls = (await rootCollectionsOfTeam(apolloClient, this.teamID))
|
const colls = await rootCollectionsOfTeam(apolloClient, this.teamID)
|
||||||
.map(coll => { // TODO: Remove
|
|
||||||
coll.title = `debug-${coll.title}`
|
|
||||||
|
|
||||||
return coll
|
|
||||||
});
|
|
||||||
this.collections$.next(colls);
|
this.collections$.next(colls);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -386,7 +381,7 @@ export default class TeamCollectionAdapter {
|
|||||||
.map<TeamCollection>(el => {
|
.map<TeamCollection>(el => {
|
||||||
return {
|
return {
|
||||||
id: el.id,
|
id: el.id,
|
||||||
title: el.title,
|
title: `debug-${el.title}`,
|
||||||
children: null,
|
children: null,
|
||||||
requests: null
|
requests: null
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user