Fix SaveRequest modal selection

This commit is contained in:
Andrew Bastin
2021-05-15 00:02:55 -04:00
parent 489f14b88f
commit 1b9b2ac4c9
8 changed files with 203 additions and 148 deletions

View File

@@ -16,8 +16,10 @@
<label for="selectLabel">Select location</label> <label for="selectLabel">Select location</label>
<!-- <input readonly :value="path" /> --> <!-- <input readonly :value="path" /> -->
<Collections <Collections
@select-folder="changeRequestDetails($event)" @select="onSelect"
@update-collection="collectionsType.type = $event" @update-collection="collectionsType.type = $event"
@update-coll-type="onUpdateCollType"
:picked="picked"
:saveRequest="true" :saveRequest="true"
/> />
</div> </div>
@@ -61,6 +63,7 @@ export default {
type: "my-collections", type: "my-collections",
selectedTeam: undefined, selectedTeam: undefined,
}, },
picked: null,
} }
}, },
subscriptions() { subscriptions() {
@@ -123,14 +126,11 @@ export default {
}, },
}, },
methods: { methods: {
changeRequestDetails(data) { onUpdateCollType(newCollType) {
this.$data.requestData.folderName = data.folderName.split("/").slice(-2)[0] this.collectionsType = newCollType
this.$data.path = data.folderName },
this.$data.requestData.collectionIndex = data.collectionIndex onSelect({ picked }) {
this.$data.requestData.requestIndex = data.reqIdx this.picked = picked
if (data.collectionsType.type !== "my-collections") {
this.$data.collectionsType = data.collectionsType
}
}, },
syncCollections() { syncCollections() {
if (fb.currentUser !== null && this.SYNC_COLLECTIONS) { if (fb.currentUser !== null && this.SYNC_COLLECTIONS) {
@@ -141,8 +141,7 @@ export default {
} }
}, },
saveRequestAs() { saveRequestAs() {
const userDidntSpecifyCollection = this.$data.requestData.collectionIndex === undefined if (this.picked == null) {
if (userDidntSpecifyCollection) {
this.$toast.error(this.$t("select_collection"), { this.$toast.error(this.$t("select_collection"), {
icon: "error", icon: "error",
}) })
@@ -161,32 +160,56 @@ export default {
collection: this.$data.requestData.collectionIndex, collection: this.$data.requestData.collectionIndex,
} }
if (this.$data.collectionsType.type === "my-collections") { if (this.picked.pickedType === "my-request") {
this.$store.commit("postwoman/saveRequestAs", { this.$store.commit("postwoman/saveRequestAs", {
request: requestUpdated, request: requestUpdated,
collectionIndex: this.$data.requestData.collectionIndex, collectionIndex: this.picked.collectionIndex,
folderName: this.$data.requestData.folderName, folderName: this.picked.folderName,
requestIndex: this.$data.requestData.requestIndex, requestIndex: this.picked.requestIndex,
flag: "rest", flag: "rest",
}) })
this.syncCollections() this.syncCollections()
} else { } else if (this.picked.pickedType === "my-folder") {
if (this.$data.requestData.requestIndex) { this.$store.commit("postwoman/saveRequestAs", {
team_utils.overwriteRequestTeams( request: requestUpdated,
this.$apollo, collectionIndex: this.picked.collectionIndex,
JSON.stringify(requestUpdated), folderName: this.picked.folderName,
requestUpdated.name, flag: "rest",
this.$data.requestData.requestIndex })
)
} else { this.syncCollections()
team_utils.saveRequestAsTeams( } else if (this.picked.pickedType === "my-collection") {
this.$apollo, this.$store.commit("postwoman/saveRequestAs", {
JSON.stringify(requestUpdated), request: requestUpdated,
requestUpdated.name, collectionIndex: this.picked.collectionIndex,
this.$data.collectionsType.selectedTeam.id, flag: "rest",
this.$data.requestData.collectionIndex })
)
} this.syncCollections()
} else if (this.picked.pickedType === "teams-request") {
team_utils.overwriteRequestTeams(
this.$apollo,
JSON.stringify(requestUpdated),
requestUpdated.name,
this.picked.requestID
)
} else if (this.picked.pickedType === "teams-folder") {
team_utils.saveRequestAsTeams(
this.$apollo,
JSON.stringify(requestUpdated),
requestUpdated.name,
this.collectionsType.selectedTeam.id,
this.picked.folderID
)
} else if (this.picked.pickedType === "teams-collection") {
team_utils.saveRequestAsTeams(
this.$apollo,
JSON.stringify(requestUpdated),
requestUpdated.name,
this.collectionsType.selectedTeam.id,
this.picked.collectionID
)
} }
this.$toast.success("Requested added", { this.$toast.success("Requested added", {
icon: "done", icon: "done",

View File

@@ -104,6 +104,7 @@
:selected="selected.some((coll) => coll == collection)" :selected="selected.some((coll) => coll == collection)"
:saveRequest="saveRequest" :saveRequest="saveRequest"
:collectionsType="collectionsType" :collectionsType="collectionsType"
:picked="picked"
@edit-collection="editCollection(collection, index)" @edit-collection="editCollection(collection, index)"
@add-folder="addFolder($event)" @add-folder="addFolder($event)"
@edit-folder="editFolder($event)" @edit-folder="editFolder($event)"
@@ -130,10 +131,10 @@
picked = $event.id picked = $event.id
} }
" "
@select="$emit('select', $event)"
@expand-collection="expandCollection" @expand-collection="expandCollection"
@remove-collection="removeCollection" @remove-collection="removeCollection"
@remove-request="removeRequest" @remove-request="removeRequest"
:picked="picked.toString()"
/> />
</li> </li>
</ul> </ul>
@@ -163,6 +164,7 @@ export default {
doc: Boolean, doc: Boolean,
selected: { type: Array, default: () => [] }, selected: { type: Array, default: () => [] },
saveRequest: Boolean, saveRequest: Boolean,
picked: Object,
}, },
data() { data() {
return { return {
@@ -187,7 +189,6 @@ export default {
}, },
teamCollectionAdapter: new TeamCollectionAdapter(null), teamCollectionAdapter: new TeamCollectionAdapter(null),
teamCollectionsNew: [], teamCollectionsNew: [],
picked: "",
} }
}, },
subscriptions() { subscriptions() {
@@ -292,9 +293,11 @@ export default {
}, },
updateSelectedTeam(newSelectedTeam) { updateSelectedTeam(newSelectedTeam) {
this.collectionsType.selectedTeam = newSelectedTeam this.collectionsType.selectedTeam = newSelectedTeam
this.$emit("update-coll-type", this.collectionsType)
}, },
updateCollectionType(newCollectionType) { updateCollectionType(newCollectionType) {
this.collectionsType.type = newCollectionType this.collectionsType.type = newCollectionType
this.$emit("update-coll-type", this.collectionsType)
}, },
// Intented to be called by the CollectionAdd modal submit event // Intented to be called by the CollectionAdd modal submit event
addNewRootCollection(name) { addNewRootCollection(name) {

View File

@@ -12,9 +12,9 @@
<button class="icon" @click="toggleShowChildren"> <button class="icon" @click="toggleShowChildren">
<i class="material-icons" v-show="!showChildren && !isFiltered">arrow_right</i> <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" v-show="showChildren || isFiltered">arrow_drop_down</i>
<i v-if="picked === collectionIndex.toString()" class="text-green-400 material-icons"
>check_circle</i <i v-if="isSelected" class="text-green-400 material-icons"> check_circle </i>
>
<i v-else class="material-icons">folder</i> <i v-else class="material-icons">folder</i>
<span>{{ collection.name }}</span> <span>{{ collection.name }}</span>
</button> </button>
@@ -82,19 +82,12 @@
:saveRequest="saveRequest" :saveRequest="saveRequest"
:collectionsType="collectionsType" :collectionsType="collectionsType"
:isFiltered="isFiltered" :isFiltered="isFiltered"
:picked="picked"
@add-folder="$emit('add-folder', $event)" @add-folder="$emit('add-folder', $event)"
@edit-folder="$emit('edit-folder', $event)" @edit-folder="$emit('edit-folder', $event)"
@edit-request="$emit('edit-request', $event)" @edit-request="$emit('edit-request', $event)"
@select-folder=" @select="$emit('select', $event)"
$emit('select-folder', {
name: folder.name + '/' + $event.name,
id: $event.id,
reqIdx: $event.reqIdx,
folderPath: $event.folderPath,
})
"
@remove-request="removeRequest" @remove-request="removeRequest"
:picked="picked.toString()"
/> />
</li> </li>
</ul> </ul>
@@ -109,18 +102,14 @@
:collection-index="collectionIndex" :collection-index="collectionIndex"
:folder-index="-1" :folder-index="-1"
:folder-name="collection.name" :folder-name="collection.name"
:folder-path="collectionIndex.toString()"
:request-index="index" :request-index="index"
:doc="doc" :doc="doc"
:saveRequest="saveRequest" :saveRequest="saveRequest"
:collectionsType="collectionsType" :collectionsType="collectionsType"
:picked="picked"
@edit-request="editRequest($event)" @edit-request="editRequest($event)"
@select-request=" @select="$emit('select', $event)"
$emit('select-folder', {
name: $event.name,
id: collection.id,
reqIdx: $event.idx,
})
"
@remove-request="removeRequest" @remove-request="removeRequest"
/> />
</li> </li>
@@ -151,7 +140,6 @@
<script> <script>
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"
export default { export default {
props: { props: {
@@ -162,7 +150,7 @@ export default {
selected: Boolean, selected: Boolean,
saveRequest: Boolean, saveRequest: Boolean,
collectionsType: Object, collectionsType: Object,
picked: { default: "", type: String }, picked: Object,
}, },
data() { data() {
return { return {
@@ -180,15 +168,18 @@ export default {
SYNC_COLLECTIONS: getSettingSubject("syncCollections"), SYNC_COLLECTIONS: getSettingSubject("syncCollections"),
} }
}, },
computed: {
isSelected() {
return (
this.picked &&
this.picked.pickedType === "my-collection" &&
this.picked.collectionIndex === this.collectionIndex
)
},
},
methods: { methods: {
editRequest(event) { editRequest(event) {
this.$emit("edit-request", 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() { syncCollections() {
if (fb.currentUser !== null && this.SYNC_COLLECTIONS) { if (fb.currentUser !== null && this.SYNC_COLLECTIONS) {
@@ -200,7 +191,13 @@ export default {
}, },
toggleShowChildren() { toggleShowChildren() {
if (this.$props.saveRequest) if (this.$props.saveRequest)
this.$emit("select-folder", { name: "", id: this.$props.collection.id, reqIdx: "" }) this.$emit("select", {
picked: {
pickedType: "my-collection",
collectionIndex: this.collectionIndex,
},
})
this.$emit("expand-collection", this.collection.id) this.$emit("expand-collection", this.collection.id)
this.showChildren = !this.showChildren this.showChildren = !this.showChildren

View File

@@ -13,7 +13,7 @@
<button class="icon" @click="toggleShowChildren"> <button class="icon" @click="toggleShowChildren">
<i class="material-icons" v-show="!showChildren && !isFiltered">arrow_right</i> <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" v-show="showChildren || isFiltered">arrow_drop_down</i>
<i v-if="picked === folderPath" class="text-green-400 material-icons">check_circle</i> <i v-if="isSelected" class="text-green-400 material-icons">check_circle</i>
<i v-else class="material-icons">folder_open</i> <i v-else class="material-icons">folder_open</i>
<span>{{ folder.name ? folder.name : folder.title }}</span> <span>{{ folder.name ? folder.name : folder.title }}</span>
</button> </button>
@@ -71,14 +71,7 @@
@edit-folder="$emit('edit-folder', $event)" @edit-folder="$emit('edit-folder', $event)"
@edit-request="$emit('edit-request', $event)" @edit-request="$emit('edit-request', $event)"
@update-team-collections="$emit('update-team-collections')" @update-team-collections="$emit('update-team-collections')"
@select-folder=" @select="$emit('select', $event)"
$emit('select-folder', {
name: subFolder.name + '/' + $event.name,
id: subFolder.id,
reqIdx: $event.reqIdx,
folderPath: $event.folderPath,
})
"
@remove-request="removeRequest" @remove-request="removeRequest"
/> />
</li> </li>
@@ -95,17 +88,13 @@
:folder-index="folderIndex" :folder-index="folderIndex"
:folder-name="folder.name" :folder-name="folder.name"
:request-index="index" :request-index="index"
:folder-path="folderPath"
:doc="doc" :doc="doc"
:picked="picked"
:saveRequest="saveRequest" :saveRequest="saveRequest"
:collectionsType="collectionsType" :collectionsType="collectionsType"
@edit-request="$emit('edit-request', $event)" @edit-request="$emit('edit-request', $event)"
@select-request=" @select="$emit('select', $event)"
$emit('select-folder', {
name: $event.name,
id: folder.id,
reqIdx: $event.idx,
})
"
@remove-request="removeRequest" @remove-request="removeRequest"
/> />
</li> </li>
@@ -135,8 +124,6 @@
<script> <script>
import { fb } from "~/helpers/fb" import { fb } from "~/helpers/fb"
import { getSettingSubject } from "~/newstore/settings" import { getSettingSubject } from "~/newstore/settings"
import * as team_utils from "~/helpers/teams/utils"
import gql from "graphql-tag"
export default { export default {
name: "folder", name: "folder",
@@ -149,7 +136,7 @@ export default {
saveRequest: Boolean, saveRequest: Boolean,
isFiltered: Boolean, isFiltered: Boolean,
collectionsType: Object, collectionsType: Object,
picked: { default: "", type: String }, picked: Object,
}, },
data() { data() {
return { return {
@@ -165,6 +152,15 @@ export default {
SYNC_COLLECTIONS: getSettingSubject("syncCollections"), SYNC_COLLECTIONS: getSettingSubject("syncCollections"),
} }
}, },
computed: {
isSelected() {
return (
this.picked &&
this.picked.pickedType === "my-folder" &&
this.picked.folderPath === this.folderPath
)
},
},
methods: { methods: {
syncCollections() { syncCollections() {
if (fb.currentUser !== null && this.SYNC_COLLECTIONS) { if (fb.currentUser !== null && this.SYNC_COLLECTIONS) {
@@ -176,11 +172,14 @@ export default {
}, },
toggleShowChildren() { toggleShowChildren() {
if (this.$props.saveRequest) if (this.$props.saveRequest)
this.$emit("select-folder", { this.$emit("select", {
name: "", picked: {
id: this.$props.folder.id, pickedType: "my-folder",
reqIdx: "",
folderPath: this.$props.folderPath, collectionIndex: this.collectionIndex,
folderName: this.folder.name,
folderPath: this.folderPath,
},
}) })
this.showChildren = !this.showChildren this.showChildren = !this.showChildren
}, },

View File

@@ -15,6 +15,9 @@
v-tooltip="!doc ? $t('use_request') : ''" v-tooltip="!doc ? $t('use_request') : ''"
> >
<span :class="getRequestLabelColor(request.method)">{{ request.method }}</span> <span :class="getRequestLabelColor(request.method)">{{ request.method }}</span>
<i v-if="isSelected" class="material-icons"> check </i>
<span>{{ request.name }}</span> <span>{{ request.name }}</span>
</button> </button>
</div> </div>
@@ -60,10 +63,6 @@
</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: {
request: Object, request: Object,
@@ -74,6 +73,18 @@ export default {
doc: Boolean, doc: Boolean,
saveRequest: Boolean, saveRequest: Boolean,
collectionsType: Object, collectionsType: Object,
folderPath: String,
picked: Object,
},
computed: {
isSelected() {
return (
this.picked &&
this.picked.pickedType === "my-request" &&
this.picked.folderPath === this.folderPath &&
this.picked.requestIndex === this.requestIndex
)
},
}, },
data() { data() {
return { return {
@@ -91,9 +102,15 @@ export default {
methods: { methods: {
selectRequest() { selectRequest() {
if (this.$props.saveRequest) if (this.$props.saveRequest)
this.$emit("select-request", { this.$emit("select", {
idx: this.$props.requestIndex, picked: {
name: this.$props.request.name, pickedType: "my-request",
collectionIndex: this.collectionIndex,
folderPath: this.folderPath,
folderName: this.folderName,
requestIndex: this.requestIndex,
},
}) })
else this.$store.commit("postwoman/selectRequest", { request: this.request }) else this.$store.commit("postwoman/selectRequest", { request: this.request })
}, },

View File

@@ -4,7 +4,9 @@
<button class="icon" @click="toggleShowChildren"> <button class="icon" @click="toggleShowChildren">
<i class="material-icons" v-show="!showChildren && !isFiltered">arrow_right</i> <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" v-show="showChildren || isFiltered">arrow_drop_down</i>
<i v-if="picked === collection.id" class="text-green-400 material-icons">check_circle</i>
<i v-if="isSelected" class="text-green-400 material-icons">check_circle</i>
<i v-else class="material-icons">folder</i> <i v-else class="material-icons">folder</i>
<span>{{ collection.title }}</span> <span>{{ collection.title }}</span>
</button> </button>
@@ -87,19 +89,13 @@
:saveRequest="saveRequest" :saveRequest="saveRequest"
:collectionsType="collectionsType" :collectionsType="collectionsType"
:isFiltered="isFiltered" :isFiltered="isFiltered"
:picked="picked"
@add-folder="$emit('add-folder', $event)" @add-folder="$emit('add-folder', $event)"
@edit-folder="$emit('edit-folder', $event)" @edit-folder="$emit('edit-folder', $event)"
@edit-request="$emit('edit-request', $event)" @edit-request="$emit('edit-request', $event)"
@select-folder=" @select="$emit('select', $event)"
$emit('select-folder', {
name: folder.title + '/' + $event.name,
id: $event.id,
reqIdx: $event.reqIdx,
})
"
@expand-collection="expandCollection" @expand-collection="expandCollection"
@remove-request="removeRequest" @remove-request="removeRequest"
:picked="picked.toString()"
/> />
</li> </li>
</ul> </ul>
@@ -118,14 +114,9 @@
:doc="doc" :doc="doc"
:saveRequest="saveRequest" :saveRequest="saveRequest"
:collectionsType="collectionsType" :collectionsType="collectionsType"
:picked="picked"
@edit-request="editRequest($event)" @edit-request="editRequest($event)"
@select-request=" @select="$emit('select', $event)"
$emit('select-folder', {
name: $event.name,
id: collection.id,
reqIdx: $event.idx,
})
"
@remove-request="removeRequest" @remove-request="removeRequest"
/> />
</li> </li>
@@ -154,10 +145,6 @@
</template> </template>
<script> <script>
import { fb } from "~/helpers/fb"
import { getSettingSubject } from "~/newstore/settings"
import gql from "graphql-tag"
export default { export default {
props: { props: {
collectionIndex: Number, collectionIndex: Number,
@@ -167,7 +154,7 @@ export default {
selected: Boolean, selected: Boolean,
saveRequest: Boolean, saveRequest: Boolean,
collectionsType: Object, collectionsType: Object,
picked: { default: "", type: String }, picked: Object,
}, },
data() { data() {
return { return {
@@ -180,19 +167,36 @@ export default {
pageNo: 0, pageNo: 0,
} }
}, },
computed: {
isSelected() {
return (
this.picked &&
this.picked.pickedType === "teams-collection" &&
this.picked.collectionID === this.collection.id
)
},
},
methods: { methods: {
editRequest(event) { editRequest(event) {
this.$emit("edit-request", event) this.$emit("edit-request", event)
if (this.$props.saveRequest) if (this.$props.saveRequest)
this.$emit("select-folder", { this.$emit("select", {
name: this.$data.collection.name, picked: {
id: this.$data.collection.id, pickedType: "teams-collection",
reqIdx: event.requestIndex,
collectionID: this.collection.id,
},
}) })
}, },
toggleShowChildren() { toggleShowChildren() {
if (this.$props.saveRequest) if (this.$props.saveRequest)
this.$emit("select-folder", { name: "", id: this.$props.collection.id, reqIdx: "" }) this.$emit("select", {
picked: {
pickedType: "teams-collection",
collectionID: this.collection.id,
},
})
this.$emit("expand-collection", this.collection.id) this.$emit("expand-collection", this.collection.id)
this.showChildren = !this.showChildren this.showChildren = !this.showChildren

View File

@@ -5,7 +5,9 @@
<button class="icon" @click="toggleShowChildren"> <button class="icon" @click="toggleShowChildren">
<i class="material-icons" v-show="!showChildren && !isFiltered">arrow_right</i> <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" v-show="showChildren || isFiltered">arrow_drop_down</i>
<i v-if="picked === folder.id" class="text-green-400 material-icons">check_circle</i>
<i v-if="isSelected" class="text-green-400 material-icons">check_circle</i>
<i v-else class="material-icons">folder_open</i> <i v-else class="material-icons">folder_open</i>
<span>{{ folder.name ? folder.name : folder.title }}</span> <span>{{ folder.name ? folder.name : folder.title }}</span>
</button> </button>
@@ -70,17 +72,12 @@
:saveRequest="saveRequest" :saveRequest="saveRequest"
:collectionsType="collectionsType" :collectionsType="collectionsType"
:folder-path="`${folderPath}/${subFolderIndex}`" :folder-path="`${folderPath}/${subFolderIndex}`"
:picked="picked"
@add-folder="$emit('add-folder', $event)" @add-folder="$emit('add-folder', $event)"
@edit-folder="$emit('edit-folder', $event)" @edit-folder="$emit('edit-folder', $event)"
@edit-request="$emit('edit-request', $event)" @edit-request="$emit('edit-request', $event)"
@update-team-collections="$emit('update-team-collections')" @update-team-collections="$emit('update-team-collections')"
@select-folder=" @select="$emit('select', $event)"
$emit('select-folder', {
name: subFolder.name + '/' + $event.name,
id: subFolder.id,
reqIdx: $event.reqIdx,
})
"
@expand-collection="expandCollection" @expand-collection="expandCollection"
@remove-request="removeRequest" @remove-request="removeRequest"
/> />
@@ -101,14 +98,9 @@
:doc="doc" :doc="doc"
:saveRequest="saveRequest" :saveRequest="saveRequest"
:collectionsType="collectionsType" :collectionsType="collectionsType"
:picked="picked"
@edit-request="$emit('edit-request', $event)" @edit-request="$emit('edit-request', $event)"
@select-request=" @select="$emit('select', $event)"
$emit('select-folder', {
name: $event.name,
id: folder.id,
reqIdx: $event.idx,
})
"
@remove-request="removeRequest" @remove-request="removeRequest"
/> />
</li> </li>
@@ -134,11 +126,6 @@
</template> </template>
<script> <script>
import { fb } from "~/helpers/fb"
import { getSettingSubject } from "~/newstore/settings"
import * as team_utils from "~/helpers/teams/utils"
import gql from "graphql-tag"
export default { export default {
name: "folder", name: "folder",
props: { props: {
@@ -150,7 +137,7 @@ export default {
saveRequest: Boolean, saveRequest: Boolean,
isFiltered: Boolean, isFiltered: Boolean,
collectionsType: Object, collectionsType: Object,
picked: { default: "", type: String }, picked: Object,
}, },
data() { data() {
return { return {
@@ -160,10 +147,25 @@ export default {
cursor: "", cursor: "",
} }
}, },
computed: {
isSelected() {
return (
this.picked &&
this.picked.pickedType === "teams-folder" &&
this.picked.folderID === this.folder.id
)
},
},
methods: { methods: {
toggleShowChildren() { toggleShowChildren() {
if (this.$props.saveRequest) if (this.$props.saveRequest)
this.$emit("select-folder", { name: "", id: this.$props.folder.id, reqIdx: "" }) this.$emit("select", {
picked: {
pickedType: "teams-folder",
folderID: this.folder.id,
},
})
this.$emit("expand-collection", this.$props.folder.id) this.$emit("expand-collection", this.$props.folder.id)
this.showChildren = !this.showChildren this.showChildren = !this.showChildren

View File

@@ -7,6 +7,8 @@
@click="!doc ? selectRequest() : {}" @click="!doc ? selectRequest() : {}"
v-tooltip="!doc ? $t('use_request') : ''" v-tooltip="!doc ? $t('use_request') : ''"
> >
<i v-if="isSelected" class="material-icons"> check </i>
<span :class="getRequestLabelColor(request.method)">{{ request.method }}</span> <span :class="getRequestLabelColor(request.method)">{{ request.method }}</span>
<span>{{ request.name }}</span> <span>{{ request.name }}</span>
</button> </button>
@@ -57,10 +59,6 @@
</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: {
request: Object, request: Object,
@@ -71,6 +69,7 @@ export default {
doc: Boolean, doc: Boolean,
saveRequest: Boolean, saveRequest: Boolean,
collectionsType: Object, collectionsType: Object,
picked: Object,
}, },
data() { data() {
return { return {
@@ -85,12 +84,23 @@ export default {
confirmRemove: false, confirmRemove: false,
} }
}, },
computed: {
isSelected() {
return (
this.picked &&
this.picked.pickedType === "teams-request" &&
this.picked.requestID === this.requestIndex
)
},
},
methods: { methods: {
selectRequest() { selectRequest() {
if (this.$props.saveRequest) if (this.$props.saveRequest)
this.$emit("select-request", { this.$emit("select", {
idx: this.$props.requestIndex, picked: {
name: this.$props.request.name, pickedType: "teams-request",
requestID: this.requestIndex,
},
}) })
else this.$store.commit("postwoman/selectRequest", { request: this.request }) else this.$store.commit("postwoman/selectRequest", { request: this.request })
}, },