Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FOUR-11846 - Return to Project List After Asset Creation #5681

Merged
merged 12 commits into from
Nov 29, 2023
42 changes: 42 additions & 0 deletions resources/js/components/shared/AssetRedirectMixin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
export default {
data() {
return {
redirectUrl: null,
};
},
mounted() {
this.setRedirectUrl();
ProcessMaker.EventBus.$on("redirect", () => {
this.handleRedirection();
});
},
computed: {
isProjectRoute() {
return window.location.pathname.startsWith("/designer/projects/");
},
},
methods: {
appendProjectIdToURL(url, projectId) {
if (this.isProjectRoute) {
url.searchParams.append("project_id", projectId);
}
},
setRedirectUrl() {
const queryParams = new URLSearchParams(window.location.search);
const projectId = queryParams.get("project_id");

if (projectId) {
this.redirectUrl = `/designer/projects/${projectId}`;
}
},
handleRedirection() {
return new Promise((resolve) => {
if (this.redirectUrl) {
window.location.href = this.redirectUrl;
resolve(true);
}
resolve(false);
});
},
},
};
2 changes: 2 additions & 0 deletions resources/js/components/shared/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import EllipsisMenu from "./EllipsisMenu";
import EnterPasswordModal from "../../processes/import/components/EnterPasswordModal.vue";
import FileUploadButton from "./FileUploadButton";
import FormErrorsMixin from "./FormErrorsMixin";
import AssetRedirectMixin from "./AssetRedirectMixin";
import IconSelector from "./IconSelector";
import Modal from "./Modal";
import PmqlInput from "./PmqlInput";
Expand Down Expand Up @@ -64,6 +65,7 @@ export {
EnterPasswordModal,
FileUploadButton,
FormErrorsMixin,
AssetRedirectMixin,
IconSelector,
Modal,
PmqlInput,
Expand Down