Initial refactor of the collections list and friends
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
id="selectLabel"
|
||||
v-model="requestUpdateData.name"
|
||||
@keyup.enter="saveRequest"
|
||||
:placeholder="request.name"
|
||||
:placeholder="placeholderReqName"
|
||||
/>
|
||||
</div>
|
||||
<div slot="footer">
|
||||
@@ -37,19 +37,10 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { fb } from "~/helpers/fb"
|
||||
import { getSettingSubject } from "~/newstore/settings"
|
||||
import * as team_utils from "~/helpers/teams/utils"
|
||||
|
||||
export default {
|
||||
props: {
|
||||
show: Boolean,
|
||||
collectionIndex: Number,
|
||||
folderIndex: Number,
|
||||
folderName: String,
|
||||
request: Object,
|
||||
requestIndex: [String, Number],
|
||||
collectionsType: Object,
|
||||
placeholderReqName: String,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@@ -58,59 +49,9 @@ export default {
|
||||
},
|
||||
}
|
||||
},
|
||||
subscriptions() {
|
||||
return {
|
||||
SYNC_COLLECTIONS: getSettingSubject("syncCollections"),
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
syncCollections() {
|
||||
if (fb.currentUser !== null && this.SYNC_COLLECTIONS) {
|
||||
fb.writeCollections(
|
||||
JSON.parse(JSON.stringify(this.$store.state.postwoman.collections)),
|
||||
"collections"
|
||||
)
|
||||
}
|
||||
},
|
||||
saveRequest() {
|
||||
const requestUpdated = {
|
||||
...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()
|
||||
this.$emit("submit", this.requestUpdateData)
|
||||
},
|
||||
hideModal() {
|
||||
this.$emit("hide-modal")
|
||||
|
||||
Reference in New Issue
Block a user